fix(spv): filter headers not starting from checkpoint on reconnect#218
fix(spv): filter headers not starting from checkpoint on reconnect#218pauldelucia wants to merge 2 commits intov0.42-devfrom
Conversation
WalkthroughThe Changes
Sequence Diagram(s)sequenceDiagram
participant Caller as store_filter_headers
participant Storage as FiltersStorage
Caller->>Storage: request store headers (has sync_base_height)
alt tip is Some
Storage->>Storage: if sync_base_height > 0 and tip < sync_base_height
alt tip < sync_base_height
Storage-->>Caller: next_blockchain_height = sync_base_height
else tip >= sync_base_height
Storage-->>Caller: next_blockchain_height = tip + 1
end
else tip is None
Storage-->>Caller: next_blockchain_height = (unchanged) sync_base_height/path
end
Note right of Storage `#D3E4CD`: Decision focused on tip vs checkpoint\n(unchanged None-case)
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes
Poem
Pre-merge checks and finishing touches✅ Passed checks (3 passed)
✨ Finishing touches
🧪 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.
Actionable comments posted: 0
🧹 Nitpick comments (1)
dash-spv/src/storage/disk/filters.rs (1)
22-30: Checkpoint-awarenext_blockchain_heightlogic correctly fixes the reconnect behaviorAnchoring
next_blockchain_heighttosync_base_heightwhensync_base_height > 0andcached_filter_tip_heightis still below the checkpoint ensures that new filter headers are written starting at the checkpoint, not into pre-checkpoint indices. That keeps the checkpoint-relative storage mapping consistent on reconnect and avoids mixing “genesis-style” indices with checkpoint-based ones, which aligns with the PR objective.Given this guard, the
next_blockchain_height < sync_base_heightbranch in the storage index computation (Lines 48–56) should now be unreachable in normal operation. You might consider tightening that path to make the invariant explicit, e.g. via adebug_assert!(next_blockchain_height >= sync_base_height)and keeping thetracing::warn!as a defensive fallback, so any future regressions are easier to spot during development.Also applies to: 44-56
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
dash-spv/src/storage/disk/filters.rs(1 hunks)
🧰 Additional context used
🧠 Learnings (2)
📓 Common learnings
Learnt from: DCG-Claude
Repo: dashpay/rust-dashcore PR: 0
File: :0-0
Timestamp: 2025-06-26T16:01:37.609Z
Learning: The mempool tracking infrastructure (UnconfirmedTransaction, MempoolState, configuration, and mempool_filter.rs) is fully implemented and integrated in the Dash SPV client as of this PR, including client logic, FFI APIs, and tests.
📚 Learning: 2025-06-26T16:01:37.609Z
Learnt from: DCG-Claude
Repo: dashpay/rust-dashcore PR: 0
File: :0-0
Timestamp: 2025-06-26T16:01:37.609Z
Learning: The mempool tracking infrastructure (UnconfirmedTransaction, MempoolState, configuration, and mempool_filter.rs) is fully implemented and integrated in the Dash SPV client as of this PR, including client logic, FFI APIs, and tests.
Applied to files:
dash-spv/src/storage/disk/filters.rs
There was a problem hiding this comment.
Actionable comments posted: 0
🧹 Nitpick comments (1)
dash-spv/src/storage/disk/filters.rs (1)
22-28: Checkpoint resume behavior looks correct; consider logging the unexpectedtip < sync_base_heightcase.The new conditional cleanly fixes the reconnect-from-checkpoint issue: when a cached tip is behind the checkpoint, you now restart from
sync_base_heightinstead oftip + 1, while leaving genesis-sync and normal continuation (tip ≥ checkpoint) semantics unchanged. That’s consistent with how storage indices are derived later in the loop and avoids writing headers at pre‑checkpoint indices.Since
tip < sync_base_heightshould generally not happen in a healthy checkpointed flow (other than the specific reconnect scenario you’re targeting), you might optionally emit atracing::warn!in that branch to surface any future unexpected state transitions:Some(tip) => { if sync_base_height > 0 && tip < sync_base_height { tracing::warn!( "cached_filter_tip_height ({}) is below sync_base_height ({}); \ resetting next_blockchain_height to checkpoint", tip, sync_base_height ); sync_base_height } else { tip + 1 } }This keeps the fix while making it easier to spot misconfigurations or future regressions around checkpoint handling.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
dash-spv/src/storage/disk/filters.rs(1 hunks)
🧰 Additional context used
🧠 Learnings (1)
📓 Common learnings
Learnt from: DCG-Claude
Repo: dashpay/rust-dashcore PR: 0
File: :0-0
Timestamp: 2025-06-26T16:01:37.609Z
Learning: The mempool tracking infrastructure (UnconfirmedTransaction, MempoolState, configuration, and mempool_filter.rs) is fully implemented and integrated in the Dash SPV client as of this PR, including client logic, FFI APIs, and tests.
|
This PR has merge conflicts with the base branch. Please rebase or merge the base branch into your branch to resolve them. |
If you sync from checkpoint, disconnect, and reconnect, filter headers were being loaded from storage at 0 instead of checkpoint.
Summary by CodeRabbit
✏️ Tip: You can customize this high-level summary in your review settings.