Skip to content

Commit a9857e3

Browse files
authored
chore(deps): bump revm 30+, alloy-evm, revm-inspectors (#12094)
* bump deps * fix types * pass in required bytecode and bytecode_hash into call inputs * address breaking changes from paradigmxyz/revm-inspectors#355 * clean up * apply fix * use updated alloy-evm, revm-inspectors * bump deps * bump foundry-fork-db * merge in master * bump to revm 30.2.0 * fix lockfile * bump revm-inspectors * fix regression in mockFunction cheatcode, isolate is a known limitation * fix default depth, related (?): paradigmxyz/revm-inspectors#369 * add reproducible startPrank panic * update test * ensure new_caller is touched & loaded, example case is when startPrank is done at setup, we need to ensure when the test is ran the "from" account remains in scope * add script function with vm.broadcastStart in setup * store ref to node & step, retrieve depth and contract_addr later
1 parent ad54afd commit a9857e3

File tree

15 files changed

+617
-1766
lines changed

15 files changed

+617
-1766
lines changed

Cargo.lock

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

Cargo.toml

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,7 @@ foundry-compilers = { version = "0.19.5", default-features = false, features = [
228228
"rustls",
229229
"svm-solc",
230230
] }
231-
foundry-fork-db = "0.18"
231+
foundry-fork-db = "0.19"
232232
solang-parser = { version = "=0.3.9", package = "foundry-solang-parser" }
233233
solar = { package = "solar-compiler", version = "=0.1.8", default-features = false }
234234
svm = { package = "svm-rs", version = "0.5", default-features = false, features = [
@@ -286,12 +286,12 @@ op-alloy-rpc-types = "0.20.0"
286286
op-alloy-flz = "0.13.1"
287287

288288
## revm
289-
revm = { version = "29.0.0", default-features = false }
290-
revm-inspectors = { version = "0.30.0", features = ["serde"] }
291-
op-revm = { version = "10.0.0", default-features = false }
289+
revm = { version = "30.2.0", default-features = false }
290+
revm-inspectors = { version = "0.31.2", features = ["serde"] }
291+
op-revm = { version = "11.1.2", default-features = false }
292292
## alloy-evm
293-
alloy-evm = "0.21.1"
294-
alloy-op-evm = "0.21.1"
293+
alloy-evm = "0.22.3"
294+
alloy-op-evm = "0.22.3"
295295

296296
## cli
297297
anstream = "0.6"
@@ -435,18 +435,18 @@ rexpect = { git = "https://github.com/rust-cli/rexpect", rev = "2ed0b1898d7edaf6
435435
# alloy-transport-ws = { git = "https://github.com/alloy-rs/alloy", rev = "7fab7ee" }
436436

437437
## alloy-evm
438-
# alloy-evm = { git = "https://github.com/alloy-rs/evm.git", rev = "3c6cebb" }
439-
# alloy-op-evm = { git = "https://github.com/alloy-rs/evm.git", rev = "3c6cebb" }
438+
# alloy-evm = { git = "https://github.com/alloy-rs/evm.git", rev = "085ad53" }
439+
# alloy-op-evm = { git = "https://github.com/alloy-rs/evm.git", rev = "085ad53" }
440440

441441
## revm
442442
# revm = { git = "https://github.com/bluealloy/revm.git", rev = "d9cda3a" }
443443
# op-revm = { git = "https://github.com/bluealloy/revm.git", rev = "d9cda3a" }
444-
# revm-inspectors = { git = "https://github.com/zerosnacks/revm-inspectors.git", rev = "74e215d" }
444+
# revm-inspectors = { git = "https://github.com/zerosnacks/revm-inspectors.git", rev = "340d37e" }
445445

446446
## foundry
447447
# foundry-block-explorers = { git = "https://github.com/foundry-rs/block-explorers.git", rev = "f5b46b2" }
448448
# foundry-compilers = { git = "https://github.com/foundry-rs/compilers.git", branch = "main" }
449-
# foundry-fork-db = { git = "https://github.com/foundry-rs/foundry-fork-db", rev = "eee6563" }
449+
# foundry-fork-db = { git = "https://github.com/foundry-rs/foundry-fork-db", rev = "be95912" }
450450

451451
# solar
452452
# solar = { package = "solar-compiler", git = "https://github.com/paradigmxyz/solar.git", branch = "main" }

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3712,7 +3712,10 @@ impl TransactionValidator for Backend {
37123712
&& max_fee_per_blob_gas < blob_gas_and_price.blob_gasprice
37133713
{
37143714
warn!(target: "backend", "max fee per blob gas={}, too low, block blob gas price={}", max_fee_per_blob_gas, blob_gas_and_price.blob_gasprice);
3715-
return Err(InvalidTransactionError::BlobFeeCapTooLow);
3715+
return Err(InvalidTransactionError::BlobFeeCapTooLow(
3716+
max_fee_per_blob_gas,
3717+
blob_gas_and_price.blob_gasprice,
3718+
));
37163719
}
37173720

37183721
let max_cost = tx.max_cost();

crates/anvil/src/eth/error.rs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -284,7 +284,7 @@ pub enum InvalidTransactionError {
284284
/// Thrown when the block's `blob_gas_price` is greater than tx-specified
285285
/// `max_fee_per_blob_gas` after Cancun.
286286
#[error("Block `blob_gas_price` is greater than tx-specified `max_fee_per_blob_gas`")]
287-
BlobFeeCapTooLow,
287+
BlobFeeCapTooLow(u128, u128),
288288
/// Thrown when we receive a tx with `blob_versioned_hashes` and we're not on the Cancun hard
289289
/// fork.
290290
#[error("Block `blob_versioned_hashes` is not supported before the Cancun hardfork")]
@@ -345,7 +345,10 @@ impl From<InvalidTransaction> for InvalidTransactionError {
345345
InvalidTransaction::NonceTooHigh { .. } => Self::NonceTooHigh,
346346
InvalidTransaction::NonceTooLow { .. } => Self::NonceTooLow,
347347
InvalidTransaction::AccessListNotSupported => Self::AccessListNotSupported,
348-
InvalidTransaction::BlobGasPriceGreaterThanMax => Self::BlobFeeCapTooLow,
348+
InvalidTransaction::BlobGasPriceGreaterThanMax {
349+
block_blob_gas_price,
350+
tx_max_fee_per_blob_gas,
351+
} => Self::BlobFeeCapTooLow(block_blob_gas_price, tx_max_fee_per_blob_gas),
349352
InvalidTransaction::BlobVersionedHashesNotSupported => {
350353
Self::BlobVersionedHashesNotSupported
351354
}
@@ -369,7 +372,8 @@ impl From<InvalidTransaction> for InvalidTransactionError {
369372
| InvalidTransaction::EmptyAuthorizationList
370373
| InvalidTransaction::Eip7873NotSupported
371374
| InvalidTransaction::Eip7873MissingTarget
372-
| InvalidTransaction::MissingChainId => Self::Revm(err),
375+
| InvalidTransaction::MissingChainId
376+
| InvalidTransaction::Str(_) => Self::Revm(err),
373377
}
374378
}
375379
}

crates/cheatcodes/src/evm.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ use std::{
4747
mod record_debug_step;
4848
use foundry_common::fmt::format_token_raw;
4949
use foundry_config::evm_spec_id;
50-
use record_debug_step::{convert_call_trace_to_debug_step, flatten_call_trace};
50+
use record_debug_step::{convert_call_trace_ctx_to_debug_step, flatten_call_trace};
5151
use serde::Serialize;
5252

5353
mod fork;
@@ -1085,7 +1085,7 @@ impl Cheatcode for stopAndReturnDebugTraceRecordingCall {
10851085
let steps = flatten_call_trace(0, root, record_info.start_node_idx);
10861086

10871087
let debug_steps: Vec<DebugStep> =
1088-
steps.iter().map(|&step| convert_call_trace_to_debug_step(step)).collect();
1088+
steps.iter().map(|step| convert_call_trace_ctx_to_debug_step(step)).collect();
10891089
// Free up memory by clearing the steps if they are not recorded outside of cheatcode usage.
10901090
if !record_info.original_tracer_config.record_steps {
10911091
tracer.traces_mut().nodes_mut().iter_mut().for_each(|node| {

crates/cheatcodes/src/evm/record_debug_step.rs

Lines changed: 37 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,24 @@ use foundry_evm_traces::CallTraceArena;
44
use revm::{bytecode::opcode::OpCode, interpreter::InstructionResult};
55

66
use foundry_evm_core::buffer::{BufferKind, get_buffer_accesses};
7-
use revm_inspectors::tracing::types::{CallTraceStep, RecordedMemory, TraceMemberOrder};
7+
use revm_inspectors::tracing::types::{
8+
CallTraceNode, CallTraceStep, RecordedMemory, TraceMemberOrder,
9+
};
810
use spec::Vm::DebugStep;
911

12+
// Context for a CallTraceStep, includes depth and contract address.
13+
pub(crate) struct CallTraceCtx<'a> {
14+
pub node: &'a CallTraceNode,
15+
pub step: &'a CallTraceStep,
16+
}
17+
1018
// Do a depth first traverse of the nodes and steps and return steps
1119
// that are after `node_start_idx`
12-
pub(crate) fn flatten_call_trace(
20+
pub(crate) fn flatten_call_trace<'a>(
1321
root: usize,
14-
arena: &CallTraceArena,
22+
arena: &'a CallTraceArena,
1523
node_start_idx: usize,
16-
) -> Vec<&CallTraceStep> {
24+
) -> Vec<CallTraceCtx<'a>> {
1725
let mut steps = Vec::new();
1826
let mut record_started = false;
1927

@@ -31,7 +39,7 @@ fn recursive_flatten_call_trace<'a>(
3139
arena: &'a CallTraceArena,
3240
node_start_idx: usize,
3341
record_started: &mut bool,
34-
flatten_steps: &mut Vec<&'a CallTraceStep>,
42+
flatten_steps: &mut Vec<CallTraceCtx<'a>>,
3543
) {
3644
// Once node_idx exceeds node_start_idx, start recording steps
3745
// for all the recursive processing.
@@ -46,7 +54,7 @@ fn recursive_flatten_call_trace<'a>(
4654
TraceMemberOrder::Step(step_idx) => {
4755
if *record_started {
4856
let step = &node.trace.steps[*step_idx];
49-
flatten_steps.push(step);
57+
flatten_steps.push(CallTraceCtx { node, step });
5058
}
5159
}
5260
TraceMemberOrder::Call(call_idx) => {
@@ -65,25 +73,34 @@ fn recursive_flatten_call_trace<'a>(
6573
}
6674

6775
// Function to convert CallTraceStep to DebugStep
68-
pub(crate) fn convert_call_trace_to_debug_step(step: &CallTraceStep) -> DebugStep {
69-
let opcode = step.op.get();
70-
let stack = get_stack_inputs_for_opcode(opcode, step.stack.as_deref());
71-
72-
let memory = get_memory_input_for_opcode(opcode, step.stack.as_deref(), step.memory.as_ref());
73-
74-
let is_out_of_gas = step.status == Some(InstructionResult::OutOfGas)
75-
|| step.status == Some(InstructionResult::MemoryOOG)
76-
|| step.status == Some(InstructionResult::MemoryLimitOOG)
77-
|| step.status == Some(InstructionResult::PrecompileOOG)
78-
|| step.status == Some(InstructionResult::InvalidOperandOOG);
76+
pub(crate) fn convert_call_trace_ctx_to_debug_step(ctx: &CallTraceCtx) -> DebugStep {
77+
let opcode = ctx.step.op.get();
78+
let stack = get_stack_inputs_for_opcode(opcode, ctx.step.stack.as_deref());
79+
80+
let memory =
81+
get_memory_input_for_opcode(opcode, ctx.step.stack.as_deref(), ctx.step.memory.as_ref());
82+
83+
let is_out_of_gas = matches!(
84+
ctx.step.status,
85+
Some(
86+
InstructionResult::OutOfGas
87+
| InstructionResult::MemoryOOG
88+
| InstructionResult::MemoryLimitOOG
89+
| InstructionResult::PrecompileOOG
90+
| InstructionResult::InvalidOperandOOG
91+
)
92+
);
93+
94+
let depth = ctx.node.trace.depth as u64 + 1;
95+
let contract_addr = ctx.node.execution_address();
7996

8097
DebugStep {
8198
stack,
8299
memoryInput: memory,
83-
opcode: step.op.get(),
84-
depth: step.depth,
100+
opcode: ctx.step.op.get(),
101+
depth,
85102
isOutOfGas: is_out_of_gas,
86-
contractAddr: step.contract,
103+
contractAddr: contract_addr,
87104
}
88105
}
89106

crates/cheatcodes/src/inspector.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use crate::{
44
CheatsConfig, CheatsCtxt, DynCheatcode, Error, Result,
55
Vm::{self, AccountAccess},
66
evm::{
7-
DealRecord, GasRecord, RecordAccess,
7+
DealRecord, GasRecord, RecordAccess, journaled_account,
88
mock::{MockCallDataContext, MockCallReturnData},
99
prank::Prank,
1010
},
@@ -835,6 +835,8 @@ impl Cheatcodes {
835835

836836
// At the target depth we set `msg.sender`
837837
if curr_depth == prank.depth {
838+
// Ensure new caller is loaded and touched
839+
let _ = journaled_account(ecx, prank.new_caller);
838840
call.caller = prank.new_caller;
839841
prank_applied = true;
840842
}
@@ -1636,6 +1638,8 @@ impl Inspector<EthEvmContext<&mut dyn DatabaseExt>> for Cheatcodes {
16361638

16371639
// At the target depth we set `msg.sender`
16381640
if curr_depth == prank.depth {
1641+
// Ensure new caller is loaded and touched
1642+
let _ = journaled_account(ecx, prank.new_caller);
16391643
input.set_caller(prank.new_caller);
16401644
prank_applied = true;
16411645
}

crates/evm/core/src/either_evm.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@ where
106106
type Inspector = I;
107107
type Precompiles = P;
108108
type Spec = SpecId;
109+
type BlockEnv = BlockEnv;
109110

110111
fn block(&self) -> &BlockEnv {
111112
match self {

crates/evm/core/src/evm.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,7 @@ fn get_create2_factory_call_inputs(
105105
CallInputs {
106106
caller: inputs.caller,
107107
bytecode_address: deployer,
108+
known_bytecode: None,
108109
target_address: deployer,
109110
scheme: CallScheme::Call,
110111
value: CallValue::Transfer(inputs.value),
@@ -160,6 +161,7 @@ impl<'db, I: InspectorExt> Evm for FoundryEvm<'db, I> {
160161
type HaltReason = HaltReason;
161162
type Spec = SpecId;
162163
type Tx = TxEnv;
164+
type BlockEnv = BlockEnv;
163165

164166
fn block(&self) -> &BlockEnv {
165167
&self.inner.block

crates/evm/evm/src/inspectors/custom_printer.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ where
6262
}
6363

6464
fn step_end(&mut self, interpreter: &mut Interpreter, _context: &mut CTX) {
65-
self.gas_inspector.step_end(&mut interpreter.gas);
65+
self.gas_inspector.step_end(&interpreter.gas);
6666
}
6767

6868
fn call_end(&mut self, _context: &mut CTX, _inputs: &CallInputs, outcome: &mut CallOutcome) {

0 commit comments

Comments
 (0)