-
Notifications
You must be signed in to change notification settings - Fork 345
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
Expose channel_type
in Event::ChannelPending
#2872
Conversation
It is useful to immediately know what kind of channel is being opened, and not having to wait until `ChannelReady`.
Note Reviews PausedUse the following commands to manage reviews:
WalkthroughThis update introduces a new Changes
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? TipsChatThere are 3 ways to chat with CodeRabbit:
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)
Additionally, you can add CodeRabbit Configration File (
|
There was a problem hiding this 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
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 theChannelPending
variant introduces a new piece of information about the channel's features. Ensure that all relevant parts of the codebase that create or handleChannelPending
events are updated to consider this new field.- 1221-1224: The serialization logic for the
ChannelPending
event correctly includes thechannel_type
field. Ensure that the deserialization logic inMaybeReadable for Event
also correctly handles this field, including cases where it might beNone
.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()), |
There was a problem hiding this comment.
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.
@coderabbitai pause |
Codecov ReportAttention:
❗ 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. |
There was a problem hiding this 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
.
There was a problem hiding this 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.
It is useful to immediately know what kind of channel is being opened, and not having to wait until
ChannelReady
.