mirror of
https://github.com/hl-archive-node/nanoreth.git
synced 2025-12-06 10:59:55 +00:00
fix "feat(evm): use RethEvmBuilder inside ConfigureEvm" (#9813)
This commit is contained in:
@ -1,7 +1,7 @@
|
||||
//! Builder for creating an EVM with a database and environment.
|
||||
|
||||
use revm::{inspector_handle_register, Database, Evm, EvmBuilder, GetInspector};
|
||||
use revm_primitives::{Env, EnvWithHandlerCfg};
|
||||
use revm_primitives::EnvWithHandlerCfg;
|
||||
|
||||
/// Builder for creating an EVM with a database and environment.
|
||||
///
|
||||
@ -14,7 +14,7 @@ pub struct RethEvmBuilder<DB: Database, EXT = ()> {
|
||||
/// The database to use for the EVM.
|
||||
db: DB,
|
||||
/// The environment to use for the EVM.
|
||||
env: Option<Box<Env>>,
|
||||
env: Option<Box<EnvWithHandlerCfg>>,
|
||||
/// The external context for the EVM.
|
||||
external_context: EXT,
|
||||
}
|
||||
@ -29,7 +29,7 @@ where
|
||||
}
|
||||
|
||||
/// Set the environment for the EVM.
|
||||
pub fn with_env(mut self, env: Box<Env>) -> Self {
|
||||
pub fn with_env(mut self, env: Box<EnvWithHandlerCfg>) -> Self {
|
||||
self.env = Some(env);
|
||||
self
|
||||
}
|
||||
@ -44,7 +44,8 @@ where
|
||||
let mut builder =
|
||||
EvmBuilder::default().with_db(self.db).with_external_context(self.external_context);
|
||||
if let Some(env) = self.env {
|
||||
builder = builder.with_env(env);
|
||||
builder = builder.with_spec_id(env.clone().spec_id());
|
||||
builder = builder.with_env(env.env);
|
||||
}
|
||||
|
||||
builder.build()
|
||||
@ -59,7 +60,8 @@ where
|
||||
let mut builder =
|
||||
EvmBuilder::default().with_db(self.db).with_external_context(self.external_context);
|
||||
if let Some(env) = self.env {
|
||||
builder = builder.with_env(env);
|
||||
builder = builder.with_spec_id(env.clone().spec_id());
|
||||
builder = builder.with_env(env.env);
|
||||
}
|
||||
builder
|
||||
.with_external_context(inspector)
|
||||
@ -103,7 +105,7 @@ pub trait EvmFactory {
|
||||
db: DB,
|
||||
env: EnvWithHandlerCfg,
|
||||
) -> Evm<'a, Self::DefaultExternalContext<'a>, DB> {
|
||||
RethEvmBuilder::new(db, self.default_external_context()).with_env(env.env).build()
|
||||
RethEvmBuilder::new(db, self.default_external_context()).with_env(env.into()).build()
|
||||
}
|
||||
|
||||
/// Returns a new EVM with the given database configured with the given environment settings,
|
||||
@ -123,7 +125,7 @@ pub trait EvmFactory {
|
||||
I: GetInspector<DB>,
|
||||
{
|
||||
RethEvmBuilder::new(db, self.default_external_context())
|
||||
.with_env(env.env)
|
||||
.with_env(env.into())
|
||||
.build_with_inspector(inspector)
|
||||
}
|
||||
|
||||
|
||||
@ -14,9 +14,10 @@ extern crate alloc;
|
||||
|
||||
use core::ops::Deref;
|
||||
|
||||
use crate::builder::RethEvmBuilder;
|
||||
use reth_chainspec::ChainSpec;
|
||||
use reth_primitives::{Address, Header, TransactionSigned, TransactionSignedEcRecovered, U256};
|
||||
use revm::{inspector_handle_register, Database, Evm, EvmBuilder, GetInspector};
|
||||
use revm::{Database, Evm, GetInspector};
|
||||
use revm_primitives::{
|
||||
BlockEnv, Bytes, CfgEnvWithHandlerCfg, Env, EnvWithHandlerCfg, SpecId, TxEnv,
|
||||
};
|
||||
@ -76,10 +77,9 @@ pub trait ConfigureEvm: ConfigureEvmEnv {
|
||||
DB: Database,
|
||||
I: GetInspector<DB>,
|
||||
{
|
||||
let mut evm = self.evm_with_inspector(db, inspector);
|
||||
evm.modify_spec_id(env.spec_id());
|
||||
evm.context.evm.env = env.env;
|
||||
evm
|
||||
RethEvmBuilder::new(db, self.default_external_context())
|
||||
.with_env(env.into())
|
||||
.build_with_inspector(inspector)
|
||||
}
|
||||
|
||||
/// Returns a new EVM with the given inspector.
|
||||
@ -92,12 +92,11 @@ pub trait ConfigureEvm: ConfigureEvmEnv {
|
||||
DB: Database,
|
||||
I: GetInspector<DB>,
|
||||
{
|
||||
EvmBuilder::default()
|
||||
.with_db(db)
|
||||
.with_external_context(inspector)
|
||||
.append_handler_register(inspector_handle_register)
|
||||
.build()
|
||||
RethEvmBuilder::new(db, self.default_external_context()).build_with_inspector(inspector)
|
||||
}
|
||||
|
||||
/// Provides the default external context.
|
||||
fn default_external_context<'a>(&self) -> Self::DefaultExternalContext<'a>;
|
||||
}
|
||||
|
||||
/// This represents the set of methods used to configure the EVM's environment before block
|
||||
|
||||
Reference in New Issue
Block a user