mirror of
https://github.com/hl-archive-node/nanoreth.git
synced 2025-12-06 10:59:55 +00:00
feat: integrate evm in rpc (#7470)
This commit is contained in:
@ -9,7 +9,7 @@
|
||||
#![cfg_attr(docsrs, feature(doc_cfg, doc_auto_cfg))]
|
||||
|
||||
use reth_primitives::{revm::env::fill_block_env, Address, ChainSpec, Header, Transaction, U256};
|
||||
use revm::{Database, Evm, EvmBuilder};
|
||||
use revm::{inspector_handle_register, Database, Evm, EvmBuilder, GetInspector};
|
||||
use revm_primitives::{BlockEnv, CfgEnvWithHandlerCfg, EnvWithHandlerCfg, SpecId, TxEnv};
|
||||
|
||||
/// Trait for configuring the EVM for executing full blocks.
|
||||
@ -42,12 +42,16 @@ pub trait ConfigureEvm: ConfigureEvmEnv {
|
||||
/// including the spec id.
|
||||
///
|
||||
/// This will preserve any handler modifications
|
||||
fn evm_with_env_and_inspector<'a, DB: Database + 'a, I>(
|
||||
fn evm_with_env_and_inspector<'a, DB, I>(
|
||||
&self,
|
||||
db: DB,
|
||||
env: EnvWithHandlerCfg,
|
||||
inspector: I,
|
||||
) -> Evm<'a, I, DB> {
|
||||
) -> Evm<'a, I, DB>
|
||||
where
|
||||
DB: Database + 'a,
|
||||
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;
|
||||
@ -59,8 +63,16 @@ pub trait ConfigureEvm: ConfigureEvmEnv {
|
||||
/// Caution: This does not automatically configure the EVM with [ConfigureEvmEnv] methods. It is
|
||||
/// up to the caller to call an appropriate method to fill the transaction and block
|
||||
/// environment before executing any transactions using the provided EVM.
|
||||
fn evm_with_inspector<'a, DB: Database + 'a, I>(&self, db: DB, inspector: I) -> Evm<'a, I, DB> {
|
||||
EvmBuilder::default().with_db(db).with_external_context(inspector).build()
|
||||
fn evm_with_inspector<'a, DB, I>(&self, db: DB, inspector: I) -> Evm<'a, I, DB>
|
||||
where
|
||||
DB: Database + 'a,
|
||||
I: GetInspector<DB>,
|
||||
{
|
||||
EvmBuilder::default()
|
||||
.with_db(db)
|
||||
.with_external_context(inspector)
|
||||
.append_handler_register(inspector_handle_register)
|
||||
.build()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user