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

cmd/evm: try to consolidate evm output switches #30849

Merged
merged 7 commits into from
Dec 10, 2024

Conversation

holiman
Copy link
Contributor

@holiman holiman commented Dec 3, 2024

This PR attempts to clean up some ambiguities and quirks from recent changes to evm flag handling.

This PR mainly focuses on evm run subcommand, to use the same flags for configuring tracing/output options as statetest/blocktest does.

Additionally, it adds quite a lot of tests for expected outputs of the various subcommands, to avoid accidental changes.

@holiman
Copy link
Contributor Author

holiman commented Dec 3, 2024

I'm going to rebase this on top of #30806 instead

@holiman
Copy link
Contributor Author

holiman commented Dec 3, 2024

# Json output:

$ go run ./cmd/evm run   --json --trace --trace.format=json 6040
{"pc":0,"op":96,"gas":"0x2540be400","gasCost":"0x3","memSize":0,"stack":[],"depth":1,"refund":0,"opName":"PUSH1"}
{"pc":2,"op":0,"gas":"0x2540be3fd","gasCost":"0x0","memSize":0,"stack":["0x40"],"depth":1,"refund":0,"opName":"STOP"}
{"output":"","gasUsed":"0x3"}
# Markdown output:
$ go run ./cmd/evm run   --json --trace --trace.format=md 6040
Pre-execution info:
  - from: `0x000000000000000000000000000073656E646572`
  - to: `0x0000000000000000000000007265636569766572`
  - data: ``
  - gas: `10000000000`
  - value: `0` wei

|  Pc   |      Op     | Cost |   Refund  |   Stack   |
|-------|-------------|------|-----------|-----------|
|    0  |      PUSH1  |    3 |         0 |        [] |
|    2  |       STOP  |    0 |         0 |    [0x40] |

Post-execution info:
  - output: ``
  - consumed gas: `3`
  - error: `<nil>`
# Struct output
$ go run ./cmd/evm run    --trace --trace.format=struct "0x6040"
PUSH1           pc=00000000 gas=10000000000 cost=3

STOP            pc=00000002 gas=9999999997 cost=0
Stack:
00000000  0x40

$ go run ./cmd/evm run   --json --trace --trace.format=json 6040
{"pc":0,"op":96,"gas":"0x2540be400","gasCost":"0x3","memSize":0,"stack":[],"depth":1,"refund":0,"opName":"PUSH1"}
{"pc":2,"op":0,"gas":"0x2540be3fd","gasCost":"0x0","memSize":0,"stack":["0x40"],"depth":1,"refund":0,"opName":"STOP"}
{"output":"","gasUsed":"0x3"}

$ go run ./cmd/evm run --debug  --trace --trace.format=json 6040

{"pc":0,"op":96,"gas":"0x2540be400","gasCost":"0x3","memSize":0,"stack":[],"depth":1,"refund":0,"opName":"PUSH1"}
{"pc":2,"op":0,"gas":"0x2540be3fd","gasCost":"0x0","memSize":0,"stack":["0x40"],"depth":1,"refund":0,"opName":"STOP"}
{"output":"","gasUsed":"0x3"}
$ go run ./cmd/evm     run --debug   --dump 6040
PUSH1           pc=00000000 gas=10000000000 cost=3

STOP            pc=00000002 gas=9999999997 cost=0
Stack:
00000000  0x40

INFO [12-03|10:04:06.104] Trie dumping started                     root=b44448..bf69f9
WARN [12-03|10:04:06.105] Dump incomplete due to missing preimages missing=1
INFO [12-03|10:04:06.105] Trie dumping complete                    accounts=1 elapsed="285.691µs"
{
    "root": "b444481d1367188172f8c6091e948aaa68bae763fd26d6b9e994306a66bf69f9",
    "accounts": {
        "pre(0x30d7a0694cb29af31b982480e11d7ebb003a3fca4026939149071f014689b142)": {
            "balance": "0",
            "nonce": 0,
            "root": "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421",
            "codeHash": "0x3e48ef54b89079a075f3b8fc253c657a86b110a7aed3568c1517b10edf2c3eb6",
            "code": "0x6040",
            "key": "0x30d7a0694cb29af31b982480e11d7ebb003a3fca4026939149071f014689b142"
        }
    }
}

@holiman holiman added this to the 1.14.13 milestone Dec 10, 2024
@holiman holiman merged commit 75f8473 into ethereum:master Dec 10, 2024
3 checks passed
@fjl fjl modified the milestones: 1.14.13, 1.15.0 Jan 23, 2025
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.

2 participants