AI-generated analysisPublished automatically and not human-verified. Validated context appears in community notes below.
← Watch feed
Low 35 Bitcoin

Correct `msgs_sent_since_pong` tracking for gossip forwards

Public commit record

What the developer wrote

Authored by Matt Corallo

85/100 · Strong
Correct `msgs_sent_since_pong` tracking for gossip forwards

When we forward gossip messages, we use the already-encoded copy
we have, pushing it onto the `gossip_broadcast_buffer`. When we
have free socket buffer space, and there are no non-gossip messages
pending, we'll remove it from the `gossip_broadcast_buffer` and
push it onto the normal `pending_outbound_buffer` socket queue.

Separately, we use `msgs_sent_since_pong` to ensure that our peer
is being responsive and our messages are getting through with
minimal latency. After we send 32 messages (if we've already
received the `pong` for the last `ping` wensent), we send an extra
`ping` and will only queue up an additional 32 forwarded gossip
messages before we start dropping forwarded gossip on the floor.

Previously, we (arguably) incorrectly incremented
`msgs_sent_since_pong` when we pushed a message onto the
`gossip_broadcast_buffer`, not when it was actually queued up in
our `pending_outbound_buffer` immediate socket queue. This is
fairly strange - the point of `msgs_sent_since_pong` is to keep
peer latency low, we already independently enforce memory limits to
ensure we drop forwarded gossip messages if a peer's message queues
have grown too large. This means we potentially disconnect a peer
for not draining the backlog forwarded-gossip socket queue fast
enough, rather than simply dropping gossip.

While this shouldn't be a big deal in practice, I do see (mostly
Tor) peers disconnect on my node occasionally, and while its likely
due to Tor circuits hanging and a disconnect is needed, the
incorrect tracking here makes state analysis difficult as there are
nearly always a flow of enough gossip messages to "send to the
peer". Its also possible that this allows incredibly low bandwidth
connections to stay afloat more durably.
✓ Specific, descriptive subject✓ Names a concrete action or component✓ Provides detailed explanatory context✓ Explains rationale or failure mode
The short version

What changed, and why it matters

This change fixes how a Lightning node counts messages it has sent to a peer. Previously, the node counted forwarded gossip messages as 'sent' when they were merely placed in a broadcast buffer, even though they had not yet been written to the actual network socket. This could cause the node to think the peer was slow or unresponsive and disconnect it prematurely, especially for peers on slow networks like Tor. The fix moves the count to the point where the message is actually queued for sending on the socket, so the node only disconnects peers for genuine backpressure, not for buffered gossip waiting to be sent.

Recommended action

Review and merge. This is a correctness fix for peer liveness/backpressure accounting. Operators running nodes with many Tor or low-bandwidth peers should benefit from fewer spurious disconnects. No immediate incident response is required; the issue is a reliability bug rather than an exploitable vulnerability.

Security signals we found

01

Incorrect backpressure accounting could lead to premature peer disconnection

02

Fixes mismatch between message counter and actual socket transmission

03

May improve stability of low-bandwidth and Tor peer connections

04

No cryptographic, memory-safety, or authentication issue present

Risk score

Why this scored 35/100

Our methodology →
Potential impact 8/30
Exploitability 3/25
Stealth signal 6/15
Affected reach 7/15
Confidence 7/10
Evidence quality 4/5
Human-validated context

Community notes

Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.

No validated notes yet.

The AI analysis stands alone for now. Submit a note if you can add evidence or important context.