Skip to content

fix(dash-spv-bench): count distinct transactions, not processing passes - #984

Draft
ZocoLini wants to merge 1 commit into
devfrom
fix/bench-distinct-tx-count
Draft

fix(dash-spv-bench): count distinct transactions, not processing passes#984
ZocoLini wants to merge 1 commit into
devfrom
fix/bench-distinct-tx-count

Conversation

@ZocoLini

@ZocoLini ZocoLini commented Aug 26, 2026

Copy link
Copy Markdown
Collaborator

The dashboard's transaction figure and the report's transactions: line were both additive counters incremented per block application. A block reaches the wallet more than once during a sync, so the number measured how much re-scanning a run happened to do rather than what it found, and varied run-to-run on an identical wallet and chain.

Both now count distinct txids collected from BlockProcessed.

The report's per-wallet line also gains known_txids. retained_records counts live records only, and with keep-finalized-transactions off a chainlocked record is pruned to its txid — so a fully synced wallet reported zero. ManagedAccountTrait::collect_known_txids returns both halves.

@coderabbitai

coderabbitai Bot commented Aug 26, 2026

Copy link
Copy Markdown
Contributor

Important

Draft PR not reviewed

Draft PRs are not automatically reviewed by default.

  • Trigger a manual review

To automatically review draft PRs, update your CodeRabbit configuration:

reviews:
  auto_review:
    drafts: true

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@codecov

codecov Bot commented Aug 26, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 75.86207% with 14 lines in your changes missing coverage. Please review.
✅ Project coverage is 77.16%. Comparing base (237f79a) to head (34aec53).

Files with missing lines Patch % Lines
key-wallet-manager/src/process_block.rs 73.91% 6 Missing ⚠️
...-wallet/src/managed_account/managed_account_ref.rs 50.00% 5 Missing ⚠️
key-wallet-manager/src/wallet_interface.rs 0.00% 3 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##              dev     #984      +/-   ##
==========================================
+ Coverage   77.14%   77.16%   +0.02%     
==========================================
  Files         329      329              
  Lines       82998    83053      +55     
==========================================
+ Hits        64026    64087      +61     
+ Misses      18972    18966       -6     
Flag Coverage Δ
core 78.25% <ø> (ø)
ffi 52.40% <ø> (ø)
rpc 20.00% <ø> (ø)
spv 92.10% <100.00%> (+0.10%) ⬆️
wallet 79.20% <73.07%> (-0.02%) ⬇️
Files with missing lines Coverage Δ
dash-spv/src/sync/blocks/manager.rs 96.82% <100.00%> (+0.03%) ⬆️
dash-spv/src/sync/blocks/progress.rs 77.50% <100.00%> (ø)
...allet/src/managed_account/managed_account_trait.rs 42.80% <ø> (ø)
.../src/managed_account/managed_core_funds_account.rs 87.82% <100.00%> (+0.04%) ⬆️
...t/src/managed_account/managed_core_keys_account.rs 58.55% <100.00%> (+0.83%) ⬆️
...allet/managed_wallet_info/wallet_info_interface.rs 81.10% <100.00%> (+0.63%) ⬆️
key-wallet-manager/src/wallet_interface.rs 8.57% <0.00%> (-0.81%) ⬇️
...-wallet/src/managed_account/managed_account_ref.rs 53.27% <50.00%> (-0.15%) ⬇️
key-wallet-manager/src/process_block.rs 91.42% <73.91%> (-0.89%) ⬇️

... and 5 files with indirect coverage changes

@ZocoLini
ZocoLini force-pushed the fix/bench-distinct-tx-count branch 2 times, most recently from aa75024 to a3d6645 Compare August 26, 2026 12:32
`BlocksProgress::transactions` was a running sum, incremented per block
application by however many txids the wallet reported as new to it. A block
reaches the wallet more than once during a sync, and a record the wallet
dropped at finalization is reported new again on the next pass, so the number
measured how much re-scanning a run happened to do rather than what it found,
and varied run-to-run on an identical wallet and chain. The dashboard and the
bench report both showed it.

The wallet already knows the answer, so it is asked instead of tracked:
`WalletInterface::tx_count` unions the txids its wallets know, and the blocks
manager sets the progress value from it once per drain rather than
accumulating. Nothing downstream changes shape — the field stays a `u32`, so
`BlocksProgress` is still cheap to clone on every progress read.

Unioned rather than summed, at both levels: one transaction can touch several
accounts, and be relevant to several wallets.

The report's per-wallet line had the same problem from the other side. It
showed `retained_records`, which counts live records only — and with
`keep-finalized-transactions` off a chainlocked record is pruned to its txid,
so a fully synced wallet reported near zero. It now shows `txids`, from
`WalletInfoInterface::txids` over a `ManagedAccountTrait::collect_txids`
primitive that reads both halves.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015NhHBDGiKfiGpy7FwooyfS
@ZocoLini
ZocoLini force-pushed the fix/bench-distinct-tx-count branch from a3d6645 to 34aec53 Compare August 26, 2026 14:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant