fix(eth/downloader): don't mistake a lagging header head for a stalling peer - #2515
fix(eth/downloader): don't mistake a lagging header head for a stalling peer#2515gzliudan 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 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
Fixes false errStallingPeer detection during fast sync when block imports temporarily move the current header backward.
Changes:
- Tracks the highest successfully inserted header for the current sync cycle.
- Uses that header for the terminating TD check when
CurrentHeaderlags. - Adds regression tests across supported protocol versions.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
eth/downloader/downloader.go |
Corrects the fast/light sync stalling-peer check. |
eth/downloader/downloader_test.go |
Simulates header-head lag and verifies successful fast sync. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
…ng peer Importing the post-pivot blocks moves the header head back to the block being inserted, so CurrentHeader can trail the headers the peer already delivered. When processHeaders reached the terminating batch inside that window, the fast sync TD check saw a head below the promised total difficulty and returned errStallingPeer, which rolled the whole chain back and dropped the only peer. Track the highest header written to the light chain in this cycle and use it when it is ahead of CurrentHeader. Attack detection is unchanged: a peer that bails out of delivering the post-pivot headers never advances it. This is what made TestFastSyncDisabling flaky under load: once the peer was dropped, BestPeer stayed nil and the sync loop could never recover.
6d0fc63 to
860f906
Compare
Proposed changes
Importing the post-pivot blocks moves the header head back to the block being inserted, so CurrentHeader can trail the headers the peer already delivered. When processHeaders reached the terminating batch inside that window, the fast sync TD check saw a head below the promised total difficulty and returned errStallingPeer, which rolled the whole chain back and dropped the only peer.
Track the highest header written to the light chain in this cycle and use it when it is ahead of CurrentHeader. Attack detection is unchanged: a peer that bails out of delivering the post-pivot headers never advances it.
This is what made TestFastSyncDisabling flaky under load: once the peer was dropped, BestPeer stayed nil and the sync loop could never recover.
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