@@ -5,7 +5,7 @@ use crate::{
55 config:: { BuilderConfig , RuProvider } ,
66 tasks:: env:: SimEnv ,
77} ;
8- use alloy:: { eips:: BlockId , network:: Ethereum , providers :: Provider } ;
8+ use alloy:: { eips:: BlockId , network:: Ethereum } ;
99use init4_bin_base:: {
1010 deps:: tracing:: { debug, error} ,
1111 utils:: calc:: SlotCalculator ,
@@ -102,7 +102,7 @@ impl Simulator {
102102 debug ! ( block_number = block_env. number, tx_count = sim_items. len( ) , "starting block build" , ) ;
103103 let concurrency_limit = self . config . concurrency_limit ( ) ;
104104
105- let db = self . create_db ( ) . await . unwrap ( ) ;
105+ let db = self . create_db ( block_env . number ) . unwrap ( ) ;
106106
107107 let block_build: BlockBuild < _ , NoOpInspector > = BlockBuild :: new (
108108 db,
@@ -226,19 +226,10 @@ impl Simulator {
226226 /// # Returns
227227 ///
228228 /// An `Option` containing the wrapped database or `None` if an error occurs.
229- async fn create_db ( & self ) -> Option < AlloyDatabaseProvider > {
230- // Fetch latest block number
231- let latest = match self . ru_provider . get_block_number ( ) . await {
232- Ok ( block_number) => block_number,
233- Err ( e) => {
234- error ! ( error = %e, "failed to get latest block number" ) ;
235- return None ;
236- }
237- } ;
238-
229+ fn create_db ( & self , latest_block_number : u64 ) -> Option < AlloyDatabaseProvider > {
239230 // Make an AlloyDB instance from the rollup provider with that latest block number
240231 let alloy_db: AlloyDB < Ethereum , RuProvider > =
241- AlloyDB :: new ( self . ru_provider . clone ( ) , BlockId :: from ( latest ) ) ;
232+ AlloyDB :: new ( self . ru_provider . clone ( ) , BlockId :: from ( latest_block_number ) ) ;
242233
243234 // Wrap the AlloyDB instance in a WrapDatabaseAsync and return it.
244235 // This is safe to unwrap because the main function sets the proper runtime settings.
0 commit comments