cometbft

package module
v0.0.0-...-eb3bf8b Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 4, 2024 License: Apache-2.0 Imports: 80 Imported by: 3

Documentation

Index

Constants

View Source
const (
	QueryPathApp   = "app"
	QueryPathP2P   = "p2p"
	QueryPathStore = "store"
)
View Source
const (
	FlagQuery        = "query"
	FlagType         = "type"
	FlagOrderBy      = "order_by"
	FlagChainID      = "chain-id"
	FlagNode         = "node"
	FlagGRPC         = "grpc-addr"
	FlagGRPCInsecure = "grpc-insecure"
	FlagHeight       = "height"
	FlagPage         = "page"
	FlagLimit        = "limit"
	FlagOutput       = "output"
	TypeHash         = "hash"
	TypeHeight       = "height"
)

Query flags

View Source
const (
	OutputFormatJSON = "json"
	OutputFormatText = "text"
)

List of supported output formats

View Source
const ServerName = "comet"

Variables

View Source
var (
	Standalone        = prefix("standalone")
	FlagAddress       = prefix("address")
	FlagTransport     = prefix("transport")
	FlagHaltHeight    = prefix("halt-height")
	FlagHaltTime      = prefix("halt-time")
	FlagTrace         = prefix("trace")
	FlagMempoolMaxTxs = prefix("mempool.max-txs")
)

Server flags

View Source
var CometBFTAutoCLIDescriptor = &autocliv1.ServiceCommandDescriptor{
	Service: cmtv1beta1.Service_ServiceDesc.ServiceName,
	RpcCommandOptions: []*autocliv1.RpcCommandOptions{
		{
			RpcMethod: "GetNodeInfo",
			Use:       "node-info",
			Short:     "Query the current node info",
		},
		{
			RpcMethod: "GetSyncing",
			Use:       "syncing",
			Short:     "Query node syncing status",
		},
		{
			RpcMethod: "GetLatestBlock",
			Use:       "block-latest",
			Short:     "Query for the latest committed block",
		},
		{
			RpcMethod:      "GetBlockByHeight",
			Use:            "block-by-height <height>",
			Short:          "Query for a committed block by height",
			Long:           "Query for a specific committed block using the CometBFT RPC `block_by_height` method",
			PositionalArgs: []*autocliv1.PositionalArgDescriptor{{ProtoField: "height"}},
		},
		{
			RpcMethod: "GetLatestValidatorSet",
			Use:       "validator-set",
			Alias:     []string{"validator-set-latest", "comet-validator-set", "cometbft-validator-set", "tendermint-validator-set"},
			Short:     "Query for the latest validator set",
		},
		{
			RpcMethod:      "GetValidatorSetByHeight",
			Use:            "validator-set-by-height <height>",
			Short:          "Query for a validator set by height",
			PositionalArgs: []*autocliv1.PositionalArgDescriptor{{ProtoField: "height"}},
		},
		{
			RpcMethod: "ABCIQuery",
			Skip:      true,
		},
	},
}

CometBFTAutoCLIDescriptor is the auto-generated CLI descriptor for the CometBFT service

View Source
var Version = ""

Functions

func AddQueryFlagsToCmd

func AddQueryFlagsToCmd(cmd *cobra.Command)

AddQueryFlagsToCmd adds common flags to a module query command.

func GetSnapshotStore

func GetSnapshotStore(rootDir string) (*snapshots.Store, error)

GetSnapshotStore returns a snapshot store for the given application options. It creates a directory for storing snapshots if it doesn't exist. It initializes a GoLevelDB database for storing metadata of the snapshots. The snapshot store is then created using the initialized database and directory. If any error occurs during the process, it is returned along with a nil snapshot store.

func QueryBlockCmd

func QueryBlockCmd() *cobra.Command

QueryBlockCmd implements the default command for a Block query.

func QueryBlockResultsCmd

func QueryBlockResultsCmd() *cobra.Command

QueryBlockResultsCmd implements the default command for a BlockResults query.

func QueryBlocksCmd

func QueryBlocksCmd() *cobra.Command

QueryBlocksCmd returns a command to search through blocks by events.

func QueryResult

func QueryResult(err error, debug bool) *abci.QueryResponse

QueryResult returns a ResponseQuery from an error. It will try to parse ABCI info from the error.

func ShowAddressCmd

func ShowAddressCmd() *cobra.Command

ShowAddressCmd - show this node's validator address

func ShowNodeIDCmd

func ShowNodeIDCmd() *cobra.Command

ShowNodeIDCmd - ported from CometBFT, dump node ID to stdout

func ShowValidatorCmd

func ShowValidatorCmd() *cobra.Command

ShowValidatorCmd - ported from CometBFT, show this node's validator info

func StatusCommand

func StatusCommand() *cobra.Command

StatusCommand returns the command to return the status of the network.

func ToSDKCommitInfo

func ToSDKCommitInfo(commit abci.CommitInfo) *comet.CommitInfo

ToSDKCommitInfo takes comet commit info and returns sdk commit info

func ToSDKEvidence

func ToSDKEvidence(ev []abci.Misbehavior) []*comet.Evidence

ToSDKEvidence takes comet evidence and returns sdk evidence

func ToSDKExtendedCommitInfo

func ToSDKExtendedCommitInfo(commit abci.ExtendedCommitInfo) comet.CommitInfo

ToSDKExtendedCommitInfo takes comet extended commit info and returns sdk commit info

func VersionCmd

func VersionCmd() *cobra.Command

VersionCmd prints CometBFT and ABCI version numbers.

Types

type AppTomlConfig

