@@ -2,7 +2,7 @@ use crate::tasks::block::sim::SimResult;
22use crate :: {
33 config:: { HostProvider , ZenithInstance } ,
44 quincey:: Quincey ,
5- utils:: extract_signature_components,
5+ utils:: { self , extract_signature_components} ,
66} ;
77use alloy:: {
88 consensus:: { Header , SimpleCoder , constants:: GWEI_TO_WEI } ,
@@ -17,15 +17,16 @@ use alloy::{
1717use eyre:: bail;
1818use init4_bin_base:: deps:: {
1919 metrics:: { counter, histogram} ,
20- tracing:: { Instrument , debug, debug_span, error, info, instrument, warn} ,
20+ tracing:: { Instrument , debug, debug_span, error, info, instrument, trace , warn} ,
2121} ;
22+ use signet_constants:: SignetSystemConstants ;
2223use signet_sim:: BuiltBlock ;
2324use signet_types:: { SignRequest , SignResponse } ;
2425use signet_zenith:: {
2526 BundleHelper :: { self , BlockHeader , FillPermit2 , submitCall} ,
2627 Zenith :: { self , IncorrectHostBlock } ,
2728} ;
28- use std:: time:: { Instant , UNIX_EPOCH } ;
29+ use std:: time:: Instant ;
2930use tokio:: {
3031 sync:: mpsc:: { self } ,
3132 task:: JoinHandle ,
@@ -190,6 +191,8 @@ pub struct SubmitTask {
190191 pub zenith : ZenithInstance ,
191192 /// Quincey
192193 pub quincey : Quincey ,
194+ /// Constants
195+ pub constants : SignetSystemConstants ,
193196 /// Config
194197 pub config : crate :: config:: BuilderConfig ,
195198 /// Channel over which to send pending transactions
@@ -206,16 +209,18 @@ impl SubmitTask {
206209
207210 /// Constructs the signing request from the in-progress block passed to it and assigns the
208211 /// correct height, chain ID, gas limit, and rollup reward address.
209- #[ instrument( skip_all) ]
210- async fn construct_sig_request ( & self , contents : & BuiltBlock ) -> eyre:: Result < SignRequest > {
211- Ok ( SignRequest {
212- host_block_number : U256 :: from ( self . next_host_block_height ( ) . await ?) ,
212+ fn construct_sig_request ( & self , contents : & BuiltBlock ) -> SignRequest {
213+ let host_block_number =
214+ self . constants . rollup_block_to_host_block_num ( contents. block_number ( ) ) ;
215+
216+ SignRequest {
217+ host_block_number : U256 :: from ( host_block_number) ,
213218 host_chain_id : U256 :: from ( self . config . host_chain_id ) ,
214219 ru_chain_id : U256 :: from ( self . config . ru_chain_id ) ,
215220 gas_limit : U256 :: from ( self . config . rollup_block_gas_limit ) ,
216221 ru_reward_address : self . config . builder_rewards_address ,
217222 contents : * contents. contents_hash ( ) ,
218- } )
223+ }
219224 }
220225
221226 /// Encodes the sidecar and then builds the 4844 blob transaction from the provided header and signature values.
@@ -327,7 +332,7 @@ impl SubmitTask {
327332 debug ! ( ?header. hostBlockNumber, "built rollup block header" ) ;
328333
329334 // Extract fills from the built block
330- let fills = self . extract_fills ( block) ;
335+ let fills = utils :: convert_fills ( block) ;
331336 debug ! ( fill_count = fills. len( ) , "extracted fills from rollup block" ) ;
332337
333338 // Create a blob transaction with the blob header and signature values and return it
@@ -398,11 +403,7 @@ impl SubmitTask {
398403 block : & BuiltBlock ,
399404 ) -> eyre:: Result < ControlFlow > {
400405 info ! ( retry_count, txns = block. tx_count( ) , "handling inbound block" ) ;
401- let Ok ( sig_request) = self . construct_sig_request ( block) . await . inspect_err ( |e| {
402- error ! ( error = %e, "error constructing signature request" ) ;
403- } ) else {
404- return Ok ( ControlFlow :: Skip ) ;
405- } ;
406+ let sig_request = self . construct_sig_request ( block) ;
406407
407408 debug ! (
408409 host_block_number = %sig_request. host_block_number,
@@ -492,29 +493,12 @@ impl SubmitTask {
492493
493494 /// Calculates and returns the slot number and its start and end timestamps for the current instant.
494495 fn calculate_slot_window ( & self ) -> ( u64 , u64 , u64 ) {
495- let now_ts = self . now ( ) ;
496+ let now_ts = utils :: now ( ) ;
496497 let current_slot = self . config . slot_calculator . calculate_slot ( now_ts) ;
497498 let ( start, end) = self . config . slot_calculator . calculate_slot_window ( current_slot) ;
498499 ( current_slot, start, end)
499500 }
500501
501- /// Returns the current timestamp in seconds since the UNIX epoch.
502- fn now ( & self ) -> u64 {
503- let now = std:: time:: SystemTime :: now ( ) ;
504- now. duration_since ( UNIX_EPOCH ) . unwrap ( ) . as_secs ( )
505- }
506-
507- /// Returns the next host block height.
508- async fn next_host_block_height ( & self ) -> eyre:: Result < u64 > {
509- let block_num = self . provider ( ) . get_block_number ( ) . await ?;
510- Ok ( block_num + 1 )
511- }
512-
513- // This function converts &[SignedFill] into [FillPermit2]
514- fn extract_fills ( & self , block : & BuiltBlock ) -> Vec < FillPermit2 > {
515- block. host_fills ( ) . iter ( ) . map ( FillPermit2 :: from) . collect ( )
516- }
517-
518502 /// Task future for the submit task. This function runs the main loop of the task.
519503 async fn task_future ( self , mut inbound : mpsc:: UnboundedReceiver < SimResult > ) {
520504 loop {
@@ -589,7 +573,7 @@ pub fn bump_gas_from_retries(
589573 let max_fee_per_gas = ( basefee as u128 ) * BASE_MULTIPLIER + ( priority_fee as u128 ) ;
590574 let max_fee_per_blob_gas = blob_basefee * BLOB_MULTIPLIER * ( retry_count as u128 + 1 ) ;
591575
592- debug ! (
576+ trace ! (
593577 retry_count,
594578 max_fee_per_gas, priority_fee, max_fee_per_blob_gas, "calculated bumped gas parameters"
595579 ) ;
0 commit comments