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 all commits
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
4 changes: 4 additions & 0 deletions cmd/lncli/commands.go
Original file line number Diff line number Diff line change
Expand Up @@ -921,6 +921,10 @@ func executeChannelClose(ctxc context.Context, client lnrpc.LightningClient,
}

switch update := resp.Update.(type) {
case *lnrpc.CloseStatusUpdate_CloseInstant:
if req.NoWait {
return nil
}
case *lnrpc.CloseStatusUpdate_ClosePending:
closingHash := update.ClosePending.Txid
txid, err := chainhash.NewHash(closingHash)
Expand Down
11 changes: 11 additions & 0 deletions docs/release-notes/release-notes-0.18.0.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,11 @@
* [Properly handle un-acked updates for exhausted watchtower
sessions](https://github.com/lightningnetwork/lnd/pull/8233)

* [Allow `shutdown`s while HTLCs are in-flight](https://github.com/lightningnetwork/lnd/pull/8167).
This change fixes an issue where we would force-close channels when receiving
a `shutdown` message if there were currently HTLCs on the channel. After this
change, the shutdown procedure should be compliant with BOLT2 requirements.

ProofOfKeags marked this conversation as resolved.
Show resolved Hide resolved
# New Features
## Functional Enhancements

Expand Down Expand Up @@ -123,6 +128,12 @@
file](https://github.com/lightningnetwork/lnd/pull/8188). The corresponding
`lncli getdebuginfo` command was also added.

* Add a [new flag](https://github.com/lightningnetwork/lnd/pull/8167) to the
`CloseChannel` RPC method that instructs the client to not wait for the
closing transaction to be negotiated. This should be used if you don't care
about the txid and don't want the calling code to block while the channel
drains the active HTLCs.

## lncli Additions

* Deprecate `bumpclosefee` for `bumpforceclosefee` to accommodate for the fact
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ require (
github.com/lightningnetwork/lightning-onion v1.2.1-0.20230823005744-06182b1d7d2f
github.com/lightningnetwork/lnd/cert v1.2.2
github.com/lightningnetwork/lnd/clock v1.1.1
github.com/lightningnetwork/lnd/fn v1.0.0
github.com/lightningnetwork/lnd/fn v1.0.1
github.com/lightningnetwork/lnd/healthcheck v1.2.3
github.com/lightningnetwork/lnd/kvdb v1.4.4
github.com/lightningnetwork/lnd/queue v1.1.1
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -449,8 +449,8 @@ github.com/lightningnetwork/lnd/cert v1.2.2/go.mod h1:jQmFn/Ez4zhDgq2hnYSw8r35bq
github.com/lightningnetwork/lnd/clock v1.0.1/go.mod h1:KnQudQ6w0IAMZi1SgvecLZQZ43ra2vpDNj7H/aasemg=
github.com/lightningnetwork/lnd/clock v1.1.1 h1:OfR3/zcJd2RhH0RU+zX/77c0ZiOnIMsDIBjgjWdZgA0=
github.com/lightningnetwork/lnd/clock v1.1.1/go.mod h1:mGnAhPyjYZQJmebS7aevElXKTFDuO+uNFFfMXK1W8xQ=
github.com/lightningnetwork/lnd/fn v1.0.0 h1:I5VG9AD63mOQ89RMQEu7HRI1r68wn8yz539LoylUIKM=
github.com/lightningnetwork/lnd/fn v1.0.0/go.mod h1:XV+0vBXSnh3aUjskJUv58TOpsveiXQ+ac8rEnXZDGFc=
github.com/lightningnetwork/lnd/fn v1.0.1 h1:4nAxKpGKgk4/xRQKxvim3BW0QM34S4BH6QghWZVjsko=
github.com/lightningnetwork/lnd/fn v1.0.1/go.mod h1:XV+0vBXSnh3aUjskJUv58TOpsveiXQ+ac8rEnXZDGFc=
github.com/lightningnetwork/lnd/healthcheck v1.2.3 h1:oqhOOy8WmIEa6RBkYKC0mmYZkhl8T2kGD97n9jpML8o=
github.com/lightningnetwork/lnd/healthcheck v1.2.3/go.mod h1:eDxH3dEwV9DeBW/6inrmlVh1qBOFV0AI14EEPnGt9gc=
github.com/lightningnetwork/lnd/kvdb v1.4.4 h1:bCv63rVCvzqj1BkagN/EWTov6NDDgYEG/t0z2HepRMk=
Expand Down
51 changes: 47 additions & 4 deletions htlcswitch/interfaces.go
Original file line number Diff line number Diff line change
Expand Up @@ -134,12 +134,55 @@ type ChannelUpdateHandler interface {
// parameter.
MayAddOutgoingHtlc(lnwire.MilliSatoshi) error

// ShutdownIfChannelClean shuts the link down if the channel state is
// clean. This can be used with dynamic commitment negotiation or coop
// close negotiation which require a clean channel state.
ShutdownIfChannelClean() error
// EnableAdds sets the ChannelUpdateHandler state to allow
// UpdateAddHtlc's in the specified direction. It returns an error if
// the state already allowed those adds.
EnableAdds(direction LinkDirection) error
ProofOfKeags marked this conversation as resolved.
Show resolved Hide resolved

// DiableAdds sets the ChannelUpdateHandler state to allow
// UpdateAddHtlc's in the specified direction. It returns an error if
// the state already disallowed those adds.
DisableAdds(direction LinkDirection) error

// IsFlushing returns true when UpdateAddHtlc's are disabled in the
// direction of the argument.
IsFlushing(direction LinkDirection) bool

// OnFlushedOnce adds a hook that will be called the next time the
// channel state reaches zero htlcs. This hook will only ever be called
// once. If the channel state already has zero htlcs, then this will be
// called immediately.
OnFlushedOnce(func())

// OnCommitOnce adds a hook that will be called the next time a
// CommitSig message is sent in the argument's LinkDirection. This hook
// will only ever be called once. If no CommitSig is owed in the
// argument's LinkDirection, then we will call this hook immediately.
OnCommitOnce(LinkDirection, func())
}

// CommitHookID is a value that is used to uniquely identify hooks in the
// ChannelUpdateHandler's commitment update lifecycle. You should never need to
// construct one of these by hand, nor should you try.
type CommitHookID uint64

// FlushHookID is a value that is used to uniquely identify hooks in the
// ChannelUpdateHandler's flush lifecycle. You should never need to construct
// one of these by hand, nor should you try.
type FlushHookID uint64

// LinkDirection is used to query and change any link state on a per-direction
// basis.
type LinkDirection bool
yyforyongyu marked this conversation as resolved.
Show resolved Hide resolved

const (
// Incoming is the direction from the remote peer to our node.
Incoming LinkDirection = false
ProofOfKeags marked this conversation as resolved.
Show resolved Hide resolved

// Outgoing is the direction from our node to the remote peer.
Outgoing LinkDirection = true
)

// ChannelLink is an interface which represents the subsystem for managing the
// incoming htlc requests, applying the changes to the channel, and also
// propagating/forwarding it to htlc switch.
Expand Down
Loading
Loading