Skip to content

Exclude halt-burned gas from block regular gas#10225

Merged
daniellehrner merged 4 commits intobesu-eth:mainfrom
daniellehrner:fix/halt_burned_not_regular_gas
Apr 14, 2026
Merged

Exclude halt-burned gas from block regular gas#10225
daniellehrner merged 4 commits intobesu-eth:mainfrom
daniellehrner:fix/halt_burned_not_regular_gas

Conversation

@daniellehrner
Copy link
Copy Markdown
Contributor

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?

  • Checked out our contribution guidelines?
  • Considered documentation and added the doc-change-required label to this PR if updates are required.
  • Considered the changelog and included an update if required.
  • For database changes (e.g. KeyValueSegmentIdentifier) considered compatibility and performed forwards and backwards compatibility tests

Locally, you can run these tests to catch failures early:

  • spotless: ./gradlew spotlessApply
  • unit tests: ./gradlew build
  • acceptance tests: ./gradlew acceptanceTest
  • integration tests: ./gradlew integrationTest
  • reference tests: ./gradlew ethereum:referenceTests:referenceTests
  • hive tests: Engine or other RPCs modified?

Copilot AI review requested due to automatic review settings April 13, 2026 11:12
@daniellehrner daniellehrner force-pushed the fix/halt_burned_not_regular_gas branch from ae125f0 to f0d3478 Compare April 13, 2026 11:14
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

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 regularGas in TransactionGasAccounting.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.

Signed-off-by: daniellehrner <daniel.lehrner@consensys.net>
Signed-off-by: daniellehrner <daniel.lehrner@consensys.net>
@daniellehrner daniellehrner force-pushed the fix/halt_burned_not_regular_gas branch from 1a3b6f0 to 8d59c99 Compare April 13, 2026 15:12
Signed-off-by: daniellehrner <daniel.lehrner@consensys.net>
@daniellehrner daniellehrner force-pushed the fix/halt_burned_not_regular_gas branch from 8d59c99 to e0ee355 Compare April 13, 2026 15:21
Signed-off-by: daniellehrner <daniel.lehrner@consensys.net>
emptyAccountDelegationStateGas(blockGasLimit) * newEmptyAccounts);
if (newEmptyAccounts > 0
&& !frame.consumeStateGas(
emptyAccountDelegationStateGas(blockGasLimit) * newEmptyAccounts)) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

why this modification and it is not inline anymore ?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

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.

Copy link
Copy Markdown
Contributor

@matkt matkt left a comment

Choose a reason for hiding this comment

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

LGTM

@daniellehrner daniellehrner merged commit 26b7536 into besu-eth:main Apr 14, 2026
34 checks passed
@daniellehrner daniellehrner deleted the fix/halt_burned_not_regular_gas branch April 14, 2026 10:10
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.

3 participants