Skip to content

Commit

Permalink
fix: Drop pending finalize messages on disconnected peer
Browse files Browse the repository at this point in the history
If the peer disconnects before the pending finalize message could have been processed, the recovery logic is in conflict with the hanging message.

Both parties return to the offered state and try to recover from there, now the pending `Finalize` message is out of place.

We had a similar issue with a pending `Confirm` message. I presume this issue got introduced after the protocol was extended for the `Revoke` message.
  • Loading branch information
holzeis committed Aug 24, 2023
1 parent a765a59 commit f10b91f
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions dlc-messages/src/message_handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,16 @@ impl MessageHandler {
);
false
}
Message::SubChannel(SubChannelMessage::Finalize(message))
if node_id == disconnected_node_id =>
{
log::warn!(
"Dropping SubChannelFinalize message for channel {:?} \
after peer {node_id} disconnected",
message.channel_id
);
false
}
Message::SubChannel(SubChannelMessage::CloseConfirm(message))
if node_id == disconnected_node_id =>
{
Expand All @@ -127,6 +137,16 @@ impl MessageHandler {
);
false
}
Message::SubChannel(SubChannelMessage::CloseFinalize(message))
if node_id == disconnected_node_id =>
{
log::warn!(
"Dropping SubChannelCloseFinalize message for channel {:?} \
after peer {node_id} disconnected",
message.channel_id
);
false
}
// Keep any other message
_ => true,
}
Expand Down

0 comments on commit f10b91f

Please sign in to comment.