Introducing a new way to review your PRs.

Read the announcement

near / nearcore

Reference client for NEAR Protocol

View on GitHub

20 documents · Updated Nov 23, 2026

docs / operations-and-observability

Operations and observability

nearcore provides the operational surface for starting a node, exposing its state, changing safe settings, and finding faults without changing protocol data. Operators combine persistent node configuration with live log and trace controls, HTTP status and metrics endpoints, telemetry reports, local debug tools, and database maintenance. See Telemetry and node observability for the detailed telemetry and monitoring model.

Node lifecycle

The neard command is the main operator entry point. It prepares the process, selects a node home, loads the chain and node configuration, and then runs either a live node or an offline support command (neard/…/main.rs• L47-81, neard/…/cli.rs• L58-177). The same command family supports local setup, configuration checks, database inspection, state viewing, replay, and recovery work.

The live lifecycle is:

flowchart LR
    A[Prepare host] --> B[Load config and keys]
    B --> C[Validate chain and node role]
    C --> D[Start node services]
    D --> E[Serve RPC status metrics and debug data]
    E --> F{Signal or node stop}
    F -->|SIGHUP| G[Reload live settings]
    G --> E
    F -->|SIGINT SIGTERM| H[Stop services and flush data]
    F -->|Epoch sync reset| I[Restart with reset marker]
    F -->|Epoch change| J[Refresh state dump]
    J --> E

The process sets a high file-descriptor limit before it starts. On Linux it also checks network kernel settings and warns when they do not match the values needed for node network performance (neard/…/main.rs• L62-79, neard/…/cli.rs• L999-1061). A production operator should treat these warnings as host readiness signals.

References: neard/…/main.rs• L47-81 neard/…/cli.rs• L58-177 neard/…/cli.rs• L491-655 neard/…/cli.rs• L999-1061

Configuration surface

The node home is the working boundary for configuration, keys, chain data, and live control files. The main config.json describes the node role and its network, consensus, storage, RPC, state sync, garbage collection, and telemetry behavior. neard init creates the files for a chain or downloads approved chain and node settings (nearcore/…/config.rs• L105-110, nearcore/…/config.rs• L223-242, neard/…/cli.rs• L314-440).

Configuration is read as JSON with comments and is checked for both file errors and unsafe combinations. The loader warns about deprecated keys and unrecognized fields, while semantic validation reports invalid settings before the node uses them (nearcore/…/config.rs• L558-607, nearcore/…/config.rs• L609-651, nearcore/…/config_validate.rs• L13-35). Use neard validate-config before a planned restart or after editing the file (neard/…/cli.rs• L985-997).

The main operational choices are:

AreaPurpose
Node roleSelect validator, RPC, archival, or a local development profile through keys, shard tracking, and archive settings.
Network and RPCSet peer bootstrapping, listening addresses, RPC access, request limits, and an optional separate metrics address.
Storage lifetimeControl archive mode, garbage collection, snapshots, cold storage, and cloud archive behavior.
Sync and consensusSet peer and timing thresholds that affect startup, catch-up, block production, and chunk processing.
TelemetrySelect reporting endpoints and the interval for node health data.

Persistent settings are not all live settings. A change to an unsupported field can be ignored during a live reload, but the same file is checked on the next startup. Treat config.json as a restart contract even when only one live field changes (core/…/README.md• L30-51). When cloud archival writing is enabled, the runtime derives the state-dump settings from that archival configuration; otherwise it uses the explicit or default state-sync settings (nearcore/…/config.rs• L697-708).

Build features also shape the available operational surface. The default nearcore build includes JSON-RPC and Rosetta RPC, while diagnostic features can add IO tracing, RPC probing, transaction generation, or test instrumentation (nearcore/Cargo.toml• L95-151).

Configuration duration values use the standard duration serialization form. A regression check builds a fully populated Config and rejects the runtime duration tuple format, which keeps the operator-facing JSON contract stable even though node runtime code uses its own duration type (nearcore/…/config_duration_test.rs• L15-24, nearcore/…/config_duration_test.rs• L29-87).

References: nearcore/…/config.rs• L105-110 nearcore/…/config.rs• L223-361 nearcore/…/config.rs• L558-708 nearcore/…/config_validate.rs• L37-169 neard/…/cli.rs• L314-440 core/…/README.md• L30-51 nearcore/Cargo.toml• L95-151 nearcore/…/config_duration_test.rs• L15-24 nearcore/…/config_duration_test.rs• L29-87

