@@ -53,6 +53,7 @@ A node:
53
53
* [ Route Blinding] ( #route-blinding )
54
54
* [ Accepting and Forwarding a Payment] ( #accepting-and-forwarding-a-payment )
55
55
* [ Non-strict Forwarding] ( #non-strict-forwarding )
56
+ * [ Resource Bucketing] ( #resource-bucketing )
56
57
* [ Payload for the Last Node] ( #payload-for-the-last-node )
57
58
* [ Shared Secret] ( #shared-secret )
58
59
* [ Blinding Ephemeral Keys] ( #blinding-ephemeral-keys )
@@ -62,6 +63,7 @@ A node:
62
63
* [ Returning Errors] ( #returning-errors )
63
64
* [ Failure Messages] ( #failure-messages )
64
65
* [ Receiving Failure Codes] ( #receiving-failure-codes )
66
+ * [ Recommendations for Reputation] ( #recommendations-for-reputation )
65
67
* [ Test Vector] ( #test-vector )
66
68
* [ Returning Errors] ( #returning-errors )
67
69
* [ References] ( #references )
@@ -635,6 +637,35 @@ Alternatively, implementations may choose to apply non-strict forwarding only to
635
637
like-policy channels to ensure their expected fee revenue does not deviate by
636
638
using an alternate channel.
637
639
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
+
638
669
## Payload for the Last Node
639
670
640
671
When building the route, the origin node MUST use a payload for
@@ -1407,6 +1438,88 @@ The _origin node_:
1407
1438
- MAY use the data specified in the various failure types for debugging
1408
1439
purposes.
1409
1440
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 will 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 holds
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 its
1464
+ ` 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 failed).
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 in the future a
1498
+ HTLC's expiry height can fall before the node will send ` expiry_too_far ` , as
1499
+ outlined in [ Failure Messages] ( #failure-messages ) ).
1500
+ - ` routing_revenue ` : the sum of all fees paid to the node to forward HTLCs
1501
+ over the interval [ ` now ` - ` routing_window ` ; ` now ` ] .
1502
+
1503
+ The total ` effective_fees ` that an individual peer has generated are assessed
1504
+ over a longer period of time to relate its reputation classification to the
1505
+ routing activity of the node (represented by ` routing_revenue ` ).
1506
+
1507
+ - ` reputation_window ` : the period of time over which the node's ` effective_fees `
1508
+ are calculated to classify its reputation (recommended default = 10 * ` routing_window ` ).
1509
+ - ` reputation_revenue ` : the total ` effective_fees ` of HTLCs forwarded by the peer
1510
+ over the interval [ ` now ` - ` reputation_window ` ; ` now ` ] .
1511
+
1512
+ A peer is classified as having "good" local reputation iff ` reputation_revenue ` >= ` routing_revenue ` ,
1513
+ otherwise the peer's reputation is classified as "neutral".
1514
+
1515
+ ### Rationale
1516
+ If a HTLC is endorsed by a peer they have signaled that they expect the HTLC
1517
+ to resolve honestly, so will be held accountable for the manner in which they
1518
+ resolve. By contrast, if a HTLC was not endorsed by the upstream peer, it
1519
+ should not have a negative impact on reputation. In the case where one of
1520
+ these "unknown" HTLCs succeeds within the reasonable resolution threshold, the
1521
+ peer is still credited with fees because the HTLC resolved desirably.
1522
+
1410
1523
# Test Vector
1411
1524
1412
1525
## Returning Errors
0 commit comments