-
Notifications
You must be signed in to change notification settings - Fork 412
Allow sending closing tx signatures asynchronously #3153
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
Allow sending closing tx signatures asynchronously #3153
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #3153 +/- ##
==========================================
+ Coverage 89.78% 91.12% +1.33%
==========================================
Files 123 126 +3
Lines 102330 114900 +12570
Branches 102330 114900 +12570
==========================================
+ Hits 91876 104701 +12825
+ Misses 7763 7708 -55
+ Partials 2691 2491 -200 ☔ View full report in Codecov by Sentry. |
a46812a
to
a37c656
Compare
a37c656
to
ca1a389
Compare
rebased because of conflicts |
ca1a389
to
8cacf67
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.
A few nits asking for more tests, but LGTM I think. @valentinewallace ?
Taking a look! |
934ec75
to
dcf4ad8
Compare
rebased because of conflicts as well |
dcf4ad8
to
44e95c2
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.
I'm good with a squash then landing this!
Feel free to squash, lets get this over the line! |
44e95c2
to
b0f7efa
Compare
addressed latest nits and squashed |
lightning/src/ln/channel.rs
Outdated
{ | ||
if matches!(self.context.channel_state, ChannelState::ShutdownComplete) { |
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.
Ugh, I think this is gonna cause issues - we currently assume that ShutdownComplete
means a channel can't exist after its set and assert it a few other places. Currently, what if a user calls force_shutdown
on a channel while its pending, I think we'll panic, but also in some message handlers we assert that the state is ChannelReady
and could similarly panic after a peer sends us the wrong message. Instead, I think we should leave the channel as ChannelReady
and just check the state in the shutdown messages (other things, IIRC, already check if the state has shutdown_sent).
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.
Alright, made sure not the set ShutdownComplete
in the pending signatures case, and added a helper to check whether we're basically shutdown but waiting on the signature, which is used in the check here + debug asserts, lmk if that works
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.
Thanks, feel free to squash.
b0f7efa
to
c3a2d8b
Compare
Sorry for the delay, release process is always fun. I think this LGTM. |
c3a2d8b
to
6e2071a
Compare
squashed |
}, | ||
_ => panic!("Unexpected event: {:?}", events[0]), | ||
}; | ||
} |
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.
As a followup, can we simulate a reconnect here? We should make sure a disconnect/reconnect here doesn't cause failure to finish the closing signed dance.
Another async signing PR, this time for
sign_closing_transaction
!If you've reviewed the other PRs, you know the drill: try to go about business as usual, if we fail to get the signature, do everything except for send the message, and mark our
signer_pending_closing
flag. The user then needs to callsigner_unblocked
, and we'll try again to get the signature, then create + send the message. In this case we not only need to send the message, but also 1. broadcast the fully signed closing tx, 2. broadcast a channel update, and 3. remove the channel from our map.I added some additional state to track everything we need to do everything we need (rebuild the tx, fully sign, send our
closing_signed
msg, etc.) upon the signer being unblocked. This state is not persisted.