Optimize block connection logging using LazyTxid#4659
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.
…gging Use a lazy Display wrapper to format confirmed txids, preventing unconditional hashing when DEBUG logging is disabled.
|
I've assigned @valentinewallace as a reviewer! |
| for (_, tx) in txdata.iter() { | ||
| log_debug!(self.logger, "Confirmed transaction {} in block {} at height {}", LazyTxid(tx), block_hash, height); | ||
| } |
There was a problem hiding this comment.
This loop logs every transaction in txdata, but txdata is not necessarily filtered to only channel-relevant transactions. In the Listen::block_connected → filtered_block_connected → transactions_confirmed path, txdata contains all transactions in the block (see block_connected default impl in chain/mod.rs:190-192). Even with BIP 157/158 compact block filters, the filtering is block-level, not transaction-level, so a matching block still delivers all its transactions here.
On mainnet blocks with ~2000-3000 transactions, this produces thousands of DEBUG log lines per block (~every 10 minutes), almost all for transactions completely unrelated to the node's channels. If DEBUG is enabled, each line also triggers a compute_txid() (double-SHA256 of the serialized transaction).
Consider either:
- Moving this logging after channel processing so you only log transactions that actually triggered a channel update, or
- Gating this on TRACE instead of DEBUG, consistent with the existing aggregate log on the line above.
Review SummaryInline comments posted:
No other issues found. The |
This PR replaces PR #4586. I am resubmitting it from this account because my previous account (Alkamal01) is currently experiencing unexpected visibility restrictions from GitHub's automated filters, making the original PR inaccessible to reviewers. This contains the same code and logic as originally proposed.
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(whichfiltered_block_connectedcalls directly). That log is left out here.