Skip to content

Commit

Permalink
fix - Use GnosisEvmConfig in payload builder (#42)
Browse files Browse the repository at this point in the history
* Made payload builder use the same evm config as executor

* chainspec field changed
  • Loading branch information
debjit-bw authored Dec 17, 2024
1 parent 02bf929 commit e4525bd
Showing 1 changed file with 14 additions and 22 deletions.
36 changes: 14 additions & 22 deletions src/payload_builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,11 @@ use reth_provider::{
use reth_trie::HashedPostState;
use revm::{
db::{states::bundle_state::BundleRetention, State},
Database, DatabaseCommit, Evm,
DatabaseCommit,
};
use revm_primitives::{
calc_excess_blob_gas, Address, BlockEnv, CfgEnvWithHandlerCfg, EVMError, EnvWithHandlerCfg,
InvalidTransaction, ResultAndState, U256,
InvalidTransaction, ResultAndState, TxEnv, U256,
};
use tracing::{debug, trace, warn};

Expand All @@ -53,24 +53,6 @@ type BestTransactionsIter<Pool> = Box<
dyn BestTransactions<Item = Arc<ValidPoolTransaction<<Pool as TransactionPool>::Transaction>>>,
>;

fn initialize_evm<'a, DB>(
db: &'a mut DB,
initialized_cfg: &'a CfgEnvWithHandlerCfg,
initialized_block_env: &'a BlockEnv,
) -> Evm<'a, (), &'a mut DB>
where
DB: Database,
{
Evm::builder()
.with_db(db)
.with_env_with_handler_cfg(EnvWithHandlerCfg::new_with_cfg_env(
initialized_cfg.clone(),
initialized_block_env.clone(),
Default::default(),
))
.build()
}

/// A basic Gnosis payload service builder
#[derive(Debug, Default, Clone)]
pub struct GnosisPayloadServiceBuilder {
Expand Down Expand Up @@ -346,7 +328,12 @@ where
PayloadBuilderError::Internal(err.into())
})?;

let mut evm = initialize_evm(&mut db, &initialized_cfg, &initialized_block_env);
let env = EnvWithHandlerCfg::new_with_cfg_env(
initialized_cfg.clone(),
initialized_block_env.clone(),
TxEnv::default(),
);
let mut evm = evm_config.evm_with_env(&mut db, env);

let mut receipts = Vec::new();
while let Some(pool_tx) = best_txs.next() {
Expand Down Expand Up @@ -475,7 +462,12 @@ where
});
}

let mut evm = initialize_evm(&mut db, &initialized_cfg, &initialized_block_env);
let env = EnvWithHandlerCfg::new_with_cfg_env(
initialized_cfg.clone(),
initialized_block_env.clone(),
TxEnv::default(),
);
let mut evm = evm_config.evm_with_env(&mut db, env);

// < GNOSIS SPECIFIC
let balance_increments = apply_post_block_system_calls(
Expand Down

0 comments on commit e4525bd

Please sign in to comment.