Skip to main content

Module header

Module header 

Source
Expand description

L2BlockHeader — independently hashable L2 block metadata and commitments.

Requirements:

§Usage

Prefer L2BlockHeader::new, L2BlockHeader::new_with_collateral, L2BlockHeader::new_with_l1_proofs, or L2BlockHeader::genesis so version is never caller-supplied (auto-detected from height; shared rules in L2BlockHeader::protocol_version_for_height and L2BlockHeader::protocol_version_for_height_with_activation (BLK-007). Production code that needs wall-clock timestamps should set timestamp after new() or use [crate::builder::BlockBuilder] (BLD-005): L2BlockHeader::new leaves timestamp at 0 per SPEC’s derived-new() parameter list.

Field order matches SPEC §2.2 so bincode layout stays deterministic (SER-001, HSH-001). Canonical encode/decode helpers live on L2BlockHeader::to_bytes / L2BlockHeader::from_bytes (SER-002).

§Rationale

Splitting header from body (super::block::L2Block, BLK-003) mirrors an Ethereum-style header/body split: attestations and light clients can process headers without deserializing SpendBundle payloads.

§Decisions

  • Bytes32 and Cost come from crate::primitives so this crate has one type identity for hashes and CLVM cost (BLK-006).
  • L1 proof anchors are Option<Bytes32>; omitted proofs serialize as None (default) per SPEC.
  • DFSP roots are mandatory Bytes32 fields; pre-activation they are set to crate::EMPTY_ROOT by constructors / validation (SVL-002), not by the type itself.

Structs§

L2BlockHeader
DIG L2 block header: identity, Merkle commitments, L1 anchor, metadata, optional L1 proofs, slash proposal commitments, and DFSP data-layer roots.