fix(tracing): reduce stack memory when tracing (#5528)

This commit is contained in:
gbrew
2023-11-22 10:32:28 -07:00
committed by GitHub
parent 9ecdea7eef
commit de048c4561
3 changed files with 7 additions and 9 deletions

View File

@@ -453,10 +453,10 @@ impl ParityTraceBuilder {
}
};
let mut push_stack = step.push_stack.clone().unwrap_or_default();
for idx in (0..show_stack).rev() {
if let Some(stack) = step.stack.as_ref() {
if let Some(stack) = step.stack.as_ref() {
for idx in (0..show_stack).rev() {
if stack.len() > idx {
push_stack.push(stack.peek(idx).unwrap_or_default())
push_stack.push(stack[stack.len() - idx - 1])
}
}
}

View File

@@ -282,7 +282,7 @@ impl TracingInspector {
.record_memory_snapshots
.then(|| RecordedMemory::new(interp.shared_memory.context_memory().to_vec()))
.unwrap_or_default();
let stack = self.config.record_stack_snapshots.then(|| interp.stack.clone());
let stack = self.config.record_stack_snapshots.then(|| interp.stack.data().clone());
let op = OpCode::new(interp.current_opcode())
.or_else(|| {

View File

@@ -10,9 +10,7 @@ use reth_rpc_types::trace::{
SelfdestructAction, TraceOutput, TransactionTrace,
},
};
use revm::interpreter::{
opcode, CallContext, CallScheme, CreateScheme, InstructionResult, OpCode, Stack,
};
use revm::interpreter::{opcode, CallContext, CallScheme, CreateScheme, InstructionResult, OpCode};
use serde::{Deserialize, Serialize};
use std::collections::{BTreeMap, VecDeque};
@@ -511,7 +509,7 @@ pub(crate) struct CallTraceStep {
/// Current contract address
pub(crate) contract: Address,
/// Stack before step execution
pub(crate) stack: Option<Stack>,
pub(crate) stack: Option<Vec<U256>>,
/// The new stack items placed by this step if any
pub(crate) push_stack: Option<Vec<U256>>,
/// All allocated memory in a step
@@ -563,7 +561,7 @@ impl CallTraceStep {
};
if opts.is_stack_enabled() {
log.stack = self.stack.as_ref().map(|stack| stack.data().clone());
log.stack = self.stack.clone();
}
if opts.is_memory_enabled() {