fix(dash-spv): prevent filter sync stalls from stale progress guards#754
fix(dash-spv): prevent filter sync stalls from stale progress guards#754xdustinface wants to merge 3 commits into
Conversation
…ders` The guard `stored_height < filter_header_tip_height` fails to trigger scanning when filters are fully stored but not yet committed to wallet. After a restart where `stored_height` equals the tip, the guard evaluates to false and the manager silently stalls. Using `committed_height` correctly detects uncommitted work. Also conditionally skip `send_pending` when `stored_height` already covers the tip, avoiding unnecessary download operations when only scan work is needed.
`start_sync` calls `update_filter_header_tip_height(stored_filters_tip)` on reconnection, which can be lower than the tip already set by `handle_new_filter_headers`. This regresses the download target and causes the pipeline to lose knowledge of available filter headers. Apply the same monotonic guard pattern already used by `update_target_height`.
…headers `take_pending` removes batches from the coordinator's pending queue. If `get_header` then returns `None` (header not yet stored), the batch is permanently lost because it's neither pending nor in-flight. Re-queue via `coordinator.enqueue` and continue to the next batch instead. Also add a second `try_commit_batches` pass after `scan_ready_batches` in `try_process_batch` so that single-block incremental updates are committed in the same tick rather than waiting for the next one.
📝 WalkthroughWalkthroughThe PR optimizes filter synchronization robustness by enforcing monotonic progress tracking, refining manager state logic to use committed heights, allowing inline batch commits, and gracefully handling missing batch headers. Three modules coordinate these changes with corresponding test coverage. ChangesFilter Sync Resilience and Commit Optimization
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 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. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
dash-spv/src/sync/filters/manager.rs (1)
426-431: 💤 Low valueConsider whether
try_create_lookahead_batchesbenefits from the same in-tick commit.The added Phase 3 cleanly removes the one-tick delay for incremental updates already in
active_batchesat entry. However,try_create_lookahead_batches(Phase 4) may itself create andscan_batcha small lookahead batch withpending_blocks == 0; that batch then sits scanned-but-uncommitted until the nexttry_process_batchcall. If incremental tips routinely arrive via the lookahead path (e.g., during steady-state catch-up of small ranges), a fourth commit pass after Phase 4 would close that gap too. Optional — the documented use case (incremental single-block updates feeding an existing batch) is already covered.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@dash-spv/src/sync/filters/manager.rs` around lines 426 - 431, The new Phase 4 (try_create_lookahead_batches) can create and scan small lookahead batches that remain uncommitted until the next tick; add a final in-tick commit pass after try_create_lookahead_batches by invoking the same commit logic (try_commit_batches) again so any newly-created scanned-but-uncommitted lookahead batches are committed immediately; locate the sequence around try_commit_batches(), try_create_lookahead_batches() in manager.rs and insert a second await of try_commit_batches() (or otherwise call the underlying commit routine) after the call to try_create_lookahead_batches() to ensure no scanned batches are left uncommitted this tick.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@dash-spv/src/sync/filters/manager.rs`:
- Around line 426-431: The new Phase 4 (try_create_lookahead_batches) can create
and scan small lookahead batches that remain uncommitted until the next tick;
add a final in-tick commit pass after try_create_lookahead_batches by invoking
the same commit logic (try_commit_batches) again so any newly-created
scanned-but-uncommitted lookahead batches are committed immediately; locate the
sequence around try_commit_batches(), try_create_lookahead_batches() in
manager.rs and insert a second await of try_commit_batches() (or otherwise call
the underlying commit routine) after the call to try_create_lookahead_batches()
to ensure no scanned batches are left uncommitted this tick.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 489bcd1b-6cd3-442c-838d-c24ae0fa5558
📒 Files selected for processing (3)
dash-spv/src/sync/filters/manager.rsdash-spv/src/sync/filters/pipeline.rsdash-spv/src/sync/filters/progress.rs
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## v0.42-dev #754 +/- ##
=============================================
+ Coverage 72.22% 72.27% +0.04%
=============================================
Files 320 320
Lines 69631 69745 +114
=============================================
+ Hits 50294 50405 +111
- Misses 19337 19340 +3
|
committed_heightinstead ofstored_heightin thehandle_new_filter_headersguard so the manager detects uncommitted work after restartfilter_header_tip_heightmonotonic to preventstart_syncfrom regressing the tip on reconnectionsend_pendingwhen block headers are unavailable instead of permanently losing themtry_commit_batchespass after scan to eliminate one-tick delay for incremental updatesSummary by CodeRabbit
Release Notes
Bug Fixes
Improvements
Tests