Channelmanager: improve block connection logging#4586
Channelmanager: improve block connection logging#4586Alkamal01 wants to merge 1 commit intolightningdevkit:mainfrom
Conversation
Upgrade best_block_updated log from TRACE to INFO so chain tip updates are visible without enabling full trace logging. Add per-txid DEBUG logs in transactions_confirmed to make it easier to identify which transactions triggered channel updates.
|
I've assigned @valentinewallace as a reviewer! |
| for (_, tx) in txdata.iter() { | ||
| log_debug!(self.logger, "Confirmed transaction {} in block {} at height {}", tx.compute_txid(), block_hash, height); | ||
| } |
There was a problem hiding this comment.
compute_txid() performs a double-SHA256 over the serialized transaction, and the log_given_level! macro evaluates its arguments unconditionally (the level check is inside the Logger::log implementation, not before argument evaluation). This means the loop runs and hashes every transaction even when the logger's level is above DEBUG.
Consider either:
- Guarding the loop behind a level check, or
- Folding these per-txid details into the existing TRACE log, or
- Using a lazy wrapper (e.g., a
Displayimpl that computes onfmt) — though this still wouldn't avoid the loop itself.
While txdata only contains matching transactions (not the full block), computing txids unconditionally on every block connection is unnecessary overhead for users who don't have DEBUG enabled.
Review SummaryInline comments posted:
No cross-cutting concerns beyond the inline comment. |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #4586 +/- ##
==========================================
+ Coverage 86.99% 87.16% +0.17%
==========================================
Files 163 161 -2
Lines 109008 109263 +255
Branches 109008 109263 +255
==========================================
+ Hits 94828 95236 +408
+ Misses 11696 11550 -146
+ Partials 2484 2477 -7
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Channelmanager: improve block connection logging
Fixes #2348. Supersedes #4420.
best_block_updatedwas logging at TRACE, making it impossible to track chain tip progress without enabling full trace logging. This upgrades it to INFO.Also adds per-txid DEBUG logs in
transactions_confirmedso individual transactions triggering channel updates are visible at a useful log level.The original PR #4420 also added an INFO log in
filtered_block_connected, but that duplicates the one inbest_block_updated(which filtered_block_connected calls directly). That log is left out here.