Repository navigation
fix(dash-spv): time an idle peer from its first request - #1332
Conversation
|
No actionable comments were generated in the recent review. Walkthrough
Merge Risk:
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## dev #1332 +/- ##
=======================================
Coverage 85.16% 85.16%
=======================================
Files 268 268
Lines 68085 68105 +20
=======================================
+ Hits 57983 58005 +22
+ Misses 10102 10100 -2
|
The timeout monitor flagged a peer with in-flight bytes whose byte counter had not risen for `request_timeout`, counting from the last byte it sent. A peer that stayed quiet at the tip for more than that was kicked and banned at the first check after it was given work. The stall clock now restarts on every check that finds the peer idle, so it counts from when the peer was given work. A peer that stays silent with work is still kicked after the full timeout.
6adff5f to
1291b11
Compare
|
/self-reviewed |
|
Waiting for bot review — coderabbitai not yet. Wait for the missing reviews, or a writer can post |
Closes #1329.
Problem
The timeout monitor flags a peer that has bytes in flight and whose byte counter has not risen for
request_timeout(10 s minimum). The clock counted from the last byte the peer sent, not from when it was given work. At the chain tip a peer is often quiet for more than 10 s, so the first request sent to it got it kicked and banned at the next one second check.A testnet run showed two such kicks, 60 to 160 ms after the send. Both peers had nothing in flight before the request, so this is not the leaked charge from #1219:
Fix
The per-peer check in
spawn_timeout_monitoralso restarts the stall clock on every tick that finds the peer with nothing in flight. The clock therefore starts at the last idle tick before the peer was given work, and a peer that stays silent with work is still kicked aboutrequest_timeoutafter the send. No extra per-peer state is needed. A peer's in-flight charge only drops on an inbound message, which also raises its byte counter, so an idle to busy change between two ticks cannot slip past the check.broker.expiretimes each request from its own progress and is unaffected.Tests
the_timeout_monitor_times_an_idle_peer_from_its_first_requestadmits a loopback peer, leaves it idle for three timeouts, then charges it with agetcfilters. It must still be connected two checks later and be kicked once a furtherREQUEST_TIMEOUTpasses in silence. It never registers the request with the broker, so a kick can only come from the per-peer check. Without the fix it fails with the peer kicked right after its first request.cargo test -p dash-spv --lib: 639 passed (ondevatc9aeac0d0).just dash-spv::test: all green, including dashd_sync 38/38 and dashd_masternode 11/11.Related: #1228, whose kicked peers had also stopped sending 10 to 18 s before the kick. This fix may explain part of it, but other causes there are not ruled out.
PR Hygiene ·
1291b11When 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