diff --git a/crates/revm/revm-inspectors/src/tracing/mod.rs b/crates/revm/revm-inspectors/src/tracing/mod.rs index d12503b2fb..a12b1e131b 100644 --- a/crates/revm/revm-inspectors/src/tracing/mod.rs +++ b/crates/revm/revm-inspectors/src/tracing/mod.rs @@ -212,6 +212,13 @@ impl TracingInspector { self.step_stack.pop().expect("can't fill step without starting a step first"); let step = &mut self.traces.arena[trace_idx].trace.steps[step_idx]; + if self.config.record_memory_snapshots { + // resize memory so opcodes that allocated memory is correctly displayed + if interp.memory.len() > step.memory.len() { + step.memory.resize(interp.memory.len()); + } + } + if let Some(pc) = interp.program_counter().checked_sub(1) { if self.config.record_state_diff { let op = interp.contract.bytecode.bytecode()[pc]; diff --git a/crates/revm/revm-inspectors/src/tracing/types.rs b/crates/revm/revm-inspectors/src/tracing/types.rs index 458d85dc6a..e7630309f9 100644 --- a/crates/revm/revm-inspectors/src/tracing/types.rs +++ b/crates/revm/revm-inspectors/src/tracing/types.rs @@ -445,7 +445,9 @@ pub(crate) struct CallTraceStep { pub(crate) contract: Address, /// Stack before step execution pub(crate) stack: Stack, - /// Memory before step execution + /// All allocated memory in a step + /// + /// This will be empty if memory capture is disabled pub(crate) memory: Memory, /// Size of memory pub(crate) memory_size: usize,