Skip to content

Commit 591e524

Browse files
committed
multi: add resource bucketing for HTLC slots and liquidity
1 parent a049b79 commit 591e524

File tree

2 files changed

+48
-1
lines changed

2 files changed

+48
-1
lines changed

02-peer-protocol.md

+10-1
Original file line numberDiff line numberDiff line change
@@ -995,7 +995,10 @@ is destined, is described in [BOLT #4](04-onion-routing.md).
995995
1. type: 0 (`blinding_point`)
996996
2. data:
997997
* [`point`:`blinding`]
998-
998+
1. type: 1 (`endorsed`)
999+
2. data:
1000+
* [`byte`:`endorsed`]
1001+
9991002
#### Requirements
10001003

10011004
A sending node:
@@ -1033,6 +1036,10 @@ A sending node:
10331036
- MUST increase the value of `id` by 1 for each successive offer.
10341037
- if it is relaying a payment inside a blinded route:
10351038
- MUST set `blinding_point` (see [Route Blinding](04-onion-routing.md#route-blinding))
1039+
- if it is the original source of the HTLC:
1040+
- SHOULD set `endorsed` to `1`.
1041+
- otherwise:
1042+
- SHOULD set `endorsed` as described in [Bolt 4](04-onion-routing.md#resource-bucketing).
10361043

10371044
`id` MUST NOT be reset to 0 after the update is complete (i.e. after `revoke_and_ack` has
10381045
been received). It MUST continue incrementing instead.
@@ -1059,6 +1066,8 @@ A receiving node:
10591066
`error` and fail the channel.
10601067
- if `blinding_point` is provided:
10611068
- MUST use the corresponding blinded private key to decrypt the `onion_routing_packet` (see [Route Blinding](04-onion-routing.md#route-blinding))
1069+
- if `endorsed` is provided:
1070+
- SHOULD interpret `endorsed` as described in [Bolt 4](04-onion-routing.md#resource-bucketing).
10621071

10631072
The `onion_routing_packet` contains an obfuscated list of hops and instructions for each hop along the path.
10641073
It commits to the HTLC by setting the `payment_hash` as associated data, i.e. includes the `payment_hash` in the computation of HMACs.

04-onion-routing.md

+38
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ A node:
5353
* [Route Blinding](#route-blinding)
5454
* [Accepting and Forwarding a Payment](#accepting-and-forwarding-a-payment)
5555
* [Non-strict Forwarding](#non-strict-forwarding)
56+
* [Resource Bucketing](#resource-bucketing)
5657
* [Payload for the Last Node](#payload-for-the-last-node)
5758
* [Shared Secret](#shared-secret)
5859
* [Blinding Ephemeral Keys](#blinding-ephemeral-keys)
@@ -62,6 +63,7 @@ A node:
6263
* [Returning Errors](#returning-errors)
6364
* [Failure Messages](#failure-messages)
6465
* [Receiving Failure Codes](#receiving-failure-codes)
66+
* [Recommendations for Reputation](#recommendations-for-reputation)
6567
* [Test Vector](#test-vector)
6668
* [Returning Errors](#returning-errors)
6769
* [References](#references)
@@ -635,6 +637,38 @@ Alternatively, implementations may choose to apply non-strict forwarding only to
635637
like-policy channels to ensure their expected fee revenue does not deviate by
636638
using an alternate channel.
637639

640+
## Resource Bucketing
641+
642+
When making the decision to forward a payment on its outgoing channel, a node
643+
MAY choose to limit its exposure to HTLCs that put it at risk of a denial of
644+
service attack.
645+
* `unknown_allocation_slots`: defines the number of HTLC slots allocated to
646+
unknown traffic.
647+
* `unknown_allocation_liquidity`: defines the amount of the channel balance
648+
that is allocated to unknown traffic.
649+
650+
It is recommended to allocate 50% of a channel's liquidity and slots to unknown
651+
traffic to accommodate the recommended maximum HTLC size (per the Oakland
652+
Protocol).
653+
654+
A node implementing resource bucketing limits exposure on its outgoing channel:
655+
- MUST choose `unknown_allocation_slots` <= the remote channel peer's
656+
`max_accepted_htlcs`.
657+
- MUST choose `unknown_allocation_liquidity` <= the remote channel peer's
658+
`max_htlc_value_in_flight_msat`.
659+
- If `endorsed` is set to 1 in the incoming `update_add_htlc` AND the HTLC
660+
is from a node that the forwarding node considers to have good local
661+
reputation (see [Recommendations for Reputation](#recommendations-for-reputation)):
662+
- SHOULD proceed with forwarding the HTLC.
663+
- SHOULD set `endorsed` to 1 in the outgoing `update_add_htlc`.
664+
- Otherwise, the HTLC is classified as `unknown`:
665+
- If `unknown_allocation_slots` HTLC slots are occupied by other `unknown` HTLCs:
666+
- SHOULD return `temporary_channel_failure` as specified in [Failure Messages](#failure-messages).
667+
- If `unknown_allocation_liquidity` satoshis of liquidity are locked in
668+
other `unknown` HTLCs:
669+
- SHOULD return `temporary_channel_failure` as specified in [Failure Messages](#failure-messages).
670+
- SHOULD set `endorsed` to 0 in the outgoing `update_add_htlc`.
671+
638672
## Payload for the Last Node
639673

640674
When building the route, the origin node MUST use a payload for
@@ -1407,6 +1441,10 @@ The _origin node_:
14071441
- MAY use the data specified in the various failure types for debugging
14081442
purposes.
14091443

1444+
# Recommendations for Reputation
1445+
1446+
At the time of writing, specification for reputation recommendations is ongoing.
1447+
14101448
# Test Vector
14111449

14121450
## Returning Errors

0 commit comments

Comments
 (0)