Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( ErrHeightNotAvailable = errors.New("height is not available") ErrInvalidRequest = errors.New("invalid request") )
var CompactGoLevelDBCmd = &cobra.Command{ Use: "experimental-compact-goleveldb", Aliases: []string{"experimental_compact_goleveldb"}, Short: "force compacts the CometBFT storage engine (only GoLevelDB supported)", Long: ` This is a temporary utility command that performs a force compaction on the state and blockstores to reduce disk space for a pruning node. This should only be run once the node has stopped. This command will likely be omitted in the future after the planned refactor to the storage engine. Currently, only GoLevelDB is supported. `, RunE: func(cmd *cobra.Command, args []string) error { if config.DBBackend != "goleveldb" { return errors.New("compaction is currently only supported with goleveldb") } compactGoLevelDBs(config.RootDir, logger) return nil }, }
var GenNodeKeyCmd = &cobra.Command{ Use: "gen-node-key", Aliases: []string{"gen_node_key"}, Short: "Generate a node key for this node and print its ID", RunE: genNodeKey, }
GenNodeKeyCmd allows the generation of a node key. It prints node's ID to the standard output.
var GenValidatorCmd = &cobra.Command{ Use: "gen-validator", Aliases: []string{"gen_validator"}, Short: "Generate new validator keypair", Run: genValidator, }
GenValidatorCmd allows the generation of a keypair for a validator.
var InitFilesCmd = &cobra.Command{
Use: "init",
Short: "Initialize CometBFT",
RunE: initFiles,
}
InitFilesCmd initializes a fresh CometBFT instance.
var LightCmd = &cobra.Command{ Use: "light [chainID]", Short: "Run a light client proxy server, verifying CometBFT rpc", Long: `Run a light client proxy server, verifying CometBFT rpc. All calls that can be tracked back to a block header by a proof will be verified before passing them back to the caller. Other than that, it will present the same interface as a full CometBFT node. Furthermore to the chainID, a fresh instance of a light client will need a primary RPC address, a trusted hash and height and witness RPC addresses (if not using sequential verification). To restart the node, thereafter only the chainID is required. When /abci_query is called, the Merkle key path format is: /{store name}/{key} Please verify with your application that this Merkle key format is used (true for applications built w/ Cosmos SDK). `, RunE: runProxy, Args: cobra.ExactArgs(1), Example: `light cosmoshub-3 -p http://52.57.29.196:26657 -w http://public-seed-node.cosmoshub.certus.one:26657 --height 962118 --hash 28B97BE9F6DE51AC69F70E0B7BFD7E5C9CD1A595B7DC31AFF27C50D4948020CD`, }
LightCmd represents the base command when called without any subcommands
var ProbeUpnpCmd = &cobra.Command{ Use: "probe-upnp", Aliases: []string{"probe_upnp"}, Short: "Test UPnP functionality", RunE: probeUpnp, }
ProbeUpnpCmd adds capabilities to test the UPnP functionality.
var ReIndexEventCmd = &cobra.Command{ Use: "reindex-event", Aliases: []string{"reindex_event"}, Short: "reindex events to the event store backends", Long: ` reindex-event is an offline tooling to re-index block and tx events to the eventsinks, you can run this command when the event store backend dropped/disconnected or you want to replace the backend. The default start-height is 0, meaning the tooling will start reindex from the base block height(inclusive); and the default end-height is 0, meaning the tooling will reindex until the latest block height(inclusive). User can omit either or both arguments. Note: This operation requires ABCI Responses. Do not set DiscardABCIResponses to true if you want to use this command. `, Example: ` cometbft reindex-event cometbft reindex-event --start-height 2 cometbft reindex-event --end-height 10 cometbft reindex-event --start-height 2 --end-height 10 `, Run: func(cmd *cobra.Command, args []string) { bs, ss, err := loadStateAndBlockStore(config) if err != nil { fmt.Println(reindexFailed, err) return } if err := checkValidHeight(bs); err != nil { fmt.Println(reindexFailed, err) return } bi, ti, err := loadEventSinks(config) if err != nil { fmt.Println(reindexFailed, err) return } riArgs := eventReIndexArgs{ startHeight: startHeight, endHeight: endHeight, blockIndexer: bi, txIndexer: ti, blockStore: bs, stateStore: ss, } if err := eventReIndex(cmd, riArgs); err != nil { panic(fmt.Errorf("%s: %w", reindexFailed, err)) } fmt.Println("event re-index finished") }, }
ReIndexEventCmd constructs a command to re-index events in a block height interval.
var ReplayCmd = &cobra.Command{ Use: "replay", Short: "Replay messages from WAL", Run: func(cmd *cobra.Command, args []string) { consensus.RunReplayFile(config.BaseConfig, config.Consensus, false) }, }
ReplayCmd allows replaying of messages from the WAL.
var ReplayConsoleCmd = &cobra.Command{ Use: "replay-console", Aliases: []string{"replay_console"}, Short: "Replay messages from WAL in a console", Run: func(cmd *cobra.Command, args []string) { consensus.RunReplayFile(config.BaseConfig, config.Consensus, true) }, }
ReplayConsoleCmd allows replaying of messages from the WAL in a console.
var ResetAllCmd = &cobra.Command{ Use: "unsafe-reset-all", Aliases: []string{"unsafe_reset_all"}, Short: "(unsafe) Remove all the data and WAL, reset this node's validator to genesis state", RunE: resetAllCmd, }
ResetAllCmd removes the database of this CometBFT core instance.
var ResetPrivValidatorCmd = &cobra.Command{ Use: "unsafe-reset-priv-validator", Aliases: []string{"unsafe_reset_priv_validator"}, Short: "(unsafe) Reset this node's validator to genesis state", RunE: resetPrivValidator, }
ResetPrivValidatorCmd resets the private validator files.
var ResetStateCmd = &cobra.Command{ Use: "reset-state", Aliases: []string{"reset_state"}, Short: "Remove all the data and WAL", RunE: func(cmd *cobra.Command, args []string) (err error) { config, err = ParseConfig(cmd) if err != nil { return err } return resetState(config.DBDir(), logger) }, }
ResetStateCmd removes the database of the specified CometBFT core instance.
var RollbackStateCmd = &cobra.Command{ Use: "rollback", Short: "rollback CometBFT state by one height", Long: ` A state rollback is performed to recover from an incorrect application state transition, when CometBFT has persisted an incorrect app hash and is thus unable to make progress. Rollback overwrites a state at height n with the state at height n - 1. The application should also roll back to height n - 1. If the --hard flag is not used, no blocks will be removed so upon restarting CometBFT the transactions in block n will be re-executed against the application. Using --hard will also remove block n. This can be done multiple times. `, RunE: func(cmd *cobra.Command, args []string) error { height, hash, err := RollbackState(config, removeBlock) if err != nil { return fmt.Errorf("failed to rollback state: %w", err) } if removeBlock { fmt.Printf("Rolled back both state and block to height %d and hash %X\n", height, hash) } else { fmt.Printf("Rolled back state to height %d and hash %X\n", height, hash) } return nil }, }
var RootCmd = &cobra.Command{ Use: "cometbft", Short: "BFT state machine replication for applications in any programming languages", PersistentPreRunE: func(cmd *cobra.Command, args []string) (err error) { if cmd.Name() == VersionCmd.Name() { return nil } config, err = ParseConfig(cmd) if err != nil { return err } if config.LogFormat == cfg.LogFormatJSON { logger = log.NewTMJSONLogger(log.NewSyncWriter(os.Stdout)) } logger, err = cmtflags.ParseLogLevel(config.LogLevel, logger, cfg.DefaultLogLevel) if err != nil { return err } if viper.GetBool(cli.TraceFlag) { logger = log.NewTracingLogger(logger) } logger = logger.With("module", "main") return nil }, }
RootCmd is the root command for CometBFT core.
var ShowNodeIDCmd = &cobra.Command{ Use: "show-node-id", Aliases: []string{"show_node_id"}, Short: "Show this node's ID", RunE: showNodeID, }
ShowNodeIDCmd dumps node's ID to the standard output.
var ShowValidatorCmd = &cobra.Command{ Use: "show-validator", Aliases: []string{"show_validator"}, Short: "Show this node's validator info", RunE: showValidator, }
ShowValidatorCmd adds capabilities for showing the validator info.
var TestnetFilesCmd = &cobra.Command{
Use: "testnet",
Short: "Initialize files for a CometBFT testnet",
Long: `testnet will create "v" + "n" number of directories and populate each with
necessary files (private validator, genesis, config, etc.).
Note, strict routability for addresses is turned off in the config file.
Optionally, it will fill in persistent_peers list in config file using either hostnames or IPs.
Example:
cometbft testnet --v 4 --o ./output --populate-persistent-peers --starting-ip-address 192.168.10.2
`,
RunE: testnetFiles,
}
TestnetFilesCmd allows initialisation of files for a CometBFT testnet.
var VersionCmd = &cobra.Command{ Use: "version", Short: "Show version info", Run: func(cmd *cobra.Command, args []string) { cmtVersion := version.TMCoreSemVer if version.TMGitCommitHash != "" { cmtVersion += "+" + version.TMGitCommitHash } if verbose { values, _ := json.MarshalIndent(struct { CometBFT string `json:"cometbft"` ABCI string `json:"abci"` BlockProtocol uint64 `json:"block_protocol"` P2PProtocol uint64 `json:"p2p_protocol"` }{ CometBFT: cmtVersion, ABCI: version.ABCISemVer, BlockProtocol: version.BlockProtocol, P2PProtocol: version.P2PProtocol, }, "", " ") fmt.Println(string(values)) } else { fmt.Println(cmtVersion) } }, }
VersionCmd ...
Functions ¶
func AddNodeFlags ¶
AddNodeFlags exposes some common configuration options on the command-line These are exposed for convenience of commands embedding a CometBFT node
func NewRunNodeCmd ¶
NewRunNodeCmd returns the command that allows the CLI to start a node. It can be used with a custom PrivValidator and in-process ABCI application.
func ParseConfig ¶
ParseConfig retrieves the default environment configuration, sets up the CometBFT root and ensures that the root exists
func RollbackState ¶
RollbackState takes the state at the current height n and overwrites it with the state at height n - 1. Note state here refers to CometBFT state not application state. Returns the latest state height and app hash alongside an error if there was one.
Types ¶
This section is empty.