Runtime configuration

Runtime configuration lets an operator change a small set of node controls without restarting the process. The node reads log_config.json and the live subset of config.json when it starts and again after SIGHUP; the loader sends accepted values to the running services (nearcore/…/dyn_config.rs• L10-75, neard/…/cli.rs• L602-627).

The live set covers shutdown height, selected block and chunk timing values, resharding controls, and the validator key state. Log and trace filters are handled with the same reload event. Removing log_config.json returns logging and OpenTelemetry filtering to the startup defaults (core/…/README.md• L7-28, core/…/reload.rs• L83-105). A valid reload can also hot-load or remove the configured validator key without restarting the node (nearcore/…/dyn_config.rs• L119-136).

Use this path for controlled diagnosis or an orderly shutdown. Do not use it as a general configuration editor. A missing log file is treated as a request to use defaults, but a malformed log file, invalid node configuration, or unreadable validator key is reported as a reload error. The node marks dynamic configuration as incorrect so an operator can fix it before the next restart (nearcore/…/dyn_config.rs• L16-59, nearcore/…/dyn_config.rs• L79-136).

References: nearcore/…/dyn_config.rs• L10-136 core/…/README.md• L7-51 core/…/reload.rs• L83-173 neard/…/cli.rs• L619-645

HTTP operations interface

The node exposes an HTTP interface for client access and operations. The main server provides JSON-RPC plus lightweight endpoints for health, status, network information, Prometheus metrics, and the OpenAPI description. Operators can bind metrics to a second address when they need stricter access control for RPC traffic (chain/…/lib.rs• L172-190, chain/…/lib.rs• L3138-3213, chain/…/lib.rs• L3215-3289).

The health endpoint answers whether the node can serve a health check and returns an HTTP service-unavailable status when the node cannot. It reports failure while the node is syncing or when no new block has arrived within the configured health delay. The status endpoint exposes the latest executed chain progress, build identity, node identity, validator state, and sync information; on Spice chains it reports the latest executed ancestor rather than an unexecuted consensus head (chain/…/lib.rs• L1182-1220, chain/…/lib.rs• L1221-1284, chain/…/client_actor.rs• L795-938). The optional debug RPC surface adds detailed sync, block, epoch, validator, peer, snapshot, split-storage, and actor activity views (chain/…/lib.rs• L1221-1284).

Status and health use the latest executed block as their chain progress point on Spice chains. Because consensus can advance before execution completes, the reported state root comes from the last certified state instead of the placeholder root in a consensus header. This keeps operator checks tied to usable chain state rather than to an unexecuted head (chain/…/client_actor.rs• L804-828).

Request processing records count, latency, timeout, and error metrics by RPC method. This makes the HTTP surface useful both for direct diagnosis and for a Prometheus scrape (chain/…/lib.rs• L532-553, chain/…/metrics.rs• L5-66).

References: chain/…/lib.rs• L172-190 chain/…/lib.rs• L1182-1284 chain/…/lib.rs• L3036-3061 chain/…/lib.rs• L3138-3289 chain/…/metrics.rs• L5-66 chain/…/client_actor.rs• L795-980

Logging and tracing

nearcore uses structured events and spans to explain node work. Logs go to the process output, while spans can also go to an OpenTelemetry collector. Filters can select a broad level or a narrow target such as a node subsystem, which lets an operator increase signal without enabling all verbose output (core/…/README.md• L1-10, core/…/subscriber.rs• L184-245).

The command line selects initial trace behavior. The live log file then controls stdout logging, OpenTelemetry filtering, and expensive metrics. OpenTelemetry records chain, node, and validator identity as resource data, so traces from several nodes can be separated in a shared backend (core/…/log_config.rs• L5-25, core/…/opentelemetry.rs• L23-69).

For local or focused database diagnosis, an IO trace records database access patterns and cache activity. It is a high-volume diagnostic record rather than a time measure; use metrics or execution spans for timing. Enable it only for a bounded investigation because the output can grow quickly (core/…/subscriber.rs• L149-169, docs/…/io_trace.md• L3-29).

The trace path is:

