@@ -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,35 @@ Alternatively, implementations may choose to apply non-strict forwarding only to
635637like-policy channels to ensure their expected fee revenue does not deviate by
636638using 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 (default: 50% of remote peer's ` max_accepted_htlcs ` ).
647+ * ` unknown_allocation_liquidity ` : defines the amount of the channel balance
648+ that is allocated to unknown traffic (default: 50% of remote peer's
649+ ` max_htlc_value_in_flight_msat ` .
650+
651+ A node implementing resource bucketing limits exposure on its outgoing channel:
652+ - MUST choose ` unknown_allocation_slots ` <= the remote channel peer's
653+ ` max_accepted_htlcs ` .
654+ - MUST choose ` unknown_allocation_liquidity ` <= the remote channel peer's
655+ ` max_htlc_value_in_flight_msat ` .
656+ - If ` endorsed ` is set to 1 in the incoming ` update_add_htlc ` AND the HTLC
657+ is from a node that the forwarding node considers to have good local
658+ reputation (see [ Recommendations for Reputation] ( #recommendations-for-reputation ) ):
659+ - SHOULD proceed with forwarding the HTLC.
660+ - SHOULD set ` endorsed ` to 1 in the outgoing ` update_add_htlc ` .
661+ - Otherwise, the HTLC is classified as ` unknown ` :
662+ - If ` unknown_allocation_slots ` HTLC slots are occupied by other ` unknown ` HTLCs:
663+ - SHOULD return ` temporary_channel_failure ` as specified in [ Failure Messages] ( #failure-messages ) .
664+ - If ` unknown_allocation_liquidity ` satoshis of liquidity are locked in
665+ other ` unknown ` HTLCs:
666+ - SHOULD return ` temporary_channel_failure ` as specified in [ Failure Messages] ( #failure-messages ) .
667+ - SHOULD set ` endorsed ` to 0 in the outgoing ` update_add_htlc ` .
668+
638669## Payload for the Last Node
639670
640671When building the route, the origin node MUST use a payload for
@@ -1407,6 +1438,87 @@ The _origin node_:
14071438 - MAY use the data specified in the various failure types for debugging
14081439 purposes.
14091440
1441+ ## Recommendations for Reputation
1442+
1443+ Local reputation is used by forwarding nodes to decide whether to endorse a HTLC
1444+ on their outgoing link. Nodes MAY use any metric of their choosing to classify
1445+ a peer as having "good" reputation, though a poor choice of reputation scoring
1446+ metric may affect their downstream reputation.
1447+
1448+ Peers build reputation by forwarding successful HTLCs that resolve quickly, and
1449+ lose reputation if they endorse failing or slow-resolving HTLCs. Reputation is
1450+ only _ negatively_ affected if an endorsed HTLC resolves undesirably, to hold
1451+ nodes accountable for their endorsement signal while still allowing them to
1452+ forward unendorsed HTLCs that they are not certain about.
1453+
1454+ HTLC resolution time is assessed relative to a threshold that the node
1455+ considers to be a reasonable amount of time for a HTLC to resolve:
1456+ - ` resolution_period ` : the amount of time a HTLC is allowed to resolve in that
1457+ is classified as "good" behavior (default: 10 seconds).
1458+ - ` resolution_time ` : the time elapsed between ` update_add_htlc ` and its
1459+ resolution (` update_fulfill_hltc ` / ` update_fail_hltc ` /
1460+ ` update_fail_malformed_htlc ` ).
1461+
1462+ Each HTLC's contribution to reputation is expressed by its ` effective_fees `
1463+ which capture the fees that it paid and the opportunity cost that holding it
1464+ for ` resolution_time ` incurred.
1465+ - ` fees ` : the fees paid by a forwarded HTLC (as described in [ BOLT #7 ] ( 07-routing-gossip.md#htlc-fees ) ,
1466+ equal to 0 if the HTLC was not fulfilled).
1467+ - ` opportunity_cost ` : ` ceil ( (resolution_time - resolution_period) / resolution_period) * fees `
1468+
1469+ Given that ` resolution_time ` will be > 0 in practice, ` opportunity_cost ` is 0
1470+ for HTLCs that resolve within ` resolution_period ` , and charges the ` fees ` that
1471+ the HTLC would have earned per period it is held thereafter. This cost accounts
1472+ for the slot and liquidity that could have otherwise been paid for by
1473+ successful, fast resolving HTLCs during the ` resolution_time ` the HTLC was
1474+ locked in the channel.
1475+
1476+ For every incoming HLTC a peer has forwarded through a node, its ` effective_fees `
1477+ are calculated as follows:
1478+ - if ` endorsed ` = 1 in ` update_add_htlc ` :
1479+ - ` effective_fees ` = ` fees ` - ` opportunity_cost `
1480+ - otherwise:
1481+ - if successfully resolved AND ` resolution_time ` <= ` resolution_period `
1482+ - ` effective_fees ` = ` fees `
1483+ - otherwise:
1484+ - ` effective_fees ` = 0
1485+
1486+ The ` effective_fees ` that a peer has paid our node are compared to our total
1487+ routing revenue to classify a peer's reputation as "good" or "neutral". This
1488+ relates the fees that must be paid to earn "good" reputation to the damage that
1489+ can be done by abusing it.
1490+
1491+ Routing revenue is assessed over a sliding window, so that reputation
1492+ classification is related to the node's current routing activity. Nodes MAY
1493+ choose a window per their preferences - shorter windows being more reactive to
1494+ recent routing patterns, and longer windows aggregating trends over time.
1495+
1496+ - ` routing_window ` : the period of time in which total routing revenue is
1497+ assessed (default: 10 minutes * the maximum number of blocks a HTLC may be
1498+ held before the node will send ` expiry_too_far ` , as outlined in [ Failure Messages] ( #failure-messages ) ).
1499+ - ` routing_revenue ` : the sum of all fees paid to the node to forward HTLCs
1500+ over the interval [ ` now ` - ` routing_window ` ; ` now ` ] .
1501+
1502+ The total ` effective_fees ` that an individual peer has generated are assessed
1503+ over a longer period of time to relate its reputation classification to the
1504+ routing activity of the node (represented by ` routing_revenue ` ).
1505+
1506+ - ` reputation_window ` : the period of time over which the node's ` effective_fees `
1507+ are calculated to classify its reputation (recommended default = 10 * ` routing_window ` ).
1508+ - ` reputation_revenue ` : the total ` effective_fees ` of HTLCs forwarded by the peer
1509+ over the interval [ ` now ` - ` reputation_window ` ; ` now ` ] .
1510+
1511+ A peer is classified as having "good" local reputation iff ` reputation_revenue ` >= ` routing_revenue ` ,
1512+ otherwise the peer's reputation is classified as "neutral".
1513+
1514+ ### Rationale
1515+ If a HTLC is endorsed by a peer they have signaled that they expect the HTLC
1516+ to resolve honestly, so will be held accountable for the manner in which they
1517+ resolve. By contrast, if a HTLC was not endorsed by the upstream peer, it
1518+ should not have a negative impact on reputation. In the case where one of
1519+ these "unknown" HTLCs succeeds within the reasonable resolution threshold, the
1520+ peer is still credited with fees because the HTLC resolved desirably.
1521+
14101522# Test Vector
14111523
14121524## Returning Errors
0 commit comments