@@ -27,6 +27,14 @@ use signet_zenith::{
27
27
use std:: time:: { Instant , UNIX_EPOCH } ;
28
28
use tokio:: { sync:: mpsc, task:: JoinHandle } ;
29
29
30
+ // NB: Consider pulling the below gas parameters out into env vars
31
+ /// Base maximum fee per gas to use as a starting point for retry bumps
32
+ pub const BASE_FEE_PER_GAS : u128 = 10_000_000_000 ; // 10 Gwei
33
+ /// Base max priority fee per gas to use as a starting point for retry bumps
34
+ pub const BASE_MAX_PRIORITY_FEE_PER_GAS : u128 = 2_000_000_000 ; // 2 Gwei
35
+ /// Base maximum fee per blob gas to use as a starting point for retry bumps
36
+ pub const BASE_MAX_FEE_PER_BLOB_GAS : u128 = 1_000_000_000 ; // 1 Gwei
37
+
30
38
macro_rules! spawn_provider_send {
31
39
( $provider: expr, $tx: expr) => {
32
40
{
@@ -88,7 +96,7 @@ impl SubmitTask {
88
96
} )
89
97
}
90
98
91
- /// Builds blob transaction from the provided header and signature values
99
+ /// Builds blob transaction and encodes the sidecar for it from the provided header and signature values
92
100
fn build_blob_tx (
93
101
& self ,
94
102
fills : Vec < FillPermit2 > ,
@@ -187,17 +195,23 @@ impl SubmitTask {
187
195
) -> Result < TransactionRequest , eyre:: Error > {
188
196
// TODO: ENG-1082 Implement fills
189
197
let fills = vec ! [ ] ;
198
+
199
+ // manually retrieve nonce
200
+ let nonce =
201
+ self . provider ( ) . get_transaction_count ( self . provider ( ) . default_signer_address ( ) ) . await ?;
202
+ debug ! ( nonce, "assigned nonce" ) ;
203
+
190
204
// Extract the signature components from the response
191
205
let ( v, r, s) = extract_signature_components ( & resp. sig ) ;
192
206
193
207
// Calculate gas limits based on retry attempts
194
208
let ( max_fee_per_gas, max_priority_fee_per_gas, max_fee_per_blob_gas) =
195
- calculate_gas_limits ( retry_count ) ;
196
-
197
- // manually retrieve nonce // TODO: Maybe this should be done in Env task and passed through elsewhere
198
- let nonce =
199
- self . provider ( ) . get_transaction_count ( self . provider ( ) . default_signer_address ( ) ) . await ? ;
200
- debug ! ( nonce , "assigned nonce" ) ;
209
+ calculate_gas_limits (
210
+ retry_count ,
211
+ BASE_FEE_PER_GAS ,
212
+ BASE_MAX_PRIORITY_FEE_PER_GAS ,
213
+ BASE_MAX_FEE_PER_BLOB_GAS ,
214
+ ) ;
201
215
202
216
// Build the block header
203
217
let header: BlockHeader = BlockHeader {
@@ -429,18 +443,20 @@ impl SubmitTask {
429
443
}
430
444
}
431
445
432
- fn calculate_gas_limits ( retry_count : usize ) -> ( u128 , u128 , u128 ) {
433
- let base_fee_per_gas: u128 = 100_000_000_000 ;
434
- let base_priority_fee_per_gas: u128 = 2_000_000_000 ;
435
- let base_fee_per_blob_gas: u128 = 1_000_000_000 ;
436
-
446
+ // Returns gas parameters based on retry counts. This uses
447
+ fn calculate_gas_limits (
448
+ retry_count : usize ,
449
+ base_max_fee_per_gas : u128 ,
450
+ base_max_priority_fee_per_gas : u128 ,
451
+ base_max_fee_per_blob_gas : u128 ,
452
+ ) -> ( u128 , u128 , u128 ) {
437
453
let bump_multiplier = 1150u128 . pow ( retry_count as u32 ) ; // 15% bump
438
454
let blob_bump_multiplier = 2000u128 . pow ( retry_count as u32 ) ; // 100% bump (double each time) for blob gas
439
455
let bump_divisor = 1000u128 . pow ( retry_count as u32 ) ;
440
456
441
- let max_fee_per_gas = base_fee_per_gas * bump_multiplier / bump_divisor;
442
- let max_priority_fee_per_gas = base_priority_fee_per_gas * bump_multiplier / bump_divisor;
443
- let max_fee_per_blob_gas = base_fee_per_blob_gas * blob_bump_multiplier / bump_divisor;
457
+ let max_fee_per_gas = base_max_fee_per_gas * bump_multiplier / bump_divisor;
458
+ let max_priority_fee_per_gas = base_max_priority_fee_per_gas * bump_multiplier / bump_divisor;
459
+ let max_fee_per_blob_gas = base_max_fee_per_blob_gas * blob_bump_multiplier / bump_divisor;
444
460
445
461
debug ! (
446
462
retry_count,
0 commit comments