Repository navigation
fix(dash-spv): retry a refused request at another peer - #1374
xdustinface wants to merge 12 commits into
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 32 minutes. View limit details
No actionable comments were generated in the recent review. Walkthrough
Merge Risk:
|
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## dev #1374 +/- ##
==========================================
+ Coverage 88.16% 88.21% +0.04%
==========================================
Files 270 270
Lines 72623 73003 +380
==========================================
+ Hits 64031 64397 +366
- Misses 8592 8606 +14
|
af7ed75 to
30b3af3
Compare
|
This PR has merge conflicts with the base branch. Please rebase or merge the base branch into your branch to resolve them. |
b58028c to
983e28b
Compare
983e28b to
467c455
Compare
30b3af3 to
259d131
Compare
467c455 to
2bda02a
Compare
259d131 to
9402114
Compare
2bda02a to
3ff2dc4
Compare
|
This pull request is a draft, so Manki does not review it automatically. Marking it ready for review starts automatic reviews. Until then, someone with write access to this repository can tick a box below: Review this draft reviews the current commit once, Deeper review does so with more effort, and Review every push reviews it now and again after each push. |
|
✅ Review complete in 23m 6s Planner (5s) Review (behavior · full): 18 findings Judge (12m 52s) Posted: 5 findings Review metadataConfig:
Account limits:
Judge decisions:
Timing:
|
There was a problem hiding this comment.
Create an issue for this to track it for later. The PR is also a draft, so mark it ready for review too. If no approval follows, comment /manki check.
4 suggestions are not listed.
Checked and left out: 1 finding
Not proven, so not listed · 1 warning
- Retrying one block in a multi-block request can resend and reassign its siblings ·
dash-spv/src/network/broker.rs:470
A check of the code could not confirm it.
The progress comment has the full log under "Judge decisions", in its "Review metadata" fold.
About this review
- Reviewed
3ff2dc4, round 1 - 250 changed lines read in 23m 6s
- Found by
claude-opus-5-5andgpt-6.2-sol, judged byclaude-opus-5-5 - Tokens: 6.4M in (5.1M from cache) · 160k out · about $8.68 at API prices
- Runner: self-hosted · started after 12s · peak memory 4.6 GiB of 30.0 GiB
- How Manki reviews
|
✅ Review complete in 15m 58s Planner (5s) Review (behavior · full): 10 findings Judge (7m 47s) Posted: 5 findings Review metadataConfig:
Account limits:
Judge decisions:
Timing:
|
|
CI does not run on this PR while it is a draft. Someone with write access can start it here:
Marking the PR ready for review also starts CI. |
There was a problem hiding this comment.
Create an issue for this to track it for later. The PR is also a draft, so mark it ready for review too. If no approval follows, comment /manki check.
2 suggestions · not blocking
✨ A stale timeout or skip can record a refusal for a newer send
Suggestion, not blocking · Concurrency · Moderate · dash-spv/src/network/broker.rs:396
Why: Expiry selects keys under one lock and applies the refusal under another, without checking the selected send. If the request is settled, released and sent again before the timeout applies, the new carrier inherits a ten-second refusal for an attempt it did not miss. The arrival path has the same gap when a newer send of the key uses the same connection.
rust-dashcore/dash-spv/src/network/broker.rs
Lines 394 to 398 in 1d3d8de
How to fix it
Apply each refusal while holding the lock used to identify the affected send, or carry the exact send identity through to requeue and only update a matching attempt.
Checked in the code
On the flagged line: Applies the timeout with |k, _| unanswerable.contains(k), without checking the carrier or send order
Saves only key.clone() in unanswerable
rust-dashcore/dash-spv/src/network/broker.rs
Lines 391 to 395 in 1d3d8de
Drops the arrival lock before line 329 checks only o.peer == peer && skipped.contains(k)
rust-dashcore/dash-spv/src/network/broker.rs
Lines 321 to 325 in 1d3d8de
Applies retry.refuse(peer.addr()) to whichever on-wire attempt is selected under the second lock
rust-dashcore/dash-spv/src/network/broker.rs
Lines 249 to 253 in 1d3d8de
dash-spv/src/network/broker.rs:329:self.requeue(|k, o| o.peer == peer && skipped.contains(k), true).await;
- Create an issue for this
✨ An unanswered request still has no deadline while its peer returns other traffic
Suggestion, not blocking · Pre-existing · Reliability · Moderate · dash-spv/src/network/broker.rs:300
Tracked in #1230.
The same problem remains here. This PR fixes it at dash-spv/src/network/broker.rs:329 but not on this path.
Already broken before this PR. Two checks found the same problem on dev at dash-spv/src/network/broker.rs:245, so it doesn't block this PR.
Why: A peer that silently skips a filter header batch but keeps returning headers can prevent the batch from ever being retried, including after its filter index catches up. Only a matched, uniquely sent carrier reply triggers skip detection. Header replies, hedge replies, and replies that arrive before the routing pass records their send do not trigger it, even though the pump counts them as progress for the unanswered request.
How to fix it
Base expiry on progress the peer can attribute to the specific send, with a deadline that allows for queued bytes and a large reply. Record sends in wire order before a reply can race their registration, and use unambiguous later replies as early retry signals rather than as the only way to detect a skip on a busy connection.
- Create an issue for this
1 more suggestion is not listed.
Checked and left out: 1 finding
Disproved by a check of the code · 1 finding
- A block reply cannot expose a skipped block in the same inventory list ·
dash-spv/src/network/broker.rs:491
Every blockgetdatathat reaches the broker is built from one hash.BlockRequest::into_messageand the blocks manager both wrap a singleInventory::Block, which gives each block request its own send order.
The progress comment has the full log under "Judge decisions", in its "Review metadata" fold.
About this review
- Reviewed
1d3d8de, round 2 - 380 changed lines read in 15m 58s
- Found by
claude-opus-5-5andgpt-6.2-sol, judged byclaude-opus-5-5 - Tokens: 5.8M in (4.4M from cache) · 147k out · about $8.42 at API prices
- Runner: self-hosted · started after 14s · peak memory 4.7 GiB of 30.0 GiB
- How Manki reviews
|
✅ Review complete in 12m 28s Planner (5s) Review (behavior · full): 9 findings Judge (7m 6s) Posted: 4 findings Review metadataConfig:
Account limits:
Judge decisions:
Timing:
|
There was a problem hiding this comment.
Approval held: this PR is a draft. Mark it ready for review, and Manki approves it if nothing else holds the approval. If the latest commit has no review yet, Manki reviews it first when automatic review runs on this PR. If nothing happens, as for a PR from a fork or while automatic review is off or paused, comment /manki check, and Manki approves or says what holds the approval.
✅ Approved. 4 suggestions, none of which block.
- Check approval
What this does: The request broker remembers which peer addresses refused a request: skipped it, let a retry expire, or sent notfound. It avoids them for 10 seconds when routing or hedging.
1 suggestion · not blocking
✨ Skip detection ignores replies to hedges and earlier copies in the same inventory
Suggestion, not blocking · Pre-existing · Correctness · Moderate · dash-spv/src/network/broker.rs:327
The same problem remains here. This PR fixes it at dash-spv/src/network/broker.rs:373 but not on this path.
Already broken before this PR. Two checks found the same problem on dev at dash-spv/src/network/broker.rs:242, so it doesn't block this PR.
Why: The broker checks for skipped work only when the reply settles a current primary copy, and it checks only earlier primary copies. A peer that skipped a primary request and then answers a later hedge provides the same ordering evidence, but the primary stays on that peer. The same gap affects a skipped earlier block in one getdata inventory: all its blocks get the same order, although Dash Core serves them in inventory order.
How to fix it
Store a position for each sent copy, including hedges and individual inventory entries. Use a reply that unambiguously identifies a copy to retire earlier skipped copies on that connection. Requeue a skipped primary, but remove just the hedge when the primary still has a live carrier.
- Create an issue for this
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 with two or more peers, for example with just dash-spv::test, and enable debug logs for dash_spv::network.
- Sync blocks and filters with two peers. Expect sync to complete with no
skipped ... retrying elsewhereloops in the log. - Use a peer that has no filter index next to one that has it. Expect filter batches to move to the serving peer after the first skip, not to stall.
- Stop one peer from answering during block download. Expect the requests at that peer to be retried at the other peer. Expect no hedge copy to go to a reconnection from the same address within 10 seconds.
- Run with a single peer that skips one request. Expect that request to be sent to the same peer again after about 10 seconds, and other queued requests to keep going out meanwhile.
- Edge case: make every peer refuse the last pending block, then wait past 10 seconds with no other traffic. Expect the block to be requested again rather than sync hanging.
- Edge case: disconnect a peer that holds a hedge copy, then reconnect it. Expect the request to stay with its carrier and to be hedged again to another peer.
Checked and left out: 1 finding
Not proven, so not listed · 1 warning
- Retrying one block can resend or hold the whole inventory ·
dash-spv/src/network/broker.rs:270
A check of the code could not confirm it.
The progress comment has the full log under "Judge decisions", in its "Review metadata" fold.
About this review
- Reviewed
c304a72, round 3 - 475 changed lines read in 12m 28s
- Found by
claude-opus-5-5andgpt-6.2-sol, judged byclaude-opus-5-5 - Tokens: 5.0M in (3.9M from cache) · 116k out · about $6.88 at API prices
- Runner: self-hosted · started after 16s · peak memory 4.8 GiB of 30.0 GiB
- How Manki reviews
|
✅ Review complete in 11m 56s Planner (3s) Review (behavior · full): 6 findings Judge (7m 39s) Posted: 1 finding Review metadataConfig:
Account limits:
Judge decisions:
Timing:
|
There was a problem hiding this comment.
Approval held: this PR is a draft. Mark it ready for review, and Manki approves it if nothing else holds the approval. If the latest commit has no review yet, Manki reviews it first when automatic review runs on this PR. If nothing happens, as for a PR from a fork or while automatic review is off or paused, comment /manki check, and Manki approves or says what holds the approval.
✅ Approved. 1 suggestion, which doesn't block.
- Check approval
What this does: A peer that skips a request, sends notfound or lets it expire is no longer asked for it again right away. The request goes to another peer, and that peer is avoided for 10 seconds.
What to test
The review model wrote these steps. Check what a step runs before you follow it.
Setup: Build dash-spv with the cli feature and sync testnet or regtest with debug logging for dash_spv::network, ideally with two or more peers.
- Run
cargo test -p dash-spv --lib network::broker. Expect all broker tests to pass, including the new refusal and skip tests. - Sync blocks with several peers and watch for
skipped ... retrying elsewherein the log. Expect the skipped block to go out to a different peer address. - Use a peer that answers a block request with
notfound. Expect the block to be retried at another peer, not the same address. - During the block endgame, let the carrier of the lowest block stall. Expect the hedge copy never to go to an address that refused that block in the last 10 seconds.
- Disconnect a peer mid-sync and let it reconnect at the same address. Expect its requests to be re-queued and the new connection to be eligible for them at once.
- Edge case: connect a single peer and make it skip or expire a block. Expect the block to go out again to that peer about 10 seconds later, even with no other traffic.
- Edge case: re-declare a block key after releasing it while an old copy is still outstanding. Expect no false skip detection when the peer answers the old copy.
Checked and left out: 2 findings
Not proven, so not listed · 2 warnings
- Skipping a request can leave the peer unable to take its retry ·
dash-spv/src/network/broker.rs:384
A check of the code could not confirm it. - Batched block requests hide skips and resend whole inventories ·
dash-spv/src/network/broker.rs:546
A check of the code could not confirm it.
The progress comment has the full log under "Judge decisions", in its "Review metadata" fold.
About this review
- Reviewed
2e28168, round 4 - 536 changed lines read in 11m 56s
- Found by
claude-opus-5-5andgpt-6.2-sol, judged byclaude-opus-5-5 - Tokens: 5.2M in (4.1M from cache) · 126k out · about $7.42 at API prices
- Runner: self-hosted · started after 8s · peak memory 5.9 GiB of 30.0 GiB
- How Manki reviews
|
✅ Review complete in 10m 45s Planner (5s) Review (behavior · full): 7 findings Judge (5m 32s) Posted: 1 finding Review metadataConfig:
Account limits:
Judge decisions:
Every result stays correct, but blocks are downloaded twice and a skipped block stalls, so this is the
The effects are a skipped request left to expiry, or a needless requeue and repeated download. Results stay correct, so this is the
Timing:
|
There was a problem hiding this comment.
Create an issue for this to track it for later. The PR is also a draft, so mark it ready for review too. If no approval follows, comment /manki check.
Checked and left out: 1 finding
Disproved by a check of the code · 1 finding
- Refusing one block retries the entire inventory and loses ordering within it ·
dash-spv/src/network/broker.rs:547
Every block request that goes through the broker is aBlockRequest, andinto_messagebuilds aGetDatawith exactly oneInventory::Block. The blocks pipeline declares each wanted block as its own request, and the router never merges queued messages.
The progress comment has the full log under "Judge decisions", in its "Review metadata" fold.
About this review
- Reviewed
8866cc5, round 5 - 554 changed lines read in 10m 45s
- Found by
claude-opus-5-5andgpt-6.2-sol, judged byclaude-opus-5-5 - Tokens: 5.8M in (4.5M from cache) · 114k out · about $7.42 at API prices
- Runner: self-hosted · started after 13s · peak memory 5.7 GiB of 30.0 GiB
- How Manki reviews
Dash Core sends nothing for a block it does not have, nor for a `getcfilters` or `getcfheaders` its filter index cannot serve. Such a request stayed on the wire until it expired, and then went back to the same peer. Peers answer in request order, and the connection's ledger already settles the requests a reply proves skipped. `Ledger::settle` now also returns their keys, unless the peer still owes a later copy of the same request, which it may still answer. The peer reader passes them on just before the message that proves the skip, and the broker treats them like a `notfound`: the request is retried at once, and not at the address that skipped it.
The hedger asked a second peer for an overdue block only while the queue was empty. A request every peer with room refused stays queued until its refusals lapse, and a node still building its filter index can refuse a batch again and again, so block hedging stopped for as long as such a batch waited. The gate now asks whether a queued message would go out to a peer with room that does not refuse it, the same check the router uses to leave a message queued.
The router recorded its sends only after the whole routing pass. A peer that answered a later request while the router was still writing to other peers proved an earlier request skipped, but that request was still queued, so the skip was dropped. The request then went on the wire at the busy peer, whose other answers kept it from expiring, and the ledger never reported it again. Each message is now put on the wire right before its write. Its send time and overdue window are still taken at the end of the write, and its silence clock at the end of the pass. A failed write is not rolled back: it closes the connection, and the loss of the connection requeues what it carried. A message with no tracked request still goes back to the queue.
…ule only Only the inbound pump in the network module calls it.
`Broker::refused` checked every carried request against the refused keys one by one, and `Ledger::settle` scanned the requests still owed once per skipped request. Both now build a set once. The set of requests still owed is built only when a reply proves a skip.
A request is on the wire before it is charged on the ledger of its peer. `a_refused_block_goes_to_another_peer` injected the reply as soon as the first block was on the wire, so the reply could arrive before the second block was charged, and the ledger then proved no skip. The test now waits until both blocks are charged.
08e7f64 to
d915da9
Compare
|
Your move: coderabbitai left review threads unresolved; resolve them. |
|
Your move: coderabbitai left review threads unresolved; resolve them. |
|
/self-reviewed |
A request is put on the wire before its write, and its attempt is counted there. A write that failed still spent that attempt although the request never reached the peer. The loss of the connection requeues the request with its attempts, so the next peer that stalled on it was not blamed, as the request had already used up its `KICKING_ATTEMPTS`. The router now takes the attempt back when the write fails, whether the request is still on the wire at that peer or the loss of its connection has already requeued it.
|
✅ Review complete in 17m 55s Planner (6s) Review (behavior · full): 10 findings Judge (7m 9s) Posted: 3 findings Review metadataConfig:
Account limits:
Judge decisions:
Timing:
|
|
Your move: coderabbitai left review threads unresolved; resolve them. |
|
Your move: coderabbitai left review threads unresolved; resolve them. |
There was a problem hiding this comment.
✅ Approved. 3 suggestions, none of which block.
What this does: Before, a request a peer would not serve went straight back to that same peer. Now a notfound, a skip proven by an answer to a later request, or a repeated timeout sends it to another peer, and that address is not asked again for 10 seconds.
What to test
The review model wrote these steps. Check what a step runs before you follow it.
Setup: Run the client against a regtest network with at least two peers serving filters and blocks, with peer_speed and dash_spv::network debug logging on.
- Make one peer answer
getdatafor a block withnotfound. Expect the block to be requested from the other peer and not from the refusing address for 10 seconds. - Make one peer skip a block request and answer a later block first. Expect the skipped block to be re-queued and fetched from another peer.
- With only one peer connected, make it refuse a block. Expect the request to wait in the queue and be sent to that same peer again after about 10 seconds, with the router not spinning meanwhile.
- Let a block request stall at a peer past two attempts. Expect it to be retried at another peer without a kick, and no hedge copy sent to the stalling address.
- Block writes to a peer until the 5 s write timeout fires. Expect the connection to close and its block to go to the next peer, with the failed write not counted as an attempt.
- Have every connected peer refuse a filter batch while a block is overdue at a silent peer. Expect the block to still be hedged to another peer.
- Edge case: reconnect to an address that refused a request within the last 10 seconds. Expect the new connection to be passed over for that request until the refusal lapses.
Checked and left out: 2 findings (1 unproven, 1 rare)
Not proven, so not listed · 1 warning
- A partial refusal retries the whole inventory and overwrites unrelated in-flight requests ·
dash-spv/src/network/broker.rs:249
A check of the code could not confirm it.
Rare trigger, so not listed · 1 warning
- A tracked write can miss the only disconnect notification and wait for expiry ·
dash-spv/src/network/broker.rs:438
Trigger 3 of 10, below the cut-off of 4.
The progress comment has the full log under "Judge decisions", in its "Review metadata" fold.
About this review
- Reviewed
ed38985, round 12 - 682 changed lines read in 17m 55s
- Found by
claude-opus-5-5andgpt-6.2-sol, judged byclaude-opus-5-5 - Tokens: 8.3M in (6.7M from cache) · 158k out · about $10.59 at API prices
- Runner: self-hosted · started after 11s · peak memory 3.9 GiB of 30.0 GiB
- How Manki reviews
A refusal requeues a request and its next send adds an attempt, as a resend after a lost connection already did. The doc of `Broker::expire` still said the attempts were stalls.
|
Your move: coderabbitai left review threads unresolved; resolve them. |
|
✅ Review complete in 16m 24s Planner (6s) Review (behavior · full): 10 findings Judge (6m 44s) Posted: 3 findings Review metadataConfig:
Account limits:
Judge decisions:
Timing:
|
There was a problem hiding this comment.
✅ Approved. 3 suggestions, none of which block.
What this does: A peer that skips a block or filter request, or answers notfound, now has that request sent to another peer at once. That address is not asked again for 10 seconds.
2 suggestions · not blocking
✨ A timeout can mark a newly assigned peer as refusing
Suggestion, not blocking · Concurrency · Quick fix · dash-spv/src/network/broker.rs:362
Why: The timeout scan identifies stalled attempts but saves only their request keys. If an attempt is moved to another peer before requeue takes the lock, the scan pulls the fresh attempt off the wire and records a refusal against its new address. This affects any keyed request moved between the scan and the retry, including a block or filter moved by a pending refusal event.
rust-dashcore/dash-spv/src/network/broker.rs
Lines 360 to 364 in 6e81119
How to fix it
Apply expiry to the exact attempt checked under the registry lock, or revalidate its identity and timeout before changing state. Do not expire whichever attempt happens to own the same key later.
Checked in the code
On the flagged line: Reacquires broker state through requeue with a key-only predicate
Takes the lock for the timeout scan
rust-dashcore/dash-spv/src/network/broker.rs
Lines 333 to 337 in 6e81119
Saves only key.clone() for a retry
rust-dashcore/dash-spv/src/network/broker.rs
Lines 357 to 361 in 6e81119
Records the address of the attempt removed by requeue, not the one observed by the scan
rust-dashcore/dash-spv/src/network/broker.rs
Lines 245 to 249 in 6e81119
dash-spv/src/network/broker.rs:492:*slot = ReqState::OnWire(Box::new(OnWire {
- Create an issue for this
✨ Block notfound messages bypass the check for a later outstanding copy
Suggestion, not blocking · Correctness · Moderate · dash-spv/src/network/manager.rs:1380
Why: A notfound settles only the first matching ledger entry, but the pump records a refusal for the key even when another copy is still owed or the ledger matched no request. Unlike an inferred skip, a negative reply to an older copy can therefore pull a current block request off the wire and stop the router from using that address for ten seconds.
rust-dashcore/dash-spv/src/network/manager.rs
Lines 1378 to 1382 in 6e81119
How to fix it
Have the ledger report explicit refusals only for matched entries whose last outstanding copy was settled, and feed those outcomes through the same broker path as inferred skips. Continue forwarding the original message to subscribers.
Checked in the code
On the flagged line: Derives broker refusals directly from the inventory rather than the ledger
Finds and removes only the first matching Awaited entry
rust-dashcore/dash-spv/src/network/costs.rs
Lines 243 to 249 in 6e81119
Returns Vec::new() instead of reporting the settlement outcome
rust-dashcore/dash-spv/src/network/costs.rs
Lines 250 to 254 in 6e81119
Suppresses an inferred skip when owed.contains(&earlier.reply)
rust-dashcore/dash-spv/src/network/costs.rs
Lines 296 to 300 in 6e81119
- Create an issue for this
What to test
The review model wrote these steps. Check what a step runs before you follow it.
Setup: Run the dash-spv network unit tests and a testnet sync with cargo run -p dash-spv --features cli --bin dash-spv -- --network testnet --data-dir <dir>, with peer_speed and dash_spv::network debug logs on.
- Run
cargo test -p dash-spv --lib network::. Expect the new refusal, skip and failed-write tests to pass. - Sync testnet from scratch. Expect blocks and filters to complete with no long pause after a
notfoundin the logs. - Configure a single peer that lacks some blocks. Expect a refused block to be asked of that peer again after about 10 s, not lost.
- Kill a peer mid-sync while blocks are on the wire to it. Expect its requests to be re-queued and served by another peer.
- Leave the client syncing near the tip with two peers. Expect
endgame: hedged blocklines to still appear while a filter batch both peers refused sits queued. - Edge case: stop and restart the network manager after refusals. Expect refused requests to go out again with no stale refusal kept.
Checked and left out: 1 finding
Not proven, so not listed · 1 warning
- A batched block request allocates a full inventory copy for every block ·
dash-spv/src/network/broker.rs:494
A check of the code could not confirm it.
The progress comment has the full log under "Judge decisions", in its "Review metadata" fold.
About this review
- Reviewed
6e81119, round 13 - 697 changed lines read in 16m 24s
- Found by
claude-opus-5-5andgpt-6.2-sol, judged byclaude-opus-5-5 - Tokens: 5.7M in (4.3M from cache) · 116k out · about $8.03 at API prices
- Runner: self-hosted · started after 48s · peak memory 4.9 GiB of 30.0 GiB
- How Manki reviews
ZocoLini
left a comment
There was a problem hiding this comment.
The core fix (settle returns skipped keys → requeue at once) looks right. Would remembering only the last refusing peer, and letting the router skip a refused message as it already does, be enough? The refusal map, hold in pop_guaranteed and has_routable add most of the size for cases that seem rare. Or am I missing something?
|
✅ Review complete in 14m 20s Planner (5s) Review (behavior · full): 12 findings Judge (9m 32s) Posted: 3 findings Review metadataConfig:
Account limits:
Judge decisions:
Timing:
Last reviewed
|
|
Your move: coderabbitai left review threads unresolved; resolve them. |
There was a problem hiding this comment.
✅ Approved. 3 suggestions, none of which block.
What this does: A peer that skips a request, sends notfound or lets it expire was asked for the same data again at once. The broker now remembers which addresses refused each request for 10 seconds and sends it elsewhere, or waits.
2 suggestions · not blocking
✨ Expiry can record a refusal against a replacement peer
Suggestion, not blocking · Concurrency · Moderate · dash-spv/src/network/broker.rs:361
Why: expire records only the key of an exhausted attempt, then drops the request lock before requeueing it. If the reader or disconnect handler requeues that key and routing assigns it to a new peer in between, expiry requeues the fresh attempt and holds off its address for 10 seconds even though it has not stalled.
rust-dashcore/dash-spv/src/network/broker.rs
Lines 359 to 363 in c3a7d97
How to fix it
Validate expiry and move the expired attempt to the queued state in the same request-lock transaction. Alternatively, carry an attempt identity into the requeue operation and apply it only if that exact attempt is still on the wire.
Checked in the code
On the flagged line: Reacquires the lock through requeue with a predicate that ignores OnWire.
Reads stall state under the request lock, but line 357 retains only key.clone().
rust-dashcore/dash-spv/src/network/broker.rs
Lines 332 to 336 in c3a7d97
Records a refusal against whichever peer owns the entry when it is removed.
rust-dashcore/dash-spv/src/network/broker.rs
Lines 245 to 249 in c3a7d97
rust-dashcore/dash-spv/src/network/broker.rs
Lines 356 to 360 in c3a7d97
- Create an issue for this
✨ A block notfound can mark the peer as refusing a copy it still owes
Suggestion, not blocking · Correctness · Quick fix · dash-spv/src/network/manager.rs:1380
Why: A peer can owe two copies of a block, for example when another copy is sent after an expiry and the refusal hold lapses. A notfound can settle the older copy while the newer one is still outstanding, but the pump uses the raw inventory to requeue the current copy and renew the hold. The skip path checks for a later copy, but the notfound path bypasses that check.
rust-dashcore/dash-spv/src/network/manager.rs
Lines 1378 to 1382 in c3a7d97
How to fix it
Have the ledger report notfound refusals only for matching outstanding copies with no later copy still owed. Let the pump consume those reconciled refusals rather than inferring them from raw inventory.
Checked in the code
On the flagged line: Calls broker.refused(peer, &inventory_keys(inv)) independently of what the ledger matched.
Requeues expired requests as refused, and dash-spv/src/network/broker.rs:125 allows the address again after the hold.
rust-dashcore/dash-spv/src/network/broker.rs
Lines 360 to 364 in c3a7d97
Finds and removes the first matching ledger entry and line 251 returns Vec::new().
rust-dashcore/dash-spv/src/network/costs.rs
Lines 245 to 249 in c3a7d97
Suppresses an inferred skip when owed still contains the reply.
rust-dashcore/dash-spv/src/network/costs.rs
Lines 296 to 300 in c3a7d97
dash-spv/src/network/broker.rs:125:self.refused.get(&addr).is_some_and(|at| at.elapsed() < REFUSAL_HELD)dash-spv/src/network/costs.rs:251:return Vec::new();
- Create an issue for this
What to test
The review model wrote these steps. Check what a step runs before you follow it.
Setup: Run the CLI against testnet with cargo run -p dash-spv --features cli --bin dash-spv -- --network testnet --data-dir <dir> and enable debug logs for dash_spv::network.
- Sync from scratch with several peers. Expect headers, filters and blocks to complete, with no growing re-send loop for one request in the logs.
- Connect a single peer that lacks a requested block, so it answers
notfound. Expect the block to be asked of that peer again only about every 10 s, not in a tight loop. - With two or more peers, make one peer skip a block, for example by answering a later block first. Expect the skipped block to go to another peer.
- Make a peer stall until its write times out. Expect the connection to close and its requests to go to the peer that joins next.
- During the block endgame, keep a filter batch refused by every peer. Expect
endgame: hedged blocklines to appear anyway. - Edge case: let every connected peer refuse the same request. Expect it to stay queued and other queued requests to keep going out until the refusals lapse.
Checked and left out: 2 findings (1 unproven, 1 rare)
Not proven, so not listed · 1 warning
- Request timing is fixed only after the routing pass, while the stall check reads the earlier times during it ·
dash-spv/src/network/broker.rs:447
A check of the code could not confirm it.
Rare trigger, so not listed · 1 warning
- A failed write to a peer whose disconnect was already handled leaves its request on the wire and gets the address banned ·
dash-spv/src/network/broker.rs:437
Trigger 3 of 10, below the cut-off of 4.
The progress comment has the full log under "Judge decisions", in its "Review metadata" fold.
About this review
- Reviewed
c3a7d97, round 14 - 696 changed lines read in 14m 20s
- Found by
claude-opus-5-5andgpt-6.2-sol, judged byclaude-opus-5-5 - Tokens: 8.3M in (6.6M from cache) · 148k out · about $10.13 at API prices
- Runner: self-hosted · started after 11s · peak memory 5.5 GiB of 30.0 GiB
- How Manki reviews
| /// already stalled [`KICKING_ATTEMPTS`] times is retried without blaming its peer. | ||
| /// Returns the peers of stalled requests, each with the earliest instant it is blamed from. | ||
| /// A request stalls on a timeout without progress, or [`ANSWER_TIMEOUTS`] timeouts unanswered. | ||
| /// Every send counts toward [`KICKING_ATTEMPTS`], after which a stall is retried without blame. |
There was a problem hiding this comment.
✨ Suggestion, not blocking · Documentation · Quick fix
The expiry comment overstates which sends use a kicking attempt
Why: The comment says every send counts, but hedge sends do not increment the attempt counter and a failed primary write rolls its increment back.
How to fix it and 6 places read
How to fix it
Describe the threshold in terms of successfully written primary attempts.
Checked in the code
On the commented line: Says Every send counts.
Increments attempts during primary registration, and line 518 rolls that increment back on write failure.
rust-dashcore/dash-spv/src/network/broker.rs
Lines 489 to 493 in c3a7d97
Records a hedge in self.hedges, and lines 549 and 598 send it without updating attempts.
rust-dashcore/dash-spv/src/network/broker.rs
Lines 148 to 152 in c3a7d97
rust-dashcore/dash-spv/src/network/broker.rs
Lines 517 to 521 in c3a7d97
dash-spv/src/network/broker.rs:549:peer.send(&msg).await.ok().map(|()| height)dash-spv/src/network/broker.rs:598:peer.send(&msg).await.ok().map(|()| height)
- Create an issue for this
- Dismiss this finding
Dash Core sends nothing for a
getcfheadersorgetcfilterswhose range its filter index lacks, nor for a block it does not have. The broker put such a request back in the queue with nothing that kept it from the peer that refused it, so the router could send it straight back there. A skipped request also never expired at a busy peer, since every answer from that peer counted as progress on it. A testnet run sent three filter header batches to such peers 45 to 47 times each over 9 minutes.Peers answer in request order, and since #1563 the connection's ledger settles the requests a reply proves skipped.
Ledger::settlenow also returns their keys, unless the peer still owes a later copy of the same request. The peer reader passes them to the broker, which retries them at once, like a block the peer sentnotfoundfor.A skipped request, a block not found and a request that expired after its kicking attempts are not routed or hedged to that peer's address for
REFUSAL_HELD. While every peer with room refuses a request, the router sends the rest of the queue and keeps that request without waking itself, and the hedger still hedges overdue blocks. The refusal lapses, so a node whose index was only catching up, or a lone configured peer, is asked again.PR Hygiene ·
c3a7d97/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.Summary by CodeRabbit