Skip to content

Commit 2600b6f

Browse files
committed
f Include incoming in-flight HLTCs in reputation calculations
1 parent 109765b commit 2600b6f

File tree

1 file changed

+21
-5
lines changed

1 file changed

+21
-5
lines changed

04-onion-routing.md

+21-5
Original file line numberDiff line numberDiff line change
@@ -1454,10 +1454,10 @@ forward unendorsed HTLCs that they are not certain about.
14541454
HTLC resolution time is assessed relative to a threshold that the node
14551455
considers to be a reasonable amount of time for a HTLC to resolve:
14561456
- `resolution_period`: the amount of time a HTLC is allowed to resolve in that
1457-
is classified as "good" behavior (default: 10 seconds).
1457+
is classified as "good" behavior, expressed in seconds (default: 10 seconds).
14581458
- `resolution_time`: the time elapsed between `update_add_htlc` and its
14591459
resolution (`update_fulfill_hltc` / `update_fail_hltc` /
1460-
`update_fail_malformed_htlc`).
1460+
`update_fail_malformed_htlc`), expressed in seconds.
14611461

14621462
Each HTLC's contribution to reputation is expressed by its `effective_fees`
14631463
which capture the fees that it paid and the opportunity cost that holding it
@@ -1473,8 +1473,8 @@ for the slot and liquidity that could have otherwise been paid for by
14731473
successful, fast resolving HTLCs during the `resolution_time` the HTLC was
14741474
locked in the channel.
14751475

1476-
For every incoming HLTC a peer has forwarded through a node, its `effective_fees`
1477-
are calculated as follows:
1476+
For every resolved incoming HLTC a peer has forwarded through a node, its
1477+
`effective_fees` are calculated as follows:
14781478
- if `endorsed` = 1 in `update_add_htlc`:
14791479
- `effective_fees` = `fees` - `opportunity_cost`
14801480
- otherwise:
@@ -1483,6 +1483,14 @@ are calculated as follows:
14831483
- otherwise:
14841484
- `effective_fees` = 0
14851485

1486+
Incoming in-flight HTLCs have a negative impact on reputation, as their
1487+
influence is unknown until time of resolution. The `outstanding_risk` of each
1488+
in flight HTLC is calculated as follows:
1489+
- if `endorsed` = 1 in `update_add_htlc`:
1490+
- `outstanding_risk` = `fees` * ( `cltv_expiry` - `height_added` * 10 * 60),
1491+
where `height_added` is the block height at which the HLTC was irrevocably
1492+
committed to by the receiving node.
1493+
14861494
The `effective_fees` that a peer has paid our node are compared to our total
14871495
routing revenue to classify a peer's reputation as "good" or "neutral". This
14881496
relates the fees that must be paid to earn "good" reputation to the damage that
@@ -1497,7 +1505,8 @@ recent routing patterns, and longer windows aggregating trends over time.
14971505
assessed (default: 10 minutes * the maximum number of blocks a HTLC may be
14981506
held before the node will send `expiry_too_far`, as outlined in [Failure Messages](#failure-messages)).
14991507
- `routing_revenue`: the sum of all fees paid to the node to forward HTLCs
1500-
over the interval [ `now` - `routing_window` ; `now` ].
1508+
over the interval [ `now` - `routing_window` ; `now` ] less the sum of
1509+
`outstanding_risk` for all incoming, in-flight HLTCs.
15011510

15021511
The total `effective_fees` that an individual peer has generated are assessed
15031512
over a longer period of time to relate its reputation classification to the
@@ -1533,6 +1542,13 @@ allows new, unendorsed entrants to slowly build reputation over time. The fee
15331542
contribution of unendorsed HTLCs is discounted by 50% to incentivise nodes to
15341543
endorse HTLCs.
15351544

1545+
In flight HLTCs are included in reputation scoring to account for sudden changes
1546+
in a peer's behavior. Even when good reputation is obtained, each HTLC choosing
1547+
to take advantage of that good reputation is treated as if it will be used to
1548+
inflict maximum damage. The expiry height of each incoming in flight HLTC is
1549+
considered so that risk is directly related to the amount of time the HTLC
1550+
could be held in the channel, and 10 minute blocks are assumed for simplicity.
1551+
15361552
# Test Vector
15371553

15381554
## Returning Errors

0 commit comments

Comments
 (0)