-
Notifications
You must be signed in to change notification settings - Fork 385
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
Support ZeroConf
channel type.
#1505
Support ZeroConf
channel type.
#1505
Conversation
lightning/src/ln/features.rs
Outdated
@@ -402,7 +402,9 @@ mod sealed { | |||
define_feature!(47, SCIDPrivacy, [InitContext, NodeContext, ChannelTypeContext], | |||
"Feature flags for only forwarding with SCID aliasing. Called `option_scid_alias` in the BOLTs", | |||
set_scid_privacy_optional, set_scid_privacy_required, supports_scid_privacy, requires_scid_privacy); | |||
|
|||
define_feature!(51, ZeroConf, [ChannelTypeContext], |
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 still need to add a comment that points out using this feature will break backwards compatibility with versions prior to 0.0.107. Probably, this comment should be added to accept_inbound_channel_from_trusted_peer_0conf
?
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.
Probably on the Event::OpenChannelRequest
, there's already a similar comment for the scid privacy flag.
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.
Done with 794a6c6.
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.
LGTM aside from the one issue you already noted.
Codecov Report
@@ Coverage Diff @@
## main #1505 +/- ##
==========================================
+ Coverage 90.97% 92.23% +1.26%
==========================================
Files 80 80
Lines 43081 51324 +8243
Branches 43081 51324 +8243
==========================================
+ Hits 39194 47340 +8146
- Misses 3887 3984 +97
Continue to review full report at Codecov.
|
794a6c6
to
1add379
Compare
Squashed. |
Test? 😛 |
lightning/src/util/events.rs
Outdated
@@ -466,6 +466,10 @@ pub enum Event { | |||
/// the resulting [`ChannelManager`] will not be readable by versions of LDK prior to | |||
/// 0.0.106. | |||
/// | |||
/// Also note that if [`ChannelTypeFeatures::supports_zero_conf`] returns true on this type, |
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.
Maybe also something about either accept the channel via accept_inbound_channel_from_trusted_peer_0conf
or the channel will be force-closed?
Thanks for the features test. In
I'm not sure if we'll accept channels with the 0-conf feature bit set, based on this? Either way, would be nice to either test or file an issue for a test for this case |
Thanks, I'll have a look and add a proper test case. |
allowed_type.set_scid_privacy_required(); | ||
if *channel_type != allowed_type { | ||
if *channel_type != ChannelTypeFeatures::only_static_remote_key() { | ||
if !channel_type.requires_scid_privacy() && !channel_type.requires_zero_conf() { |
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.
Wont this change imply we accept a channel_type that has some other unknown bit set?
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.
Argh, right. Fixed this with 7f8bab5.
I'd generally like to add yet another test case in |
a5d577f
to
3c13abe
Compare
Done with 9ca9dd0. |
lightning/src/ln/channel.rs
Outdated
return Err(ChannelError::Close("Channel Type field contains unknown bits".to_owned())); | ||
} | ||
|
||
// We currently only allow three channel types, so write it all out here - we allow |
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.
Technically 4 - you can also do SRC and privacy+0conf
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.
Done.
lightning/src/ln/functional_tests.rs
Outdated
nodes[1].node.handle_open_channel(&nodes[0].node.get_our_node_id(), InitFeatures::known(), &open_channel_msg); | ||
|
||
let events = nodes[1].node.get_and_clear_pending_msg_events(); | ||
println!("EVENTS {:?}", events); |
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.
nit rm.
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.
Fixed in cfab760.
526422a
to
cfab760
Compare
Squashed. |
/// the resulting [`ChannelManager`] will not be readable by versions of LDK prior to | ||
/// 0.0.107. Channels setting this type also need to get manually accepted via | ||
/// [`crate::ln::channelmanager::ChannelManager::accept_inbound_channel_from_trusted_peer_0conf`], | ||
/// or will be rejected otherwise. |
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.
Hmm, so its not technically "rejected otherwise" the accept_inbound_channel
call fails, and the channel is still there, which kinda sucks. Maybe we just force-close automatically if you call accept_inbound_channel
?
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.
AFAICT, if the user calls the wrong method and the channel keeps 'lingering' in our channel_state
, we would basically have the same situation as before he called. I'm not sure how this would be different from the 'normal' operation of lingering incoming channels when we set manually_accept_channels
?
If we want to get rid of such stale request, we might generally need some kind of garbage collection for the state?
Also not entirely sure what 'force-close' would mean in this context? We'd probably just send an error over the wire and remove the channel from channel_state
?
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.
AFAICT, if the user calls the wrong method and the channel keeps 'lingering' in our channel_state, we would basically have the same situation as before he called. I'm not sure how this would be different from the 'normal' operation of lingering incoming channels when we set manually_accept_channels?
Correct, though its pretty different in that the user handled the OpenChannelRequest
event, they don't expect to have to handle it twice. In general, our users aren't going to manually handle an error - if we return an APIError
here, the users' code probably just won't do anything else. The counterparty, however, may be waiting for an error
to retry the channel open (this is the expected behavior for a channel_type
"negotiation").
We can (generally) assume that users will try to handle OpenChannelRequest
, my concern her is that they won't handle an error handling it.
If we want to get rid of such stale request, we might generally need some kind of garbage collection for the state?
Agreed - in general we should eventually time-out requests, but such requests may take some time to process (external API calls to third-party providers are not unlikely, I believe), so we have to be kinda conservative here, likely even too conservative for moving the channel_type
negotiation forward.
Also not entirely sure what 'force-close' would mean in this context? We'd probably just send an error over the wire and remove the channel from channel_state?
Yep, that. I generally use "force-close" to mean "send error message and close channel", though, indeed, there's no broadcast associated here.
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.
Alright, I now reject the channel in accept_inbound_channel
if it is 0conf. Also added a note explaining this behavior.
cfa656e
to
6ec1d0a
Compare
Squashed again. |
a28a5ae
to
efad02b
Compare
Feel free to squash again (or split the commits up a bit). |
Squashed. |
Closes #1502
This PR implements a
ZeroConf
channel type feature, which is then considered when we receive inbound open channel requests.Note that zero confirmation channels are rejected by default, and may only get manually accepted via
accept_inbound_channel_from_trusted_peer_0conf
.