Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 20 additions & 5 deletions Cargo.lock

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

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -87,4 +87,4 @@ solang-parser = "=0.3.1"
#ethers-solc = { path = "../ethers-rs/ethers-solc" }

[patch.crates-io]
revm = { git = "https://github.com/bluealloy/revm/", branch = "release/v25" }
revm = { git = "https://github.com/bluealloy/revm/" }
21 changes: 6 additions & 15 deletions anvil/src/eth/backend/mem/inspector.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,27 +61,21 @@ impl<DB: Database> revm::Inspector<DB> for Inspector {
&mut self,
interp: &mut Interpreter,
data: &mut EVMData<'_, DB>,
is_static: bool,
) -> InstructionResult {
call_inspectors!(
inspector,
[&mut self.gas.as_deref().map(|gas| gas.borrow_mut()), &mut self.tracer],
{ inspector.initialize_interp(interp, data, is_static) }
{ inspector.initialize_interp(interp, data) }
);
InstructionResult::Continue
}

fn step(
&mut self,
interp: &mut Interpreter,
data: &mut EVMData<'_, DB>,
is_static: bool,
) -> InstructionResult {
fn step(&mut self, interp: &mut Interpreter, data: &mut EVMData<'_, DB>) -> InstructionResult {
call_inspectors!(
inspector,
[&mut self.gas.as_deref().map(|gas| gas.borrow_mut()), &mut self.tracer],
{
inspector.step(interp, data, is_static);
inspector.step(interp, data);
}
);
InstructionResult::Continue
Expand Down Expand Up @@ -111,14 +105,13 @@ impl<DB: Database> revm::Inspector<DB> for Inspector {
&mut self,
interp: &mut Interpreter,
data: &mut EVMData<'_, DB>,
is_static: bool,
eval: InstructionResult,
) -> InstructionResult {
call_inspectors!(
inspector,
[&mut self.gas.as_deref().map(|gas| gas.borrow_mut()), &mut self.tracer],
{
inspector.step_end(interp, data, is_static, eval);
inspector.step_end(interp, data, eval);
}
);
eval
Expand All @@ -128,7 +121,6 @@ impl<DB: Database> revm::Inspector<DB> for Inspector {
&mut self,
data: &mut EVMData<'_, DB>,
call: &mut CallInputs,
is_static: bool,
) -> (InstructionResult, Gas, Bytes) {
call_inspectors!(
inspector,
Expand All @@ -138,7 +130,7 @@ impl<DB: Database> revm::Inspector<DB> for Inspector {
Some(&mut self.log_collector)
],
{
inspector.call(data, call, is_static);
inspector.call(data, call);
}
);

Expand All @@ -152,13 +144,12 @@ impl<DB: Database> revm::Inspector<DB> for Inspector {
remaining_gas: Gas,
ret: InstructionResult,
out: Bytes,
is_static: bool,
) -> (InstructionResult, Gas, Bytes) {
call_inspectors!(
inspector,
[&mut self.gas.as_deref().map(|gas| gas.borrow_mut()), &mut self.tracer],
{
inspector.call_end(data, inputs, remaining_gas, ret, out.clone(), is_static);
inspector.call_end(data, inputs, remaining_gas, ret, out.clone());
}
);
(ret, remaining_gas, out)
Expand Down
5 changes: 2 additions & 3 deletions anvil/src/eth/backend/mem/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ use ethers::{
use flate2::{read::GzDecoder, write::GzEncoder, Compression};
use forge::{
executor::inspector::AccessListTracer,
hashbrown,
revm::{
interpreter::{return_ok, InstructionResult},
primitives::{BlockEnv, ExecutionResult},
Expand Down Expand Up @@ -707,7 +706,7 @@ impl Backend {
Err(e) => return Err(e.into()),
};
let state = result_and_state.state;
let state: hashbrown::HashMap<H160, Account> =
let state: revm::primitives::HashMap<H160, Account> =
state.into_iter().map(|kv| (kv.0.into(), kv.1)).collect();
let (exit_reason, gas_used, out, logs) = match result_and_state.result {
ExecutionResult::Success { reason, gas_used, logs, output, .. } => {
Expand Down Expand Up @@ -1067,7 +1066,7 @@ impl Backend {
},
};
let state = result_and_state.state;
let state: hashbrown::HashMap<H160, Account> =
let state: revm::primitives::HashMap<H160, Account> =
state.into_iter().map(|kv| (kv.0.into(), kv.1)).collect();
let (exit_reason, gas_used, out) = match result_and_state.result {
ExecutionResult::Success { reason, gas_used, output, .. } => {
Expand Down
8 changes: 7 additions & 1 deletion anvil/src/eth/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,9 @@ pub enum InvalidTransactionError {
/// Thrown when a legacy tx was signed for a different chain
#[error("Incompatible EIP-155 transaction, signed for another chain")]
IncompatibleEIP155,
/// Thrown when an access list is used before the berlin hard fork.
#[error("Access lists are not supported before the Berlin hardfork")]
AccessListNotSupported,
}

impl From<revm::primitives::InvalidTransaction> for InvalidTransactionError {
Expand All @@ -201,7 +204,7 @@ impl From<revm::primitives::InvalidTransaction> for InvalidTransactionError {
})
}
InvalidTransaction::RejectCallerWithCode => InvalidTransactionError::SenderNoEOA,
InvalidTransaction::LackOfFundForGasLimit { .. } => {
InvalidTransaction::LackOfFundForMaxFee { .. } => {
InvalidTransactionError::InsufficientFunds
}
InvalidTransaction::OverflowPaymentInTransaction => {
Expand All @@ -215,6 +218,9 @@ impl From<revm::primitives::InvalidTransaction> for InvalidTransactionError {
}
InvalidTransaction::NonceTooHigh { .. } => InvalidTransactionError::NonceTooHigh,
InvalidTransaction::NonceTooLow { .. } => InvalidTransactionError::NonceTooLow,
InvalidTransaction::AccessListNotSupported => {
InvalidTransactionError::AccessListNotSupported
}
}
}
}
Expand Down
3 changes: 1 addition & 2 deletions evm/src/executor/backend/in_memory_db.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
//! The in memory DB
use crate::executor::backend::error::DatabaseError;
use hashbrown::HashMap as Map;
use revm::{
db::{CacheDB, DatabaseRef, EmptyDB},
primitives::{Account, AccountInfo, Bytecode, B160, B256, U256},
primitives::{Account, AccountInfo, Bytecode, HashMap as Map, B160, B256, U256},
Database, DatabaseCommit,
};

Expand Down
9 changes: 4 additions & 5 deletions evm/src/executor/backend/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,13 @@ use ethers::{
types::{Address, BlockNumber, Transaction, U64},
utils::keccak256,
};
use hashbrown::HashMap as Map;
pub use in_memory_db::MemDb;
use revm::{
db::{CacheDB, DatabaseRef},
precompile::{Precompiles, SpecId},
primitives::{
Account, AccountInfo, Bytecode, CreateScheme, Env, Log, ResultAndState, TransactTo, B160,
B256, KECCAK_EMPTY, U256 as rU256,
Account, AccountInfo, Bytecode, CreateScheme, Env, HashMap as Map, Log, ResultAndState,
TransactTo, B160, B256, KECCAK_EMPTY, U256 as rU256,
},
Database, DatabaseCommit, Inspector, JournaledState, EVM,
};
Expand Down Expand Up @@ -1100,7 +1099,7 @@ impl DatabaseExt for Backend {
// prevent issues in the new journalstate, e.g. assumptions that accounts are loaded
// if the account is not touched, we reload it, if it's touched we clone it
for (addr, acc) in journaled_state.state.iter() {
if acc.is_touched {
if acc.is_touched() {
merge_journaled_state_data(
b160_to_h160(*addr),
journaled_state,
Expand Down Expand Up @@ -1806,7 +1805,7 @@ fn commit_transaction(
/// Applies the changeset of a transaction to the active journaled state and also commits it in the
/// forked db
fn apply_state_changeset(
state: hashbrown::HashMap<revm::primitives::Address, Account>,
state: Map<revm::primitives::Address, Account>,
journaled_state: &mut JournaledState,
fork: &mut Fork,
) {
Expand Down
3 changes: 1 addition & 2 deletions evm/src/executor/backend/snapshot.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
use hashbrown::HashMap as Map;
use revm::{
primitives::{AccountInfo, Env, B160, B256, U256},
primitives::{AccountInfo, Env, HashMap as Map, B160, B256, U256},
JournaledState,
};
use serde::{Deserialize, Serialize};
Expand Down
10 changes: 6 additions & 4 deletions evm/src/executor/fork/cache.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
//! Cache related abstraction
use crate::{executor::backend::snapshot::StateSnapshot, HashMap as Map};
use crate::executor::backend::snapshot::StateSnapshot;
use parking_lot::RwLock;
use revm::{
primitives::{Account, AccountInfo, B160, B256, KECCAK_EMPTY, U256},
primitives::{
Account, AccountInfo, AccountStatus, HashMap as Map, B160, B256, KECCAK_EMPTY, U256,
},
DatabaseCommit,
};
use serde::{ser::SerializeMap, Deserialize, Deserializer, Serialize, Serializer};
Expand Down Expand Up @@ -249,7 +251,7 @@ impl MemDb {
let mut storage = self.storage.write();
let mut accounts = self.accounts.write();
for (add, mut acc) in changes {
if acc.is_empty() || acc.is_destroyed {
if acc.is_empty() || acc.is_selfdestructed() {
accounts.remove(&add);
storage.remove(&add);
} else {
Expand All @@ -264,7 +266,7 @@ impl MemDb {
accounts.insert(add, acc.info);

let acc_storage = storage.entry(add).or_default();
if acc.storage_cleared {
if acc.status.contains(AccountStatus::Created) {
acc_storage.clear();
}
for (index, value) in acc.storage {
Expand Down
3 changes: 1 addition & 2 deletions evm/src/executor/fork/database.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,10 @@ use crate::{
revm::db::CacheDB,
};
use ethers::{prelude::U256, types::BlockId};
use hashbrown::HashMap as Map;
use parking_lot::Mutex;
use revm::{
db::DatabaseRef,
primitives::{Account, AccountInfo, Bytecode, B160, B256, U256 as rU256},
primitives::{Account, AccountInfo, Bytecode, HashMap as Map, B160, B256, U256 as rU256},
Database, DatabaseCommit,
};
use std::sync::Arc;
Expand Down
1 change: 0 additions & 1 deletion evm/src/executor/inspector/access_list.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ where
&mut self,
interpreter: &mut Interpreter,
_data: &mut EVMData<'_, DB>,
_is_static: bool,
) -> InstructionResult {
let pc = interpreter.program_counter();
let op = interpreter.contract.bytecode.bytecode()[pc];
Expand Down
2 changes: 1 addition & 1 deletion evm/src/executor/inspector/cheatcodes/mapping.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ pub fn on_evm_step<DB: Database>(
_data: &mut EVMData<'_, DB>,
) {
match interpreter.contract.bytecode.bytecode()[interpreter.program_counter()] {
opcode::SHA3 => {
opcode::KECCAK256 => {
if interpreter.stack.peek(1) == Ok(revm::primitives::U256::from(0x40)) {
let address = interpreter.contract.address;
let offset = interpreter.stack.peek(0).expect("stack size > 1").to::<usize>();
Expand Down
8 changes: 2 additions & 6 deletions evm/src/executor/inspector/cheatcodes/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,6 @@ where
&mut self,
_: &mut Interpreter,
data: &mut EVMData<'_, DB>,
_: bool,
) -> InstructionResult {
// When the first interpreter is initialized we've circumvented the balance and gas checks,
// so we apply our actual block data with the correct fees and all.
Expand All @@ -321,7 +320,6 @@ where
&mut self,
interpreter: &mut Interpreter,
data: &mut EVMData<'_, DB>,
_: bool,
) -> InstructionResult {
self.pc = interpreter.program_counter();

Expand Down Expand Up @@ -522,7 +520,7 @@ where
(CALLCODE, 5, 6, true),
(STATICCALL, 4, 5, true),
(DELEGATECALL, 4, 5, true),
(SHA3, 0, 1, false),
(KECCAK256, 0, 1, false),
(LOG0, 0, 1, false),
(LOG1, 0, 1, false),
(LOG2, 0, 1, false),
Expand Down Expand Up @@ -577,7 +575,6 @@ where
&mut self,
data: &mut EVMData<'_, DB>,
call: &mut CallInputs,
is_static: bool,
) -> (InstructionResult, Gas, bytes::Bytes) {
if call.contract == h160_to_b160(CHEATCODE_ADDRESS) {
let gas = Gas::new(call.gas_limit);
Expand Down Expand Up @@ -686,7 +683,7 @@ where
// because we only need the from, to, value, and data. We can later change this
// into 1559, in the cli package, relatively easily once we
// know the target chain supports EIP-1559.
if !is_static {
if !call.is_static {
if let Err(err) = data
.journaled_state
.load_account(h160_to_b160(broadcast.new_origin), data.db)
Expand Down Expand Up @@ -751,7 +748,6 @@ where
remaining_gas: Gas,
status: InstructionResult,
retdata: bytes::Bytes,
_: bool,
) -> (InstructionResult, Gas, bytes::Bytes) {
if call.contract == h160_to_b160(CHEATCODE_ADDRESS) ||
call.contract == h160_to_b160(HARDHAT_CONSOLE_ADDRESS)
Expand Down
1 change: 0 additions & 1 deletion evm/src/executor/inspector/chisel_state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ where
&mut self,
interp: &mut Interpreter,
_: &mut revm::EVMData<'_, DB>,
_: bool,
eval: InstructionResult,
) -> InstructionResult {
// If we are at the final pc of the REPL contract execution, set the state.
Expand Down
Loading