Skip to content

Commit 47e8c2c

Browse files
committed
Scale the success probability of channels without info down by 75%
If we are examining a channel for which we have no information at all, we traditionally assume the HTLC success probability is proportional to the channel's capacity. While this may be the case, it is not the case that a tiny payment over a huge channel is guaranteed to succeed, as we assume. Rather, the probability of such success is likely closer to 50% than 100%. Here we try to capture this by simply scaling the success probability for channels where we have no information down linearly. We pick 75% as the upper bound rather arbitrarily - while 50% may be more accurate, its possible it would lead to an over-reliance on channels which we have paid through in the past, which aren't necessarily always the best candidates. Note that we only do this scaling for the historical bucket tracker, as there we can be confident we've never seen a successful HTLC completion on the given channel. If we were to apply the same scaling to the simple liquidity bounds based scoring we'd penalize channels we've never tried over those we've only ever fails to pay over, which is obviously not a good outcome.
1 parent ba82cbb commit 47e8c2c

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

lightning/src/routing/scoring.rs

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1007,11 +1007,21 @@ const BASE_AMOUNT_PENALTY_DIVISOR: u64 = 1 << 30;
10071007
/// min_zero_implies_no_successes signals that an `amount_msat` of 0 means we've not (recently)
10081008
/// seen an HTLC successfully complete over this channel.
10091009
fn success_probability(
1010-
min_liquidity_msat: u64, amount_msat: u64, max_liquidity_msat: u64, _capacity_msat: u64,
1011-
_params: &ProbabilisticScoringFeeParameters, _min_zero_implies_no_successes: bool,
1010+
min_liquidity_msat: u64, amount_msat: u64, max_liquidity_msat: u64, capacity_msat: u64,
1011+
_params: &ProbabilisticScoringFeeParameters, min_zero_implies_no_successes: bool,
10121012
) -> (u64, u64) {
1013+
debug_assert!(min_liquidity_msat <= amount_msat);
1014+
debug_assert!(amount_msat < max_liquidity_msat);
1015+
debug_assert!(max_liquidity_msat <= capacity_msat);
1016+
10131017
let numerator = max_liquidity_msat - amount_msat;
1014-
let denominator = (max_liquidity_msat - min_liquidity_msat).saturating_add(1);
1018+
let mut denominator = (max_liquidity_msat - min_liquidity_msat).saturating_add(1);
1019+
if min_zero_implies_no_successes && min_liquidity_msat == 0 &&
1020+
numerator < u64::max_value() / 3 {
1021+
// If we have no knowledge of the channel, scale probability down by 75%
1022+
numerator = numerator * 3 / 4
1023+
}
1024+
10151025
(numerator, denominator)
10161026
}
10171027

0 commit comments

Comments
 (0)