From 0fd8132e902f15ef66791bd14e77542adf01915e Mon Sep 17 00:00:00 2001 From: nk_ysg Date: Tue, 17 Sep 2024 06:55:40 +0800 Subject: [PATCH] feat(reth-evm-ethereum): use EVMError::map_db_err (#10916) Co-authored-by: Emilia Hane --- crates/ethereum/evm/src/execute.rs | 10 ++-------- crates/optimism/evm/src/execute.rs | 10 ++-------- 2 files changed, 4 insertions(+), 16 deletions(-) diff --git a/crates/ethereum/evm/src/execute.rs b/crates/ethereum/evm/src/execute.rs index 67709ca2e047..f173c6cca454 100644 --- a/crates/ethereum/evm/src/execute.rs +++ b/crates/ethereum/evm/src/execute.rs @@ -35,7 +35,7 @@ use reth_revm::{ }; use revm_primitives::{ db::{Database, DatabaseCommit}, - BlockEnv, CfgEnvWithHandlerCfg, EVMError, EnvWithHandlerCfg, ResultAndState, + BlockEnv, CfgEnvWithHandlerCfg, EnvWithHandlerCfg, ResultAndState, }; use std::collections::hash_map::Entry; @@ -184,13 +184,7 @@ where // Execute transaction. let ResultAndState { result, state } = evm.transact().map_err(move |err| { - let new_err = match err { - EVMError::Transaction(e) => EVMError::Transaction(e), - EVMError::Header(e) => EVMError::Header(e), - EVMError::Database(e) => EVMError::Database(e.into()), - EVMError::Custom(e) => EVMError::Custom(e), - EVMError::Precompile(e) => EVMError::Precompile(e), - }; + let new_err = err.map_db_err(|e| e.into()); // Ensure hash is calculated for error log, if not already done BlockValidationError::EVM { hash: transaction.recalculate_hash(), diff --git a/crates/optimism/evm/src/execute.rs b/crates/optimism/evm/src/execute.rs index c8874685c822..3e2a8751689b 100644 --- a/crates/optimism/evm/src/execute.rs +++ b/crates/optimism/evm/src/execute.rs @@ -28,7 +28,7 @@ use reth_revm::{ }; use revm_primitives::{ db::{Database, DatabaseCommit}, - BlockEnv, CfgEnvWithHandlerCfg, EVMError, EnvWithHandlerCfg, ResultAndState, + BlockEnv, CfgEnvWithHandlerCfg, EnvWithHandlerCfg, ResultAndState, }; use std::{collections::hash_map::Entry, fmt::Display, sync::Arc}; use tracing::trace; @@ -186,13 +186,7 @@ where // Execute transaction. let ResultAndState { result, state } = evm.transact().map_err(move |err| { - let new_err = match err { - EVMError::Transaction(e) => EVMError::Transaction(e), - EVMError::Header(e) => EVMError::Header(e), - EVMError::Database(e) => EVMError::Database(e.into()), - EVMError::Custom(e) => EVMError::Custom(e), - EVMError::Precompile(e) => EVMError::Precompile(e), - }; + let new_err = err.map_db_err(|e| e.into()); // Ensure hash is calculated for error log, if not already done BlockValidationError::EVM { hash: transaction.recalculate_hash(),