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

Use accurate refund counter #267

Open
mattsse opened this issue Mar 7, 2025 · 1 comment
Open

Use accurate refund counter #267

mattsse opened this issue Mar 7, 2025 · 1 comment
Assignees

Comments

@mattsse
Copy link
Contributor

mattsse commented Mar 7, 2025

as described here

paradigmxyz/reth#14783

we're incorrectly tracking refunds because revm's refund function returns the refund per call which can go negative.

but we want the total refund counter.

to fix this we need to change the type to an i64 because this can go negative:

/// Gas refund counter before step execution
pub gas_refund_counter: u64,

and move this

gas_refund_counter: interp.gas.refunded() as u64,

to the step_end function, here:

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

this now only tracks the refund snapshot on call level, so what we need to do on call_end is to compute the total refund counter by looking at the previous calls

fn fill_trace_on_call_end<DB: Database>(

and compute the real refund counters

@paronikyanarmen
Copy link

Will work on this

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