Introducing a new way to review your PRs.

Read the announcement

celestiaorg / celestia-node

Celestia Data Availability Nodes

View on GitHub

22 documents · Updated Nov 23, 2026

docs / data-availability-sampling

Data availability sampling

Data availability sampling (DAS) checks that the data committed by block headers can be obtained from the network. The DAS service follows the network head, assigns bounded sampling work, retries failed checks, and saves progress so it can continue after a restart. It is the sampling part of the broader block data flow and uses the availability services described in share retrieval. It receives headers through header synchronization and relies on the core chain client for the wider chain data flow.

System purpose

The das.DASer is a long-running service that turns new and stored extended headers into availability checks. It does not decide how shares are fetched. It calls the share.Availability contract, which can use light sampling or full data-square recovery. Light nodes gain a probabilistic view of availability. Full nodes verify availability by recovering the complete data needed by their mode.

Availability validation

Each header enters the DAS service with a data-availability header (DAH), which commits to the block’s share data. A successful availability check advances the known sampled range. A failed check remains visible as a failed height until a later retry succeeds.

The availability layer can mark an old header as outside the sampling window. DAS treats this result as a skip rather than a sampling failure. The window is shared with the share and storage systems, so header sync and data retention can use the same age boundary.

References: das/daser.go• L20-29 share/availability.go• L13-19 share/…/window.go• L12-25 share/…/availability.go• L32-35 share/…/availability.go• L27-30

Coordination lifecycle

The coordinator combines recovery of past headers with prompt checks for new network heads. It first restores saved progress, then fills available worker slots with retry and catch-up jobs while a subscriber sends new heads into a separate recent-job path.

Catch-up and live-head sampling

At start, DAS reads the header store’s tail and head. It loads the last checkpoint when one exists. If no checkpoint exists, it begins at the current tail and uses the current head as its target. The coordinator then submits contiguous catch-up ranges until it reaches the known network head.

New headers received from the network are sampled as recent jobs. This path reduces delay for newly produced blocks and moves the catch-up cursor when it would otherwise process the same height twice. The coordinator accepts a limited recent-job burst in addition to the normal worker limit, so live work can progress without allowing unbounded concurrency.

On restart, the coordinator resumes unfinished worker ranges from the checkpoint before it schedules new work. If the saved range has already reached the current network head, it marks catch-up complete without waiting for another header. A new header can make the service active again.

This diagram shows how saved progress and new headers become sampled state and monitoring data.

flowchart LR
    A[Saved checkpoint] --> C[Sampling coordinator]
    B[Header store tail and head] --> C
    N[New header subscription] --> C
    C --> W[Catch-up workers]
    C --> R[Recent-header workers]
    C --> X[Retry workers]
    W --> V[Availability check]
    R --> V
    X --> V
    V --> S[Sampling state]
    S --> P[Checkpoint and statistics]

References: das/daser.go• L71-94 das/daser.go• L97-152 das/coordinator.go• L60-97 das/restart_catchup_test.go• L44-80 das/state.go• L154-190

Sampling workers

A worker processes one header interval. Catch-up jobs cover a bounded range, recent jobs cover a header already received from the subscription, and retry jobs normally cover one failed height. A worker loads headers from the header store when it does not already have the recent header. It then gives each header its own sampling timeout.

The timeout can be set by configuration or derived from the header’s extended-square width. The derived value has a fixed network round-trip allowance plus an allowance based on the original data size in the outside data square (ODS). Light-node defaults use a fixed timeout based on block time and worker concurrency because light nodes sample a fixed number of shares rather than work through the full square.

Workers report a result only after they finish their assigned range. The coordinator removes the worker from active state, records successes, and places errors into retry state. Context cancellation stops the worker without treating unfinished work as complete. The next start can resume it from the checkpoint. A worker treats an outside-window result as a deliberate skip and does not record it as a sample error. Worker state snapshots copy failed-height data before statistics read it, so active sampling can update state without exposing a shared mutable map.

References: das/worker.go• L18-34 das/worker.go• L36-80 das/worker.go• L83-118 das/worker.go• L120-182 das/worker.go• L213-235 nodebuilder/…/config.go• L25-35

Sampling state

The coordinator keeps one state model for progress, active work, failed heights, and catch-up completion. The model separates work submitted to a worker from work successfully sampled. This lets operators distinguish lag from confirmed availability.

Progress state

The public sampling view uses three heights with different meanings:

FieldMeaning
NetworkHeadHighest header known from the header store or subscription.
CatchupHeadHighest height submitted to catch-up work. It may still be running or failed.
SampledChainHeadHighest contiguous sampled point before the first failed or active height.

