Skip to content

Zero-fee commitments using v3 transactions (feature 40/41) #1228

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

Draft
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

t-bast
Copy link
Collaborator

@t-bast t-bast commented Feb 14, 2025

We introduce a new channel_type that leverages v3 transactions, pay-to-anchor outputs and ephemeral dust. With this change, commitment transactions don't pay any mining fee, which gets rid of update_fee and all of the related channel reserve issues. It also gets rid of the undesired channel force-closes that happen when the mempool feerate spikes and channel participants disagree on what feerate to use, which has been a major source of wasted on-chain space.

It also offers better protection against pinning attacks (thanks to package relay) and reduces the on-chain footprint compared to anchor output channels. We use a single anchor output whose amount is the sum of all trimmed outputs (and may thus be 0 sat). We remove the 1-block relative delay used by anchor output channels: this allows using our channel outputs (main balance or pending HTLCs) to CPFP a remote commitment transaction (no need to add external inputs).

v3 transactions and pay-to-anchor outputs have been standard since the release of Bitcoin Core v28.0. Ephemeral dust will become standard in the Bitcoin Core v29.0 release.

TODO:

  • add Bolt 3 test vectors for this new commitment format
  • verify v3 transaction limits and the maximum number of allowed HTLCs

We introduce a new `channel_type` that leverages v3 transactions,
pay-to-anchor outputs and ephemeral dust. With this change, commitment
transactions don't pay any mining fee, which gets rid of `update_fee`
and all of the related channel reserve issues. It also gets rid of the
undesired channel force-closes that happen when the mempool feerate
spikes and channel participants disagree on what feerate to use, which
has been a major source of wasted on-chain space.

It also offers better protection against pinning attacks and reduces the
on-chain footprint compared to anchor output channels. We use a single
anchor output whose amount is the sum of all trimmed outputs (and may
thus be `0 sat`). We remove the 1-block relative delay used by anchor
output channels: this allows using our channel outputs (main balance or
pending HTLCs) to CPFP a remote commitment transaction (no need to add
external inputs).

v3 transactions and pay-to-anchor outputs have been standard since the
release of Bitcoin Core v28.0. Ephemeral dust will become standard in
the Bitcoin Core v29.0 release.
@saubyk
Copy link

saubyk commented Feb 17, 2025

We use a single anchor output whose amount is the sum of all trimmed outputs (and may thus be 0 sat).

Hi @t-bast can you elaborate this a bit?

@saubyk
Copy link

saubyk commented Feb 17, 2025

We use a single anchor output whose amount is the sum of all trimmed outputs (and may thus be 0 sat).

Hi @t-bast can you elaborate this a bit?

Never mind. This delving post has the details, makes for a good supplemental reading:
https://delvingbitcoin.org/t/which-ephemeral-anchor-script-should-lightning-use/1412

@t-bast
Copy link
Collaborator Author

t-bast commented Feb 19, 2025

Hi @t-bast can you elaborate this a bit?

This will become more obvious when I add the test vectors! It is also already defined in Bolt 3, if the paragraph for this is unclear please put a comment on it with a suggestion on how I could make it clearer.

Copy link
Contributor

@morehouse morehouse left a comment

Choose a reason for hiding this comment

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

Approach ACK.

Really eager to see this get implemented and used across the network. Also hope we can follow up soon with the changes needed to fix HTLC pinning.

Copy link
Collaborator

@TheBlueMatt TheBlueMatt left a comment

Choose a reason for hiding this comment

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

This was actually a good bit easier to implement than I thought.

We cap the amount of the `shared_anchor` to its dust limit of 240 sats
to ensure that only miners can collect the excess from trimmed outputs.

We cannot keep the `shared_anchor` amount at 0 sats all the time: when
the commitment transaction includes some mining fees (because outputs
are trimmed) it is forbidden by `bitcoind`'s default policy to have a
0-value output, otherwise we those outputs would pollute the utxo set
because nobody would ever spend them if the transaction confirms on its
own.
HTLC transactions don't benefit from the wider network's anonymity set,
so we can stick to `0` as we did previously.
@tnull
Copy link
Contributor

tnull commented May 6, 2025

Just want to node that it was discussed in yesterday's spec call that as part of this work we'll probably also want to make option_simple_close transactions (optionally) v3, i.e., require v3 close transactions for v3 channels.

@Roasbeef
Copy link
Collaborator

Roasbeef commented May 7, 2025

Just want to node that it was discussed in yesterday's spec call that as part of this work we'll probably also want to make option_simple_close transactions (optionally) v3, i.e., require v3 close transactions for v3 channels.

Compared to the HTLC case, are there any pinning concerns when it comes to coop close? The channel is no longer active, and the only outputs on the coop close transaction send funds directly to either party.

I point this out as the TRUC constraints are passed on to all unconfirmed children:

Any TRUC transaction's unconfirmed ancestors must all be TRUC

As a result, if the coop close transaction is v3, then a user wouldn't be able to CPFP with a non-v3 transaction to bump the fee (imagine the peer is just no longer offline). Another scenario that would be prevented is a non-v3 aware wallet spending that unconfirmed change to create a normal transaction, or fund a new channel.

@t-bast
Copy link
Collaborator Author

t-bast commented May 12, 2025

Compared to the HTLC case, are there any pinning concerns when it comes to coop close?

I don't think there are any, once we start using v3 for the commit tx and mutual close tx, the mutual close tx should be protected against pinning.

The "legacy" anchor outputs are always taken from the funder's main
output. Thanks @carlaKC for spotting this!
OP_1 <0x4e73>

The amount of this output is usually 0 sats, in which case it must be spent by the child transaction paying the mining fees.
When the commitment contains [trimmed outputs](#trimmed-outputs), their amount is added to this `shared_anchor` output until it reaches 240 sats.
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: I think it would be helpful to make a note here explaining why need to switch between the anchor and fees

  • Ephemeral dust requires zero fees for values <= dust limit to be standard
  • The dust limit for P2A is 240

Perhaps link to this issue: bitcoin/bitcoin#31938 (helped me understand it better)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Good idea!

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.

10 participants