-
Notifications
You must be signed in to change notification settings - Fork 418
Additional closing cleanups post-#3881 #3899
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
base: main
Are you sure you want to change the base?
Additional closing cleanups post-#3881 #3899
Conversation
👋 Thanks for assigning @wpaulino as a reviewer! |
0dac107
to
77fabef
Compare
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #3899 +/- ##
==========================================
- Coverage 89.02% 89.01% -0.02%
==========================================
Files 166 166
Lines 119683 119652 -31
Branches 119683 119652 -31
==========================================
- Hits 106546 106506 -40
- Misses 10725 10729 +4
- Partials 2412 2417 +5
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.
Will take a closer look soon, but, FYI, CI is unhappy.
Yea, realized that but will probably fix after #3881 |
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.
This needs a rebase now that #3881 has been merged.
853bdfc
to
a099c02
Compare
Squashed and fixed rustfmt. |
a099c02
to
afc42ab
Compare
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.
Changes by themselves LGTM.
Once this is land I'll need to see how to proceed with the simple-close flow.
🔔 1st Reminder Hey @wpaulino! This PR has been waiting for your review. |
afc42ab
to
59bf265
Compare
Rebased. |
lightning/src/ln/channelmanager.rs
Outdated
// We're done with this channel, we've got a signed closing transaction and | ||
// will send the closing_signed back to the remote peer upon return. This | ||
// also implies there are no pending HTLCs left on the channel, so we can | ||
// fully delete it from tracking (the channel monitor is still around to | ||
// watch for old state broadcasts)! | ||
locked_close_channel!(self, peer_state, chan, close_res, FUNDED); | ||
(Some(tx), Some(chan_entry.remove()), Some(close_res)) | ||
let (_, err) = convert_channel_err!(self, peer_state, close_res, chan, &msg.channel_id, COOP_CLOSED); |
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.
I find it odd that coop close gets classified as an error when it's something both nodes agreed upon, but I guess it's too late to really do anything about it
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.
I mean I can add a new, wrapping, macro to give it a new name, or rename convert_channel_err
?
59bf265
to
2d5a81d
Compare
Our coop close methods `Channel::maybe_propose_closing_signed` and `Channel::closing_signed` may return a `Transaction` to broadcast as well as a `ShutdownResult` to provide the post-shutdown handling fields. However, it only does either both of them or neither - we only and always broadcast when we're done closing. Here we tweak the return values to match the possible states, combining the two fields in the return value into a single `Option`.
While most of our closure logic mostly lives in `locked_close_chan`, some important steps happen in `convert_channel_err` and `handle_error` (mostly broadcasting a channel closure `ChannelUpdate` and sending a relevant error message to our peer). In a previous commit we removed most instances of `locked_close_channel` in our closure pipeline, however it was still called in cases where we did a cooperative close. Here we remove the remaining direct references to it, always using `convert_channel_err` instead (now with a new `COOP_CLOSED` macro variant).
The `channel_id` argument to `convert_channel_err` allows us to set a different channel ID in the error message around the funding process. However, its not exactly critical to make sure we get it right, and yet another macro argument is annoying to deal with, so here we simply drop it and use the `Channel` value. This means that when force-closing we sometimes send an `error` with the `temporary_channel_id` rather than the funded `channel_id`, but its not that critical to get right (and we don't in all cases anyway), the peer will eventually figure it out when we reconnect or they try to send more messages about the channel.
Now that we never call `locked_close_channel` directly, the documentation on it should be updated to note that it shouldn't be used, rather relying on `convert_channel_err`, which now gets much of the substantive documentation on closing logic. Similarly, as `finish_close_channel` is now only called from `handle_error` we update the docs on both to note the new semantics.
2d5a81d
to
731657b
Compare
I had really hoped to spend some time moving some of the monitor completion and closure logic out of macros (as I fear they are a nontrivial portion of our compile time), but sadly I just really don't have the time. So instead here's the few additional small things I wanted to get out of the way.