mirror of
https://github.com/hl-archive-node/nanoreth.git
synced 2025-12-06 10:59:55 +00:00
feat: add functions for env creation (#12928)
This commit is contained in:
@ -24,7 +24,7 @@ use reth_primitives::{BlockWithSenders, Receipt};
|
||||
use reth_revm::db::State;
|
||||
use revm_primitives::{
|
||||
db::{Database, DatabaseCommit},
|
||||
BlockEnv, CfgEnvWithHandlerCfg, EnvWithHandlerCfg, ResultAndState, U256,
|
||||
EnvWithHandlerCfg, ResultAndState, U256,
|
||||
};
|
||||
|
||||
/// Factory for [`EthExecutionStrategy`].
|
||||
@ -117,10 +117,7 @@ where
|
||||
header: &alloy_consensus::Header,
|
||||
total_difficulty: U256,
|
||||
) -> EnvWithHandlerCfg {
|
||||
let mut cfg = CfgEnvWithHandlerCfg::new(Default::default(), Default::default());
|
||||
let mut block_env = BlockEnv::default();
|
||||
self.evm_config.fill_cfg_and_block_env(&mut cfg, &mut block_env, header, total_difficulty);
|
||||
|
||||
let (cfg, block_env) = self.evm_config.cfg_and_block_env(header, total_difficulty);
|
||||
EnvWithHandlerCfg::new_with_cfg_env(cfg, block_env, Default::default())
|
||||
}
|
||||
}
|
||||
|
||||
@ -207,17 +207,11 @@ mod tests {
|
||||
primitives::{BlockEnv, CfgEnv, SpecId},
|
||||
JournaledState,
|
||||
};
|
||||
use revm_primitives::{CfgEnvWithHandlerCfg, EnvWithHandlerCfg, HandlerCfg};
|
||||
use revm_primitives::{EnvWithHandlerCfg, HandlerCfg};
|
||||
use std::collections::HashSet;
|
||||
|
||||
#[test]
|
||||
fn test_fill_cfg_and_block_env() {
|
||||
// Create a new configuration environment
|
||||
let mut cfg_env = CfgEnvWithHandlerCfg::new_with_spec_id(CfgEnv::default(), SpecId::LATEST);
|
||||
|
||||
// Create a default block environment
|
||||
let mut block_env = BlockEnv::default();
|
||||
|
||||
// Create a default header
|
||||
let header = Header::default();
|
||||
|
||||
@ -236,12 +230,8 @@ mod tests {
|
||||
|
||||
// Use the `EthEvmConfig` to fill the `cfg_env` and `block_env` based on the ChainSpec,
|
||||
// Header, and total difficulty
|
||||
EthEvmConfig::new(Arc::new(chain_spec.clone())).fill_cfg_and_block_env(
|
||||
&mut cfg_env,
|
||||
&mut block_env,
|
||||
&header,
|
||||
total_difficulty,
|
||||
);
|
||||
let (cfg_env, _) = EthEvmConfig::new(Arc::new(chain_spec.clone()))
|
||||
.cfg_and_block_env(&header, total_difficulty);
|
||||
|
||||
// Assert that the chain ID in the `cfg_env` is correctly set to the chain ID of the
|
||||
// ChainSpec
|
||||
|
||||
Reference in New Issue
Block a user