-
Notifications
You must be signed in to change notification settings - Fork 268
[DO NOT MERGE] - Timed mining Tests for Gammanet #3373
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
- Add bitcoin checkpoints - Update peg-in/pegout waiting block values - Change genesis federation keys and creation time - Set federation change authorizers keys - Set federation change period values - Set mainnet min block difficulty to the minimum value - Pre-load RBTC for genesis pegnatories, authorizers and cow address - Set genesis fee per kb value and authorizers keys - Set locking cap authorizers keys and initial value - Set whitelist authorizer key - Update version modifier
Dependency Review✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.Scanned FilesNone |
| bytes = Math.min(bytes, 256_000L); | ||
|
|
||
| StringBuilder data = new StringBuilder((int) bytes * 2); | ||
| for (int i = 0; i < bytes; i++) { |
Check failure
Code scanning / CodeQL
Comparison of narrow type with wide type in loop condition High
expression
expression
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix
AI 2 months ago
To fix the problem, update the type of the loop counter i so that it matches the type of the value it is compared against (bytes, which is a long). Specifically, change the loop from for (int i = 0; i < bytes; i++) to for (long i = 0; i < bytes; i++). No other code needs to change, since the StringBuilder and concatenation logic operate on the string and indices, not the type of i. This change should be made in the buildIntrinsicTx method in rskj-core/src/main/java/co/rsk/txload/TxLoadGeneratorService.java, lines 326–328.
No imports or other definitions are needed.
-
Copy modified line R326
| @@ -323,7 +323,7 @@ | ||
| bytes = Math.min(bytes, 256_000L); | ||
|
|
||
| StringBuilder data = new StringBuilder((int) bytes * 2); | ||
| for (int i = 0; i < bytes; i++) { | ||
| for (long i = 0; i < bytes; i++) { | ||
| data.append("01"); | ||
| } | ||
|
|
| if (nonZeroBytes > maxBytes) nonZeroBytes = maxBytes; | ||
|
|
||
| StringBuilder data = new StringBuilder((int) nonZeroBytes * 2); | ||
| for (int i = 0; i < nonZeroBytes; i++) { |
Check failure
Code scanning / CodeQL
Comparison of narrow type with wide type in loop condition High
expression
expression
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix
AI 2 months ago
To fix this problem, unify the loop counter and loop bound types by changing the indexing variable i from int to long in the for loop at line 401. This ensures that i can enumerate all values up to nonZeroBytes, no matter how large, and eliminates the possibility of overflow.
You should also ensure that the code using i inside the loop expected an int type; in this case, i only appears in the calculation (int) nonZeroBytes * 2 at the StringBuilder allocation, but this is before the loop, and in the loop body, i is not used as an index but in the for loop itself.
Therefore, you only need to change the type of i from int to long in that for loop.
No additional imports or definitions are needed.
-
Copy modified line R401
| @@ -398,7 +398,7 @@ | ||
| if (nonZeroBytes > maxBytes) nonZeroBytes = maxBytes; | ||
|
|
||
| StringBuilder data = new StringBuilder((int) nonZeroBytes * 2); | ||
| for (int i = 0; i < nonZeroBytes; i++) { | ||
| for (long i = 0; i < nonZeroBytes; i++) { | ||
| data.append("01"); | ||
| } | ||
|
|
Description
This is just for testing the timed mining feature on Gammanet
Motivation and Context
How Has This Been Tested?
Types of changes
Checklist: