Skip to content

fix(core): skip minimum gas consumption for simulated calls - #305

Merged
JonathanOppenheimer merged 4 commits into
mainfrom
JonathanOppenheimer/fix-estimate-gas-minimum-consumption
Aug 24, 2026
Merged

fix(core): skip minimum gas consumption for simulated calls#305
JonathanOppenheimer merged 4 commits into
mainfrom
JonathanOppenheimer/fix-estimate-gas-minimum-consumption

Conversation

@JonathanOppenheimer

@JonathanOppenheimer JonathanOppenheimer commented Aug 21, 2026

Copy link
Copy Markdown

Why this should be merged

This was reported in ava-labs/avalanchego#5850.

ACP-194 charges real transactions:

chargedGas
  = limit - min(limit - actualGasUsed, limit - minimumConsumption)
  = max(actualGasUsed, minimumConsumption)
  = max(actualGasUsed, ceil(limit / 2))

During eth_estimateGas, this floor makes UsedGas depend on the trial gas limit. The geth estimator assumes UsedGas is a lower bound on the gas required for execution, so it can return an estimate near half of the sender's balance-derived gas allowance. This is incorrect, as we should not alter the behavior of RPCs as described in the issue report.

How this works

Adds a StateTransitionOption that explicitly disables minimum gas consumption for a state transition.

How this was tested

All existing UTs pass and I added a minimum-consumption unit test.

@JonathanOppenheimer JonathanOppenheimer self-assigned this Aug 21, 2026
@JonathanOppenheimer JonathanOppenheimer added the Category: Bug 🐛 Something isn't working label Aug 21, 2026
Comment thread core/state_transition.libevm.go Outdated
@JonathanOppenheimer
JonathanOppenheimer marked this pull request as draft August 21, 2026 20:07
@JonathanOppenheimer

Copy link
Copy Markdown
Author

pending discussion of better solution

JonathanOppenheimer and others added 2 commits August 24, 2026 11:10
## Why this should be merged

## How this works

## How this was tested

Co-authored-by: Arran Schlosberg <me@arranschlosberg.com>
@JonathanOppenheimer
JonathanOppenheimer marked this pull request as ready for review August 24, 2026 15:37

@alarso16 alarso16 left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Aren't there other RPCs that need changed? Namely, the tracers?

@JonathanOppenheimer

Copy link
Copy Markdown
Author

Aren't there other RPCs that need changed? Namely, the tracers?

Yeah the other 'simulated' (tracers, access-list) will also need to opt out -- I was thinking this PR provides the option/mechanism to do so, and then when I open the avalanchego bump PR, I can apply it at the appropriate call sites.

Does that sound reasonable to you?

Comment thread core/state_transition.libevm.go Outdated
Comment thread core/state_transition.libevm.go Outdated
Comment thread core/state_transition.libevm_test.go Outdated
Comment thread core/state_transition.libevm_test.go
Co-authored-by: Arran Schlosberg <519948+ARR4N@users.noreply.github.com>
Signed-off-by: Jonathan Oppenheimer <147infiniti@gmail.com>
@ARR4N

ARR4N commented Aug 24, 2026

Copy link
Copy Markdown
Collaborator

Aren't there other RPCs that need changed? Namely, the tracers?

Yeah the other 'simulated' (tracers, access-list) will also need to opt out -- I was thinking this PR provides the option/mechanism to do so, and then when I open the avalanchego bump PR, I can apply it at the appropriate call sites.

Does that sound reasonable to you?

I don't think either of these should opt out. Tracers are meant to mirror the actual execution, and access-list-generation is orthogonal to the amount of gas consumed.

@JonathanOppenheimer

Copy link
Copy Markdown
Author

Aren't there other RPCs that need changed? Namely, the tracers?

Yeah the other 'simulated' (tracers, access-list) will also need to opt out -- I was thinking this PR provides the option/mechanism to do so, and then when I open the avalanchego bump PR, I can apply it at the appropriate call sites.
Does that sound reasonable to you?

I don't think either of these should opt out. Tracers are meant to mirror the actual execution, and access-list-generation is orthogonal to the amount of gas consumed.

Hm I was just thinking of this through the gasUsed framing -- I will merge this as is (I applied your changes), and make a PR in AvalancheGo to bump libevm.

@JonathanOppenheimer
JonathanOppenheimer enabled auto-merge (squash) August 24, 2026 19:47
@JonathanOppenheimer
JonathanOppenheimer merged commit 80edd41 into main Aug 24, 2026
18 of 19 checks passed
@JonathanOppenheimer
JonathanOppenheimer deleted the JonathanOppenheimer/fix-estimate-gas-minimum-consumption branch August 24, 2026 19:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Category: Bug 🐛 Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants