cometbft

package module
v1.0.0-beta.1 Latest Latest
Warning

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

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

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 GetConsensusParams

func GetConsensusParams[T transaction.Tx](ctx context.Context, app handlers.AppManager[T]) (*cmtproto.ConsensusParams, error)

GetConsensusParams makes a query to the consensus module in order to get the latest consensus parameters from committed state

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 RawTx

func RawTx(tx []byte) transaction.Tx

RawTx allows access to the raw bytes of a transaction even if it failed to decode.

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 ValidateVoteExtensions

func ValidateVoteExtensions[T transaction.Tx](
	ctx context.Context,
	app handlers.AppManager[T],
	chainID string,
	validatorStore func(context.Context, []byte) (cryptotypes.PubKey, error),
	extCommit abci.ExtendedCommitInfo,
	currentHeight int64,
	commitInfo *abci.CommitInfo,
) error

ValidateVoteExtensions defines a helper function for verifying vote extension signatures that may be passed or manually injected into a block proposal from a proposer in PrepareProposal. It returns an error if any signature is invalid or if unexpected vote extensions and/or signatures are found or less than 2/3 power is received. If commitInfo is nil, this function can be used to check a set of vote extensions without comparing them to a commit.

func VersionCmd

func VersionCmd() *cobra.Command

VersionCmd prints CometBFT and ABCI version numbers.

Types

type AppCodecs

type AppCodecs[T transaction.Tx] struct {
	TxCodec transaction.Codec[T]

	// The following codecs are only required for the gRPC services
	AppCodec              codec.Codec
	LegacyAmino           registry.AminoRegistrar
	ConsensusAddressCodec addresscodec.Codec
}

AppCodecs contains all codecs that the CometBFT server requires provided by the application. They are extracted in struct to not be API breaking once amino is completely deprecated or new codecs should be added.

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],
	appCodecs AppCodecs[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 InjectedTx

type InjectedTx []byte

func (InjectedTx) Bytes

func (tx InjectedTx) Bytes() []byte

func (InjectedTx) GetGasLimit

func (tx InjectedTx) GetGasLimit() (uint64, error)

func (InjectedTx) GetMessages

func (tx InjectedTx) GetMessages() ([]transaction.Msg, error)

func (InjectedTx) GetSenders

func (tx InjectedTx) GetSenders() ([]transaction.Identity, error)

func (InjectedTx) Hash

func (tx InjectedTx) Hash() [32]byte

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