Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bugfix/htlc flush shutdown #8167

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
9b2d101
htlcswitch+peer: add flush api and lifecycle hooks to ChannelUpdateHa…
ProofOfKeags Nov 21, 2023
30ad49a
chancloser: add new closeAwaitingFlushState
ProofOfKeags Dec 15, 2023
6fef9ea
chancloser: extract ProcessCloseMsg Shutdown handling logic into dedi…
ProofOfKeags Dec 15, 2023
e77d3ad
chancloser: extract ProcessCloseMsg ClosingSigned handling logic into…
ProofOfKeags Dec 15, 2023
45d30af
chancloser: add BeginNegotiation method to bridge phases
ProofOfKeags Dec 15, 2023
1b0f97a
chancloser: move initFeeBaseline to BeginNegotiation
ProofOfKeags Dec 15, 2023
3aceeea
chancloser: move nil MarkCoopBroadcasted to BeginNegotiation
ProofOfKeags Dec 15, 2023
7b08899
chancloser: cache remote ClosingSigned to deal with race
ProofOfKeags Jan 18, 2024
f81e7ad
peer: rewrite handleCloseMsg in terms of new ChanCloser methods
ProofOfKeags Dec 1, 2023
704eb84
chancloser: rewrite tests in terms of new ChanCloser methods
ProofOfKeags Dec 2, 2023
6955dc9
chancloser: remove ProcessCloseMsg
ProofOfKeags Dec 2, 2023
7029225
htlcswitch: make link forward eligibility flush aware
ProofOfKeags Nov 26, 2023
442f1dd
peer: handle close messages using link lifecycle hooks
ProofOfKeags Nov 26, 2023
025e569
peer: fix local close requests to shutdown via link lifecycle hooks
ProofOfKeags Nov 26, 2023
5ab69ae
peer: remove tryLinkShutdown due to redundance
ProofOfKeags Nov 26, 2023
a9d5235
htlcswitch: bounce downstream adds when flushing
ProofOfKeags Nov 26, 2023
891b00d
htlcswitch: drop the connection when receiving an invalid add
ProofOfKeags Dec 8, 2023
601afaf
htlcswitch: implement flush api for channelLink
ProofOfKeags Nov 28, 2023
64fda6c
htlcswitch: implement flush and commit lifecycle hooks for channelLink
ProofOfKeags Nov 28, 2023
ec55831
htlcswitch+peer: remove ShutdownIfChannelClean
ProofOfKeags Nov 29, 2023
804dabb
lnd: make closechannel send an instant empty update when no_wait set
ProofOfKeags Jan 10, 2024
94373bd
htlcswitch: placate confused linter
ProofOfKeags Jan 12, 2024
9e58ebd
itest: test that we can close with in-flight htlcs
ProofOfKeags Jan 12, 2024
0727717
itest+lntest: remove temporary hacks around broken coop close in itests
ProofOfKeags Jan 17, 2024
69ef1b2
docs: update release notes
ProofOfKeags Jan 9, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 0 additions & 9 deletions itest/lnd_mpp_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -309,15 +309,6 @@ func (m *mppTestScenario) closeChannels() {
return
}

// TODO(yy): remove the sleep once the following bug is fixed. When the
// payment is reported as settled by Alice, it's expected the
// commitment dance is finished and all subsequent states have been
// updated. Yet we'd receive the error `cannot co-op close channel with
// active htlcs` or `link failed to shutdown` if we close the channel.
// We need to investigate the order of settling the payments and
// updating commitments to understand and fix .
time.Sleep(5 * time.Second)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍


