Repository navigation
fix(dash-spv): rank a stalled peer last when routing - #1375
xdustinface wants to merge 16 commits into
Conversation
|
Important Draft PR not reviewedDraft PRs are not automatically reviewed by default.
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. |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## dev #1375 +/- ##
==========================================
+ Coverage 87.96% 87.97% +0.01%
==========================================
Files 270 270
Lines 72505 72688 +183
==========================================
+ Hits 63780 63949 +169
- Misses 8725 8739 +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. |
e1ff95c to
36ddbe3
Compare
36ddbe3 to
92741dc
Compare
30b3af3 to
259d131
Compare
92741dc to
c54619d
Compare
259d131 to
9402114
Compare
|
Follow-up from the #1345 review: a culprit that |
c54619d to
3ad9174
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 14m 36s Planner (5s) Review (behavior · full): 11 findings Judge (8m 23s) Posted: 4 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.
1 suggestion · not blocking
✨ Measured hedge candidates ignore the stalled rank
Suggestion, not blocking · Pre-existing · Performance · Quick fix · dash-spv/src/network/broker.rs:626
The same problem remains here. This PR fixes it at dash-spv/src/network/broker.rs:582 but not on this path.
Why: A peer marked stalled for low throughput can still have a recent small reply, so it passes the hedge silence check. Both block and filter hedges then use its old rate ahead of a healthy candidate, because only the no-rate fallback applies the new rank.
How to fix it
Apply the same stall preference to hedge candidates before comparing finish times. Keep the existing silence check, which also excludes peers that do not qualify as hedge recipients at all.
- Create an issue for this
2 more suggestions are not listed.
About this review
- Reviewed
3ad9174, round 1 - 167 changed lines read in 14m 36s
- Found by
claude-opus-5-5andgpt-6.2-sol, judged byclaude-opus-5-5 - Tokens: 4.1M in (3.0M from cache) · 94k out · about $6.43 at API prices
- Runner: self-hosted · started after 11s · peak memory 3.7 GiB of 30.0 GiB
- How Manki reviews
|
✅ Review complete in 12m 58s Planner (6s) Review (behavior · full): 14 findings Judge (6m 9s) 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. CI started for d2e7005: Continuous integration, Pre-commit Checks, Sanitizer. |
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.
Still open from earlier reviews:
dash-spv/src/network/manager.rs:621: A request the broker gave up on keeps its peer flagged stalled whenever it goes quiet (view thread)
1 suggestion is not listed.
About this review
- Reviewed
91a07b2, round 2 - 188 changed lines read in 12m 58s
- Found by
claude-opus-5-5andgpt-6.2-sol, judged byclaude-opus-5-5 - Tokens: 5.8M in (4.8M from cache) · 105k out · about $6.60 at API prices
- Runner: self-hosted · started after 13s · peak memory 3.9 GiB of 30.0 GiB
- How Manki reviews
|
✅ Review complete in 11m 41s Planner (5s) Review (behavior · full): 11 findings Judge (5m 2s) Posted: 3 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. 2 suggestions, none of which block.
- Check approval
What this does: A peer that owes data but has gone almost silent kept its old speed figures, so the router could still pick it for new block, header or filter requests and for backup copies. Such peers are now flagged as stalled and passed over while another peer can take the work.
1 suggestion · not blocking
✨ A bursty healthy connection can keep a silent peer ranked highly beyond two seconds
Suggestion, not blocking · Pre-existing · Correctness · Moderate · dash-spv/src/network/manager.rs:623
The same problem remains here. This PR fixes it at dash-spv/src/network/broker.rs:587 but not on this path.
Already broken before this PR. Two checks found the same problem on dev at dash-spv/src/network/manager.rs:659, so it doesn't block this PR.
Why: When two peers owe replies, the controller calls every 250 ms interval without incoming bytes a local link stall. If one peer is silent and the other returns blocks or filter data in bursts about once a second, the silent peer earns only one stall tick per burst and can keep its old rank for about eight seconds instead of two. New requests can still queue behind that peer during the delay.
How to fix it
Use recent activity to distinguish an intermittent but working link from a sustained outage when measuring peer stalls. Keep the per-tick silence signal for cap protection, but do not use it alone to stop the peer stall clock.
- Create an issue for this
📌 1 follow-up agreed for later
Agreed in their threads as later work. None of them blocks.
dash-spv/src/network/manager.rs:621: A request the broker gave up on keeps its peer flagged stalled whenever it goes quiet (view thread)
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 several peers and peer_speed and dash_spv::network debug logging enabled, for example cargo run -p dash-spv --features cli --bin dash-spv -- --network testnet --data-dir <dir>.
- Sync normally with several peers. Expect sync speed comparable to before and few or no
stalled:log lines. - Freeze one peer mid-sync, for example by blocking its traffic with a firewall rule. Expect a
<addr> stalled: owes ... KBdebug line after about 2 seconds. - Keep that peer frozen. Expect new block and header requests and hedge copies to go to the other peers, not to the frozen one.
- Unblock the peer before the timeout monitor kicks it. Expect a
no longer stalled after ...sline once it delivers again. - Drop your own network briefly. Expect no peer to be marked stalled because of the outage.
- Edge case: run with a single peer and freeze it. Expect requests still to be routed to it, since a stalled peer is used when it is the only one.
About this review
- Reviewed
d3268c6, round 3 - 273 changed lines read in 11m 41s
- Found by
claude-opus-5-5andgpt-6.2-sol, judged byclaude-opus-5-5 - Tokens: 5.5M in (4.3M from cache) · 96k out · about $7.24 at API prices
- Runner: self-hosted · started after 17s · peak memory 4.6 GiB of 30.0 GiB
- How Manki reviews
|
✅ Review complete in 7m 50s Planner (5s) Review (behavior · full): 7 findings Judge (2m 38s) Posted: 3 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. 3 suggestions, none of which block.
- Check approval
What this does: A peer that owes replies but has stopped delivering could still receive new requests and hedge copies, because it kept the rate and cap it had before. Such a peer is now marked stalled and gets new work only when every peer is stalled.
2 suggestions · not blocking
✨ A routing pass keeps using a peer after it stalls
Suggestion, not blocking · Performance · Quick fix · dash-spv/src/network/broker.rs:358
Tracked in #1237.
Why: route selects the non-stalled peers once, then reuses that list across awaited writes. If a socket write waits while the flow controller marks a peer stalled, the remaining batch can still go to that peer even though another peer is delivering. The reverse also happens: a recovered peer stays excluded until the next pass.
rust-dashcore/dash-spv/src/network/broker.rs
Lines 356 to 360 in c765f5a
How to fix it
Use the initial peer set to size the batch, but refresh eligibility before each send or whenever the flow controller publishes a stall transition. Put unsent messages back when no currently eligible peer has room.
Checked in the code
On the flagged line: Rechecks only !p.is_closed() && p.in_flight_bytes() < p.cap() on the saved list
Computes live before any writes
rust-dashcore/dash-spv/src/network/broker.rs
Lines 332 to 336 in c765f5a
Awaits peer.send(&msg) inside the batch loop
rust-dashcore/dash-spv/src/network/broker.rs
Lines 362 to 366 in c765f5a
Lets a write wait for WRITE_TIMEOUT, which is five seconds at line 92
rust-dashcore/dash-spv/src/network/peer.rs
Lines 356 to 360 in c765f5a
dash-spv/src/network/manager.rs:713: Publishes each transition throughflow.updateand wakes the broker at line 717 without interrupting the current passdash-spv/src/network/peer.rs:92:const WRITE_TIMEOUT: Duration = Duration::from_secs(5);dash-spv/src/network/manager.rs:627:peer.set_stalled(stalled);dash-spv/src/network/manager.rs:717:state.broker.wake();
- Create an issue for this
✨ The router's comment on an empty routing pass no longer matches when it happens
Suggestion, not blocking · Documentation · Quick fix · dash-spv/src/network/manager.rs:454
Why: The comment says sent == 0 means Every peer is at its in-flight cap. After this change, route also returns 0 when every delivering peer is at its cap and only stalled peers have room, because budget sums delivering_first peers only. The router then also waits for a stall to begin or end (the new broker.wake() in the flow controller), not only for a response or a kicked peer.
How to fix it
Reword the comment to say that every peer that may take work is at its cap, and that a stall beginning or ending also wakes the router.
- // Every peer is at its in-flight cap: wait for a response or a kicked peer to free
+ // Every peer that may take work is at its cap: wait for a response, a kicked peer or a stall that begins or ends (all notify). The sleep is only a backstop against a missed wake.Repository rule
This PR breaks a required rule of AGENTS.md: When your change makes a nearby comment untrue, fix that comment.
Checked in the code
On the flagged line: if sent == 0 { // Every peer is at its in-flight cap: wait for a response or a kicked peer to free a slot (both notify)
let live = delivering_first(...) and budget summed over live, if budget == 0 { return 0; }, so stalled peers' room no longer counts
rust-dashcore/dash-spv/src/network/broker.rs
Lines 332 to 336 in c765f5a
if stalls_changed { state.broker.wake(); } is a new wake source the comment leaves out
rust-dashcore/dash-spv/src/network/manager.rs
Lines 715 to 719 in c765f5a
- Create an issue for this
📌 1 follow-up agreed for later
Agreed in their threads as later work. None of them blocks.
dash-spv/src/network/manager.rs: A request the broker gave up on keeps its peer flagged stalled whenever it goes quiet (view thread)
What to test
The review model wrote these steps. Check what a step runs before you follow it.
Setup: Run the client against testnet with RUST_LOG=dash_spv::network=debug, enough peers for comparison (for example max_peers 3) and filters enabled.
- Sync filters and blocks normally. Expect occasional
stalled: owes ... KBandno longer stalled after ...debug lines, and no drop in overall throughput. - Freeze one peer mid-reply, for example by firewalling its inbound traffic for a few seconds. Expect its
stalledline after about 2 s and no newgetdataorgetcfiltersrouted to it while the other peers deliver. - With that peer frozen, check the
hedged filter batchandendgame: hedged blocklines. Expect the copies to go to peers other than the frozen one. - Unfreeze the peer before the 10 s request timeout. Expect
no longer stalledand new work routed to it again. - Run with a single peer and freeze it briefly. Expect requests still to be routed to it, since a stalled peer is used when every peer is stalled.
- Drop the whole network link for several seconds. Expect no new
stalledlines for peers that were not already flagged before the outage.
About this review
- Reviewed
c765f5a, round 4 - 348 changed lines read in 7m 50s
- Found by
claude-opus-5-5andgpt-6.2-sol, judged byclaude-opus-5-5 - Tokens: 4.2M in (3.2M from cache) · 81k out · about $6.10 at API prices
- Runner: self-hosted · started after 8s · peak memory 6.4 GiB of 30.0 GiB
- How Manki reviews
|
✅ Review complete in 9m 37s Planner (5s) Review (behavior · full): 11 findings Judge (4m 36s) Posted: 2 findings Review metadataConfig:
Account limits:
Judge decisions:
Timing:
|
|
This PR has merge conflicts with the base branch. Please rebase or merge the base branch into your branch to resolve them. |
b32a034 to
4e3eda1
Compare
|
✅ Review complete in 11m 55s Planner (6s) Review (behavior · full): 14 findings Judge (4m 55s) Posted: 3 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. 3 suggestions, none of which block.
- Check approval
What this does: A peer that owes replies but has sent almost nothing for two seconds kept getting new requests and hedge copies, because its old rate still ranked it well. Such a peer is now flagged as stalled and skipped while another peer is delivering, so requests go to peers that answer.
1 suggestion · not blocking
✨ The block hedge goes to a stalled peer while a delivering peer is open but mid-reply
Suggestion, not blocking · Pre-existing · Performance · Moderate · dash-spv/src/network/broker.rs:427
The same problem remains here. This PR fixes it at dash-spv/src/network/broker.rs:333 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:420, so it doesn't block this PR.
Why: delivering_first sees only the peers answering kept. A peer streaming a large block at full speed has not finished a reply for 2 s, so answering removes it although it is not stalled. If the only other candidates trickle tiny replies, they count as stalled, the fallback picks one of them, and the lowest block's one hedge goes to that peer. Line 423 then refuses any further hedge for that block, so it stays stuck until the timeout reassigns it.
How to fix it
Apply the stall filter before answering drops anything: compute whether any open, non-stalled peer exists, and fall back to stalled peers only when there is none. Otherwise skip stalled peers and send no hedge this round.
- Create an issue for this
2 more suggestions are not listed.
📌 1 follow-up agreed for later
Agreed in their threads as later work. None of them blocks.
dash-spv/src/network/manager.rs: A request the broker gave up on keeps its peer flagged stalled whenever it goes quiet (view thread)
What to test
The review model wrote these steps. Check what a step runs before you follow it.
Setup: Run the SPV client against several peers, for example testnet with cargo run -p dash-spv --features cli --bin dash-spv -- --network testnet --data-dir <dir>, with debug logging for dash_spv::network.
- Sync from scratch with several peers connected. Expect sync to complete, with occasional
stalled: owes ... KBandno longer stalled after ...debug lines. - Freeze one peer mid-sync, for example by pausing its process or dropping its traffic with a firewall rule. Expect a
stalledline for it within about 2 s, and new block and header requests going only to the other peers. - Unfreeze that peer before the request timeout. Expect a
no longer stalledline and the peer taking new work again. - Briefly cut the client's own network for a few seconds. Expect every owing peer to show as stalled, no peer to be swapped out, and sync to resume once the link is back.
- Edge case: connect a single peer and freeze it. Expect requests to stay routed to it, since a peer is skipped only while another is delivering, until the timeout monitor kicks it.
About this review
- Reviewed
4e3eda1, round 8 - 374 changed lines read in 11m 55s
- Found by
claude-opus-5-5andgpt-6.2-sol, judged byclaude-opus-5-5 - Tokens: 6.9M in (5.6M from cache) · 115k out · about $8.03 at API prices
- Runner: self-hosted · started after 13s · peak memory 4.2 GiB of 30.0 GiB
- How Manki reviews
|
✅ Review complete in 10m 12s Planner (4s) Review (behavior · full): 9 findings Judge (3m 20s) 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. 3 suggestions, none of which block.
Caution
Claude subscription has used 70% of its weekly limit, past the 70% mark. It resets 2026-12-04 01:00 UTC.
Once a limit is used up, reviews on that account stop until it resets.
- Check approval
What this does: Before, a peer that stopped sending data while it still owed replies could keep receiving new requests and backup copies. The client now marks such a peer stalled after 2 seconds and sends new work and backup copies to peers that are still delivering.
2 suggestions · not blocking
✨ A routing pass keeps using stall flags after they change
Suggestion, not blocking · Concurrency · Moderate · dash-spv/src/network/broker.rs:358
Tracked in #1237.
Why: The router snapshots stall eligibility once, but a pass can wait for socket writes while the flow controller continues to update those flags. During a multi-request pass, work can still go to a newly stalled peer after another peer has recovered, and the recovery notification cannot change the pass already in progress.
rust-dashcore/dash-spv/src/network/broker.rs
Lines 356 to 360 in a650726
How to fix it
Recompute the preferred set from the open peers before assigning each queued message, not just when calculating the initial budget. Keep the initial budget as a bound on the pass and requeue the remainder if no currently eligible peer has room.
Checked in the code
On the flagged line: Rechecks closure and capacity against live, but not stall eligibility
Builds live once using delivering_first
rust-dashcore/dash-spv/src/network/broker.rs
Lines 332 to 336 in a650726
Awaits peer.send(&msg) inside the routing loop
rust-dashcore/dash-spv/src/network/broker.rs
Lines 362 to 366 in a650726
Waits for the writer lock and the socket write, with WRITE_TIMEOUT applied at line 357
rust-dashcore/dash-spv/src/network/peer.rs
Lines 350 to 354 in a650726
dash-spv/src/network/manager.rs:715: Updates stall flags independently and line 719 only wakes the routerdash-spv/src/network/manager.rs:719:state.broker.wake();
- Create an issue for this
✨ get_cfilters stays duplicated in the manager tests after the other request helpers were shared
Suggestion, not blocking · Maintainability · Quick fix · dash-spv/src/network/manager.rs:1631
Why: The PR now imports get_block and get_headers from broker::tests. Its new so it does for a filter batch case still uses the manager's own get_cfilters, which is identical to broker.rs:800.
rust-dashcore/dash-spv/src/network/manager.rs
Lines 1629 to 1633 in a650726
How to fix it
Make get_cfilters in broker::tests pub(crate) and import it with the other two helpers. Then delete the copy at manager.rs:1631.
Checked in the code
On the flagged line: fn get_cfilters(start: u32) builds GetCFilters { filter_type: 0, start_height: start, stop_hash: BlockHash::dummy(start) }
Has the same body
rust-dashcore/dash-spv/src/network/broker.rs
Lines 799 to 803 in a650726
use crate::network::broker::tests::{get_block, get_headers};
rust-dashcore/dash-spv/src/network/manager.rs
Lines 1608 to 1612 in a650726
- Create an issue for this
📌 1 follow-up agreed for later
Agreed in their threads as later work. None of them blocks.
dash-spv/src/network/manager.rs: A request the broker gave up on keeps its peer flagged stalled whenever it goes quiet (view thread)
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 several peers and debug logging for dash_spv::network, for example cargo run -p dash-spv --features cli --bin dash-spv -- --network testnet --data-dir <dir>.
- Sync filters from scratch. Expect the sync to finish with occasional
stalled: owes ... KBlines, each followed by a matchingno longer stalled after ...line or a kick. - Pause one peer's traffic mid-sync, for example by firewalling its address. Expect a
stalledline for it within about 2 s, new requests going to the other peers, and a kick after the request timeout. - Lift the block before the kick. Expect
no longer stalledand the peer getting new requests again. - Drop the client's own network for about 20 s mid-sync. Expect every owing peer to be logged as stalled, no peer banned, and the sync to resume once the link is back.
- Edge case: run with
max_peersset to 1 and stall that peer. Expect requests still sent to it, because every peer is stalled.
About this review
- Reviewed
a650726, round 9 - 375 changed lines read in 10m 12s
- Found by
claude-opus-5-5andgpt-6.2-sol, judged byclaude-opus-5-5 - Tokens: 4.8M in (3.9M from cache) · 92k out · about $6.07 at API prices
- Runner: self-hosted · started after 8s · peak memory 4.7 GiB of 30.0 GiB
- How Manki reviews
|
This PR has merge conflicts with the base branch. Please rebase or merge the base branch into your branch to resolve them. |
A peer that stopped delivering kept the rates it had earned, so shortest-queue routing kept picking it. In a mainnet run one peer serving 2 to 3 MB/s stalled with blocks owed, received 51 more block requests within 4 s, and each was hedged after 10 s. A peer owing less than its cap is not serving all it can, so its served rate and cap stay where they were and keep its queue looking short. A peer that owes replies and delivers under 8 KB/s for `HEDGE_AFTER` is now stalled, and routing picks a stalled peer only when every candidate is stalled. The flag clears with the first tick of real delivery, so a fast peer computing one reply for less than `HEDGE_AFTER` keeps its rank, and one still streaming a big reply is never flagged. A tick in which our own link stalled neither adds to a stall nor ends it.
The test ticked its own `PeerFlow` pair and passed each peer's cap as its in-flight bytes during bulk download, a state the ledger never held. It now fills both peers to their caps with real requests through `feed`, answers every batch, and lets the running flow controller flag the stall before the router picks a peer. Our link's stall comes from a tick in which no peer delivers, as in production.
A tick in which our own link stalled still ends a stall when the peer delivered or owes nothing, which is right, so the doc no longer claims it never does.
The stall test built its peers through bulk download and then answered every batch inline. A hedge test needs the same start, so the setup moves into a helper, together with the framed bulk filter and batch answer it sends.
A peer flagged stalled that still settled a small reply in the last `HEDGE_AFTER` passes the hedge silence check. `hedge_peer` then ranked it by the rate it had before the stall, so a peer trickling tiny filters could win a second copy over a healthy one. Hedges now pick from the non-stalled candidates whenever one exists, through the same `delivering_first` that routing uses.
The stall counter lived in `PeerFlow::update`, which needs a live peer, while the cap and rates are worked out in the numeric `tick`. It now sits in `tick` beside them, and `update` only publishes and logs.
The stall and hedge tests queued their requests on the broker directly and read the carrier from its registry. They now queue through `NetworkManager::enqueue` and watch which peer's far end receives the request, through a loopback peer that records what its far end reads. The test-only `hedges_of` accessor goes with it.
`route` dropped full peers before it looked at the stall flag, and it counted a stalled peer's room in its budget. In bulk download every delivering peer sits at its cap, so the overflow went to the stalled peer up to the cap it had earned, the incident this branch set out to stop. A stalled peer that owes less than `MIN_CAP_BYTES` is never serving all it can, so that cap does not even shrink. The stall rule now applies to every open peer before the cap check, in routing and in both hedges. While any open peer is not stalled, a stalled peer adds nothing to the budget and takes no request, so the work waits for a delivering peer to free room. The flow controller wakes the router when a stall begins or ends, so work held back for a peer that then stalls too goes out within a tick.
The loopback recorder ends on a frame it cannot decode and drops its sender, and `Feeder::received` read a closed inbox like an empty one. A test that expects no peer to receive a request then passed with a broken recorder. A closed inbox now fails the test, so only an empty, live inbox means nothing was sent.
`for_test_reading` wrapped the decoding recorder of `for_test_recording` and dropped its channel. A frame the recorder could not decode stopped the far end from reading, so the peer's writes failed or blocked in tests that never look at what the peer sends. `for_test_reading` drains the far end raw again, as before the recorder existed, and both helpers share the loopback setup in `for_test_link`.
A frame the recorder could not decode ended it silently, and `Feeder::received` only said the recorder stopped. The recorder now sends the decode error through its channel and drains the rest of the socket raw, so the test fails with the cause.
With two or more peers owing, `link_silent` calls any tick in which no peer delivered a stall of our own link, and such ticks added nothing to a peer's stall. Beside a peer that delivers in bursts, a silent peer then gained a stall tick only on the burst ticks. With one burst in four ticks it was flagged after about 8 s instead of `HEDGE_AFTER`, and kept taking new work meanwhile. Every tick now counts. One tick cannot tell an outage of our own link from a slow peer, and the stall flag only steers routing and hedges, which is safe in a real outage: every owing peer stalls together, `delivering_first` then falls back to every open peer, an idle peer owing nothing stays unflagged and may take work, and each peer clears its flag on its first delivering tick once the link is back. Kicks never read the flag. The per-tick link-silence check still holds the caps and the serving-rate samples.
The manager tests carried their own `get_block` and `get_headers`, the first a copy of the shared builder and the second the broker tests' builder with a fixed locator. `get_headers` moves into `test_utils` beside the other request builders, and both test modules import them.
`a_hedge_skips_a_stalled_peer` only reached `hedge` through a block, so nothing tested that `hedge_filters` puts a stalled peer last. The test now takes the request, and a filter batch case expects its copy to skip the stalled peer. Without `delivering_first` in `hedge_filters` the copy goes to the stalled peer and the case fails.
a650726 to
6619f94
Compare
|
Review superseded by the new commit |
`hedge` and `hedge_filters` ranked stalled peers last before they dropped the peers at their cap. With every delivering alternate at its cap, the stalled alternates with room were already gone, so nothing was hedged at all. The cap now filters first and `delivering_first` ranks what is left, so a stalled peer with room gets the copy when no delivering one has room. The lowest filter batch still ignores the cap. In `a_hedge_skips_a_stalled_peer` the case with the delivering peer full now expects the copy at the stalled peer instead of no copy.
|
✅ Review complete in 9m 44s Planner (5s) Review (behavior · full): 8 findings Judge (3m 12s) Posted: 2 findings Review metadataConfig:
Account limits:
Judge decisions:
Timing:
Last reviewed
|
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.
Caution
Claude subscription has used 70% of its weekly limit, past the 70% mark. It resets 2026-12-04 01:00 UTC.
Once a limit is used up, reviews on that account stop until it resets.
- Check approval
What this does: Peers that owe replies but deliver almost nothing for 2 seconds are now marked as stalled. New requests and second copies of slow requests go to peers that are still delivering.
1 suggestion · not blocking
✨ A routing pass keeps sending to peers that stall mid-pass
Suggestion, not blocking · Pre-existing · Performance · Moderate · dash-spv/src/network/broker.rs:358
Tracked in #1237.
The same problem remains here. This PR fixes it at dash-spv/src/network/broker.rs:430 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:332, so it doesn't block this PR.
Why: The router chooses the non-stalled peers once, before it awaits the queue and socket writes. If a write waits on a busy socket long enough for the flow controller to mark a peer stalled, the router can still send the rest of the batch to that peer based on its old rate.
How to fix it
Use the initial peer set to estimate the pop budget, but recompute stall eligibility from all currently open peers before each send. Keep the rule that stalled peers are eligible only when every open peer is stalled, and return unsent work to the queue when the eligible peers have no room.
- Create an issue for this
📌 1 follow-up agreed for later
Agreed in their threads as later work. None of them blocks.
dash-spv/src/network/manager.rs: A request the broker gave up on keeps its peer flagged stalled whenever it goes quiet (view thread)
What to test
The review model wrote these steps. Check what a step runs before you follow it.
Setup: Run the SPV client against several peers, for example with the CLI on testnet with DASHD_TEST_LOG=1 or a debug log level for dash_spv::network.
- Sync filters and blocks from several peers. Expect
stalled: owes ... KBandno longer stalled after ...debug lines only for peers that pause, and sync to complete. - Freeze one peer mid-download, for example by pausing its process or dropping its traffic with a firewall rule. Expect it to be logged as stalled within about 2 s and new
router: sentwork to go to the other peers. - Unfreeze that peer. Expect
no longer stalledon its first tick with data and the peer to take new requests again. - With a single connected peer, freeze it briefly. Expect requests to keep routing to it once it delivers again, not to stay queued forever.
- Freeze all peers at once, simulating a drop of your own link. Expect queued work to fall back to all peers and sync to resume when the link returns.
- Edge case: let a stalled peer hold the lowest block during the endgame while another peer is idle. Expect the
endgame: hedged blockcopy to go to the idle, delivering peer.
About this review
- Reviewed
d2e7005, round 10 - 381 changed lines read in 9m 44s
- Found by
claude-opus-5-5andgpt-6.2-sol, judged byclaude-opus-5-5 - Tokens: 4.1M in (3.0M from cache) · 87k out · about $6.46 at API prices
- Runner: self-hosted · started after 12s · peak memory 4.6 GiB of 30.0 GiB
- How Manki reviews
A peer that stopped delivering kept the rates it had earned, so shortest-queue routing kept picking it. In a mainnet run one peer serving 2 to 3 MB/s stalled with blocks owed, received 51 more block requests within 4 s, and each was hedged after 10 s.
A peer that owes replies and delivers under 8 KB/s for
HEDGE_AFTERis now stalled. While any open peer is not stalled, a stalled peer takes no new request and its free room does not count, so work waits for a delivering peer even when every delivering peer is at its cap. A stalled peer gets work only when every open peer is stalled, and the router looks again as soon as a stall begins or ends. The flag clears with the first tick of real delivery, so a fast peer computing one reply keeps its rank, and a peer still streaming a big reply is never flagged. A tick in which our own link stalled counts too, since one tick cannot tell it from a slow peer: in a real outage every owing peer stalls together, so routing falls back to all of them, and each flag clears once its peer delivers again. Hedges already skip a silent peer, and they now also skip a stalled peer that still answers small replies whenever another candidate has room. A stalled peer with room still gets the copy when no delivering one has room, so a hedge is never dropped for it.Sampling the serving rate while a peer is backlogged moved to #1564.