Core chain client and data exchange
The Core client connects a Celestia node to the consensus chain. It checks that each source serves the expected network, turns new block signals into extended headers and available data, and provides a single lookup path for current and historical headers. This page is part of Block data acquisition and availability and relates to Header synchronization, Share retrieval and reconstruction, and Data availability sampling.
Core boundary
Core is the consensus-side source for block identity and block data. The client turns Core's block, commit, validator set, status, and event information into the inputs that the header and data-availability services use.
RPC data contract
The client uses Core RPC over gRPC for block lookup, commit lookup, validator-set lookup, status, and new-height subscription. A signed block contains the consensus header, commit, validator set, and transaction data. Together these values let the node build an ExtendedHeader and its committed EDS rather than treating a block notification as complete block data.
The connection can use transport security and an authentication token when the endpoint requires them. Calls retry transient unavailable errors, and the connection accepts large block responses because transaction data can exceed normal gRPC message sizes. RPC services describes the node-facing API that exposes the resulting data to applications.
References: core/fetcher.go• L20-24 core/fetcher.go• L60-77 core/fetcher.go• L80-117 nodebuilder/…/constructors.go• L62-113
Network identity
The expected chain ID is a startup boundary for Core data. The client checks the endpoint's reported network before the listener starts, then checks the chain ID on fetched blocks before they enter the data path. This prevents a reachable endpoint on another network from becoming a trusted source.
References: core/fetcher.go• L242-268 core/listener.go• L143-160 core/listener.go• L300-312 core/exchange.go• L76-85
Block intake
Block intake separates the fast signal that a new height exists from the slower work needed to process that height. Core announces a height first. The listener then fetches the signed block from the announcing source, drops blocks outside the local window when needed, creates the data commitment, stores eligible data, and publishes the resulting header.
New-block events
The subscription carries a height and the source that announced it, not the full block. The listener fetches the block only after it receives the event. This keeps event fan-in light and lets the system choose the source that supplied the signal.
The subscription remains active across transient stream failures. When a stream ends or a receive fails, the client attempts to establish a new subscription. A stuck subscription is reported so operators can distinguish a quiet chain from a broken event path.
References: core/fetcher.go• L27-39 core/fetcher.go• L169-221 core/listener.go• L184-215
Header and EDS production
For each new height, the listener first checks stored heights to avoid repeat work. It fetches the signed block from the source that announced it, checks whether the block is inside the retention window, and only then checks source sync state and builds the EDS. It combines the block header, commit, validator set, and EDS into an ExtendedHeader. The DAH in that header binds the block to the EDS.
The listener stores eligible EDS data before it publishes the header. A block from a source that is still catching up is published to local consumers only. A block from a caught-up source also announces its data hash and header to the network. This ordering keeps header-driven consumers from requesting data before the local bridge path has made it ready.
This diagram shows how a Core height signal becomes a locally available header and, when permitted, a network announcement.
flowchart LR
A[Core height event] --> B[Fetch signed block from announcing source]
B --> C{Inside availability window?}
C -->|No| D[Drop old block]
C -->|Yes| E[Check source sync state]
E --> F[Build EDS and DAH]
F --> G[Create extended header]
G --> H[Store eligible EDS]
H --> I[Publish locally and, when caught up, to network]
References: core/listener.go• L218-286 core/listener.go• L289-360 core/eds.go• L14-38 core/header_test.go• L20-49 core/eds_test.go• L21-64
Availability and retention
The availability window decides which fetched EDS data the node keeps. A non-archival node drops blocks outside that window. An archival node keeps the original data square for old blocks but does not keep the extended quadrant outside the active window. Empty block data follows the same header path without requiring useful share storage.
The data root is derived from the block transactions and application version. Empty blocks use the canonical empty EDS roots. This keeps the header's data commitment aligned with Core even when a block has no transactions.
This policy links Core intake to later sampling and share retrieval. A header can remain useful after its local EDS is gone because Share retrieval and reconstruction can obtain the data from the network.
References: core/eds.go• L14-38 core/option.go• L23-27 core/option.go• L44-54 core/eds_test.go• L67-180 core/header_test.go• L20-49
Source failover
Multiple Core endpoints provide resilience for live block intake. Each endpoint has its own event subscription. The combined stream preserves the source identity so the listener can fetch and check a block against the same endpoint that announced it.
Source verification
At startup, every configured source reports its chain ID in parallel. The active set keeps sources that confirm the expected network and removes sources that are unreachable or report another network. Startup fails when no source can be confirmed. An operator restores a removed source by fixing its endpoint and restarting the node.
References: core/multisource.go• L19-30 core/multisource.go• L52-117 nodebuilder/…/constructors.go• L48-57 core/multisource_test.go• L286-343
Event fan-in
The multi-source client combines all active subscriptions into one event stream. The same height may appear more than once because more than one source can observe it. The listener uses stored height as the durable de-duplication point instead of assuming that sources deliver heights in the same order.
If one source stops, the other source subscriptions continue. The combined stream closes only after all source workers stop. With one source, the wrapper keeps the source's event order and preserves the same chain and sync-status behavior as a direct source.
References: core/multisource.go• L119-175 core/listener.go• L218-230 core/multisource_test.go• L102-172 core/multisource_test.go• L346-428
Source-specific retry
The first source to announce a height is treated as the fastest source for that event. The client fetches the block and its sync state from that announcing source. It does not silently switch sources during the same event because the source's sync state determines whether the block is a new head or a catch-up replay.
When a fetch or sync-status request fails, the listener leaves the height unstored. The source client returns that error without trying another source for the same event. A later duplicate event can then retry the full operation through another source. This makes failover depend on the durable store and the event fan-in rather than on hidden cross-source state.
The listener also checks the fetched block's chain ID after the de-duplication gate. A wrong-chain source that wins the race for an unprocessed height is treated as a critical configuration error. A later duplicate from a slower source is skipped after the height is stored.
References: core/multisource.go• L177-227 core/listener.go• L231-286 core/listener.go• L300-312 core/multisource_test.go• L204-283
Header exchange
The Core exchange gives callers a common header interface for current and historical chain data. It prefers full Core blocks because they provide enough information to build and store the EDS. When Core has pruned a block, it can return an extended header from the peer network and leave EDS retrieval to the data-availability path.
Direct Core retrieval
A height or hash request fetches the matching block from Core, obtains the commit and validator context when needed, builds the EDS, constructs the extended header, and stores data allowed by the retention policy. Range requests fetch heights concurrently while returning only the largest contiguous prefix that is known to be safe to use.
The exchange verifies the returned header against the requested hash and verifies each header in a range against the prior header. These checks keep the Core path aligned with the same header trust rules used by Header synchronization.
Range requests must move forward from the supplied header. An empty forward range is valid, while a range whose end is at or below the supplied height is rejected before any fetch starts. If the requested end is beyond the chain tip, the exchange returns the contiguous prefix that it can verify instead of treating the missing future heights as a complete failure.
References: core/exchange.go• L87-153 core/exchange.go• L156-195 core/exchange.go• L234-279 core/exchange_test.go• L20-70 core/exchange_test.go• L188-231
Header-only fallback
When Core cannot provide a requested historical block, the exchange asks the peer header service for the extended header by height or hash. The returned header remains useful for chain following and data requests. The DAS path can obtain the EDS later through the share network, as described in Data availability sampling.
The fallback applies to missing full blocks at historical heights. The exchange also falls back to the peer service for the head when Core cannot return it. A Core failure can therefore degrade a result from a full data-backed header to a header-only result without changing the caller's header interface.
References: core/exchange.go• L156-231 core/exchange.go• L243-279 core/exchange.go• L282-298 core/option.go• L56-63
Routing exchange
The routing exchange presents Core and peer-to-peer header sources as one header service. It uses Core for the authoritative head and for direct height lookup. For ranges, it estimates the boundary between retained recent data and older data, then sends each side to the source that is expected to serve it.
Range routing
The availability window is the routing boundary. Recent heights inside the window use Core because Core can provide the full block and EDS. Older heights use the peer network because consensus nodes may prune those blocks. A range that crosses the boundary is split into an old peer segment and a recent Core segment, then returned as one ordered range.
This diagram shows how a range request is split when it crosses the availability boundary.
flowchart LR
A[Header range request] --> B{Range crosses availability cutoff?}
B -->|No, recent| C[Core exchange]
B -->|No, historical| D[P2P header exchange]
B -->|Yes| E[P2P historical segment]
E --> F[Core recent segment]
C --> G[Ordered headers]
D --> G
F --> G
References: core/routing_exchange.go• L14-26 core/routing_exchange.go• L73-145 core/routing_exchange.go• L148-160
Lookup fallback
A hash lookup tries Core first because Core can return a complete, locally storable result. If Core does not have the block, the routing exchange asks the peer exchange for the header. This fallback supports historical identity and validation without forcing the node to retain every old EDS locally.
References: core/routing_exchange.go• L48-71 core/exchange.go• L198-217
Change checklist
When these files or sections are changed, remember to consider these:
- Changes to the Core block or event contract must keep height, source identity, signed-block data, and sync status aligned across single-source and multi-source intake.
- Changes to chain-ID checks must preserve both startup pruning and the later block-level guard. A source that passes one check must not bypass the other.
- Changes to event de-duplication must keep the store ordering intact. A failed fetch or sync-status check must leave the height available for another source's event.
- Changes to the availability window must stay aligned across EDS retention, header range routing, share retrieval, and DAS behavior.
- Changes to Core pruning or peer fallback must preserve the difference between a full EDS-backed header and a header whose EDS is fetched later.
- Changes to range validation or partial results must preserve the forward-range contract and the contiguous-prefix behavior used by callers.
- Changes to source subscription shutdown must keep the fan-in open while any healthy source remains active and must close it only after all source workers stop.
- Changes to the listener's pre-processing order must keep historical blocks from reaching sync checks or EDS construction when retention rules will drop them.
- Changes to Core test-node startup must preserve readiness before RPC or event clients begin use and must release each service that started when setup fails part-way through.
Important failure modes
| Trigger | Consequence | Guard |
|---|---|---|
| A Core endpoint reports the wrong chain ID | The node may ingest blocks from another network | Verify the expected chain ID at startup and check the fetched block before processing it |
| The fastest source for an unprocessed height serves the wrong chain | The listener treats the source as a critical configuration error | Check the block chain ID after de-duplication and identify the source in the failure |
| A source becomes unreachable during a block event | That event cannot be completed from the announcing source | Leave the height unstored so a duplicate event from another source can retry it |
| A source is still catching up when it announces a block | The node may mistake historical replay for a new network head | Query sync state from the source that announced the event and publish only locally while it catches up |
| A source announces a block outside the retention window | The node can waste work building data that it will discard | Check block time after fetch and drop the block before sync checks and EDS construction |
| Core has pruned a historical block | A full block and local EDS cannot be built from Core | Fall back to a peer extended header and let DAS or share retrieval obtain the EDS later |
| A fetched block does not match the requested header identity or chain | The node could bind the wrong data to a requested height or hash | Check chain identity, header construction, requested hash, and header links |
| A range request ends at or below its starting header | Unsigned range arithmetic can produce an invalid fetch span or panic | Reject the range before fetching and allow only a forward end height |
| A non-archival node receives an old block outside its window | The header may remain available but the EDS is not retained | Apply the shared availability and storage policy before keeping the EDS |
| All configured Core sources fail verification | Live Core intake cannot start with a trusted source | Fail startup until at least one source confirms the expected network |
Key files
| File | Why to read it |
|---|---|
| core/fetcher.go | Defines the Core RPC boundary for blocks, status, chain identity, and new-height events. |
| core/listener.go | Shows the live path from Core events to EDS-backed headers and network publication. |
| core/multisource.go | Shows source verification, event fan-in, and source-specific retry behavior. |
| core/exchange.go | Defines full Core header retrieval, EDS storage, range behavior, and peer header fallback. |
| core/routing_exchange.go | Defines how current and historical header ranges move between Core and peer exchange. |
| core/eds.go | Defines the relationship between the availability window and EDS retention. |
| core/testing.go | Provides ready Core-backed test networks and controlled cleanup for RPC and event-client tests. |
| nodebuilder/…/constructors.go | Shows Core connection setup, endpoint auth, retry behavior, and multi-source assembly. |
| nodebuilder/…/module.go | Shows how Core fetch, exchange, routing, and listener services join the bridge node. |
| header/header.go | Defines the extended header that connects Core consensus data to the DAH and EDS. |
| share/…/window.go | Defines the shared age boundary used by storage and data retrieval. |