Sitelet https://github.com/init4tech/builder/pull/100/commits/d9fec671bb2bd768c229d920fa3426da2af372be
Skip to content
Prev Previous commit
Next Next commit
clippy + fmt
  • Loading branch information
dylanlott committed Jun 13, 2025
commit d9fec671bb2bd768c229d920fa3426da2af372be
25 changes: 8 additions & 17 deletions src/tasks/block/sim.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,13 @@ use crate::{
config::{BuilderConfig, RuProvider},
tasks::env::SimEnv,
};
use alloy::{
eips::BlockId,
network::Ethereum,
providers::Provider,
};
use alloy::{eips::BlockId, network::Ethereum, providers::Provider};
use init4_bin_base::{
deps::tracing::{debug, error},
utils::calc::SlotCalculator,
};
use signet_sim::{BlockBuild, BuiltBlock, SimCache};
use signet_types::constants::SignetSystemConstants;
use tracing::info;
use std::time::{Duration, Instant};
use tokio::{
sync::{
Expand All @@ -25,6 +20,7 @@ use tokio::{
},
task::JoinHandle,
};
use tracing::info;
use trevm::revm::{
context::BlockEnv,
database::{AlloyDB, WrapDatabaseAsync},
Expand Down Expand Up @@ -83,8 +79,8 @@ impl Simulator {
/// Handles building a single block.
///
/// Builds a block in the block environment with items from the simulation cache
/// against the database state. When the `finish_by` deadline is reached, it
/// stops simulating and returns the block.
/// against the database state. When the `finish_by` deadline is reached, it
/// stops simulating and returns the block.
///
/// # Arguments
///
Expand All @@ -103,11 +99,7 @@ impl Simulator {
finish_by: Instant,
block_env: BlockEnv,
) -> eyre::Result<BuiltBlock> {
debug!(
block_number = block_env.number,
tx_count = sim_items.len(),
"starting block build",
);
debug!(block_number = block_env.number, tx_count = sim_items.len(), "starting block build",);

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

Expand Down Expand Up @@ -155,15 +147,15 @@ impl Simulator {
tokio::spawn(async move { self.run_simulator(constants, cache, submit_sender).await })
}

/// This function runs indefinitely, waiting for the block environment to be set and checking
/// This function runs indefinitely, waiting for the block environment to be set and checking
/// if the current slot is valid before building a block and sending it along for to the submit channel.
///
/// If it is authorized for the current slot, then the simulator task
/// - clones the simulation cache,
/// - calculates a deadline for block building,
/// - attempts to build a block using the latest cache and constants,
/// - then submits the built block through the provided channel.
///
///
/// If an error occurs during block building or submission, it logs the error and continues the loop.
///
/// # Arguments
Expand Down Expand Up @@ -191,8 +183,7 @@ impl Simulator {
// waiting for a new block, and checking current slot authorization.
let finish_by = self.calculate_deadline();
let sim_cache = cache.clone();
match self.handle_build(constants, sim_cache, finish_by, sim_env.signet.clone()).await
{
match self.handle_build(constants, sim_cache, finish_by, sim_env.signet.clone()).await {
Ok(block) => {
debug!(block = ?block.block_number(), tx_count = block.transactions().len(), "built simulated block");
let _ = submit_sender.send(SimResult { block, env: sim_env });
Expand Down
14 changes: 9 additions & 5 deletions src/tasks/env.rs
Original file line number Diff line number Diff line change
Expand Up @@ -89,10 +89,11 @@ impl EnvTask {
info_span!("EnvTask::task_fut::loop", %block_hash, number = tracing::field::Empty);

// Get the rollup header for rollup block simulation environment configuration
let rollup_header = match self.get_latest_rollup_header(&sender, block_hash, &span).await {
Some(value) => value,
None => continue,
};
let rollup_header =
match self.get_latest_rollup_header(&sender, block_hash, &span).await {
Some(value) => value,
None => continue,
};
debug!(?rollup_header.number, "pulled rollup block for simulation");

// Get the host header for blob transaction submission gas pricing
Expand All @@ -108,7 +109,10 @@ impl EnvTask {

// Construct the block env using the previous block header
let signet_env = self.construct_block_env(&host_header);
debug!(block_number = signet_env.number, signet_env.basefee, "constructed signet block env");
debug!(
block_number = signet_env.number,
signet_env.basefee, "constructed signet block env"
);

if sender.send(Some(SimEnv { signet: signet_env, host: host_header })).is_err() {
// The receiver has been dropped, so we can stop the task.
Expand Down
4 changes: 2 additions & 2 deletions src/tasks/submit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -552,10 +552,10 @@ fn calculate_gas(retry_count: usize, prev_header: Header) -> (u128, u128, u128)
parent_blob_basefee
} else {
// Fallback to a default value if no blob base fee is set
fallback_blob_basefee
fallback_blob_basefee
};

bump_gas_from_retries(retry_count, base_fee_per_gas, blob_basefee as u128)
bump_gas_from_retries(retry_count, base_fee_per_gas, blob_basefee)
}

/// Bumps the gas parameters based on the retry count, base fee, and blob base fee.
Expand Down