Skip to content

fix(net): reject inconsistent terminal sync replies - #104

Closed
317787106 wants to merge 3 commits into
release_v4.8.3from
fix/sync-terminal-inventory
Closed

317787106 wants to merge 3 commits into
release_v4.8.3from
fix/sync-terminal-inventory

Conversation

@317787106

@317787106 317787106 commented Nov 2, 2026 •

Copy link
Copy Markdown
Owner

What does this PR do?

Reject terminal (remain_num=0) chain inventory replies whose last block height is below the peer's HELLO head or a recent BLOCK announcement received before the sync request. Also reject multi-block terminal replies whose final block already appears in the requested summary. Disconnect inconsistent replies with SYNC_FAIL.

Why are these changes required?

A peer can announce and deliver newer blocks while answering a sync request with only a block already known locally. Accepting that reply marks the connection synchronized without identifying the missing blocks. The validation prevents these contradictory replies from being accepted.

This PR has been tested by:

  • 43 targeted unit tests in ChainInventoryMsgHandlerTest, InventoryMsgHandlerTest, and SyncServiceTest.
  • ./gradlew clean build -x test.
  • ./gradlew :framework:checkstyleMain :framework:checkstyleTest :plugins:checkstyleMain.
  • bash .github/scripts/check_math_usage.sh and git diff --check.
  • Compared the validation conditions with the supplied synchronization-delay logs; no live-node test was performed. The full test suite was not run.

Follow up

Evaluate proactive synchronization recovery separately.

Extra details

Fork rollbacks can temporarily contradict a previous handshake or summary snapshot. Use a synchronization failure so the peer can reconnect with a fresh handshake.

Restore terminal chain inventory checks against the HELLO head and requested summary, and reject replies below recent block announcements received before the request.

Resume synchronization with a random eligible peer through the existing fetch worker after a syncing peer disconnects. Cover source selection, retries, and recovery of previously discarded blocks.
Keep terminal chain inventory validation and its tests focused in this PR. Restore SyncService and SyncServiceTest to release_v4.8.3 so proactive source recovery can be reviewed separately.
@317787106 317787106 changed the title fix(net): reject inconsistent sync replies and retry another peer fix(net): reject inconsistent terminal sync replies Nov 3, 2026
Rename advertisedNum to maxAdvInvNum and adjust the inventory validation comment and stream formatting without changing validation behavior.
@317787106 317787106 closed this Nov 3, 2026
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