erigontech / erigontech/erigon
execution: EIP-8037 state gas follow-ups from PR #20255 review
- Dominant language
- Go
- Stars
- 3.6k
- Forks
- 1.5k
- Avg merge
- 1d 16h
- Merged PRs (30d)
- 455
Description
## Context
Follow-up items from reviewing #20255 (EIP-8037 state gas limit enforcement in block builder). The core logic is correct — these are hardening items and known gaps.
## 1. AA txns bypass the EIP-8037 state gas check
In `execution/exec/block_assembler.go`, AA txns attribute gas entirely to `BlockRegular` with no state gas accounting:
```go
gasUsed.BlockRegular += aaGasUsed
gasUsed.Blob += txn.GetBlobGas()
```
The comment says "AA has no state-gas dimension yet", but if AA txns can create state (new accounts, storage slots), they bypass the `applyTransaction` invariant check (`max(Σ regular, Σ state) <= gas_limit`) since they never go through `protocol.ApplyTransaction`. If AA txns can trigger SSTOREs or account creation, the block could still exceed the state gas limit via the AA path.
**Action:** Determine whether AA txns can create state. If so, add state gas accounting to the AA path.
## 2. No fork gate on the `applyTransaction` state gas check
In `execution/protocol/state_processor.go:95-101`, the EIP-8037 block-level invariant check runs unconditionally (pre- and post-Amsterdam). Pre-Amsterdam `BlockStateGasUsed` should be 0, so it's harmless in practice, but gating on `config.IsAmsterdam(header.Time)` would be more defensive and avoid any future interaction with pre-fork block processing.
## 3. Shutter pool over-filtering under EIP-8037
In `txnprovider/shutter/pool.go`, `txn.GetGasLimit()` is used as a conservative proxy for both regular and state gas dimensions. A contract creation with `gasLimit=200K` gets filtered by *both* dimensions, but its actual intrinsic state gas (~131K) and regular gas (~30K) are very different. This will cause Shutter to under-fill state-heavy blocks.
There is an existing `TODO(yperbasis)` for this — tracking here for visibility.
## 4. Potential underflow in builder gas target calculation
In `execution/builder/exec.go`:
```go
header.GasLimit - gasUsed.BlockRegular
header.GasLimit - gasUsed.BlockState
```
The `applyTransaction` check prevents cumulative gas from exceeding `GasLimit`, so underflow should be impossible. But a defensive `min()` guard or a comment explaining why underflow cannot occur would improve robustness.
## 5. `PeekBest` lost gas/RLP filtering capability
`PeekBest` now always passes `MaxUint64` for all gas dimensions and `MaxInt` for RLP space. Current callers (gRPC `Pending`, tests) don't need filtering, but this is a behavioral change to the interface. If any external consumer relied on `PeekBest` for filtered results, they'd need to switch to `ProvideTxns`.
---
Refs: #20255, #20243
Contributor guide
Assessment
This issue has not been assessed yet.