@@ -4,7 +4,7 @@ use crate::{
4
4
utils:: extract_signature_components,
5
5
} ;
6
6
use alloy:: {
7
- consensus:: { SimpleCoder , Transaction , constants :: GWEI_TO_WEI } ,
7
+ consensus:: SimpleCoder ,
8
8
eips:: BlockNumberOrTag ,
9
9
network:: { TransactionBuilder , TransactionBuilder4844 } ,
10
10
primitives:: { FixedBytes , TxHash , U256 } ,
@@ -101,10 +101,8 @@ impl SubmitTask {
101
101
let data = submitCall { fills, header, v, r, s } . abi_encode ( ) ;
102
102
103
103
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) )
108
106
}
109
107
110
108
/// Returns the next host block height.
@@ -169,7 +167,7 @@ impl SubmitTask {
169
167
. unwrap_or_default ( )
170
168
{
171
169
debug ! ( %e, "incorrect host block" ) ;
172
- return Some ( Ok ( ControlFlow :: Retry ) ) ;
170
+ return Some ( Ok ( ControlFlow :: Skip ) ) ;
173
171
}
174
172
175
173
if e. as_revert_data ( )
@@ -208,7 +206,8 @@ impl SubmitTask {
208
206
let ( v, r, s) = extract_signature_components ( & resp. sig ) ;
209
207
210
208
// 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) ;
212
211
213
212
// manually retrieve nonce
214
213
let nonce =
@@ -228,12 +227,12 @@ impl SubmitTask {
228
227
// Create a blob transaction with the blob header and signature values and return it
229
228
let tx = self
230
229
. 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);
237
236
238
237
debug ! ( ?tx, "prepared transaction request" ) ;
239
238
Ok ( tx)
@@ -247,20 +246,18 @@ impl SubmitTask {
247
246
tx : TransactionRequest ,
248
247
) -> Result < ControlFlow , eyre:: Error > {
249
248
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,
254
250
host_block_number = %resp. req. host_block_number,
255
251
gas_limit = %resp. req. gas_limit,
256
252
"sending transaction to network"
257
253
) ;
258
254
259
255
// assign the nonce and fill the rest of the values
256
+ debug ! ( ?tx, "blob transaction request before fill" ) ;
260
257
let SendableTx :: Envelope ( tx) = self . provider ( ) . fill ( tx) . await ? else {
261
258
bail ! ( "failed to fill transaction" )
262
259
} ;
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" ) ;
264
261
265
262
// send the tx via the primary host_provider
266
263
let fut = spawn_provider_send ! ( self . provider( ) , & tx) ;
@@ -280,8 +277,7 @@ impl SubmitTask {
280
277
if let Err ( e) = fut. await ? {
281
278
let err_str = e. to_string ( ) ;
282
279
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" ) ;
285
281
return Ok ( ControlFlow :: Retry ) ;
286
282
}
287
283
error ! ( error = %e, "Primary tx broadcast failed. Skipping transaction." ) ;
@@ -349,16 +345,16 @@ impl SubmitTask {
349
345
control_flow
350
346
}
351
347
Err ( err) => {
352
- retries += 1 ;
353
348
// Delay until next slot if we get a 403 error
354
349
if err. to_string ( ) . contains ( "403 Forbidden" ) {
355
350
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" ) ;
357
352
return Ok ( ControlFlow :: Skip ) ;
358
353
} else {
359
354
error ! ( error = %err, "error handling inbound block" ) ;
360
355
}
361
356
357
+ retries += 1 ;
362
358
ControlFlow :: Retry
363
359
}
364
360
} ;
@@ -442,7 +438,7 @@ impl SubmitTask {
442
438
last_block_attempted = block. block_number ( ) ;
443
439
debug ! ( last_block_attempted, "resetting last block attempted" ) ;
444
440
445
- if self . retrying_handle_inbound ( & block, 3 ) . await . is_err ( ) {
441
+ if self . retrying_handle_inbound ( & block, 10 ) . await . is_err ( ) {
446
442
debug ! ( "error handling inbound block" ) ;
447
443
continue ;
448
444
} ;
@@ -458,20 +454,25 @@ impl SubmitTask {
458
454
}
459
455
}
460
456
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;
471
468
472
469
debug ! (
473
470
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"
475
475
) ;
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)
477
478
}
0 commit comments