Skip to content

Gas Dimension Trace Tests #3229

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

Closed
wants to merge 35 commits into from

Conversation

relyt29
Copy link
Collaborator

@relyt29 relyt29 commented May 9, 2025

In OffchainLabs/go-ethereum#457 I make a PR that adds native and live tracers for tracking gas consumption by the dimensions of computation, state access, state growth, and history growth.

This PR adds integration-style tests that test that the of the output of those live tracers matches the expectation for each gas dimension(the logger_test.go files), and also tests that the gas dimensions add up to the same value as the one dimensional gas in the transaction receipt (the tx_op_test.go files).

See OffchainLabs/go-ethereum#457 for more details including invocation commands for the tracers. See OffchainLabs/nitro-contracts#345 for the solidity of the contract code that runs the opcodes that are tested in system_tests

rollchad and others added 30 commits May 9, 2025 11:46
Implement go-ethereum's live tracing feature in Nitro

- Add the live tracer to go-ethereum/eth/tracers/live.
Rebuild nitro

- To activate a tracer pass --node.trace.tracername
and optionally --node.vmtrace.jsonconfig

- Support --dev and production mode, in both sequencer and
non-sequencer mode

- Changes made
  1. Import the tracers/live directory in cmd/nitro.go
  to call init() functions on tracers
  2. Add config params to the nitro binary to activate a tracer
  from bash
  3. Call LiveDirectory.New() in func GetBlockchain() in
  gethexec/blockchain.go to activate the tracer based on config.
  The tracer is attached to vmconfig
  4. Read the tracer in executionengine.go. Pass it to
 block_processor.go
  5. Missing hook calls OnBlockStart and OnBlockEnd in
  block_processor.go
  6. If tracer hooks are provided and isMsgForPrefetch
  is false then attach hooks to the stateDB, pass them to vm.Config
  to spawn an EVM instance with tracing enabled.

- Credits: OffchainLabs#2934
tests, including doing the math for the expected values.
it was becoming far too unweildy in one file for navigation
add boilerplate for the read only opcodes like BALANCE, SLOAD, etc
Adapt tests to take advantage of the now exposed L1GasUsed and L2GasUsed
values in the tracer output. Check against it in the gas_dim_tx_op_state
tests. Change all the tests to handle child execution gas separately
from one dimensional gas for CALL, CALLCODE STATICCALL, DELEGATECALL,
CREATE, and CREATE2.
one sstore test is still failing, need to examine further
@relyt29 relyt29 requested a review from tsahee May 9, 2025 18:19
@CLAassistant
Copy link

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you all sign our Contributor License Agreement before we can accept your contribution.
1 out of 2 committers have signed the CLA.

✅ rollchad
❌ relyt29
You have signed the CLA already but the status is still pending? Let us recheck it.

@relyt29 relyt29 requested review from eljobe and joshuacolvin0 May 9, 2025 18:19
@relyt29 relyt29 self-assigned this May 9, 2025
@relyt29 relyt29 force-pushed the relyt-live-tracing branch 2 times, most recently from dacccc7 to 9694e90 Compare May 9, 2025 18:46
@relyt29 relyt29 force-pushed the relyt-live-tracing branch from 4435c05 to 79d975a Compare May 13, 2025 12:22
@relyt29
Copy link
Collaborator Author

relyt29 commented May 13, 2025

Closing in favor of #3233

@relyt29 relyt29 closed this May 13, 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.

3 participants