Expand description
L2BlockHeader — independently hashable L2 block metadata and commitments.
Requirements:
- BLK-001 — field groups / NORMATIVE § BLK-001
- BLK-002 — constructors / NORMATIVE § BLK-002
- BLK-007 — version auto-detection / NORMATIVE (BLK-007)
- SVL-001 — header
versionvs height / DFSP activation (L2BlockHeader::validate) - SVL-002 — DFSP roots must be
EMPTY_ROOTbefore activation (L2BlockHeader::validate_with_dfsp_activation) - SVL-003 — declared
L2BlockHeader::total_cost/L2BlockHeader::block_sizevs protocol caps (crate::MAX_COST_PER_BLOCK,crate::MAX_BLOCK_SIZE) - SVL-004 —
L2BlockHeader::timestampvs wall clock +crate::MAX_FUTURE_TIMESTAMP_SECONDS; production [validate]/L2BlockHeader::validate_with_dfsp_activation, testsL2BlockHeader::validate_with_dfsp_activation_at_unix - HSH-001 — header
hash()(SPEC §3.1 field order; preimage lengthL2BlockHeader::HASH_PREIMAGE_LEN) - SER-002 —
L2BlockHeader::to_bytes/L2BlockHeader::from_bytes(SPEC §8.2; bincode +BlockError::InvalidDataon decode) - SER-003 —
L2BlockHeader::genesisdeterministic bootstrap (SPEC §8.3; see NORMATIVE § SER-003) - SPEC §2.2, SPEC §8.3 Genesis
§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
Bytes32andCostcome fromcrate::primitivesso this crate has one type identity for hashes and CLVM cost (BLK-006).- L1 proof anchors are
Option<Bytes32>; omitted proofs serialize asNone(default) per SPEC. - DFSP roots are mandatory
Bytes32fields; pre-activation they are set tocrate::EMPTY_ROOTby constructors / validation (SVL-002), not by the type itself.
Structs§
- L2Block
Header - DIG L2 block header: identity, Merkle commitments, L1 anchor, metadata, optional L1 proofs, slash proposal commitments, and DFSP data-layer roots.