core: fix 8037 gas accounting#34631
Conversation
|
It feels like there may be some deeper underlying problem with the entire concept of the 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. |
|
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: |
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>
30910bb to
f66b7ea
Compare
|
Decided to merge this as it brings the failing tests down, and afaict is correct. |
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.