// Close all channels without mining the closing transactions.
m.ht.CloseChannelAssertPending(m.alice, m.channelPoints[0], false)
m.ht.CloseChannelAssertPending(m.alice, m.channelPoints[1], false)
Expand Down
27 changes: 0 additions & 27 deletions itest/lnd_psbt_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -312,15 +312,6 @@ func runPsbtChanFunding(ht *lntest.HarnessTest, carol, dave *node.HarnessNode,
resp := dave.RPC.AddInvoice(invoice)
ht.CompletePaymentRequests(carol, []string{resp.PaymentRequest})

// TODO(yy): remove the sleep once the following bug is fixed. When the
// payment is reported as settled by Carol, it's expected the
// commitment dance is finished and all subsequent states have been
// updated. Yet we'd receive the error `cannot co-op close channel with
// active htlcs` or `link failed to shutdown` if we close the channel.
// We need to investigate the order of settling the payments and
// updating commitments to understand and fix .
time.Sleep(2 * time.Second)

// To conclude, we'll close the newly created channel between Carol and
// Dave. This function will also block until the channel is closed and
// will additionally assert the relevant channel closing post
Expand Down Expand Up @@ -496,15 +487,6 @@ func runPsbtChanFundingExternal(ht *lntest.HarnessTest, carol,
resp := dave.RPC.AddInvoice(invoice)
ht.CompletePaymentRequests(carol, []string{resp.PaymentRequest})

// TODO(yy): remove the sleep once the following bug is fixed. When the
// payment is reported as settled by Carol, it's expected the
// commitment dance is finished and all subsequent states have been
// updated. Yet we'd receive the error `cannot co-op close channel with
// active htlcs` or `link failed to shutdown` if we close the channel.
// We need to investigate the order of settling the payments and
// updating commitments to understand and fix .
time.Sleep(2 * time.Second)

// To conclude, we'll close the newly created channel between Carol and
// Dave. This function will also block until the channels are closed and
// will additionally assert the relevant channel closing post
Expand Down Expand Up @@ -656,15 +638,6 @@ func runPsbtChanFundingSingleStep(ht *lntest.HarnessTest, carol,
resp := dave.RPC.AddInvoice(invoice)
ht.CompletePaymentRequests(carol, []string{resp.PaymentRequest})

// TODO(yy): remove the sleep once the following bug is fixed. When the
// payment is reported as settled by Carol, it's expected the
// commitment dance is finished and all subsequent states have been
// updated. Yet we'd receive the error `cannot co-op close channel with
// active htlcs` or `link failed to shutdown` if we close the channel.
// We need to investigate the order of settling the payments and
// updating commitments to understand and fix .
time.Sleep(2 * time.Second)

// To conclude, we'll close the newly created channel between Carol and
// Dave. This function will also block until the channel is closed and
// will additionally assert the relevant channel closing post
Expand Down
9 changes: 0 additions & 9 deletions itest/lnd_routing_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1323,15 +1323,6 @@ func testRouteFeeCutoff(ht *lntest.HarnessTest) {
}
testFeeCutoff(feeLimitFixed)

// TODO(yy): remove the sleep once the following bug is fixed. When the
// payment is reported as settled by Carol, it's expected the
// commitment dance is finished and all subsequent states have been
// updated. Yet we'd receive the error `cannot co-op close channel with
// active htlcs` or `link failed to shutdown` if we close the channel.
// We need to investigate the order of settling the payments and
// updating commitments to understand and fix .
time.Sleep(2 * time.Second)

// Once we're done, close the channels and shut down the nodes created
// throughout this test.
ht.CloseChannel(alice, chanPointAliceBob)
Expand Down
9 changes: 0 additions & 9 deletions itest/lnd_wallet_import_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -426,15 +426,6 @@ func fundChanAndCloseFromImportedAccount(ht *lntest.HarnessTest, srcNode,

ht.CompletePaymentRequests(srcNode, []string{resp.PaymentRequest})

// TODO(yy): remove the sleep once the following bug is fixed. When the
// payment is reported as settled by srcNode, it's expected the
// commitment dance is finished and all subsequent states have been
// updated. Yet we'd receive the error `cannot co-op close channel with
// active htlcs` or `link failed to shutdown` if we close the channel.
// We need to investigate the order of settling the payments and
// updating commitments to understand and fix .
time.Sleep(2 * time.Second)

// Now that we've confirmed the opened channel works, we'll close it.
ht.CloseChannel(srcNode, chanPoint)

Expand Down
9 changes: 0 additions & 9 deletions itest/lnd_zero_conf_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -865,15 +865,6 @@ func testOptionScidUpgrade(ht *lntest.HarnessTest) {
daveInvoice2 := dave.RPC.AddInvoice(daveParams)
ht.CompletePaymentRequests(bob, []string{daveInvoice2.PaymentRequest})

// TODO(yy): remove the sleep once the following bug is fixed. When
// the payment is reported as settled by Bob, it's expected the
// commitment dance is finished and all subsequent states have been
// updated. Yet we'd receive the error `cannot co-op close channel with
// active htlcs` or `link failed to shutdown` if we close the channel.
// We need to investigate the order of settling the payments and
// updating commitments to understand and fix.
time.Sleep(2 * time.Second)

// Close standby node's channels.
ht.CloseChannel(bob, fundingPoint2)
}
Expand Down
32 changes: 10 additions & 22 deletions lntest/harness.go
Original file line number Diff line number Diff line change
Expand Up @@ -1207,6 +1207,7 @@ func (h *HarnessTest) CloseChannelAssertPending(hn *node.HarnessNode,
closeReq := &lnrpc.CloseChannelRequest{
ChannelPoint: cp,
Force: force,
NoWait: true,
}

var (
Expand All @@ -1218,28 +1219,15 @@ func (h *HarnessTest) CloseChannelAssertPending(hn *node.HarnessNode,
// Consume the "channel close" update in order to wait for the closing
// transaction to be broadcast, then wait for the closing tx to be seen
// within the network.
//
// TODO(yy): remove the wait once the following bug is fixed.
// - https://github.com/lightningnetwork/lnd/issues/6039
// We may receive the error `cannot co-op close channel with active
// htlcs` or `link failed to shutdown` if we close the channel. We need
// to investigate the order of settling the payments and updating
// commitments to properly fix it.
err = wait.NoError(func() error {
ProofOfKeags marked this conversation as resolved.
Show resolved Hide resolved
stream = hn.RPC.CloseChannel(closeReq)
event, err = h.ReceiveCloseChannelUpdate(stream)
if err != nil {
h.Logf("Test: %s, close channel got error: %v",
h.manager.currentTestCase, err)

// NoError predicates every 200ms, which is too
// frequent for closing channels. We sleep here to
// avoid trying it too much.
time.Sleep(2 * time.Second)
}

return err
}, wait.ChannelCloseTimeout)
stream = hn.RPC.CloseChannel(closeReq)
_, err = h.ReceiveCloseChannelUpdate(stream)
require.NoError(h, err, "close channel update got error: %v", err)

event, err = h.ReceiveCloseChannelUpdate(stream)
if err != nil {
h.Logf("Test: %s, close channel got error: %v",
h.manager.currentTestCase, err)
}
require.NoError(h, err, "retry closing channel failed")

pendingClose, ok := event.Update.(*lnrpc.CloseStatusUpdate_ClosePending)
Expand Down