-
Notifications
You must be signed in to change notification settings - Fork 132
feat: Add Gas dimension tracers #459
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
Open
relyt29
wants to merge
36
commits into
master
Choose a base branch
from
gas-dimension-tracing
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Support live tracing and by RPC, support all pure-CPU opcodes. Support the simple state access opcodes. Rest still TODO
1. EXTCODECOPY with no memory expansion, and warm storage access 2. EXTCODECOPY with memory expansion and warm storage access 3. EXTCODECOPY with memory expansion and cold storage access 4. EXTCODECOPY with no memory expansion and cold storage access
Cold access list SLOAD Warm access list SLOAD
all of the LOG opcodes with both indexed and unindexed data
Selfdestruct to: * cold, empty account target, sender has balance * warm, empty account target, sender has balance * warm, code/value at target, sender has balance * warm, code/value at target, no money to send * cold, code/value at target, sender has balance
Tested: * calling to a contract that is cold but has code * calling to a contract that is cold and has no code
Tested: * calling to a contract that is warm and has code * calling to a contract that is cold and has code * calling to a contract that is warm and has no code * calling to a contract that is cold and has no code
Tested by hand: * Delegatecall to warm address, to a contract with code * Delegatecall to cold address, to a contract with code * Delegatecall to cold address, to a contract with no code * Delegatecall to warm address, to a contract with no code
Tested by Hand: * warm access list+ target has code + zero value * warm access list+ target has code + positive value * warm access list+ target has no code + zero value * warm access list+ target has no code + positive value * cold access list+ target has code + zero value * cold access list+ target has code + positive value * cold access list+ target has no code + zero value * cold access list+ target has no code + positive value
Tested By hand: * CREATE * CREATE2 * CREATE sending value * CREATE2 sending value sending value does not affect gas dimensions but I tested it anyways
Tested by hand in variations: * writing to a new slot * writing to the same slot twice with the same value * writing to the same slot twice with a different value * writing to a slot that was uninitialized and setting it back to zero * writing to a slot that was cold but set to non-zero and setting it to nonzero
CALL, DELEGATECALL, EXTCODECOPY, etc. Tested by hand.
This PR exposes the GasUsed, L1GasUsed, and L2GasUsed from the transaction reciept directly in the tracer response. It also changes the tracers for CALL, CALLCODE, STATICCALL, DELEGATECALL, CREATE and CREATE2 to explicitly return the gas consumed by the child execution of the call when the call stack depth is increased by those opcodes.
This was referenced May 13, 2025
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR introduces two native and two live tracers,
txGasDimensionLogger
andtxGasDimensionByOpcode
, that on a per-opcode basis track the consumption of gas across multiple dimensions:txGasDimensionLogger
The logger is based off the default geth opcode struct logger. It will return each opcode, and its associated gas dimensional consumption, e.g.
txGasDimensionByOpcode
The transaction gas dimensions by opcode tracer returns the total sum of gas consumed by each different opcode, split out by dimension, e.g:
Tracer Invocation
The tracers need to have a parameter of a transaction hash to operate upon. If you have that and your node either is an archive node with the state or the transaction hash you're tracing is in the last 128 blocks then you can run the tracer like so:
Live Tracers
The live tracers are identical use the native tracers under the hood. The difference with the live tracers is that they dump the output of the tracer to disk in protobuf format to then in in order to save on storage space relative to json. Python or whatever can then generate serialization code from the .proto file to ingest the protobuf output.
Live Tracer Invocation
The live tracers can be run like so:
For example, this will create a directory called
gas-dimension-logs
in the root of the repo that will have each block as a subfolder, and a protobuf dumped file for the gas dimensions by transaction. The tracer expects a chain configuration because I was unable to get the chain configuration in the tracer creation context without having a bigger diff. So it expects it to be passed in by json - you can use the nitro repository's chain info as a reference for a chain configuration if you don't have one.this PR is identical to and replaces #457.