Header synchronization
Header synchronization keeps a node's view of the Celestia chain current and makes each block's consensus and data-availability commitments available to other node services. It turns Core block data into a common ExtendedHeader form, checks that form before use, stores it, exchanges it with peers, and exposes it through the node API. This page is a child of Block data acquisition and availability and relates to Core chain client and data exchange, Share retrieval and reconstruction, and Data availability sampling.
Header model
An ExtendedHeader is the shared identity for a Celestia block. It joins the consensus header with the commit that proves the block, the validator set that can verify the commit, and the Data Availability Header (DAH) that commits to the block's encoded data. Other data services use this object to select a block and to check its data root.
Extended header identity
The raw consensus header supplies the chain ID, height, time, links to the prior block, validator hashes, and the data hash. The commit supplies the block ID and signatures. The validator set gives the verification context. The DAH supplies the roots and square metadata for the block's extended data square (EDS), which is the erasure-coded form used by sampling and share retrieval. The extended header's block identity comes from the commit's block hash, while its data identity must match the raw header's data hash.
An EDS is normally used to build the DAH. A block with no EDS uses the minimum DAH representation, so empty blocks still have a valid header object and data commitment.
References: header/header.go• L27-69 header/header.go• L80-107
Header wire forms
The binary form uses protobuf. Its fields preserve the raw header, commit, validator set, and DAH as one message. This form is used when headers cross the peer-to-peer header exchange. JSON uses the CometBFT encoder so that the same header can pass through existing Core-compatible clients and RPC tools.
The generated protobuf representation carries the same four parts. Its decoder rejects malformed wire data and skips unknown fields. The pubsub message ID is derived from the committed block hash instead of the full message body. Validators can produce different valid signature sets for the same block, so a body-based ID could treat equivalent headers as different messages. If the payload cannot yield a commit, the ID falls back to a hash of the payload; header validation still rejects the faulty message.
References: header/…/extended_header.pb.go• L30-35 header/serde.go• L13-64 header/serde.go• L67-108 header/header.go• L209-245
Header validation
Validation protects downstream services from a header that is incomplete or internally inconsistent. It checks the raw header, supported application version, commit, validator set, DAH, validator hash, DAH data root, commit height, block hash, and commit signatures.
Header-to-header verification uses the shortest safe path. For adjacent heights it checks the prior hash and the next validator hash. For a non-adjacent header it uses the trusted validator set to verify the commit with the light-client trust rule. A failed check prevents the header from becoming trusted synchronization state.
The shared header test fixtures create valid chains, validator commits, empty DAHs, and EDS-backed DAHs. They also cover the supported application-version boundary, which keeps the validation contract visible to both local producers and peer-delivered headers. Fuzz coverage adds arbitrary encoded inputs and tampered commitments to this contract. It checks that message-ID generation and decoding do not panic, valid binary forms round-trip, encoding remains stable, and verification runs only after validation succeeds.
References: header/header.go• L109-162 header/header.go• L165-206 header/…/testing.go• L100-140 header/…/testing.go• L200-228 header/…/validate_test.go• L18-103 header/…/fuzz_test.go• L98-149
Header production and synchronization
The header life cycle has two related paths. Bridge nodes create headers from newly received Core blocks and publish them. Light nodes and bridge nodes also sync stored extended headers from the network through the shared header exchange and syncer. This separation lets a node obtain a header even when the source that normally serves full block data has pruned that block.
The diagram shows how a new block becomes a stored and published header, and how a missing Core block uses the header-only peer path.
flowchart LR
A[Core block event] --> B[Fetch signed block]
B --> C[Build EDS and DAH]
C --> D[Create ExtendedHeader]
D --> E[Store header and EDS]
E --> F[Publish header]
G[Header request] --> H{Core has block?}
H -- Yes --> B
H -- No --> I[Fetch ExtendedHeader from peer]
I --> J[Verify and return header]
J --> K[DAS retrieves EDS later]
Core-to-header flow
Core, the consensus process, announces new block heights through the Core client. The listener fetches the signed block, builds its EDS, and passes the block header, commit, validator set, and EDS to the header constructor. After the EDS and extended header are stored, the listener publishes the header. A block that is still part of Core catch-up is made available to local consumers without being advertised as a new network head.
The Core exchange uses the same constructor for direct header requests. If Core no longer has a requested block, the exchange asks the peer-to-peer header service for only the extended header. The DAS service can retrieve the EDS later, so header availability does not depend on local full-block retention.
References: core/listener.go• L77-83 core/listener.go• L218-360 core/exchange.go• L156-217 core/exchange.go• L220-298
Peer synchronization
The nodebuilder header module combines four responsibilities: a durable header store, a peer exchange client, a pubsub subscriber, and a syncer. The syncer uses the exchange, store, and subscriber to advance the local chain view while validating header links.
The module also runs a peer exchange server. This allows other nodes to request headers from the local store. Header pruning follows the configured retention window. Archival bridge mode disables header pruning and starts from the network genesis so that old headers remain available.
References: nodebuilder/…/constructors.go• L28-70 nodebuilder/…/constructors.go• L73-118 nodebuilder/…/constructors.go• L121-146
Node role behavior
The header module changes its network role by node type. A light node receives headers and exposes a header exchange to the rest of its node. A bridge node also broadcasts locally produced headers and supplies the standard constructor used by the Core listener.
Bridge nodes use fanout-only header subscription. This prevents a bridge from consuming a gossiped header before its local Core listener has stored the matching EDS. It keeps header-driven sampling aligned with local data storage.
References: nodebuilder/…/module.go• L25-50 nodebuilder/…/module.go• L52-137 nodebuilder/…/module.go• L36-99
Header service boundary
The nodebuilder header service is the stable boundary between synchronization components and callers. It reads from the local store for historical data, reads from the syncer for the network view, and converts subscriptions into a context-bound stream for RPC clients and other modules.
Header queries
The service exposes the local head, network head, tail, lookup by hash, lookup by height, bounded height ranges, and a wait operation. A local head is the highest header stored by this node. A network head is the syncer's current view. The tail is the lowest retained header; data below it is not available through this service.
Height lookup compares the requested height with both the network head and the retained store. It returns the network head or tail at those exact boundaries, serves retained heights from the store, and distinguishes a request that is still being written from one that is beyond the network view. Range requests use an exclusive upper bound and reject nil starting headers, reversed or empty ranges, and requests above the shared peer-exchange limit.
References: nodebuilder/…/header.go• L16-54 nodebuilder/…/service.go• L56-223 nodebuilder/…/service_test.go• L19-142
Header subscriptions
A subscription delivers recent extended headers in arrival order until its context ends or the underlying subscription closes. The service cancels the underlying subscription when the output stream closes, so callers can use context cancellation as the lifecycle control.
Consumers use this stream to react to new canonical headers rather than polling. Share and availability services use height-based header lookup when they need the DAH for a specific request, while sampling and peer services can follow the live stream.
References: nodebuilder/…/service.go• L227-255 nodebuilder/…/share.go• L148-193 nodebuilder/…/header_test.go• L39-91
RPC and operator access
The header module is registered as the header RPC service. Its read-only API mirrors the service boundary, so applications can query heads, retained headers, sync state, and subscriptions without accessing the store or syncer directly. The command line exposes the same operational view through local-head, network-head, get-by-hash, get-by-height, sync-state, and tail commands.
References: nodebuilder/…/header.go• L56-121 nodebuilder/…/constructors.go• L17-35 nodebuilder/…/header.go• L13-133
Configuration relationships
Header configuration connects peer selection, retention, sync start points, and peer exchange limits. The node-wide configuration carries this section into module construction, where validation runs before the store, exchange, subscriber, and syncer start.
Trusted peers identify reliable sources for header retrieval. They do not bypass header verification. The retention window must cover the storage window needed by availability work; archival mode is the explicit exception because it retains the full header history.
References: nodebuilder/…/config.go• L19-35 nodebuilder/…/config.go• L38-105 nodebuilder/config.go• L25-50 nodebuilder/…/module.go• L52-115
Change checklist
When these files or sections are changed, remember to consider these:
- Changes to
ExtendedHeaderfields must stay aligned across the protobuf message, generated protobuf representation, binary conversion, JSON behavior, and every producer that builds the header. - Changes to header identity or
MsgIDmust preserve deduplication for equivalent commits and must remain compatible with peers on the header pubsub topic. - Changes to validation must be checked against both direct Core construction and peer-delivered headers. The DAH data root must still agree with the raw header commitment.
- Changes to the retention window must preserve the availability storage window and the documented meaning of the tail header.
- Changes to the
Moduleinterface must be mirrored in the RPC API wrapper and in callers such as the share module. - Changes to bridge subscriber timing must preserve the ordering between local EDS storage and header-driven consumers.
- Changes to the protobuf field shape must keep generated code and all binary readers and writers in step.
- Changes to height lookup or range rules must preserve the shared boundary between local callers and the peer exchange, including its exclusive upper bound and maximum request size.
Important failure modes
| Trigger | Consequence | Guard |
|---|---|---|
| A header's DAH root differs from the raw header's data hash | The header cannot prove which EDS belongs to the block | Full header validation checks both commitments |
| A commit height, block hash, or validator hash does not match the header | The node may accept a header from a different block or validator history | Commit and validator checks run during validation and header-link verification |
| A request is below the retained tail | The node cannot serve the header or related retained data | Check the tail and configure a sync start that covers the required height |
| A height request is beyond both the local and network heads | The caller receives a future-height error instead of a misleading empty result | Compare the request with both service views before reading the store |
| A range request is reversed, empty, or above the shared limit | The caller gets a range error and no partial header list | Validate the exclusive range before using the store |
| A bridge receives a header before its local EDS is stored | DAS work can request data that the local listener has not made ready | Bridge header subscription uses fanout-only mode |
| Core has pruned a requested block | Direct block retrieval fails even though the header may still be available | The Core exchange falls back to peer header retrieval; DAS obtains the EDS separately |
| The configured sync retention is below the availability storage window | Required sampling data can outlive its header | Configuration validation rejects the unsafe window |
| A serialized header is decoded but not validated | Malformed or inconsistent commitments can reach synchronization or data services | Validate headers after decoding and before trusting or storing them |
Key files
| File | Why to read it |
|---|---|
| header/header.go | Defines the extended header model, identity, construction, validation, and header-link verification. |
| header/serde.go | Shows the protobuf and JSON boundary plus the stable pubsub message identity. |
| header/…/extended_header.pb.go | Shows the generated protobuf wire representation used by binary header exchange. |
| header/…/extended_header.proto | Defines the cross-process and peer wire shape of an extended header. |
| header/…/testing.go | Provides valid chain, commit, DAH, and EDS fixtures for header behavior. |
| header/…/validate_test.go | Shows the supported application-version boundary for header validation. |
| header/…/fuzz_test.go | Checks that arbitrary wire inputs do not panic and that valid headers round-trip and verify safely. |
| core/listener.go | Shows how new Core blocks become EDS-backed headers and enter the header network. |
| core/exchange.go | Shows direct Core retrieval and the header-only peer fallback when Core has pruned a block. |
| nodebuilder/…/constructors.go | Shows the store, peer exchange, syncer, and lifecycle responsibilities of the header module. |
| nodebuilder/…/module.go | Shows node-role wiring and the bridge ordering rule for header gossip. |
| nodebuilder/…/service.go | Defines the service behavior for lookups, sync state, retention boundaries, range limits, and subscriptions. |
| nodebuilder/…/service_test.go | Verifies the service's height and range boundary contracts, including syncer lag and invalid requests. |
| nodebuilder/…/header.go | Defines the public module and RPC-facing header contract. |
| nodebuilder/…/config.go | Defines peer, retention, sync, and exchange settings and their safety checks. |