Skip to content

Commit

Permalink
Use DatabaseExt inside run era tx
Browse files Browse the repository at this point in the history
Signed-off-by: Danil <[email protected]>
  • Loading branch information
Deniallugo committed Dec 11, 2023
1 parent 5a603fb commit ddd1637
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 7 deletions.
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions crates/evm/core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -54,3 +54,4 @@ thiserror = "1"
tokio = { version = "1", features = ["time", "macros"] }
tracing = "0.1"
url = "2"
auto_impl = "1"
1 change: 1 addition & 0 deletions crates/evm/core/src/backend/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<Error = DatabaseError> {
/// Creates a new snapshot at the current point of execution.
///
Expand Down
12 changes: 5 additions & 7 deletions crates/evm/core/src/era_revm/transactions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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},
Expand All @@ -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<H160> {
for query in execution_result.logs.storage_logs.iter().rev() {
Expand Down Expand Up @@ -130,7 +128,7 @@ pub enum DatabaseError {

pub fn run_era_transaction<DB, E, INSP>(env: &mut Env, db: DB, _inspector: INSP) -> EVMResult<E>
where
DB: Database + Send,
DB: DatabaseExt + Send,
<DB as revm::Database>::Error: Debug,
{
let (num, ts) = (env.block.number.to::<u64>(), env.block.timestamp.to::<u64>());
Expand Down

0 comments on commit ddd1637

Please sign in to comment.