Skip to content

Commit 098cd32

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 098cd32

File tree

1 file changed

+48
-22
lines changed

1 file changed

+48
-22
lines changed

lightning/src/routing/scoring.rs

Lines changed: 48 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: 262,144 msat (i.e. we're willing to pay 0.25bps 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,13 @@ 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 that the historical scoring model configured with
535+
/// the [`historical_liquidity_penalty_multiplier_msat`] and thus is disabled by default.
536+
///
537+
/// Default value: 0 msat
522538
///
523539
/// [`liquidity_offset_half_life`]: ProbabilisticScoringDecayParameters::liquidity_offset_half_life
540+
/// [`historical_liquidity_penalty_multiplier_msat`]: Self::historical_liquidity_penalty_multiplier_msat
524541
pub liquidity_penalty_multiplier_msat: u64,
525542

526543
/// A multiplier used in conjunction with the payment amount and the negative `log10` of the
@@ -540,7 +557,13 @@ pub struct ProbabilisticScoringFeeParameters {
540557
/// probabilities, the multiplier will have a decreasing effect as the negative `log10` will
541558
/// fall below `1`.
542559
///
543-
/// Default value: 192 msat
560+
/// In testing, this scoring model performs that the historical scoring model configured with
561+
/// the [`historical_liquidity_penalty_amount_multiplier_msat`] and thus is disabled by
562+
/// default.
563+
///
564+
/// Default value: 0 msat
565+
///
566+
/// [`historical_liquidity_penalty_amount_multiplier_msat`]: Self::historical_liquidity_penalty_amount_multiplier_msat
544567
pub liquidity_penalty_amount_multiplier_msat: u64,
545568

546569
/// A multiplier used in conjunction with the negative `log10` of the channel's success
@@ -554,7 +577,8 @@ pub struct ProbabilisticScoringFeeParameters {
554577
/// track which of several buckets those bounds fall into, exponentially decaying the
555578
/// probability of each bucket as new samples are added.
556579
///
557-
/// Default value: 10,000 msat
580+
/// Default value: 10,000 msat (i.e. willing to pay 1 sat to avoid an 80% probability channel,
581+
/// or 6 sats to avoid a 25% probability channel).
558582
///
559583
/// [`liquidity_penalty_multiplier_msat`]: Self::liquidity_penalty_multiplier_msat
560584
pub historical_liquidity_penalty_multiplier_msat: u64,
@@ -575,7 +599,9 @@ pub struct ProbabilisticScoringFeeParameters {
575599
/// channel, we track which of several buckets those bounds fall into, exponentially decaying
576600
/// the probability of each bucket as new samples are added.
577601
///
578-
/// Default value: 64 msat
602+
/// Default value: 2,500 msat (i.e. willing to pay about 0.25 bps per hop to avoid 78%
603+
/// probability channels, or 1bp to avoid a 38% probability
604+
/// channel).
579605
///
580606
/// [`liquidity_penalty_amount_multiplier_msat`]: Self::liquidity_penalty_amount_multiplier_msat
581607
pub historical_liquidity_penalty_amount_multiplier_msat: u64,
@@ -642,15 +668,15 @@ pub struct ProbabilisticScoringFeeParameters {
642668
impl Default for ProbabilisticScoringFeeParameters {
643669
fn default() -> Self {
644670
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,
671+
base_penalty_msat: 1024,
672+
base_penalty_amount_multiplier_msat: 1024,
673+
liquidity_penalty_multiplier_msat: 0,
674+
liquidity_penalty_amount_multiplier_msat: 0,
649675
manual_node_penalties: new_hash_map(),
650676
anti_probing_penalty_msat: 250,
651677
considered_impossible_penalty_msat: 1_0000_0000_000,
652678
historical_liquidity_penalty_multiplier_msat: 10_000,
653-
historical_liquidity_penalty_amount_multiplier_msat: 64,
679+
historical_liquidity_penalty_amount_multiplier_msat: 2_500,
654680
linear_success_probability: false,
655681
}
656682
}
@@ -3017,47 +3043,47 @@ mod tests {
30173043
info,
30183044
short_channel_id: 42,
30193045
});
3020-
assert_eq!(scorer.channel_penalty_msat(&candidate, usage, &params), 11577);
3046+
assert_eq!(scorer.channel_penalty_msat(&candidate, usage, &params), 56_916);
30213047
let usage = ChannelUsage {
30223048
effective_capacity: EffectiveCapacity::Total { capacity_msat: 1_950_000_000, htlc_maximum_msat: 1_000 }, ..usage
30233049
};
3024-
assert_eq!(scorer.channel_penalty_msat(&candidate, usage, &params), 8462);
3050+
assert_eq!(scorer.channel_penalty_msat(&candidate, usage, &params), 44_906);
30253051
let usage = ChannelUsage {
30263052
effective_capacity: EffectiveCapacity::Total { capacity_msat: 2_950_000_000, htlc_maximum_msat: 1_000 }, ..usage
30273053
};
3028-
assert_eq!(scorer.channel_penalty_msat(&candidate, usage, &params), 6889);
3054+
assert_eq!(scorer.channel_penalty_msat(&candidate, usage, &params), 38_842);
30293055
let usage = ChannelUsage {
30303056
effective_capacity: EffectiveCapacity::Total { capacity_msat: 3_950_000_000, htlc_maximum_msat: 1_000 }, ..usage
30313057
};
3032-
assert_eq!(scorer.channel_penalty_msat(&candidate, usage, &params), 5883);
3058+
assert_eq!(scorer.channel_penalty_msat(&candidate, usage, &params), 34_960);
30333059
let usage = ChannelUsage {
30343060
effective_capacity: EffectiveCapacity::Total { capacity_msat: 4_950_000_000, htlc_maximum_msat: 1_000 }, ..usage
30353061
};
3036-
assert_eq!(scorer.channel_penalty_msat(&candidate, usage, &params), 5412);
3062+
assert_eq!(scorer.channel_penalty_msat(&candidate, usage, &params), 33_141);
30373063
let usage = ChannelUsage {
30383064
effective_capacity: EffectiveCapacity::Total { capacity_msat: 5_950_000_000, htlc_maximum_msat: 1_000 }, ..usage
30393065
};
3040-
assert_eq!(scorer.channel_penalty_msat(&candidate, usage, &params), 4940);
3066+
assert_eq!(scorer.channel_penalty_msat(&candidate, usage, &params), 31_321);
30413067
let usage = ChannelUsage {
30423068
effective_capacity: EffectiveCapacity::Total { capacity_msat: 6_950_000_000, htlc_maximum_msat: 1_000 }, ..usage
30433069
};
3044-
assert_eq!(scorer.channel_penalty_msat(&candidate, usage, &params), 4689);
3070+
assert_eq!(scorer.channel_penalty_msat(&candidate, usage, &params), 30_351);
30453071
let usage = ChannelUsage {
30463072
effective_capacity: EffectiveCapacity::Total { capacity_msat: 7_450_000_000, htlc_maximum_msat: 1_000 }, ..usage
30473073
};
3048-
assert_eq!(scorer.channel_penalty_msat(&candidate, usage, &params), 4468);
3074+
assert_eq!(scorer.channel_penalty_msat(&candidate, usage, &params), 29_502);
30493075
let usage = ChannelUsage {
30503076
effective_capacity: EffectiveCapacity::Total { capacity_msat: 7_950_000_000, htlc_maximum_msat: 1_000 }, ..usage
30513077
};
3052-
assert_eq!(scorer.channel_penalty_msat(&candidate, usage, &params), 4468);
3078+
assert_eq!(scorer.channel_penalty_msat(&candidate, usage, &params), 29_502);
30533079
let usage = ChannelUsage {
30543080
effective_capacity: EffectiveCapacity::Total { capacity_msat: 8_950_000_000, htlc_maximum_msat: 1_000 }, ..usage
30553081
};
3056-
assert_eq!(scorer.channel_penalty_msat(&candidate, usage, &params), 4217);
3082+
assert_eq!(scorer.channel_penalty_msat(&candidate, usage, &params), 28_531);
30573083
let usage = ChannelUsage {
30583084
effective_capacity: EffectiveCapacity::Total { capacity_msat: 9_950_000_000, htlc_maximum_msat: 1_000 }, ..usage
30593085
};
3060-
assert_eq!(scorer.channel_penalty_msat(&candidate, usage, &params), 3996);
3086+
assert_eq!(scorer.channel_penalty_msat(&candidate, usage, &params), 27_682);
30613087
}
30623088

30633089
#[test]

0 commit comments

Comments
 (0)