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

feature request: rpc method for per opcode gas tracing #6421

Closed
sslivkoff opened this issue Feb 5, 2024 · 5 comments · Fixed by #6977
Closed

feature request: rpc method for per opcode gas tracing #6421

sslivkoff opened this issue Feb 5, 2024 · 5 comments · Fixed by #6977
Labels
A-rpc Related to the RPC implementation C-enhancement New feature or request M-prevent-stale Prevents old inactive issues/PRs from being closed due to inactivity

Comments

@sslivkoff
Copy link
Member

Describe the feature

It would be very nice to have an rpc method ("opcode_trace") that gives a per-transaction accounting of:

  • how many times each opcode was called
  • how much total gas was used per opcode

This would be the final missing piece for full resolution gas analysis.

Data could have a similar schema to state_diffs tracing:

data = {
    "opcode": [
        {
            "transaction_hash": "0x1234...",
            "opcode_counts": {
                "SSTORE": 17,
                ...
            },
            "opcode_gas": {
                "SSTORE": 153000,
                ...
            },
            ...
        }
        {
            "transaction_hash": "0x8764...",
            ...
        }
    ]
}

Additional context

No response

@sslivkoff sslivkoff added C-enhancement New feature or request S-needs-triage This issue needs to be labelled labels Feb 5, 2024
@gakonst
Copy link
Member

gakonst commented Feb 5, 2024

I think this should be possible via a custom tracer similar to Geth's tracers, or should this be in a separate trace method @mattsse ?

@mattsse
Copy link
Collaborator

mattsse commented Feb 6, 2024

I believe the only way to do this rn is via JS

but it's possible to add this

@mattsse mattsse added A-rpc Related to the RPC implementation and removed S-needs-triage This issue needs to be labelled labels Feb 8, 2024
Copy link
Contributor

github-actions bot commented Mar 1, 2024

This issue is stale because it has been open for 21 days with no activity.

@github-actions github-actions bot added the S-stale This issue/PR is stale and will close with no further activity label Mar 1, 2024
@mattsse mattsse added M-prevent-stale Prevents old inactive issues/PRs from being closed due to inactivity and removed S-stale This issue/PR is stale and will close with no further activity labels Mar 1, 2024
@mattsse
Copy link
Collaborator

mattsse commented Mar 1, 2024

cc @DoTheBestToGetTheBest

we can add this as trace_blockOpcodeGas and trace_transactionOpcodeGas

@sslivkoff
Copy link
Member Author

sslivkoff commented Mar 5, 2024

[edited for future-proofness, turned opcodes into list not map]

possible schema for output

  1. trace_transactionOpcodeGas

request:
[txHash]

response:

{
    "transactionHash": "0xb5be..."
    "opcodes": [
        {"opcode": "SSTORE", "count": 4, "gas_used": 38000},
        {"opcode": "CREATE", "count": 1, "gas_used": 32000},
        ...
    ],
}
  1. trace_blockOpcodeGas

request:
[blockNumber | blockHash]

response:

{
    "blockHash": "0x9eaf...",
    "transactions": [trace_transactionOpcodeGasResponse],
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-rpc Related to the RPC implementation C-enhancement New feature or request M-prevent-stale Prevents old inactive issues/PRs from being closed due to inactivity
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

3 participants