11use crate :: {
22 config:: { HostProvider , ZenithInstance } ,
33 quincey:: Quincey ,
4- utils:: extract_signature_components,
4+ utils:: { self , extract_signature_components} ,
55} ;
66use alloy:: {
77 consensus:: { Header , SimpleCoder , constants:: GWEI_TO_WEI } ,
@@ -16,15 +16,16 @@ use alloy::{
1616use eyre:: bail;
1717use init4_bin_base:: deps:: {
1818 metrics:: { counter, histogram} ,
19- tracing:: { Instrument , debug, debug_span, error, info, instrument, warn} ,
19+ tracing:: { Instrument , debug, debug_span, error, info, instrument, trace , warn} ,
2020} ;
21+ use signet_constants:: SignetSystemConstants ;
2122use signet_sim:: BuiltBlock ;
2223use signet_types:: { SignRequest , SignResponse } ;
2324use signet_zenith:: {
2425 BundleHelper :: { self , BlockHeader , FillPermit2 , submitCall} ,
2526 Zenith :: { self , IncorrectHostBlock } ,
2627} ;
27- use std:: time:: { Instant , UNIX_EPOCH } ;
28+ use std:: time:: Instant ;
2829use tokio:: {
2930 sync:: mpsc:: { self } ,
3031 task:: JoinHandle ,
@@ -191,6 +192,8 @@ pub struct SubmitTask {
191192 pub zenith : ZenithInstance ,
192193 /// Quincey
193194 pub quincey : Quincey ,
195+ /// Constants
196+ pub constants : SignetSystemConstants ,
194197 /// Config
195198 pub config : crate :: config:: BuilderConfig ,
196199 /// Channel over which to send pending transactions
@@ -207,16 +210,18 @@ impl SubmitTask {
207210
208211 /// Constructs the signing request from the in-progress block passed to it and assigns the
209212 /// 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) ,
214219 host_chain_id : U256 :: from ( self . config . host_chain_id ) ,
215220 ru_chain_id : U256 :: from ( self . config . ru_chain_id ) ,
216221 gas_limit : U256 :: from ( self . config . rollup_block_gas_limit ) ,
217222 ru_reward_address : self . config . builder_rewards_address ,
218223 contents : * contents. contents_hash ( ) ,
219- } )
224+ }
220225 }
221226
222227 /// Encodes the sidecar and then builds the 4844 blob transaction from the provided header and signature values.
@@ -328,7 +333,7 @@ impl SubmitTask {
328333 debug ! ( ?header. hostBlockNumber, "built rollup block header" ) ;
329334
330335 // Extract fills from the built block
331- let fills = self . extract_fills ( block) ;
336+ let fills = utils :: convert_fills ( block) ;
332337 debug ! ( fill_count = fills. len( ) , "extracted fills from rollup block" ) ;
333338
334339 // Create a blob transaction with the blob header and signature values and return it
@@ -399,11 +404,7 @@ impl SubmitTask {
399404 block : & BuiltBlock ,
400405 ) -> eyre:: Result < ControlFlow > {
401406 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) ;
407408
408409 debug ! (
409410 host_block_number = %sig_request. host_block_number,
@@ -493,29 +494,12 @@ impl SubmitTask {
493494
494495 /// Calculates and returns the slot number and its start and end timestamps for the current instant.
495496 fn calculate_slot_window ( & self ) -> ( u64 , u64 , u64 ) {
496- let now_ts = self . now ( ) ;
497+ let now_ts = utils :: now ( ) ;
497498 let current_slot = self . config . slot_calculator . calculate_slot ( now_ts) ;
498499 let ( start, end) = self . config . slot_calculator . calculate_slot_window ( current_slot) ;
499500 ( current_slot, start, end)
500501 }
501502
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-
519503 /// Task future for the submit task. This function runs the main loop of the task.
520504 async fn task_future ( self , mut inbound : mpsc:: UnboundedReceiver < SimResult > ) {
521505 loop {
@@ -590,7 +574,7 @@ pub fn bump_gas_from_retries(
590574 let max_fee_per_gas = ( basefee as u128 ) * BASE_MULTIPLIER + ( priority_fee as u128 ) ;
591575 let max_fee_per_blob_gas = blob_basefee * BLOB_MULTIPLIER * ( retry_count as u128 + 1 ) ;
592576
593- debug ! (
577+ trace ! (
594578 retry_count,
595579 max_fee_per_gas, priority_fee, max_fee_per_blob_gas, "calculated bumped gas parameters"
596580 ) ;
0 commit comments