Skip to content

Commit 99f93f3

Browse files
committed
Remove redundant channel ID logging
Previously, log messages often included the channel ID both in the message text and in the structured `channel_id` field. This led to redundant information and made it difficult to quickly identify which log lines pertain to a given channel, as the ID could appear in different positions or sometimes not at all. This change removes the channel ID from the message in all cases where it is already present in the structured field. A test run was used to verify that the structured field always appeared in these log calls. Some exceptions remain—for example, calls where the structured field contains a temporary channel ID and the message contains the final ID were left unchanged.
1 parent 9ee6b26 commit 99f93f3

File tree

10 files changed

+192
-253
lines changed

10 files changed

+192
-253
lines changed

lightning/src/chain/chainmonitor.rs

Lines changed: 16 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -580,23 +580,17 @@ where
580580

581581
let has_pending_claims = monitor_state.monitor.has_pending_claims();
582582
if has_pending_claims || get_partition_key(channel_id) % partition_factor == 0 {
583-
log_trace!(
584-
logger,
585-
"Syncing Channel Monitor for channel {}",
586-
log_funding_info!(monitor)
587-
);
583+
log_trace!(logger, "Syncing Channel Monitor");
588584
// Even though we don't track monitor updates from chain-sync as pending, we still want
589585
// updates per-channel to be well-ordered so that users don't see a
590586
// `ChannelMonitorUpdate` after a channel persist for a channel with the same
591587
// `latest_update_id`.
592588
let _pending_monitor_updates = monitor_state.pending_monitor_updates.lock().unwrap();
593589
match self.persister.update_persisted_channel(monitor.persistence_key(), None, monitor)
594590
{
595-
ChannelMonitorUpdateStatus::Completed => log_trace!(
596-
logger,
597-
"Finished syncing Channel Monitor for channel {} for block-data",
598-
log_funding_info!(monitor)
599-
),
591+
ChannelMonitorUpdateStatus::Completed => {
592+
log_trace!(logger, "Finished syncing Channel Monitor for block-data")
593+
},
600594
ChannelMonitorUpdateStatus::InProgress => {
601595
log_trace!(
602596
logger,
@@ -961,16 +955,12 @@ where
961955
}
962956
if have_monitors_to_prune {
963957
let mut monitors = self.monitors.write().unwrap();
964-
monitors.retain(|channel_id, monitor_holder| {
958+
monitors.retain(|_channel_id, monitor_holder| {
965959
let logger = WithChannelMonitor::from(&self.logger, &monitor_holder.monitor, None);
966960
let (is_fully_resolved, _) =
967961
monitor_holder.monitor.check_and_update_full_resolution_status(&logger);
968962
if is_fully_resolved {
969-
log_info!(
970-
logger,
971-
"Archiving fully resolved ChannelMonitor for channel ID {}",
972-
channel_id
973-
);
963+
log_info!(logger, "Archiving fully resolved ChannelMonitor");
974964
self.persister
975965
.archive_persisted_channel(monitor_holder.monitor.persistence_key());
976966
false
@@ -1106,11 +1096,7 @@ where
11061096
},
11071097
hash_map::Entry::Vacant(e) => e,
11081098
};
1109-
log_trace!(
1110-
logger,
1111-
"Loaded existing ChannelMonitor for channel {}",
1112-
log_funding_info!(monitor)
1113-
);
1099+
log_trace!(logger, "Loaded existing ChannelMonitor");
11141100
if let Some(ref chain_source) = self.chain_source {
11151101
monitor.load_outputs_to_watch(chain_source, &self.logger);
11161102
}
@@ -1366,25 +1352,17 @@ where
13661352
},
13671353
hash_map::Entry::Vacant(e) => e,
13681354
};
1369-
log_trace!(logger, "Got new ChannelMonitor for channel {}", log_funding_info!(monitor));
1355+
log_trace!(logger, "Got new ChannelMonitor");
13701356
let update_id = monitor.get_latest_update_id();
13711357
let mut pending_monitor_updates = Vec::new();
13721358
let persist_res = self.persister.persist_new_channel(monitor.persistence_key(), &monitor);
13731359
match persist_res {
13741360
ChannelMonitorUpdateStatus::InProgress => {
1375-
log_info!(
1376-
logger,
1377-
"Persistence of new ChannelMonitor for channel {} in progress",
1378-
log_funding_info!(monitor)
1379-
);
1361+
log_info!(logger, "Persistence of new ChannelMonitor in progress",);
13801362
pending_monitor_updates.push(update_id);
13811363
},
13821364
ChannelMonitorUpdateStatus::Completed => {
1383-
log_info!(
1384-
logger,
1385-
"Persistence of new ChannelMonitor for channel {} completed",
1386-
log_funding_info!(monitor)
1387-
);
1365+
log_info!(logger, "Persistence of new ChannelMonitor completed",);
13881366
},
13891367
ChannelMonitorUpdateStatus::UnrecoverableError => {
13901368
let err_str = "ChannelMonitor[Update] persistence failed unrecoverably. This indicates we cannot continue normal operation and must shut down.";
@@ -1426,12 +1404,7 @@ where
14261404
Some(monitor_state) => {
14271405
let monitor = &monitor_state.monitor;
14281406
let logger = WithChannelMonitor::from(&self.logger, &monitor, None);
1429-
log_trace!(
1430-
logger,
1431-
"Updating ChannelMonitor to id {} for channel {}",
1432-
update.update_id,
1433-
log_funding_info!(monitor)
1434-
);
1407+
log_trace!(logger, "Updating ChannelMonitor to id {}", update.update_id,);
14351408

14361409
// We hold a `pending_monitor_updates` lock through `update_monitor` to ensure we
14371410
// have well-ordered updates from the users' point of view. See the
@@ -1452,7 +1425,7 @@ where
14521425
// We don't want to persist a `monitor_update` which results in a failure to apply later
14531426
// while reading `channel_monitor` with updates from storage. Instead, we should persist
14541427
// the entire `channel_monitor` here.
1455-
log_warn!(logger, "Failed to update ChannelMonitor for channel {}. Going ahead and persisting the entire ChannelMonitor", log_funding_info!(monitor));
1428+
log_warn!(logger, "Failed to update ChannelMonitor. Going ahead and persisting the entire ChannelMonitor");
14561429
self.persister.update_persisted_channel(
14571430
monitor.persistence_key(),
14581431
None,
@@ -1468,18 +1441,17 @@ where
14681441
match persist_res {
14691442
ChannelMonitorUpdateStatus::InProgress => {
14701443
pending_monitor_updates.push(update_id);
1471-
log_debug!(logger,
1472-
"Persistence of ChannelMonitorUpdate id {:?} for channel {} in progress",
1444+
log_debug!(
1445+
logger,
1446+
"Persistence of ChannelMonitorUpdate id {:?} in progress",
14731447
update_id,
1474-
log_funding_info!(monitor)
14751448
);
14761449
},
14771450
ChannelMonitorUpdateStatus::Completed => {
14781451
log_debug!(
14791452
logger,
1480-
"Persistence of ChannelMonitorUpdate id {:?} for channel {} completed",
1453+
"Persistence of ChannelMonitorUpdate id {:?} completed",
14811454
update_id,
1482-
log_funding_info!(monitor)
14831455
);
14841456
},
14851457
ChannelMonitorUpdateStatus::UnrecoverableError => {

lightning/src/chain/channelmonitor.rs

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4223,8 +4223,8 @@ impl<Signer: EcdsaChannelSigner> ChannelMonitorImpl<Signer> {
42234223
log_info!(logger, "Applying pre-0.1 force close update to monitor {} with {} change(s).",
42244224
log_funding_info!(self), updates.updates.len());
42254225
} else {
4226-
log_info!(logger, "Applying update to monitor {}, bringing update_id from {} to {} with {} change(s).",
4227-
log_funding_info!(self), self.latest_update_id, updates.update_id, updates.updates.len());
4226+
log_info!(logger, "Applying update, bringing update_id from {} to {} with {} change(s).",
4227+
self.latest_update_id, updates.update_id, updates.updates.len());
42284228
}
42294229

42304230
// ChannelMonitor updates may be applied after force close if we receive a preimage for a
@@ -4351,7 +4351,7 @@ impl<Signer: EcdsaChannelSigner> ChannelMonitorImpl<Signer> {
43514351
self.queue_latest_holder_commitment_txn_for_broadcast(broadcaster, &bounded_fee_estimator, logger, true);
43524352
} else if !self.holder_tx_signed {
43534353
log_error!(logger, "WARNING: You have a potentially-unsafe holder commitment transaction available to broadcast");
4354-
log_error!(logger, " in channel monitor for channel {}!", &self.channel_id());
4354+
log_error!(logger, " in channel monitor!");
43554355
log_error!(logger, " Read the docs for ChannelMonitor::broadcast_latest_holder_commitment_txn to take manual action!");
43564356
} else {
43574357
// If we generated a MonitorEvent::HolderForceClosed, the ChannelManager
@@ -5479,7 +5479,7 @@ impl<Signer: EcdsaChannelSigner> ChannelMonitorImpl<Signer> {
54795479
} else {
54805480
"".to_string()
54815481
};
5482-
log_info!(logger, "{desc} for channel {} confirmed with txid {txid}{action}", self.channel_id());
5482+
log_info!(logger, "{desc} confirmed with txid {txid}{action}");
54835483

54845484
self.alternative_funding_confirmed = Some((txid, height));
54855485

@@ -5531,8 +5531,7 @@ impl<Signer: EcdsaChannelSigner> ChannelMonitorImpl<Signer> {
55315531
.map(|(txid, _)| txid)
55325532
.unwrap_or_else(|| self.funding.funding_txid())
55335533
);
5534-
log_info!(logger, "Channel {} closed by funding output spend in txid {txid}",
5535-
self.channel_id());
5534+
log_info!(logger, "Channel closed by funding output spend in txid {txid}");
55365535
if !self.funding_spend_seen {
55375536
self.pending_monitor_events.push(MonitorEvent::CommitmentTxConfirmed(()));
55385537
}

lightning/src/ln/chanmon_update_fail_tests.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -150,8 +150,7 @@ fn test_monitor_and_persister_update_fail() {
150150
}
151151
logger.assert_log_regex(
152152
"lightning::chain::chainmonitor",
153-
regex::Regex::new("Failed to update ChannelMonitor for channel [0-9a-f]*.")
154-
.unwrap(),
153+
regex::Regex::new("Failed to update ChannelMonitor").unwrap(),
155154
1,
156155
);
157156

0 commit comments

Comments
 (0)