cometbft

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

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

Go to latest
Published: Oct 17, 2024 License: Apache-2.0 Imports: 68 Imported by: 2

Documentation

Index

Constants

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 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 */
	IndexEvents     []string `` /* 212-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 */
}

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 *Consensus[T]
	// contains filtered or unexported fields
}

func New

func New[T transaction.Tx](
	txCodec transaction.Codec[T],
	serverOptions ServerOptions[T],
	cfgOptions ...CfgOption,
) *CometBFTServer[T]

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]) Init

func (s *CometBFTServer[T]) Init(appI serverv2.AppI[T], cfg map[string]any, logger log.Logger) error

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 Consensus

type Consensus[T transaction.Tx] struct {
	// contains filtered or unexported fields
}

func NewConsensus

func NewConsensus[T transaction.Tx](
	logger log.Logger,
	appName string,
	app *appmanager.AppManager[T],
	appCloser func() error,
	mp mempool.Mempool[T],
	indexedEvents map[string]struct{},
	queryHandlersMap map[string]appmodulev2.Handler,
	store types.Store,
	cfg Config,
	txCodec transaction.Codec[T],
	chainId string,
) *Consensus[T]

func (*Consensus[T]) ApplySnapshotChunk

ApplySnapshotChunk implements types.Application.

func (*Consensus[T]) CheckTx

CheckTx implements types.Application. It is called by cometbft to verify transaction validity

func (*Consensus[T]) Commit

Commit implements types.Application. It is called by cometbft to notify the application that a block was committed.

func (*Consensus[T]) ExtendVote

ExtendVote implements types.Application.

func (*Consensus[T]) FinalizeBlock

FinalizeBlock implements types.Application. It is called by cometbft to finalize a block.

func (*Consensus[T]) GetBlockRetentionHeight

func (c *Consensus[T]) GetBlockRetentionHeight(cp *cmtproto.ConsensusParams, commitHeight int64) int64

func (*Consensus[T]) GetConsensusParams

func (c *Consensus[T]) GetConsensusParams(ctx context.Context) (*cmtproto.ConsensusParams, error)

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

func (*Consensus[T]) Info

Info implements types.Application.

func (*Consensus[T]) InitChain

InitChain implements types.Application.

func (*Consensus[T]) ListSnapshots

ListSnapshots implements types.Application.

func (*Consensus[T]) LoadSnapshotChunk

LoadSnapshotChunk implements types.Application.

func (*Consensus[T]) OfferSnapshot

OfferSnapshot implements types.Application.

func (*Consensus[T]) PrepareProposal

func (c *Consensus[T]) PrepareProposal(
	ctx context.Context,
	req *abciproto.PrepareProposalRequest,
) (resp *abciproto.PrepareProposalResponse, err error)

PrepareProposal implements types.Application. It is called by cometbft to prepare a proposal block.

func (*Consensus[T]) ProcessProposal

ProcessProposal implements types.Application. It is called by cometbft to process/verify a proposal block.

func (*Consensus[T]) Query

func (c *Consensus[T]) Query(ctx context.Context, req *abciproto.QueryRequest) (resp *abciproto.QueryResponse, err error)

Query implements types.Application. It is called by cometbft to query application state.

func (*Consensus[T]) RegisterSnapshotExtensions

func (c *Consensus[T]) RegisterSnapshotExtensions(extensions ...snapshots.ExtensionSnapshotter) error

RegisterSnapshotExtensions registers the given extensions with the consensus module's snapshot manager. It allows additional snapshotter implementations to be used for creating and restoring snapshots.

func (*Consensus[T]) SetStreamingManager

func (c *Consensus[T]) SetStreamingManager(sm streaming.Manager)

SetStreamingManager sets the streaming manager for the consensus module.

func (*Consensus[T]) VerifyVoteExtension

VerifyVoteExtension implements types.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

	Mempool         func(cfg map[string]any) mempool.Mempool[T]
	SnapshotOptions func(cfg map[string]any) snapshots.SnapshotOptions

	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