Skip to content

Commit 82d92dd

Browse files
authored
Merge pull request #2557 from waterson/stale-monitor-force-close-debugging
Log each condition that was violated for a stale monitor
2 parents 072a6ff + ff8c5db commit 82d92dd

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

lightning/src/ln/channelmanager.rs

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8637,8 +8637,22 @@ where
86378637
// But if the channel is behind of the monitor, close the channel:
86388638
log_error!(args.logger, "A ChannelManager is stale compared to the current ChannelMonitor!");
86398639
log_error!(args.logger, " The channel will be force-closed and the latest commitment transaction from the ChannelMonitor broadcast.");
8640-
log_error!(args.logger, " The ChannelMonitor for channel {} is at update_id {} but the ChannelManager is at update_id {}.",
8641-
&channel.context.channel_id(), monitor.get_latest_update_id(), channel.context.get_latest_monitor_update_id());
8640+
if channel.context.get_latest_monitor_update_id() < monitor.get_latest_update_id() {
8641+
log_error!(args.logger, " The ChannelMonitor for channel {} is at update_id {} but the ChannelManager is at update_id {}.",
8642+
&channel.context.channel_id(), monitor.get_latest_update_id(), channel.context.get_latest_monitor_update_id());
8643+
}
8644+
if channel.get_cur_holder_commitment_transaction_number() > monitor.get_cur_holder_commitment_number() {
8645+
log_error!(args.logger, " The ChannelMonitor for channel {} is at holder commitment number {} but the ChannelManager is at holder commitment number {}.",
8646+
&channel.context.channel_id(), monitor.get_cur_holder_commitment_number(), channel.get_cur_holder_commitment_transaction_number());
8647+
}
8648+
if channel.get_revoked_counterparty_commitment_transaction_number() > monitor.get_min_seen_secret() {
8649+
log_error!(args.logger, " The ChannelMonitor for channel {} is at revoked counterparty transaction number {} but the ChannelManager is at revoked counterparty transaction number {}.",
8650+
&channel.context.channel_id(), monitor.get_min_seen_secret(), channel.get_revoked_counterparty_commitment_transaction_number());
8651+
}
8652+
if channel.get_cur_counterparty_commitment_transaction_number() > monitor.get_cur_counterparty_commitment_number() {
8653+
log_error!(args.logger, " The ChannelMonitor for channel {} is at counterparty commitment transaction number {} but the ChannelManager is at counterparty commitment transaction number {}.",
8654+
&channel.context.channel_id(), monitor.get_cur_counterparty_commitment_number(), channel.get_cur_counterparty_commitment_transaction_number());
8655+
}
86428656
let (monitor_update, mut new_failed_htlcs) = channel.context.force_shutdown(true);
86438657
if let Some((counterparty_node_id, funding_txo, update)) = monitor_update {
86448658
close_background_events.push(BackgroundEvent::MonitorUpdateRegeneratedOnStartup {

0 commit comments

Comments
 (0)