fix(core): prevent --set-head startup rewind overshooting to N-1, close #2465#2467
fix(core): prevent --set-head startup rewind overshooting to N-1, close #2465#2467gzliudan wants to merge 1 commit into
Conversation
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Pull request overview
Fixes an off-by-one boundary in the blockchain startup repair path when --set-head (via common.RollbackNumber) is set, preventing the repair rewind loop from overshooting the intended rollback target and causing a fatal “can’t rollback … greater than current …” error.
Changes:
- Adjust
BlockChain.repairtermination condition to include the rollback target height (<=), so repair can stop exactly at the requested block when state is available. - Add a regression test to ensure startup repair respects the rollback target and does not rewind below it when the target state exists.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| core/blockchain.go | Fix off-by-one in startup repair rewind boundary when common.RollbackNumber is set. |
| core/blockchain_test.go | Add regression test validating repair stops at the rollback target when state exists. |
XinFinOrg#2465 Fix an off-by-one boundary in startup repair when RollbackNumber is set from --set-head. Repair now accepts the target height (<=) so startup does not rewind past N and fail with 'can't rollback to N which is greater than current N-1'. Add a regression test to ensure startup repair stops at the requested rollback block when state exists.
Proposed changes
Fix issue #2465: an off-by-one boundary in startup repair when RollbackNumber is set from --set-head.
Repair now accepts the target height (<=) so startup does not rewind past N and fail with 'can't rollback to N which is greater than current N-1'.
Add a regression test to ensure startup repair stops at the requested rollback block when state exists.
Types of changes
What types of changes does your code introduce to XDC network?
Put an
✅in the boxes that applyImpacted Components
Which parts of the codebase does this PR touch?
Put an
✅in the boxes that applyChecklist
Put an
✅in the boxes once you have confirmed below actions (or provide reasons on not doing so) that