op-reth: validate fork-specific block-header extraData
Bug Description
At develop@a6a088325deebbe6cad74db395b9a079669580b6, OpBeaconConsensus::validate_header only applies the generic 32-byte extraData length cap.
It therefore accepts non-genesis pre-Holocene headers with non-empty extraData, and malformed Holocene/Jovian encodings whose length is at most 32 bytes. The OP specifications require empty pre-Holocene extraData, exactly 9 bytes with version 0 during Holocene, and exactly 17 bytes with version 1 from Jovian onward.
The decoders updated by #21292 enforce the fork-specific encoding rules, but they are only reached later when a header is used as the parent for base-fee calculation. They do not validate the current header. This delays rejection by one block and differs from op-geth, which calls ValidateOptimismExtraData while processing engine_newPayload.
Steps to Reproduce
- Construct an
OpChainSpecwith the relevant fork activation. - Construct a sealed header that is otherwise valid but has invalid
extraData. - Call
OpBeaconConsensus::validate_header. - Observe
Ok(())for examples such as:- non-empty pre-Holocene
extraDataon a non-genesis header; - empty or wrong-version Holocene
extraData; - a 9-byte Holocene encoding after Jovian activation.
- non-empty pre-Holocene
Expected behavior
Match the OP execution specification and op-geth ValidateOptimismExtraData behavior:
- allow arbitrary pre-Holocene
extraDataonly for the configured genesis header; - require empty
extraDataon other pre-Holocene blocks; - validate the exact Holocene and Jovian formats at their respective activation timestamps.
Environment Information:
- Repository:
ethereum-optimism/optimism - Commit:
a6a088325deebbe6cad74db395b9a079669580b6 - Component:
rust/op-reth/crates/consensus - Operating system: independent of OS; reproduced by direct consensus validation
Configurations:
Default OpBeaconConsensus with timestamp-activated Holocene/Jovian chain specifications. No special node flags are required.
Logs:
No runtime logs are required. The direct validate_header call unexpectedly returns Ok(()) for the malformed headers above.
Additional context
Related work covers adjacent but incomplete parts of the behavior:
- #18951 / #21292 added validation to the op-alloy decoders.
- ethereum-optimism/op-geth#743 added the complete op-geth header validation.
- paradigmxyz/reth#20858 tightened payload-attribute validation, not block-header validation.
The proposed fix belongs in the consensus layer so every import path applies the same rule.
Source: ethereum-optimism/optimism