fix(dash-spv): preserve buffered block headers across disconnect#702
fix(dash-spv): preserve buffered block headers across disconnect#702xdustinface wants to merge 1 commit intov0.42-devfrom
Conversation
`BlockHeadersManager::clear_in_flight_state` rebuilt the entire `HeadersPipeline` on every disconnect, throwing away each segment's `current_tip_hash`, `current_height`, `buffered_headers`, and `complete` flags. This PR splits it so that `SegmentState::clear_in_flight` and `HeadersPipeline::clear_in_flight` now reset only the `DownloadCoordinator` per segment. `BlockHeadersManager::clear_in_flight_state` calls the pipeline-level helper instead of constructing a new pipeline. `start_sync` skips `pipeline.init` when the pipeline is already initialized and calls `reset_tip_segment` so a previously synced tip is prepared to let `send_pending` re-fire `GetHeaders`. Adds unit coverage for the new clear path at the segment, pipeline, and manager levels (mid-sync and post-sync disconnect/reconnect cycles), plus a header-progress monotonicity assertion in `run_disconnect_loop` so the dashd integration tests catch a future regression that drops validated chain state on disconnect.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (5)
📝 WalkthroughWalkthroughThis PR refactors the block header synchronization pipeline to preserve segment state and per-segment progress during peer disconnection/reconnection. It introduces a Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~22 minutes Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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. Review rate limit: 0/1 reviews remaining, refill in 60 minutes.Comment |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## v0.42-dev #702 +/- ##
=============================================
+ Coverage 70.58% 70.64% +0.06%
=============================================
Files 320 320
Lines 68028 68172 +144
=============================================
+ Hits 48018 48162 +144
Misses 20010 20010
|
BlockHeadersManager::clear_in_flight_staterebuilt the entireHeadersPipelineon every disconnect, throwing away each segment'scurrent_tip_hash,current_height,buffered_headers, andcompleteflags.This PR splits it so that
SegmentState::clear_in_flightandHeadersPipeline::clear_in_flightnow reset only theDownloadCoordinatorper segment.BlockHeadersManager::clear_in_flight_statecalls the pipeline-level helper instead of constructing a new pipeline.start_syncskipspipeline.initwhen the pipeline is already initialized and callsreset_tip_segmentso a previously synced tip is prepared to letsend_pendingre-fireGetHeaders.Adds unit coverage for the new clear path at the segment, pipeline, and manager levels (mid-sync and post-sync disconnect/reconnect cycles), plus a header-progress monotonicity assertion in
run_disconnect_loopso the dashd integration tests catch a future regression that drops validated chain state on disconnect.Summary by CodeRabbit
Tests
Refactor