Repository navigation
refactor!: detect bloom filter staleness with a hash of what the filter watches - #1359
Conversation
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 50 minutes. View limit details
No actionable comments were generated in the recent review. Walkthrough
Merge Risk:
|
|
Waiting for bot review — coderabbitai not yet. Wait for the missing reviews, or a writer can post |
|
Bots are done — your move: post |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## dev #1359 +/- ##
==========================================
+ Coverage 85.80% 85.86% +0.05%
==========================================
Files 269 269
Lines 70764 70645 -119
==========================================
- Hits 60722 60662 -60
+ Misses 10042 9983 -59
|
…ion-on-pool-growth
|
Waiting for bot review — coderabbitai not yet. Wait for the missing reviews, or a writer can post |
|
This PR has merge conflicts with the base branch. Please rebase or merge the base branch into your branch to resolve them. |
|
Bots are done — your move: post |
…ion-on-pool-growth # Conflicts: # key-wallet-manager/src/process_block.rs
|
✅ Review complete in 3m 35s Planner (6s) Review (security · pair): 2 findings Judge: 2 kept · 0 dropped (1m 34s) Review metadataConfig:
Account limits:
Judge decisions:
Timing:
|
|
Waiting for bot review — coderabbitai not yet. Wait for the missing reviews, or a writer can post |
There was a problem hiding this comment.
✅ Approved. 2 suggestions, none of which block.
What this does: The mempool bloom filter was rebuilt when a manual revision counter changed. Some code paths bumped it and others did not.
Related work: open PRs and issues that may cover the same change. None of them blocks.
- Overlaps · #634 feat(key-wallet-manager): single-map WalletManager with Arc<RwLock> per wallet
- Overlaps · #357 feat: explore bloom filter for mempool
- Overlaps · #855 key-wallet-manager: include watched_outpoints in compact-filter matching (defense-in-depth for #649-class bugs)
What to test
The review model wrote these steps. Check what a step runs before you follow it.
Setup: Run the SPV client with mempool tracking enabled and MempoolStrategy::BloomFilter, with a wallet loaded and synced to the tip.
- Generate a new receive address. Expect one log line 'Wallet monitored set changed, rebuilding bloom filter' and a new
filterloadsent to each activated peer. - Leave the client idle for a minute. Expect no repeated rebuild log lines and no extra
filterloadmessages. - Receive a payment to a wallet address. Expect a rebuild after the transaction is processed, because a new UTXO is now watched.
- Receive an InstantSend lock for a transaction the wallet already holds. Expect no rebuild.
- Remove a wallet from the manager. Expect a rebuild with a filter that no longer covers its addresses.
- Switch to
MempoolStrategy::FetchAlland generate addresses. Expect nofilterclearorfilterloadmessages.
About this review
- Reviewed
70b14b1, round 1 - 416 changed lines read in 3m 35s
- Found by
claude-sonnet-5-5andclaude-opus-5-5, judged byclaude-opus-5-5 - Tokens: 3.2M in (2.4M from cache) · 21k out · about $4.34 at API prices
- How Manki reviews
|
✅ Review complete in 2m 43s Planner (5s) Review (security · pair): 2 findings Judge: 2 kept · 0 dropped (53s) Review metadataConfig:
Account limits:
Judge decisions:
Timing:
|
|
Waiting for bot review — coderabbitai not yet. Wait for the missing reviews, or a writer can post |
There was a problem hiding this comment.
✅ Approved. 1 suggestion, which doesn't block.
What this does: The bloom filter for mempool monitoring was rebuilt only when wallet code remembered to bump a revision counter. The wallet now exposes a hash of the watched addresses and coins, and the mempool manager rebuilds the filter whenever that hash changes, so no change can be missed.
Related work: open PRs and issues that may cover the same change. None of them blocks.
- Overlaps · #634 feat(key-wallet-manager): single-map WalletManager with Arc<RwLock> per wallet
- Overlaps · #855 key-wallet-manager: include watched_outpoints in compact-filter matching (defense-in-depth for #649-class bugs)
What to test
The review model wrote these steps. Check what a step runs before you follow it.
Setup: Run the SPV client on testnet or regtest with mempool tracking enabled and mempool_strategy set to BloomFilter, with a funded wallet.
- Let initial sync finish. Expect one
filterloadand onemempoolmessage sent to each connected peer. - Wait several seconds without wallet activity. Expect no further
filterloadmessages and no "Wallet monitored set changed" log line. - Generate a new receive address beyond the current gap window. Expect "Wallet monitored set changed, rebuilding bloom filter" within about 100 ms, followed by
filterclear,filterloadandmempoolper activated peer. - Send funds to a wallet address from another wallet. Expect the incoming mempool transaction to be detected and the filter to be rebuilt once, because a new UTXO is watched.
- Receive an InstantSend lock for that transaction. Expect no filter rebuild, since the watched sets do not change.
- Switch to
mempool_strategyFetchAlland repeat the address generation. Expect nofilterloadorfilterclearmessages. - Remove a wallet from the manager while running. Expect one filter rebuild, then none on later ticks.
About this review
- Reviewed
1c96695, round 2 - 424 changed lines read in 2m 43s
- Found by
claude-sonnet-5-5andclaude-opus-5-5, judged byclaude-opus-5-5 - Tokens: 3.3M in (2.7M from cache) · 19k out · about $3.60 at API prices
- How Manki reviews
|
Bots are done — your move: post |
36266e9
|
Waiting for bot review — coderabbitai not yet. Wait for the missing reviews, or a writer can post |
|
✅ Review complete in 2m 3s Planner (5s) Review (security · pair): 0 findings Judge: 0 kept · 0 dropped (38s) Review metadataConfig:
Account limits:
Timing:
Last reviewed
|
There was a problem hiding this comment.
✅ Approved.
What this does: The bloom filter used to be rebuilt only when wallet code remembered to bump a counter, and some changes were missed. The client now hashes the watched addresses and coins and rebuilds the filter whenever that hash changes.
Related work: open PRs and issues that may cover the same change. None of them blocks.
- Overlaps · #634 feat(key-wallet-manager): single-map WalletManager with Arc<RwLock> per wallet
- Overlaps · #855 key-wallet-manager: include watched_outpoints in compact-filter matching (defense-in-depth for #649-class bugs)
What to test
The review model wrote these steps. Check what a step runs before you follow it.
Setup: Run the SPV client against regtest or testnet with mempool tracking enabled and MempoolStrategy::BloomFilter.
- Complete initial sync. Expect one
FilterLoadper peer at activation and no secondFilterLoadon the following ticks. - Generate a new receive address in the wallet. Expect a log line saying the monitored set changed, followed by
FilterClear,FilterLoadandMemPoolto each activated peer. - Receive a payment into the wallet. Expect a filter rebuild, because the set of watched outpoints changed.
- Leave the client idle for a minute. Expect no repeated filter rebuilds while nothing in the wallet changes.
- Switch to
MempoolStrategy::FetchAlland change the wallet's addresses. Expect noFilterLoadorFilterClearmessages. - Remove the only wallet from the manager. Expect a single rebuild, and the monitor hash to equal its empty-manager value again.
About this review
- Reviewed
36266e9, round 3 - 438 changed lines read in 2m 3s
- Found by
claude-sonnet-5-5andclaude-opus-5-5, judged byclaude-opus-5-5 - Tokens: 3.8M in (3.1M from cache) · 14k out · about $3.52 at API prices
- How Manki reviews
|
Bots are done — your move: post |
…run 43467509500)
monitor_revisionwas a counter bumped by hand wherever the monitored set might change. That is easy to get wrong in both directions:next_address,next_address_with_info,next_bls_operator_key,next_eddsa_platform_keyand the batchnext_receive_addresses/next_change_addressesgrow address pools without bumping, so the mempool bloom filter keeps watching the old set (key-wallet: bumpmonitor_revisionin all pool-mutating helpers onManagedCoreFundsAccount#713, key-wallet: bumpmonitor_revisionin pool-mutating helpers onManagedCoreKeysAccount#715).next_receive_address/next_change_addressbump even when they hand out an already generated address (Found-022:TransactionBuilder::set_fundingmutates funds account beforebuild_signedcan fail — phantommonitor_revisionbumps on failed builds #764).This replaces the counter with
WalletInterface::monitor_hash(), a hash ofmonitored_addresses()andwatched_outpoints(), the two lists the bloom filter is built from. The mempool manager compares it on each tick as before. It changes exactly when the filter contents change, so there is nothing to bump.monitor_revision,bump_monitor_revision,structural_revisionand every manual bump are gone.Cost (release, per tick, every 100 ms): ~15 µs with 355 addresses (default wallet), ~90 µs with 2,295.
Hasher: it uses std's
DefaultHasher(SipHash). Hash-only timings for 355 / 2,295 addresses:If this ever needs to be faster,
ahashwith fixed seeds is the one to use, but it would add a dependency to the normal tree that is not worth it at this cost.Breaking changes for Platform
monitor_revisionis removed fromWalletInterface,ManagedAccountTrait,ManagedAccountRef/MutandWalletInfoInterface. Platform only shows it in diagnostics, so nothing users see changes when it bumps this crate:rs-platform-wallet/src/wallet/platform_wallet_traits.rs: drop themonitor_revisionoverride inimpl WalletInfoInterface for PlatformWalletInfo.rs-platform-wallet/src/manager/accessors.rs: dropmonitor_revisionfromCoreWalletStateSnapshotandAccountMetadataSnapshot(or report the wallet'smonitor_hash()in the first), together with the matching FFI fields inCoreWalletStateFFI/AccountMetadataFFIand the Swift diagnostics view.The mempool bloom filter keeps rebuilding as before:
WalletManager<PlatformWalletInfo>getsmonitor_hash()from the trait default.Closes #713
Closes #715
Part of #764
PR Hygiene ·
36266e9/self-revieweddash-spv(dash-spv/src/client/lifecycle.rs,dash-spv/src/sync/mempool/manager.rs,dash-spv/src/sync/mempool/sync_manager.rs) — QuantumExplorer or xdustinfacekey-wallet-manager(key-wallet-manager/src/accessors.rs,key-wallet-manager/src/lib.rs,key-wallet-manager/src/process_block.rsand 3 more) — QuantumExplorer or xdustinfacekey-wallet(key-wallet/src/managed_account/managed_account_ref.rs,key-wallet/src/managed_account/managed_account_trait.rs,key-wallet/src/managed_account/managed_core_funds_account.rsand 6 more) — QuantumExplorer or xdustinfaceWhen every merge requirement is met, the
PR Hygienecheck passes. Reviewer limits do not block merging; other required GitHub checks and protections still apply.Summary by CodeRabbit