return -38015 when tx gas exceeds block gas limit#10073
Open
kkaur01 wants to merge 2 commits intobesu-eth:mainfrom
Open
return -38015 when tx gas exceeds block gas limit#10073kkaur01 wants to merge 2 commits intobesu-eth:mainfrom
kkaur01 wants to merge 2 commits intobesu-eth:mainfrom
Conversation
Signed-off-by: kkaur01 <kanchan.kaur@consensys.net>
macfarla
reviewed
Mar 19, 2026
Contributor
macfarla
left a comment
There was a problem hiding this comment.
You could add a test for mid-block partial consumption - The tests both start with a fresh block (zero cumulative gas used). There's no test for the case where a first transaction uses some gas and a second transaction's explicit gas exceeds the remaining gas. This is the more realistic scenario and worth covering, since getRemainingGas() tracks intra-block cumulative usage.
also add a changelog entry
reference tests are passing ✔️
I ran rpc-compat hive tests locally and got 11 failures, which is the same as main branch so ✔️
Mar 19 14:24:48.798 INF simulation ethereum/rpc-compat finished suites=1 tests=200 failed=11
11 tests failed
| /** The nonce is invalid. */ | ||
| INVALID_NONCES(-32602, "Invalid nonces"), | ||
| /** Block gas limit exceeded by the block's transactions. */ | ||
| BLOCK_GAS_LIMIT_EXCEEDED(-38015, "Block gas limit exceeded by the block's transactions"), |
Contributor
There was a problem hiding this comment.
Suggested change
| BLOCK_GAS_LIMIT_EXCEEDED(-38015, "Block gas limit exceeded by the block's transactions"), | |
| BLOCK_GAS_LIMIT_EXCEEDED(-38015, "Transaction gas exceeds block gas limit"), |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
PR description
When a call explicitly provides a gas value exceeding the block's
gasLimit override, eth_simulateV1 was succeeding instead of returning
error -38015. With validation enabled, it was returning -38014
(upfront cost exceeds balance) instead of -38015 because the balance
check fired first.
Added an early check in BlockSimulator.processTransactions that throws
BLOCK_GAS_LIMIT_EXCEEDED (-38015) before the transaction simulator is
invoked, matching the behavior of geth, reth, nethermind, and erigon.
Fixed Issue(s)
fixes #9961
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