@@ -1864,6 +1864,9 @@ mod bucketed_history {
1864
1864
let mut total_valid_points_tracked = 0 ;
1865
1865
for ( min_idx, min_bucket) in self . min_liquidity_offset_history . buckets . iter ( ) . enumerate ( ) {
1866
1866
for max_bucket in self . max_liquidity_offset_history . buckets . iter ( ) . take ( 32 - min_idx) {
1867
+ // In testing, raising the weights of buckets to a high power led to better
1868
+ // scoring results. Thus, we raise the bucket weights to the 4th power here (by
1869
+ // squaring the result of multiplying the weights).
1867
1870
let mut bucket_weight = ( * min_bucket as u64 ) * ( * max_bucket as u64 ) ;
1868
1871
bucket_weight *= bucket_weight;
1869
1872
total_valid_points_tracked += bucket_weight;
@@ -1992,6 +1995,10 @@ mod bucketed_history {
1992
1995
if * max_bucket != 0 {
1993
1996
highest_max_bucket_with_points = cmp:: max ( highest_max_bucket_with_points, max_idx) ;
1994
1997
}
1998
+ // In testing, raising the weights of buckets to a high power led to better
1999
+ // scoring results. Thus, we raise the bucket weights to the 4th power here (by
2000
+ // squaring the result of multiplying the weights), matching the logic in
2001
+ // `recalculate_valid_point_count`.
1995
2002
total_weight += ( * max_bucket as u64 ) * ( * max_bucket as u64 )
1996
2003
* ( min_liquidity_offset_history_buckets[ 0 ] as u64 ) * ( min_liquidity_offset_history_buckets[ 0 ] as u64 ) ;
1997
2004
}
@@ -2015,16 +2022,20 @@ mod bucketed_history {
2015
2022
let min_bucket_start_pos = BUCKET_START_POS [ min_idx] ;
2016
2023
for ( max_idx, max_bucket) in max_liquidity_offset_history_buckets. iter ( ) . enumerate ( ) . take ( 32 - min_idx) {
2017
2024
let max_bucket_end_pos = BUCKET_START_POS [ 32 - max_idx] - 1 ;
2018
- let mut bucket_weight = ( * min_bucket as u64 ) * ( * max_bucket as u64 ) ;
2019
- bucket_weight *= bucket_weight;
2020
- debug_assert ! ( bucket_weight as f64 <= total_valid_points_tracked) ;
2021
-
2022
2025
if payment_pos >= max_bucket_end_pos {
2023
2026
// Success probability 0, the payment amount may be above the max liquidity
2024
2027
break ;
2025
2028
}
2026
2029
2030
+ // In testing, raising the weights of buckets to a high power led to better
2031
+ // scoring results. Thus, we raise the bucket weights to the 4th power here (by
2032
+ // squaring the result of multiplying the weights), matching the logic in
2033
+ // `recalculate_valid_point_count`.
2034
+ let mut bucket_weight = ( * min_bucket as u64 ) * ( * max_bucket as u64 ) ;
2035
+ bucket_weight *= bucket_weight;
2036
+ debug_assert ! ( bucket_weight as f64 <= total_valid_points_tracked) ;
2027
2037
let bucket_prob = bucket_weight as f64 / total_valid_points_tracked;
2038
+
2028
2039
if payment_pos < min_bucket_start_pos {
2029
2040
cumulative_success_prob += bucket_prob;
2030
2041
} else {
0 commit comments