-
Notifications
You must be signed in to change notification settings - Fork 943
Shutdown while awaiting lockin #1313
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
Shutdown while awaiting lockin #1313
Conversation
Signed-off-by: Rusty Russell <[email protected]>
Fixes: ElementsProject#1308 Signed-off-by: Rusty Russell <[email protected]>
Signed-off-by: Rusty Russell <[email protected]>
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.
Looks OK, mostly trusting Rusty superior knowledge of state machine though.
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.
The commits should probably be reordered (test needs to move down) otherwise we broke the bisectability of master
.
FWIW, I don't think this addresses #1308 since that fails on the transition after channeld_shutting_down
:
lightning/lightningd/channel_control.c
Lines 104 to 106 in 26f7014
/* This sets channel->owner, closes down channeld. */ | |
peer_start_closingd(channel, &cs, gossip_index, fds[0], fds[1], false); | |
channel_set_state(channel, CHANNELD_SHUTTING_DOWN, CLOSINGD_SIGEXCHANGE); |
@@ -77,9 +77,9 @@ static void peer_got_shutdown(struct channel *channel, const u8 *msg) | |||
} | |||
|
|||
/* If we weren't already shutting down, we are now */ | |||
if (channel->state == CHANNELD_NORMAL) | |||
if (channel->state != CHANNELD_SHUTTING_DOWN) |
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.
Might a bit too permissive now? We probably also don't want to accept in state sigexchange.
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.
If we're in channeld (which we are), we have to be in AWAITING_LOCKIN or NORMAL or SHUTTING_DOWN. So this is actually safe.
I think the PR makes the state machine transition to |
Oh I see, we're forcing the channel state into shutting down, then tell IMHO there still is a tiny probability that there is a channel state transition between receiving the shutdown and |
It's channeld which tells us that it received shutdown, so it can't die at the same time? The order is:
Note that if we reconnect, the peer can re-send shutdown so we need to handle the case where we're already in CHANNELD_SHUTTING_DOWN. We could eliminate the CHANNELD_SHUTTING_DOWN state and use the existence of the remote closing scriptpubkey as a flag, but as shutdown can be extended, I think having the state is clearer to users. |
Oh, and on test order: I've taken to leaving the test-then-fix order in my pushes, using unittest.expectedFail() and removing it in the fix. That proves that I actually tested it before and after :) |
No description provided.