flowchart LR
    A[Node events and spans] --> B[Structured log layer]
    A --> C[OpenTelemetry layer]
    A --> D[Optional IO trace layer]
    B --> E[Process output]
    C --> F[Collector and trace store]
    D --> G[Local trace file]

References: core/…/README.md• L1-10 core/…/subscriber.rs• L184-296 core/…/log_config.rs• L5-25 core/…/opentelemetry.rs• L23-79 docs/…/io_trace.md• L3-29

Debugging tools

The debug surface combines node-side debug RPCs with a browser UI. When debug RPC is enabled, the UI can inspect recent blocks, peers, epochs, sync progress, chain processing, validator state, snapshots, actors, and selected internal entities (chain/…/lib.rs• L3192-3207, tools/…/App.tsx• L19-72). It is intended for diagnosis, not for the normal public request path.

Entity queries provide a read view of stored chain and state data for focused diagnosis. They can use hot storage or request cold storage explicitly. A cold query fails with a named storage-column error when the requested data is not retained there, which tells the operator to use the hot store or a different diagnostic view (nearcore/…/entity_debug.rs• L54-64, nearcore/…/entity_debug.rs• L623-641).

The UI reads the node's status and debug endpoints over HTTP. In a browser deployment it can use a proxy, while local development can connect directly to the node address. A separate read-only entity query server also exists for cases where an operator needs database-backed inspection without the full node RPC service (tools/…/README.md• L3-24, tools/…/api.tsx• L440-600, chain/…/lib.rs• L3292-3308).

Offline neard commands support recovery and analysis around the live node. State viewing, database commands, block undo, replay, state parts, flat storage, cold storage, and cloud archive tools let an engineer inspect or repair local data while keeping the live operational path separate (neard/…/cli.rs• L119-166, neard/…/cli.rs• L225-282).

References: chain/…/lib.rs• L1221-1284 chain/…/lib.rs• L3192-3207 chain/…/lib.rs• L3292-3308 nearcore/…/entity_debug.rs• L54-64 nearcore/…/entity_debug.rs• L623-641 tools/…/README.md• L3-24 tools/…/App.tsx• L19-72 tools/…/api.tsx• L488-600 neard/…/cli.rs• L119-166

Storage maintenance

Storage maintenance keeps a node's local history within its intended role and makes recovery paths explicit. Non-archival nodes use garbage collection to remove old data, while archival and split-storage modes preserve a wider history and can move older data to cold or cloud-backed storage. Running nodes always enable state snapshots so they can serve state parts; cloud archival can set a snapshot cadence (nearcore/…/config.rs• L264-287, nearcore/…/config.rs• L697-708, nearcore/…/config.rs• L943-970).

When configured, the state dump service publishes state-sync headers and parts for tracked shards to external storage. It checks the current epoch, skips headers and parts that already exist, limits concurrent state-part work, retries temporary generation or upload errors, and records progress so a restart can resume the work. It also rechecks external storage during an active dump, so work uploaded by another node is not repeated (nearcore/…/state_sync.rs• L54-110, nearcore/…/state_sync.rs• L133-167, nearcore/…/state_sync.rs• L460-555, nearcore/…/state_sync.rs• L587-607, nearcore/…/state_sync.rs• L791-839, nearcore/…/state_sync.rs• L866-875). The dump cadence can select every epoch or a wider interval, while resharding epochs are always included (nearcore/…/state_sync.rs• L925-946). A new epoch cancels an older in-progress dump so the service can prioritize the latest state (nearcore/…/state_sync.rs• L878-923).

Garbage collection must reclaim data faster than the chain creates it. Configuration validation rejects a rate that can fall permanently behind block production and warns when the rate has too little headroom for forks or restarts (nearcore/…/config_validate.rs• L89-169). Archive, cold-store, cloud-archive, and state-sync choices are checked as a group because a mismatch can prevent data retention or recovery (nearcore/…/config_validate.rs• L219-339).

An epoch-sync data reset is a controlled recovery action. The node writes a durable marker before shutdown, then removes the hot data directory on the next startup for non-archival nodes. Archival nodes ignore the marker to prevent accidental history loss (neard/…/cli.rs• L631-691).

