Open
Conversation
…Exception for extraData length validation
…t and enhance test coverage for gap block snapshots
Contributor
There was a problem hiding this comment.
Pull request overview
Adds XDC chain support around the V1→V2 switch boundary so fast-sync snapshot bootstrapping and reward/epoch calculations behave correctly when SwitchBlock != 0.
Changes:
- Add
ParseV1Masternodesto parse masternode addresses from V1-formatExtraData, and reuse it for genesis parsing whenSwitchBlock == 0. - Bootstrap an initial snapshot when the computed gap lands on the switch boundary.
- Adjust epoch-switch/reward logic to treat pre-switch blocks as V1 epoch checkpoints and to skip
SwitchBlock + 1.
Reviewed changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| src/Nethermind/Nethermind.Xdc/XdcStateSyncSnapshotManager.cs | Stores an initial snapshot when the gap calculation aligns with SwitchBlock. |
| src/Nethermind/Nethermind.Xdc/XdcRewardCalculator.cs | Skips SwitchBlock+1 and uses V1 masternode parsing for headers <= SwitchBlock. |
| src/Nethermind/Nethermind.Xdc/XdcExtensions.cs | Introduces ParseV1Masternodes helper for V1 ExtraData. |
| src/Nethermind/Nethermind.Xdc/Spec/XdcChainSpecBasedSpecProvider.cs | Uses ParseV1Masternodes to derive genesis masternodes when SwitchBlock == 0. |
| src/Nethermind/Nethermind.Xdc/EpochSwitchManager.cs | Treats pre-switch epoch switches as blockNumber % EpochLength == 0. |
| src/Nethermind/Nethermind.Xdc.Test/XdcStateSyncSnapshotManagerTests.cs | Adds coverage for the “gap lands on switch block” snapshot bootstrapping case. |
| src/Nethermind/Nethermind.Xdc.Test/ModuleTests/RewardTests.cs | Updates reward test setup so block 0 uses V1 ExtraData format when SwitchBlock == 0. |
| src/Nethermind/Nethermind.Xdc.Test/Helpers/XdcTestHelper.cs | Adds helper to build V1-format ExtraData for tests. |
| src/Nethermind/Nethermind.Xdc.Test/EpochSwitchManagerTests.cs | Adds tests for IsEpochSwitchAtBlock behavior pre-switch. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
7 tasks
ak88
approved these changes
Mar 12, 2026
alexb5dh
approved these changes
Mar 12, 2026
| return spec; | ||
| } | ||
|
|
||
| public static Address[] ParseV1Masternodes(this byte[] extraData) |
Contributor
There was a problem hiding this comment.
Maybe would be better to make it an extension to BlockHeader? byte[] is a very commonly use object, and this is not really related.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Changes
ParseV1Masternodesextension method toXdcExtensionsto parse masternodes from V1 headersXdcStateSyncSnapshotManagerXdcRewardCalculatorTwo missing checks for non-zero SwitchBlock: skip
SwitchBlock+1and use v1 masternode parsing ifnumber <= SwitchBlock. WithSwitchBlock=0it worked by accident.Refer:
Types of changes
What types of changes does your code introduce?
Testing
Requires testing
If yes, did you write tests?