Coin Brief ENDE

Bitcoin Core stops dropping peers for a missed ping while they are sending it blocks

Bitcoin Core merged pull request #36080 on 5 October, changing when a node enforces its ping timeout. It was written by the contributor mzumsande.

The problem. A node that serves blocks gives priority to a peer's block requests over its other peer-to-peer messages. During initial block download on a connection with little bandwidth, spread across ten peers, that prioritisation can mean a peer does not get round to answering a ping before the 20-minute timeout, and the downloading node then disconnects it, although, as the pull request puts it, the peer has done nothing wrong and is not even slow itself. The issue was reported as #35761.

The fix. The ping-timeout check is moved out of MaybeSendPing(), which the author calls a slightly awkward place for it, and is suspended while there are blocks in flight with that peer. A grace period follows the last block, so the peer has time to send its pong before the timeout applies again.

Bitcoin Core stops dropping peers for a missed ping while they are sending it blocks
Bitcoin Core stops dropping peers for a missed ping while they are sending it blocks — Coin Brief

Why nothing is lost. The pull request lists the other protections that still apply during block download:

  • a dynamic per-block download timeout which, with ten peers in parallel, works out at 600 s × (1 + 0.5 × 9), or 55 minutes per block;
  • the stalling logic, which disconnects a peer that is much slower than the others;
  • the socket inactivity check, which drops a peer that has sent nothing at all for 20 minutes.

Given those, the author argues, the ping timeout added little in this situation. The change adds a functional test, p2p_ping_ibd.py.

Primary source
Bitcoin Core (GitHub pull request)
https://github.com/bitcoin/bitcoin/pull/36080