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. |
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.
* Add SHL, SHR and SAR shift operations for EVM v2 (#10154) * Add SHL, SHR and SAR implementations and benchmarks for EVM v2 Signed-off-by: Ameziane H. <ameziane.hamlat@consensys.net> * Upgrade RocksDB version from 9.7.3 to 10.6.2 (#9767) * Upgrade RocksDB version from 9.7.3 to 10.6.2 * Fix JNI SIGSEGV crashes Signed-off-by: Ameziane H. <ameziane.hamlat@consensys.net> Co-authored-by: Sally MacFarlane <macfarla.github@gmail.com> * Add missing verification metadata (#10198) Signed-off-by: Fabio Di Fabio <fabio.difabio@consensys.net> * Stream debug_traceBlock* responses directly to avoid OOM on large blocks (#9848) * stream block traces on op code level Signed-off-by: daniellehrner <daniel.lehrner@consensys.net> * correctly parse default setting for memory tracing Signed-off-by: daniellehrner <daniel.lehrner@consensys.net> * fix initcode capture for failed create op codes Signed-off-by: daniellehrner <daniel.lehrner@consensys.net> * created separate streaming debug tracer, for batch request fall back to accumulation in memory, adddress pr comments Signed-off-by: daniellehrner <daniel.lehrner@consensys.net> * execute tests from genesis and verify full trace Signed-off-by: daniellehrner <daniel.lehrner@consensys.net> * addressed pr comments Signed-off-by: daniellehrner <daniel.lehrner@consensys.net> * spotless Signed-off-by: daniellehrner <daniel.lehrner@consensys.net> * optimize trace streaming and struct log handling Signed-off-by: Ameziane H. <ameziane.hamlat@consensys.net> * spotless Signed-off-by: Ameziane H. <ameziane.hamlat@consensys.net> * Fix remaining issues and add unit tests Signed-off-by: Ameziane H. <ameziane.hamlat@consensys.net> * added back pressure when writing to the socket and reduced the buffer size to work better with netty's default buffer size Signed-off-by: daniellehrner <daniel.lehrner@consensys.net> * improve error handling by deferring to send the header only when data is available, allows to send the proper error codes during setup Signed-off-by: daniellehrner <daniel.lehrner@consensys.net> * compactHex candidate comparison Signed-off-by: daniellehrner <daniel.lehrner@consensys.net> * wire in more performant hex writer Signed-off-by: daniellehrner <daniel.lehrner@consensys.net> * introduce separate timeout for streaming calls, defaults to 10 minutes Signed-off-by: daniellehrner <daniel.lehrner@consensys.net> * spotless Signed-off-by: daniellehrner <daniel.lehrner@consensys.net> * Fix streamin/accumulating output parity, added missing refund field, corrected error format, reason encoding, returnValue prefix, and precompile gasCost, with equivalence tests between both Signed-off-by: daniellehrner <daniel.lehrner@consensys.net> * revert accidental removal of 0x prefix Signed-off-by: daniellehrner <daniel.lehrner@consensys.net> * pad memory bytes to 32 bytes Signed-off-by: daniellehrner <daniel.lehrner@consensys.net> --------- Signed-off-by: daniellehrner <daniel.lehrner@consensys.net> Signed-off-by: Ameziane H. <ameziane.hamlat@consensys.net> Co-authored-by: Ameziane H. <ameziane.hamlat@consensys.net> * Optimize performance and reduce memory when creating Quantity from scalar (#10134) * Optimize performance and reduce memory when creating Quantity from scalar Signed-off-by: Fabio Di Fabio <fabio.difabio@consensys.net> * Benchmark other implementations Signed-off-by: Fabio Di Fabio <fabio.difabio@consensys.net> --------- Signed-off-by: Fabio Di Fabio <fabio.difabio@consensys.net> * snap sync - apply BALs before flat db heal (#10151) Signed-off-by: Miroslav Kovar <miroslavkovar@protonmail.com> * Remove dryRunDetector workaround methods from unit tests (#10201) * Remove dryRunDetector workaround methods from unit tests The dryRunDetector methods were added as a workaround for a Gradle issue that prevented @ParameterizedTest classes from being selected when running with --dry-run. Since the issue is fixed and --dry-run is no longer used, these methods are no longer needed. Signed-off-by: Fabio Di Fabio <fabio.difabio@consensys.net> * Remove dryRunDetector workaround from acceptance tests too The Gradle issue is confirmed fixed, so the workaround is no longer needed anywhere, including acceptance tests. Signed-off-by: Fabio Di Fabio <fabio.difabio@consensys.net> --------- Signed-off-by: Fabio Di Fabio <fabio.difabio@consensys.net> * preserve state gas reservoir for the top level frame in case of OOG (#10205) Signed-off-by: daniellehrner <daniel.lehrner@consensys.net> * Enable execution processor on PoA networks with system contract addresses (#10196) * enable the prague execution processor for poa networks that have the systems contract addresses set in their genesis file Signed-off-by: daniellehrner <daniel.lehrner@consensys.net> * Fix engine_getPayloadV1 to return -38001 instead of -32001 for unknown payloadId (#10179) The Engine API spec requires error code -38001 (Unknown payload) when engine_getPayloadV1 is called with an unrecognized payloadId. Besu was incorrectly returning -32001 (Resource not found), which is a non-standard error code that may cause interoperability issues with consensus layer clients. Fixes #10174 Signed-off-by: Vivek Singh Solanki <viveksolanki0509@gmail.com> * Exclude IntelliJ bin/default output from Spotless shell script check (#10210) When IntelliJ syncs a Gradle project without build delegation, it copies processed resources (including reference test shell scripts from the submodule) into bin/default/. Spotless then finds these copies and incorrectly flags them for missing license headers, while CI never sees bin/default/ since it runs bare Gradle. Add '**/bin/default/**' to the ShellScripts targetExclude, matching the existing pattern used for other generated/external content. Signed-off-by: Simon Dudley <simon.dudley@consensys.net> Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com> * Missing memory presence check (#10213) * Call lastFrame.getMemory().isPresent() before calling lastFrame.getMemory().get().length to avoid NPE Signed-off-by: daniellehrner <daniel.lehrner@consensys.net> Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * feat: add transactionReceipts subscription support in eth_subscribe #… (#10190) Signed-off-by: Vivek Singh Solanki <viveksolanki0509@gmail.com> * remove 2nd definition of forceCaptureMem Signed-off-by: daniellehrner <daniel.lehrner@consensys.net> * Exclude IntelliJ generated dir from spotless solidity (#10223) Signed-off-by: Simon Dudley <simon.dudley@consensys.net> * ci check to make sure that all libraries have their source code verified as well (#10217) Signed-off-by: daniellehrner <daniel.lehrner@consensys.net> * Implement aggregation in pipeline service (#10202) Signed-off-by: Miroslav Kovar <miroslavkovar@protonmail.com> * Add enableMemory parameter to debug_traceTransaction and debug_traceBlockByNumber (#10169) * Add enableMemory parameter to debug_traceTransaction Adds the enableMemory param (default false) to TransactionTraceParams. When both enableMemory and disableMemory are provided, enableMemory takes precedence. Ref: #10115 Signed-off-by: Vivek Singh Solanki <viveksolanki0509@gmail.com> * Update CHANGELOG for enableMemory parameter Signed-off-by: Vivek Singh Solanki <viveksolanki0509@gmail.com> --------- Signed-off-by: Vivek Singh Solanki <viveksolanki0509@gmail.com> * Exclude halt-burned gas from block regular gas (#10225) * Exclude halt-burned gas from block regular gas Signed-off-by: daniellehrner <daniel.lehrner@consensys.net> * Add contributor call agenda issue template (#10232) * Add contributor call agenda issue template --------- Signed-off-by: jflo <justin+github@florentine.us> Signed-off-by: Justin Florentine <justin+github@florentine.us> Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com> Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Improve block proposal cancellation to (best effort) avoid concurrency issues (#10219) * Fix concurrency issues when block proposal is cancelled during tx selection When block creation is cancelled or times out, the selection thread may still be running briefly. This change adds a CountDownLatch to internal tx selection (mirroring the existing plugin selection mechanism) and extracts a shared waitForCancellationToBeProcessed method that correctly handles negative remaining-time values and logs the outcome of the wait. Exception handling in both selection phases is split by type so that rollback() is only called for ExecutionException, where the selection thread is guaranteed to have finished. CancellationException and InterruptedException no longer trigger a rollback, removing a potential race on shared world state. In MergeCoordinator, exceptions thrown after a cancellation are now logged at INFO with guidance to report if unexpected, rather than at WARN, reducing noise from the expected concurrency edge cases during block proposal cancellation. Signed-off-by: Fabio Di Fabio <fabio.difabio@consensys.net> * Add unit tests for concurrency fixes and repair early-return regression - Add test verifying CancellationException during plugin selection is handled gracefully (no exception propagated to caller) - Add test verifying internal selection CountDownLatch causes buildTransactionListForBlock() to wait for the selection thread - Add test verifying Throwable thrown after block creation cancellation is handled gracefully (logged at INFO, not propagated) - Remove early return from timeLimitedSelection when isCancelled is true: the guard was causing validPendingTransactionIsNotIncludedIf SelectionCancelled to fail because evaluatePendingTransaction (which marks each tx as SELECTION_CANCELLED) was never reached; the check is unnecessary since evaluatePendingTransaction already handles isCancelled on every iteration without touching world state Signed-off-by: Fabio Di Fabio <fabio.difabio@consensys.net> --------- Signed-off-by: Fabio Di Fabio <fabio.difabio@consensys.net> * Feature add block import trace to eth simulate (#10211) * initial addition of optional block import tracing to eth_simulateV1 * move block traceEnd prior to trielog write --------- Signed-off-by: garyschulte <garyschulte@gmail.com> Co-authored-by: Justin Florentine <justin+github@florentine.us> * Handle peer permission updates in PeerDiscoveryAgentV5 (#10193) * Handle peer permission updates in PeerDiscoveryAgentV5 * Remove apparently unneeded mock calls * Refactor to reduce code deduplication --------- Signed-off-by: Matilda Clerke <matilda.clerke@consensys.net> --------- Signed-off-by: Ameziane H. <ameziane.hamlat@consensys.net> Signed-off-by: Fabio Di Fabio <fabio.difabio@consensys.net> Signed-off-by: daniellehrner <daniel.lehrner@consensys.net> Signed-off-by: Miroslav Kovar <miroslavkovar@protonmail.com> Signed-off-by: Vivek Singh Solanki <viveksolanki0509@gmail.com> Signed-off-by: Simon Dudley <simon.dudley@consensys.net> Signed-off-by: jflo <justin+github@florentine.us> Signed-off-by: Justin Florentine <justin+github@florentine.us> Signed-off-by: garyschulte <garyschulte@gmail.com> Signed-off-by: Matilda Clerke <matilda.clerke@consensys.net> Co-authored-by: ahamlat <ameziane.hamlat@consensys.net> Co-authored-by: Sally MacFarlane <macfarla.github@gmail.com> Co-authored-by: Fabio Di Fabio <fabio.difabio@consensys.net> Co-authored-by: Miroslav Kovář <miroslavkovar@protonmail.com> Co-authored-by: Vivek Singh Solanki <viveksolanki0509@gmail.com> Co-authored-by: Simon Dudley <simon.dudley@consensys.net> Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com> Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Co-authored-by: Justin Florentine <justin+github@florentine.us> Co-authored-by: garyschulte <garyschulte@gmail.com> Co-authored-by: Matilda-Clerke <matilda.clerke@consensys.net>
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