References: nearcore/…/config.rs• L264-287 nearcore/…/config.rs• L697-708 nearcore/…/config.rs• L943-1013 nearcore/…/state_sync.rs• L54-110 nearcore/…/state_sync.rs• L133-167 nearcore/…/state_sync.rs• L460-555 nearcore/…/state_sync.rs• L587-607 nearcore/…/state_sync.rs• L791-839 nearcore/…/state_sync.rs• L866-875 nearcore/…/state_sync.rs• L878-946 nearcore/…/config_validate.rs• L89-169 nearcore/…/config_validate.rs• L219-339 neard/…/cli.rs• L631-719

Database migration

Database migration keeps stored node data usable when a new release changes its on-disk contract. At startup, the migrator accepts only supported older versions and applies the required upgrades to hot storage and, when present, cold storage (nearcore/…/migrations.rs• L34-85, nearcore/…/lib.rs• L98-112).

The migration path protects live data during structural changes. It can move retained block headers to cold storage, refresh epoch-sync data, verify headers before removing redundant hot copies, rewrite historical light-client rows into a versioned form, and clear obsolete data. Snapshot databases and empty or genesis-only chains skip chain-dependent work because they do not contain the data that those steps need (nearcore/…/migrations.rs• L87-138, nearcore/…/migrations.rs• L353-409, nearcore/…/migrations.rs• L411-459).

Migration progress and failures are reported through the migrations log target. A row with no known historical format is rejected rather than guessed, so the operator gets a precise failure instead of silent data conversion (nearcore/…/migrations.rs• L316-350). Storage opening also reports hot/cold mismatches, unsupported database versions, and interrupted migration snapshots with recovery guidance (nearcore/…/lib.rs• L113-196).

References: nearcore/…/migrations.rs• L34-85 nearcore/…/migrations.rs• L87-138 nearcore/…/migrations.rs• L316-367 nearcore/…/migrations.rs• L353-409 nearcore/…/migrations.rs• L411-459 nearcore/…/lib.rs• L98-196

The Telemetry and node observability page explains the data sent outside the node and the signals used to assess node health. Read it after this page when you need the metric, trace, and telemetry view rather than the wider operator lifecycle.

The Node startup and lifecycle page gives the focused startup and shutdown model. Storage and state explains local data lifetime, while State sync and state parts covers the state transfer model that the state dump service supports.

References: chain/…/lib.rs• L15-30 chain/…/README.md• L1-10 core/…/README.md• L1-10 nearcore/…/state_sync.rs• L54-110

Change checklist

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

  • Keep the live-field list in nearcore/…/dyn_config.rs aligned with the documented dynamic configuration contract and the client fields that consume it.
  • Preserve the SIGHUP path across config loading, log filter reload, client updates, and validator-key updates. A break in one stage can leave the node running with only part of the requested change.
  • Keep /health, /status, /metrics, and debug RPC behavior aligned with the debug UI fetch paths and with any external scrape or load-balancer checks.
  • Treat metric names and labels as external query contracts. Changes can break dashboards and alerts even when the Rust code still compiles.
  • Recheck archive, trie-change, outcome, cold-store, cloud-archive, and state-sync validation together. These settings describe one data-retention contract.
  • Keep cloud-archival-derived state-sync settings aligned with the explicit state-sync configuration path. A change can alter dump behavior without an obvious change to the node role.
  • Keep trace resource identity stable across chain_id, node_id, account_id, and service.name so multi-node trace queries still separate nodes.
  • Preserve standard duration serialization for every configuration duration field. A new runtime duration field can silently change the operator-facing JSON contract if it is not given the shared serializer.
  • Keep deprecated configuration aliases and warning mappings aligned with the fields that still deserialize. Removing an alias without a clear migration path can make an existing node fail to reload.
  • Keep database version gates and migration arms ordered. A new on-disk column or row shape must have a safe path from every supported older version.
  • Keep migration behavior aligned across hot storage, cold storage, and state snapshots. A chain-dependent step must not assume data that a snapshot or empty database does not contain.
  • Keep historical light-client row readers aligned with every released row shape. Reject unknown or ambiguous data instead of converting it by guesswork.
  • Keep state-dump progress, external object names, and state-part counts aligned. A mismatch can cause a resumed dump to skip needed parts or repeat completed work.
  • Keep entity debug query names aligned with hot and cold storage availability. A new query can work on a live node but fail for operators who rely on cold storage.
  • Keep the status contract tied to the latest executed block on Spice chains. Changes to head selection or certified state-root reporting can make health checks describe consensus progress that the node has not executed.