CatchUpDone becomes true when no worker is active, no height is waiting for retry, and the catch-up cursor is past the network head. New heads can make the service active again after this point. WaitCatchUp waits for this state and returns when the current known range is complete. The completion signal supports concurrent waiters and can close and reopen for each new catch-up cycle. After a restart with no new headers, the service reports this state immediately when the saved range is already complete.

References: das/stats.go• L3-21 das/state.go• L225-307 das/coordinator.go• L60-68 das/daser.go• L196-204 das/restart_catchup_test.go• L65-80 das/state_catchup_test.go• L13-67

Retry state

The coordinator gives retry work priority over new catch-up ranges. A failed height records its attempt count and a time before which it must not run again. The default delays grow from one minute to four, sixteen, and sixty-four minutes. After the configured growth range, later attempts keep the last delay and produce a warning rather than disappearing from the state.

An error from a retry worker returns the height to the failed set with its count preserved. A later success removes the height from that set. An outside-window result does not enter this path because it is a deliberate skip rather than evidence that the data is unavailable.

References: das/state.go• L78-130 das/state.go• L170-209 das/backoff.go• L7-15 das/backoff.go• L28-46 das/worker.go• L77-88

Checkpoints and restart

The checkpoint is the durable recovery point for the sampling service. It is stored in the node datastore under the DAS namespace and is written during normal operation and shutdown. A checkpoint can describe partial progress. It does not require the service to be fully caught up.

Checkpoint contents

The saved state contains the next catch-up height, the latest known network head, failed heights with their retry counts, and unfinished catch-up worker ranges. Retry jobs resume through the failed-height map. Recent jobs are handled according to the catch-up cursor: a recent job at or below CatchupHead is saved as a catch-up worker range, while a recent job above CatchupHead is covered by catch-up after restart.

On restart, DAS aligns the saved state with the current header-store tail and head. It raises stale starting heights to the current tail, drops failed heights below that tail, and trims worker ranges that no longer overlap retained headers. Saved retry counts resume without an initial delay so the service can restore its prior work promptly.

References: das/checkpoint.go• L7-56 das/checkpoint_test.go• L44-56 das/daser.go• L97-149 das/state.go• L65-75

Persistence cadence

The background store periodically captures a fresh checkpoint when catch-up progress has advanced. This limits lost progress if the process stops before a clean shutdown. The interval can be set to zero to disable the background write. Shutdown still attempts to save state before and after workers stop.

The checkpoint records coordination progress. It does not store share bytes or the detailed per-share result used by a light availability implementation. Those data-layer records belong to the availability service and remain separate from DAS coordination state.

References: das/store.go• L18-31 das/store.go• L34-61 das/store.go• L64-102 das/daser.go• L155-189 share/…/availability.go• L98-122

Subscriber updates

The DAS subscriber listens for extended-header notifications from the header network. It passes each received header to the coordinator, which rejects a height that is not newer than its current network head and schedules newer headers for prompt sampling.

The subscriber keeps listening after a non-cancellation read error. It stops when its context is canceled, then cancels the underlying subscription during cleanup. This keeps transient subscription errors from ending the DAS loop while still allowing node shutdown to finish all supporting routines.

References: das/subscriber.go• L12-39 das/coordinator.go• L112-118 das/state.go• L133-152

Sampling statistics

Sampling statistics provide the operational view of DAS progress. The service gathers them through the coordinator so callers and monitoring systems receive one consistent snapshot of active workers and shared state.

Operational statistics

The statistics include active worker ranges and job types, current worker positions, worker errors, failed heights with attempt counts, concurrency, the three head values, catch-up status, and service status. These values show whether the node is caught up, processing a range, or waiting for retry time.

The DAS metrics layer exports high-level signals for monitoring. It records sample and header-load durations, successful or failed sample outcomes, head updates, active workers, the latest sample time, total sampled headers, and the lag between the network head and sampled chain head. Head lag is never negative. A caught-up or temporarily ahead sampled head reports zero. Metrics are an observation channel. The checkpoint remains the recovery channel.

The metrics tests verify the head-lag contract for a node that is behind, caught up, ahead, or has no sampled headers.

References: das/stats.go• L3-31 das/metrics.go• L36-145 das/metrics.go• L148-212 das/metrics_test.go• L9-25

External access

The node exposes SamplingStats and WaitCatchUp through the DAS module’s read-only RPC surface. The das sampling-stats command calls the first method and prints its result. Operators can inspect progress without accessing the coordinator directly.

References: nodebuilder/…/das.go• L9-32 nodebuilder/…/das.go• L20-33

Change checklist

When these files or sections are changed, remember to consider these:

  • Changes to the availability contract or its outside-window error must preserve the coordinator’s distinction between a skipped header and a failed sample.
  • Changes to SamplingStats must keep checkpoint creation aligned with the meaning of CatchupHead, SampledChainHead, failed heights, and resumable workers.
  • Changes to worker job types must update both scheduling priority and restart behavior. Only the job types intended for restart should enter checkpoint worker records.
  • Changes to retry timing must preserve the attempt count stored in checkpoints and the rule for heights that exceed the growing backoff range.
  • Changes to head subscription or catch-up cursor movement must prevent a live header from being sampled twice or from moving the cursor past an unsampled height.
  • Changes to DAS configuration must keep validation, node startup wiring, and the rule that zero derives a timeout consistent. Light-node defaults must retain their fixed timeout relationship to block time and worker concurrency.
  • Changes to monitoring fields must preserve the meaning of head lag and keep the metric view consistent with the sampling statistics snapshot.
  • Changes to restart handling must preserve immediate catch-up completion when the checkpoint already covers the current network head.
  • Changes to catch-up completion signaling must preserve safe concurrent waits and allow a completed state to reset when a new head starts another cycle.
  • Changes to worker state snapshots must preserve safe concurrent reads of failed-height data while a worker records results.

Important failure modes

TriggerConsequenceGuard
Header availability returns a real sampling errorThe height enters the failed set and the sampled chain head stops before it.Retry scheduling preserves the height and its attempt count.
Sampling runs outside the availability windowThe header is skipped and does not count as a failed sample.The availability layer returns ErrOutsideSamplingWindow, which workers handle explicitly.
A sample exceeds its per-header timeoutThe availability call is canceled and the height is eligible for retry.Use the ODS-size-derived timeout or set SampleTimeout to a value that fits the node’s sampling method and worker concurrency.
The process stops during catch-upWork after the last durable checkpoint must run again after restart.The background store and shutdown path save checkpoint progress.
A checkpoint already covers the current network headA restart can remain waiting even though no work remains.Startup checks the resumed state and marks catch-up complete before waiting for a new head.
The header store tail advances beyond saved progressOld failed or worker entries no longer describe retained headers.Startup clamps ranges to the current tail and removes obsolete failures.
A non-cancellation subscription read failsNo new head reaches the coordinator during that read.The subscriber logs the error and continues listening.
SamplingRange or ConcurrencyLimit is zero or negativeDAS cannot reserve useful work or complete sampling.Configuration validation rejects these values before startup.
SampleTimeout is negativeDAS cannot create a valid per-header sampling deadline.Configuration validation rejects negative values. Zero selects the ODS-size-derived timeout.
A completion waiter observes a new head while completion state resetsA waiter can miss a completion signal or wait on the wrong cycle.The coordinator protects the completion state and signal together, then creates a fresh signal for the next cycle.
Statistics read a worker’s failed-height map while the worker updates itThe statistics snapshot can race with sampling state updates.Worker snapshots copy the failed-height map under the worker lock.

Key files

FileWhy to read it
das/daser.goDefines the DAS service lifecycle, availability call, checkpoint recovery, and public status methods.
das/coordinator.goShows how workers, results, head updates, and state snapshots are coordinated.
das/worker.goShows the unit of sampling work and how timeout, cancellation, skip, error, and state snapshot results are reported.
das/options.goDefines the sampling range, worker limit, checkpoint interval, and timeout rules.
das/state.goDefines progress heads, job priority, retry state, and catch-up completion.
das/state_catchup_test.goDemonstrates concurrent catch-up waits and repeated completion cycles as new heads arrive.
das/checkpoint.goDefines which sampling state survives a restart.
das/store.goDefines durable and background checkpoint writes.
das/subscriber.goShows how new network headers enter the sampling flow.
das/stats.goDefines the operational status returned to callers and monitoring.
das/metrics.goDefines the monitoring view of sampling progress and head lag.
das/restart_catchup_test.goDemonstrates that a restart with no remaining work reports catch-up completion.
share/availability.goDefines the boundary between DAS coordination and availability validation.
share/…/availability.goIllustrates probabilistic share sampling and its persisted per-header results.
share/…/availability.goIllustrates full data recovery as the alternate availability strategy.
nodebuilder/…/config.goApplies DAS defaults by node type and validates the settings before startup.
nodebuilder/…/das.goDefines the read-only RPC surface for sampling status and catch-up waits.