Skip to content

Conversation

@italo-sampaio
Copy link
Collaborator

Description

This is just for testing the timed mining feature on Gammanet

Motivation and Context

How Has This Been Tested?

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)

Checklist:

  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • Tests for the changes have been added (for bug fixes / features)
  • Requires Activation Code (Hard Fork)
  • Other information:

marcos-iov and others added 6 commits October 24, 2025 13:56
- 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
@github-actions
Copy link

Dependency Review

✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.

Scanned Files

None

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

Comparison between
expression
of type int and
expression
of wider type long.

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.

Suggested changeset 1
rskj-core/src/main/java/co/rsk/txload/TxLoadGeneratorService.java

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/rskj-core/src/main/java/co/rsk/txload/TxLoadGeneratorService.java b/rskj-core/src/main/java/co/rsk/txload/TxLoadGeneratorService.java
--- a/rskj-core/src/main/java/co/rsk/txload/TxLoadGeneratorService.java
+++ b/rskj-core/src/main/java/co/rsk/txload/TxLoadGeneratorService.java
@@ -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");
         }
 
EOF
@@ -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");
}

Copilot is powered by AI and may make mistakes. Always verify output.
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

Comparison between
expression
of type int and
expression
of wider type long.

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.


Suggested changeset 1
rskj-core/src/main/java/co/rsk/txload/TxLoadGeneratorService.java

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/rskj-core/src/main/java/co/rsk/txload/TxLoadGeneratorService.java b/rskj-core/src/main/java/co/rsk/txload/TxLoadGeneratorService.java
--- a/rskj-core/src/main/java/co/rsk/txload/TxLoadGeneratorService.java
+++ b/rskj-core/src/main/java/co/rsk/txload/TxLoadGeneratorService.java
@@ -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");
         }
 
EOF
@@ -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");
}

Copilot is powered by AI and may make mistakes. Always verify output.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants