1
1
use crate :: {
2
2
config:: { HostProvider , ZenithInstance } ,
3
3
quincey:: Quincey ,
4
- utils:: extract_signature_components,
4
+ utils:: { self , extract_signature_components} ,
5
5
} ;
6
6
use alloy:: {
7
7
consensus:: { Header , SimpleCoder , constants:: GWEI_TO_WEI } ,
@@ -16,15 +16,16 @@ use alloy::{
16
16
use eyre:: bail;
17
17
use init4_bin_base:: deps:: {
18
18
metrics:: { counter, histogram} ,
19
- tracing:: { Instrument , debug, debug_span, error, info, instrument, warn} ,
19
+ tracing:: { Instrument , debug, debug_span, error, info, instrument, trace , warn} ,
20
20
} ;
21
+ use signet_constants:: SignetSystemConstants ;
21
22
use signet_sim:: BuiltBlock ;
22
23
use signet_types:: { SignRequest , SignResponse } ;
23
24
use signet_zenith:: {
24
25
BundleHelper :: { self , BlockHeader , FillPermit2 , submitCall} ,
25
26
Zenith :: { self , IncorrectHostBlock } ,
26
27
} ;
27
- use std:: time:: { Instant , UNIX_EPOCH } ;
28
+ use std:: time:: Instant ;
28
29
use tokio:: {
29
30
sync:: mpsc:: { self } ,
30
31
task:: JoinHandle ,
@@ -191,6 +192,8 @@ pub struct SubmitTask {
191
192
pub zenith : ZenithInstance ,
192
193
/// Quincey
193
194
pub quincey : Quincey ,
195
+ /// Constants
196
+ pub constants : SignetSystemConstants ,
194
197
/// Config
195
198
pub config : crate :: config:: BuilderConfig ,
196
199
/// Channel over which to send pending transactions
@@ -207,16 +210,18 @@ impl SubmitTask {
207
210
208
211
/// Constructs the signing request from the in-progress block passed to it and assigns the
209
212
/// correct height, chain ID, gas limit, and rollup reward address.
210
- #[ instrument( skip_all) ]
211
- async fn construct_sig_request ( & self , contents : & BuiltBlock ) -> eyre:: Result < SignRequest > {
212
- Ok ( SignRequest {
213
- host_block_number : U256 :: from ( self . next_host_block_height ( ) . await ?) ,
213
+ fn construct_sig_request ( & self , contents : & BuiltBlock ) -> SignRequest {
214
+ let host_block_number =
215
+ self . constants . rollup_block_to_host_block_num ( contents. block_number ( ) ) ;
216
+
217
+ SignRequest {
218
+ host_block_number : U256 :: from ( host_block_number) ,
214
219
host_chain_id : U256 :: from ( self . config . host_chain_id ) ,
215
220
ru_chain_id : U256 :: from ( self . config . ru_chain_id ) ,
216
221
gas_limit : U256 :: from ( self . config . rollup_block_gas_limit ) ,
217
222
ru_reward_address : self . config . builder_rewards_address ,
218
223
contents : * contents. contents_hash ( ) ,
219
- } )
224
+ }
220
225
}
221
226
222
227
/// Encodes the sidecar and then builds the 4844 blob transaction from the provided header and signature values.
@@ -328,7 +333,7 @@ impl SubmitTask {
328
333
debug ! ( ?header. hostBlockNumber, "built rollup block header" ) ;
329
334
330
335
// Extract fills from the built block
331
- let fills = self . extract_fills ( block) ;
336
+ let fills = utils :: convert_fills ( block) ;
332
337
debug ! ( fill_count = fills. len( ) , "extracted fills from rollup block" ) ;
333
338
334
339
// Create a blob transaction with the blob header and signature values and return it
@@ -399,11 +404,7 @@ impl SubmitTask {
399
404
block : & BuiltBlock ,
400
405
) -> eyre:: Result < ControlFlow > {
401
406
info ! ( retry_count, txns = block. tx_count( ) , "handling inbound block" ) ;
402
- let Ok ( sig_request) = self . construct_sig_request ( block) . await . inspect_err ( |e| {
403
- error ! ( error = %e, "error constructing signature request" ) ;
404
- } ) else {
405
- return Ok ( ControlFlow :: Skip ) ;
406
- } ;
407
+ let sig_request = self . construct_sig_request ( block) ;
407
408
408
409
debug ! (
409
410
host_block_number = %sig_request. host_block_number,
@@ -493,29 +494,12 @@ impl SubmitTask {
493
494
494
495
/// Calculates and returns the slot number and its start and end timestamps for the current instant.
495
496
fn calculate_slot_window ( & self ) -> ( u64 , u64 , u64 ) {
496
- let now_ts = self . now ( ) ;
497
+ let now_ts = utils :: now ( ) ;
497
498
let current_slot = self . config . slot_calculator . calculate_slot ( now_ts) ;
498
499
let ( start, end) = self . config . slot_calculator . calculate_slot_window ( current_slot) ;
499
500
( current_slot, start, end)
500
501
}
501
502
502
- /// Returns the current timestamp in seconds since the UNIX epoch.
503
- fn now ( & self ) -> u64 {
504
- let now = std:: time:: SystemTime :: now ( ) ;
505
- now. duration_since ( UNIX_EPOCH ) . unwrap ( ) . as_secs ( )
506
- }
507
-
508
- /// Returns the next host block height.
509
- async fn next_host_block_height ( & self ) -> eyre:: Result < u64 > {
510
- let block_num = self . provider ( ) . get_block_number ( ) . await ?;
511
- Ok ( block_num + 1 )
512
- }
513
-
514
- // This function converts &[SignedFill] into [FillPermit2]
515
- fn extract_fills ( & self , block : & BuiltBlock ) -> Vec < FillPermit2 > {
516
- block. host_fills ( ) . iter ( ) . map ( FillPermit2 :: from) . collect ( )
517
- }
518
-
519
503
/// Task future for the submit task. This function runs the main loop of the task.
520
504
async fn task_future ( self , mut inbound : mpsc:: UnboundedReceiver < SimResult > ) {
521
505
loop {
@@ -590,7 +574,7 @@ pub fn bump_gas_from_retries(
590
574
let max_fee_per_gas = ( basefee as u128 ) * BASE_MULTIPLIER + ( priority_fee as u128 ) ;
591
575
let max_fee_per_blob_gas = blob_basefee * BLOB_MULTIPLIER * ( retry_count as u128 + 1 ) ;
592
576
593
- debug ! (
577
+ trace ! (
594
578
retry_count,
595
579
max_fee_per_gas, priority_fee, max_fee_per_blob_gas, "calculated bumped gas parameters"
596
580
) ;
0 commit comments