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

Update channel-type implementation to upstream spec as merged #1314

Merged
merged 2 commits into from
Feb 18, 2022

Conversation

TheBlueMatt
Copy link
Collaborator

@TheBlueMatt TheBlueMatt commented Feb 16, 2022

Somehow, our channel type implementation doesn't echo back the
channel type as we believe it was negotiated, as we should. Though
the spec doesn't explicitly require this, some implementations may
and it appears to have been in the BOLTs from the start of the
channel type logic.

Somewhat of a bugfix so I'd like to land it ASAP.

Somehow, our channel type implementation doesn't echo back the
channel type as we believe it was negotiated, as we should. Though
the spec doesn't explicitly require this, some implementations may
require it and it appears to have been in the BOLTs from the start
of the channel type logic.
@TheBlueMatt TheBlueMatt added this to the 0.0.105 milestone Feb 16, 2022
Copy link

@ariard ariard left a comment

Choose a reason for hiding this comment

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

ACK 6d7ae6e

(If you think so you can take the suggestion about failing empty type when channel_type is already supported)

@@ -1895,6 +1895,16 @@ impl<Signer: Sign> Channel<Signer> {
return Err(ChannelError::Close("Minimum confirmation depth must be at least 1".to_owned()));
}

if let Some(ty) = &msg.channel_type {
if *ty != self.channel_type {
return Err(ChannelError::Close("Channel Type in accept_channel didn't match the one sent in open_channel.".to_owned()));
Copy link

Choose a reason for hiding this comment

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

I think the spec says in accept_channel subsection:

"The sender if it sets the channel_type MUST set it to the channel_type from open_channel".

I agree the "it" isn't clear though sounds the spec requirement to echo is already there.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I'd think it is pretty clearly (a) the sender, and (b) the channel_type, so technically I don't think we're in violation today, though we maybe should be.

Copy link

Choose a reason for hiding this comment

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

My point was the spec already mentions it. Contrary to what the commit message sounds to suggest "Though the spec doesn't explicitly require this" :p ?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

No, the spec very clearly does not explicitly require this - it says "IF [the sender] sets the channel_type"...then it must set it to a copy. The spec does not require the accept_channel sender to send a copy.

Copy link
Contributor

Choose a reason for hiding this comment

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

I'll add my unsolicited 2 cents, but my reading of this is exactly that: if accept_channel sets the channel type, clearly implying optionality, it must match the value from open_channel, but it definitely needn't be set.

if *ty != self.channel_type {
return Err(ChannelError::Close("Channel Type in accept_channel didn't match the one sent in open_channel.".to_owned()));
}
} else if their_features.supports_channel_type() {
Copy link

Choose a reason for hiding this comment

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

IIUC we might have a peer supporting channel type (feature bits 44/45) but not announcing any channel_type because they don't support any channel feature. What's the state of mainstream implementations, they all support static_key at least ?

Maybe we can implement the spec suggestion : "The receiving node MAY fail the channel if option_channel_type was negotiated but the message doesn't include a channel_type". That would be a first step deprecating channel type detection from Init message (and I think we can deprecate such logic once channel_type is well-deployed, as it's doesn't constrain to force-close alive channel such as when deprecating commitment format). Maybe too early.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

IIUC we might have a peer supporting channel type (feature bits 44/45) but not announcing any channel_type because they don't support any channel feature. What's the state of mainstream implementations, they all support static_key at least ?

No, the point of the feature bit is they have to announce a channel type field/TLV, though it can be empty.

The receiving node MAY fail the channel if option_channel_type was negotiated but the message doesn't include a channel_type".

Two things: a) this is about open_channel not accept_channel, and (b) that's how I had this PR initially, but that means new-LDK won't be able to accept a channel from current-LDK, which is not ideal.

@TheBlueMatt
Copy link
Collaborator Author

ACK 6d7ae6e

Note you need to do an official "github approve" to have it count now :/.

It seems the linting CI check is unrelated and because of a tokio MSRV bump (ugh why do people do this in minor versions...I hate the rust ecosystem):

error: could not compile tokio.

Copy link

@ariard ariard left a comment

Choose a reason for hiding this comment

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

ACK 6d7ae6e

Copy link

@ariard ariard left a comment

Choose a reason for hiding this comment

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

ACK 6d7ae6e

@@ -2174,11 +2184,11 @@ impl<Signer: Sign> Channel<Signer> {

/// Returns transaction if there is pending funding transaction that is yet to broadcast
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: "to be broadcast"

@arik-so arik-so merged commit e43cfe1 into lightningdevkit:main Feb 18, 2022
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.

3 participants