Send warning messages when repeating shutdown messages at volume

This commit is contained in:
Matt Corallo 2023-08-21 23:04:47 +00:00
parent bb7c4d1853
commit b14927968f
4 changed files with 19 additions and 2 deletions

View file

@ -1501,6 +1501,7 @@ impl MaybeReadable for Event {
/// broadcast to most peers).
/// These events are handled by PeerManager::process_events if you are using a PeerManager.
#[derive(Clone, Debug)]
#[cfg_attr(test, derive(PartialEq))]
pub enum MessageSendEvent {
/// Used to indicate that we've accepted a channel open and should send the accept_channel
/// message provided to the given peer.

View file

@ -7512,6 +7512,16 @@ where
msg,
});
}
peer_state.pending_msg_events.push(events::MessageSendEvent::HandleError {
node_id: *counterparty_node_id,
action: msgs::ErrorAction::SendWarningMessage {
msg: msgs::WarningMessage {
channel_id: msg.channel_id,
data: "You appear to be exhibiting LND bug 6039, we'll keep sending you shutdown messages until you handle them correctly".to_owned()
},
log_level: Level::Trace,
}
});
}
}
return;

View file

@ -1144,7 +1144,7 @@ enum EncodingType {
}
/// Used to put an error message in a [`LightningError`].
#[derive(Clone, Debug)]
#[derive(Clone, Debug, PartialEq)]
pub enum ErrorAction {
/// The peer took some action which made us think they were useless. Disconnect them.
DisconnectPeer {

View file

@ -219,7 +219,13 @@ fn test_lnd_bug_6039() {
// see if LND will accept our protocol compliance.
let err_msg = msgs::ErrorMessage { channel_id: chan.2, data: "link failed to shutdown".to_string() };
nodes[0].node.handle_error(&nodes[1].node.get_our_node_id(), &err_msg);
let _node_0_repeated_shutdown = get_event_msg!(nodes[0], MessageSendEvent::SendShutdown, nodes[1].node.get_our_node_id());
let node_a_responses = nodes[0].node.get_and_clear_pending_msg_events();
assert_eq!(node_a_responses[0], MessageSendEvent::SendShutdown {
node_id: nodes[1].node.get_our_node_id(),
msg: node_0_shutdown,
});
if let MessageSendEvent::HandleError { action: msgs::ErrorAction::SendWarningMessage { .. }, .. }
= node_a_responses[1] {} else { panic!(); }
let node_1_shutdown = get_event_msg!(nodes[1], MessageSendEvent::SendShutdown, nodes[0].node.get_our_node_id());