Skip to content

Commit a0a31c3

Browse files
authored
fix(evm): revert all revm changes (foundry-rs#5610)
* chore: revert all revm changes * chore: fmt
1 parent 5f22627 commit a0a31c3

File tree

19 files changed

+94
-79
lines changed

19 files changed

+94
-79
lines changed

Cargo.lock

Lines changed: 5 additions & 32 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
@@ -135,4 +135,4 @@ solang-parser = "=0.3.1"
135135
#ethers-solc = { path = "../ethers-rs/ethers-solc" }
136136

137137
[patch.crates-io]
138-
revm = { git = "https://github.com/bluealloy/revm/", rev = "bc4d203bf0b5f5c01868477c8e98d3abd6bb92ab" }
138+
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
@@ -61,21 +61,27 @@ impl<DB: Database> revm::Inspector<DB> for Inspector {
6161
&mut self,
6262
interp: &mut Interpreter,
6363
data: &mut EVMData<'_, DB>,
64+
is_static: bool,
6465
) -> InstructionResult {
6566
call_inspectors!(
6667
inspector,
6768
[&mut self.gas.as_deref().map(|gas| gas.borrow_mut()), &mut self.tracer],
68-
{ inspector.initialize_interp(interp, data) }
69+
{ inspector.initialize_interp(interp, data, is_static) }
6970
);
7071
InstructionResult::Continue
7172
}
7273

73-
fn step(&mut self, interp: &mut Interpreter, data: &mut EVMData<'_, DB>) -> InstructionResult {
74+
fn step(
75+
&mut self,
76+
interp: &mut Interpreter,
77+
data: &mut EVMData<'_, DB>,
78+
is_static: bool,
79+
) -> InstructionResult {
7480
call_inspectors!(
7581
inspector,
7682
[&mut self.gas.as_deref().map(|gas| gas.borrow_mut()), &mut self.tracer],
7783
{
78-
inspector.step(interp, data);
84+
inspector.step(interp, data, is_static);
7985
}
8086
);
8187
InstructionResult::Continue
@@ -105,13 +111,14 @@ impl<DB: Database> revm::Inspector<DB> for Inspector {
105111
&mut self,
106112
interp: &mut Interpreter,
107113
data: &mut EVMData<'_, DB>,
114+
is_static: bool,
108115
eval: InstructionResult,
109116
) -> InstructionResult {
110117
call_inspectors!(
111118
inspector,
112119
[&mut self.gas.as_deref().map(|gas| gas.borrow_mut()), &mut self.tracer],
113120
{
114-
inspector.step_end(interp, data, eval);
121+
inspector.step_end(interp, data, is_static, eval);
115122
}
116123
);
117124
eval
@@ -121,6 +128,7 @@ impl<DB: Database> revm::Inspector<DB> for Inspector {
121128
&mut self,
122129
data: &mut EVMData<'_, DB>,
123130
call: &mut CallInputs,
131+
is_static: bool,
124132
) -> (InstructionResult, Gas, Bytes) {
125133
call_inspectors!(
126134
inspector,
@@ -130,7 +138,7 @@ impl<DB: Database> revm::Inspector<DB> for Inspector {
130138
Some(&mut self.log_collector)
131139
],
132140
{
133-
inspector.call(data, call);
141+
inspector.call(data, call, is_static);
134142
}
135143
);
136144

@@ -144,12 +152,13 @@ impl<DB: Database> revm::Inspector<DB> for Inspector {
144152
remaining_gas: Gas,
145153
ret: InstructionResult,
146154
out: Bytes,
155+
is_static: bool,
147156
) -> (InstructionResult, Gas, Bytes) {
148157
call_inspectors!(
149158
inspector,
150159
[&mut self.gas.as_deref().map(|gas| gas.borrow_mut()), &mut self.tracer],
151160
{
152-
inspector.call_end(data, inputs, remaining_gas, ret, out.clone());
161+
inspector.call_end(data, inputs, remaining_gas, ret, out.clone(), is_static);
153162
}
154163
);
155164
(ret, remaining_gas, out)

crates/anvil/src/eth/error.rs

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

187184
impl From<revm::primitives::InvalidTransaction> for InvalidTransactionError {
@@ -204,7 +201,7 @@ impl From<revm::primitives::InvalidTransaction> for InvalidTransactionError {
204201
})
205202
}
206203
InvalidTransaction::RejectCallerWithCode => InvalidTransactionError::SenderNoEOA,
207-
InvalidTransaction::LackOfFundForMaxFee { .. } => {
204+
InvalidTransaction::LackOfFundForGasLimit { .. } => {
208205
InvalidTransactionError::InsufficientFunds
209206
}
210207
InvalidTransaction::OverflowPaymentInTransaction => {
@@ -218,9 +215,6 @@ impl From<revm::primitives::InvalidTransaction> for InvalidTransactionError {
218215
}
219216
InvalidTransaction::NonceTooHigh { .. } => InvalidTransactionError::NonceTooHigh,
220217
InvalidTransaction::NonceTooLow { .. } => InvalidTransactionError::NonceTooLow,
221-
InvalidTransaction::AccessListNotSupported => {
222-
InvalidTransactionError::AccessListNotSupported
223-
}
224218
}
225219
}
226220
}

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};
@@ -251,17 +250,13 @@ impl MemDb {
251250
let mut storage = self.storage.write();
252251
let mut accounts = self.accounts.write();
253252
for (add, mut acc) in changes {
254-
if acc.is_empty() || acc.is_selfdestructed() {
253+
if acc.is_empty() || acc.is_destroyed {
255254
accounts.remove(&add);
256255
storage.remove(&add);
257256
} else {
258257
// insert account
259-
if let Some(code_hash) = acc
260-
.info
261-
.code
262-
.as_ref()
263-
.filter(|code| !code.is_empty())
264-
.map(|code| code.hash_slow())
258+
if let Some(code_hash) =
259+
acc.info.code.as_ref().filter(|code| !code.is_empty()).map(|code| code.hash)
265260
{
266261
acc.info.code_hash = code_hash;
267262
} else if acc.info.code_hash.is_zero() {
@@ -270,7 +265,7 @@ impl MemDb {
270265
accounts.insert(add, acc.info);
271266

272267
let acc_storage = storage.entry(add).or_default();
273-
if acc.status.contains(AccountStatus::Created) {
268+
if acc.storage_cleared {
274269
acc_storage.clear();
275270
}
276271
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
@@ -58,6 +58,7 @@ where
5858
&mut self,
5959
interpreter: &mut Interpreter,
6060
_data: &mut EVMData<'_, DB>,
61+
_is_static: bool,
6162
) -> InstructionResult {
6263
let pc = interpreter.program_counter();
6364
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>();

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

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -303,6 +303,7 @@ where
303303
&mut self,
304304
_: &mut Interpreter,
305305
data: &mut EVMData<'_, DB>,
306+
_: bool,
306307
) -> InstructionResult {
307308
// When the first interpreter is initialized we've circumvented the balance and gas checks,
308309
// so we apply our actual block data with the correct fees and all.
@@ -320,6 +321,7 @@ where
320321
&mut self,
321322
interpreter: &mut Interpreter,
322323
data: &mut EVMData<'_, DB>,
324+
_: bool,
323325
) -> InstructionResult {
324326
self.pc = interpreter.program_counter();
325327

@@ -520,7 +522,7 @@ where
520522
(CALLCODE, 5, 6, true),
521523
(STATICCALL, 4, 5, true),
522524
(DELEGATECALL, 4, 5, true),
523-
(KECCAK256, 0, 1, false),
525+
(SHA3, 0, 1, false),
524526
(LOG0, 0, 1, false),
525527
(LOG1, 0, 1, false),
526528
(LOG2, 0, 1, false),
@@ -575,6 +577,7 @@ where
575577
&mut self,
576578
data: &mut EVMData<'_, DB>,
577579
call: &mut CallInputs,
580+
is_static: bool,
578581
) -> (InstructionResult, Gas, bytes::Bytes) {
579582
if call.contract == h160_to_b160(CHEATCODE_ADDRESS) {
580583
let gas = Gas::new(call.gas_limit);
@@ -683,7 +686,7 @@ where
683686
// because we only need the from, to, value, and data. We can later change this
684687
// into 1559, in the cli package, relatively easily once we
685688
// know the target chain supports EIP-1559.
686-
if !call.is_static {
689+
if !is_static {
687690
if let Err(err) = data
688691
.journaled_state
689692
.load_account(h160_to_b160(broadcast.new_origin), data.db)
@@ -748,6 +751,7 @@ where
748751
remaining_gas: Gas,
749752
status: InstructionResult,
750753
retdata: bytes::Bytes,
754+
_: bool,
751755
) -> (InstructionResult, Gas, bytes::Bytes) {
752756
if call.contract == h160_to_b160(CHEATCODE_ADDRESS) ||
753757
call.contract == h160_to_b160(HARDHAT_CONSOLE_ADDRESS)

0 commit comments

Comments
 (0)