Important failure modes

TriggerConsequenceGuard
Garbage collection cannot keep up with block productionThe storage tail grows without bound.Configuration validation rejects an unsafe rate and warns when headroom is low.
cloud_archival sets both writer and reader, or neitherThe node cannot select one valid cloud archive role.Configuration validation requires exactly one role.
Cold storage is enabled without saved trie changesCold data cannot be maintained correctly.Configuration validation rejects the combination.
A dynamic config file is malformed or semantically invalidThe requested live update is not applied and the next restart may fail.The loader reports errors and sets the configuration health metric to incorrect.
The configured validator key cannot be read during reloadThe key state is not updated and dynamic configuration is marked incorrect.Fix the key file or its permissions before the next reload or restart.
The database version is below the minimum supported versionStartup cannot safely open or upgrade the node data.The migrator rejects unsupported versions; use a supported upgrade path.
A stored light-client row matches no known historical layout, or matches layouts with different valuesDatabase migration stops instead of risking silent data corruption.The migration reports the affected epoch and requires recovery of the stored data.
Debug RPC is disabledThe debug UI and detailed debug endpoints return no usable node view.Enable the debug RPC surface only for a controlled diagnostic window.
The node is syncing or has not produced a recent blockThe health endpoint returns service unavailable even when the HTTP server responds.Use the status response to distinguish sync state from a stalled chain before restarting the node.
The Prometheus address is the same as the RPC addressNo second monitoring server is started.Configure a distinct metrics address when access separation is required.
Trace or IO-trace verbosity is too broadLog volume, trace ingest, or disk use can grow quickly.Use narrow target filters and bound IO-trace collection.
A cold entity query targets a column not stored in cold storageThe query returns an internal error instead of the requested data.Run the query against hot storage or confirm cold-column coverage first.
External state storage is unavailable during a state dumpHeaders or parts remain incomplete and the dump keeps retrying.Check state_sync_dump logs and metrics, then restore storage access or credentials.
State dump configuration tracks no shardsThe node completes no useful state dump for the epoch.Align shard tracking with the shards that consumers need.
A running node opens a store written by a cloud-archive readerNode startup stops before actors can use the store.Use the cloud-archive tool for that store or point the node to a writable node store.
A Spice node reports the consensus head before execution completesHealth and status consumers can see a block or state root that is not usable by the node.Derive status from the latest executed ancestor and its certified state root.

Key files

FileWhy to read it
neard/…/main.rsShows host preparation and the process entry point.
neard/…/cli.rsShows the lifecycle, operator commands, signal handling, and debug options.
nearcore/Cargo.tomlShows build features that enable or remove operational surfaces.
nearcore/…/config.rsDefines the node's persistent operational contract and how it becomes runtime state.
nearcore/…/config_validate.rsShows the safety checks for storage, sync, archive, and timing settings.
nearcore/…/config_duration_test.rsProtects the stable duration format used in configuration JSON.
nearcore/…/dyn_config.rsShows which settings, log controls, and validator keys can change during a live run.
nearcore/…/lib.rsShows storage opening, migration handling, service startup, snapshots, archival actors, and operational endpoints.
nearcore/…/migrations.rsShows the supported database upgrade path and the safeguards around stored data changes.
core/…/lib.rsShows how accepted live settings reach node services.
core/…/subscriber.rsShows the common log, trace, and optional IO-trace output paths.
core/…/reload.rsShows how log, trace, and expensive-metric settings reload.
chain/…/lib.rsShows the operational HTTP endpoints and debug RPC surface.
chain/…/client_actor.rsDefines the status and network views used by health checks and node diagnosis.
chain/…/metrics.rsShows the main RPC health and performance signals.
nearcore/…/entity_debug.rsShows the read-only entity queries used for focused hot and cold storage diagnosis.
nearcore/…/state_sync.rsShows how configured state-sync data is prepared, resumed, uploaded, and observed.
tools/…/App.tsxShows the operator views available through the browser debug tool.
tools/…/api.tsxShows the node status and debug data consumed by the UI.
chain/…/lib.rsShows how configured node reports are scheduled and sent.