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 gas cost for js tracer #200

Open
mattsse opened this issue Sep 17, 2024 · 1 comment
Open

Fix gas cost for js tracer #200

mattsse opened this issue Sep 17, 2024 · 1 comment

Comments

@mattsse
Copy link
Contributor

mattsse commented Sep 17, 2024

reported: paradigmxyz/reth#10959

we use incorrect gasCost value:

cost: interp.gas.spent(),

this should be gas cost of the opcode:

https://github.com/ethereum/go-ethereum/blob/0dd173a727dd2d2409b8e401b22e85d20c25b71f/core/vm/interpreter.go#L237-L237

this becomes a bit tricky for dynamic gas, because we don't know how much gas the opcode will cost if we call the tracer in the step fn, only if we track and call it on step_end.

see also:

let gas_cost = gas_remaining.saturating_sub(interp.gas().remaining());

so we'd need to move this call to step_end, but this messes with memory because the tracer should be called with mem before opcode I believe...

I don't think there's an easier way to get this than doing

step: gas_remaining
step_end: gas_remaining - spent
@rakita

@DaniPopes
Copy link
Member

Likely same for refund?

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

No branches or pull requests

2 participants