Skip to content

core: fix 8037 gas accounting#34631

Merged
jwasinger merged 2 commits into
ethereum:bal-devnet-3from
jwasinger:bal-devnet-3
Apr 5, 2026
Merged

core: fix 8037 gas accounting#34631
jwasinger merged 2 commits into
ethereum:bal-devnet-3from
jwasinger:bal-devnet-3

Conversation

@jwasinger
Copy link
Copy Markdown
Contributor

To check whether a transaction can be applied, we validate that blockGasLimit > txGasLimit + (cumulativeRegularGasUsed + cumulativeStateGasUsed). However, the check should only be applied to the bottleneck resource, i.e. blockGasLimit > max(txRegularGasUsed+cumulativeRegularGasUsed, txStateGasUsed+ cumulativeStateGasUsed).

The changes here break multiple tests. I am trying to determine why.

@jwasinger
Copy link
Copy Markdown
Contributor Author

jwasinger commented Apr 1, 2026

It feels like there may be some deeper underlying problem with the entire concept of the gasPool post-8037. Before Amsterdam, checking that a transaction can execute involves "buying" the tx gas limit from the pool. Later we return whatever remains, before moving on to the next transaction.

However, with 8037 we can only know if a transaction was valid to include if either tx regular/state gas used would cause the corresponding cumulative used of the bottleneck resource to exceed the block gas limit. We can only know this after executing the transaction.

@jwasinger
Copy link
Copy Markdown
Contributor Author

I said previously that there were failures with this. It seems to have been some kind of caching issue with my machine (downloading wrong/outdated spec tests release).

Inclusion of these commits bring the test failures from the new release down by one: TestExecutionSpecBlocktestsBAL/for_amsterdam/amsterdam/eip8037_state_creation_gas_cost_increase/state_gas_reservoir/block_2d_gas_valid_when_cumulative_exceeds_limit.json, which is the test that Stefan created to address this case.

@jwasinger jwasinger marked this pull request as ready for review April 5, 2026 19:52
@jwasinger jwasinger requested a review from rjl493456442 as a code owner April 5, 2026 19:52
qu0b and others added 2 commits April 5, 2026 15:55
ReturnGasAmsterdam was draining the gas pool by the 1D sum of
regular+state gas consumed per tx (tx_gas_used), but EIP-8037 defines
block validity as max(sum_regular, sum_state) <= gas_limit. This caused
valid blocks to be rejected when the sum of both dimensions exceeded
the gas limit, even though each dimension individually was within bounds.

Fix: set remaining = initial - max(cumulativeRegular, cumulativeState)
after each tx, so SubGas correctly gates subsequent transactions against
the 2D block capacity.

Co-authored-by: Jared Wasinger <j-wasinger@hotmail.com>
@jwasinger jwasinger force-pushed the bal-devnet-3 branch 2 times, most recently from 30910bb to f66b7ea Compare April 5, 2026 22:12
@jwasinger jwasinger merged commit 985cdac into ethereum:bal-devnet-3 Apr 5, 2026
2 of 3 checks passed
@jwasinger
Copy link
Copy Markdown
Contributor Author

Decided to merge this as it brings the failing tests down, and afaict is correct.

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

Successfully merging this pull request may close these issues.

2 participants