Node assembly and lifecycle
A Celestia Core node joins an ABCI application with local chain state, consensus, peer transport, and client services. Its command entrypoints prepare the node home or start a configured node, while the node coordinates recovery, public service, peer participation, and orderly shutdown. See Node CLI and configuration for command use and operator settings.
Node boundary
The node is the top-level service for one network participant. It owns the links between the application, persistent chain data, validator signing, event and transaction indexing, peer communication, and optional RPC and telemetry services.
Configuration inputs
Configuration supplies the choices that shape assembly and startup. The command layer combines defaults with file and command values, assigns one home directory to related services, and validates the result before it creates the node.
The home directory anchors the node's genesis data, keys, address book, databases, block store, and runtime files. Validation also protects service boundaries. For example, state sync needs trusted peer data, and an externally reachable private-validator signer needs mutual TLS unless the operator allows insecure access.
References: config/config.go• L48-61 config/config.go• L85-177 config/config.go• L226-325 config/config.go• L385-466 config/config.go• L512-531 config/config.go• L1062-1153
Service assembly
Node construction creates durable state and the live links around the application. The default provider supplies the node identity, validator signer, application client, genesis source, database provider, and metrics policy. The constructor opens application connections, starts event publication and indexing before replay, builds the execution and recovery services, and then connects those services to the peer switch.
The assembled node covers these system roles:
- Chain state and history preserve application state, blocks, validator evidence, and recovery markers.
- Application links carry consensus, mempool, and query traffic to the ABCI application.
- Execution and transaction services execute blocks, admit transactions, publish events, and support indexed lookup.
- Consensus and recovery services coordinate validator decisions and catch up a node through block sync or state sync.
- Peer services authenticate connections and route reactor messages through shared transport.
- Client and telemetry services expose RPC, metrics, profiling, and tracing when enabled.
References: node/setup.go• L65-82 node/node.go• L304-424 node/node.go• L425-528 node/node.go• L565-609
Reactor set
Reactors are peer-facing workers for one class of node data. The switch gives them common transport, node identity, peer rules, and channels. The standard set supports transactions, blocks, consensus, evidence, peer exchange, state sync, and block propagation.
Construction options can add a reactor or replace a built-in reactor by name. A replacement also changes the channels advertised to peers, so it changes a network-facing contract rather than only local behavior. The node also filters peers that do not support the configured block propagation and CAT mempool modes.
References: node/node.go• L108-145 node/setup.go• L381-481 node/setup.go• L484-522 node/setup.go• L552-570 node/node.go• L1139-1200
Startup flow
Startup moves a constructed node from local recovery to public service and then to peer participation. The node starts the validator signer first, opens client-facing services before peer transport, and starts state sync only after the peer switch is ready.
This diagram shows how the command turns a configured node into a network participant.
flowchart TD
A[Start command] --> B[Create configured node]
B --> C[Load state and genesis data]
C --> D[Connect to ABCI application]
D --> E[Replay and reconcile application state]
E --> F[Assemble reactors and peer switch]
F --> G[Start validator signer]
G --> H[Start RPC and optional telemetry]
H --> I[Listen on P2P transport]
I --> J[Start switch and dial persistent peers]
J --> K{State sync enabled?}
K -- Yes --> L[Restore trusted state]
L --> M[Continue with block sync]
K -- No --> N[Continue with block sync or consensus]
M --> N
Pre-network recovery
Before normal peer work, the node compares stored state with the application through a handshake. The handshake requests application information and replays missing blocks when needed. This lets the node decide whether it can enter consensus or must first catch up through block sync.
State sync is the bootstrap path for a node without local chain state. It restores trusted state, records the matching height and commit, and then hands recovery to block sync. A node with existing local state skips this path.
References: node/node.go• L384-412 node/node.go• L443-489 node/setup.go• L573-626 node/node.go• L693-704
Public services
The node starts the private-validator gRPC signer before other listeners. This makes signer exposure, TLS, certificate loading, and listener errors fail before RPC, metrics, profiling, or P2P service becomes available.
RPC starts before P2P so clients can submit transactions while the node prepares to receive blocks. Metrics, profiling, and tracing remain optional. If a later startup step fails, the signer stops at once because the node never reaches normal shutdown.
References: node/node.go• L612-668 node/node.go• L709-777 node/node.go• L902-1020
Peer services
After public listeners are ready, the node binds its P2P transport and starts the switch. The switch starts its reactors and then dials persistent peers. Node information tells peers the chain identity, node identity, supported channels, RPC address, and transaction-index status.
References: node/node.go• L670-704 node/setup.go• L484-522 node/node.go• L1139-1200
Command entrypoints
The command entrypoints turn operator actions into node lifecycle stages. Initialization prepares a home, while the start command creates and runs the node until a termination signal requests a stop.
Initialization command
The init command prepares a new node home with configuration, keys, and genesis data. It preserves existing validator and node keys when they are present. Otherwise, it creates the local identity and writes the initial chain description.
References: cmd/…/init.go• L17-80 cmd/…/main.go• L14-49
Start command
The start command can verify the configured genesis file against a supplied SHA-256 hash before node creation. It then obtains the node, starts it, records its peer identity, waits for a termination signal, and requests a stop after a successful start.
For command flags and operator settings, follow Node CLI and configuration.
References: cmd/…/run_node.go• L22-118 cmd/…/run_node.go• L120-186
Offline recovery commands
The command entrypoint also provides offline tools for data recovery while the node is stopped. Rollback restores CometBFT state to a selected height and protects deep changes with explicit force approval. Event reindexing rebuilds block and transaction indexes from retained blocks and ABCI responses.
References: cmd/…/rollback.go• L18-133 cmd/…/reindex_event.go• L33-92 cmd/…/reindex_event.go• L105-240
Shutdown flow
Shutdown follows the ownership links created during assembly. It stops event and index services first, then peer reactors and transport, then listeners and external services, and finally telemetry and persistent stores. Each cleanup step logs its own error so one failed close does not block the remaining cleanup.
This diagram shows the service order after the command receives a termination signal.
sequenceDiagram
participant OS as Signal handler
participant N as Node
participant E as Event and index services
participant P as P2P switch and transport
participant X as RPC and external services
participant S as Telemetry and stores
OS->>N: Stop()
N->>E: Stop event bus and indexer
N->>P: Stop switch and transport
N->>X: Close listeners and signing services
N->>S: Stop telemetry and close stores
N-->>OS: Return from stop callback
Service state
The node uses a shared service lifecycle with running, stopped, and quit states. A failed start cleans up resources that opened before the failure. A normal stop performs cleanup once and closes the quit signal, while the command remains responsible for waiting on the process lifecycle.
References: libs/…/service.go• L23-69 libs/…/service.go• L127-190 cmd/…/run_node.go• L137-153 node/node.go• L612-706
Resource closure
Normal shutdown drains in-flight private-validator gRPC calls. Failed startup uses immediate signer stop instead, because waiting for a client call could prevent the failed start from returning. RPC listeners, telemetry servers, tracing, profiling, the block store, the state store, and the evidence store then close in the node's cleanup sequence.
References: node/node.go• L764-865
Change checklist
When these files or sections are changed, remember to consider these:
- Keep application connections, event publication, indexing, and handshake replay in an order that preserves recovered events.
- When adding or replacing a reactor, update switch registration, advertised channels, and peer compatibility together. This also applies to block propagation and CAT mempool modes.
- Keep state-sync markers aligned with the restored height, commit, and block-sync handoff.
- For each new listener or long-lived service, define both its startup dependency and its shutdown position.
- Keep private-validator signer exposure rules aligned across validation, TLS loading, listener startup, and failed-start cleanup.
- Use immediate signer stop for startup failure and graceful signer stop for normal shutdown.
- Keep genesis verification in the start command before node creation.
- Keep rollback targets and event-reindex ranges within the data retained by the stores.
Important failure modes
| Trigger | Consequence | Guard |
|---|---|---|
| Application handshake fails | The node does not become ready for peer operation. | Complete application recovery before normal startup. |
| Private-validator gRPC settings are incomplete or unsafe | Startup refuses to open the signer. | Validate complete TLS credentials and endpoint exposure before listening. |
| A later startup step fails after the signer opens | The failed node can leave the signer port or open calls behind. | Stop the signer immediately on failed start. |
| RPC, signer, or P2P address cannot open | Startup returns an error and the process reports a failed start. | Check each listener and transport result during startup. |
| State sync cannot switch to block sync | The node restores state but cannot continue chain recovery. | Require a compatible block-sync reactor and preserve synced state markers. |
| Block propagation and legacy propagation are both disabled | Node assembly fails before the node can start. | Keep one block propagation path enabled. |
| A peer lacks the required block propagation or CAT mempool channels | The peer is rejected by the transport filters. | Keep local reactor modes and peer capabilities compatible. |
| A service or store close fails | Shutdown logs the error and continues with later cleanup. | Keep cleanup steps independent and inspect shutdown logs. |
| A consensus panic occurs | The node exits after requesting full shutdown. | Use the consensus panic callback to stop the node before process exit. |
Key files
| File | Why to read it |
|---|---|
| node/node.go | Shows node assembly, startup order, listener setup, reactor wiring, and shutdown order. |
| node/setup.go | Shows the default provider and high-level construction of node dependencies. |
| cmd/…/main.go | Shows command registration and the binary's default entrypoint. |
| cmd/…/run_node.go | Shows start-time checks, signal handling, and the command wait loop. |
| cmd/…/init.go | Shows how a new node home receives keys and genesis data. |
| config/config.go | Defines defaults, shared root paths, service settings, and startup validation. |
| libs/…/service.go | Defines the shared start, stop, reset, and quit lifecycle. |