-
Notifications
You must be signed in to change notification settings - Fork 376
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
Onion messages: flip feature bit 🎉 #1688
Onion messages: flip feature bit 🎉 #1688
Conversation
81a18d2
to
c5503ee
Compare
Codecov Report
@@ Coverage Diff @@
## main #1688 +/- ##
==========================================
+ Coverage 90.84% 90.85% +0.01%
==========================================
Files 86 86
Lines 46399 46422 +23
Branches 46399 46422 +23
==========================================
+ Hits 42150 42178 +28
+ Misses 4249 4244 -5
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. |
// - option_channel_type | option_scid_alias | ||
// - option_zeroconf | ||
assert_eq!(node_features.flags.len(), 7); | ||
assert_eq!(node_features.flags[0], 0b00000010); | ||
assert_eq!(node_features.flags[1], 0b01010001); | ||
assert_eq!(node_features.flags[2], 0b00001010); | ||
assert_eq!(node_features.flags[3], 0b00001000); | ||
assert_eq!(node_features.flags[4], 0b00000000); | ||
assert_eq!(node_features.flags[4], 0b10000000); |
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.
I think I gotta spend some time figuring out how we handle feature bits internally lol
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.
Basically LGTM, but we need to change the Init
message we send our peers based on if we have an onion messenger hooked up or not as well.
c5503ee
to
f64aea0
Compare
LGTM, will need rebase after 1650. |
d923d54
to
4f2a842
Compare
Needs rebase 🚀 |
lightning/src/ln/msgs.rs
Outdated
/// Advertise onion message forwarding support in broadcasted node announcements. | ||
fn advertise_onion_message_support(&self); |
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.
I get that we're trying to only advertise the feature if we have a handler that will support it, but this seems like it should be more of a configuration parameter. Otherwise, we're shoehorning it into a trait meant for handling messages even though this only affects message broadcasting.
Trying to think if there is a better way of accomplishing this...
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.
Yea, I'd really love a cleaner way of accomplishing this, definitely agree, but its not clear to me there is one, at least not without exposing this stuff to the user and making them set yet another config knob correctly, which I'd strongly rather avoid :(
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.
Some questions / ideas to bounce of you both:
Do we expect the user to ever need to write their own OnionMessageHandler
? Or will they always configure OnionMessenger
with individual handlers for the different types of onion message payloads? If the latter, instead of using IgnoringMessageHandler
, maybe we could have it be Option<OnionMessenger>
and use its presence to signal if onion message forwarding is supported? Might be worth doing this regardless instead of having two levels of configuration.
For broadcast_node_announcement
, could this also take InitFeatures
as a parameter? I guess we'd want only PeerManager
to determine which features to pass to it. So could have a broadcast_node_announcement
method on PeerManager
(without the parameter), which delegates to ChannelManager
(with the parameter). Though that means having a somewhat unrelated broadcast_node_announcement
on ChannelMessageHandler
or MessageSendEventsProvider
. Alternatively, have BackgroundProcessor
be responsible for calling broadcast_node_announcement
on ChannelManager
with features obtained from PeerManager
.
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.
Do we expect the user to ever need to write their own OnionMessageHandler? Or will they always configure OnionMessenger with individual handlers for the different types of onion message payloads? If the latter, instead of using IgnoringMessageHandler , maybe we could have it be Option and use its presence to signal if onion message forwarding is supported? Might be worth doing this regardless instead of having two levels of configuration.
Yea, I'd be fine with that, I don't have a super strong idea of when a user would want a custom onion message handler vs just handling onion messages in a custom way. It doesn't seem to clean the interface up all that much, though, having a "do you forward messages" call on the handler interface seems fine, its the calling back through to ChannelManager that's awkward.
For broadcast_node_announcement, could this also take InitFeatures as a parameter? I guess we'd want only PeerManager to determine which features to pass to it.
I don't think so, there's plenty of things the ChannelManager is responsible for and needs to select the features of :(.
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.
I don't think so, there's plenty of things the ChannelManager is responsible for and needs to select the features of :(.
Not sure I understand here. Looks like broadcast_node_announcement
is the only place it needs our features.
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.
Hmmm... I see . Though that would also mean the features advertised by Init
may not be accurate if a custom channel message handler were used? Seems each handler may want to declare which features they support (i.e., implement), and the PeerManager
would want to take the intersection of these for what is actually used in either Init
or ChannelAnnouncement
?
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.
er... s/intersection/union
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.
Though that would also mean the features advertised by Init may not be accurate if a custom channel message handler were used?
Hmm, good point.
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 PeerManager would want to take the intersection of these for what is actually used in either Init or ChannelAnnouncement?
Yea, maybe that's the way we want to go. One annoying part is that we can't make a node announcement until we've sent at least one public channel announcement. Thus, if we make a new peer connection we'll really have to ask the ChannelManager to rebroadcast the channel announcements (and updates, I guess) from the PeerManager. We maybe should do this anyway and do it when we connect to a peer.
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.
Ok, take a look at #1699 - it basically does this, though doesn't implement the feature OR'ing part yet.
ee576ca
to
1fee894
Compare
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.
Still LGTM, Feel free to squash once @jkczyz is fine.
lightning/src/ln/peer_handler.rs
Outdated
@@ -506,6 +508,7 @@ pub struct PeerManager<Descriptor: SocketDescriptor, CM: Deref, RM: Deref, OM: D | |||
/// when an event process call is waiting. | |||
blocked_event_processors: AtomicBool, | |||
our_node_secret: SecretKey, | |||
our_features: InitFeatures, |
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.
Oops, lol, I commented wrong, I meant "stack/local variable", not "member variable". It doesn't really matter all that much, though.
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.
Oh lol. @jkczyz do you have a preference?
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.
Possibly would depend on the resolution of #1688 (comment).
1fee894
to
50444ea
Compare
08ed7d0
to
4805961
Compare
4805961
to
d757585
Compare
Oops, mis-push. Updating |
5a2350b
to
43ae31b
Compare
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 Code Review ACK 43ae31b
@@ -39,8 +39,13 @@ | |||
//! (see [BOLT-4](https://github.com/lightning/bolts/blob/master/04-onion-routing.md) for more information). | |||
//! - `BasicMPP` - requires/supports that a node can receive basic multi-part payments | |||
//! (see [BOLT-4](https://github.com/lightning/bolts/blob/master/04-onion-routing.md#basic-multi-part-payments) for more information). | |||
//! - `Wumbo` - requires/supports that a node create large channels. Called `option_support_large_channel` in the spec. |
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.
Could say "large channels (superior to MAX_FUNDING_SATOSHIS_NO_WUMBO
)"
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.
Ah, that const isn't public
When we broadcast a node announcement, the features we support are really a combination of all the various features our different handlers support. This commit captures this concept by OR'ing our NodeFeatures across both our channel and routing message handlers.
When ChannelMessageHandler implementations wish to return a NodeFeatures which contain all the known flags that are relevant to channel handling, but not gossip handling, they currently need to do so by manually constructing a NodeFeatures with all known flags and then clearing the ones they don't want. Instead of spreading this logic across the codebase, this consolidates such construction into one place in features.rs.
In upcoming commit(s), onion message support will be advertised conditionally based on the OnionMessageProvider provided to PeerManager.
Similar to how we OR our InitFeaures and NodeFeatures across both our channel and routing message handlers, we also want to OR the features of our onion message handler.
To be uniform with the other handler provided_node_features docs
5d9dddd
43ae31b
to
5d9dddd
Compare
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.
ACK 5d9dddd
Based on #1650