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 commitment type negotiation #5669

Merged
merged 11 commits into from
Sep 1, 2021

Conversation

Roasbeef
Copy link
Member

Replaces #5373 (just rebased on top of master).

@Roasbeef
Copy link
Member Author

Just need to fix one of the commits re a change in the feature bit types.

@Roasbeef Roasbeef force-pushed the explicit-chan-type branch 2 times, most recently from 6f4684d to 7c9ec3a Compare August 30, 2021 22:59
Roasbeef and others added 11 commits August 30, 2021 19:17
In this commit, we add a new TLV record that's intended to be used as an
explicit channel commitment 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 OpenChannel message. 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.
If these bits are present, then both sides can examine the new
CommitmentType TLV field that's present and use this in place of the
existing implicit commiment type negotiation. With this change, it's now
possible to actually deprecate old unsupported commitment types
properly.
This field will be examined later down the stack along with the set of
feature bits to determine if explicit channel commitment type
negotiation is possible or not.
This commit adds the ability for a channel initiator/responder to
determine whether the channel to be opened can use a specific commitment
type through explicit negotiation. It also includes the existing
implicit negotiation logic to fall back on if explicit negotiation is
not supported.
In this commit, we modify the existing logic that defaults to implicit
commitment type negotiation to support explicit negotiation if the new
feature bit is set. This change allows us to ditch the notion of a
"default" commitment type, as we'll now use feature bits to signal our
understanding of a commiment type, but allow peers to select which
commitment type they actually wish to use.

In addition, this explicit negotiation removes the need for using the
required bit of any commitment types. Instead, if an implementation
wishes to no longer support a commitment type, they should simply stop
advertising the optional bit.
@Roasbeef Roasbeef force-pushed the explicit-chan-type branch from 7c9ec3a to 61a0112 Compare August 31, 2021 02:18
@Roasbeef
Copy link
Member Author

Roasbeef commented Sep 1, 2021

PR retains its approvals from #5373, gonna land this now (with our temp feature bit until an official one is selected) so we can continue to rebase+land the dependent PRs.

@Roasbeef Roasbeef merged commit d263a01 into lightningnetwork:master Sep 1, 2021
@alexbosworth
Copy link
Contributor

Can the proto be made to be consistent with the previous proto? Like server signal 2 always means anchors and not sometimes static remote key when talking to a prior version LND?

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