rpc: unify BlockOverrides into a single type with three override methods#19533
Draft
rpc: unify BlockOverrides into a single type with three override methods#19533
Conversation
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>
ef6ba2f to
0e9a4da
Compare
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>
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.
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:
Verify type consistency and functional behavioral with Geth.
waiting RPC test TAG