Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: patch create traces to work with foundry #578

Merged
merged 6 commits into from
Sep 17, 2024
Merged

Conversation

nbaztec
Copy link
Collaborator

@nbaztec nbaztec commented Sep 16, 2024

Motivation

Unlike EVM, CREATE call traces obtained from zkEVM do not contain the bytecode in the output section but a 0-padded address instead. This causes the traces to not be decoded properly in foundry causing issues in gas reporting and invariant tests.

Solution

Patch zkEVM CREATE call trace to populate it with the bytecode, for better interoperability with foundry.

Now:

Traces:
  [32676] ZkTraceTest::testZkTraceOutputDuringCreate()
    ├─ [0] → new ConstructorAdder@0xF9E9ba9Ed9B96AB918c74B21dD0f1D5f2ac38a30
    │   ├─ [127] → new Number@0xf232f12E115391c535FD519B00efADf042fc8Be5
    │   │   └─ ← [Return] 2272 bytes of code
    │   ├─ [85280] Number::five()
    │   │   ├─ [91] → new InnerNumber@0xEd570f3F91621894E001DF0fB70BfbD123D3c8AD
    │   │   │   └─ ← [Return] 736 bytes of code
    │   │   ├─ [889] InnerNumber::innerFive()
    │   │   │   └─ ← [Return] 5
    │   │   └─ ← [Return] 5
    │   ├─ [74776] Number::five()
    │   │   ├─ [91] → new InnerNumber@0xAbceAEaC3d3a2ac3Dcffd7A60Ca00A3fAC9490cA
    │   │   │   └─ ← [Return] 736 bytes of code
    │   │   ├─ [889] InnerNumber::innerFive()
    │   │   │   └─ ← [Return] 5
    │   │   └─ ← [Return] 5
    │   ├─ [276] console::log(10)
    │   │   └─ ← [Return] 
    │   └─ ← [Return] 3168 bytes of code
    └─ ← [Stop] 

@nbaztec nbaztec requested a review from elfedy September 16, 2024 14:15
Copy link
Contributor

@Karrq Karrq left a comment

Choose a reason for hiding this comment

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

Great work

elfedy
elfedy previously approved these changes Sep 16, 2024
crates/evm/evm/src/inspectors/trace.rs Show resolved Hide resolved
@nbaztec nbaztec merged commit 02346a9 into main Sep 17, 2024
12 checks passed
@nbaztec nbaztec deleted the nish-fix-zk-create-trace branch September 17, 2024 11:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants