Skip to content

fix(dash-spv): pinned tip-announce GetHeaders leaks an in-flight slot on refactor/network-mod, kicking every new peer and stalling sync #1219

Closed

Description

@xdustinface

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

  1. When the headers manager is Synced (and the pipeline is initialized, the address is not in announced_peers, and no tip request is pending), it handles PeerConnected by sending GetHeaders(tip) to the new peer through send_to (sync/block_headers/sync_manager.rs:212-229).
  2. send_to (network/manager.rs:614-631) calls peer.send(&msg, sizes.cost(&msg)). GetHeaders passes is_pipeline_request (peer.rs:351), so send charges the peer one in_flight unit and cost bytes (peer.rs:231-234). No request-registry entry is created.
  3. Units are only given back through registry-keyed paths: request_answered (manager.rs:634-646, which needs an OnWire entry), the router and hedge refunds, and block arrival. None covers this send. The peer answers with an empty headers (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 clears announced_peers, so a reconnect leaks again.
  4. The timeout monitor (manager.rs:1601-1611) flags any peer with in_flight() > 0 whose byte counter has not risen for request_timeout(lag) = max(10s, 6 x lag). The idle announced peer trips it and is kicked with retried 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, no router: sent for 3.5 minutes).
    • It recovered at 12:53:41 only when the peer set drained to zero. PeersUpdated(0) runs stop_sync, which takes the headers manager out of Synced, so the next peers were not announced to.

Fix

  • Do not charge send_to messages that have no registry entry, or register the announcement so its reply releases the unit.
  • Only learn ClassSizes from replies that answer a registered request, so the headers estimate cannot exceed a real response.
  • Test: send a pinned GetHeaders to an idle peer and assert that the peer survives past request_timeout and can still be routed work.

Related

Activity

  1. changed the title [-]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[/+] on Oct 26, 2026
  2. changed the title [-]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[/+] on Oct 26, 2026
  3. added a commit that references this issue on Oct 27, 2026
    5227359
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions