Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Minor Logging tweaks #2895

Merged
merged 4 commits into from
Feb 14, 2024
Merged

Conversation

TheBlueMatt
Copy link
Collaborator

This removes 4 of our most common log lines (which generally don't impart any information, given they're so common), as well as addresses #2471

Multiple times we've had users wonder why they see `Error handling
message from.*; ignoring: Couldn't find channel for update` in
their logs and wonder if its related to their channel
force-closing. While this does indicate a peer is sending us gossip
our of order (and thus misbehaving), its not relevant to channel
operation and the logged message and level should indicate that.

Thus, here, we move the level to Gossip and add "gossip" between
"handling" and "message" (so it reads "Error handling gossip
message from.*").

Fixes lightningdevkit#2471
On a high-traffic/channel node, `Channel .* does not qualify for a
feerate change.*` is our most common log, and it doesn't provide
much useful information. It's logged in two cases - (a) where the
estimator feerate is less than the current channel feerate but not
by more than half twice and (b) where we'd like to update the
channel feerate but the peer is disconnected or channel not
available for updates.

Because these conditions can persist and we log them once a minute
the volume of logs can add up quickly. Here we simply remove the
log in case (a), though leave (b) as its anticipated to be somewhat
quieter and does indicate a persistent issue that should be
addressed (possibly by closing the channel).
On each block, for each `ChannelMonitor`, we log a status statement
in `OnChainTx::update_claims_view_from_requests`. This can add up
to quite a bit, and is generally not very interesting when we don't
actually do anything if there's no claims to bump.

Here we drop the log if we have no claims to work with, but retain
it if we process any claims.
On each block, for each `ChannelMonitor`, we log two status
statements in `OnChainTx::update_claims_view_from_matched_txn`.
This can add up to quite a bit, and is generally not very
interesting when we don't actually do anything if there's no claims
to bump.

Here we drop both logs if we have no claims to work with, but
retain it if we process any claims.
@TheBlueMatt TheBlueMatt added this to the 0.0.122 milestone Feb 13, 2024
Copy link

coderabbitai bot commented Feb 13, 2024

Walkthrough

The updates across several files in the Lightning project enhance logging mechanisms, refine error handling, and adjust conditions for logging channel feerate changes. These changes aim to improve the clarity and efficiency of log messages, ensuring that important information is logged only when necessary and providing more context in log outputs.

Changes

File Path Change Summary
.../onchaintx.rs, .../peer_handler.rs, .../gossip.rs Enhanced logging with conditional checks, improved context, and specific level logging. Introduced a closure for one-time log messages.
.../channelmanager.rs Modified logic for logging channel feerate changes; removed a condition for logging and adjusted return value.

🐇✨

In the code's weave, a rabbit hops,

Logging tales of bits and ops.

With a tweak, a turn, a nifty fix,

It mends the mesh, its magic mix.

In the glow of screen, it dances light,

Celebrating changes, day and night. 🌙

🌟📜

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

Share

Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • Generate unit-tests for this file.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit tests for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai generate interesting stats about this repository from git and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit tests.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (invoked as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger a review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • The JSON schema for the configuration file is available here.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/coderabbit-overrides.v2.json

CodeRabbit Discord Community

Join our Discord Community to get help, request features, and share feedback.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review Status

Actionable comments generated: 5

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between 73da722 and 8910153.
Files selected for processing (4)
  • lightning/src/chain/onchaintx.rs (5 hunks)
  • lightning/src/ln/channelmanager.rs (1 hunks)
  • lightning/src/ln/peer_handler.rs (2 hunks)
  • lightning/src/routing/gossip.rs (1 hunks)
Files not reviewed due to errors (1)
  • (no review received)
Additional comments: 1
lightning/src/chain/onchaintx.rs (1)
  • 864-870: The introduction of maybe_log_intro for conditional logging is a good practice. However, ensure that the logging provided is necessary and informative to avoid cluttering the log files with redundant information.

Comment on lines +1928 to +1931
return Err(LightningError {
err: "Couldn't find channel for update".to_owned(),
action: ErrorAction::IgnoreAndLog(Level::Gossip),
});
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The error message "Couldn't find channel for update" could be more descriptive by including the short channel ID in the message.

- Err(LightningError{err: "Couldn't find channel for update".to_owned(), action: ErrorAction::IgnoreAndLog(Level::Gossip)})
+ Err(LightningError{err: format!("Couldn't find channel for update: {}", msg.short_channel_id), action: ErrorAction::IgnoreAndLog(Level::Gossip)})

Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.

Suggested change
return Err(LightningError {
err: "Couldn't find channel for update".to_owned(),
action: ErrorAction::IgnoreAndLog(Level::Gossip),
});
return Err(LightningError {
err: format!("Couldn't find channel for update: {}", msg.short_channel_id),
action: ErrorAction::IgnoreAndLog(Level::Gossip),
});

Comment on lines 4833 to 4838

// If the feerate has decreased by less than half, don't bother
if new_feerate <= chan.context.get_feerate_sat_per_1000_weight() && new_feerate * 2 > chan.context.get_feerate_sat_per_1000_weight() {
if new_feerate != chan.context.get_feerate_sat_per_1000_weight() {
log_trace!(logger, "Channel {} does not qualify for a feerate change from {} to {}.",
chan_id, chan.context.get_feerate_sat_per_1000_weight(), new_feerate);
}
return NotifyOption::SkipPersistNoEvents;
}
if !chan.context.is_live() {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📝 NOTE
This review was outside the diff hunks, and no overlapping diff hunk was found. Original lines [3-6]

Consider merging the two if conditions into a single compound condition to improve readability and potentially performance by reducing the number of conditional checks.

-		if new_feerate <= chan.context.get_feerate_sat_per_1000_weight() && new_feerate * 2 > chan.context.get_feerate_sat_per_1000_weight() {
-			return NotifyOption::SkipPersistNoEvents;
-		}
-		if !chan.context.is_live() {
+		if (new_feerate <= chan.context.get_feerate_sat_per_1000_weight() && new_feerate * 2 > chan.context.get_feerate_sat_per_1000_weight()) || !chan.context.is_live() {
+			return NotifyOption::SkipPersistNoEvents;
+		}

Comment on lines +729 to +732
if !requests.is_empty() {
log_debug!(logger, "Updating claims view at height {} with {} claim requests", cur_height, requests.len());
}

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider removing the debug log if it does not provide significant value. Excessive logging, especially at debug level, can clutter log files without offering substantial insights.

Comment on lines +778 to +783
if !self.locktimed_packages.is_empty() {
log_debug!(logger,
"Updating claims view at height {} with {} locked packages available for claim",
cur_height,
self.locktimed_packages.len());
}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This debug log could potentially generate a lot of output if there are many locked packages. Evaluate if this level of verbosity is necessary or if it could be condensed or removed.

Comment on lines +1003 to +1007
if !bump_candidates.is_empty() {
maybe_log_intro();
log_trace!(logger, "Bumping {} candidates", bump_candidates.len());
}

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similar to previous comments on logging, ensure that this trace log provides value. If the information is not actionable or does not significantly aid in debugging, consider removing or reducing the verbosity.

@codecov-commenter
Copy link

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (73da722) 89.12% compared to head (8910153) 89.13%.

❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #2895   +/-   ##
=======================================
  Coverage   89.12%   89.13%           
=======================================
  Files         115      115           
  Lines       94179    94196   +17     
  Branches    94179    94196   +17     
=======================================
+ Hits        83936    83958   +22     
+ Misses       7768     7752   -16     
- Partials     2475     2486   +11     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Contributor

@tnull tnull left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

Given there are only logging changes, I'm going ahead and merge this without waiting for a second reviewer.

@tnull tnull merged commit 3fd4b39 into lightningdevkit:main Feb 14, 2024
11 of 15 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants