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-pruning

Data pruning and checkpoints

Data pruning keeps a node within its useful data-retention window while preserving the data needed for availability checks and network recovery. The pruning service follows the header store, removes data that has aged past the selected window, records its progress, and lets nodebuilder choose the right policy for light, pruned bridge, and archival bridge nodes.

Parent: Storage and retention
Related: Blockstore, Header sync, Node configuration

Retention boundaries

Availability windows

The availability windows define how long recent chain data remains locally useful. The sampling window is seven days by default. The request window has the same length. The storage window adds one hour so storage and header retention have a small safety margin. CELESTIA_OVERRIDE_AVAILABILITY_WINDOW can replace the selected window with a valid duration, and the shared resolver applies that value to availability checks and pruning.

The pruning service compares the head header time with the active window. A header becomes a pruning candidate only when its time is at or before that cutoff. A zero window disables the time limit for window checks, but archival header behavior is controlled separately by the nodebuilder mode.

References: share/…/window.go• L12-20 share/…/window.go• L28-53 pruner/find.go• L23-43

Node role retention

Each node role removes a different kind of local data because it has a different availability duty. A light node removes its stored samples and sampling results. A pruned bridge removes the full EDS data for old blocks. An archival bridge keeps old headers and block records, but still trims Q4 data outside the storage window.

Node roleActive pruning windowData removed after the window
LightSampling windowStored samples and sampling results
Pruned bridgeStorage windowFull ODS/Q4 block data
Archival bridgeStorage window for data trimmingQ4 data only; old block records and headers remain

This split lets a node keep the minimum local data needed for its role. Network getters can still recover data that a pruned node no longer stores. See Blockstore for the local and network data path.

References: nodebuilder/…/module.go• L54-79 share/…/availability.go• L186-243 share/…/availability.go• L111-119

Candidate discovery

Prunable header candidates

The candidate finder uses the last successful pruning position and the current header-store head to locate the oldest safe range. It estimates a target height from elapsed time and the configured block time, then checks actual header timestamps so block-time variation cannot move the retention boundary forward too far.

Candidate discovery follows this sequence:

  1. Load the last header that the checkpoint says the service handled.
  2. Set the cutoff to head time minus the active availability window.
  3. Estimate a target height from the elapsed time and expected block time.
  4. Read headers through the target and extend the range until it reaches the time cutoff.
  5. Return only headers at or before the cutoff.

The finder limits one range to 512 headers. The service can process more than one range in a cycle when a node has been offline or changes from archival to pruned mode. A fresh range also includes the genesis header when the pruning position starts at height one.

References: pruner/find.go• L10-20 pruner/find.go• L28-97 pruner/find.go• L100-122

Pruning service

Service schedule

The pruning service is a lifecycle service that starts after the header syncer is available. It runs one pruning round immediately and then waits for the configured interval between later rounds. The default interval is 30 seconds. A node can replace this interval through a pruning option, but a zero interval is invalid.

Each round retries headers that failed in an earlier round before it discovers new candidates. It then removes eligible data in order, advances the progress point after successful work, and stores failed heights for later retry. If every header in a full candidate batch fails, the service ends the current round instead of requesting the same batch again. The next cycle retries the recorded heights. This makes pruning asynchronous: data can remain available for one or more cycles after it first becomes old enough.

References: pruner/params.go• L10-35 pruner/service.go• L42-89 pruner/service.go• L129-150 pruner/service.go• L152-230

Header and data coordination

Header retention and data retention must move together. Before the header store deletes an old header, the pruning service receives a callback and removes the matching data. Header-delete callbacks can arrive out of order, so each callback handles its own height and does not use the checkpoint's last-pruned height as a skip rule.

The resulting lifecycle is:

flowchart LR
    A[Header sync advances] --> B[Header reaches retention cutoff]
    B --> C[Pruning service finds candidates]
    C --> D[Role-specific data removal]
    D --> E[Checkpoint stores progress]
    B --> F[Header store requests deletion]
    F --> G[Per-height data removal]
    G --> H[Header deletion completes]

The shared boundary is important for recovery. A node should not delete the header needed to identify a data item before the data-retention path has had a chance to remove or account for that item. See Header sync for the header-store side of this contract.

References: pruner/service.go• L254-304 nodebuilder/…/constructors.go• L15-27 nodebuilder/…/config.go• L84-104

Checkpoint lifecycle

Progress and retry state

The checkpoint is the durable record of pruning progress. It stores the last pruned height and a set of heights whose data removal failed. The service updates it after candidate batches and again during shutdown.

The last-pruned height is a progress boundary, not a claim that every earlier operation succeeded. Failed heights remain explicit so later rounds can retry them. A failed retry stays recorded when its header cannot be loaded, so the service can try that work again in a later round. A header-delete callback removes a height from the failed set only after that per-height prune succeeds.

References: pruner/checkpoint.go• L14-31 pruner/checkpoint.go• L34-60 pruner/checkpoint.go• L94-128 pruner/service.go• L232-252 pruner/service.go• L254-286

Restart and reset behavior

On startup, the service loads its checkpoint. If no checkpoint exists, it creates one from the current header-store tail. On a normal restart, this preserves progress and failed work instead of scanning all retained headers again. On stop, the service waits for its worker loop to exit before saving the final checkpoint.

Resetting the checkpoint moves the starting point back to the current header-store tail and clears recorded failures. Nodebuilder uses this reset after an archival-to-pruned conversion. Archival mode may have trimmed only Q4 data, so the pruned service must revisit the older range and remove the full data records that a pruned node no longer keeps.

References: pruner/checkpoint.go• L63-91 pruner/service.go• L91-127 nodebuilder/…/module.go• L121-127

Mode migration

Archival and pruned modes

Archival mode is a bridge-node retention mode that keeps the full historical header and block record view. Pruned mode removes data outside the active window. The mode affects the core source, header sync, full availability behavior, and the data advertised to archival peers, so it is a node-wide policy rather than a setting for the pruning service alone.

The supported direction is archival to pruned. The reverse direction is rejected after pruning has run because removed data cannot be restored from the existing store. Starting a new archival node requires re-initialization or another store with the needed history.

References: nodebuilder/…/flags.go• L15-38 nodebuilder/…/module.go• L69-79 nodebuilder/…/constructors.go• L83-97 share/…/utils.go• L19-45

Migration markers

Nodebuilder records the first retention mode in the full-availability datastore. A temporary migration check uses that marker together with the pruning checkpoint to recognize stores created by older versions. It rejects archival startup when the store already shows pruning progress, then records the current mode for later starts.

When the marker says archival and the node starts in pruned mode, the migration code updates the marker and reports a conversion. Nodebuilder then resets the pruning checkpoint so the new policy covers the full old range. This protects against treating archival Q4 trimming as equivalent to full pruned-node deletion.

References: nodebuilder/…/migration_utils.go• L13-58 share/…/utils.go• L19-45 nodebuilder/…/module.go• L98-132

Nodebuilder data-retention configuration

Node-type wiring

Nodebuilder assembles retention behavior from the node type and startup options. The pruning module is part of the common node graph, but it receives a light-specific sampling window or a bridge-specific storage window. It also supplies the role-specific availability component as the operation that removes data.

The --archival flag is valid only for bridge nodes. It disables header pruning, starts header sync from genesis, enables archival behavior in core and full availability, and advertises the node as an archival source. Without the flag, pruning remains enabled by default.

References: nodebuilder/module.go• L23-55 nodebuilder/…/module.go• L22-80 nodebuilder/…/constructors.go• L83-97 nodebuilder/…/flags.go• L24-38

Configuration sources

The main node configuration groups the header, share, core, and availability settings that define the surrounding retention contract. Header defaults use the storage window for both light and bridge nodes, and validation prevents a configured header-pruning window from being shorter than that storage requirement. The pruning service itself uses nodebuilder’s resolved window and keeps its cycle as a service option with a 30-second default.

The availability-window override is the common operational control for shrinking or growing the effective retention boundary. The nodebuilder assembly resolves it when it supplies the pruning window, while runtime availability checks use the same shared resolver. Keep these paths aligned when changing retention policy. See Node configuration for the wider configuration lifecycle.

References: nodebuilder/config.go• L25-50 nodebuilder/…/config.go• L38-57 nodebuilder/…/config.go• L84-104 nodebuilder/…/constructors.go• L18-36 share/…/window.go• L18-53

Blob command input

The blob command provides the user-facing path for submitting data that later enters the retention system. It accepts one namespace and payload or a JSON file with multiple blobs. It sends the resulting blobs through the node RPC service and reports the inclusion height and commitments; this is an ingress path, not a separate retention policy.

The command validates the two input forms before submission. It accepts plain text, decodes 0x-prefixed payloads as hex, and reads - as raw bytes from standard input. These rules keep blob creation consistent before data reaches the block and retention flows. The command tests cover the accepted forms and reject conflicting or malformed input.

