Skip to content

Commit e97a35a

Browse files
authored
feat: temporarily re-introduce custom trace printer (#7716)
1 parent 18e0d03 commit e97a35a

File tree

3 files changed

+28
-7
lines changed

3 files changed

+28
-7
lines changed

crates/cast/bin/cmd/run.rs

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,7 @@ pub struct RunArgs {
3030
debug: bool,
3131

3232
/// Print out opcode traces.
33-
#[deprecated]
34-
#[arg(long, short, hide = true)]
33+
#[arg(long, short)]
3534
trace_printer: bool,
3635

3736
/// Executes the transaction only with the state from the previous block.
@@ -83,11 +82,6 @@ impl RunArgs {
8382
///
8483
/// Note: This executes the transaction(s) as is: Cheatcodes are disabled
8584
pub async fn run(self) -> Result<()> {
86-
#[allow(deprecated)]
87-
if self.trace_printer {
88-
eprintln!("WARNING: --trace-printer is deprecated and has no effect\n");
89-
}
90-
9185
let figment =
9286
Config::figment_with_root(find_project_root_path(None).unwrap()).merge(self.rpc);
9387
let evm_opts = figment.extract::<EvmOpts>()?;
@@ -214,6 +208,8 @@ impl RunArgs {
214208

215209
// Execute our transaction
216210
let result = {
211+
executor.set_trace_printer(self.trace_printer);
212+
217213
configure_tx_env(&mut env, &tx);
218214

219215
if let Some(to) = tx.to {

crates/evm/evm/src/executors/mod.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,12 @@ impl Executor {
171171
self
172172
}
173173

174+
#[inline]
175+
pub fn set_trace_printer(&mut self, trace_printer: bool) -> &mut Self {
176+
self.inspector.print(trace_printer);
177+
self
178+
}
179+
174180
#[inline]
175181
pub fn set_gas_limit(&mut self, gas_limit: U256) -> &mut Self {
176182
self.gas_limit = gas_limit;

crates/evm/evm/src/inspectors/stack.rs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ use foundry_evm_core::{
1111
use foundry_evm_coverage::HitMaps;
1212
use foundry_evm_traces::CallTraceArena;
1313
use revm::{
14+
inspectors::CustomPrintTracer,
1415
interpreter::{
1516
CallInputs, CallOutcome, CallScheme, CreateInputs, CreateOutcome, Gas, InstructionResult,
1617
Interpreter, InterpreterResult,
@@ -45,6 +46,8 @@ pub struct InspectorStackBuilder {
4546
pub logs: Option<bool>,
4647
/// Whether coverage info should be collected.
4748
pub coverage: Option<bool>,
49+
/// Whether to print all opcode traces into the console. Useful for debugging the EVM.
50+
pub print: Option<bool>,
4851
/// The chisel state inspector.
4952
pub chisel_state: Option<usize>,
5053
/// Whether to enable call isolation.
@@ -116,6 +119,13 @@ impl InspectorStackBuilder {
116119
self
117120
}
118121

122+
/// Set whether to enable the trace printer.
123+
#[inline]
124+
pub fn print(mut self, yes: bool) -> Self {
125+
self.print = Some(yes);
126+
self
127+
}
128+
119129
/// Set whether to enable the tracer.
120130
#[inline]
121131
pub fn trace(mut self, yes: bool) -> Self {
@@ -144,6 +154,7 @@ impl InspectorStackBuilder {
144154
debug,
145155
logs,
146156
coverage,
157+
print,
147158
chisel_state,
148159
enable_isolation,
149160
} = self;
@@ -162,6 +173,7 @@ impl InspectorStackBuilder {
162173
stack.collect_coverage(coverage.unwrap_or(false));
163174
stack.collect_logs(logs.unwrap_or(true));
164175
stack.enable_debugger(debug.unwrap_or(false));
176+
stack.print(print.unwrap_or(false));
165177
stack.tracing(trace.unwrap_or(false));
166178

167179
stack.enable_isolation(enable_isolation);
@@ -273,6 +285,7 @@ pub struct InspectorStack {
273285
pub debugger: Option<Debugger>,
274286
pub fuzzer: Option<Fuzzer>,
275287
pub log_collector: Option<LogCollector>,
288+
pub printer: Option<CustomPrintTracer>,
276289
pub tracer: Option<TracingInspector>,
277290
pub enable_isolation: bool,
278291

@@ -357,6 +370,12 @@ impl InspectorStack {
357370
self.log_collector = yes.then(Default::default);
358371
}
359372

373+
/// Set whether to enable the trace printer.
374+
#[inline]
375+
pub fn print(&mut self, yes: bool) {
376+
self.printer = yes.then(Default::default);
377+
}
378+
360379
/// Set whether to enable the tracer.
361380
#[inline]
362381
pub fn tracing(&mut self, yes: bool) {

0 commit comments

Comments
 (0)