@@ -2,7 +2,7 @@ use crate::tasks::block::sim::SimResult;
2
2
use crate :: {
3
3
config:: { HostProvider , ZenithInstance } ,
4
4
quincey:: Quincey ,
5
- utils:: extract_signature_components,
5
+ utils:: { self , extract_signature_components} ,
6
6
} ;
7
7
use alloy:: {
8
8
consensus:: { Header , SimpleCoder , constants:: GWEI_TO_WEI } ,
@@ -17,15 +17,16 @@ use alloy::{
17
17
use eyre:: bail;
18
18
use init4_bin_base:: deps:: {
19
19
metrics:: { counter, histogram} ,
20
- tracing:: { Instrument , debug, debug_span, error, info, instrument, warn} ,
20
+ tracing:: { Instrument , debug, debug_span, error, info, instrument, trace , warn} ,
21
21
} ;
22
+ use signet_constants:: SignetSystemConstants ;
22
23
use signet_sim:: BuiltBlock ;
23
24
use signet_types:: { SignRequest , SignResponse } ;
24
25
use signet_zenith:: {
25
26
BundleHelper :: { self , BlockHeader , FillPermit2 , submitCall} ,
26
27
Zenith :: { self , IncorrectHostBlock } ,
27
28
} ;
28
- use std:: time:: { Instant , UNIX_EPOCH } ;
29
+ use std:: time:: Instant ;
29
30
use tokio:: {
30
31
sync:: mpsc:: { self } ,
31
32
task:: JoinHandle ,
@@ -190,6 +191,8 @@ pub struct SubmitTask {
190
191
pub zenith : ZenithInstance ,
191
192
/// Quincey
192
193
pub quincey : Quincey ,
194
+ /// Constants
195
+ pub constants : SignetSystemConstants ,
193
196
/// Config
194
197
pub config : crate :: config:: BuilderConfig ,
195
198
/// Channel over which to send pending transactions
@@ -206,16 +209,18 @@ impl SubmitTask {
206
209
207
210
/// Constructs the signing request from the in-progress block passed to it and assigns the
208
211
/// 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) ,
213
218
host_chain_id : U256 :: from ( self . config . host_chain_id ) ,
214
219
ru_chain_id : U256 :: from ( self . config . ru_chain_id ) ,
215
220
gas_limit : U256 :: from ( self . config . rollup_block_gas_limit ) ,
216
221
ru_reward_address : self . config . builder_rewards_address ,
217
222
contents : * contents. contents_hash ( ) ,
218
- } )
223
+ }
219
224
}
220
225
221
226
/// Encodes the sidecar and then builds the 4844 blob transaction from the provided header and signature values.
@@ -327,7 +332,7 @@ impl SubmitTask {
327
332
debug ! ( ?header. hostBlockNumber, "built rollup block header" ) ;
328
333
329
334
// Extract fills from the built block
330
- let fills = self . extract_fills ( block) ;
335
+ let fills = utils :: convert_fills ( block) ;
331
336
debug ! ( fill_count = fills. len( ) , "extracted fills from rollup block" ) ;
332
337
333
338
// Create a blob transaction with the blob header and signature values and return it
@@ -398,11 +403,7 @@ impl SubmitTask {
398
403
block : & BuiltBlock ,
399
404
) -> eyre:: Result < ControlFlow > {
400
405
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) ;
406
407
407
408
debug ! (
408
409
host_block_number = %sig_request. host_block_number,
@@ -492,29 +493,12 @@ impl SubmitTask {
492
493
493
494
/// Calculates and returns the slot number and its start and end timestamps for the current instant.
494
495
fn calculate_slot_window ( & self ) -> ( u64 , u64 , u64 ) {
495
- let now_ts = self . now ( ) ;
496
+ let now_ts = utils :: now ( ) ;
496
497
let current_slot = self . config . slot_calculator . calculate_slot ( now_ts) ;
497
498
let ( start, end) = self . config . slot_calculator . calculate_slot_window ( current_slot) ;
498
499
( current_slot, start, end)
499
500
}
500
501
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
-
518
502
/// Task future for the submit task. This function runs the main loop of the task.
519
503
async fn task_future ( self , mut inbound : mpsc:: UnboundedReceiver < SimResult > ) {
520
504
loop {
@@ -589,7 +573,7 @@ pub fn bump_gas_from_retries(
589
573
let max_fee_per_gas = ( basefee as u128 ) * BASE_MULTIPLIER + ( priority_fee as u128 ) ;
590
574
let max_fee_per_blob_gas = blob_basefee * BLOB_MULTIPLIER * ( retry_count as u128 + 1 ) ;
591
575
592
- debug ! (
576
+ trace ! (
593
577
retry_count,
594
578
max_fee_per_gas, priority_fee, max_fee_per_blob_gas, "calculated bumped gas parameters"
595
579
) ;
0 commit comments