Repository navigation
peer: reestablish pending channels on reconnect - #11540
yyforyongyu merged 2 commits into
Conversation
🟢 PR Severity: LOW
🟢 Low (1 file)
AnalysisThis PR only modifies To override, add a |
🔴 PR Severity: CRITICAL
🔴 Critical (2 files)
🟢 Low (2 files)
AnalysisThis PR now modifies production code in To override, add a |
litbot-9000
left a comment
There was a problem hiding this comment.
/gateway review
Approve — no blockers. Real bug, correct minimal fix, test catches it.
The bug: a pending funding channel (broadcast, unconfirmed) is remembered across reconnect per BOLT 2, but loadActiveChannels dropped it with continue, so no channel_reestablish was ever transmitted for it. A peer that requires the message for every remembered channel (LDK does) disconnects, taking all other channels down until the pending one confirms.
The fix queues ChanSyncMsg() for pending channels at reconnect — the same message path borked channels already use — and records the send in chanSyncSent so the post-confirmation link doesn't retransmit. Design checks I ran rather than trusted:
- BOLT 2 text: verified against the spec. The funding node "MUST remember the channel for reconnection" once it has broadcast, and "MUST transmit
channel_reestablishfor each channel" on reconnection — confirmation is not a condition. The PR's reading is correct. - Duplicate suppression: LDK fails a channel on a loose second reestablish, and the
ChanSyncMsgSentflag cleanly prevents it while the link still waits for the remote's message, as required. - Ordering: confirmed in
Start: all queued sync messages are written before the write handler launches, so this reestablish precedeschannel_readyon the wire as the body claims. - The
channel_readydeadlock tradeoff: the PR deliberately does not blockchannel_readyon receipt of the peer's reestablish. That's the only safe choice against pre-fix peers (which never send it for pending channels — blocking would hang those channels forever), at the cost of a residual spec nit you can't distinguish without feature negotiation. Correct call, and it's documented in the body. - Error path: if
ChanSyncMsg()itself fails, the channel stays marked pending with no message — degrades to pre-fix behavior for that channel only. Fine.
Verified by execution: TestPendingChannelReestablishOnReconnect passes at the PR head and fails at the pre-fix commit 7ea573d18 (the test-only commit before the fix), so the test demonstrably catches the bug. Full go test ./peer/ passes (9.8s). gofmt clean, go vet clean, added lines ≤80 cols, release note present.
Note: the failing "CI result" check is the ci-hold label on this PR, not the code — remove the label for a full CI run. Not verified here: itests (no Docker).
— claudell ⚡ (OpenClaw dev agent; approval posts as litbot-9000 and does not count toward branch protection)
fc57596 to
f821fe0
Compare
|
Reworked the PR history into two focused commits: the regression test and implementation are together in the first commit, and the release note is in the second. Vincenzo remains the author and signatory on both commits. |
Signed-off-by: Vincenzo Palazzo <vincenzopalazzodev@gmail.com>
f821fe0 to
2a5c505
Compare
🟢 PR Severity: LOW
AnalysisA For reference, the file-based classification would otherwise have been critical, driven by production changes in To override, add a |
Signed-off-by: Vincenzo Palazzo <vincenzopalazzodev@gmail.com>
2a5c505 to
2565c63
Compare
Signed-off-by: Vincenzo Palazzo <vincenzopalazzodev@gmail.com>
2565c63 to
a34ec76
Compare
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>
Signed-off-by: Vincenzo Palazzo <vincenzopalazzodev@gmail.com>
a34ec76 to
6e47397
Compare
|
Created backport PR for
Please cherry-pick the changes locally and resolve any conflicts. git fetch origin backport-11540-to-v0.20.x-branch
git worktree add --checkout .worktree/backport-11540-to-v0.20.x-branch backport-11540-to-v0.20.x-branch
cd .worktree/backport-11540-to-v0.20.x-branch
git reset --hard HEAD^
git cherry-pick -x 14efa3d32ffb2a7341522d6294af98450371f22c 6e473970bc476aa299fe9f3aae9fb73353972cd6
git push --force-with-lease |
|
Successfully created backport PR for |
…21.x-branch [v0.21.x-branch] Backport #11540: peer: reestablish pending channels on reconnect
Signed-off-by: Vincenzo Palazzo <vincenzopalazzodev@gmail.com>
…20.x-branch [v0.20.x-branch] Backport #11540: peer: reestablish pending channels on reconnect
Signed-off-by: Vincenzo Palazzo <vincenzopalazzodev@gmail.com> (cherry picked from commit 6e47397)
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.