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

lnwire+funding: introduce new protocol extension for explicit channel type negotiation #5071

Closed
wants to merge 8 commits into from

Conversation

Roasbeef
Copy link
Member

@Roasbeef Roasbeef commented Mar 4, 2021

In this PR, we put forth a draft implementation of explicit channel type negotiation. Explicit channel type negotiation prepares us for a future where no "default" channel type actually exists. Compared to implicit channel type negotiation, rather than using a set of overlapping feature bits to determine which channel type is being used during funding negotiation, we instead have both sides signal what their desired channel type is to be. This preps us for a future of dynamic commitments as the same channel type reference will be used to change the commitment type in-flight. Additionally, moving to an explicit channel type negotiation gives us a better way to remove unsupported channel types, as we'd simply stop advertising the optional feature bit and reject all attempts to us that channel type.

This PR is still in the draft phase as it's missing a few things including:

  • Funding manager level unit tests for the new negotiation/rejection
  • Rejection based on absence of channel type feature bits
  • Modification of the existing "downgrade" feature bit logic in the peer

In this commit, we add a new TLV record that's intended to be used as an
explicit channel type for a new form of funding negotiation, and later
on a dynamic commitment upgrade protocol. As defined, we have 3 channel
types: base (the OG), tweakless, and anchors w/ zero fee HTLCs. We omit
the original variant of anchors as it was never truly deployed from the
PoV of lnd.
In this commit, we add a new ChannelType field as a new TLV record to
the open and accept channel messages. During this change, we make a few
tweaks to the generic TLV encode/decode methods for the ExtraOpaqueData
struct to have it work on the level of tlv.RecordProducer instead of
tlv.Record, as this reduces line noise a bit.

We also partially undo existing logic that would attempt to "prepend"
any new TLV records to the end of the ExtraOpaqueData if one was already
present within the struct. This is based on the assumption that if we've
read a message from disk to order to re-send/transmit it, then the
ExtraOpaqueData is fully populated so we'll write that as is. Otherwise,
a message is being encoded for the first time, and we expect all fields
that are known TLV fields to be specified within the struct itself.

This change required the unit tests to be modified slightly, as we'll
always encode a fresh set of TLV records if none was already specified
within the struct.
…thods

We now use their generic variants in place.
If these bits are present, then both sides can examine the new
ChannelType TLV field that's present and use this in place of the
existing implicit channel type negotiation. With this change, it's now
possible to actually deprecate old unsupported channel types properly.
This field will be examined later down the stack along with the set of
feature bits to determine if explicit channel type negotiation is
possible or not.
In this commit, we modify the existing logic that defaults to implicit
channel type negotiation to support explicit negotiation if the new
feature bit is set. This change allows us to ditch the notion of a
"default" channel type, as we'll now use feature bits to signal our
understanding of a channel type, but allow peers to select which channel
type they actually wish to use.

In addition, this explicit negotiation removes the need for using the
required bit of any channel types. Instead, if an implementation wishes
to no longer support a channel type, they should simply stop advertising
the optional bit. We also remove the need to "downgrade" our feature
bits if we have an old channel type with that peer, as we'll simply
reject the legacy channel type if they attempt to use it.
@Roasbeef Roasbeef added wire protocol Encoding of messages for the communication between nodes funding Related to the opening of new channels with funding transactions on the blockchain commitments Commitment transactions containing the state of the channel channels channel management The management of the nodes channels labels Mar 4, 2021
@wpaulino
Copy link
Contributor

Closing in favor of #5373.

@wpaulino wpaulino closed this Jun 10, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
channel management The management of the nodes channels channels commitments Commitment transactions containing the state of the channel funding Related to the opening of new channels with funding transactions on the blockchain wire protocol Encoding of messages for the communication between nodes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants