Repository navigation
Description
Crate: dash-spv
Rev observed: 981e97f1015960ae5d277afdabcba1cbbc0b3a63
Network: Testnet (core chain ~1,502,6xx)
Severity: High — a single mistimed block permanently wedges sync with no client-side recovery.
Summary
After a DashSpvClient restart in which compact-filter headers are already persisted up to the chain tip, a core block that arrives during the client's reinit window falls into a one-block gap between the from-genesis filter-body rescan and the live tip tracker. That block's compact-filter body is never requested or committed, so the Filters phase committed_height freezes one block below the chain tip — permanently. Because SyncProgress::is_synced() requires the Filters phase to be Synced, it stays false forever, and every downstream consumer reads the client as "syncing" indefinitely even though the chain, filter headers, masternodes, and chainlocks are all fully synced.
This was observed in a host application (Dash Evo Tool) where a Disconnect→Reconnect recreates the DashSpvClient; the reinit window during that recreation is when the offending block arrived. The host UI then displayed "Syncing…" forever with no recovery path.
Symptom
After the restart, every sync phase reaches Synced except Filters, which is wedged:
Headers: Synced 1502629/1502629
Filter Headers: Synced 1502629/1502629
Filters: Syncing 1502615/1502629 (100.0%) stored:1502615, downloaded: 0, processed: 0
Blocks: Synced ...
Masternodes: Synced 1502629/1502629
ChainLocks: Synced ; InstantSend: Synced ; Mempool: Synced
FiltersProgress::current_height() returns committed_height (1502615), which never crosses 1502616, so the phase state stays Syncing (committed_height < target_height) and SyncProgress::is_synced() (all phases must be Synced) returns false for the life of the client.
Root cause (analysis)
The offending block (1502616) arrived inside the reinit window — its header was stored ~2s after the fresh client initialized filter headers to the prior tip (1502615), straddling the boundary between:
- the from-genesis historical filter-body rescan (whose tail batch nominally covered up to 1502616 but never committed it — batch-complete download ≠ commit), and
- the live tip tracker, which began requesting filter bodies at 1502617.
The contiguous commit pointer (committed_height) therefore cannot cross the 1502616 hole. All later tip filters (1502617…1502632) download and "complete" fine but are wasted — the pointer is stuck behind the gap.
Relevant code paths (rev 981e97f):
dash-spv/src/sync/filters/sync_manager.rs~L89 —pipeline.init(stored_filters_tip + 1, stored_filters_tip)on restart; the boundary block that lands between init and the first liveFilterHeadersStoredis the one that slips through.dash-spv/src/sync/filters/pipeline.rs/manager.rs— batch download vs. commit/contiguity accounting; a downloaded-but-not-committed batch does not advancecommitted_height.dash-spv/src/sync/filters/progress.rs—current_height()returnscommitted_height.dash-spv/src/sync/progress.rs—SyncProgress::is_synced()requires all phases (incl. Filters)Synced.
Evidence (falsifiable, from a ~1.9M-line client log)
- The body for the gap block was never requested.
GetCFilters: 1502616 to 1502616— 0 occurrences in the entire post-restart log. Tip body requests are contiguous except 1502616:… 1502614, 1502615, [1502616 ABSENT], 1502617, 1502618 …. committed_heightis frozen at 1502615 across the entire post-restart log. Every Filters progress line reads1502615/…; not one line has a first value ≥ 1502616.- Download ≠ commit. Immediately after the rescan's final batch logged
Filter batch 1502001-1502616 complete, the very next progress still readFilters: Syncing 1502615/1502617 stored:1502615. - Not environmental / not a peer-capability issue. Peers served ~1.5M
cfilterresponses with zerounknown block hash/ validation rejections post-restart. The wedge is purely client-side commit accounting. (This distinguishes it from dash-spv: compact-filter sync stalls silently when the only connected peer lacks NODE_COMPACT_FILTERS #815, which is the same symptom — Filters phase never reachingSynced— via a different cause, a peer lackingNODE_COMPACT_FILTERS.)
Timeline (UTC)
| Time | Event |
|---|---|
| 08:25:41 | Old client shutdown complete; storage persisted (Disconnect) |
| 08:25:44 | Fresh client starts (SpvRuntime::run() recreates DashSpvClient) |
| 08:25:46 | BlockHeadersManager initialized at height 1502615; sync-manager tasks spawned; best_height=1502615 |
| 08:25:54 | New header arrives: Segment 0: 1 headers ready to store from height 1502616 |
| 08:25:56 | FilterHeadersStored(1502616-1502616, tip=1502616); from-genesis filter-body rescan begins |
| 08:26–08:28 | ~1.5M cfilter messages downloaded; rescan tail Filter batch 1502001-1502616 complete — yet committed_height stays 1502615 |
| 08:28→tail | Tip requests 1502615 → [1502616 skipped] → 1502617, 1502618, …; every later filter "completes" but cannot advance the frozen pointer |
| later | Every phase Synced except Filters: Syncing 1502615/1502629 |
Reproduction
- Sync a
DashSpvClientto tip (filter headers + bodies committed to height H). - Restart the client (recreate
DashSpvClient) while a new block H+1 lands during the reinit window — i.e. after filter headers init to H but before the live tip tracker starts requesting bodies. - Observe:
committed_heightstays at H; the Filters phase reportsSyncing H/(H+k)indefinitely;SyncProgress::is_synced()never returnstrue, despite all other phasesSyncedand peers healthy.
Suggested fix
On restart, guarantee no gap at the rescan/tip boundary: re-request and commit any filter body in (committed_height, filter_header_tip] that is not yet committed before (or as part of) starting live tip tracking. In practice, resume tip tracking from committed_height + 1 rather than filter_header_tip + 1, and ensure the historical-rescan tail batch actually advances committed_height to its upper bound on completion (investigate why batch 1502001-1502616 completed download without committing 1502616 — the commit/contiguity logic in filters/pipeline.rs + manager.rs).
A committed_height-stall guard (Filters committed_height not advancing while filter_header_tip/Headers advance for N seconds → re-drive the gap) would also make this self-healing rather than terminal.
Related
- dash-spv: compact-filter sync stalls silently when the only connected peer lacks NODE_COMPACT_FILTERS #815 — same stuck-"Syncing" symptom (Filters phase never
Synced,is_synced()stuck false) via a different cause (peer lackingNODE_COMPACT_FILTERS). Cross-referenced as the same symptom class, distinct root cause.
🤖 Co-authored by Claudius the Magnificent AI Agent
Activity
lklimek commentedon Jul 1, 2026
Independent reproduction at a second rev (
5c0113e, dash-evo-tool's pin) plus a mechanism-level root cause that answers the open question in the report — "why did the tail batch complete download but never commit?"TL;DR: on an already-synced boot,
FiltersManager::start_downloadtakes its "Filters already synced" early return before it initializes the download pipeline or the store cursor. The pipeline is left uninitialized (target_height = 0) andnext_batch_to_store = 0. When the next block's filter header arrives,handle_new_filter_headerscallsextend_targeton that uninitialized pipeline, which re-enqueues from height 1 (a full from-genesis re-download), and the in-order store loop then wedges forever because the lowest completed batch starts at height 1 whilenext_batch_to_store == 0. Nothing commits →stored_height/committed_heightfrozen at the persisted height, exactly as reported. (The gap isn't strictly one block — it'stip − persisted_height, and it grows with every new block: I observedstored:1506436while the tip climbed 1506438 → 1506444.)Mechanism (code refs @
5c0113e,dash-spv/src/sync/filters/):Early return skips init.
manager.rs:195-204— when the wallet boots already synced (scan_start > filter_header_tip),start_downloadlogsFilters already synced to …and returns at:201-203, beforeself.next_batch_to_store = download_start(:220),self.processing_height = scan_start(:221), andself.filter_pipeline.init(download_start, tip)(:235). Sonext_batch_to_storestays0(default:113) and the pipeline stays uninitialized (FiltersPipeline::new()→target_height = 0).extend_targetre-downloads from genesis (off-by-one). The next filter header driveshandle_new_filter_headers(manager.rs:870), which callsself.filter_pipeline.extend_target(tip)(:888). Inpipeline.rs:113-128,old_target = 0, so it enqueues batches fromcurrent = old_target + 1 = 1up totip— a full-chain re-download even though filters are already stored.send_pending(:891) then issuesGetCFiltersfrom height 1.In-order store loop wedges. Completed batches flow to
store_and_match_batches(manager.rs:286). The store loop (:306-315) requiresbatch.start_height() == self.next_batch_to_store; the lowest completed batch starts at 1, butnext_batch_to_store == 0, so it breaks on the first iteration, every time. Nothing is ever stored (stored_heightnever advances via:397), so the tip batch never becomes scannable/commitable andcommitted_heightis frozen — the "download ≠ commit" this issue observed.Control A/B (proof it's the resume path):
Starting filter download (scan_start=0, download_start=0, stored_filters_tip=0, …)(full init)Filters already synced(early return)GetCFilters: 0 to 999(init fromdownload_start=0, matchesnext_batch_to_store=0)GetCFilters: 1 to 1000(extend_targetold_target+1, ≠next_batch_to_store=0)Filters: Synced … processed:1506465, matched:365; wallet tx detected at its blockFilters: Syncing … stored:<frozen>, processed:0, matched:0(permanent)Same binary, same wallet, same peers — the only difference is persisted filter state, and the divergence is exactly
init()(from height 0) vsextend_target(from height 1).Note on PR #816: #816 sets
processing_height = scan_startbefore the early return, which fixes the height-0 lookahead panic under checkpoint sync. But it does not setnext_batch_to_storeorinit()the pipeline on the early-return path, andpipeline.rs::extend_targetis unchanged — so by code reading the genesis re-download (step 2) and the store-loop wedge (step 3) persist past #816. Bumping to ≥ #816 alone likely does not resolve this.Suggested fix (in addition to the boundary guard already proposed): on the already-synced early-return path, either initialize the pipeline (
init(download_start, tip)) and setnext_batch_to_store = download_start, or havehandle_new_filter_headerscallstart_downloadwhenfilter_pipeline.is_idle()instead ofextend_targeton an uninitialized pipeline. That both removes the pointless from-genesis re-download and lets the store cursor advance from the correct frontier. Acommitted_height-stall watchdog (as suggested) is still worthwhile as a self-healing backstop.🤖 Co-authored by Claudius the Magnificent AI Agent
fix(dash-spv): commit filter boundary block landing in restart reinit…
fix(dash-spv): set filter store cursor on fully-synced restart to pre…
fix(dash-spv): anchor filter store cursor and pipeline in `start_down…
test(dash-spv): cover boundary block after fully-synced restart in da…
fix(dash-spv): drop filter tick stall guard that re-drove downloads i…
fix(dash-spv): avoid filter sync getting stuck on the first new block…
lklimek commentedon Jul 2, 2026
Claudius says it's fixed:
fix(dash-spv): avoid filter sync getting stuck on the first new block…