Skip to content

fix: Handle missing blocks to prevent sync stall#257

Merged
quake merged 3 commits intonervosnetwork:developfrom
eval-exec:exec/fix-clean-up-matched-blocks-at-startup
Dec 30, 2025
Merged

fix: Handle missing blocks to prevent sync stall#257
quake merged 3 commits intonervosnetwork:developfrom
eval-exec:exec/fix-clean-up-matched-blocks-at-startup

Conversation

@eval-exec
Copy link
Contributor

@eval-exec eval-exec commented Dec 10, 2025

This PR want to fix a bug:
When the filter protocol matches blocks, they're added to matched_blocks and we request their proofs/data. The batch waits until all blocks are downloaded before processing. However, some matched blocks may be uncle blocks (orphaned from old forks) or blocks peers don't have. When peers respond with missing_block_hashes, these blocks remain in matched_blocks, causing the batch to stall indefinitely waiting for blocks that will never arrive.

Changes:

  1. When blocks are marked as missing in send_blocks_proof.rs, remove them from matched_blocks
  2. Add periodic cleanup (1 hour) for old missing headers in fetching_headers
  3. Skip blocks marked as missing when recovering matched blocks from storage

@eval-exec
Copy link
Contributor Author

eval-exec commented Dec 10, 2025

Request for @Officeyutong @driftluo @zhangsoledad @quake @chenyukang @gpBlockchain 's review.

@eval-exec eval-exec force-pushed the exec/fix-clean-up-matched-blocks-at-startup branch from 033eace to 9a14f1c Compare December 10, 2025 06:03
@eval-exec eval-exec marked this pull request as draft December 10, 2025 06:06
@eval-exec eval-exec changed the title clean invalid matched blocks at startup fix: Handle missing blocks to prevent sync stall Dec 26, 2025
@eval-exec eval-exec force-pushed the exec/fix-clean-up-matched-blocks-at-startup branch from 9a14f1c to 657a0ce Compare December 26, 2025 13:28
@eval-exec eval-exec marked this pull request as ready for review December 26, 2025 13:28
@eval-exec eval-exec force-pushed the exec/fix-clean-up-matched-blocks-at-startup branch 2 times, most recently from 72087ed to a8c2c94 Compare December 29, 2025 07:43
@codecov-commenter
Copy link

Codecov Report

❌ Patch coverage is 70.71429% with 41 lines in your changes missing coverage. Please review.
✅ Project coverage is 72.01%. Comparing base (c9d489d) to head (a8c2c94).
⚠️ Report is 1 commits behind head on develop.

Files with missing lines Patch % Lines
...ht-client-lib/src/protocols/filter/block_filter.rs 55.55% 12 Missing ⚠️
...ocols/light_client/components/send_blocks_proof.rs 65.38% 9 Missing ⚠️
light-client-lib/src/protocols/synchronizer.rs 52.94% 8 Missing ⚠️
...ght-client-lib/src/protocols/light_client/peers.rs 80.64% 6 Missing ⚠️
light-client-lib/src/storage/db/native.rs 72.22% 5 Missing ⚠️
light-client-lib/src/protocols/light_client/mod.rs 91.66% 1 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##           develop     #257      +/-   ##
===========================================
- Coverage    72.04%   72.01%   -0.04%     
===========================================
  Files           28       28              
  Lines         6937     7042     +105     
===========================================
+ Hits          4998     5071      +73     
- Misses        1939     1971      +32     
Flag Coverage Δ
unittests 72.01% <70.71%> (-0.04%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@eval-exec eval-exec force-pushed the exec/fix-clean-up-matched-blocks-at-startup branch from a8c2c94 to a33c23d Compare December 30, 2025 04:05
@eval-exec eval-exec requested a review from driftluo December 30, 2025 04:05
Signed-off-by: Eval EXEC <execvy@gmail.com>
@eval-exec eval-exec force-pushed the exec/fix-clean-up-matched-blocks-at-startup branch from a33c23d to 7835653 Compare December 30, 2025 05:49
@quake quake merged commit 7249e8c into nervosnetwork:develop Dec 30, 2025
7 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.

4 participants