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

Explicit channel type in channel open #1867

Merged
merged 3 commits into from
Aug 31, 2021
Merged

Explicit channel type in channel open #1867

merged 3 commits into from
Aug 31, 2021

Conversation

t-bast
Copy link
Member

@t-bast t-bast commented Jul 7, 2021

Add support for lightning/bolts#880

This lets node operators open a channel with different features than what the implicit choice based on activated features would use.

This has been tested successfully against lightningnetwork/lnd#5373

Copy link
Member

@pm47 pm47 left a comment

Choose a reason for hiding this comment

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

This is a first pass, let me know if you like where it's going before I dig deeper.

stay() using d.copy(channels = d.channels + (TemporaryChannelId(temporaryChannelId) -> channel))
val defaultChannelType = ChannelTypes.pickChannelType(d.localFeatures, d.remoteFeatures)
val chosenChannelType: Either[InvalidChannelType, SupportedChannelType] = msg.channelType_opt match {
case None => Right(defaultChannelType)
Copy link
Member

Choose a reason for hiding this comment

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

Does this mean that we'll add a channel_type to our accept message even there was none in our peer's open message ? If so it looks like a spec violation ?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, we always send back a channel_type. It's not a spec violation, the only thing the spec requires is:

  - if it sets `channel_type`:
    - MUST set it to the `channel_type` from `open_channel`

If it wasn't set in open_channel, we're free to do what we want, and it's an odd message type so it's always ok to include.

Copy link
Member

Choose a reason for hiding this comment

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

But then it will be ignored, so what is the point ?

Copy link
Member

Choose a reason for hiding this comment

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

It doesn't hurt, is future proof, and we don't have to manage an option?

Copy link
Member

Choose a reason for hiding this comment

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

Also, it can be viewed as "FYI I'll be using that channel type"?

Copy link
Member Author

Choose a reason for hiding this comment

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

Exactly, it's simpler in the flow to always use channel_types internally, because otherwise you can't as easily distinguish in this piece of code the case where no channel type was sent and the case where an invalid one was sent (it would need a bit more code).

Copy link
Member

Choose a reason for hiding this comment

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

I guess that what bothered me is that it's not "symmetric" (we set it but they did not) but it does work.

Copy link
Member

@pm47 pm47 left a comment

Choose a reason for hiding this comment

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

I've put some test improvements on branch https://github.com/ACINQ/eclair/tree/channel-types-pm.

pm47
pm47 previously approved these changes Aug 24, 2021
Copy link
Member

@pm47 pm47 left a comment

Choose a reason for hiding this comment

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

LGTM

@codecov-commenter
Copy link

Codecov Report

Merging #1867 (806d277) into master (49e1996) will increase coverage by 0.10%.
The diff coverage is 98.11%.

@@            Coverage Diff             @@
##           master    #1867      +/-   ##
==========================================
+ Coverage   87.52%   87.62%   +0.10%     
==========================================
  Files         159      159              
  Lines       12104    12157      +53     
  Branches      502      483      -19     
==========================================
+ Hits        10594    10653      +59     
+ Misses       1510     1504       -6     
Impacted Files Coverage Δ
...r-core/src/main/scala/fr/acinq/eclair/Eclair.scala 53.06% <ø> (ø)
...in/scala/fr/acinq/eclair/channel/ChannelData.scala 100.00% <ø> (ø)
...in/scala/fr/acinq/eclair/channel/Commitments.scala 93.89% <87.50%> (+0.02%) ⬆️
...cala/fr/acinq/eclair/channel/ChannelFeatures.scala 97.05% <96.42%> (-2.95%) ⬇️
.../fr/acinq/eclair/blockchain/fee/FeeEstimator.scala 100.00% <100.00%> (ø)
...c/main/scala/fr/acinq/eclair/channel/Channel.scala 86.30% <100.00%> (+0.18%) ⬆️
...c/main/scala/fr/acinq/eclair/channel/Helpers.scala 96.14% <100.00%> (+0.07%) ⬆️
...-core/src/main/scala/fr/acinq/eclair/io/Peer.scala 90.04% <100.00%> (+0.46%) ⬆️
...ala/fr/acinq/eclair/wire/protocol/ChannelTlv.scala 100.00% <100.00%> (ø)
...q/eclair/wire/protocol/LightningMessageTypes.scala 96.66% <100.00%> (+0.23%) ⬆️
... and 8 more

t-bast added 3 commits August 25, 2021 14:14
Add support for lightning/bolts#880

This lets node operators open a channel with different features than what
the implicit choice based on activated features would use.
* ChannelType contains a set of features
* TLV doesn't expose the feature bits directly
* An unsupported channel type class is explicitly added
@t-bast t-bast merged commit 59ccf34 into master Aug 31, 2021
@t-bast t-bast deleted the channel-types branch August 31, 2021 07:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants