fix(dash-spv): reprocess blocks on rescan against newly derived scripts#820
fix(dash-spv): reprocess blocks on rescan against newly derived scripts#820xdustinface wants to merge 2 commits into
Conversation
The commit-time batch rescan re-matches scripts derived during block processing against the active batches, but `BlockMatchTracker::track` subtracted wallets that already had a block applied, so a block processed before those scripts existed was silently skipped. Scripts derived from processing a block could therefore never trigger a re-examination of any earlier block in the same batch, and partially recognized blocks stayed partial. Add `track_for_new_scripts`, which keeps the in-flight accounting of `track` but ignores processed records, and use it in `rescan_batch`: every match there is by construction against scripts that did not exist at first processing. Re-application is safe because wallet-side block processing is idempotent (transaction dedup, outpoint-keyed UTXO insertion, balance recomputed from the UTXO set). Termination is preserved since the rescan only queries newly collected scripts, and re-processing a block whose outputs are already recognized derives nothing further. The plain `scan_batch` path keeps the processed-record skip, late-added wallets still get their residual pass through plain `track`.
One transaction pays a run of consecutive fresh addresses reaching past the gap window, mined before the client ever starts. The historical scan must climb the burst via fixpoint re-scanning and credit every output. Adds `DashCoreNode::send_many` so a regtest wallet can pay many addresses in a single transaction.
📝 WalkthroughWalkthroughAdds ChangesGap-window rescan via track_for_new_scripts
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
Suggested labels
Suggested reviewers
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 |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## dev #820 +/- ##
==========================================
+ Coverage 72.82% 73.02% +0.20%
==========================================
Files 323 323
Lines 72000 72072 +72
==========================================
+ Hits 52432 52633 +201
+ Misses 19568 19439 -129
|
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 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.
Inline comments:
In `@dash-spv/src/test_utils/node.rs`:
- Around line 322-327: The send_many helper is collapsing duplicate destination
addresses when building the serde_json::Map, which can silently change the
intended outputs. Update send_many to detect repeated address strings before
constructing the RPC object, and either reject them with an explicit error or
aggregate their amounts intentionally. Make the behavior clear in send_many and
the amount-to-map building logic so each `(address, amount)` pair is handled
deterministically.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: e4d9b656-3aa2-423c-a62f-c0a3fcc1e0ff
📒 Files selected for processing (4)
dash-spv/src/sync/filters/block_match_tracker.rsdash-spv/src/sync/filters/manager.rsdash-spv/src/test_utils/node.rsdash-spv/tests/dashd_sync/tests_transaction.rs
The commit-time batch rescan re-matches scripts derived during block processing against the active batches, but
BlockMatchTracker::tracksubtracted wallets that already had a block applied, so a block processed before those scripts existed was silently skipped. Scripts derived from processing a block could therefore never trigger a re-examination of any earlier block in the same batch, and partially recognized blocks stayed partial.Add
track_for_new_scripts, which keeps the in-flight accounting oftrackbut ignores processed records, and use it inrescan_batch: every match there is by construction against scripts that did not exist at first processing. Re-application is safe because wallet-side block processing is idempotent (transaction dedup, outpoint-keyed UTXO insertion, balance recomputed from the UTXO set). Termination is preserved since the rescan only queries newly collected scripts, and re-processing a block whose outputs are already recognized derives nothing further.The plain
scan_batchpath keeps the processed-record skip, late-added wallets still get their residual pass through plaintrack.Summary by CodeRabbit
New Features
Bug Fixes