Skip to content

Commit 1e3515e

Browse files
committed
Update the default scoring parameters to use historical model only
Utilizing the results of probes sent once a minute to a random node in the network for a random amount (within a reasonable range), we were able to analyze the accuracy of our resulting success probability estimation with various PDFs across the historical and live-bounds models. For each candidate PDF (as well as other parameters, to be tuned in the coming commits), we used the `min_zero_implies_no_successes` fudge factor in `success_probability` as well as a total probability multiple fudge factor to get both the historical success model and the a priori model to be neither too optimistic nor too pessimistic (as measured by the relative log-loss between succeeding and failing hops in our sample data). We then compared the resulting log-loss for the historical success model and selected the candidate PDF with the lowest log-loss, skipping a few candidates with similar resulting log-loss but with more extreme constants (such as a power of 11 with a higher `min_zero_implies_no_successes` penalty). In every case, the historical model performed substantially better than the live-bounds model, so here we simply disable the live-bounds model by default and use only the historical model. Further, we use the calculated total probability multiple fudge factor (0.7886892844179266) to choose the ratio between the historical model and the per-hop penalty (as multiplying each hop's probability by 78% is equivalent to adding a per-hop penalty of log10(0.78) of our probabilistic penalty). We take this opportunity to bump the penalties up a bit as well, as anecdotally LDK users are willing to pay more than they do today to get more successful paths. Fixes #3040
1 parent 8cacd7d commit 1e3515e

File tree

1 file changed

+49
-22
lines changed

1 file changed

+49
-22
lines changed

lightning/src/routing/scoring.rs

Lines changed: 49 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -488,7 +488,13 @@ where L::Target: Logger {
488488
pub struct ProbabilisticScoringFeeParameters {
489489
/// A fixed penalty in msats to apply to each channel.
490490
///
491-
/// Default value: 500 msat
491+
/// In testing, a value of roughly 1/10th of [`historical_liquidity_penalty_multiplier_msat`]
492+
/// (implying scaling all estimated probabilities down by a factor of ~79%) resulted in the
493+
/// most accurate total success probabilities.
494+
///
495+
/// Default value: 1,024 msat (i.e. we're willing to pay 1 sat to avoid each additional hop).
496+
///
497+
/// [`historical_liquidity_penalty_multiplier_msat`]: Self::historical_liquidity_penalty_multiplier_msat
492498
pub base_penalty_msat: u64,
493499

494500
/// A multiplier used with the payment amount to calculate a fixed penalty applied to each
@@ -500,9 +506,16 @@ pub struct ProbabilisticScoringFeeParameters {
500506
///
501507
/// ie `base_penalty_amount_multiplier_msat * amount_msat / 2^30`
502508
///
503-
/// Default value: 8,192 msat
509+
/// In testing, a value of roughly ~100x (1/10th * 2^10) of
510+
/// [`historical_liquidity_penalty_amount_multiplier_msat`] (implying scaling all estimated
511+
/// probabilities down by a factor of ~79%) resulted in the most accurate total success
512+
/// probabilities.
513+
///
514+
/// Default value: 131,072 msat (i.e. we're willing to pay 0.125bps to avoid each additional
515+
/// hop).
504516
///
505517
/// [`base_penalty_msat`]: Self::base_penalty_msat
518+
/// [`historical_liquidity_penalty_amount_multiplier_msat`]: Self::historical_liquidity_penalty_amount_multiplier_msat
506519
pub base_penalty_amount_multiplier_msat: u64,
507520

508521
/// A multiplier used in conjunction with the negative `log10` of the channel's success
@@ -518,9 +531,14 @@ pub struct ProbabilisticScoringFeeParameters {
518531
///
519532
/// `-log10(success_probability) * liquidity_penalty_multiplier_msat`
520533
///
521-
/// Default value: 30,000 msat
534+
/// In testing, this scoring model performs much worse than the historical scoring model
535+
/// configured with the [`historical_liquidity_penalty_multiplier_msat`] and thus is disabled
536+
/// by default.
537+
///
538+
/// Default value: 0 msat
522539
///
523540
/// [`liquidity_offset_half_life`]: ProbabilisticScoringDecayParameters::liquidity_offset_half_life
541+
/// [`historical_liquidity_penalty_multiplier_msat`]: Self::historical_liquidity_penalty_multiplier_msat
524542
pub liquidity_penalty_multiplier_msat: u64,
525543

526544
/// A multiplier used in conjunction with the payment amount and the negative `log10` of the
@@ -540,7 +558,13 @@ pub struct ProbabilisticScoringFeeParameters {
540558
/// probabilities, the multiplier will have a decreasing effect as the negative `log10` will
541559
/// fall below `1`.
542560
///
543-
/// Default value: 192 msat
561+
/// In testing, this scoring model performs much worse than the historical scoring model
562+
/// configured with the [`historical_liquidity_penalty_amount_multiplier_msat`] and thus is
563+
/// disabled by default.
564+
///
565+
/// Default value: 0 msat
566+
///
567+
/// [`historical_liquidity_penalty_amount_multiplier_msat`]: Self::historical_liquidity_penalty_amount_multiplier_msat
544568
pub liquidity_penalty_amount_multiplier_msat: u64,
545569

546570
/// A multiplier used in conjunction with the negative `log10` of the channel's success
@@ -554,7 +578,8 @@ pub struct ProbabilisticScoringFeeParameters {
554578
/// track which of several buckets those bounds fall into, exponentially decaying the
555579
/// probability of each bucket as new samples are added.
556580
///
557-
/// Default value: 10,000 msat
581+
/// Default value: 10,000 msat (i.e. willing to pay 1 sat to avoid an 80% probability channel,
582+
/// or 6 sats to avoid a 25% probability channel).
558583
///
559584
/// [`liquidity_penalty_multiplier_msat`]: Self::liquidity_penalty_multiplier_msat
560585
pub historical_liquidity_penalty_multiplier_msat: u64,
@@ -575,7 +600,9 @@ pub struct ProbabilisticScoringFeeParameters {
575600
/// channel, we track which of several buckets those bounds fall into, exponentially decaying
576601
/// the probability of each bucket as new samples are added.
577602
///
578-
/// Default value: 64 msat
603+
/// Default value: 1,250 msat (i.e. willing to pay about 0.125 bps per hop to avoid 78%
604+
/// probability channels, or 0.5bps to avoid a 38% probability
605+
/// channel).
579606
///
580607
/// [`liquidity_penalty_amount_multiplier_msat`]: Self::liquidity_penalty_amount_multiplier_msat
581608
pub historical_liquidity_penalty_amount_multiplier_msat: u64,
@@ -642,15 +669,15 @@ pub struct ProbabilisticScoringFeeParameters {
642669
impl Default for ProbabilisticScoringFeeParameters {
643670
fn default() -> Self {
644671
Self {
645-
base_penalty_msat: 500,
646-
base_penalty_amount_multiplier_msat: 8192,
647-
liquidity_penalty_multiplier_msat: 30_000,
648-
liquidity_penalty_amount_multiplier_msat: 192,
672+
base_penalty_msat: 1024,
673+
base_penalty_amount_multiplier_msat: 131_072,
674+
liquidity_penalty_multiplier_msat: 0,
675+
liquidity_penalty_amount_multiplier_msat: 0,
649676
manual_node_penalties: new_hash_map(),
650677
anti_probing_penalty_msat: 250,
651678
considered_impossible_penalty_msat: 1_0000_0000_000,
652679
historical_liquidity_penalty_multiplier_msat: 10_000,
653-
historical_liquidity_penalty_amount_multiplier_msat: 64,
680+
historical_liquidity_penalty_amount_multiplier_msat: 1_250,
654681
linear_success_probability: false,
655682
}
656683
}
@@ -3017,47 +3044,47 @@ mod tests {
30173044
info,
30183045
short_channel_id: 42,
30193046
});
3020-
assert_eq!(scorer.channel_penalty_msat(&candidate, usage, &params), 11577);
3047+
assert_eq!(scorer.channel_penalty_msat(&candidate, usage, &params), 42_252);
30213048
let usage = ChannelUsage {
30223049
effective_capacity: EffectiveCapacity::Total { capacity_msat: 1_950_000_000, htlc_maximum_msat: 1_000 }, ..usage
30233050
};
3024-
assert_eq!(scorer.channel_penalty_msat(&candidate, usage, &params), 8462);
3051+
assert_eq!(scorer.channel_penalty_msat(&candidate, usage, &params), 36_005);
30253052
let usage = ChannelUsage {
30263053
effective_capacity: EffectiveCapacity::Total { capacity_msat: 2_950_000_000, htlc_maximum_msat: 1_000 }, ..usage
30273054
};
3028-
assert_eq!(scorer.channel_penalty_msat(&candidate, usage, &params), 6889);
3055+
assert_eq!(scorer.channel_penalty_msat(&candidate, usage, &params), 32_851);
30293056
let usage = ChannelUsage {
30303057
effective_capacity: EffectiveCapacity::Total { capacity_msat: 3_950_000_000, htlc_maximum_msat: 1_000 }, ..usage
30313058
};
3032-
assert_eq!(scorer.channel_penalty_msat(&candidate, usage, &params), 5883);
3059+
assert_eq!(scorer.channel_penalty_msat(&candidate, usage, &params), 30_832);
30333060
let usage = ChannelUsage {
30343061
effective_capacity: EffectiveCapacity::Total { capacity_msat: 4_950_000_000, htlc_maximum_msat: 1_000 }, ..usage
30353062
};
3036-
assert_eq!(scorer.channel_penalty_msat(&candidate, usage, &params), 5412);
3063+
assert_eq!(scorer.channel_penalty_msat(&candidate, usage, &params), 29_886);
30373064
let usage = ChannelUsage {
30383065
effective_capacity: EffectiveCapacity::Total { capacity_msat: 5_950_000_000, htlc_maximum_msat: 1_000 }, ..usage
30393066
};
3040-
assert_eq!(scorer.channel_penalty_msat(&candidate, usage, &params), 4940);
3067+
assert_eq!(scorer.channel_penalty_msat(&candidate, usage, &params), 28_939);
30413068
let usage = ChannelUsage {
30423069
effective_capacity: EffectiveCapacity::Total { capacity_msat: 6_950_000_000, htlc_maximum_msat: 1_000 }, ..usage
30433070
};
3044-
assert_eq!(scorer.channel_penalty_msat(&candidate, usage, &params), 4689);
3071+
assert_eq!(scorer.channel_penalty_msat(&candidate, usage, &params), 28_435);
30453072
let usage = ChannelUsage {
30463073
effective_capacity: EffectiveCapacity::Total { capacity_msat: 7_450_000_000, htlc_maximum_msat: 1_000 }, ..usage
30473074
};
3048-
assert_eq!(scorer.channel_penalty_msat(&candidate, usage, &params), 4468);
3075+
assert_eq!(scorer.channel_penalty_msat(&candidate, usage, &params), 27_993);
30493076
let usage = ChannelUsage {
30503077
effective_capacity: EffectiveCapacity::Total { capacity_msat: 7_950_000_000, htlc_maximum_msat: 1_000 }, ..usage
30513078
};
3052-
assert_eq!(scorer.channel_penalty_msat(&candidate, usage, &params), 4468);
3079+
assert_eq!(scorer.channel_penalty_msat(&candidate, usage, &params), 27_993);
30533080
let usage = ChannelUsage {
30543081
effective_capacity: EffectiveCapacity::Total { capacity_msat: 8_950_000_000, htlc_maximum_msat: 1_000 }, ..usage
30553082
};
3056-
assert_eq!(scorer.channel_penalty_msat(&candidate, usage, &params), 4217);
3083+
assert_eq!(scorer.channel_penalty_msat(&candidate, usage, &params), 27_488);
30573084
let usage = ChannelUsage {
30583085
effective_capacity: EffectiveCapacity::Total { capacity_msat: 9_950_000_000, htlc_maximum_msat: 1_000 }, ..usage
30593086
};
3060-
assert_eq!(scorer.channel_penalty_msat(&candidate, usage, &params), 3996);
3087+
assert_eq!(scorer.channel_penalty_msat(&candidate, usage, &params), 27_047);
30613088
}
30623089

30633090
#[test]

0 commit comments

Comments
 (0)