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

Expose channel_type in Event::ChannelPending #2872

Conversation

tnull
Copy link
Contributor

@tnull tnull commented Feb 5, 2024

It is useful to immediately know what kind of channel is being opened, and not having to wait until ChannelReady.

It is useful to immediately know what kind of channel is being opened,
and not having to wait until `ChannelReady`.
Copy link

coderabbitai bot commented Feb 5, 2024

Note

Reviews Paused

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Walkthrough

This update introduces a new channel_type field to the Event enum for the ChannelNormal variant. It also ensures that this new data is properly emitted within the event handling logic. Essentially, this enhancement enriches event data with channel type information, improving the granularity and utility of event notifications in the system.

Changes

Files Change Summary
lightning/src/events/mod.rs, lightning/src/.../channelmanager.rs Added channel_type field to Event::ChannelNormal and updated event data emission.

🐇✨
In the code, a change does gleam,
A channel_type in Event does beam.
With every notification it sends,
A clearer picture it now lends.
🥕🎉

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: 2

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between 7c94636 and 2e61d92.
Files selected for processing (2)
  • lightning/src/events/mod.rs (4 hunks)
  • lightning/src/ln/channelmanager.rs (1 hunks)
Additional comments: 3
lightning/src/events/mod.rs (2)
  • 848-851: The addition of channel_type: Option<ChannelTypeFeatures> to the ChannelPending variant introduces a new piece of information about the channel's features. Ensure that all relevant parts of the codebase that create or handle ChannelPending events are updated to consider this new field.
  • 1221-1224: The serialization logic for the ChannelPending event correctly includes the channel_type field. Ensure that the deserialization logic in MaybeReadable for Event also correctly handles this field, including cases where it might be None.

Also applies to: 1228-1228

lightning/src/ln/channelmanager.rs (1)
  • 2155-2155: Ensure that the addition of channel_type to the event data aligns with the overall architecture and data flow of the system, particularly in how events are handled and propagated. This change should not introduce inconsistencies or unexpected behavior in event processing.

@@ -2152,6 +2152,7 @@ macro_rules! emit_channel_pending_event {
counterparty_node_id: $channel.context.get_counterparty_node_id(),
user_channel_id: $channel.context.get_user_id(),
funding_txo: $channel.context.get_funding_txo().unwrap().into_bitcoin_outpoint(),
channel_type: Some($channel.context.get_channel_type().clone()),
Copy link

Choose a reason for hiding this comment

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

The use of unwrap() on get_funding_txo() could lead to a panic if the option is None. Consider handling the None case gracefully or ensuring that get_funding_txo() cannot return None at this point in the code.


Cloning channel_type with .clone() might be inefficient if the type is complex or large. Evaluate if a reference or a more efficient cloning strategy can be used, depending on the ownership and lifetime requirements.

@tnull
Copy link
Contributor Author

tnull commented Feb 5, 2024

@coderabbitai pause

@codecov-commenter
Copy link

Codecov Report

Attention: 4 lines in your changes are missing coverage. Please review.

Comparison is base (7c94636) 89.17% compared to head (2e61d92) 89.16%.

Files Patch % Lines
lightning/src/events/mod.rs 55.55% 4 Missing ⚠️

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

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2872      +/-   ##
==========================================
- Coverage   89.17%   89.16%   -0.01%     
==========================================
  Files         116      116              
  Lines       93252    93259       +7     
  Branches    93252    93259       +7     
==========================================
+ Hits        83157    83158       +1     
- Misses       7567     7569       +2     
- Partials     2528     2532       +4     

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

Copy link
Contributor

@shaavan shaavan left a comment

Choose a reason for hiding this comment

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

Light ACK

It seems intuitively logical that channel_type can be useful as soon as the channel’s funding is broadcasted but is waiting for confirmation. However, right now I am not 100% sure as to what these use cases would look like and I shall be taking a deeper look to understand these.

Looking at this from another angle, the channel_type is already negotiated and finalized before the channel is opened and funding broadcasted, so I believe the channel_type information will be safe to expose in Event::ChannelPending.

Copy link
Collaborator

@TheBlueMatt TheBlueMatt left a comment

Choose a reason for hiding this comment

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

Sure. Probably didn't need a second reviewer, either.

@TheBlueMatt TheBlueMatt merged commit ce2907f into lightningdevkit:main Feb 5, 2024
14 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.

None yet

5 participants