@@ -135,7 +135,7 @@ pub struct Config {
135135 /// Maximum total compute unit fee paid for a single transaction. Defaults to 0.001 SOL. This
136136 /// is a safety measure while using dynamic compute price to prevent the exporter from paying
137137 /// too much for a single transaction
138- pub maximum_total_compute_fee_micro_lamports : u64 ,
138+ pub maximum_compute_unit_price_micro_lamports : u64 ,
139139 /// Maximum slot gap between the current slot and the oldest slot amongst all the accounts in
140140 /// the batch. This is used to calculate the dynamic price per compute unit. When the slot gap
141141 /// reaches this number we will use the maximum total_compute_fee for the transaction.
@@ -156,12 +156,12 @@ impl Default for Config {
156156 compute_unit_limit : 40000 ,
157157 compute_unit_price_micro_lamports : None ,
158158 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 ,
161161 // 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 ,
165165 }
166166 }
167167}
@@ -710,17 +710,14 @@ impl Exporter {
710710 // keep the uptime high during congestion whereas without it we would publish price after a
711711 // large gap and then we can publish it again after the next large gap.
712712 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-
716713 // Use the estimated previous price if it is higher
717714 // than the current price.
718715 if let Some ( estimated_recent_price) = self . recent_compute_unit_price_micro_lamports {
719716 // Get the estimated compute unit price and wrap it so it stays below the maximum
720717 // total compute unit fee. We additionally divide such price by 2 to create an
721718 // exponential decay. This will make sure that a spike doesn't get propagated
722719 // forever.
723- let estimated_price = ( estimated_recent_price >> 1 ) . min ( maximum_unit_price ) ;
720+ let estimated_price = estimated_recent_price >> 1 ;
724721
725722 compute_unit_price_micro_lamports = compute_unit_price_micro_lamports
726723 . map ( |price| price. max ( estimated_price) )
@@ -770,7 +767,7 @@ impl Exporter {
770767 // 15 : 3_906
771768 // 13 : 976
772769 // 10 : 122
773- let exponential_price = maximum_unit_price
770+ let exponential_price = self . config . maximum_compute_unit_price_micro_lamports
774771 >> self
775772 . config
776773 . maximum_slot_gap_for_dynamic_compute_unit_price
@@ -782,7 +779,10 @@ impl Exporter {
782779 }
783780 }
784781
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+
786786 debug ! ( self . logger, "setting compute unit price" ; "unit_price" => compute_unit_price_micro_lamports) ;
787787 instructions. push ( ComputeBudgetInstruction :: set_compute_unit_price (
788788 compute_unit_price_micro_lamports,
0 commit comments