Skip to content

Introduce new commitment format to enforce channel lease expirations in scripts#5709

Merged
Roasbeef merged 18 commits intolightningnetwork:masterfrom
Roasbeef:lease-script-enforce
Oct 21, 2021
Merged

Introduce new commitment format to enforce channel lease expirations in scripts#5709
Roasbeef merged 18 commits intolightningnetwork:masterfrom
Roasbeef:lease-script-enforce

Conversation

@Roasbeef
Copy link
Member

Replaces #5549

See PR body there

@Roasbeef Roasbeef added this to the v0.14.0 milestone Sep 11, 2021
@orijbot
Copy link

orijbot commented Sep 11, 2021

@Roasbeef
Copy link
Member Author

Rebased again, itests got borked during the original rebase, looking into the failure, prob a stray guard based on the new commitment types somewhere.

The new commitment type consists of adding an additional CLTV
requirement to guarantee a leased channel's expiration on any commitment
and HTLC outputs that pay directly to the channel initiator.
This witness generators and weight estimates added only apply for the
new script-enforced leased channel commitment type.
This commit modifies the channel state machine to be able to derive the
proper commitment and second-level HTLC output scripts required by the
new script-enforced leased channel commitment type.
In order to sweep the commitment and HTLC outputs belonging to a
script-enforced leased channel, each resolver must know whether the
additional CLTV clause on the channel initiator applies to them. To do
so, we retrieve the historical channel state stored within the database
and supplement it to the resolvers to provide them with what's needed in
order to sweep the necessary outputs and resolve their respective
contracts.
This aims to cover an edge case and also serves as an optimization of
what happens when an input that was offered to the Sweeper with an
exclusive group is re-offered without one. This happens every time we
attempt to sweep the different possible anchors of a channel at the time
of broadcast, as we don't know which commitment transaction will end up
confirming in the chain. Once the commitment transaction confirms
however, we know which anchor output to act upon and re-offer it to the
Sweeper without an exclusive group. At this point, the Sweeper will
continue to attempt sweeping the other anchor output versions even know
we know they are not valid.
We update several of our integration tests that exercise different
scenarios with regards to the broadcast of a channel commitment
transaction with HTLCs in-flight to use the new commitment type for
channel leases. We do this to ensure we have complete coverage of said
channel commitment type. This required changing several assumptions
throughout the tests based on when we should expect sweeps to happen.
@Roasbeef Roasbeef force-pushed the lease-script-enforce branch from 70e2d5a to 08d93fd Compare October 20, 2021 01:35
@Roasbeef
Copy link
Member Author

Rebased once again! Found an issue in the OG rebase thanks to @guggero

@Roasbeef Roasbeef merged commit 7f656a2 into lightningnetwork:master Oct 21, 2021
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