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

Remove OptionalField and make DataLossProtect fields mandatory #2253

Merged

Conversation

dunxen
Copy link
Contributor

@dunxen dunxen commented May 1, 2023

As per lightning/bolts@6656b70, we do three main things here:

  1. Make DataLossProtect fields required and move them directly into ChannelReestablish.
    These fields have been made mandatory regardless of whether option_dataloss_protect or
    option_remote_key feature bits are set.

  2. Move shutdown_scriptpubkey into TLV stream.
    We can move the shutdown_scriptpubkey field into the TLV streams of OpenChannel and
    AcceptChannel without affecting the resulting encoding as per the BOLT commit linked above.

  3. Remove OptionalField entirely as it is obsolete.

Blocks #1794

The fields provided by `DataLossProtect` have been mandatory since
lightning/bolts@6656b70, regardless
of whether `option_dataloss_protect` or `option_remote_key` feature bits
are set.

We move the fields out of `DataLossProtect` to make encoding definitions
more succinct with `impl_writeable_msg!` and to reduce boilerplate.

This paves the way for completely removing `OptionalField` in subsequent
commits.
@dunxen
Copy link
Contributor Author

dunxen commented May 1, 2023

Oops. Broke taproot cfgs along the way. Will fix.

@wpaulino wpaulino self-requested a review May 2, 2023 00:17
As pointed out in lightning/bolts@6656b70,
we can move the `shutdown_scriptpubkey` field into the TLV streams of
`OpenChannel` and `AcceptChannel` without affecting the resulting encoding.

We use `WithoutLength` encoding here to ensure that we do not encode a
length prefix along with `Script` as is normally the case.
@dunxen dunxen force-pushed the 2023-05-removeoptionalfield branch from 64aa89c to 20cd856 Compare May 2, 2023 08:25
@codecov-commenter
Copy link

codecov-commenter commented May 2, 2023

Codecov Report

Patch coverage: 70.37% and project coverage change: +0.45 🎉

Comparison is base (0e8da58) 91.59% compared to head (f0b3961) 92.05%.

📣 This organization is not using Codecov’s GitHub App Integration. We recommend you install it so Codecov can continue to function properly for your repositories. Learn more

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2253      +/-   ##
==========================================
+ Coverage   91.59%   92.05%   +0.45%     
==========================================
  Files         104      104              
  Lines       51976    55468    +3492     
  Branches    51976    55468    +3492     
==========================================
+ Hits        47609    51062    +3453     
- Misses       4367     4406      +39     
Impacted Files Coverage Δ
lightning/src/util/ser.rs 88.44% <28.57%> (-0.75%) ⬇️
lightning/src/ln/channel.rs 92.87% <71.42%> (+2.85%) ⬆️
lightning/src/ln/msgs.rs 88.71% <75.00%> (+1.55%) ⬆️
lightning/src/ln/channelmanager.rs 91.66% <100.00%> (+2.86%) ⬆️
lightning/src/ln/features.rs 98.45% <100.00%> (ø)
lightning/src/ln/shutdown_tests.rs 98.05% <100.00%> (ø)
lightning/src/util/ser_macros.rs 92.50% <100.00%> (ø)

... and 4 files with indirect coverage changes

☔ View full report in Codecov by Sentry.
📢 Do you have feedback about the report comment? Let us know in this issue.

@TheBlueMatt
Copy link
Collaborator

We need to update the channelmanager feature set to set data_loss_protect_required, otherwise LGTM.

@TheBlueMatt TheBlueMatt merged commit b0d37ed into lightningdevkit:main May 2, 2023
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.

4 participants