Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 4 additions & 13 deletions src/tasks/block/sim.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use crate::{
config::{BuilderConfig, RuProvider},
tasks::env::SimEnv,
};
use alloy::{eips::BlockId, network::Ethereum, providers::Provider};
use alloy::{eips::BlockId, network::Ethereum};
use init4_bin_base::{
deps::tracing::{debug, error},
utils::calc::SlotCalculator,
Expand Down Expand Up @@ -102,7 +102,7 @@ impl Simulator {
debug!(block_number = block_env.number, tx_count = sim_items.len(), "starting block build",);
let concurrency_limit = self.config.concurrency_limit();

let db = self.create_db().await.unwrap();
let db = self.create_db(block_env.number).unwrap();

let block_build: BlockBuild<_, NoOpInspector> = BlockBuild::new(
db,
Expand Down Expand Up @@ -226,19 +226,10 @@ impl Simulator {
/// # Returns
///
/// An `Option` containing the wrapped database or `None` if an error occurs.
async fn create_db(&self) -> Option<AlloyDatabaseProvider> {
// Fetch latest block number
let latest = match self.ru_provider.get_block_number().await {
Ok(block_number) => block_number,
Err(e) => {
error!(error = %e, "failed to get latest block number");
return None;
}
};

fn create_db(&self, latest_block_number: u64) -> Option<AlloyDatabaseProvider> {
// Make an AlloyDB instance from the rollup provider with that latest block number
let alloy_db: AlloyDB<Ethereum, RuProvider> =
AlloyDB::new(self.ru_provider.clone(), BlockId::from(latest));
AlloyDB::new(self.ru_provider.clone(), BlockId::from(latest_block_number));

// Wrap the AlloyDB instance in a WrapDatabaseAsync and return it.
// This is safe to unwrap because the main function sets the proper runtime settings.
Expand Down
1 change: 1 addition & 0 deletions src/tasks/cache/tx.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ impl TxPoller {
.get(url)
.send()
.await?
.error_for_status()?
.json()
.await
.map(|resp: TxPoolResponse| resp.transactions)
Expand Down
Loading