Skip to content

return -38015 when tx gas exceeds block gas limit#10073

Open
kkaur01 wants to merge 2 commits intobesu-eth:mainfrom
kkaur01:eth-simulate-v1-block-gas-limit-exceeded
Open

return -38015 when tx gas exceeds block gas limit#10073
kkaur01 wants to merge 2 commits intobesu-eth:mainfrom
kkaur01:eth-simulate-v1-block-gas-limit-exceeded

Conversation

@kkaur01
Copy link
Contributor

@kkaur01 kkaur01 commented Mar 19, 2026

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?

  • 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?

Signed-off-by: kkaur01 <kanchan.kaur@consensys.net>
Copy link
Contributor

@macfarla macfarla left a comment

Choose a reason for hiding this comment

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

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"),
Copy link
Contributor

Choose a reason for hiding this comment

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

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"),

@macfarla macfarla assigned kkaur01 and unassigned macfarla Mar 19, 2026
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.

another eth_simulateV1 inconsistency bug

2 participants