eth: add eth_getHeaderByHash and eth_getHeaderByNumber - #877
Open
MysticRyuujin wants to merge 4 commits into
Open
MysticRyuujin wants to merge 4 commits into
MysticRyuujin wants to merge 4 commits into
Conversation
This was referenced Sep 1, 2026
bomanaps
reviewed
Sep 1, 2026
Contributor
|
Thanks for taking this forward so comprehensively, including the client-side PRs. This matches the direction I had in mind when opening #874. I am comfortable with the choices to omit |
4 tasks
MariusVanDerWijden
pushed a commit
to ethereum/go-ethereum
that referenced
this pull request
Sep 9, 2026
…_getHeaderByNumber (#35627) `eth_getHeaderByNumber` now returns `null` for the `pending` tag and for a `safe` or `finalized` tag that cannot be resolved to a block. Before this change it returned a pending header with `hash`, `nonce`, and `miner` nulled, and a `-32000` error for unresolvable tags. Implements the semantics proposed in ethereum/execution-apis#877 for these methods (ethereum/execution-apis#874). Block methods are not changed.
MysticRyuujin
force-pushed
the
eth-get-header
branch
from
September 9, 2026 15:50
12a4986 to
ada8fd5
Compare
MysticRyuujin
marked this pull request as ready for review
September 9, 2026 16:01
yperbasis
pushed a commit
to Sahil-4555/erigon
that referenced
this pull request
Sep 16, 2026
…ech#23717) Adds `eth_getHeaderByHash` and `eth_getHeaderByNumber`, implementing the spec proposed in ethereum/execution-apis#877 (ethereum/execution-apis#874). geth, Nethermind, and reth already serve these methods; Erigon has them only in the `erigon_` namespace. The new methods do not reuse the `erigon_getHeaderBy*` path because its `types.Header` JSON marshaling emits pre-fork fields as literal `null` and returns errors for unknown blocks. They marshal through `ethapi.RPCMarshalHeader`, which fork-gates optional fields, and return `null` for an unknown block, for the `pending` tag, and for an unresolvable `safe` or `finalized` tag. `RPCMarshalHeader` no longer sets `size`. Its only caller overwrites the value with the block size, and the header methods must not emit it: the spec excludes `size` because no client computes a header size and the block getters already report the block size. --------- Co-authored-by: Alexey Sharov <askalexsharov@gmail.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.
Implements #874.
Adds
eth_getHeaderByHashandeth_getHeaderByNumber. The result is a newHeaderschema: the consensus header fields plus the derivedhash.sizeandtotalDifficultyare excluded, because neither is a header field. The schema is closed, so a client must not add fields. Fields introduced by a fork are omitted for headers that predate it. The result isnullfor an unknown block and forpending.slotNumber(EIP-7843) is added toBlockandHeaderto keep the schemas aligned.An unresolvable
safeorfinalizedtag is an unknown block, so the result isnullthere too. #879 put that rule inBlockTagitself, so this PR no longer repeats it in the method description.Also adds the testgen generators and 13 geth-generated fixtures.
Client work, one PR per client:
nullinstead of-32000for unresolvable tags and pending.nullfor pending instead of a header withhash,nonce, andminernulled.sizefrom header responses. The value is the whole-block RLP length. Block responses keep it.ethnamespace.erigon_getHeaderBy*emits pre-fork fields asnulland errors on unknown blocks, so it cannot be aliased directly.baseFeePerGas,withdrawalsRoot, andparentBeaconBlockRootmust be omitted, notnull.Hive rpc-compat against client master images on 2026-09-01, before any of those PRs: geth and Nethermind pass all 13 fixtures byte-identically, reth fails 10 on the extra
sizefield, and Besu, Erigon and ethrex do not implement the methods.The
pendingand unresolvable-tag rules are not reproducible on the static test chain, so no fixture covers them.