Skip to content

Commit f5fe68b

Browse files
committed
Bound exposure to trimmed in-flight HTLCs
1 parent 84213f4 commit f5fe68b

File tree

1 file changed

+55
-0
lines changed

1 file changed

+55
-0
lines changed

02-peer-protocol.md

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -797,6 +797,61 @@ A fulfilling node:
797797
transaction, AND is past this fulfillment deadline:
798798
- MUST fail the channel.
799799

800+
### Bounding exposure to trimmed in-flight HTLCs: `max_dust_htlc_exposure_msat`
801+
802+
When a HTLC is present in a channel is below the "trimmed" threshold in [BOLT3 #3](03-transactions.md),
803+
the HTLC is not claimable on-chain, instead being turned into additional miner
804+
fees if either party unilaterally closes the channel. Because the threshold is
805+
per-HTLC, the total exposure to such HTLCs may be substantial if there are many
806+
dust HTLCs present when the channel is force-closed.
807+
808+
This can be exploited in griefing attacks or even in miner-extractable-value attacks,
809+
if the malicious entity avails <sup>[mining capabilities](https://lists.linuxfoundation.org/pipermail/lightning-dev/2020-May/002714.html)</sup>.
810+
811+
The total exposure is given by the following back-of-the-envelope computation:
812+
813+
counterparty's `max_accepted_htlcs` * (`HTLC-success-kiloweight` * opener's `feerate_per_kw` + counterparty's `dust_limit_satoshis`)
814+
+ holder's `max_accepted_htlcs` * (`HTLC-timeout-kiloweight` * opener's `feerate_per_kw` + counterparty's `dust_limit_satoshis`)
815+
816+
817+
To mitigate this scenario, a `max_dust_htlc_exposure_msat` must be apply at
818+
HTLC sending, forwarding and receiving.
819+
820+
A node:
821+
- upon an incoming HTLC:
822+
- if a HTLC's `amount_msat` is inferior to the counterparty's `dust_limit_satoshis` plus the HTLC-timeout fee at the `dust_buffer_feerate`:
823+
- if the `amount_msat` plus the `dust_balance_on_counterparty_tx` is superior to `max_dust_htlc_exposure_msat`:
824+
- SHOULD fail this HTLC once it's committed
825+
- SHOULD NOT reveal a preimage for this HTLC
826+
- if a HTLC's `amount_msat` is inferior to the holder's `dust_limit_satoshis` plus the HTLC-success fee at the `dust_buffer_feerate`:
827+
- if the `amount_msat` plus the `dust_balance_on_holder_tx` is superior to `max_dust_htlc_exposure_msat`:
828+
- SHOULD fail this HTLC once it's committed
829+
- SHOULD NOT reveal a preimage for this HTLC
830+
- upon an outgoing HTLC:
831+
- if a HTLC's `amount_msat` is inferior the counterparty's `dust_limit_satoshis` plus the HTLC-success fee at the `dust_buffer_feerate`:
832+
- if the `amount_msat` plus the `dust_balance_on_counterparty_tx` is superior to `max_dust_htlc_exposure_msat`:
833+
- SHOULD NOT send this HTLC
834+
- SHOULD fail this HTLC if it's forwarded
835+
- if a HTLC's `amount_msat` is inferior to the holder's `dust_limit_satoshis` plus the HTLC-timeout fee at the `dust_buffer_feerate`:
836+
- if the `amount_msat` plus the `dust_balance_on_holder_tx` is superior to `max_dust_htlc_exposure_msat`:
837+
- SHOULD NOT send this HTLC
838+
- SHOULD fail this HTLC if it's forwarded
839+
840+
`dust_buffer_feerate` is defined as the maximum of either 2530 sats per kWU or
841+
125% of the current `feerate_per_kw`. This ensure that the node isn't suddenly
842+
exposed to significantly more trimmed balance if the feerate increases when we have
843+
several HTLCs pending which are near the dust limit.
844+
845+
`dust_balance_on_holder_tx` as the sum:
846+
- incoming HTLCs inferior to the holder's `dust_limit_satoshis` plus the HTLC-timeout fee at the `dust_buffer_feerate`
847+
- outgoing HTLCs inferior to the holder's `dust_limit_satoshis` plus the HTLC-success fee at the `dust_buffer_feerate`
848+
- waiting-a-counterparty-RAA-to-be-removed outgoing HTLCs inferior to the holder's `dust_limit_satoshis` plus the HTLC-timeout fee at the `dust_buffer_feerate`
849+
850+
`dust_balance_on_counterparty_tx` as the sum:
851+
- incoming HTLCs inferior to the counterparty's `dust_limit_satoshis` plus the HTLC-success fee at the `dust_buffer_feerate`
852+
- outgoing HTLCs inferior to the counterparty's `dust_limit_satoshis` plus the HTLC-timeout fee at the `dust_buffer_feerate`
853+
- waiting-a-counterparty-RAA-to-be-removed outgoing HTLCs inferior to the counterparty's `dust_limit_satoshis` plus the HTLC-timoeut fee at the `dust_buffer_feerate`
854+
800855
### Adding an HTLC: `update_add_htlc`
801856

802857
Either node can send `update_add_htlc` to offer an HTLC to the other,

0 commit comments

Comments
 (0)