Exclude halt-burned gas from block regular gas#10225
Exclude halt-burned gas from block regular gas#10225daniellehrner merged 4 commits intobesu-eth:mainfrom
Conversation
ae125f0 to
f0d3478
Compare
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
Adjusts gas accounting so gas burned by an exceptional halt on the initial EVM frame (before any opcode execution) is excluded from block “regular gas”, aligning block header gas accounting with EIP-7778/EIP-8037 expectations while still charging the sender via receipts.
Changes:
- Track initial-frame “halt-burned” regular gas separately on exceptional halts before opcode execution.
- Subtract the tracked halt-burn from
regularGasinTransactionGasAccounting.calculate(). - Add unit tests covering the new field’s effect and default behavior.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| evm/src/main/java/org/hyperledger/besu/evm/processor/AbstractMessageProcessor.java | Records initial-frame halt-burn before clearing remaining gas; marks when opcode execution begins. |
| evm/src/main/java/org/hyperledger/besu/evm/frame/TxValues.java | Adds persistent (non-reverting) counter storage for initial-frame halt-burn. |
| evm/src/main/java/org/hyperledger/besu/evm/frame/MessageFrame.java | Stores/reads initial-frame halt-burn; introduces codeExecuted flag. |
| ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/TransactionGasAccounting.java | Excludes initial-frame halt-burn from computed regularGas. |
| ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/MainnetTransactionProcessor.java | Plumbs initial-frame halt-burn into gas accounting builder. |
| ethereum/core/src/test/java/org/hyperledger/besu/ethereum/mainnet/TransactionGasAccountingTest.java | Adds tests to validate exclusion and defaulting to zero. |
evm/src/main/java/org/hyperledger/besu/evm/processor/AbstractMessageProcessor.java
Show resolved
Hide resolved
evm/src/main/java/org/hyperledger/besu/evm/processor/AbstractMessageProcessor.java
Outdated
Show resolved
Hide resolved
Signed-off-by: daniellehrner <daniel.lehrner@consensys.net>
Signed-off-by: daniellehrner <daniel.lehrner@consensys.net>
1a3b6f0 to
8d59c99
Compare
Signed-off-by: daniellehrner <daniel.lehrner@consensys.net>
8d59c99 to
e0ee355
Compare
Signed-off-by: daniellehrner <daniel.lehrner@consensys.net>
| emptyAccountDelegationStateGas(blockGasLimit) * newEmptyAccounts); | ||
| if (newEmptyAccounts > 0 | ||
| && !frame.consumeStateGas( | ||
| emptyAccountDelegationStateGas(blockGasLimit) * newEmptyAccounts)) { |
There was a problem hiding this comment.
why this modification and it is not inline anymore ?
There was a problem hiding this comment.
We must continue here and check for alreadyExistingDelegators a bit below as well if we still have state gas here. If we do not have enough state gas frame.consumeStateGas() will return false and we can directly return here.
PR description
When the initial EVM frame halts exceptionally (e.g. EIP-3607 collision on CREATE tx, code deposit failure), Besu cleared gasRemaining via clearGasRemaining() and the leftover was folded into regularGas by TransactionGasAccounting. The sender correctly paid for that gas via the receipt, but under EIP-7778/EIP-8037 the block header's gas_used must only reflect gas actually consumed by executed regular or state work and not gas burned on halt.
Fix: snapshot getRemainingGas() on initial-frame halt into a new initialFrameRegularHaltBurn counter (in TxValues, not undone on revert) and subtract it from regularGas in TransactionGasAccounting.calculate().
Thanks for sending a pull request! Have you done the following?
doc-change-requiredlabel to this PR if updates are required.Locally, you can run these tests to catch failures early:
./gradlew spotlessApply./gradlew build./gradlew acceptanceTest./gradlew integrationTest./gradlew ethereum:referenceTests:referenceTests