-
Notifications
You must be signed in to change notification settings - Fork 418
Detect commitment transaction confirmation in ChannelMonitor instead #4013
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
Detect commitment transaction confirmation in ChannelMonitor instead #4013
Conversation
👋 Thanks for assigning @TheBlueMatt as a reviewer! |
This was already the case, at least if you connected the block to the monitor first, probably worth updating the commit message. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
CI is unhappy but otherwise happy to land this.
👋 The first review has been submitted! Do you think this PR is ready for a second reviewer? If so, click here to assign a second reviewer. |
Previously, the `ChannelManager` would assume a `Channel` was closed the moment it saw a spend for its funding input. With splicing, this will no longer be the case. Since the `ChannelMonitor` is already responsible for reliably tracking each onchain transaction relevant to a channel, we now produce a `MonitorEvent::CommitmentTxConfirmed` event to inform the `ChannelManager` the channel can be considered closed and removed. As a result of this change, many tests failed now that we rely on handling the `MonitorEvent::CommitmentTxConfirmed` first before seeing the `ChannelMonitorUpdateStep::ChannelForceClosed` go out.
da958b0
to
68cd71c
Compare
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #4013 +/- ##
==========================================
- Coverage 88.85% 88.84% -0.02%
==========================================
Files 175 175
Lines 127710 127723 +13
Branches 127710 127723 +13
==========================================
- Hits 113478 113476 -2
- Misses 11675 11686 +11
- Partials 2557 2561 +4
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Gonna go ahead and land this. Its really trivial code-change, and while its a bit of a change logic-wise, we already have to support basically this - someone can connect a block to the ChannelMonitor
and then sit around for a minute before connecting the block to the ChannelManager
, so any behavior that relied on the Channel
being closed directly would have been buggy anyway.
It does mean we will sometimes send a channel_ready
and then close later if a channel is closed in the same block it was opened, but who cares.
let err = ChannelError::Close((reason.to_string(), reason)); | ||
let mut chan = chan_entry.remove(); | ||
let (_, e) = convert_channel_err!(self, peer_state, err, &mut chan); | ||
failed_channels.push((Err(e), counterparty_node_id)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We always generate a ChannelMonitorUpdate
to tell the ChannelMonitor
that this channel is closed...which the monitor just told us about. The only thing it really does is set lockdown_from_offchain
in the ChannelMonitor
which adds panics if we later provide a ChannelMonitorUpdate
for the channel, but those are just sanity checks and definitely aren't something to protect for an extra monitor update.
Isn't required here cause its not new, but we should drop the ChannelMonitorUpdate
in a followup.
Previously, the
ChannelManager
would assume aChannel
was closed the moment it saw a spend for its funding input. With splicing, this will no longer be the case. Since theChannelMonitor
is already responsible for reliably tracking each onchain transaction relevant to a channel, we now produce aMonitorEvent::CommitmentTxConfirmed
event to inform theChannelManager
the channel can be considered closed and removed.As a result of this change, many tests failed now that we rely on handling the
MonitorEvent::CommitmentTxConfirmed
first before seeing theChannelMonitorUpdateStep::ChannelForceClosed
go out.