Repository navigation
Description
Problem
On refactor/network-mod (#902), verified at 49b5fe23 (the same Rust code as 748816fe, where it was first seen), once headers are synced every newly connected peer is kicked for "request timeout" about 11-13s after it connects, with nothing to re-queue. The supervisor dials replacements, they are kicked the same way, and the client churns peers for as long as it stays synced.
Root cause
- When the headers manager is
Synced(and the pipeline is initialized, the address is not inannounced_peers, and no tip request is pending), it handlesPeerConnectedby sendingGetHeaders(tip)to the new peer throughsend_to(sync/block_headers/sync_manager.rs:212-229). send_to(network/manager.rs:614-631) callspeer.send(&msg, sizes.cost(&msg)).GetHeaderspassesis_pipeline_request(peer.rs:351), sosendcharges the peer onein_flightunit andcostbytes (peer.rs:231-234). No request-registry entry is created.- Units are only given back through registry-keyed paths:
request_answered(manager.rs:634-646, which needs anOnWireentry), the router and hedge refunds, and block arrival. None covers this send. The peer answers with an emptyheaders(Dash Core always replies, empty when the locator is its tip), which matches no pending segment and resolves nothing. The leak lasts for the life of the connection, and a kick clearsannounced_peers, so a reconnect leaks again. - The timeout monitor (
manager.rs:1601-1611) flags any peer within_flight() > 0whose byte counter has not risen forrequest_timeout(lag)=max(10s, 6 x lag). The idle announced peer trips it and is kicked withretried 0 request(s).
Second cause: the leaked cost can lock a new peer out of work
The router only routes to a peer with in_flight_bytes < cap (manager.rs:810-818), and a new peer starts at INITIAL_CAP_BYTES = 256 KB. The leaked unit is charged the headers class's expected response size, which was 297 KB in one run and 503 KB in another. At that size every announced peer is full on arrival, gets no work, and its cap cannot grow.
Those sizes are impossible for a real headers response, which is at most 2000 x 81 B, about 158 KB. ClassSizes::received counts the bytes of headers messages that are never answered (announcement replies, unsolicited headers), which inflates the estimate. With a sane estimate the leaked cost fits under the cap and the peer can still take work while there is any. In one run the estimate fell from 503 KB to 172 KB at 12:17, and the next announced peer received blocks within a second.
Evidence
Two mainnet full syncs from a dev vs refactor/network-mod benchmark (2026-10-26):
- Run 4: 40 announcements, all 40 announced peers kicked with
retried 0, each living 11-14s (two lived 78s and 111s after getting real work first). There were no 0-requeue kicks of peers that were not announced to. - Run 3: 37 of 38 announced peers kicked with
retried 0(the 38th survived only because the run ended). There were no 0-requeue kicks of peers that were not announced to. - Each announced peer sits at
cap=256 KB in_flight=1 (297 KB) rate=0.00 MB/s, and total in flight steps in units of about 298 KB.
12:49:02.500 Announcing tip 2561735 to new peer 135.181.50.32:9999
12:49:05.960 decompressed 0 headers from 135.181.50.32:9999
12:49:16.375 request timeout: kicked 1 peer(s) {PeerId { addr: 135.181.50.32:9999, connection: 21 }}, retried 0 request(s)
Impact
- Synced steady state: a synced client can never keep a replacement peer. Every new connection is kicked about 12s later, and it reconnects forever.
- During a sync: peers that connect after headers finish are useless while the estimate exceeds 256 KB. In run 4 this turned a stall into 3 minutes with no blocks:
- The only working peer, 151.244.85.212, was itself stalling. It had about 635 requests in flight on a cap that had run away, see #1220. It was kicked at 12:50:54 with
retried 635. - Every replacement was announced to and full on arrival, so nothing could take those 635 requests (
sum_peer_cap=768 in_flight=893 KB, norouter: sentfor 3.5 minutes). - It recovered at 12:53:41 only when the peer set drained to zero.
PeersUpdated(0)runsstop_sync, which takes the headers manager out ofSynced, so the next peers were not announced to.
- The only working peer, 151.244.85.212, was itself stalling. It had about 635 requests in flight on a cap that had run away, see #1220. It was kicked at 12:50:54 with
Fix
- Do not charge
send_tomessages that have no registry entry, or register the announcement so its reply releases the unit. - Only learn
ClassSizesfrom replies that answer a registered request, so the headers estimate cannot exceed a real response. - Test: send a pinned
GetHeadersto an idle peer and assert that the peer survives pastrequest_timeoutand can still be routed work.
Related
- #1218: peers swapped in by the slow-peer path never get
PeerConnected, so they never get the announcement and escape this kick. Fixing fix(dash-spv): slow-peer swap onrefactor/network-modadds a peer without emittingPeerConnected#1218 alone would expose them to it too, so this one should land first or together with it. - #1220: the runaway cap that let one slow peer hoard 635 requests.
Activity
[-]fix(dash-spv): pinned tip-announce `GetHeaders` leaks an in-flight slot on `refactor/network-mod`, so every new peer is kicked once synced[/-][+]fix(dash-spv): pinned tip-announce `GetHeaders` leaks an in-flight slot on `refactor/network-mod`, kicking every new peer and wedging sync[/+][-]fix(dash-spv): pinned tip-announce `GetHeaders` leaks an in-flight slot on `refactor/network-mod`, kicking every new peer and wedging sync[/-][+]fix(dash-spv): pinned tip-announce `GetHeaders` leaks an in-flight slot on `refactor/network-mod`, kicking every new peer and stalling sync[/+]fix(dash-spv): charge every request by the replies it awaits