@@ -1852,6 +1852,9 @@ mod bucketed_history {
1852
1852
let mut total_valid_points_tracked = 0 ;
1853
1853
for ( min_idx, min_bucket) in self . min_liquidity_offset_history . buckets . iter ( ) . enumerate ( ) {
1854
1854
for max_bucket in self . max_liquidity_offset_history . buckets . iter ( ) . take ( 32 - min_idx) {
1855
+ // In testing, raising the weights of buckets to a high power led to better
1856
+ // scoring results. Thus, we raise the bucket weights to the 4th power here (by
1857
+ // squaring the result of multiplying the weights).
1855
1858
let mut bucket_weight = ( * min_bucket as u64 ) * ( * max_bucket as u64 ) ;
1856
1859
bucket_weight *= bucket_weight;
1857
1860
total_valid_points_tracked += bucket_weight;
@@ -1980,6 +1983,10 @@ mod bucketed_history {
1980
1983
if * max_bucket != 0 {
1981
1984
highest_max_bucket_with_points = cmp:: max ( highest_max_bucket_with_points, max_idx) ;
1982
1985
}
1986
+ // In testing, raising the weights of buckets to a high power led to better
1987
+ // scoring results. Thus, we raise the bucket weights to the 4th power here (by
1988
+ // squaring the result of multiplying the weights), matching the logic in
1989
+ // `recalculate_valid_point_count`.
1983
1990
total_weight += ( * max_bucket as u64 ) * ( * max_bucket as u64 )
1984
1991
* ( min_liquidity_offset_history_buckets[ 0 ] as u64 ) * ( min_liquidity_offset_history_buckets[ 0 ] as u64 ) ;
1985
1992
}
@@ -2003,16 +2010,20 @@ mod bucketed_history {
2003
2010
let min_bucket_start_pos = BUCKET_START_POS [ min_idx] ;
2004
2011
for ( max_idx, max_bucket) in max_liquidity_offset_history_buckets. iter ( ) . enumerate ( ) . take ( 32 - min_idx) {
2005
2012
let max_bucket_end_pos = BUCKET_START_POS [ 32 - max_idx] - 1 ;
2006
- let mut bucket_weight = ( * min_bucket as u64 ) * ( * max_bucket as u64 ) ;
2007
- bucket_weight *= bucket_weight;
2008
- debug_assert ! ( bucket_weight as f64 <= total_valid_points_tracked) ;
2009
-
2010
2013
if payment_pos >= max_bucket_end_pos {
2011
2014
// Success probability 0, the payment amount may be above the max liquidity
2012
2015
break ;
2013
2016
}
2014
2017
2018
+ // In testing, raising the weights of buckets to a high power led to better
2019
+ // scoring results. Thus, we raise the bucket weights to the 4th power here (by
2020
+ // squaring the result of multiplying the weights), matching the logic in
2021
+ // `recalculate_valid_point_count`.
2022
+ let mut bucket_weight = ( * min_bucket as u64 ) * ( * max_bucket as u64 ) ;
2023
+ bucket_weight *= bucket_weight;
2024
+ debug_assert ! ( bucket_weight as f64 <= total_valid_points_tracked) ;
2015
2025
let bucket_prob = bucket_weight as f64 / total_valid_points_tracked;
2026
+
2016
2027
if payment_pos < min_bucket_start_pos {
2017
2028
cumulative_success_prob += bucket_prob;
2018
2029
} else {
0 commit comments