Skip to content

Commit 6a832c5

Browse files
committed
Zero-fee commitments using v3 transactions
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`), capped at 240 sats. When the sum of trimmed outputs exceeds 240 sats, the remaining amount directly goes to on-chain fees (and in that case, the commitment transactions does pay some on-chain fees on its own). We do this to ensure that only miners can collect the excess from trimmed outputs, while respecting standardness rules. We remove the 1-block relative delay used by anchor output channels, because we don't need the CPFP carve-out rule when using v3 txs. 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 has been standard since the Bitcoin Core v29.0 release.
1 parent fae5fcc commit 6a832c5

File tree

4 files changed

+208
-121
lines changed

4 files changed

+208
-121
lines changed

02-peer-protocol.md

Lines changed: 59 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -609,7 +609,6 @@ the `channel_ready` message, the channel is established and can begin
609609
normal operation. The `channel_ready` message includes information
610610
that will be used to construct channel authentication proofs.
611611

612-
613612
+-------+ +-------+
614613
| |--(1)--- open_channel ----->| |
615614
| |<-(2)-- accept_channel -----| |
@@ -745,6 +744,7 @@ affect the channel operation).
745744
The currently defined basic types are:
746745
- `option_static_remotekey` (bit 12)
747746
- `option_anchors` and `option_static_remotekey` (bits 22 and 12)
747+
- `zero_fee_commitments` (bit 40)
748748

749749
Each basic type has the following variations allowed:
750750
- `option_scid_alias` (bit 46)
@@ -774,14 +774,19 @@ The sending node:
774774
- MUST set it to a defined type representing the type it wants.
775775
- MUST use the smallest bitmap possible to represent the channel type.
776776
- SHOULD NOT set it to a type containing a feature which was not negotiated.
777+
- if `channel_type` includes `zero_fee_commitments`:
778+
- MUST set `feerate_per_kw` to `0`.
777779
- if `announce_channel` is `true` (not `0`):
778780
- MUST NOT send `channel_type` with the `option_scid_alias` bit set.
779781

780782
The sending node SHOULD:
781783
- set `to_self_delay` sufficient to ensure the sender can irreversibly spend a commitment transaction output, in case of misbehavior by the receiver.
782-
- set `feerate_per_kw` to at least the rate it estimates would cause the transaction to be immediately included in a block.
783-
- set `dust_limit_satoshis` to a sufficient value to allow commitment transactions to propagate through the Bitcoin network.
784784
- set `htlc_minimum_msat` to the minimum value HTLC it's willing to accept from this peer.
785+
- when using `zero_fee_commitments` or `option_anchors`:
786+
- set `dust_limit_satoshis` to a sufficient value to ensure that it is economical to spend, taking the cost of HTLC transactions into account.
787+
- otherwise (not using `zero_fee_commitments` or `option_anchors`):
788+
- set `feerate_per_kw` to at least the rate it estimates would cause the transaction to be immediately included in a block.
789+
- set `dust_limit_satoshis` to a sufficient value to allow commitment transactions to propagate through the Bitcoin network.
785790

786791
The receiving node MUST:
787792
- ignore undefined bits in `channel_flags`.
@@ -807,8 +812,12 @@ The receiving node MUST fail the channel if:
807812
- the `chain_hash` value is set to a hash of a chain that is unknown to the receiver.
808813
- `push_msat` is greater than `funding_satoshis` * 1000.
809814
- `to_self_delay` is unreasonably large.
810-
- `max_accepted_htlcs` is greater than 483.
811-
- it considers `feerate_per_kw` too small for timely processing or unreasonably large.
815+
- `channel_type` includes `zero_fee_commitments` and:
816+
- `max_accepted_htlcs` is greater than 114.
817+
- `feerate_per_kw` is not `0`.
818+
- `channel_type` does not include `zero_fee_commitments` and:
819+
- `max_accepted_htlcs` is greater than 483.
820+
- it considers `feerate_per_kw` too small for timely processing or unreasonably large.
812821
- `funding_pubkey`, `revocation_basepoint`, `htlc_basepoint`, `payment_basepoint`, or `delayed_payment_basepoint`
813822
are not valid secp256k1 pubkeys in compressed format.
814823
- `dust_limit_satoshis` is greater than `channel_reserve_satoshis`.
@@ -1161,6 +1170,8 @@ If nodes have negotiated `option_dual_fund`:
11611170
The sending node:
11621171
- MUST set `channel_type`
11631172
- MUST set `funding_feerate_perkw` to the feerate for this transaction
1173+
- if `channel_type` includes `zero_fee_commitments`:
1174+
- MUST set `commitment_feerate_perkw` to `0`.
11641175
- If it requires the receiving node to only use confirmed inputs:
11651176
- MUST set `require_confirmed_inputs`
11661177

@@ -1169,6 +1180,7 @@ The receiving node:
11691180
- the `locktime` is unacceptable
11701181
- the `funding_feerate_perkw` is unacceptable
11711182
- MUST fail the negotiation if:
1183+
- `channel_type` includes `zero_fee_commitments` and `commitment_feerate_perkw` is not `0`.
11721184
- `require_confirmed_inputs` is set but it cannot provide confirmed inputs
11731185
- `channel_type` is not set
11741186

@@ -2208,9 +2220,9 @@ A node:
22082220
The `max_dust_htlc_exposure_msat` is an upper bound on the trimmed balance from
22092221
dust exposure. The exact value used is a matter of node policy.
22102222

2211-
For channels that don't use `option_anchors`, an increase of
2212-
the `feerate_per_kw` may trim multiple htlcs from commitment transactions,
2213-
which could create a large increase in dust exposure.
2223+
For channels that don't use `zero_fee_commitments` or `option_anchors`, an
2224+
increase of the `feerate_per_kw` may trim multiple htlcs from commitment
2225+
transactions, which could create a large increase in dust exposure.
22142226

22152227
### Adding an HTLC: `update_add_htlc`
22162228

@@ -2241,26 +2253,27 @@ is destined, is described in [BOLT #4](04-onion-routing.md).
22412253
#### Requirements
22422254

22432255
A sending node:
2244-
- if it is _responsible_ for paying the Bitcoin fee:
2245-
- MUST NOT offer `amount_msat` if, after adding that HTLC to its commitment
2246-
transaction, it cannot pay the fee for either the local or remote commitment
2247-
transaction at the current `feerate_per_kw` while maintaining its channel
2248-
reserve (see [Updating Fees](#updating-fees-update_fee)).
2249-
- if `option_anchors` applies to this commitment transaction and the sending
2250-
node is the funder:
2251-
- MUST be able to additionally pay for `to_local_anchor` and
2252-
`to_remote_anchor` above its reserve.
2253-
- SHOULD NOT offer `amount_msat` if, after adding that HTLC to its commitment
2254-
transaction, its remaining balance doesn't allow it to pay the commitment
2255-
transaction fee when receiving or sending a future additional non-dust HTLC
2256-
while maintaining its channel reserve. It is recommended that this "fee spike
2257-
buffer" can handle twice the current `feerate_per_kw` to ensure predictability
2258-
between implementations.
2259-
- if it is _not responsible_ for paying the Bitcoin fee:
2260-
- SHOULD NOT offer `amount_msat` if, once the remote node adds that HTLC to
2261-
its commitment transaction, it cannot pay the fee for the updated local or
2262-
remote transaction at the current `feerate_per_kw` while maintaining its
2263-
channel reserve.
2256+
- if `zero_fees_commitments` has not been negotiated:
2257+
- if it is _responsible_ for paying the Bitcoin fee:
2258+
- MUST NOT offer `amount_msat` if, after adding that HTLC to its commitment
2259+
transaction, it cannot pay the fee for either the local or remote commitment
2260+
transaction at the current `feerate_per_kw` while maintaining its channel
2261+
reserve (see [Updating Fees](#updating-fees-update_fee)).
2262+
- if `option_anchors` applies to this commitment transaction and the sending
2263+
node is the funder:
2264+
- MUST be able to additionally pay for `to_local_anchor` and
2265+
`to_remote_anchor` above its reserve.
2266+
- SHOULD NOT offer `amount_msat` if, after adding that HTLC to its commitment
2267+
transaction, its remaining balance doesn't allow it to pay the commitment
2268+
transaction fee when receiving or sending a future additional non-dust HTLC
2269+
while maintaining its channel reserve. It is recommended that this "fee spike
2270+
buffer" can handle twice the current `feerate_per_kw` to ensure predictability
2271+
between implementations.
2272+
- if it is _not responsible_ for paying the Bitcoin fee:
2273+
- SHOULD NOT offer `amount_msat` if, once the remote node adds that HTLC to
2274+
its commitment transaction, it cannot pay the fee for the updated local or
2275+
remote transaction at the current `feerate_per_kw` while maintaining its
2276+
channel reserve.
22642277
- MUST offer `amount_msat` greater than 0.
22652278
- MUST NOT offer `amount_msat` below the receiving node's `htlc_minimum_msat`
22662279
- MUST set `cltv_expiry` less than 500000000.
@@ -2329,12 +2342,16 @@ sides send the maximum number of HTLCs, the `commitment_signed` message will
23292342
still be under the maximum message size. It also ensures that
23302343
a single penalty transaction can spend the entire commitment transaction,
23312344
as calculated in [BOLT #5](05-onchain.md#penalty-transaction-weight-calculation).
2345+
When using `zero_fee_commitments`, we further limit `max_accepted_htlcs` to
2346+
114 because v3 transactions are limited to 10kvB, which decreases the number
2347+
of outputs the commitment transaction can have.
23322348

23332349
`cltv_expiry` values equal to or greater than 500000000 would indicate a time in
23342350
seconds, and the protocol only supports an expiry in blocks.
23352351

2336-
The node _responsible_ for paying the Bitcoin fee should maintain a "fee
2337-
spike buffer" on top of its reserve to accommodate a future fee increase.
2352+
When `zero_fee_commitments` is not used, the node _responsible_ for paying
2353+
the Bitcoin fee should maintain a "fee spike buffer" on top of its reserve
2354+
to accommodate a future fee increase.
23382355
Without this buffer, the node _responsible_ for paying the Bitcoin fee may
23392356
reach a state where it is unable to send or receive any non-dust HTLC while
23402357
maintaining its channel reserve (because of the increased weight of the
@@ -2504,9 +2521,6 @@ the case of offered HTLCs being timed out or received HTLCs being spent. This
25042521
is done to reduce fees by creating smaller scripts compared to explicitly
25052522
stating time-locks on HTLC outputs.
25062523

2507-
The `option_anchors` allows HTLC transactions to "bring their own fees" by
2508-
attaching other inputs and outputs, hence the modified signature flags.
2509-
25102524
### Completing the Transition to the Updated State: `revoke_and_ack`
25112525

25122526
Once the recipient of `commitment_signed` checks the signature and knows
@@ -2551,8 +2565,9 @@ A node:
25512565

25522566
### Updating Fees: `update_fee`
25532567

2554-
An `update_fee` message is sent by the node which is paying the
2555-
Bitcoin fee. Like any update, it's first committed to the receiver's
2568+
For channels that don't use `zero_fee_commitments`, an `update_fee`
2569+
message is sent by the node which is paying the Bitcoin fee.
2570+
Like any update, it's first committed to the receiver's
25562571
commitment transaction and then (once acknowledged) committed to the
25572572
sender's. Unlike an HTLC, `update_fee` is never closed but simply
25582573
replaced.
@@ -2573,6 +2588,9 @@ given in [BOLT #3](03-transactions.md#fee-calculation).
25732588

25742589
#### Requirements
25752590

2591+
When using `zero_fee_commitments`, nodes:
2592+
- MUST NOT send `update_fee`.
2593+
25762594
The node _responsible_ for paying the Bitcoin fee:
25772595
- SHOULD send `update_fee` to ensure the current fee rate is sufficient (by a
25782596
significant margin) for timely processing of the commitment transaction.
@@ -2591,6 +2609,9 @@ A sending node:
25912609
- MAY fail the channel
25922610

25932611
A receiving node:
2612+
- if `zero_fee_commitments` is used:
2613+
- MUST ignore the message.
2614+
- SHOULD send a `warning` and disconnect.
25942615
- if the `update_fee` is too low for timely processing, OR is unreasonably large:
25952616
- MUST send a `warning` and close the connection, or send an
25962617
`error` and fail the channel.
@@ -2615,7 +2636,9 @@ Bitcoin fees are required for unilateral closes to be effective.
26152636
With `option_anchors`, `feerate_per_kw` is not as critical anymore to guarantee
26162637
confirmation as it was in the legacy commitment format, but it still needs to
26172638
be enough to be able to enter the mempool (satisfy min relay fee and mempool
2618-
min fee).
2639+
min fee). With `zero_fee_commitments`, transactions can enter the mempool
2640+
as a package with a child transaction paying the fees: channel transactions
2641+
thus don't need to directly include a fee, so this message isn't used.
26192642

26202643
For the legacy commitment format, there is no general method for the
26212644
broadcasting node to use child-pays-for-parent to increase its effective fee.

0 commit comments

Comments
 (0)