fix: split blocks at gap in import - #2522
Conversation
in order to fix fastsync snapshot err
|
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 Plus Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
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
Splits downloaded block imports at XDPoS gap blocks to ensure snapshots exist before subsequent header verification.
Changes:
- Adds gap-aware block segmentation.
- Imports each segment sequentially with existing error handling.
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| // block's snapshot exists before the next segment's headers are verified. For | ||
| // non-XDPoS chains (or when there is nothing to split) the whole batch is | ||
| // returned as a single segment. | ||
| func (d *Downloader) splitBlocksAtGap(blocks []*types.Block) [][]*types.Block { |
Proposed changes
in order to fix fastsync snapshot err, when inserting a batch of blocks, it split the batch into multiple batches that do not contain gap block inside (except for boarder).
tested on a mainnet fast sync new node
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