type AppTomlConfig struct {
	MinRetainBlocks uint64 `` /* 285-byte string literal not displayed */
	HaltHeight      uint64 `` /* 199-byte string literal not displayed */
	HaltTime        uint64 `` /* 217-byte string literal not displayed */
	Address         string `mapstructure:"address" toml:"address" comment:"address defines the CometBFT RPC server address to bind to."`
	Transport       string `` /* 126-byte string literal not displayed */
	Trace           bool   `` /* 140-byte string literal not displayed */
	Standalone      bool   `` /* 153-byte string literal not displayed */

	// Sub configs
	Mempool                mempool.Config         `` /* 136-byte string literal not displayed */
	Indexer                indexer.IndexingConfig `` /* 126-byte string literal not displayed */
	IndexABCIEvents        []string               `` /* 227-byte string literal not displayed */
	DisableIndexABCIEvents bool                   `` /* 282-byte string literal not displayed */
	DisableABCIEvents      bool                   `` /* 176-byte string literal not displayed */
}

func DefaultAppTomlConfig

func DefaultAppTomlConfig() *AppTomlConfig

type CfgOption

type CfgOption func(*Config)

CfgOption is a function that allows to overwrite the default server configuration.

func OverwriteDefaultAppTomlConfig

func OverwriteDefaultAppTomlConfig(newCfg *AppTomlConfig) CfgOption

OverwriteDefaultAppTomlConfig overwrites the default comet config with the new config.

func OverwriteDefaultConfigTomlConfig

func OverwriteDefaultConfigTomlConfig(newCfg *cmtcfg.Config) CfgOption

OverwriteDefaultConfigTomlConfig overwrites the default comet config with the new config.

type CometBFTServer

type CometBFTServer[T transaction.Tx] struct {
	Node      *node.Node
	Consensus abci.Application
	// contains filtered or unexported fields
}

func New

func New[T transaction.Tx](
	logger log.Logger,
	appName string,
	store types.Store,
	app appmanager.AppManager[T],
	appCodec codec.Codec,
	txCodec transaction.Codec[T],
	queryHandlers map[string]appmodulev2.Handler,
	decoderResolver decoding.DecoderResolver,
	serverOptions ServerOptions[T],
	cfg server.ConfigMap,
	cfgOptions ...CfgOption,
) (*CometBFTServer[T], error)

func NewWithConfigOptions

func NewWithConfigOptions[T transaction.Tx](opts ...CfgOption) *CometBFTServer[T]

NewWithConfigOptions creates a new CometBFT server with the provided config options. It is *not* a fully functional server (since it has been created without dependencies) The returned server should only be used to get and set configuration.

func (*CometBFTServer[T]) BootstrapStateCmd

func (s *CometBFTServer[T]) BootstrapStateCmd() *cobra.Command

func (*CometBFTServer[T]) CLICommands

func (s *CometBFTServer[T]) CLICommands() serverv2.CLIConfig

func (*CometBFTServer[T]) Config

func (s *CometBFTServer[T]) Config() any

Config returns the (app.toml) server configuration.

func (*CometBFTServer[T]) GRPCServiceRegistrar

func (s *CometBFTServer[T]) GRPCServiceRegistrar(
	clientCtx client.Context,
	cfg server.ConfigMap,
) func(srv *grpc.Server) error

gRPCServiceRegistrar returns a function that registers the CometBFT gRPC service Those services are defined for backward compatibility. Eventually, they will be removed in favor of the new gRPC services.

func (*CometBFTServer[T]) Name

func (s *CometBFTServer[T]) Name() string

func (*CometBFTServer[T]) Start

func (s *CometBFTServer[T]) Start(ctx context.Context) error

func (*CometBFTServer[T]) StartCmdFlags

func (s *CometBFTServer[T]) StartCmdFlags() *pflag.FlagSet

func (*CometBFTServer[T]) Stop

func (s *CometBFTServer[T]) Stop(context.Context) error

func (*CometBFTServer[T]) WriteCustomConfigAt

func (s *CometBFTServer[T]) WriteCustomConfigAt(configPath string) error

WriteCustomConfigAt writes the default cometbft config.toml

type Config

type Config struct {
	AppTomlConfig    *AppTomlConfig
	ConfigTomlConfig *cmtcfg.Config
}

Config is the configuration for the CometBFT application

type ServerOptions

type ServerOptions[T transaction.Tx] struct {
	PrepareProposalHandler     handlers.PrepareHandler[T]
	ProcessProposalHandler     handlers.ProcessHandler[T]
	CheckTxHandler             handlers.CheckTxHandler[T]
	VerifyVoteExtensionHandler handlers.VerifyVoteExtensionhandler
	ExtendVoteHandler          handlers.ExtendVoteHandler
	KeygenF                    keyGenF

	// Set mempool for the consensus module.
	Mempool func(cfg map[string]any) mempool.Mempool[T]
	// Set streaming manager for the consensus module.
	StreamingManager streaming.Manager
	// Set snapshot options for the consensus module.
	SnapshotOptions func(cfg map[string]any) snapshots.SnapshotOptions
	// Allows additional snapshotter implementations to be used for creating and restoring snapshots.
	SnapshotExtensions []snapshots.ExtensionSnapshotter

	AddrPeerFilter types.PeerFilter // filter peers by address and port
	IdPeerFilter   types.PeerFilter // filter peers by node ID
}

ServerOptions defines the options for the CometBFT server. When an option takes a map[string]any, it can access the app.tom's cometbft section and the config.toml config.

func DefaultServerOptions

func DefaultServerOptions[T transaction.Tx]() ServerOptions[T]

DefaultServerOptions returns the default server options. It defaults to a NoOpMempool and NoOp handlers.

Directories

Path Synopsis
client
rpc
internal
Package mempool defines a few mempool services which can be used in conjunction with your consensus implementation.
Package mempool defines a few mempool services which can be used in conjunction with your consensus implementation.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL