From ddd1637a4032e8e10b169563d7939098edf5e95f Mon Sep 17 00:00:00 2001 From: Danil Date: Mon, 11 Dec 2023 17:40:47 +0100 Subject: [PATCH] Use DatabaseExt inside run era tx Signed-off-by: Danil --- Cargo.lock | 1 + crates/evm/core/Cargo.toml | 1 + crates/evm/core/src/backend/mod.rs | 1 + crates/evm/core/src/era_revm/transactions.rs | 12 +++++------- 4 files changed, 8 insertions(+), 7 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 4b3d359e6..fb039f2d8 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4407,6 +4407,7 @@ dependencies = [ "alloy-json-abi", "alloy-primitives", "alloy-sol-types", + "auto_impl", "const-hex", "derive_more", "era_test_node", diff --git a/crates/evm/core/Cargo.toml b/crates/evm/core/Cargo.toml index 68530bca0..fb5ecba45 100644 --- a/crates/evm/core/Cargo.toml +++ b/crates/evm/core/Cargo.toml @@ -54,3 +54,4 @@ thiserror = "1" tokio = { version = "1", features = ["time", "macros"] } tracing = "0.1" url = "2" +auto_impl = "1" \ No newline at end of file diff --git a/crates/evm/core/src/backend/mod.rs b/crates/evm/core/src/backend/mod.rs index d79a0829d..fbc98d1f8 100644 --- a/crates/evm/core/src/backend/mod.rs +++ b/crates/evm/core/src/backend/mod.rs @@ -65,6 +65,7 @@ const GLOBAL_FAILURE_SLOT: B256 = b256!("6661696c65640000000000000000000000000000000000000000000000000000"); /// An extension trait that allows us to easily extend the `revm::Inspector` capabilities +#[auto_impl::auto_impl(&mut, Box)] pub trait DatabaseExt: Database { /// Creates a new snapshot at the current point of execution. /// diff --git a/crates/evm/core/src/era_revm/transactions.rs b/crates/evm/core/src/era_revm/transactions.rs index a04269cc2..4f22304b6 100644 --- a/crates/evm/core/src/era_revm/transactions.rs +++ b/crates/evm/core/src/era_revm/transactions.rs @@ -7,12 +7,9 @@ use era_test_node::{ }; use ethers_core::abi::ethabi::{self, ParamType}; use multivm::{interface::VmExecutionResultAndLogs, vm_refunds_enhancement::ToTracerPointer}; -use revm::{ - primitives::{ - Account, AccountInfo, Address, Bytes, EVMResult, Env, Eval, Halt, HashMap as rHashMap, - OutOfGasError, ResultAndState, StorageSlot, TxEnv, B256, KECCAK_EMPTY, U256 as rU256, - }, - Database, +use revm::primitives::{ + Account, AccountInfo, Address, Bytes, EVMResult, Env, Eval, Halt, HashMap as rHashMap, + OutOfGasError, ResultAndState, StorageSlot, TxEnv, B256, KECCAK_EMPTY, U256 as rU256, }; use std::{ collections::{HashMap, HashSet}, @@ -36,6 +33,7 @@ use foundry_common::zk_utils::{ }; use super::db::RevmDatabaseForEra; +use crate::backend::DatabaseExt; fn contract_address_from_tx_result(execution_result: &VmExecutionResultAndLogs) -> Option { for query in execution_result.logs.storage_logs.iter().rev() { @@ -130,7 +128,7 @@ pub enum DatabaseError { pub fn run_era_transaction(env: &mut Env, db: DB, _inspector: INSP) -> EVMResult where - DB: Database + Send, + DB: DatabaseExt + Send, ::Error: Debug, { let (num, ts) = (env.block.number.to::(), env.block.timestamp.to::());