Skip to content

Sf 1.12.0#7483

Draft
raduchis wants to merge 57 commits intorc/supernovafrom
SF-1.12.0
Draft

Sf 1.12.0#7483
raduchis wants to merge 57 commits intorc/supernovafrom
SF-1.12.0

Conversation

@raduchis
Copy link
Contributor

Reasoning behind the pull request

Proposed changes

Testing procedure

Pre-requisites

Based on the Contributing Guidelines the PR author and the reviewers must check the following requirements are met:

  • was the PR targeted to the correct branch?
  • if this is a larger feature that probably needs more than one PR, is there a feat branch created?
  • if this is a feat branch merging, do all satellite projects have a proper tag inside go.mod?

raduchis and others added 26 commits May 19, 2025 12:02
# Conflicts:
#	consensus/spos/bls/constants.go
#	consensus/spos/consensusMessageValidator.go
#	go.mod
#	go.sum
#	process/block/metablock.go
# Conflicts:
#	process/sync/baseForkDetector.go
if roundsPerEpochUint < minRoundModulus {
log.Warn("epochfastforward rounds per epoch too small", "rounds", roundsPerEpoch, "minRoundModulus", minRoundModulus)
roundsPerEpochUint = minRoundModulus
}

Check failure

Code scanning / CodeQL

Incorrect conversion between integer types High

Incorrect conversion of a signed 64-bit integer from
strconv.ParseInt
to a lower bit size type int without an upper bound check.

Copilot Autofix

AI 3 months ago

To fix this issue, we must ensure that the value parsed for epochs does not exceed the range (upper and lower bounds) of the destination type (int) before casting.

  • The safest route is to check if epochs is within [0, math.MaxInt) (or, guard negative values, or make a stricter minimum if negative values are not allowed) and less than or equal to math.MaxInt (from the math package).
  • If out of bounds, the code can log an error and either return or clip epochs to a safe value (like 0), depending on desired semantics.
  • The change will be in the epochsFastForward function. We'll need to import the math package (already imported).
  • Edit the block to add a bounds check for epochs before casting to int, and assign a default value (0) or exit early with a warning if out of bounds.

Suggested changeset 1
process/block/metablock.go

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/process/block/metablock.go b/process/block/metablock.go
--- a/process/block/metablock.go
+++ b/process/block/metablock.go
@@ -2810,11 +2810,13 @@
 	epochs, err := strconv.ParseInt(tokens[1], 10, 64)
 	if err != nil {
 		log.Error("epochfastforward", "epochs could not be parsed", tokens[1])
+		return
 	}
 
 	roundsPerEpoch, err := strconv.ParseInt(tokens[2], 10, 64)
 	if err != nil {
 		log.Error("epochfastforward", "rounds could not be parsed", tokens[2])
+		return
 	}
 	roundsPerEpochUint := uint64(roundsPerEpoch)
 
@@ -2823,6 +2820,10 @@
 		roundsPerEpochUint = minRoundModulus
 	}
 
+	if epochs < 0 || epochs > int64(^uint(0)>>1) {
+		log.Error("epochfastforward", "epochs value out of int bounds", epochs)
+		return
+	}
 	mp.nrEpochsChanges = int(epochs)
 	mp.roundsModulus = roundsPerEpochUint
 
EOF
@@ -2810,11 +2810,13 @@
epochs, err := strconv.ParseInt(tokens[1], 10, 64)
if err != nil {
log.Error("epochfastforward", "epochs could not be parsed", tokens[1])
return
}

roundsPerEpoch, err := strconv.ParseInt(tokens[2], 10, 64)
if err != nil {
log.Error("epochfastforward", "rounds could not be parsed", tokens[2])
return
}
roundsPerEpochUint := uint64(roundsPerEpoch)

@@ -2823,6 +2820,10 @@
roundsPerEpochUint = minRoundModulus
}

if epochs < 0 || epochs > int64(^uint(0)>>1) {
log.Error("epochfastforward", "epochs value out of int bounds", epochs)
return
}
mp.nrEpochsChanges = int(epochs)
mp.roundsModulus = roundsPerEpochUint

Copilot is powered by AI and may make mistakes. Always verify output.
@github-actions
Copy link

Integration Tests completed with failures or errors.

📊 MultiversX Automated Test Report: View Report

🔄 Build Details:

  • mx-chain-go Commit Hash: d7155d42c1660907241644503a7a7fec4d764182
  • Current Branch: SF-1.12.0
  • mx-chain-go Target Branch: rc/supernova
  • mx-chain-simulator-go Target Branch: rc/supernova
  • mx-chain-simulator-go Commit Hash: 6d12db1fee8d6bbd7a24f422a215b554a93450a7
  • mx-chain-testing-suite Target Branch: rc/supernova
  • mx-chain-testing-suite Commit Hash: 171a49d4a8d9b0a35c8a4a4c146fc34933c5a416

🚀 Environment Variables:

  • TIMESTAMP: 2025_DECEMBER_15__14_25_19
  • PYTEST_EXIT_CODE: 1

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.

3 participants