Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(hardfork): Specify hardfork environment #51

Merged
merged 8 commits into from
Aug 2, 2024
Merged
Changes from 5 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
23 changes: 20 additions & 3 deletions bin/opt8n/src/opt8n.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@ use futures::StreamExt;
use op_test_vectors::execution::{ExecutionFixture, ExecutionReceipt, ExecutionResult};
use revm::{
db::{AlloyDB, CacheDB},
primitives::{BlobExcessGasAndPrice, BlockEnv, U256},
primitives::{
BlobExcessGasAndPrice, BlockEnv, CfgEnvWithHandlerCfg, Env, HandlerCfg, SpecId, U256,
},
DatabaseCommit, EvmBuilder,
};
use serde::{Deserialize, Serialize};
Expand Down Expand Up @@ -224,12 +226,27 @@ impl Opt8n {
.map(|excess_gas| BlobExcessGasAndPrice::new(excess_gas as u64)),
};

let mut env = Env {
block: block_env,
..Default::default()
};
env.cfg.chain_id = self.eth_api.chain_id();

let handler_cfg = HandlerCfg {
spec_id: SpecId::from(self.node_config.hardfork.unwrap_or_default()),
// @refcell When we set is_optimism true, execution fails here due to "Failed to load enveloped transaction."
0xOsiris marked this conversation as resolved.
Show resolved Hide resolved
..Default::default()
};
let cfg_env_with_handler_cfg = CfgEnvWithHandlerCfg {
cfg_env: env.cfg.clone(),
handler_cfg,
};
let mut evm = EvmBuilder::default()
.with_db(Box::new(revm_db))
.with_block_env(block_env)
.with_env(Box::new(env))
.with_cfg_env_with_handler_cfg(cfg_env_with_handler_cfg)
.build();

evm.context.evm.env.cfg.chain_id = self.eth_api.chain_id();
for tx in block.transactions.iter() {
let pending = PendingTransaction::new(tx.clone().into())?;
evm.context.evm.env.tx = pending.to_revm_tx_env();
Expand Down