@@ -4,7 +4,7 @@ use crate::{
44 utils:: extract_signature_components,
55} ;
66use alloy:: {
7- consensus:: { SimpleCoder , Transaction , constants :: GWEI_TO_WEI } ,
7+ consensus:: SimpleCoder ,
88 eips:: BlockNumberOrTag ,
99 network:: { TransactionBuilder , TransactionBuilder4844 } ,
1010 primitives:: { FixedBytes , TxHash , U256 } ,
@@ -101,10 +101,8 @@ impl SubmitTask {
101101 let data = submitCall { fills, header, v, r, s } . abi_encode ( ) ;
102102
103103 let sidecar = block. encode_blob :: < SimpleCoder > ( ) . build ( ) ?;
104- Ok ( TransactionRequest :: default ( )
105- . with_blob_sidecar ( sidecar)
106- . with_input ( data)
107- . with_max_priority_fee_per_gas ( ( GWEI_TO_WEI * 16 ) as u128 ) )
104+
105+ Ok ( TransactionRequest :: default ( ) . with_blob_sidecar ( sidecar) . with_input ( data) )
108106 }
109107
110108 /// Returns the next host block height.
@@ -169,7 +167,7 @@ impl SubmitTask {
169167 . unwrap_or_default ( )
170168 {
171169 debug ! ( %e, "incorrect host block" ) ;
172- return Some ( Ok ( ControlFlow :: Retry ) ) ;
170+ return Some ( Ok ( ControlFlow :: Skip ) ) ;
173171 }
174172
175173 if e. as_revert_data ( )
@@ -208,7 +206,8 @@ impl SubmitTask {
208206 let ( v, r, s) = extract_signature_components ( & resp. sig ) ;
209207
210208 // Calculate gas limits based on retry attempts
211- let ( max_fee_per_gas, max_priority_fee_per_gas) = calculate_gas_limits ( retry_count) ;
209+ let ( max_fee_per_gas, max_priority_fee_per_gas, max_fee_per_blob_gas) =
210+ calculate_gas_limits ( retry_count) ;
212211
213212 // manually retrieve nonce
214213 let nonce =
@@ -228,12 +227,12 @@ impl SubmitTask {
228227 // Create a blob transaction with the blob header and signature values and return it
229228 let tx = self
230229 . build_blob_tx ( fills, header, v, r, s, block) ?
231- . with_from ( self . provider ( ) . default_signer_address ( ) )
232- . with_to ( self . config . builder_helper_address )
233- . with_max_fee_per_gas ( max_fee_per_gas. into ( ) )
234- . with_max_priority_fee_per_gas ( max_priority_fee_per_gas)
235- . with_max_fee_per_blob_gas ( max_fee_per_gas )
236- . with_nonce ( nonce) ;
230+ // .with_from(self.provider().default_signer_address())
231+ . with_to ( self . config . builder_helper_address ) ;
232+ // .with_max_fee_per_gas(max_fee_per_gas)
233+ // .with_max_priority_fee_per_gas(max_priority_fee_per_gas)
234+ // .with_max_fee_per_blob_gas(max_fee_per_blob_gas )
235+ // .with_nonce(nonce);
237236
238237 debug ! ( ?tx, "prepared transaction request" ) ;
239238 Ok ( tx)
@@ -247,20 +246,18 @@ impl SubmitTask {
247246 tx : TransactionRequest ,
248247 ) -> Result < ControlFlow , eyre:: Error > {
249248 debug ! (
250- ?tx. max_fee_per_gas,
251- ?tx. max_fee_per_blob_gas,
252- ?tx. max_priority_fee_per_gas,
253- nonce = ?tx. nonce,
249+ ?tx,
254250 host_block_number = %resp. req. host_block_number,
255251 gas_limit = %resp. req. gas_limit,
256252 "sending transaction to network"
257253 ) ;
258254
259255 // assign the nonce and fill the rest of the values
256+ debug ! ( ?tx, "blob transaction request before fill" ) ;
260257 let SendableTx :: Envelope ( tx) = self . provider ( ) . fill ( tx) . await ? else {
261258 bail ! ( "failed to fill transaction" )
262259 } ;
263- debug ! ( tx_hash = %tx . tx_hash ( ) , nonce = ?tx. nonce ( ) , gas_limit = ?tx . gas_limit ( ) , blob_gas_used = ?tx . blob_gas_used ( ) , "filled blob transaction" ) ;
260+ debug ! ( ?tx, "filled blob transaction" ) ;
264261
265262 // send the tx via the primary host_provider
266263 let fut = spawn_provider_send ! ( self . provider( ) , & tx) ;
@@ -280,8 +277,7 @@ impl SubmitTask {
280277 if let Err ( e) = fut. await ? {
281278 let err_str = e. to_string ( ) ;
282279 if err_str. contains ( "replacement transaction underpriced" ) {
283- // bump gas and repeat
284- debug ! ( "UNDERPRICE ERROR DETECTED" ) ;
280+ debug ! ( ?tx, "underpriced transaction error - retrying tx with gas bump" ) ;
285281 return Ok ( ControlFlow :: Retry ) ;
286282 }
287283 error ! ( error = %e, "Primary tx broadcast failed. Skipping transaction." ) ;
@@ -349,16 +345,16 @@ impl SubmitTask {
349345 control_flow
350346 }
351347 Err ( err) => {
352- retries += 1 ;
353348 // Delay until next slot if we get a 403 error
354349 if err. to_string ( ) . contains ( "403 Forbidden" ) {
355350 let ( slot_number, _, _) = self . calculate_slot_window ( ) ?;
356- debug ! ( slot_number, ?block , "403 detected - not assigned to slot" ) ;
351+ debug ! ( slot_number, "403 detected - skipping slot" ) ;
357352 return Ok ( ControlFlow :: Skip ) ;
358353 } else {
359354 error ! ( error = %err, "error handling inbound block" ) ;
360355 }
361356
357+ retries += 1 ;
362358 ControlFlow :: Retry
363359 }
364360 } ;
@@ -442,7 +438,7 @@ impl SubmitTask {
442438 last_block_attempted = block. block_number ( ) ;
443439 debug ! ( last_block_attempted, "resetting last block attempted" ) ;
444440
445- if self . retrying_handle_inbound ( & block, 3 ) . await . is_err ( ) {
441+ if self . retrying_handle_inbound ( & block, 10 ) . await . is_err ( ) {
446442 debug ! ( "error handling inbound block" ) ;
447443 continue ;
448444 } ;
@@ -458,20 +454,25 @@ impl SubmitTask {
458454 }
459455}
460456
461- fn calculate_gas_limits ( retry_count : usize ) -> ( u128 , u128 ) {
462- // Set a base gas amount
463- let base_gas = 1_500_000 ;
464- // Define a gas coefficient
465- let gas_coefficient: u64 = 1 + ( retry_count as u64 ) ;
466- // Determine gas limit by multiplying base gas by the coefficient
467- let max_fee_per_gas: u128 = ( base_gas + ( gas_coefficient * base_gas) ) as u128 ;
468- // Determine priority gas fee by multiplying retry count by the coefficient
469- let max_priority_fee_per_gas: u128 =
470- ( 1 + retry_count as u128 ) * ( gas_coefficient as u128 * 100_000 ) ;
457+ fn calculate_gas_limits ( retry_count : usize ) -> ( u128 , u128 , u128 ) {
458+ let base_fee_per_gas: u128 = 60_000_000 ;
459+ let base_priority_fee_per_gas: u128 = 20_000_000 ;
460+ let base_fee_per_blob_gas: u128 = 1_000_000 ;
461+
462+ let bump_multiplier = 1500u128 . pow ( retry_count as u32 ) ;
463+ let bump_divisor = 1000u128 . pow ( retry_count as u32 ) ;
464+
465+ let max_fee_per_gas = base_fee_per_gas * bump_multiplier / bump_divisor;
466+ let max_priority_fee_per_gas = base_priority_fee_per_gas * bump_multiplier / bump_divisor;
467+ let max_fee_per_blob_gas = base_fee_per_blob_gas * bump_multiplier / bump_divisor;
471468
472469 debug ! (
473470 retry_count,
474- gas_coefficient, max_fee_per_gas, max_priority_fee_per_gas, "calculated gas limits"
471+ max_fee_per_gas,
472+ max_priority_fee_per_gas,
473+ max_fee_per_blob_gas,
474+ "calculated bumped gas parameters"
475475 ) ;
476- ( max_fee_per_gas, max_priority_fee_per_gas)
476+
477+ ( max_fee_per_gas, max_priority_fee_per_gas, max_fee_per_blob_gas)
477478}
0 commit comments