Skip to content

feat(l1): add eth_getHeaderByHash and eth_getHeaderByNumber - #7247

Draft
MysticRyuujin wants to merge 1 commit into
lambdaclass:mainfrom
MysticRyuujin:eth-getheader-methods
Draft

feat(l1): add eth_getHeaderByHash and eth_getHeaderByNumber#7247
MysticRyuujin wants to merge 1 commit into
lambdaclass:mainfrom
MysticRyuujin:eth-getheader-methods

Conversation

@MysticRyuujin

Copy link
Copy Markdown
Contributor

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.

The result is the consensus header plus the derived hash, with no size, totalDifficulty, or body fields. The result is null for an unknown block, for the pending tag (the spec diverges from resolve_block_number's latest fallback here), and for an unresolvable safe or finalized tag.

BlockHeader serialization now skips baseFeePerGas, withdrawalsRoot, and parentBeaconBlockRoot when absent, matching the struct's other optional fork fields. The spec requires pre-fork fields to be omitted rather than null, and this also aligns eth_getBlockBy* responses with geth, which omits them. Deserialization is unchanged.

Full workspace cargo check passes; ethrex-common and ethrex-rpc test suites pass, including a new test covering the header shape, the by-hash round trip, and the three null cases.

@github-actions github-actions Bot added the external-contributor PR opened by a contributor outside the team label Sep 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

external-contributor PR opened by a contributor outside the team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant