Repository navigation
fix(dash-spv)!: settle filter requests on network arrival - #1370
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 47 minutes. View limit details
Pre-merge checks:
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## dev #1370 +/- ##
==========================================
+ Coverage 86.38% 86.49% +0.10%
==========================================
Files 270 270
Lines 70849 71053 +204
==========================================
+ Hits 61204 61457 +253
+ Misses 9645 9596 -49
|
|
This PR has merge conflicts with the base branch. Please rebase or merge the base branch into your branch to resolve them. |
3a69ba0 to
73f9869
Compare
60cb181 to
810e7de
Compare
80d80bf to
ca66de7
Compare
|
This PR has merge conflicts with the base branch. Please rebase or merge the base branch into your branch to resolve them. |
810e7de to
74f9283
Compare
ca66de7 to
e89874d
Compare
74f9283 to
bb5a0d0
Compare
e89874d to
5cc69f8
Compare
|
This PR has merge conflicts with the base branch. Please rebase or merge the base branch into your branch to resolve them. |
3b3971d to
a37e9b9
Compare
4d4641f to
46beb07
Compare
A `getcfilters` request was keyed by its start height, but no `cfilter` in the reply carries a height. Mapping a reply back to its request needed the filters pipeline, which resolves each block hash to a height through storage. The last `cfilter` of a reply is the one for the request's stop hash. Keying `RequestKey::CFilters` by that hash lets anything that sees the reply identify its request directly, without a scan or a storage lookup. The filters pipeline already records the stop hash of each batch it sends, so a completed batch now returns that hash for the release.
A `CFilters` or `CfHeaders` request stayed on the wire until its serial manager processed the reply, which could be a million messages later. A kicked peer then had its delivered batches sent again, and a busy manager looked like a stalled peer. The network pump now settles a filter request as soon as its reply arrives, as it already did for blocks. `Broker::block_arrived` becomes `Broker::arrived`, which takes any request key. The last `cfilter` of a reply carries the stop hash that keys its `CFilters` request, and a `cfheaders` reply carries the stop hash of its `CfHeaders` request. A settled key stays registered until its manager releases it, so every path that drops a delivered batch now releases it. The filter headers manager releases a `cfheaders` reply whatever comes of it. The filters manager releases a batch whose last filter arrived while earlier ones are missing, so the next tick requests it again, a reply whose stop hash no stored header resolves, and the wanted batches it drops in a rescan reset.
bb5a0d0 to
51a854b
Compare
|
✅ Review complete in 9m 35s Planner (6s) Review (behavior · full): 8 findings Judge: 4 kept · 3 dropped (4m 33s) Review metadataConfig:
Account limits:
Judge decisions:
Incomplete reply. The pump settles a Release from any peer. filter_headers/sync_manager.rs:52 now releases Whether this stalls sync, and not only wastes requests, depends on routing picking the same peer again. I could not follow that in the code shown, so it is listed as a doubt.
No consumer repo references The open question is whether a public enum change should carry
Both tests still run the changed code, so they can fail when it breaks. That keeps this on the Timing:
Last reviewed
|
|
Bots are done — your move: post |
There was a problem hiding this comment.
Create an issue for this to track it for later. Manki approves once every warning is handled.
Related work: open PRs and issues this PR may duplicate or fix. None of them blocks.
- This PR may fix #1234 dash-spv: a peer whose filter replies wait in our own backlog is kicked as stalled. Add
Closes #1234to the description if it does.
About this review
- Reviewed
51a854b, round 1 - 317 changed lines read in 9m 35s
- Found by
claude-opus-5-5andgpt-6.2-sol, judged byclaude-opus-5-5 - Tokens: 3.5M in (2.7M from cache) · 75k out · about $5.92 at API prices, partly priced
- Runner: self-hosted · started after 12s · peak memory 3.1 GiB of 30.0 GiB
- How Manki reviews
|
|
There was a problem hiding this comment.
✅ Approved. All blocking threads are resolved, and no warning thread holds the approval.
What this does: Filter and filter-header requests were only cleared once the sync manager processed them, so a long backlog looked like a stalled peer. The broker now marks them done when the reply arrives.
What to test
The review model wrote these steps. Check what a step runs before you follow it.
Setup: Run the SPV client against testnet or a regtest dashd with filters enabled, with debug logging for dash_spv::network.
- Do a fresh filter sync from genesis or a checkpoint. Expect filters to download to the tip and
committed_heightto reach the tip without repeatedrequest timeout: kickedlines caused by the filter backlog. - Run
just dash-spv::test. Expect the dashd sync and restart tests to pass. - Disconnect the network mid filter sync, then reconnect. Expect filter sync to resume and complete without re-requesting already completed batches.
- Add a wallet with a low birth height after the client is synced, which triggers a rescan. Expect the old batches to be dropped, new
getcfiltersrequests to go out, and the sync to finish. - Restart a client that is already synced and wait for a new block. Expect the new block's filter header and filter to be fetched and committed.
- Edge case: kill or firewall a peer while it is answering a
getcfilters. Expect the request to be re-sent to another peer and the batch to complete. - Edge case: watch logs for
ended incomplete ... requesting it again. When it appears, expect the same batch to be requested again on the next tick and to complete.
…run 44901441069)
A
CFiltersorCfHeadersrequest stayed on the wire until its serial manager processed the reply, which could be a million messages later. A kicked peer then had its delivered batches sent again, and a busy manager looked like a stalled peer.The network pump now settles a filter request as soon as its reply arrives, as it already did for blocks.
CFiltersrequests are keyed by stop hash, so the lastcfilterof a reply identifies its request without a scan. A settled request stays registered until its manager releases it, so every path that drops a delivered batch now releases it: a batch whose last filter arrived incomplete, a stop hash no stored header resolves, a rescan reset, and acfheadersreply that matches nothing.Closes #1234
PR Hygiene ·
51a854b/self-reviewedWhen every merge requirement is met, the
PR Hygienecheck passes. Reviewer limits do not block merging; other required GitHub checks and protections still apply.