Skip to content

Commit f8a07c3

Browse files
authored
Revert "feat(evm): Use latest revm main commit (foundry-rs#5669)" (foundry-rs#5695)
* Revert "feat(`evm`): Use latest `revm` main commit (foundry-rs#5669)" This reverts commit efedf1f. * test: add basic coverage test * bump
1 parent 6676e81 commit f8a07c3

File tree

21 files changed

+106
-87
lines changed

21 files changed

+106
-87
lines changed

Cargo.lock

Lines changed: 17 additions & 44 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,4 +154,4 @@ solang-parser = "=0.3.1"
154154
#ethers-solc = { path = "../ethers-rs/ethers-solc" }
155155

156156
[patch.crates-io]
157-
revm = { git = "https://github.com/bluealloy/revm/", rev = "eb6a9f09e8ac2227bc1c353b698ad9e68a9574b2" }
157+
revm = { git = "https://github.com/bluealloy/revm/", branch = "release/v25" }

crates/anvil/src/eth/backend/mem/inspector.rs

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -53,17 +53,23 @@ impl<DB: Database> revm::Inspector<DB> for Inspector {
5353
&mut self,
5454
interp: &mut Interpreter,
5555
data: &mut EVMData<'_, DB>,
56+
is_static: bool,
5657
) -> InstructionResult {
5758
call_inspectors!([&mut self.tracer], |inspector| {
58-
inspector.initialize_interp(interp, data);
59+
inspector.initialize_interp(interp, data, is_static);
5960
});
6061
InstructionResult::Continue
6162
}
6263

6364
#[inline]
64-
fn step(&mut self, interp: &mut Interpreter, data: &mut EVMData<'_, DB>) -> InstructionResult {
65+
fn step(
66+
&mut self,
67+
interp: &mut Interpreter,
68+
data: &mut EVMData<'_, DB>,
69+
is_static: bool,
70+
) -> InstructionResult {
6571
call_inspectors!([&mut self.tracer], |inspector| {
66-
inspector.step(interp, data);
72+
inspector.step(interp, data, is_static);
6773
});
6874
InstructionResult::Continue
6975
}
@@ -86,10 +92,11 @@ impl<DB: Database> revm::Inspector<DB> for Inspector {
8692
&mut self,
8793
interp: &mut Interpreter,
8894
data: &mut EVMData<'_, DB>,
95+
is_static: bool,
8996
eval: InstructionResult,
9097
) -> InstructionResult {
9198
call_inspectors!([&mut self.tracer], |inspector| {
92-
inspector.step_end(interp, data, eval);
99+
inspector.step_end(interp, data, is_static, eval);
93100
});
94101
eval
95102
}
@@ -99,9 +106,10 @@ impl<DB: Database> revm::Inspector<DB> for Inspector {
99106
&mut self,
100107
data: &mut EVMData<'_, DB>,
101108
call: &mut CallInputs,
109+
is_static: bool,
102110
) -> (InstructionResult, Gas, Bytes) {
103111
call_inspectors!([&mut self.tracer, Some(&mut self.log_collector)], |inspector| {
104-
inspector.call(data, call);
112+
inspector.call(data, call, is_static);
105113
});
106114

107115
(InstructionResult::Continue, Gas::new(call.gas_limit), Bytes::new())
@@ -115,9 +123,10 @@ impl<DB: Database> revm::Inspector<DB> for Inspector {
115123
remaining_gas: Gas,
116124
ret: InstructionResult,
117125
out: Bytes,
126+
is_static: bool,
118127
) -> (InstructionResult, Gas, Bytes) {
119128
call_inspectors!([&mut self.tracer], |inspector| {
120-
inspector.call_end(data, inputs, remaining_gas, ret, out.clone());
129+
inspector.call_end(data, inputs, remaining_gas, ret, out.clone(), is_static);
121130
});
122131
(ret, remaining_gas, out)
123132
}

crates/anvil/src/eth/error.rs

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -181,9 +181,6 @@ pub enum InvalidTransactionError {
181181
/// Thrown when a legacy tx was signed for a different chain
182182
#[error("Incompatible EIP-155 transaction, signed for another chain")]
183183
IncompatibleEIP155,
184-
/// Thrown when an access list is used before the berlin hard fork.
185-
#[error("Access lists are not supported before the Berlin hardfork")]
186-
AccessListNotSupported,
187184
}
188185

189186
impl From<revm::primitives::InvalidTransaction> for InvalidTransactionError {
@@ -206,7 +203,7 @@ impl From<revm::primitives::InvalidTransaction> for InvalidTransactionError {
206203
})
207204
}
208205
InvalidTransaction::RejectCallerWithCode => InvalidTransactionError::SenderNoEOA,
209-
InvalidTransaction::LackOfFundForMaxFee { .. } => {
206+
InvalidTransaction::LackOfFundForGasLimit { .. } => {
210207
InvalidTransactionError::InsufficientFunds
211208
}
212209
InvalidTransaction::OverflowPaymentInTransaction => {
@@ -220,9 +217,6 @@ impl From<revm::primitives::InvalidTransaction> for InvalidTransactionError {
220217
}
221218
InvalidTransaction::NonceTooHigh { .. } => InvalidTransactionError::NonceTooHigh,
222219
InvalidTransaction::NonceTooLow { .. } => InvalidTransactionError::NonceTooLow,
223-
InvalidTransaction::AccessListNotSupported => {
224-
InvalidTransactionError::AccessListNotSupported
225-
}
226220
}
227221
}
228222
}

crates/anvil/src/genesis.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ impl From<GenesisAccount> for AccountInfo {
146146
AccountInfo {
147147
balance: balance.into(),
148148
nonce: nonce.unwrap_or_default(),
149-
code_hash: code.as_ref().map(|code| code.hash_slow()).unwrap_or(KECCAK_EMPTY),
149+
code_hash: code.as_ref().map(|code| code.hash).unwrap_or(KECCAK_EMPTY),
150150
code,
151151
}
152152
}

crates/evm/src/executor/backend/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1099,7 +1099,7 @@ impl DatabaseExt for Backend {
10991099
// prevent issues in the new journalstate, e.g. assumptions that accounts are loaded
11001100
// if the account is not touched, we reload it, if it's touched we clone it
11011101
for (addr, acc) in journaled_state.state.iter() {
1102-
if acc.is_touched() {
1102+
if acc.is_touched {
11031103
merge_journaled_state_data(
11041104
b160_to_h160(*addr),
11051105
journaled_state,

crates/evm/src/executor/fork/cache.rs

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
//! Cache related abstraction
22
use crate::executor::backend::snapshot::StateSnapshot;
3+
use hashbrown::HashMap as Map;
34
use parking_lot::RwLock;
45
use revm::{
5-
primitives::{
6-
Account, AccountInfo, AccountStatus, HashMap as Map, B160, B256, KECCAK_EMPTY, U256,
7-
},
6+
primitives::{Account, AccountInfo, B160, B256, KECCAK_EMPTY, U256},
87
DatabaseCommit,
98
};
109
use serde::{ser::SerializeMap, Deserialize, Deserializer, Serialize, Serializer};
@@ -257,17 +256,13 @@ impl MemDb {
257256
let mut storage = self.storage.write();
258257
let mut accounts = self.accounts.write();
259258
for (add, mut acc) in changes {
260-
if acc.is_empty() || acc.is_selfdestructed() {
259+
if acc.is_empty() || acc.is_destroyed {
261260
accounts.remove(&add);
262261
storage.remove(&add);
263262
} else {
264263
// insert account
265-
if let Some(code_hash) = acc
266-
.info
267-
.code
268-
.as_ref()
269-
.filter(|code| !code.is_empty())
270-
.map(|code| code.hash_slow())
264+
if let Some(code_hash) =
265+
acc.info.code.as_ref().filter(|code| !code.is_empty()).map(|code| code.hash)
271266
{
272267
acc.info.code_hash = code_hash;
273268
} else if acc.info.code_hash.is_zero() {
@@ -276,7 +271,7 @@ impl MemDb {
276271
accounts.insert(add, acc.info);
277272

278273
let acc_storage = storage.entry(add).or_default();
279-
if acc.status.contains(AccountStatus::Created) {
274+
if acc.storage_cleared {
280275
acc_storage.clear();
281276
}
282277
for (index, value) in acc.storage {

crates/evm/src/executor/inspector/access_list.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ impl<DB: Database> Inspector<DB> for AccessListTracer {
5656
&mut self,
5757
interpreter: &mut Interpreter,
5858
_data: &mut EVMData<'_, DB>,
59+
_is_static: bool,
5960
) -> InstructionResult {
6061
let pc = interpreter.program_counter();
6162
let op = interpreter.contract.bytecode.bytecode()[pc];

crates/evm/src/executor/inspector/cheatcodes/mapping.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ pub fn on_evm_step<DB: Database>(
9191
_data: &mut EVMData<'_, DB>,
9292
) {
9393
match interpreter.contract.bytecode.bytecode()[interpreter.program_counter()] {
94-
opcode::KECCAK256 => {
94+
opcode::SHA3 => {
9595
if interpreter.stack.peek(1) == Ok(revm::primitives::U256::from(0x40)) {
9696
let address = interpreter.contract.address;
9797
let offset = interpreter.stack.peek(0).expect("stack size > 1").to::<usize>();

0 commit comments

Comments
 (0)