Skip to content

rpc/jsonrpc: use overridden fee values consistently in eth_estimateGas and eth_call#20949

Merged
yperbasis merged 6 commits into
erigontech:mainfrom
Sahil-4555:fix/rpc-block-overrides-call-estimate
May 5, 2026
Merged

rpc/jsonrpc: use overridden fee values consistently in eth_estimateGas and eth_call#20949
yperbasis merged 6 commits into
erigontech:mainfrom
Sahil-4555:fix/rpc-block-overrides-call-estimate

Conversation

@Sahil-4555

Copy link
Copy Markdown
Contributor

This PR fixes two inconsistencies in RPC behavior.

First, in eth_estimateGas, the validation for blob fee caps was not working properly when a blobBaseFee block override was provided. This happened because estimate mode was skipping that validation when NoBaseFee was enabled. The fix ensures that even in estimate mode, blob fee caps are still properly validated when the transaction includes blobs.

Second, in eth_call, the gas price calculation for EIP-1559 was using the original block header’s base fee instead of the overridden BaseFeePerGas. This could lead to incorrect GASPRICE and related fee calculations when block overrides were used. The fix makes eth_call construct its message and block context using the overridden header whenever header-based fee fields are changed.

In simple terms, if a caller overrides block fee settings, the RPC now consistently uses those overridden values everywhere.

The regression tests added cover:

  • Proper gas limit bounding when overridden in eth_estimateGas
  • Rejection of invalid blob base fee overrides
  • Correct impact of base fee overrides on GASPRICE calculations

@Sahil-4555 Sahil-4555 marked this pull request as ready for review May 2, 2026 12:27
Comment thread execution/protocol/txn_executor.go Outdated
blobGasPrice := st.evm.Context.BlobBaseFee
maxFeePerBlobGas := st.msg.MaxFeePerBlobGas()
if !st.evm.Config().NoBaseFee && blobGasPrice.Cmp(maxFeePerBlobGas) > 0 {
if maxFeePerBlobGas == nil {

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.

skipBlobCheck := st.evm.Config().NoBaseFee && maxFeePerBlobGas.IsZero()
if !skipBlobCheck && blobGasPrice.Cmp(maxFeePerBlobGas) > 0 {
return ErrMaxFeePerBlobGas
}
The blob fee check should mirror the skipCheck pattern already used for EIP-1559 fees at line 321-323
Removing all skip logic makes erigon stricter than geth: a caller who leaves maxFeePerBlobGas at zero will now always get an error, even in simulation contexts where no fee is intended.

Copilot AI left a comment

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.

Pull request overview

This PR makes RPC simulation consistent when block fee-related overrides are provided, ensuring eth_call and eth_estimateGas use overridden fee values uniformly during message construction and transaction pre-checks.

Changes:

  • eth_call: build the call message and EVM block context using a header with BlockOverrides applied (notably BaseFeePerGas).
  • eth_estimateGas: ensure blob fee-cap validation is not incorrectly skipped under NoBaseFee when blob-related fields are present.
  • Add/extend regression tests covering gasLimit bounding, blob base fee override validation, and GASPRICE impact from base fee overrides.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
rpc/transactions/call.go Uses an overridden header to compute 1559 gas price fields and initialize block context consistently under block overrides.
rpc/jsonrpc/eth_call_test.go Adds regression tests for override behavior (gasLimit ceiling, blob base fee validation, baseFee affecting GASPRICE), plus test refactors/helpers.
execution/protocol/txn_executor.go Adjusts blob fee-cap pre-check skip logic so estimate/call modes don’t bypass validation when blob fee caps are explicitly provided.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

blobGasPrice := st.evm.Context.BlobBaseFee
maxFeePerBlobGas := st.msg.MaxFeePerBlobGas()
if !st.evm.Config().NoBaseFee && blobGasPrice.Cmp(maxFeePerBlobGas) > 0 {
skipBlobCheck := st.evm.Config().NoBaseFee && (maxFeePerBlobGas == nil || maxFeePerBlobGas.IsZero())
@yperbasis yperbasis added the RPC label May 4, 2026
@yperbasis yperbasis added this to the 3.6.0 milestone May 4, 2026
@yperbasis yperbasis enabled auto-merge May 5, 2026 08:11
@yperbasis yperbasis modified the milestones: 3.6.0, 3.5.0 May 5, 2026
@yperbasis yperbasis added this pull request to the merge queue May 5, 2026
@github-merge-queue github-merge-queue Bot removed this pull request from the merge queue due to failed status checks May 5, 2026
@yperbasis yperbasis enabled auto-merge May 5, 2026 10:18
@yperbasis yperbasis added this pull request to the merge queue May 5, 2026
Merged via the queue into erigontech:main with commit efd3a36 May 5, 2026
34 of 35 checks passed
@Sahil-4555 Sahil-4555 deleted the fix/rpc-block-overrides-call-estimate branch May 5, 2026 12:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants