Skip to content

Conversation

Roasbeef
Copy link
Member

In this PR, we add logging to the new Access Manager. It was committed without any logs at all, which otherwise would've made it hard to monitor and debug the new sub-system.

Copy link
Contributor

coderabbitai bot commented Apr 15, 2025

Important

Review skipped

Auto reviews are limited to specific labels.

🏷️ Labels to auto review (1)
  • llm-review

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ 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>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • 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 testing code 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 gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

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 using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • 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/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR adds logging support to the new Access Manager sub‑system, enabling easier monitoring and debugging.

  • Introduces a new logger (acsmLog) for the Access Manager.
  • Inserts various debug, info, and warning log statements in key state transitions and error branches.
  • Enhances error reporting in the access management logic.

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
log.go Added new Access Manager logger (acsmLog).
accessman.go Inserted logging calls in permission assignment, pending channel and connection methods.
Comments suppressed due to low confidence (2)

accessman.go:86

  • [nitpick] Consider storing the serialized peer key as a []byte instead of converting it to a string and then back to []byte in logging calls; this can improve clarity and help avoid potential formatting inconsistencies.
peerMapKey := string(remotePub.SerializeCompressed())

accessman.go:435

  • Consider using %s instead of %x when formatting the peer identifier, or convert peerMapKey to a []byte to match the %x verb. This will ensure the error message is formatted as intended.
err := fmt.Errorf("invalid peer access status: new open channel for restricted peer %x", peerMapKey)

Copy link
Collaborator

@guggero guggero left a comment

Choose a reason for hiding this comment

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

Nice usage of the new logging system 💯

I think the two commits should probably be combined. Only looked at the combined diff.

Copy link
Collaborator

@ellemouton ellemouton left a comment

Choose a reason for hiding this comment

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

We can make the diff way smaller by not using a global context but instead deriving one at the start of a call (using context.TODO for now to indicate that it should eventually be replace by a ctx param) and then adding certain info (like the peer pub key) to that initial context - then it doesnt need to be re-added each time you log

@Roasbeef
Copy link
Member Author

I think the two commits should probably be combined. Only looked at the combined diff.

SGTM. I did the first commit, then decided it would be better to use the latest n greatest logging.

@Roasbeef Roasbeef added this to the v0.19.0 milestone Apr 16, 2025
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

Comments suppressed due to low confidence (2)

accessman.go:85

  • [nitpick] Consider replacing context.TODO() with a proper context passed from upstream to improve context propagation and cancellation support in production scenarios.
ctx := btclog.WithCtx(context.TODO(), lnutils.LogPubKey("peer", remotePub))

accessman.go:302

  • [nitpick] Consider removing the trailing colon in the log message to maintain consistency with other log messages.
acsmLog.WarnS(ctx, "Peer last pending channel closed: ", ErrNoMoreRestrictedAccessSlots, "num_restricted", a.numRestricted, "max_restricted", a.cfg.maxRestrictedSlots)

This captures a common pattern where we want to log a peer's public key
along side each logging statement.
This commit adds logs to the new access manager. This'll help us monitor
the new system behavior, and may make debugging easier in the future.
Copy link
Collaborator

@ziggie1984 ziggie1984 left a comment

Choose a reason for hiding this comment

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

Nice example PR how to add SLogging, LGTM

@Roasbeef Roasbeef merged commit cb481df into lightningnetwork:master Apr 18, 2025
34 of 35 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants