Skip to content

Commit efedf1f

Browse files
authored
feat(evm): Use latest revm main commit (foundry-rs#5669)
* Revert "fix(`evm`): revert all revm changes (foundry-rs#5610)" This reverts commit a0a31c3. * upgrade revm * fmt
1 parent b536f51 commit efedf1f

File tree

19 files changed

+75
-87
lines changed

19 files changed

+75
-87
lines changed

Cargo.lock

Lines changed: 32 additions & 5 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/", branch = "release/v25" }
157+
revm = { git = "https://github.com/bluealloy/revm/", rev = "eb6a9f09e8ac2227bc1c353b698ad9e68a9574b2" }

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

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

6463
#[inline]
65-
fn step(
66-
&mut self,
67-
interp: &mut Interpreter,
68-
data: &mut EVMData<'_, DB>,
69-
is_static: bool,
70-
) -> InstructionResult {
64+
fn step(&mut self, interp: &mut Interpreter, data: &mut EVMData<'_, DB>) -> InstructionResult {
7165
call_inspectors!([&mut self.tracer], |inspector| {
72-
inspector.step(interp, data, is_static);
66+
inspector.step(interp, data);
7367
});
7468
InstructionResult::Continue
7569
}
@@ -92,11 +86,10 @@ impl<DB: Database> revm::Inspector<DB> for Inspector {
9286
&mut self,
9387
interp: &mut Interpreter,
9488
data: &mut EVMData<'_, DB>,
95-
is_static: bool,
9689
eval: InstructionResult,
9790
) -> InstructionResult {
9891
call_inspectors!([&mut self.tracer], |inspector| {
99-
inspector.step_end(interp, data, is_static, eval);
92+
inspector.step_end(interp, data, eval);
10093
});
10194
eval
10295
}
@@ -106,10 +99,9 @@ impl<DB: Database> revm::Inspector<DB> for Inspector {
10699
&mut self,
107100
data: &mut EVMData<'_, DB>,
108101
call: &mut CallInputs,
109-
is_static: bool,
110102
) -> (InstructionResult, Gas, Bytes) {
111103
call_inspectors!([&mut self.tracer, Some(&mut self.log_collector)], |inspector| {
112-
inspector.call(data, call, is_static);
104+
inspector.call(data, call);
113105
});
114106

115107
(InstructionResult::Continue, Gas::new(call.gas_limit), Bytes::new())
@@ -123,10 +115,9 @@ impl<DB: Database> revm::Inspector<DB> for Inspector {
123115
remaining_gas: Gas,
124116
ret: InstructionResult,
125117
out: Bytes,
126-
is_static: bool,
127118
) -> (InstructionResult, Gas, Bytes) {
128119
call_inspectors!([&mut self.tracer], |inspector| {
129-
inspector.call_end(data, inputs, remaining_gas, ret, out.clone(), is_static);
120+
inspector.call_end(data, inputs, remaining_gas, ret, out.clone());
130121
});
131122
(ret, remaining_gas, out)
132123
}

crates/anvil/src/eth/error.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,9 @@ 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,
184187
}
185188

186189
impl From<revm::primitives::InvalidTransaction> for InvalidTransactionError {
@@ -203,7 +206,7 @@ impl From<revm::primitives::InvalidTransaction> for InvalidTransactionError {
203206
})
204207
}
205208
InvalidTransaction::RejectCallerWithCode => InvalidTransactionError::SenderNoEOA,
206-
InvalidTransaction::LackOfFundForGasLimit { .. } => {
209+
InvalidTransaction::LackOfFundForMaxFee { .. } => {
207210
InvalidTransactionError::InsufficientFunds
208211
}
209212
InvalidTransaction::OverflowPaymentInTransaction => {
@@ -217,6 +220,9 @@ impl From<revm::primitives::InvalidTransaction> for InvalidTransactionError {
217220
}
218221
InvalidTransaction::NonceTooHigh { .. } => InvalidTransactionError::NonceTooHigh,
219222
InvalidTransaction::NonceTooLow { .. } => InvalidTransactionError::NonceTooLow,
223+
InvalidTransaction::AccessListNotSupported => {
224+
InvalidTransactionError::AccessListNotSupported
225+
}
220226
}
221227
}
222228
}

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).unwrap_or(KECCAK_EMPTY),
149+
code_hash: code.as_ref().map(|code| code.hash_slow()).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: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
//! Cache related abstraction
22
use crate::executor::backend::snapshot::StateSnapshot;
3-
use hashbrown::HashMap as Map;
43
use parking_lot::RwLock;
54
use revm::{
6-
primitives::{Account, AccountInfo, B160, B256, KECCAK_EMPTY, U256},
5+
primitives::{
6+
Account, AccountInfo, AccountStatus, HashMap as Map, B160, B256, KECCAK_EMPTY, U256,
7+
},
78
DatabaseCommit,
89
};
910
use serde::{ser::SerializeMap, Deserialize, Deserializer, Serialize, Serializer};
@@ -256,13 +257,17 @@ impl MemDb {
256257
let mut storage = self.storage.write();
257258
let mut accounts = self.accounts.write();
258259
for (add, mut acc) in changes {
259-
if acc.is_empty() || acc.is_destroyed {
260+
if acc.is_empty() || acc.is_selfdestructed() {
260261
accounts.remove(&add);
261262
storage.remove(&add);
262263
} else {
263264
// insert account
264-
if let Some(code_hash) =
265-
acc.info.code.as_ref().filter(|code| !code.is_empty()).map(|code| code.hash)
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())
266271
{
267272
acc.info.code_hash = code_hash;
268273
} else if acc.info.code_hash.is_zero() {
@@ -271,7 +276,7 @@ impl MemDb {
271276
accounts.insert(add, acc.info);
272277

273278
let acc_storage = storage.entry(add).or_default();
274-
if acc.storage_cleared {
279+
if acc.status.contains(AccountStatus::Created) {
275280
acc_storage.clear();
276281
}
277282
for (index, value) in acc.storage {

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,6 @@ impl<DB: Database> Inspector<DB> for AccessListTracer {
5656
&mut self,
5757
interpreter: &mut Interpreter,
5858
_data: &mut EVMData<'_, DB>,
59-
_is_static: bool,
6059
) -> InstructionResult {
6160
let pc = interpreter.program_counter();
6261
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::SHA3 => {
94+
opcode::KECCAK256 => {
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>();

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

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -294,7 +294,6 @@ impl<DB: DatabaseExt> Inspector<DB> for Cheatcodes {
294294
&mut self,
295295
_: &mut Interpreter,
296296
data: &mut EVMData<'_, DB>,
297-
_: bool,
298297
) -> InstructionResult {
299298
// When the first interpreter is initialized we've circumvented the balance and gas checks,
300299
// so we apply our actual block data with the correct fees and all.
@@ -312,7 +311,6 @@ impl<DB: DatabaseExt> Inspector<DB> for Cheatcodes {
312311
&mut self,
313312
interpreter: &mut Interpreter,
314313
data: &mut EVMData<'_, DB>,
315-
_: bool,
316314
) -> InstructionResult {
317315
self.pc = interpreter.program_counter();
318316

@@ -513,7 +511,7 @@ impl<DB: DatabaseExt> Inspector<DB> for Cheatcodes {
513511
(CALLCODE, 5, 6, true),
514512
(STATICCALL, 4, 5, true),
515513
(DELEGATECALL, 4, 5, true),
516-
(SHA3, 0, 1, false),
514+
(KECCAK256, 0, 1, false),
517515
(LOG0, 0, 1, false),
518516
(LOG1, 0, 1, false),
519517
(LOG2, 0, 1, false),
@@ -568,7 +566,6 @@ impl<DB: DatabaseExt> Inspector<DB> for Cheatcodes {
568566
&mut self,
569567
data: &mut EVMData<'_, DB>,
570568
call: &mut CallInputs,
571-
is_static: bool,
572569
) -> (InstructionResult, Gas, bytes::Bytes) {
573570
if call.contract == h160_to_b160(CHEATCODE_ADDRESS) {
574571
let gas = Gas::new(call.gas_limit);
@@ -677,7 +674,7 @@ impl<DB: DatabaseExt> Inspector<DB> for Cheatcodes {
677674
// because we only need the from, to, value, and data. We can later change this
678675
// into 1559, in the cli package, relatively easily once we
679676
// know the target chain supports EIP-1559.
680-
if !is_static {
677+
if !call.is_static {
681678
if let Err(err) = data
682679
.journaled_state
683680
.load_account(h160_to_b160(broadcast.new_origin), data.db)
@@ -742,7 +739,6 @@ impl<DB: DatabaseExt> Inspector<DB> for Cheatcodes {
742739
remaining_gas: Gas,
743740
status: InstructionResult,
744741
retdata: bytes::Bytes,
745-
_: bool,
746742
) -> (InstructionResult, Gas, bytes::Bytes) {
747743
if call.contract == h160_to_b160(CHEATCODE_ADDRESS) ||
748744
call.contract == h160_to_b160(HARDHAT_CONSOLE_ADDRESS)

0 commit comments

Comments
 (0)