feat(tracing): consolidate trace options#15665
Conversation
…el is available When an address appears as a parameter in a decoded trace and has a label, it currently renders as `LabelName: [0xAddr]`. The new `--compact-labels` flag shows only the label name, making traces more readable when addresses are already identified. Available in `cast run`, `cast call`, `forge test`, and `forge script`. Closes #3381
mattsse
left a comment
There was a problem hiding this comment.
Thanks, this is much cleaner overall. I found two compatibility regressions that should be addressed before merge.
crates/config/src/lib.rs: the configured checks treat the presence of any[tracing]table as iftracing.verbositywas explicitly configured. With a config like top-levelverbosity = 4plus[tracing] disable_labels = true,normalize_tracing_settingscopies the default tracing verbosity (0) back intoself.verbosity, suppressing verbose trace output.
Suggested fix: make the verbosity checks leaf-key only in both from_figment_inner and merge_inline_provider, e.g. figment_value_is_configured(&figment, "tracing.verbosity") / provider.contains("tracing.verbosity"), and add a regression test where [tracing] contains a non-verbosity option while top-level verbosity remains set.
cast run -l <addr:label>no longer parses. FlatteningTracingArgskeeps--labelsand--label, but drops the previous#[arg(long, short)]labelfield fromRunArgs.
Suggested fix: avoid adding short = 'l' to shared TracingArgs globally because forge test -l is already --list. Instead, keep a command-specific hidden #[arg(short = 'l', value_name = "ADDRESS:LABEL")] Vec on RunArgs, merge it into self.tracing.labels before resolve, and add a parse test for cast run -l ....
mablr
left a comment
There was a problem hiding this comment.
I confirm Matt's findings, and have two more.
# Conflicts: # crates/cast/src/cmd/run.rs # crates/config/src/providers/warnings.rs
# Conflicts: # crates/fmt/src/lib.rs # crates/forge/src/cmd/snapshot.rs
|
|
||
| // Transaction will be `None`, if execution didn't pass. | ||
| if tx.is_none() || self.script_config.evm_opts.verbosity > 3 { | ||
| if tx.is_none() || tracing.verbosity > 3 { |
There was a problem hiding this comment.
This prints trace trees to stdout under --json when configured verbosity is >3, corrupting machine-readable output. !shell::is_json() should be included in this guard.
| let mut trace = trace.clone(); | ||
| decode_trace_arena(&mut trace, decoder).await; | ||
| if let Some(trace_depth) = tracing.trace_depth { | ||
| prune_trace_depth(&mut trace, trace_depth); |
There was a problem hiding this comment.
Should the same pruning be applied in show_json? Currently forge script --json --trace-depth 0 still serializes nested calls, unlike text execution and simulation output.
Consolidates trace rendering options in shared
TracingArgsfor cast, forge, and script, with defaults under[tracing]. CLI overrides resolve into a cloned effectiveTracingConfig, which is passed through trace collection, decoder construction, and rendering. Legacy[labels]and profile-locallabelsremain supported with deprecation warnings that point to[tracing.labels]. This subsumes #15662 by including--compact-labelsin the shared trace options and threading it through decoding. Closes #3381. AI assistance was used for this change, per CONTRIBUTING.md.