Skip to content

fix(net): correct sync completion and chain summary request timeouts - #92

Merged
317787106 merged 3 commits into
release_v4.8.3from
fix/sync_complete
Sep 24, 2026
Merged

317787106 merged 3 commits into
release_v4.8.3from
fix/sync_complete

Conversation

@317787106

@317787106 317787106 commented Sep 14, 2026 •

Copy link
Copy Markdown
Owner

What does this PR do?

Add a response timeout for outstanding chain-summary requests and harden chain-inventory validation, while preserving upload-direction state when the local download finishes.

  • Check syncChainRequested against the existing five-second SYNC_TIME_OUT, using the original request timestamp. The existing periodic status check disconnects the responsible peer with TIME_OUT after the threshold is exceeded, regardless of sync direction flags. PING/PONG, valid inbound requests, and other block progress do not extend this deadline.
  • Reject negative remaining-block counts and prevent arithmetic overflow from bypassing the existing future-height limit. Validate responses against the captured request before clearing it or changing peer state.
  • For a known single-block response from the requested summary with zero remaining blocks, reset remainNum and finish the local download. Preserve needSyncFromUs for both the summary tail and earlier blocks: an existing upload requirement remains active, and a new one is not inferred from the response.
  • Retain TronState.SYNC_COMPLETED so a later download can restart. Unknown queued blocks still follow the fetch path, and normal multi-block validation and paged downloads remain in place.

Why are these changes required?

The existing block-progress timeout does not provide a deadline tied to an individual chain-summary request. A peer must answer that request even when other traffic or block activity continues.

A single-block response also does not initiate a download on the remote peer. For example, if our summary ends at block 100 and an existing peer replies with the known block 50, setting needSyncFromUs=true locally can suppress normal inventory exchange while waiting for a remote download that never starts. Preserving the upload flag keeps BLOCK/TRX inventory exchange compatible with existing peers and retains any upload synchronization already in progress.

This PR has been tested by:

  • Local ARM64 / JDK 17 validation: 55 tests passed across nine related classes, including 30 tests added by this PR, with zero failures, errors, or skipped tests.
  • A regression exercises the existing remote summary handler, processes its earlier single-block reply locally, and verifies that subsequent BLOCK/TRX inventories are accepted and scheduled.
  • Additional coverage includes summary-tail and earlier-block responses, upload-direction preservation, head advancement, restarting downloads, unknown queued blocks, paged responses, malformed counts and ranges, and timeout attribution. Real message-dispatch tests verify that PING/PONG and successful inbound sync requests do not renew the outgoing request deadline.
  • Existing regression classes: ChainInventoryMsgHandlerTest, SyncBlockChainMsgHandlerTest, SyncServiceTest, PeerStatusCheckTest, PeerStatusCheckMockTest, PeerConnectionTest, and InventoryMsgHandlerTest.
  • ./gradlew checkstyleMain checkstyleTest: passed.
  • Semgrep (p/java, p/security-audit, p/owasp-top-ten): two changed production files, 93 applicable rules, zero findings or parsing errors.
  • Full-repository tests and live mixed-version network tests have not been run.

Follow up

Ending the local download still trusts the peer's claim that no blocks remain. A peer can echo an earlier known summary block while withholding newer blocks; this PR does not verify the peer's actual head. Chain-inventory responses do not receive block contribution credit.

When integrating with #90, retain both Hello and chain-summary timeout checks in the common status-check flow. Integration assumes the separate libp2p fixes from its v2.3.0 branch and the MessageCount concurrency fix from another developer's PR are available. No dependency update is included here.

Extra details

Targets release_v4.8.3. Production changes are limited to ChainInventoryMsgHandler and PeerStatusCheck. Public interfaces, wire formats, database formats, and configuration remain unchanged; the implementation uses Java 8-compatible APIs. Active head probing and the block-fetch changes in #91 are outside this PR.

@317787106 317787106 changed the title fix(net): fix the bug of marking sync complete when blockIdWeGet don't equal re… fix(net): correct sync completion and chain summary request timeouts Sep 14, 2026
@317787106
317787106 changed the base branch from release_v4.8.3 to develop September 23, 2026 09:16
@317787106
317787106 changed the base branch from develop to release_v4.8.3 September 23, 2026 09:16
@317787106
317787106 merged commit c208141 into release_v4.8.3 Sep 24, 2026
13 checks passed
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