Skip to content

fix(sync): sync distant P2P data heads by range - #3421

Draft
jgimeno wants to merge 1 commit into
evstack:mainfrom
jgimeno:jgimeno/fix-p2p-data-range-sync
Draft

fix(sync): sync distant P2P data heads by range#3421
jgimeno wants to merge 1 commit into
evstack:mainfrom
jgimeno:jgimeno/fix-p2p-data-range-sync

Conversation

@jgimeno

@jgimeno jgimeno commented Aug 3, 2026

Copy link
Copy Markdown
Contributor

Overview

Fix P2P data head verification so non-adjacent heads are accepted as provisional sync targets instead of triggering repeated bifurcation requests.

P2PData.Verify previously compared the trusted data hash with LastDataHash for every candidate. That linkage is only meaningful for adjacent heights: a distant head points to its immediate predecessor, not the node's current local head. As a result, distant heads soft-failed verification and go-header fetched intermediate heights repeatedly before starting normal range sync (258 GetByHeight calls when catching up from height 1 to 64 in the regression).

The verification now checks data-hash linkage only for adjacent heights. Non-adjacent heads can become provisional sync targets, after which the downloaded range is verified link by link. Adjacent candidates with an invalid LastDataHash are still rejected.

Validation

  • go test ./... -count=1
  • go test ./pkg/sync -run TestDataSyncerDistantHeadUsesRangeSync -count=50
  • go test -race ./pkg/sync -run TestDataSyncerDistantHeadUsesRangeSync -count=1
  • go test ./types -run TestP2PDataVerifyAdjacentHeads -count=50
  • go vet ./types ./pkg/sync
  • git diff --check

@coderabbitai

coderabbitai Bot commented Aug 3, 2026

Copy link
Copy Markdown
Contributor

Important

Review skipped

Draft detected.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 96fcbb6b-ce19-487c-8efe-1a3d58212d9a

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

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.

1 participant