peer: bound peer-controlled resource growth - #11090
Conversation
🔴 PR Severity: CRITICAL
🔴 Critical (1 file)
🟢 Low (3 files)
AnalysisThe substantive change is entirely in To override, add a |
Bound pong replies with a conservative sustained rate and burst while disconnecting peers that exceed a separate flood threshold. Add deterministic coverage for honest cadences, reply suppression, and flood teardown.
Track the combined priority and lazy queue depth and disconnect peers once the backlog crosses the per-peer message cap. Keep servicing producers during teardown so ping manager shutdown and synchronous senders cannot deadlock.
Charge fixed queue overhead and the staged high-risk dynamic payloads without serializing messages on the hot path. Disconnect when charged memory crosses the per-peer budget and cover each cost rule plus the byte threshold.
Document the ping reply rate and outgoing queue bounds in both supported patch release notes so operators know that peer-controlled resource exhaustion is mitigated.
85a430b to
bbada64
Compare
Change Description
Bound the resources a peer can consume through inbound pings and queued
outgoing messages.
Inbound ping handling now has two limits:
that reply budget are accepted without a Pong.
This flood check also covers pings whose requested Pong size would otherwise
be ignored.
The per-peer outgoing backlog is also capped at 10,000 messages and 16 MiB of
charged memory. Queue accounting covers fixed overhead and the high-risk
dynamic payloads without serializing messages on the hot path. An overflowing
peer is disconnected while the queue remains serviced until teardown, avoiding
deadlocks with synchronous senders.
Release notes are included for 0.21.3 and 0.20.4.
Open Question
The reply budget deliberately deviates from BOLT 1's requirement to answer
valid pings. A peer using those pings for liveness may close the connection when
its Pong is skipped, so the 1-10 ping/second band can relocate the disconnect
decision to the remote peer and make lnd appear unresponsive. Should the two
tiers remain, or should they be collapsed into the flood disconnect threshold?
This draft implements both tiers so reviewers can evaluate the concrete
behavior.
Steps to Test
The queue-accounting and teardown-drain regression tests were also mutation
tested by removing their respective implementation lines and confirming each
test failed.
Pull Request Checklist
Testing
Code Style and Documentation