Skip to content

[v0.21.x-branch] Backport #11540: peer: reestablish pending channels on reconnect - #11560

Merged
ziggie1984 merged 2 commits into
v0.21.x-branchfrom
backport-11540-to-v0.21.x-branch
Nov 11, 2026
Merged

ziggie1984 merged 2 commits into
v0.21.x-branchfrom
backport-11540-to-v0.21.x-branch

Conversation

@github-actions

Copy link
Copy Markdown

Backport of #11540


Change Description

Fixes #4006.

BOLT 2, Message Retransmission, does not mention confirmation:

A funding node:

  • upon disconnection:
    • if it has broadcast the funding transaction:
      • MUST remember the channel for reconnection.

A non-funding node:

  • upon disconnection:
    • if it has sent the funding_signed message:
      • MUST remember the channel for reconnection.

A node:

  • upon reconnection:
    • otherwise:
      • MUST transmit channel_reestablish for each channel.
      • MUST wait to receive the other node's channel_reestablish message before sending any other messages for that channel.

Brontide.Start already remembers the channel. FetchOpenChannels returns it while the funding transaction is unconfirmed. loadActiveChannels then dropped it:

if lnChan.IsPending() {
    p.markPendingChannel(chanID)
    continue
}

No link is created, and Start wrote no channel_reestablish. A peer waiting on that message disconnects, which takes every other channel to that lnd node down until the pending one confirms. See lightningdevkit/rust-lightning#4764.

The first commit contains the regression test and fix. The second commit adds the release note.

The pending channel still does not get a link. The funding manager owns that, and creating one here would be torn down when the final link is added. The fix queues ChanSyncMsg(), the same message already sent for a borked channel, so Start writes it before the write handler. That is the funding-node case the test builds: initiator, funding transaction stored, still pending. A non-funding node that has sent funding_signed is pending in the same map and gets the same message.

The link created after confirmation still runs syncChanStates, which would send channel_reestablish again. A second copy on the same connection is not a reconnection. LDK fails the channel (Peer sent a loose channel_reestablish not after reconnect). The peer records that this connection already queued the message, and the link waits for the remote channel_reestablish without transmitting another one.

channel_ready is still sent by the funding manager after confirmation. It follows this channel_reestablish on the wire, because Start writes the sync message before the write handler starts. This patch does not block channel_ready on receipt of the peer's channel_reestablish. Doing so deadlocks with a peer that only sends channel_reestablish once its own link exists, which is what this code did before the fix.

Steps to Test

  1. go test -count=1 -timeout 120s -run TestPendingChannelReestablishOnReconnect ./peer/
  2. The test passes. It requires a channel_reestablish for the pending funding channel, and requires that this connection recorded the send so the later link does not repeat it.

Pull Request Checklist

Testing

  • Your PR passes all CI checks.
  • Tests covering the positive and negative (error paths) are included.
  • Bug fixes contain tests triggering the bug to prevent regressions.

Code Style and Documentation

  • The change is not insubstantial.
  • The change obeys the Code Documentation and Commenting guidelines, and lines wrap at 80.
  • Commits follow the Ideal Git Commit Structure.
  • Any new logging statements use an appropriate subsystem and logging level.
  • Any new lncli commands have appropriate tags in the comments for the rpc in the proto file.
  • There is a change description in a PR-specific release note fragment, or the no-changelog label is applied.

BOLT 2 requires a node to send channel_reestablish for every
remembered channel when a peer reconnects. Pending channels are remembered
but have no link, so lnd previously sent nothing until funding confirmed. A
peer waiting for the message could disconnect the shared connection.

Queue the message while loading pending channels and record the handoff so
the link created after confirmation still processes the remote state without
sending a duplicate.

Add regression coverage for the pending funding-node case.

Signed-off-by: Vincenzo Palazzo <vincenzopalazzodev@gmail.com>
(cherry picked from commit 14efa3d)
Signed-off-by: Vincenzo Palazzo <vincenzopalazzodev@gmail.com>
(cherry picked from commit 6e47397)
@github-actions github-actions Bot added this to the v0.21.7 milestone Nov 11, 2026
@ziggie1984
ziggie1984 merged commit 84cefa3 into v0.21.x-branch Nov 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants