You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Clean up error messages and conditionals in reestablish handling
When we reestablish there are generally always 4 conditions for
both local and remote commitment transactions:
* we're stale and have possibly lost data
* we're ahead and the peer has lost data
* we're caught up
* we're nearly caught up and need to retransmit one update.
In especially the local commitment case we had a mess of different
comparisons, which is improved here. Further, the error messages
are clarified and include more information.
Copy file name to clipboardExpand all lines: lightning/src/ln/channel.rs
+24-8
Original file line number
Diff line number
Diff line change
@@ -4180,10 +4180,12 @@ impl<SP: Deref> Channel<SP> where
4180
4180
// Before we change the state of the channel, we check if the peer is sending a very old
4181
4181
// commitment transaction number, if yes we send a warning message.
4182
4182
let our_commitment_transaction = INITIAL_COMMITMENT_NUMBER - self.context.cur_holder_commitment_transaction_number - 1;
4183
-
if msg.next_remote_commitment_number + 1 < our_commitment_transaction {
4184
-
return Err(
4185
-
ChannelError::Warn(format!("Peer attempted to reestablish channel with a very old local commitment transaction: {} (received) vs {} (expected)", msg.next_remote_commitment_number, our_commitment_transaction))
4186
-
);
4183
+
if msg.next_remote_commitment_number + 1 < our_commitment_transaction {
4184
+
return Err(ChannelError::Warn(format!(
4185
+
"Peer attempted to reestablish channel with a very old local commitment transaction: {} (received) vs {} (expected)",
4186
+
msg.next_remote_commitment_number,
4187
+
our_commitment_transaction
4188
+
)));
4187
4189
}
4188
4190
4189
4191
// Go ahead and unmark PeerDisconnected as various calls we may make check for it (and all
@@ -4225,19 +4227,23 @@ impl<SP: Deref> Channel<SP> where
4225
4227
});
4226
4228
}
4227
4229
4228
-
let required_revoke = if msg.next_remote_commitment_number + 1 == INITIAL_COMMITMENT_NUMBER - self.context.cur_holder_commitment_transaction_number {
4230
+
let required_revoke = if msg.next_remote_commitment_number == our_commitment_transaction {
4229
4231
// Remote isn't waiting on any RevokeAndACK from us!
4230
4232
// Note that if we need to repeat our ChannelReady we'll do that in the next if block.
0 commit comments