@@ -1852,6 +1852,9 @@ mod bucketed_history {
18521852 let mut total_valid_points_tracked = 0 ;
18531853 for ( min_idx, min_bucket) in self . min_liquidity_offset_history . buckets . iter ( ) . enumerate ( ) {
18541854 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).
18551858 let mut bucket_weight = ( * min_bucket as u64 ) * ( * max_bucket as u64 ) ;
18561859 bucket_weight *= bucket_weight;
18571860 total_valid_points_tracked += bucket_weight;
@@ -1980,6 +1983,10 @@ mod bucketed_history {
19801983 if * max_bucket != 0 {
19811984 highest_max_bucket_with_points = cmp:: max ( highest_max_bucket_with_points, max_idx) ;
19821985 }
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`.
19831990 total_weight += ( * max_bucket as u64 ) * ( * max_bucket as u64 )
19841991 * ( min_liquidity_offset_history_buckets[ 0 ] as u64 ) * ( min_liquidity_offset_history_buckets[ 0 ] as u64 ) ;
19851992 }
@@ -2003,16 +2010,20 @@ mod bucketed_history {
20032010 let min_bucket_start_pos = BUCKET_START_POS [ min_idx] ;
20042011 for ( max_idx, max_bucket) in max_liquidity_offset_history_buckets. iter ( ) . enumerate ( ) . take ( 32 - min_idx) {
20052012 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-
20102013 if payment_pos >= max_bucket_end_pos {
20112014 // Success probability 0, the payment amount may be above the max liquidity
20122015 break ;
20132016 }
20142017
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) ;
20152025 let bucket_prob = bucket_weight as f64 / total_valid_points_tracked;
2026+
20162027 if payment_pos < min_bucket_start_pos {
20172028 cumulative_success_prob += bucket_prob;
20182029 } else {
0 commit comments