Repository navigation
[v0.21.x-branch] Backport #11540: peer: reestablish pending channels on reconnect - #11560
Merged
Merged
Conversation
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)
7 of 9 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Backport of #11540
Change Description
Fixes #4006.
BOLT 2, Message Retransmission, does not mention confirmation:
Brontide.Startalready remembers the channel.FetchOpenChannelsreturns it while the funding transaction is unconfirmed.loadActiveChannelsthen dropped it:No link is created, and
Startwrote nochannel_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, soStartwrites 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 sentfunding_signedis pending in the same map and gets the same message.The link created after confirmation still runs
syncChanStates, which would sendchannel_reestablishagain. 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 remotechannel_reestablishwithout transmitting another one.channel_readyis still sent by the funding manager after confirmation. It follows thischannel_reestablishon the wire, becauseStartwrites the sync message before the write handler starts. This patch does not blockchannel_readyon receipt of the peer'schannel_reestablish. Doing so deadlocks with a peer that only sendschannel_reestablishonce its own link exists, which is what this code did before the fix.Steps to Test
go test -count=1 -timeout 120s -run TestPendingChannelReestablishOnReconnect ./peer/channel_reestablishfor the pending funding channel, and requires that this connection recorded the send so the later link does not repeat it.Pull Request Checklist
Testing
Code Style and Documentation
no-changeloglabel is applied.