Repository navigation
fix(dash-spv): stop swapping peers on idle rates - #1333
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 26 minutes. View limit details
No actionable comments were generated in the recent review. Walkthrough
Merge Risk:
|
d891751 to
378f438
Compare
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## dev #1333 +/- ##
==========================================
+ Coverage 85.17% 85.29% +0.12%
==========================================
Files 268 268
Lines 68101 68678 +577
==========================================
+ Hits 58005 58580 +575
- Misses 10096 10098 +2
|
378f438 to
d2561cb
Compare
d2561cb to
12945f3
Compare
|
Waiting for bot review — coderabbitai not yet. Wait for the missing reviews, or a writer can post |
|
Waiting for bot review — coderabbitai not yet. Wait for the missing reviews, or a writer can post |
|
Bots are done — your move: post |
The flow controller fed every tick with bytes in flight into a peer's `serving_rate`. At the chain tip the only traffic is a few KB of replies whose speed is set by the round trip, so a far peer drifted to a fraction of a near one and the supervisor swapped it out as slow long after sync. `PeerFlow::tick` now samples only while the router can give the peer no more work: its bytes in flight are at its cap, or the client's link cap binds. These are the two conditions the router stops sending on, so a peer short of both is limited by how much it was asked for, not by its bandwidth. Sync-time detection keeps working because bulk download holds peers at one of the two caps.
12945f3 to
5348394
Compare
|
Waiting for bot review — coderabbitai not yet. Wait for the missing reviews, or a writer can post |
|
Bots are done — your move: post |
|
/self-reviewed |
|
Policy satisfied — this can merge. |
Closes #1330.
Problem
The flow controller fed every tick with bytes in flight into a peer's
serving_rate. At the chain tip the only traffic is a few KB of replies (a mempoolgetdata, oneCFHeaders, oneMnListDiff), and their speed is set by the round trip, not by bandwidth. A far peer then drifted to a fraction of a near one, and the supervisor swapped it out as slow long after sync. In a testnet run a healthy peer was swapped out 14 minutes after sync completed:That peer had read only 0.8 MB in total, so it was measured from idle traffic alone.
Fix
refactor: the serving-rate sampling moves out of the flow loop intoPeerFlow::newandPeerFlow::tick, so it can be tested. Behaviour is unchanged.serving_rateonly when the peer has bytes in flight and either they reach its cap or the client's link cap (global_cap) binds. These are the two conditions on which the router stops sending. A peer short of both has no more work waiting, so its rate reflects how much it was asked for, not its bandwidth. The link clause matters because the router keeps peers at a similar in-flight to cap ratio. When the global cap binds, fast peers sit well below their own caps, and without it only the slow peer would ever be sampled.Phases where the pipeline offers less work than the caps allow, such as headers sync and the download endgame, are no longer sampled. Those rates are latency bound, so this is intended. A slow peer is still detected from the bulk filter and block download.
Tests
only_bandwidth_bound_service_condemns_a_peerdrivesPeerFlow::tickfor two peers and feeds the result tounderserving_peer:cargo test -p dash-spv --lib: 642 passed (ondevat4e49ea925).just dash-spv::test: all green, including dashd_sync 38/38 and dashd_masternode 11/11.PR Hygiene ·
5348394When 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