#36080 p2p: Suspend ping timeout while downloading blocks from a peer
https://github.com/bitcoin/bitcoin/pull/36080 · · +238/-18 in 3 files, 3 commits · labels: P2P
Goal
- Avoid disconnecting well-behaved peers when block downloads delay their ping responses
- Improves initial sync reliability for users on slow or bandwidth-constrained connections
This PR moves the ping timeout check into SendMessages and suspends it for any peer that currently has blocks in flight, with a one-minute grace period after the last block is received. It also adds a functional test reproducing the pong delay issue and verifying the grace period behavior.
Problem: When downloading blocks over a slow connection, peers prioritize block responses over pings, which can cause the ping timeout of 20 minutes to expire and drop peers that are behaving correctly.
Category: P2P (#18 of 65)
P3 · bug fix
- P3 because it fixes unnecessary disconnections during block download on slow connections
- Other fallback timeouts already prevent nodes from stalling indefinitely
Fixes unnecessary disconnections during initial block download on slower connections (#35761). While this improves IBD stability for users on limited bandwidth, existing fallback timeouts (socket inactivity and block download stalling) already prevent the node from hanging indefinitely, making this a worthwhile but non-critical bug fix.
Membership: Changes peer timeout and disconnection logic in src/net_processing.cpp and carries the P2P label.
Factors: security/stability 1, bug 1, performance 1, user value 1, leverage 0
Reviewability: Ready
- Ready to review now with passing CI and recent reviewer feedback addressed
The PR has passing CI, is up to date, and recent pushes addressed all outstanding reviewer feedback.
Author status: Active; addressing all feedback promptly with force pushes.
Resolved concerns:
- l0rinc requested splitting the functional test into a characterization test before the fix commit.
- danielabrozzoni noted potential edge cases around unsolicited blocks not updating m_last_block_time and user-invoked ping RPCs resetting timeouts, which were discussed and deemed non-issues.
- danielabrozzoni suggested adding a test assertion verifying the grace period does not trigger while blocks remain in flight, which was implemented.
Agreement: Positive
- Concept support with test improvements addressed (l0rinc)
- Concept support with edge cases explored and extra test assertions added (danielabrozzoni)
Positive: Concept ACKs from l0rinc and danielabrozzoni, with all test and edge-case feedback addressed.
Multiple contributors reviewed the PR and supported the concept, and all technical inquiries and suggested test improvements have been answered and resolved.
- l0rinc gave Concept ACK and requested test structure adjustments
- danielabrozzoni gave Concept ACK, tested edge cases, and suggested an additional mutation-killing assertion that was adopted
Review verdicts (DrahtBot): 0
- Concept ACK: l0rinc, danielabrozzoni
Files
220 lines under test/bench/ci.
- test/functional/p2p_ping_ibd.py +219/-0
- src/net_processing.cpp +18/-18
- test/functional/test_runner.py +1/-0
Card
Suspends the 20-minute ping timeout for peers actively serving blocks during initial block download, granting a one-minute grace period after the last block is received. This fixes #35761, where slow-bandwidth downloaders mistakenly drop responsive peers that prioritize block delivery over pongs. Existing socket inactivity and block download timeouts continue to protect against dead peers. The PR is in a clean reviewable state with Concept ACKs from l0rinc and danielabrozzoni.