Skip to content

09+11: require transitive feature dependencies#719

Merged
cdecker merged 4 commits intolightning:masterfrom
cfromknecht:feature-deps
Jan 21, 2020
Merged

09+11: require transitive feature dependencies#719
cdecker merged 4 commits intolightning:masterfrom
cfromknecht:feature-deps

Conversation

@cfromknecht
Copy link
Collaborator

@cfromknecht cfromknecht commented Dec 16, 2019

This PR adds an additional column to our feature table in BOLT 09, enumerating any dependencies that a feature pair has. At the moment, there are 3 such pairs that have dependencies, and more will be added in the near term. The motivation is to offer a concise way to describe these relations, and also simplify how we specify behavior gated by features with dependencies.

Consider the basic_mpp feature, which (as of #712) depends on payment_secret and transitively depends on var_onion_optin. Instead of specifying (or coding) has(basic_mpp) && has(payment_secret) && has(var_onion_optin) everywhere we need to gate basic_mpp, this allows us to isolate the gate to only basic_mpp since the transitive requirements are assumed to be already validated..

An implementation of this validation can be found here: https://github.com/lightningnetwork/lnd/blob/master/feature/deps.go which we are currently using as we build out MPP to simplify our own logic.

The test vectors have also been updated to set the var_onion_optin feature when setting a payment secret, as @t-bast points out, the current ones are missing this bit to be fully aligned with the existing spec.

Copy link
Collaborator

@t-bast t-bast left a comment

Choose a reason for hiding this comment

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

LGTM, thanks!

01-messaging.md Outdated
- MUST ignore the bit.
- upon receiving unknown _even_ feature bits that are non-zero:
- MUST fail the connection.
- MUST validate all known, transitive feature dependencies.
Copy link
Collaborator

Choose a reason for hiding this comment

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

MUST validate doesn't mean anything - should I disconnect? Should I ignore the message? Should I....

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

oops, forgot the most important part, thanks! both have been updated

- MUST set `var_onion_optin` if and only if it supports that feature.

A reader:
- MUST validate all known, transitive feature dependencies before paying.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Same here.

@cdecker cdecker removed the Meeting Discussion Raise at next meeting label Jan 6, 2020
Copy link
Collaborator

@t-bast t-bast left a comment

Choose a reason for hiding this comment

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

ACK 06bc5e3

Copy link
Collaborator

@t-bast t-bast left a comment

Choose a reason for hiding this comment

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

LGTM

@cfromknecht cfromknecht force-pushed the feature-deps branch 8 times, most recently from 6b51059 to b9892d0 Compare January 16, 2020 00:24
Copy link
Collaborator

@t-bast t-bast left a comment

Choose a reason for hiding this comment

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

LGTM, and reducing spec size is always a win ;)

Copy link
Collaborator

@t-bast t-bast left a comment

Choose a reason for hiding this comment

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

Thanks @cfromknecht, ACK 65291f8

@t-bast t-bast added the Meeting Discussion Raise at next meeting label Jan 17, 2020
This commit:
 - Adds a new Dependencies column to the BOLT 9 feature table
   populated with existing feature dependencies.
 - Requires that all valid feature vectors set transitive dependencies.
 - Requires checking transitive dependencies when validating init
   messages and payment request.
 - Removes transitive feature requiremetns from the BOLT 11 writer, now
   that they are implicit by needing to comply with the BOLT 9 origin
   requirements.
As a final step, we now can remove several of the BOLT 11 writer's
requirements now that it builds on BOLT 9's, particularly:
 - setting the even bit if a feature is required.
 - only setting a feature if the node supports a given feature.

The lone requirement that remains pertains to setting the `s` value if
and only if the `payment_secret` feature is set.
@cdecker
Copy link
Collaborator

cdecker commented Jan 21, 2020

Merging following the spec meeting on 2020/01/20

@cdecker cdecker merged commit c3a8e5e into lightning:master Jan 21, 2020
SomberNight added a commit to SomberNight/electrum that referenced this pull request Mar 16, 2020
SomberNight added a commit to SomberNight/electrum that referenced this pull request Mar 17, 2020
SomberNight added a commit to SomberNight/electrum that referenced this pull request Mar 17, 2020
SomberNight added a commit to SomberNight/electrum that referenced this pull request Mar 24, 2020
SomberNight added a commit to SomberNight/electrum that referenced this pull request Apr 1, 2020
sidhujag pushed a commit to syscoin/electrumsys that referenced this pull request Apr 2, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Meeting Discussion Raise at next meeting

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants