@@ -135,7 +135,7 @@ pub struct Config {
135
135
/// Maximum total compute unit fee paid for a single transaction. Defaults to 0.001 SOL. This
136
136
/// is a safety measure while using dynamic compute price to prevent the exporter from paying
137
137
/// too much for a single transaction
138
- pub maximum_total_compute_fee_micro_lamports : u64 ,
138
+ pub maximum_compute_unit_price_micro_lamports : u64 ,
139
139
/// Maximum slot gap between the current slot and the oldest slot amongst all the accounts in
140
140
/// the batch. This is used to calculate the dynamic price per compute unit. When the slot gap
141
141
/// reaches this number we will use the maximum total_compute_fee for the transaction.
@@ -156,12 +156,12 @@ impl Default for Config {
156
156
compute_unit_limit : 40000 ,
157
157
compute_unit_price_micro_lamports : None ,
158
158
dynamic_compute_unit_pricing_enabled : false ,
159
- // Maximum total compute unit fee paid for a single transaction (0.00003 SOL )
160
- maximum_total_compute_fee_micro_lamports : 30_000_000_000 ,
159
+ // Maximum compute unit price (as a cap on the dynamic price )
160
+ maximum_compute_unit_price_micro_lamports : 1_000_000 ,
161
161
// A publisher update is not included if it is 25 slots behind the current slot.
162
- // Due to the delay in the network (until a block gets confirmed) we add 5 slots
163
- // to make sure we do not overpay.
164
- maximum_slot_gap_for_dynamic_compute_unit_price : 30 ,
162
+ // Due to the delay in the network (until a block gets confirmed) and potential
163
+ // ws issues we add 15 slots to make sure we do not overpay.
164
+ maximum_slot_gap_for_dynamic_compute_unit_price : 40 ,
165
165
}
166
166
}
167
167
}
@@ -710,17 +710,14 @@ impl Exporter {
710
710
// keep the uptime high during congestion whereas without it we would publish price after a
711
711
// large gap and then we can publish it again after the next large gap.
712
712
if self . config . dynamic_compute_unit_pricing_enabled {
713
- let maximum_unit_price =
714
- self . config . maximum_total_compute_fee_micro_lamports / total_compute_limit as u64 ;
715
-
716
713
// Use the estimated previous price if it is higher
717
714
// than the current price.
718
715
if let Some ( estimated_recent_price) = self . recent_compute_unit_price_micro_lamports {
719
716
// Get the estimated compute unit price and wrap it so it stays below the maximum
720
717
// total compute unit fee. We additionally divide such price by 2 to create an
721
718
// exponential decay. This will make sure that a spike doesn't get propagated
722
719
// forever.
723
- let estimated_price = ( estimated_recent_price >> 1 ) . min ( maximum_unit_price ) ;
720
+ let estimated_price = estimated_recent_price >> 1 ;
724
721
725
722
compute_unit_price_micro_lamports = compute_unit_price_micro_lamports
726
723
. map ( |price| price. max ( estimated_price) )
@@ -770,7 +767,7 @@ impl Exporter {
770
767
// 15 : 3_906
771
768
// 13 : 976
772
769
// 10 : 122
773
- let exponential_price = maximum_unit_price
770
+ let exponential_price = self . config . maximum_compute_unit_price_micro_lamports
774
771
>> self
775
772
. config
776
773
. maximum_slot_gap_for_dynamic_compute_unit_price
@@ -782,7 +779,10 @@ impl Exporter {
782
779
}
783
780
}
784
781
785
- if let Some ( compute_unit_price_micro_lamports) = compute_unit_price_micro_lamports {
782
+ if let Some ( mut compute_unit_price_micro_lamports) = compute_unit_price_micro_lamports {
783
+ compute_unit_price_micro_lamports = compute_unit_price_micro_lamports
784
+ . min ( self . config . maximum_compute_unit_price_micro_lamports ) ;
785
+
786
786
debug ! ( self . logger, "setting compute unit price" ; "unit_price" => compute_unit_price_micro_lamports) ;
787
787
instructions. push ( ComputeBudgetInstruction :: set_compute_unit_price (
788
788
compute_unit_price_micro_lamports,
0 commit comments