Skip to content

feat(tracing): consolidate trace options#15665

Open
DaniPopes wants to merge 16 commits into
masterfrom
dani/tracing-options
Open

feat(tracing): consolidate trace options#15665
DaniPopes wants to merge 16 commits into
masterfrom
dani/tracing-options

Conversation

@DaniPopes

@DaniPopes DaniPopes commented Jul 9, 2026

Copy link
Copy Markdown
Member

Consolidates trace rendering options in shared TracingArgs for cast, forge, and script, with defaults under [tracing]. CLI overrides resolve into a cloned effective TracingConfig, which is passed through trace collection, decoder construction, and rendering. Legacy [labels] and profile-local labels remain supported with deprecation warnings that point to [tracing.labels]. This subsumes #15662 by including --compact-labels in the shared trace options and threading it through decoding. Closes #3381. AI assistance was used for this change, per CONTRIBUTING.md.

DaniPopes and others added 3 commits July 9, 2026 21:26
…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 mattsse left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, this is much cleaner overall. I found two compatibility regressions that should be addressed before merge.

  1. crates/config/src/lib.rs: the configured checks treat the presence of any [tracing] table as if tracing.verbosity was explicitly configured. With a config like top-level verbosity = 4 plus [tracing] disable_labels = true, normalize_tracing_settings copies the default tracing verbosity (0) back into self.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.

  1. cast run -l <addr:label> no longer parses. Flattening TracingArgs keeps --labels and --label, but drops the previous #[arg(long, short)] label field from RunArgs.

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 mablr left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I confirm Matt's findings, and have two more.

Comment thread crates/script/src/lib.rs
Comment thread crates/forge/tests/cli/config.rs
@DaniPopes DaniPopes requested review from mablr and mattsse July 10, 2026 13:13
Comment thread crates/config/src/lib.rs Outdated
Comment thread crates/config/src/lib.rs Outdated
Comment thread crates/cli/src/opts/tracing.rs
Comment thread crates/script/src/simulate.rs
@DaniPopes DaniPopes requested a review from mablr July 11, 2026 12:15
# 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 {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

feat(tracing): add flag to hide address when label is available

5 participants