@@ -5,7 +5,7 @@ use crate::{
5
5
config:: { BuilderConfig , RuProvider } ,
6
6
tasks:: env:: SimEnv ,
7
7
} ;
8
- use alloy:: { eips:: BlockId , network:: Ethereum , providers :: Provider } ;
8
+ use alloy:: { eips:: BlockId , network:: Ethereum } ;
9
9
use init4_bin_base:: {
10
10
deps:: tracing:: { debug, error} ,
11
11
utils:: calc:: SlotCalculator ,
@@ -102,7 +102,7 @@ impl Simulator {
102
102
debug ! ( block_number = block_env. number, tx_count = sim_items. len( ) , "starting block build" , ) ;
103
103
let concurrency_limit = self . config . concurrency_limit ( ) ;
104
104
105
- let db = self . create_db ( ) . await . unwrap ( ) ;
105
+ let db = self . create_db ( block_env . number ) . unwrap ( ) ;
106
106
107
107
let block_build: BlockBuild < _ , NoOpInspector > = BlockBuild :: new (
108
108
db,
@@ -226,19 +226,10 @@ impl Simulator {
226
226
/// # Returns
227
227
///
228
228
/// 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 > {
239
230
// Make an AlloyDB instance from the rollup provider with that latest block number
240
231
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 ) ) ;
242
233
243
234
// Wrap the AlloyDB instance in a WrapDatabaseAsync and return it.
244
235
// This is safe to unwrap because the main function sets the proper runtime settings.
0 commit comments