Skip to content

Commit

Permalink
fix(anvil): properly handle EVMError on call_with_state (#5347)
Browse files Browse the repository at this point in the history
  • Loading branch information
Evalir authored Jul 10, 2023
1 parent 8f20631 commit e488e2b
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions anvil/src/eth/backend/mem/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,12 @@ use forge::{
use foundry_evm::{
decode::{decode_custom_error_args, decode_revert},
executor::backend::{DatabaseError, DatabaseResult},
revm,
revm::{
self,
db::CacheDB,
primitives::{Account, CreateScheme, Env, Output, SpecId, TransactTo, TxEnv, KECCAK_EMPTY},
primitives::{
Account, CreateScheme, EVMError, Env, Output, SpecId, TransactTo, TxEnv, KECCAK_EMPTY,
},
},
utils::u256_to_h256_be,
};
Expand Down Expand Up @@ -1056,9 +1058,13 @@ impl Backend {
evm.database(state);
let result_and_state = match evm.inspect_ref(&mut inspector) {
Ok(result_and_state) => result_and_state,
Err(_) => {
return Err(BlockchainError::InvalidTransaction(InvalidTransactionError::GasTooHigh))
}
Err(e) => match e {
EVMError::Transaction(invalid_tx) => {
return Err(BlockchainError::InvalidTransaction(invalid_tx.into()))
}
EVMError::PrevrandaoNotSet => return Err(BlockchainError::PrevrandaoNotSet),
EVMError::Database(e) => return Err(BlockchainError::DatabaseError(e)),
},
};
let state = result_and_state.state;
let state: hashbrown::HashMap<H160, Account> =
Expand Down

0 comments on commit e488e2b

Please sign in to comment.