Skip to content

feat: print optional opcodes in forge test#14843

Merged
grandizzy merged 30 commits into
foundry-rs:masterfrom
jaimebarrancos:master
Jul 10, 2026
Merged

feat: print optional opcodes in forge test#14843
grandizzy merged 30 commits into
foundry-rs:masterfrom
jaimebarrancos:master

Conversation

@jaimebarrancos

@jaimebarrancos jaimebarrancos commented May 20, 2026

Copy link
Copy Markdown
Contributor

Added --opcodes argument in forge test.
This allows opcodes to be analyzed in more detail as well as their gas costs and storage changes (if any).

AI was not used to write any code.

This is my first contribution to open source!

Motivation

Closes #8198.

Solution

Passed opcode lines to the renderer.

PR Checklist

  • Added Tests
  • Added Documentation
  • Breaking changes

@grandizzy grandizzy left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

thank you, direction is good, left couple of comments. Please make sure clippy and fmt pass, see https://github.com/foundry-rs/foundry/blob/master/CONTRIBUTING.md#resolving-an-issue for details

Comment thread crates/forge/src/cmd/test/mod.rs Outdated
Comment thread crates/evm/traces/src/decoder/mod.rs Outdated
Comment thread crates/forge/src/cmd/test/mod.rs Outdated
Comment thread crates/forge/src/cmd/test/mod.rs Outdated
@jaimebarrancos jaimebarrancos requested a review from grandizzy May 29, 2026 13:27

@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.

Please fix the Cargo.lock file + 2 small nits

Comment thread crates/forge/src/cmd/test/mod.rs Outdated
Comment thread crates/forge/src/cmd/test/mod.rs Outdated
@jaimebarrancos jaimebarrancos requested a review from mablr May 30, 2026 09:50
Comment thread crates/forge/tests/cli/test_cmd/mod.rs Outdated
@jaimebarrancos jaimebarrancos requested a review from mablr June 1, 2026 06:36
mablr
mablr previously approved these changes Jun 1, 2026

@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.

Sgtm, thanks.

Pending @grandizzy :)

Comment thread crates/forge/src/cmd/test/mod.rs Outdated
mablr
mablr previously approved these changes Jun 30, 2026

@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.

Moved resolved.to_mut() inside the if with_storage_changes block, so the clone only happens when we actually need to mutate the rendered copy.

Should be good to go. Thank you @jaimebarrancos.

@mablr mablr requested review from figtracer and grandizzy June 30, 2026 09:17

@grandizzy grandizzy left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

One blocking issue: the storage de-dup clones the whole trace arena on every -vvvvv render, even when --opcodes isn't used. Fix inline below. One minor follow-up noted as well.

Comment thread crates/evm/traces/src/lib.rs Outdated
Comment thread crates/forge/src/cmd/test/mod.rs
mablr
mablr previously approved these changes Jul 3, 2026
Comment thread crates/evm/traces/src/lib.rs Outdated
Comment thread crates/forge/src/cmd/test/mod.rs Outdated
@grandizzy grandizzy enabled auto-merge (squash) July 10, 2026 06:18
@grandizzy grandizzy merged commit 7f1931b into foundry-rs:master Jul 10, 2026
19 checks passed
@github-project-automation github-project-automation Bot moved this to Done in Foundry Jul 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

Add printing of OPCODEs in forge tests

6 participants