Node CLI and configuration
The cometbft command surface creates, runs, inspects, repairs, and supports a node. Configuration joins operator choices to the services and local stores that use them. The command layer selects one node home, loads and checks the settings, then passes the result to node assembly. See Node assembly and lifecycle for the service startup and shutdown view.
Command surface
The command surface groups actions by the node's operating life. Setup commands create identity and chain files. Runtime commands start a full node or a verified light-client proxy. Maintenance commands inspect or change local state. Debug commands collect live node data for diagnosis without changing normal node settings.
Node setup commands
The setup commands prepare the files that a node needs before it can join a chain. init creates missing validator and peer identity keys and writes a local genesis file. testnet creates a group of node homes with a shared genesis and optional persistent peer settings. Key commands generate or print validator and node identity data without starting the node.
The main setup commands are:
initprepares one node home.testnetprepares many validator and non-validator homes for a test network.gen-validatorprints a new validator key pair.gen-node-keycreates a node key and prints its peer ID.show-validatorprints the configured validator public key.show-node-idprints the configured peer ID.
References: cmd/…/init.go• L17-80 cmd/…/testnet.go• L79-95 cmd/…/gen_validator.go• L12-29 cmd/…/gen_node_key.go• L12-32 cmd/…/show_validator.go• L13-40 cmd/…/show_node_id.go• L11-26
Node runtime commands
The start command is the full-node entry point. It also accepts node and run as aliases. Before node creation, it can compare a supplied SHA-256 value with the configured genesis file. After the node starts, the command keeps the process alive and stops the node when it receives a termination signal.
The light command serves a proxy that checks responses from a full node with light-client verification. A new light client needs a chain ID, a primary RPC address, and trusted header data. Later runs can restore the saved provider and trusted state from its light-client home.
References: cmd/…/run_node.go• L120-159 cmd/…/run_node.go• L161-186 cmd/…/light.go• L28-54 cmd/…/light.go• L103-199
Node maintenance commands
Maintenance commands operate on local node state and are not part of normal block production. reset-state removes local chain databases and the consensus WAL while keeping validator signing state. unsafe-reset-all also resets the validator to genesis state and removes the address book unless the operator keeps it. unsafe-reset-priv-validator only resets validator files.
rollback moves CometBFT state to a selected height. By default it targets the current height minus one and keeps the last block, so the application can run that block's transactions again. With --hard, it removes the block above the target as well. The command prints the target before its full write check, rejects a target outside the stored range, and blocks rollbacks deeper than 100 heights unless --force is set. The application must roll back to the same height.
reindex-event rebuilds block and transaction event indexes from stored blocks and ABCI responses. It can cover the block store range or a supplied inclusive height range. This repair path needs retained ABCI responses and uses the configured event sink, such as PostgreSQL or the local key-value indexer. replay and replay-console read the consensus WAL for fault analysis. inspect runs a limited server for examining inconsistent local state. version reports the binary version and can include protocol versions.
References: cmd/…/reset.go• L14-78 cmd/…/rollback.go• L18-72 cmd/…/rollback.go• L75-132 cmd/…/reindex_event.go• L33-103 cmd/…/reindex_event.go• L105-131 cmd/…/replay.go• L9-26 cmd/…/inspect.go• L19-33 cmd/…/version.go• L12-43
Node debug commands
The debug command gathers a point-in-time or repeated diagnostic bundle from a running node. debug dump polls RPC status, network, and consensus data, then adds the consensus WAL and optional goroutine and heap profiles. debug kill gathers the same core state plus the node configuration, captures the process stack trace, and then sends an abort signal to the process.
The diagnostic archive is an operator handoff artifact. It can contain the full configuration, including sensitive values such as a PostgreSQL indexer connection string. The archive is therefore created with owner-only permissions, and the collected JSON and profile files use restrictive permissions as well.
The diagnostic flow turns live node state and local files into a protected archive.
flowchart LR
A[Running node] --> B[RPC state]
A --> C[WAL and config files]
A --> D[Optional profiling endpoint]
B --> E[Temporary debug directory]
C --> E
D --> E
E --> F[Owner-only ZIP archive]
debug dump writes timestamped archives at the configured frequency and continues until the command stops. A zero frequency is rejected. Both debug commands use the selected home to locate local configuration and the consensus WAL, while the RPC address identifies the live node.
References: cmd/…/debug.go• L23-40 cmd/…/dump.go• L18-43 cmd/…/dump.go• L45-78 cmd/…/kill.go• L21-95 cmd/…/io.go• L14-25 cmd/…/io.go• L107-117 cmd/…/io_test.go• L11-21
Configuration loading
Configuration loading turns operator input into one Config value for a command. The command framework binds flags and reads a TOML file from the selected home or its config directory. The command layer then chooses the home, applies it to service sections, creates the home structure, validates the values, and reports deprecated settings before the command runs.
Configuration sources
The normal source order is defaults first, then the config file, environment values, and command-line flags. Later sources override earlier sources when they set the same value. The file is normally config/config.toml below the home directory. The default home is $HOME/.cometbft.
The node command uses the CMT environment prefix. For example, CMT_LOG_LEVEL maps to log_level. Dots and dashes in setting names map to underscores. CMTHOME selects the home directory. TMHOME remains accepted as a deprecated home variable, but startup logs a warning when it is used. The --home flag is the command-line home choice when neither home environment variable is set.
References: libs/…/setup.go• L27-55 libs/…/setup.go• L127-146 cmd/…/root.go• L29-64 config/config.go• L96-109
Configuration validation
Validation is a startup gate. It checks the base settings and the service sections that define rules for valid choices, non-negative limits, required relationships, and enabled-feature requirements. A bad setting prevents node creation instead of allowing a partly configured node to run.
Important cross-setting checks include:
- The log format must be
plainorjson. - State sync needs at least two RPC servers plus trusted height, hash, and period.
- Block sync accepts
v0; older protocol values are rejected as deprecated. - The
nopmempool cannot run withconsensus.create_empty_blocks = false. - WebSocket write capacity cannot be less than subscription buffer capacity.
- Profiling needs a profiling server URL when its trace switch is enabled.
- Storage compaction needs a positive compaction interval when compaction is enabled.
- The blockstore memtable size must stay between 0 and 256 MiB.
- External validator gRPC must use all three mutual TLS files when it is reachable beyond loopback, unless the operator explicitly enables the insecure override. Mutual TLS means that both the client and server prove their identity with certificates. Hostnames such as
localhostare not treated as loopback for this safety check. - Validator gRPC TLS files must be either all absent or all present. A partial set is rejected even on loopback and even when the insecure override is enabled.
Deprecated settings do not all stop startup. The command reports their use so operators can move to current names and behavior before a later release removes them.
References: config/config.go• L142-176 config/config.go• L384-466 config/config.go• L999-1050 config/config.go• L1075-1084 config/config.go• L1264-1300 config/config.go• L1348-1355 config/config.go• L1483-1506 config/config_test.go• L75-166
Node home layout
The home directory is the common boundary for node configuration and runtime state. Relative paths resolve from this directory. The command creates the home, config, and data directories and writes a default TOML file when one does not exist.
The default layout separates identity and chain inputs from mutable node data:
| Area | Main purpose |
|---|---|
config/ | Configuration, genesis, validator key, node key, and peer address book. |
data/ | State databases, block data by default, validator sign state, and consensus WAL. |
| External paths | Optional locations for data or block storage when an operator needs separate volumes. |
Absolute paths do not use the home directory. An empty blockstore path falls back to the database directory. The generated TOML file now documents the database backend and blockstore path beside the main database path, so the default file reflects the storage choices that affect node startup and maintenance.
References: config/toml.go• L30-71 config/toml.go• L75-108 config/config.go• L285-302 config/config.go• L313-344
Operator settings
The configuration is split by the node service that consumes each setting. Operators normally change the base, RPC, P2P, consensus, mempool, sync, storage, index, and instrumentation groups. The generated TOML file is the practical guide to operator-visible settings. Some internal or test-only values are intentionally absent from that file.
Base node settings
Base settings connect the node to its application and identify the local chain role. proxy_app names the ABCI application endpoint or an embedded test app. abci selects socket or gRPC transport. Genesis and validator paths define the chain input and signing state. The moniker labels the node to peers and logs.
The base group also selects log level and format. plain is suited to a human terminal. json is suited to log collection. The node key identifies the peer, while the validator key signs consensus votes. These keys have different roles and must not be treated as interchangeable.
An optional validator gRPC endpoint lets an external signer request validator signatures. A loopback-only endpoint may run without TLS. An endpoint reachable beyond loopback needs a server certificate, a server key, and a client CA for mutual TLS, unless the operator accepts the explicit insecure override. A partial certificate, key, or client CA set is invalid in every case. The complete set or no TLS files is required before startup. This protection keeps a network peer from using the validator key as a signing service.
References: config/config.go• L220-283 config/config.go• L285-302 config/config.go• L384-466 config/toml.go• L83-162 cmd/…/run_node.go• L24-50 config/config_test.go• L75-166
RPC settings
RPC settings control how clients query the node and submit transactions. The HTTP RPC listener is local by default. Optional gRPC and pprof listeners provide separate client and diagnostic access. TLS starts only when both certificate and key paths are set.
Operators use connection limits and request limits to bound resource use. max_concurrent_heavy_requests shares one cap across RPC transports for memory-heavy responses, which protects node memory during request bursts. block_search also limits each page to 64 MiB of stored block data before it loads the blocks; clients can request a smaller per_page value when a page is too large, while per_page=1 keeps each block reachable. A higher cap increases request capacity and peak memory use. Subscription and WebSocket buffers trade client tolerance for memory use. These settings also shape browser access and transport protection through CORS, TLS, and the unsafe administrative switch.
References: config/config.go• L366-501 config/config.go• L503-581 config/config.go• L609-611 config/toml.go• L169-297 cmd/…/run_node.go• L52-60
P2P settings
P2P settings control peer reachability and network shape. laddr accepts inbound links. external_address tells other peers where to dial. Seeds help a node find its first peers. Persistent peers are connections the node tries to keep. The address book stores learned peer addresses.
Peer limits affect the normal inbound and outbound pool. Unconditional peers bypass those limits. Peer exchange spreads learned addresses. Seed mode makes a node crawl for addresses and then disconnect after serving them. Private peer IDs prevent selected peers from being gossiped to other nodes.
References: config/config.go• L588-664 config/config.go• L666-689 config/toml.go• L299-370 cmd/…/run_node.go• L61-73
Consensus and block settings
Consensus settings shape how fast the node moves through rounds and heights. Proposal, prevote, and precommit timeouts give the network time to make progress when messages or proposers are slow. The commit timeout controls the normal wait before the next height. These values are network behavior, so validators should use compatible settings.
Empty-block settings decide whether the chain advances without new transactions. With empty blocks enabled, the node can produce blocks at the commit cadence. With them disabled, transactions or an enabled interval drive block creation. A non-zero double-sign check height makes validator restart checks look back before the validator joins consensus.
Consensus also has a legacy pacing switch for disaster recovery. When enabled, it uses configured legacy commit waits instead of the application's dynamic commit timing. This is a local timing choice with network effects, so validators should treat it as a coordinated recovery setting.
References: config/config.go• L1062-1121 config/config.go• L1123-1145 config/config.go• L1167-1170 config/config.go• L1200-1261 config/toml.go• L528-591 docs/…/configuration.md• L501-513
Mempool and transaction settings
The mempool holds transactions that passed the application's check but are not yet in a block. The cat mempool is the normal choice. The nop mode leaves storage, relay, and proposal work to the application and cannot be combined with disabled empty blocks.
Operators can control transaction recheck after a block, gossip to peers, capacity, duplicate filtering, and the optional mempool WAL. These settings affect admission, memory use, and how quickly transactions reach other peers. A persistent-peer gossip bound can also guarantee delivery to a selected number of persistent peers for each signer. It defaults when unset and is not shown in the generated TOML file. These settings do not change the application rules for transaction validity.
References: config/config.go• L753-858 config/config.go• L860-884 config/config.go• L886-954 config/config.go• L987-1013 config/toml.go• L372-468
Sync settings
State sync and block sync provide different ways to reach the current chain state. State sync restores a trusted snapshot and gives the node a shorter history. It needs trusted chain data and enough RPC sources for verification. Block sync uses the supported v0 path to fetch block history.
State sync is intended for a node with no local chain progress. A node operator must choose the trust height, matching trust hash, trust period, RPC sources, chunk limits, and fetch timeouts as one trust and recovery policy.
References: config/config.go• L932-946 config/config.go• L957-965 config/config.go• L973-1024 config/config.go• L1030-1059 config/toml.go• L470-526 docs/…/configuration.md• L353-401
Storage and index settings
Storage settings control what node data remains available after execution and pruning. Keeping ABCI responses supports /block_results queries and event reindexing. Discarding them can reduce disk use but removes those later data sources. Compaction can reclaim space after pruning when the selected database supports it. It runs only when enabled and uses the configured block interval.
The blockstore memory settings shape how large block writes reach the database engine. The memtable size is bounded to protect node memory. A separate GoLevelDB option controls whether large blockstore batches use the journal path instead of waiting on compaction. These settings apply to the blockstore and do not replace the engine defaults used by other stores.
The transaction indexer controls whether transaction search data is kept locally, sent to PostgreSQL, or not indexed. Index choice changes the query surface and storage needs. A search-result cap can limit how many matches a broad tx_search or block_search query may collect; a non-positive value leaves that cap unlimited. The indexer does not change consensus state. The offline reindex-event command uses this choice to rebuild block and transaction event data after an index sink loss or replacement. Its height range must exist in the block store, and the selected sink must be usable.
References: config/config.go• L1277-1328 config/config.go• L1330-1355 config/config.go• L1427-1507 config/toml.go• L593-643 config/db.go• L27-49 config/db_test.go• L29-87 docs/…/configuration.md• L444-475 cmd/…/reindex_event.go• L39-47 cmd/…/reindex_event.go• L105-131 cmd/…/reindex_event.go• L204-240 cmd/…/reindex_event_test.go• L83-128
Database settings
Database settings choose the local storage engine and where each store lives. The default backend is PebbleDB. The database provider maps the configured backend name to its database library and opens a named store at the requested path. The blockstore can use PebbleDB or GoLevelDB-specific write settings, while other stores keep the database engine defaults.
The blockstore can use a separate path from the state database. This supports separate storage volumes, but moving an existing blockstore is an operator migration task. The node does not copy or reconcile old block data when the path changes. State, block, evidence, and transaction index data must remain consistent with the chain state that the node loads.
Maintenance commands use the same configured backend and paths as node startup. In particular, rollback opens the blockstore and state store separately, checks that both stores exist, and applies the configured ABCI-response retention rule. A custom blockstore path therefore affects rollback as well as normal node operation. Its depth guard prevents a write until the operator uses --force for a rollback deeper than 100 heights.
The light command is separate from full-node stores. It uses a Pebble database below its --home-dir to save light-client providers and verification state.
References: config/db.go• L17-49 config/db_test.go• L29-87 config/config.go• L238-249 config/config.go• L333-344 config/toml.go• L98-108 node/setup.go• L111-132 cmd/…/rollback.go• L50-72 cmd/…/rollback.go• L187-214 cmd/…/rollback_test.go• L52-103 cmd/…/light.go• L122-142
Instrumentation settings
Instrumentation settings expose node health and performance data without changing consensus. Prometheus metrics are available only when enabled with a listen address. Trace and profiling settings add optional data paths or external services. These settings also have connection and batch limits that shape their resource use.
The start command exposes the trace push, trace pull, and profiling switches as flags for operational use. Their values still become part of the same validated configuration passed to node assembly.
References: config/config.go• L1368-1485 config/toml.go• L645-701 cmd/…/run_node.go• L95-117 node/setup.go• L85-102
Change checklist
When these files or sections are changed, remember to consider these:
- Keep the home precedence contract aligned across
--home,CMTHOME, deprecatedTMHOME, and theCMT_*setting environment variables. - Keep config struct map keys, generated TOML names, CLI flag names, and Viper key conversion aligned. A mismatch can silently leave a default in effect.
- When a setting changes a path, update every consumer of that store. Blockstore and state storage do not share the same migration behavior.
- When an RPC request limit changes, keep the shared heavy-request behavior and error contract aligned across all RPC transports.
- When a validation rule changes, check both the generated default file and commands that load a custom config such as
testnet. - Keep external validator gRPC exposure checks aligned with the loopback address rules, the complete mutual TLS file set, the partial-TLS rejection, and the explicit insecure override. The override must not make a partial TLS set valid.
- Keep database backend support aligned across node startup, rollback, inspection, replay, and transaction indexing.
- Keep blockstore write tuning aligned with the selected backend. The memtable limit and the GoLevelDB large-batch option must remain safe for blockstore writes while other stores retain engine defaults.
- When changing rollback or reindex command flags, keep the selected home, database paths, store backend, height rules, and retained ABCI response contract aligned with the command behavior.
- Treat changes to validator or node key paths as identity changes. Confirm the related genesis, sign state, address book, and peer records remain associated with the intended node.
- Keep the default TOML template and its coverage rules aligned. Internal, test-only, and deliberately hidden settings must remain explicit exceptions.
- Keep debug archive permissions restrictive when the collected configuration can contain credentials. Preserve the owner-only contract for the archive and state dump files.
- Keep debug collection inputs aligned with the selected home and live RPC address. A mismatch can combine data from different node instances.
- Keep legacy pacing settings aligned with the application timing contract and the generated TOML defaults. Changing one can alter block timing across validators.
- Keep transaction search-result limits aligned with the memory behavior and error contract of every search endpoint.
Important failure modes
| Trigger | Consequence | Guard |
|---|---|---|
CMTHOME points to a different home than the operator expects | The command reads different keys, genesis, and databases. | Resolve home precedence before changing or inspecting node data. |
| A config file uses an unknown or out-of-range value | The command stops before node creation. | Run the root configuration validation and read the reported section. |
| An external validator gRPC listener is reachable beyond loopback without complete mutual TLS | Startup rejects the configuration instead of exposing the validator key to network clients. | Use the full certificate, key, and client CA set, or enable the insecure override only for a controlled setup. |
| Only some validator gRPC TLS files are set | Startup rejects the configuration, including on loopback and when the insecure override is enabled. | Set the server certificate, server key, and client CA together, or leave all three unset. |
blockstore_dir changes without moving existing block data | The node can open a new empty blockstore beside an existing state database. | Stop the node, move the blockstore data, then change the path. |
db_backend differs from the backend used by local data | Database open or maintenance commands can fail. | Use the same backend for startup, rollback, inspection, and index access. |
Rollback targets more than 100 heights without --force | The command refuses to write, which prevents an unexpected deep state change. | Review the printed target and use --force only for a deliberate recovery. |
| Rollback targets a height outside the stored block or state range | The command stops before changing either store. | Select a target within the loaded block base and state height. |
| Rollback uses a state store without the required validator or historical data | The full rollback check fails and leaves store heights unchanged. | Keep the needed state history and run the check before the write. |
reindex-event runs after ABCI responses were discarded | The command cannot rebuild event data for the affected heights. | Keep ABCI responses when event repair or /block_results queries are required. |
reindex-event uses an unavailable height or sink | Reindexing stops without completing the requested range. | Use a valid block-store range and a configured, reachable event sink. |
max_concurrent_heavy_requests is set too high or to unlimited on a memory-limited node | A burst of large RPC responses can exhaust node memory. | Size the limit against spare RAM and the largest response the node serves. |
| A search-result cap is too low for a required broad query | tx_search or block_search returns an error before all matches are collected. | Set the cap for expected query size or leave it unlimited only when memory is controlled. |
unsafe RPC methods are enabled on an exposed listener | Remote clients can call administrative actions. | Keep rpc.unsafe disabled unless the endpoint is tightly protected. |
| State sync has missing or mismatched trust data | Startup rejects state sync or cannot verify the restored state. | Use at least two RPC servers with a trusted height, matching hash, and valid period. |
| Validator key files are reset or replaced on a live chain | The node can sign with a different identity or lose sign protection. | Use unsafe reset commands only for a deliberate testnet or recovery action. |
| A debug archive is shared without checking its contents | Credentials in the copied configuration can be exposed. | Treat debug archives as sensitive and preserve their owner-only permissions. |
| Debug collection uses the wrong home or RPC endpoint | The archive can mix local WAL/config data with state from another node. | Use the target process's home and RPC address for every collection. |
| Storage compaction is enabled with a non-positive interval | Startup rejects the storage configuration. | Set a positive compaction interval before enabling compaction. |
| A blockstore memtable size is negative or above 256 MiB | Startup rejects the storage configuration. | Set blockstore_memtable_size_mb to a value from 0 through 256. |
| Legacy pacing is enabled with timing values that do not match the recovery plan | Block timing can change across validators and reduce network progress. | Treat the switch and its waits as a coordinated recovery setting. |
Key files
| File | Why to read it |
|---|---|
| cmd/…/main.go | Shows the command tree and the default home used by the binary. |
| cmd/…/root.go | Shows how each command gets the final home, configuration, validation, and logger. |
| libs/…/setup.go | Shows config-file search, environment naming, flag binding, and command execution errors. |
| cmd/…/run_node.go | Shows the start command and the operator-facing node flags. |
| cmd/…/init.go | Shows how a node home receives its keys and genesis file. |
| cmd/…/debug.go | Shows the debug command group and its shared RPC address option. |
| cmd/…/dump.go | Shows repeated diagnostic collection from a running node. |
| cmd/…/kill.go | Shows diagnostic collection during process termination. |
| cmd/…/io.go | Shows archive, file-copy, and state-dump file handling, including restrictive permissions. |
| cmd/…/io_test.go | Confirms that debug archives are not group- or world-readable. |
| cmd/…/rollback.go | Shows rollback target selection, depth protection, and database use. |
| cmd/…/reindex_event.go | Shows offline event repair from retained block and ABCI response data. |
| config/config.go | Defines the setting groups, defaults, path rules, validation contract, validator signer exposure rules, RPC response-size limits, and blockstore write limits. |
| config/config_test.go | Guards path resolution, setting validation, and validator signer gRPC exposure behavior, including complete TLS configuration. |
| config/toml.go | Defines home directory creation and the generated TOML shape for operator settings. |
| config/toml_test.go | Shows that generated TOML can be parsed and that visible configuration fields stay covered, with explicit exceptions for hidden values and defaults for older blockstore settings. |
| config/db.go | Defines how a configured backend and path become a named database, including blockstore write settings. |
| config/db_test.go | Confirms blockstore tuning for PebbleDB and GoLevelDB, and confirms that data can be reopened with the configured settings. |
| node/setup.go | Shows how blockstore and state paths enter full-node assembly. |
| docs/…/configuration.md | Gives the operator-oriented TOML reference and guidance for consensus and storage choices. |