Skip to content

fix(dash-spv): size byte caps from the served rate - #1371

Draft
xdustinface wants to merge 1 commit into
fix/cfilters-settle-on-arrivalfrom
fix/rate-sized-cap
Draft

xdustinface wants to merge 1 commit into
fix/cfilters-settle-on-arrivalfrom
fix/rate-sized-cap

Conversation

@xdustinface

@xdustinface xdustinface commented Nov 9, 2026 •

Copy link
Copy Markdown
Collaborator

A peer's in-flight byte cap was set by a round-trip based limiter whose step grew with the queue, so slow peers reached caps of tens of megabytes. On mainnet a burst raised one peer's cap to 15.7 MB while it delivered 0.4 to 0.8 MB/s.

Each peer's cap now follows its own served rate, TARGET_QUEUE_SECS of it. It rises at once when the rate supports it and falls only while the peer serves all it can. The floor is two getheaders2 replies, so a new peer has one header request queued behind the one it serves. The global limiter is gone, since a full link already shows in the peer rates. The frontier filter batch and the lowest endgame block are hedged once they have been on the wire for twice the queue they were sent behind, and a peer still being measured is timed by what it served in the last two seconds, so shortest-queue routing no longer falls back to the cap ratio.

The floor relies on the getheaders2 pricing from #1369, which is in dev now.

Stacked on #1370, and will be retargeted to dev when that one merges.

@coderabbitai

coderabbitai Bot commented Nov 9, 2026 •

Copy link
Copy Markdown
Contributor
Pre-merge checks: Passed 1 · Inconclusive 1

Failed Failed checks: 1 inconclusive

Check name Status Explanation Resolution
Title check Pending This assessment has not completed. The check will be retried on the next pre-merge check run.
Passed Passed checks: 1 passed

Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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

@codecov

codecov Bot commented Nov 9, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 97.96610% with 6 lines in your changes missing coverage. Please review.
✅ Project coverage is 85.79%. Comparing base (bb5a0d0) to head (a92d094).

Files with missing lines Patch % Lines
dash-spv/src/network/broker.rs 95.80% 6 Missing ⚠️
Additional details and impacted files
@@                        Coverage Diff                         @@
##           fix/cfilters-settle-on-arrival    #1371      +/-   ##
==================================================================
+ Coverage                           85.75%   85.79%   +0.03%     
==================================================================
  Files                                 268      268              
  Lines                               70790    70948     +158     
==================================================================
+ Hits                                60706    60867     +161     
+ Misses                              10084    10081       -3     
Flag Coverage Δ
core 82.80% <ø> (ø)
rpc 52.10% <ø> (ø)
spv 94.50% <97.96%> (+0.04%) ⬆️
wallet 83.53% <ø> (ø)
Files with missing lines Coverage Δ
dash-spv/src/network/costs.rs 96.00% <ø> (ø)
dash-spv/src/network/manager.rs 91.87% <100.00%> (+0.39%) ⬆️
dash-spv/src/network/peer.rs 91.11% <100.00%> (-0.06%) ⬇️
dash-spv/src/network/broker.rs 98.19% <95.80%> (-0.31%) ⬇️

... and 4 files with indirect coverage changes

@xdustinface
xdustinface force-pushed the fix/cfilters-settle-on-arrival branch from 3a69ba0 to 73f9869 Compare November 10, 2026 06:07
@github-actions github-actions Bot added the merge-conflict The PR conflicts with the target branch. label Nov 10, 2026
@github-actions

Copy link
Copy Markdown
Contributor

This PR has merge conflicts with the base branch. Please rebase or merge the base branch into your branch to resolve them.

@xdustinface
xdustinface force-pushed the fix/cfilters-settle-on-arrival branch 2 times, most recently from 60cb181 to 810e7de Compare November 10, 2026 06:11
@github-actions github-actions Bot removed the merge-conflict The PR conflicts with the target branch. label Nov 10, 2026
@xdustinface
xdustinface force-pushed the fix/cfilters-settle-on-arrival branch from 810e7de to 74f9283 Compare November 10, 2026 14:27
A peer's in-flight cap now follows its own served rate, `TARGET_QUEUE_SECS` of it. The cap rises at once when the rate supports it, so a fast peer reaches megabytes within a second or two, and a slow peer stays near the floor. A small probe lets a peer limited by its cap find more, and ticks of a stalled link are skipped. This replaces the round-trip based limiter, whose step grew with the queue and reached tens of megabytes on slow peers.

The served rate and the cap fall only while the peer serves all it can: while it is bound at its cap, or while it holds more than `TARGET_QUEUE_SECS` of what it delivers below its cap. Below that a peer shows how much it was asked for. Less than `MIN_CAP_BYTES` in flight is a reply or two in the making and leaves both alone. Only a bound peer probes for a higher cap. On mainnet a burst raised one peer's cap to 15.7 MB while it delivered 0.4 to 0.8 MB/s, and the router queued up to 8.8 MB below that cap.

The floor is two `getheaders2` replies, so a new peer has one queued behind the one it serves. A 336 KB reply did not fit the old 256 KB floor twice.

The global limiter is gone. Each cap follows its peer's share of the client's link, so a full link already shows up in the peer rates, and `PeerFlow` samples the serving rate while the peer is bound to its own cap. The `peer_speed` lines drop `base` and `global_cap` and gain `served`.

Replaying the six logs of the slow and fast testnet runs, the peak peer cap on the slow run falls from 4.7 MB to 2.1 MB and its implied queue from 17 s to 6 s, while over the first 60 s of the four fast logs the bytes delivered range from 6% below to 6% above the unbounded limiter and from 2% to 8% above the step-bound one.

The hedges and the shortest-queue pick build on the served rate:

- The frontier filter batch and the lowest endgame block get a second copy once their peer answered nothing for `HEDGE_AFTER`, or once they have been on the wire for `HEDGE_QUEUE_FACTOR` (2) times the queue they were sent behind, `in_flight / rate` of the peer at send, and never before `HEDGE_OVERDUE` (10 s). A peer that keeps trickling other replies held a frontier batch for 118 s in one testnet run. A fixed 10 s bound instead hedged the mainnet frontier batch 20 to 76 times per sync, mostly while the batch merely waited in a long queue. The queue is taken at send, so a peer that slows down does not earn more time.
- The hedge log names the holder, the time on the wire, the overdue threshold, the holder's silence and the peer asked for the copy.
- A peer without a serving rate is timed by its served rate of the last two seconds, published as `PeerHandle::served`, so the shortest-queue pick no longer falls back to the cap ratio whenever one busy peer is still being measured. A busy peer that delivered nothing yet goes last.
- Both hedges go to the peer with a serving rate that answers soonest, and to an unmeasured peer only when no measured one qualifies. An idle newcomer used to win the second copy.
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