Skip to content

rpc: drop size from eth_getHeaderBy* responses - #26912

Draft
MysticRyuujin wants to merge 1 commit into
paradigmxyz:mainfrom
MysticRyuujin:eth-getheader-drop-size
Draft

MysticRyuujin wants to merge 1 commit into
paradigmxyz:mainfrom
MysticRyuujin:eth-getheader-drop-size

Conversation

@MysticRyuujin

Copy link
Copy Markdown
Contributor

eth_getHeaderByNumber and eth_getHeaderByHash no longer emit size. The value was the whole-block RLP length, the same number eth_getBlockBy* reports, so it leaked body data into a header-only response. geth, Nethermind, and Erigon's erigon_getHeaderBy* all omit it.

Implements the semantics proposed in ethereum/execution-apis#877 (ethereum/execution-apis#874). Block responses keep size.

Mechanics: RpcTypes::Header gains a SizedHeader bound with a clear_size implementation for alloy_rpc_types_eth::Header, and rpc_block_header clears the field after conversion. An alternative is changing FromConsensusHeader in reth-core to take an optional size; happy to redo it that way if preferred.

Follow-up candidate: a header-only lookup path, since rpc_block_header loads and recovers the full block only to discard the body.

let Some(block) = self.recovered_block(block_id).await? else { return Ok(None) };
let header =
let mut header =
self.converter().convert_header(block.clone_sealed_header(), block.rlp_length())?;

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the better solution here would be to change convert_header so that this accepts Optional size or remove that arg entirely, leaning towards removing entirely

@MysticRyuujin MysticRyuujin Sep 3, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Both need a reth-core change. FromConsensusHeader::from_consensus_header takes block_size: usize, so the () impl of HeaderConverter cannot build a size-free header today.

convert_header is also the only place block size gets set. Block flattens its header, and into_rpc_block* passes rlp_length to the header builder. Drop the arg and the block path has to set size after conversion, which needs a setter bound on the RPC header type in into_rpc_block*. Same trait as this PR, moved to the block path.

I prefer that version. Size is a block property, so headers never carry it and blocks add it. I can open the reth-core PR that drops the arg from FromConsensusHeader and adds the setter for into_rpc_block*, then rebase this one on the release. If you would rather take the smaller Option<usize> step first, tell me.

@MysticRyuujin

Copy link
Copy Markdown
Contributor Author

Opened paradigmxyz/reth-core#44 for the removal. from_consensus_header loses the size argument, and a new SetBlockSize trait lets into_rpc_block* set the field from the block RLP length after the header builder runs.

I have the matching reth side ready locally and checked it against that branch through a temporary [patch.crates-io]. rpc-convert, rpc-eth-api, rpc, rpc-eth-types and the rest of the workspace build, fmt and clippy are clean. RpcTypes::Header gains the SetBlockSize bound, so rpc-convert needs reth-primitives-traits with the rpc-compat feature.

Two notes on that version:

  • eth_subscribe newHeads keeps its size field. The refactor drops it by default, so I set it explicitly in header_stream to hold the current output. Tell me if you would rather have newHeads lose it too, which would match the header responses.
  • Uncle responses keep size as well, set from the uncle block RLP length as before.

I will push it here once reth-core cuts a release with that change. This PR stays on the current version until then.

@mattsse mattsse added M-prevent-stale Prevents old inactive issues/PRs from being closed due to inactivity M-changelog This change should be included in the changelog labels Sep 5, 2026
@mattsse

mattsse commented Sep 5, 2026

Copy link
Copy Markdown
Collaborator

We will finalize this after paradigmxyz/reth-core#44 is merged and included in the next minor reth-core release.

@MysticRyuujin

Copy link
Copy Markdown
Contributor Author

Status update. ethereum/execution-apis#877 is out of draft, and so are the Nethermind, Besu, Erigon and ethrex PRs. go-ethereum #35627 is merged.

This PR stays a draft, as agreed. It waits on reth-core#44 and the next minor reth-core release. The replacement version is ready locally and verified against that branch through a temporary [patch.crates-io]. I will push it and take this out of draft once the release lands.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

M-changelog This change should be included in the changelog M-prevent-stale Prevents old inactive issues/PRs from being closed due to inactivity

Projects

Status: Backlog

Development

Successfully merging this pull request may close these issues.

2 participants