References: nodebuilder/…/blob.go• L22-39 nodebuilder/…/blob.go• L115-232 nodebuilder/…/blob_test.go• L24-99 nodebuilder/…/blob_test.go• L101-205

Change checklist

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

  • Keep the sampling, storage, header-pruning, and service windows on the same retention boundary. The shared environment override must affect every consumer that uses the effective window.
  • Keep the node-role mapping aligned with the data removed by each Pruner implementation. A light node must clear sampling state, while a bridge must select full-data or archival trimming behavior.
  • Preserve checkpoint compatibility when changing progress or failed-height fields. Startup, retry, reset, and header-delete handling must agree on the meaning of the last-pruned height.
  • Review batch-stop behavior when changing candidate limits or retry handling. A full batch that makes no progress must end the round so the next cycle can retry recorded heights without repeating the same query.
  • Preserve per-height header-delete handling when changing callback order or concurrency. A callback must prune its own height even when it arrives outside checkpoint order.
  • Review both mode markers and checkpoint migration when changing archival behavior. A store that has run in pruned mode must not become archival without re-initialization.
  • Preserve the header-sync start and pruning-window rules when changing archival configuration. A header store that keeps less history than availability work needs can break later retrieval or sampling.
  • Preserve blob command input contracts when changing submission parsing. File input must remain exclusive with positional input, and raw standard input must not be treated as hex.

Important failure modes

TriggerConsequenceGuard
A configured header-pruning window is shorter than the storage windowAvailability work can lose the header range that identifies data it still needsHeader configuration validation rejects the unsafe window
A pruning operation fails for a candidateThe height remains in the failed set and its data can remain past the retention cutoffRetry failed heights at the start of later rounds
Every candidate in a full batch failsThe round can repeatedly fetch the same batch and fail to make progressStop the round when the last-pruned height does not change; retry the recorded heights in the next cycle
A failed header cannot be loaded during retryThe failed height remains pending and can delay complete retentionKeep the height in the failed set and retry it later
A header-delete callback uses checkpoint order to choose whether to pruneAn out-of-order callback can leave data behindLoad and prune the callback's own height independently
A header-delete callback arrives after the service is closedThe matching data is not pruned through that callbackReject closed-service callbacks and preserve the lifecycle boundary
A pruned store starts with archival modeThe node would claim archival history that pruning may have removedReject the mode change and require re-initialization
An archival store changes to pruned mode without a checkpoint resetOlder full data can remain because archival trimming only removed Q4Reset the checkpoint after the migration marker changes
The prune cycle is configured as zeroThe service cannot create a valid scheduleValidate the cycle as positive and non-zero
Blob input uses both a JSON file and positional argumentsThe command cannot determine one submission formReject the mixed input before the RPC call
Raw standard input is decoded as hexBinary or text payloads can be changed before submissionTreat - as raw bytes and decode only explicit 0x payloads

Key files

FileWhy to read it
pruner/service.goDefines the pruning lifecycle, round order, retries, checkpoint updates, header-delete coordination, and the no-progress stop for a fully failing batch.
pruner/service_test.goShows the service guarantees for time-based discovery, retries, checkpoint persistence, large backlogs, no-progress batches, and out-of-order header deletion.
pruner/find.goDefines the time cutoff and bounded candidate discovery process.
pruner/checkpoint.goDefines durable progress, failed-height state, startup loading, and reset behavior.
pruner/params.goDefines the pruning-cycle default and validation.
share/…/window.goDefines the sampling and storage windows and the shared operational override.
share/…/availability.goShows the difference between pruned full-data removal and archival Q4 trimming.
share/…/availability.goShows which sampling data a light node removes.
nodebuilder/…/module.goConnects node roles, windows, availability implementations, archival mode, and migration.
nodebuilder/…/flags.goDefines the user-facing archival switch and its node-type rule.
nodebuilder/…/migration_utils.goDefines the temporary first-run mode marker used during migration.
nodebuilder/…/config.goDefines the header-retention safety boundary around the storage window.
nodebuilder/…/constructors.goShows how archival mode changes header pruning and sync start behavior.
nodebuilder/config.goDefines the main node configuration that carries the surrounding retention settings.
nodebuilder/…/blob.goDefines the blob submission input boundary that feeds data into the node before retention applies.
nodebuilder/…/blob_test.goShows the supported blob input forms and the validation guarantees for submission.