Skip to content

rpc: unify BlockOverrides into a single type with three override methods#19533

Draft
lupin012 wants to merge 3 commits intomainfrom
lupin012/uniform_blockOverrides
Draft

rpc: unify BlockOverrides into a single type with three override methods#19533
lupin012 wants to merge 3 commits intomainfrom
lupin012/uniform_blockOverrides

Conversation

@lupin012
Copy link
Contributor

@lupin012 lupin012 commented Feb 28, 2026

Two separate BlockOverrides structs existed in the codebase (ethapi.BlockOverrides and transactions.BlockOverrides) with overlapping but divergent fields, different field types, and different JSON tags. This caused inconsistencies across eth_call, eth_estimateGas, eth_simulateV1, and eth_callMany.

Changes:

  • Merge into a single ethapi.BlockOverrides with all 11 fields: Number, Difficulty, Time, GasLimit, FeeRecipient, PrevRandao, BaseFeePerGas, BlobBaseFee, BeaconRoot, BlockHash, Withdrawals
  • Add ethapi.BlockHashOverrides (was only in transactions package)
  • Three methods with clearly separated responsibilities:
    • Override(*BlockContext) error — for eth_call/eth_estimateGas; rejects BeaconRoot and Withdrawals (aligned with Geth); now propagates error (was silently swallowed before)
    • OverrideHeader(*Header) *Header — for eth_simulateV1 block assembly
    • OverrideBlockContext(*BlockContext, BlockHashOverrides) — for eth_simulateV1/eth_callMany; applies all fields including BlobBaseFee and BlockHash
  • Remove duplicate struct from transactions/call.go
  • Replace manual field-by-field application in eth_callMany with OverrideBlockContext call
  • Add complete unit test suite: 20 tests covering all three methods, nil receivers, field isolation, overflow checks, rejection of unsupported fields, and BlockHash map merging

Verify type consistency and functional behavioral with Geth.

waiting RPC test TAG

lupin012 and others added 2 commits February 28, 2026 10:23
Two separate BlockOverrides structs existed in the codebase
(ethapi.BlockOverrides and transactions.BlockOverrides) with overlapping
but divergent fields, different field types, and different JSON tags.
This caused inconsistencies across eth_call, eth_estimateGas,
eth_simulateV1, and eth_callMany.

Changes:
- Merge into a single ethapi.BlockOverrides with all 11 fields:
  Number, Difficulty, Time, GasLimit, FeeRecipient, PrevRandao,
  BaseFeePerGas, BlobBaseFee, BeaconRoot, BlockHash, Withdrawals
- Add ethapi.BlockHashOverrides (was only in transactions package)
- Three methods with clearly separated responsibilities:
  - Override(*BlockContext) error — for eth_call/eth_estimateGas;
    rejects BeaconRoot and Withdrawals (aligned with Geth);
    now propagates error (was silently swallowed before)
  - OverrideHeader(*Header) *Header — for eth_simulateV1 block assembly
  - OverrideBlockContext(*BlockContext, BlockHashOverrides) — for
    eth_simulateV1/eth_callMany; applies all fields including
    BlobBaseFee and BlockHash
- Remove duplicate struct from transactions/call.go
- Replace manual field-by-field application in eth_callMany with
  OverrideBlockContext call
- Add complete unit test suite: 20 tests covering all three methods,
  nil receivers, field isolation, overflow checks, rejection of
  unsupported fields, and BlockHash map merging

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@lupin012 lupin012 force-pushed the lupin012/uniform_blockOverrides branch from ef6ba2f to 0e9a4da Compare February 28, 2026 09:23
Align the error message for the Withdrawals rejection with the Geth
format and with the existing BeaconRoot message: both now use the
lowercase-field-name pattern so that callers can reliably check for
the field name (e.g. assert.Contains(..., "withdrawals")).

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
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.

1 participant