Skip to content

Commit

Permalink
feat(reth-evm-ethereum): use EVMError::map_db_err (paradigmxyz#10916)
Browse files Browse the repository at this point in the history
Co-authored-by: Emilia Hane <[email protected]>
  • Loading branch information
nkysg and emhane authored Sep 16, 2024
1 parent bf80098 commit 0fd8132
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 16 deletions.
10 changes: 2 additions & 8 deletions crates/ethereum/evm/src/execute.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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(),
Expand Down
10 changes: 2 additions & 8 deletions crates/optimism/evm/src/execute.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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(),
Expand Down

0 comments on commit 0fd8132

Please sign in to comment.