config

package
v100.2.0 Latest Latest
Warning

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

Go to latest
Published: Sep 4, 2024 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// FuzzModeDrop is a mode in which we randomly drop reads/writes, connections or sleep.
	FuzzModeDrop = iota
	// FuzzModeDelay is a mode in which we randomly sleep.
	FuzzModeDelay

	// LogFormatPlain is a format for colored text.
	LogFormatPlain = "plain"
	// LogFormatJSON is a format for json output.
	LogFormatJSON = "json"

	// DefaultLogLevel defines a default log level as INFO.
	DefaultLogLevel = "info"

	DefaultCometDir  = ".cometbft"
	DefaultConfigDir = "config"
	DefaultDataDir   = "data"

	DefaultConfigFileName  = "config.toml"
	DefaultGenesisJSONName = "genesis.json"

	DefaultPrivValKeyName   = "priv_validator_key.json"
	DefaultPrivValStateName = "priv_validator_state.json"

	DefaultNodeKeyName  = "node_key.json"
	DefaultAddrBookName = "addrbook.json"

	DefaultPruningInterval = 10 * time.Second

	MempoolTypeFlood = "flood"
	MempoolTypeNop   = "nop"
)
View Source
const DefaultDirPerm = 0o700

DefaultDirPerm is the default permissions used when creating directories.

Variables

View Source
var (
	ErrEmptyRPCServerEntry             = errors.New("found empty rpc_servers entry")
	ErrNotEnoughRPCServers             = errors.New("at least two rpc_servers entries are required")
	ErrInsufficientDiscoveryTime       = errors.New("snapshot discovery time must be at least five seconds")
	ErrInsufficientChunkRequestTimeout = errors.New("timeout for re-requesting a chunk (chunk_request_timeout) is less than 5 seconds")
	ErrUnknownLogFormat                = errors.New("unknown log_format (must be 'plain' or 'json')")
	ErrSubscriptionBufferSizeInvalid   = fmt.Errorf("experimental_subscription_buffer_size must be >= %d", minSubscriptionBufferSize)
)

Functions

func DefaultDBProvider

func DefaultDBProvider(ctx *DBContext) (dbm.DB, error)

DefaultDBProvider returns a database using the DBBackend and DBDir specified in the Config.

func EnsureRoot

func EnsureRoot(rootDir string)

EnsureRoot creates the root, config, and data directories if they don't exist, and panics if it fails.

func WriteConfigFile

func WriteConfigFile(configFilePath string, config *Config)

WriteConfigFile renders config using the template and writes it to configFilePath.

Types

type BaseConfig

type BaseConfig struct {
	// The version of the CometBFT binary that created
	// or last modified the config file
	Version string `mapstructure:"version"`

	// The root directory for all data.
	// This should be set in viper so it can unmarshal into this struct
	RootDir string `mapstructure:"home"`

	// TCP or UNIX socket address of the ABCI application,
	// or the name of an ABCI application compiled in with the CometBFT binary
	ProxyApp string `mapstructure:"proxy_app"`

	// A custom human readable name for this node
	Moniker string `mapstructure:"moniker"`

	// Database backend: goleveldb | cleveldb | boltdb | rocksdb | pebbledb
	// * goleveldb (github.com/syndtr/goleveldb)
	//   - UNMAINTAINED
	//   - stable
	//   - pure go
	// * cleveldb (uses levigo wrapper)
	//   - DEPRECATED
	//   - requires gcc
	//   - use cleveldb build tag (go build -tags cleveldb)
	// * boltdb (uses etcd's fork of bolt - github.com/etcd-io/bbolt)
	//   - DEPRECATED
	//   - EXPERIMENTAL
	//   - stable
	//   - use boltdb build tag (go build -tags boltdb)
	// * rocksdb (uses github.com/linxGnu/grocksdb)
	//   - EXPERIMENTAL
	//   - requires gcc
	//   - use rocksdb build tag (go build -tags rocksdb)
	// * badgerdb (uses github.com/dgraph-io/badger)
	//   - EXPERIMENTAL
	//   - stable
	//   - use badgerdb build tag (go build -tags badgerdb)
	// * pebbledb (uses github.com/cockroachdb/pebble)
	//   - EXPERIMENTAL
	//   - stable
	//   - pure go
	//   - use pebbledb build tag (go build -tags pebbledb)
	DBBackend string `mapstructure:"db_backend"`

	// Database directory
	DBPath string `mapstructure:"db_dir"`

	// Output level for logging
	LogLevel string `mapstructure:"log_level"`

	// Output format: 'plain' (colored text) or 'json'
	LogFormat string `mapstructure:"log_format"`

	// Path to the JSON file containing the initial validator set and other meta data
	Genesis string `mapstructure:"genesis_file"`

	// Path to the JSON file containing the private key to use as a validator in the consensus protocol
	PrivValidatorKey string `mapstructure:"priv_validator_key_file"`

	// Path to the JSON file containing the last sign state of a validator
	PrivValidatorState string `mapstructure:"priv_validator_state_file"`

	// TCP or UNIX socket address for CometBFT to listen on for
	// connections from an external PrivValidator process
	PrivValidatorListenAddr string `mapstructure:"priv_validator_laddr"`

	// A JSON file containing the private key to use for p2p authenticated encryption
	NodeKey string `mapstructure:"node_key_file"`

	// Mechanism to connect to the ABCI application: socket | grpc
	ABCI string `mapstructure:"abci"`

	// If true, query the ABCI app on connecting to a new peer
	// so the app can decide if we should keep the connection or not
	FilterPeers bool `mapstructure:"filter_peers"` // false
}

BaseConfig defines the base configuration for a CometBFT node.

func DefaultBaseConfig

func DefaultBaseConfig() BaseConfig

DefaultBaseConfig returns a default base configuration for a CometBFT node.

func TestBaseConfig

func TestBaseConfig() BaseConfig

TestBaseConfig returns a base configuration for testing a CometBFT node.

func (BaseConfig) DBDir

func (cfg BaseConfig) DBDir() string

DBDir returns the full path to the database directory.

func (BaseConfig) GenesisFile

func (cfg BaseConfig) GenesisFile() string

GenesisFile returns the full path to the genesis.json file.

func (BaseConfig) NodeKeyFile

func (cfg BaseConfig) NodeKeyFile() string

NodeKeyFile returns the full path to the node_key.json file.

func (BaseConfig) PrivValidatorKeyFile

func (cfg BaseConfig) PrivValidatorKeyFile() string

PrivValidatorKeyFile returns the full path to the priv_validator_key.json file.

func (BaseConfig) PrivValidatorStateFile

func (cfg BaseConfig) PrivValidatorStateFile() string

PrivValidatorFile returns the full path to the priv_validator_state.json file.

func (BaseConfig) ValidateBasic

func (cfg BaseConfig) ValidateBasic() error

ValidateBasic performs basic validation (checking param bounds, etc.) and returns an error if any check fails.

type BlockSyncConfig

type BlockSyncConfig struct {
	Version string `mapstructure:"version"`
}

BlockSyncConfig (formerly known as FastSync) defines the configuration for the CometBFT block sync service.

func DefaultBlockSyncConfig

func DefaultBlockSyncConfig() *BlockSyncConfig

DefaultBlockSyncConfig returns a default configuration for the block sync service.

func TestBlockSyncConfig

func TestBlockSyncConfig() *BlockSyncConfig

TestBlockSyncConfig returns a default configuration for the block sync.

func (*BlockSyncConfig) ValidateBasic

func (cfg *BlockSyncConfig) ValidateBasic() error

ValidateBasic performs basic validation.

type Config

type Config struct {
	// Top level options use an anonymous struct
	BaseConfig `mapstructure:",squash"`

	// Options for services
	RPC             *RPCConfig             `mapstructure:"rpc"`
	GRPC            *GRPCConfig            `mapstructure:"grpc"`
	P2P             *P2PConfig             `mapstructure:"p2p"`
	Mempool         *MempoolConfig         `mapstructure:"mempool"`
	StateSync       *StateSyncConfig       `mapstructure:"statesync"`
	BlockSync       *BlockSyncConfig       `mapstructure:"blocksync"`
	Consensus       *ConsensusConfig       `mapstructure:"consensus"`
	Storage         *StorageConfig         `mapstructure:"storage"`
	TxIndex         *TxIndexConfig         `mapstructure:"tx_index"`
	Instrumentation *InstrumentationConfig `mapstructure:"instrumentation"`
}

Config defines the top level configuration for a CometBFT node.

func DefaultConfig

func DefaultConfig() *Config

DefaultConfig returns a default configuration for a CometBFT node.

func TestConfig

func TestConfig() *Config

TestConfig returns a configuration that can be used for testing.

func (*Config) CheckDeprecated

func (cfg *Config) CheckDeprecated() []string

CheckDeprecated returns any deprecation warnings. These are printed to the operator on startup.

func (*Config) SetRoot

func (cfg *Config) SetRoot(root string) *Config

SetRoot sets the RootDir for all Config structs.

func (*Config) ValidateBasic

func (cfg *Config) ValidateBasic() error

ValidateBasic performs basic validation (checking param bounds, etc.) and returns an error if any check fails.

type ConsensusConfig

type ConsensusConfig struct {
	RootDir string `mapstructure:"home"`
	WalPath string `mapstructure:"wal_file"`

	// How long we wait for a proposal block before prevoting nil
	TimeoutPropose time.Duration `mapstructure:"timeout_propose"`
	// How much timeout_propose increases with each round
	TimeoutProposeDelta time.Duration `mapstructure:"timeout_propose_delta"`
	// How long we wait after receiving +2/3 prevotes for “anything” (ie. not a single block or nil)
	TimeoutPrevote time.Duration `mapstructure:"timeout_prevote"`
	// How much the timeout_prevote increases with each round
	TimeoutPrevoteDelta time.Duration `mapstructure:"timeout_prevote_delta"`
	// How long we wait after receiving +2/3 precommits for “anything” (ie. not a single block or nil)
	TimeoutPrecommit time.Duration `mapstructure:"timeout_precommit"`
	// How much the timeout_precommit increases with each round
	TimeoutPrecommitDelta time.Duration `mapstructure:"timeout_precommit_delta"`
	// How long we wait after committing a block, before starting on the new
	// height (this gives us a chance to receive some more precommits, even
	// though we already have +2/3).
	// NOTE: when modifying, make sure to update time_iota_ms genesis parameter
	// Set to 0 if you want to make progress as soon as the node has all the precommits.
	TimeoutCommit time.Duration `mapstructure:"timeout_commit"`

	// Deprecated: set `timeout_commit` to 0 instead.
	SkipTimeoutCommit bool `mapstructure:"skip_timeout_commit"`

	// EmptyBlocks mode and possible interval between empty blocks
	CreateEmptyBlocks         bool          `mapstructure:"create_empty_blocks"`
	CreateEmptyBlocksInterval time.Duration `mapstructure:"create_empty_blocks_interval"`

	// Reactor sleep duration parameters
	PeerGossipSleepDuration          time.Duration `mapstructure:"peer_gossip_sleep_duration"`
	PeerQueryMaj23SleepDuration      time.Duration `mapstructure:"peer_query_maj23_sleep_duration"`
	PeerGossipIntraloopSleepDuration time.Duration `mapstructure:"peer_gossip_intraloop_sleep_duration"` // upper bound on randomly selected values

	DoubleSignCheckHeight int64 `mapstructure:"double_sign_check_height"`
	// contains filtered or unexported fields
}

ConsensusConfig defines the configuration for the Tendermint consensus algorithm, adopted by CometBFT, including timeouts and details about the WAL and the block structure.

func DefaultConsensusConfig

func DefaultConsensusConfig() *ConsensusConfig

DefaultConsensusConfig returns a default configuration for the consensus service.

func TestConsensusConfig

func TestConsensusConfig() *ConsensusConfig

TestConsensusConfig returns a configuration for testing the consensus service.

func (*ConsensusConfig) Commit

func (cfg *ConsensusConfig) Commit(t time.Time) time.Time

Commit returns the amount of time to wait for straggler votes after receiving +2/3 precommits for a single block (ie. a commit).

func (*ConsensusConfig) Precommit

func (cfg *ConsensusConfig) Precommit(round int32) time.Duration

Precommit returns the amount of time to wait for straggler votes after receiving any +2/3 precommits.

func (*ConsensusConfig) Prevote

func (cfg *ConsensusConfig) Prevote(round int32) time.Duration

Prevote returns the amount of time to wait for straggler votes after receiving any +2/3 prevotes.

func (*ConsensusConfig) Propose

func (cfg *ConsensusConfig) Propose(round int32) time.Duration

Propose returns the amount of time to wait for a proposal.

func (*ConsensusConfig) SetWalFile

func (cfg *ConsensusConfig) SetWalFile(walFile string)

SetWalFile sets the path to the write-ahead log file.

func (*ConsensusConfig) ValidateBasic

func (cfg *ConsensusConfig) ValidateBasic() error

ValidateBasic performs basic validation (checking param bounds, etc.) and returns an error if any check fails.

func (*ConsensusConfig) WaitForTxs

func (cfg *ConsensusConfig) WaitForTxs() bool

WaitForTxs returns true if the consensus should wait for transactions before entering the propose step.

func (*ConsensusConfig) WalFile

func (cfg *ConsensusConfig) WalFile() string

WalFile returns the full path to the write-ahead log file.

type DBContext

type DBContext struct {
	ID     string
	Config *Config
}

DBContext specifies config information for loading a new DB.

type DBProvider

type DBProvider func(*DBContext) (dbm.DB, error)

DBProvider takes a DBContext and returns an instantiated DB.

type DataCompanionPruningConfig

type DataCompanionPruningConfig struct {
	// Whether automatic pruning respects values set by the data companion.
	// Disabled by default. All other parameters in this section are ignored
	// when this is disabled.
	//
	// If disabled, only the application retain height will influence block
	// pruning (but not block results pruning). Only enabling this at a later
	// stage will potentially mean that blocks below the application-set retain
	// height at the time will not be available to the data companion.
	Enabled bool `mapstructure:"enabled"`
	// The initial value for the data companion block retain height if the data
	// companion has not yet explicitly set one. If the data companion has
	// already set a block retain height, this is ignored.
	InitialBlockRetainHeight int64 `mapstructure:"initial_block_retain_height"`
	// The initial value for the data companion block results retain height if
	// the data companion has not yet explicitly set one. If the data companion
	// has already set a block results retain height, this is ignored.
	InitialBlockResultsRetainHeight int64 `mapstructure:"initial_block_results_retain_height"`
}

func DefaultDataCompanionPruningConfig

func DefaultDataCompanionPruningConfig() *DataCompanionPruningConfig

func TestDataCompanionPruningConfig

func TestDataCompanionPruningConfig() *DataCompanionPruningConfig

func (*DataCompanionPruningConfig) ValidateBasic

func (cfg *DataCompanionPruningConfig) ValidateBasic() error

type ErrDeprecatedBlocksyncVersion

type ErrDeprecatedBlocksyncVersion struct {
	Version string
	Allowed []string
}

func (ErrDeprecatedBlocksyncVersion) Error

type ErrInSection

type ErrInSection struct {
	Err     error
	Section string
}

ErrInSection is returned if validate basic does not pass for any underlying config service.

func (ErrInSection) Error

func (e ErrInSection) Error() string

func (ErrInSection) Unwrap

func (e ErrInSection) Unwrap() error

type ErrUnknownBlocksyncVersion

type ErrUnknownBlocksyncVersion struct {
	Version string
}

func (ErrUnknownBlocksyncVersion) Error

type FuzzConnConfig

type FuzzConnConfig struct {
	Mode         int
	MaxDelay     time.Duration
	ProbDropRW   float64
	ProbDropConn float64
	ProbSleep    float64
}

FuzzConnConfig is a FuzzedConnection configuration.

func DefaultFuzzConnConfig

func DefaultFuzzConnConfig() *FuzzConnConfig

DefaultFuzzConnConfig returns the default config.

type GRPCBlockResultsServiceConfig

type GRPCBlockResultsServiceConfig struct {
	Enabled bool `mapstructure:"enabled"`
}

func DefaultGRPCBlockResultsServiceConfig

func DefaultGRPCBlockResultsServiceConfig() *GRPCBlockResultsServiceConfig

type GRPCBlockServiceConfig

type GRPCBlockServiceConfig struct {
	Enabled bool `mapstructure:"enabled"`
}

func DefaultGRPCBlockServiceConfig

func DefaultGRPCBlockServiceConfig() *GRPCBlockServiceConfig

func TestGRPCBlockServiceConfig

func TestGRPCBlockServiceConfig() *GRPCBlockServiceConfig

type GRPCConfig

type GRPCConfig struct {
	// TCP or Unix socket address for the gRPC server to listen on. If empty,
	// the gRPC server will be disabled.
	ListenAddress string `mapstructure:"laddr"`

	// The gRPC version service provides version information about the node and
	// the protocols it uses.
	VersionService *GRPCVersionServiceConfig `mapstructure:"version_service"`

	// The gRPC block service provides block information
	BlockService *GRPCBlockServiceConfig `mapstructure:"block_service"`

	// The gRPC block results service provides the block results for a given height
	// If no height is provided, the block results of the latest height are returned
	BlockResultsService *GRPCBlockResultsServiceConfig `mapstructure:"block_results_service"`

	// The "privileged" section provides configuration for the gRPC server
	// dedicated to privileged clients.
	Privileged *GRPCPrivilegedConfig `mapstructure:"privileged"`
}

GRPCConfig defines the configuration for the CometBFT gRPC server.

func DefaultGRPCConfig

func DefaultGRPCConfig() *GRPCConfig

func TestGRPCConfig

func TestGRPCConfig() *GRPCConfig

func (*GRPCConfig) ValidateBasic

func (cfg *GRPCConfig) ValidateBasic() error

type GRPCPrivilegedConfig

type GRPCPrivilegedConfig struct {
	// TCP or Unix socket address for the gRPC server for privileged clients
	// to listen on. If empty, the privileged gRPC server will be disabled.
	ListenAddress string `mapstructure:"laddr"`

	// The gRPC pruning service provides control over the depth of block
	// storage information that the node
	PruningService *GRPCPruningServiceConfig `mapstructure:"pruning_service"`
}

GRPCPrivilegedConfig defines the configuration for the CometBFT gRPC server exposing privileged endpoints.

func DefaultGRPCPrivilegedConfig

func DefaultGRPCPrivilegedConfig() *GRPCPrivilegedConfig

func TestGRPCPrivilegedConfig

func TestGRPCPrivilegedConfig() *GRPCPrivilegedConfig

type GRPCPruningServiceConfig

type GRPCPruningServiceConfig struct {
	Enabled bool `mapstructure:"enabled"`
}

func DefaultGRPCPruningServiceConfig

func DefaultGRPCPruningServiceConfig() *GRPCPruningServiceConfig

func TestGRPCPruningServiceConfig

func TestGRPCPruningServiceConfig() *GRPCPruningServiceConfig

type GRPCVersionServiceConfig

type GRPCVersionServiceConfig struct {
	Enabled bool `mapstructure:"enabled"`
}

func DefaultGRPCVersionServiceConfig

func DefaultGRPCVersionServiceConfig() *GRPCVersionServiceConfig

func TestGRPCVersionServiceConfig

func TestGRPCVersionServiceConfig() *GRPCVersionServiceConfig

type InstrumentationConfig

type InstrumentationConfig struct {
	// When true, Prometheus metrics are served under /metrics on
	// PrometheusListenAddr.
	// Check out the documentation for the list of available metrics.
	Prometheus bool `mapstructure:"prometheus"`

	// Address to listen for Prometheus collector(s) connections.
	PrometheusListenAddr string `mapstructure:"prometheus_listen_addr"`

	// Maximum number of simultaneous connections.
	// If you want to accept a larger number than the default, make sure
	// you increase your OS limits.
	// 0 - unlimited.
	MaxOpenConnections int `mapstructure:"max_open_connections"`

	// Instrumentation namespace.
	Namespace string `mapstructure:"namespace"`
}

InstrumentationConfig defines the configuration for metrics reporting.

func DefaultInstrumentationConfig

func DefaultInstrumentationConfig() *InstrumentationConfig

DefaultInstrumentationConfig returns a default configuration for metrics reporting.

func TestInstrumentationConfig

func TestInstrumentationConfig() *InstrumentationConfig

TestInstrumentationConfig returns a default configuration for metrics reporting.

func (*InstrumentationConfig) IsPrometheusEnabled

func (cfg *InstrumentationConfig) IsPrometheusEnabled() bool

func (*InstrumentationConfig) ValidateBasic

func (cfg *InstrumentationConfig) ValidateBasic() error

ValidateBasic performs basic validation (checking param bounds, etc.) and returns an error if any check fails.

type MempoolConfig

type MempoolConfig struct {
	// The type of mempool for this node to use.
	//
	//  Possible types:
	//  - "flood" : concurrent linked list mempool with flooding gossip protocol
	//  (default)
	//  - "nop"   : nop-mempool (short for no operation; the ABCI app is
	//  responsible for storing, disseminating and proposing txs).
	//  "create_empty_blocks=false" is not supported.
	Type string `mapstructure:"type"`
	// RootDir is the root directory for all data. This should be configured via
	// the $CMTHOME env variable or --home cmd flag rather than overriding this
	// struct field.
	RootDir string `mapstructure:"home"`
	// Recheck (default: true) defines whether CometBFT should recheck the
	// validity for all remaining transaction in the mempool after a block.
	// Since a block affects the application state, some transactions in the
	// mempool may become invalid. If this does not apply to your application,
	// you can disable rechecking.
	Recheck bool `mapstructure:"recheck"`
	// RecheckTimeout is the time the application has during the rechecking process
	// to return CheckTx responses, once all requests have been sent. Responses that
	// arrive after the timeout expires are discarded. It only applies to
	// non-local ABCI clients and when recheck is enabled.
	RecheckTimeout time.Duration `mapstructure:"recheck_timeout"`
	// Broadcast (default: true) defines whether the mempool should relay
	// transactions to other peers. Setting this to false will stop the mempool
	// from relaying transactions to other peers until they are included in a
	// block. In other words, if Broadcast is disabled, only the peer you send
	// the tx to will see it until it is included in a block.
	Broadcast bool `mapstructure:"broadcast"`
	// WalPath (default: "") configures the location of the Write Ahead Log
	// (WAL) for the mempool. The WAL is disabled by default. To enable, set
	// WalPath to where you want the WAL to be written (e.g.
	// "data/mempool.wal").
	WalPath string `mapstructure:"wal_dir"`
	// Maximum number of transactions in the mempool
	Size int `mapstructure:"size"`
	// Maximum size in bytes of a single transaction accepted into the mempool.
	MaxTxBytes int `mapstructure:"max_tx_bytes"`
	// The maximum size in bytes of all transactions stored in the mempool.
	// This is the raw, total transaction size. For example, given 1MB
	// transactions and a 5MB maximum mempool byte size, the mempool will
	// only accept five transactions.
	MaxTxsBytes int64 `mapstructure:"max_txs_bytes"`
	// Size of the cache (used to filter transactions we saw earlier) in transactions
	CacheSize int `mapstructure:"cache_size"`
	// Do not remove invalid transactions from the cache (default: false)
	// Set to true if it's not possible for any invalid transaction to become
	// valid again in the future.
	KeepInvalidTxsInCache bool `mapstructure:"keep-invalid-txs-in-cache"`
	// Experimental parameters to limit gossiping txs to up to the specified number of peers.
	// We use two independent upper values for persistent and non-persistent peers.
	// Unconditional peers are not affected by this feature.
	// If we are connected to more than the specified number of persistent peers, only send txs to
	// ExperimentalMaxGossipConnectionsToPersistentPeers of them. If one of those
	// persistent peers disconnects, activate another persistent peer.
	// Similarly for non-persistent peers, with an upper limit of
	// ExperimentalMaxGossipConnectionsToNonPersistentPeers.
	// If set to 0, the feature is disabled for the corresponding group of peers, that is, the
	// number of active connections to that group of peers is not bounded.
	// For non-persistent peers, if enabled, a value of 10 is recommended based on experimental
	// performance results using the default P2P configuration.
	ExperimentalMaxGossipConnectionsToPersistentPeers    int `mapstructure:"experimental_max_gossip_connections_to_persistent_peers"`
	ExperimentalMaxGossipConnectionsToNonPersistentPeers int `mapstructure:"experimental_max_gossip_connections_to_non_persistent_peers"`
}

MempoolConfig defines the configuration options for the CometBFT mempool

Note: Until v0.37 there was a `Version` field to select which implementation of the mempool to use. Two versions used to exist: the current, default implementation (previously called v0), and a prioritized mempool (v1), which was removed (see https://github.com/KYVENetwork/cometbft/v100/issues/260).

func DefaultMempoolConfig

func DefaultMempoolConfig() *MempoolConfig

DefaultMempoolConfig returns a default configuration for the CometBFT mempool.

func TestMempoolConfig

func TestMempoolConfig() *MempoolConfig

TestMempoolConfig returns a configuration for testing the CometBFT mempool.

func (*MempoolConfig) ValidateBasic

func (cfg *MempoolConfig) ValidateBasic() error

ValidateBasic performs basic validation (checking param bounds, etc.) and returns an error if any check fails.

func (*MempoolConfig) WalDir

func (cfg *MempoolConfig) WalDir() string

WalDir returns the full path to the mempool's write-ahead log.

func (*MempoolConfig) WalEnabled

func (cfg *MempoolConfig) WalEnabled() bool

WalEnabled returns true if the WAL is enabled.

type P2PConfig

type P2PConfig struct {
	RootDir string `mapstructure:"home"`

	// Address to listen for incoming connections
	ListenAddress string `mapstructure:"laddr"`

	// Address to advertise to peers for them to dial
	ExternalAddress string `mapstructure:"external_address"`

	// Comma separated list of seed nodes to connect to
	// We only use these if we can’t connect to peers in the addrbook
	Seeds string `mapstructure:"seeds"`

	// Comma separated list of nodes to keep persistent connections to
	PersistentPeers string `mapstructure:"persistent_peers"`

	// Path to address book
	AddrBook string `mapstructure:"addr_book_file"`

	// Set true for strict address routability rules
	// Set false for private or local networks
	AddrBookStrict bool `mapstructure:"addr_book_strict"`

	// Maximum number of inbound peers
	MaxNumInboundPeers int `mapstructure:"max_num_inbound_peers"`

	// Maximum number of outbound peers to connect to, excluding persistent peers
	MaxNumOutboundPeers int `mapstructure:"max_num_outbound_peers"`

	// List of node IDs, to which a connection will be (re)established ignoring any existing limits
	UnconditionalPeerIDs string `mapstructure:"unconditional_peer_ids"`

	// Maximum pause when redialing a persistent peer (if zero, exponential backoff is used)
	PersistentPeersMaxDialPeriod time.Duration `mapstructure:"persistent_peers_max_dial_period"`

	// Time to wait before flushing messages out on the connection
	FlushThrottleTimeout time.Duration `mapstructure:"flush_throttle_timeout"`

	// Maximum size of a message packet payload, in bytes
	MaxPacketMsgPayloadSize int `mapstructure:"max_packet_msg_payload_size"`

	// Rate at which packets can be sent, in bytes/second
	SendRate int64 `mapstructure:"send_rate"`

	// Rate at which packets can be received, in bytes/second
	RecvRate int64 `mapstructure:"recv_rate"`

	// Set true to enable the peer-exchange reactor
	PexReactor bool `mapstructure:"pex"`

	// Seed mode, in which node constantly crawls the network and looks for
	// peers. If another node asks it for addresses, it responds and disconnects.
	//
	// Does not work if the peer-exchange reactor is disabled.
	SeedMode bool `mapstructure:"seed_mode"`

	// Comma separated list of peer IDs to keep private (will not be gossiped to
	// other peers)
	PrivatePeerIDs string `mapstructure:"private_peer_ids"`

	// Toggle to disable guard against peers connecting from the same ip.
	AllowDuplicateIP bool `mapstructure:"allow_duplicate_ip"`

	// Peer connection configuration.
	HandshakeTimeout time.Duration `mapstructure:"handshake_timeout"`
	DialTimeout      time.Duration `mapstructure:"dial_timeout"`

	// Testing params.
	// Force dial to fail
	TestDialFail bool `mapstructure:"test_dial_fail"`
	// Fuzz connection
	TestFuzz       bool            `mapstructure:"test_fuzz"`
	TestFuzzConfig *FuzzConnConfig `mapstructure:"test_fuzz_config"`
}

P2PConfig defines the configuration options for the CometBFT peer-to-peer networking layer.

func DefaultP2PConfig

func DefaultP2PConfig() *P2PConfig

DefaultP2PConfig returns a default configuration for the peer-to-peer layer.

func TestP2PConfig

func TestP2PConfig() *P2PConfig

TestP2PConfig returns a configuration for testing the peer-to-peer layer.

func (*P2PConfig) AddrBookFile

func (cfg *P2PConfig) AddrBookFile() string

AddrBookFile returns the full path to the address book.

func (*P2PConfig) ValidateBasic

func (cfg *P2PConfig) ValidateBasic() error

ValidateBasic performs basic validation (checking param bounds, etc.) and returns an error if any check fails.

type PruningConfig

type PruningConfig struct {
	// The time period between automated background pruning operations.
	Interval time.Duration `mapstructure:"interval"`
	// Data companion-related pruning configuration.
	DataCompanion *DataCompanionPruningConfig `mapstructure:"data_companion"`
}

func DefaultPruningConfig

func DefaultPruningConfig() *PruningConfig

func TestPruningConfig

func TestPruningConfig() *PruningConfig

func (*PruningConfig) ValidateBasic

func (cfg *PruningConfig) ValidateBasic() error

type RPCConfig

type RPCConfig struct {
	RootDir string `mapstructure:"home"`

	// TCP or UNIX socket address for the RPC server to listen on
	ListenAddress string `mapstructure:"laddr"`

	// A list of origins a cross-domain request can be executed from.
	// If the special '*' value is present in the list, all origins will be allowed.
	// An origin may contain a wildcard (*) to replace 0 or more characters (i.e.: http://*.domain.com).
	// Only one wildcard can be used per origin.
	CORSAllowedOrigins []string `mapstructure:"cors_allowed_origins"`

	// A list of methods the client is allowed to use with cross-domain requests.
	CORSAllowedMethods []string `mapstructure:"cors_allowed_methods"`

	// A list of non simple headers the client is allowed to use with cross-domain requests.
	CORSAllowedHeaders []string `mapstructure:"cors_allowed_headers"`

	// Activate unsafe RPC commands like /dial_persistent_peers and /unsafe_flush_mempool
	Unsafe bool `mapstructure:"unsafe"`

	// Maximum number of simultaneous connections (including WebSocket).
	// If you want to accept a larger number than the default, make sure
	// you increase your OS limits.
	// 0 - unlimited.
	// Should be < {ulimit -Sn} - {MaxNumInboundPeers} - {MaxNumOutboundPeers} - {N of wal, db and other open files}
	// 1024 - 40 - 10 - 50 = 924 = ~900
	MaxOpenConnections int `mapstructure:"max_open_connections"`

	// Maximum number of unique clientIDs that can /subscribe
	// If you're using /broadcast_tx_commit, set to the estimated maximum number
	// of broadcast_tx_commit calls per block.
	MaxSubscriptionClients int `mapstructure:"max_subscription_clients"`

	// Maximum number of unique queries a given client can /subscribe to. If
	// you're using /broadcast_tx_commit, set to the estimated maximum number
	// of broadcast_tx_commit calls per block.
	MaxSubscriptionsPerClient int `mapstructure:"max_subscriptions_per_client"`

	// The number of events that can be buffered per subscription before
	// returning `ErrOutOfCapacity`.
	SubscriptionBufferSize int `mapstructure:"experimental_subscription_buffer_size"`

	// The maximum number of responses that can be buffered per WebSocket
	// client. If clients cannot read from the WebSocket endpoint fast enough,
	// they will be disconnected, so increasing this parameter may reduce the
	// chances of them being disconnected (but will cause the node to use more
	// memory).
	//
	// Must be at least the same as `SubscriptionBufferSize`, otherwise
	// connections may be dropped unnecessarily.
	WebSocketWriteBufferSize int `mapstructure:"experimental_websocket_write_buffer_size"`

	// If a WebSocket client cannot read fast enough, at present we may
	// silently drop events instead of generating an error or disconnecting the
	// client.
	//
	// Enabling this parameter will cause the WebSocket connection to be closed
	// instead if it cannot read fast enough, allowing for greater
	// predictability in subscription behavior.
	CloseOnSlowClient bool `mapstructure:"experimental_close_on_slow_client"`

	// How long to wait for a tx to be committed during /broadcast_tx_commit
	// WARNING: Using a value larger than 10s will result in increasing the
	// global HTTP write timeout, which applies to all connections and endpoints.
	// See https://github.com/tendermint/tendermint/issues/3435
	TimeoutBroadcastTxCommit time.Duration `mapstructure:"timeout_broadcast_tx_commit"`

	// Maximum number of requests that can be sent in a batch
	// https://www.jsonrpc.org/specification#batch
	MaxRequestBatchSize int `mapstructure:"max_request_batch_size"`

	// Maximum size of request body, in bytes
	MaxBodyBytes int64 `mapstructure:"max_body_bytes"`

	// Maximum size of request header, in bytes
	MaxHeaderBytes int `mapstructure:"max_header_bytes"`

	// The path to a file containing certificate that is used to create the HTTPS server.
	// Might be either absolute path or path related to CometBFT's config directory.
	//
	// If the certificate is signed by a certificate authority,
	// the certFile should be the concatenation of the server's certificate, any intermediates,
	// and the CA's certificate.
	//
	// NOTE: both tls_cert_file and tls_key_file must be present for CometBFT to create HTTPS server.
	// Otherwise, HTTP server is run.
	TLSCertFile string `mapstructure:"tls_cert_file"`

	// The path to a file containing matching private key that is used to create the HTTPS server.
	// Might be either absolute path or path related to CometBFT's config directory.
	//
	// NOTE: both tls_cert_file and tls_key_file must be present for CometBFT to create HTTPS server.
	// Otherwise, HTTP server is run.
	TLSKeyFile string `mapstructure:"tls_key_file"`

	// pprof listen address (https://golang.org/pkg/net/http/pprof)
	// FIXME: This should be moved under the instrumentation section
	PprofListenAddress string `mapstructure:"pprof_laddr"`
}

RPCConfig defines the configuration options for the CometBFT RPC server.

func DefaultRPCConfig

func DefaultRPCConfig() *RPCConfig

DefaultRPCConfig returns a default configuration for the RPC server.

func TestRPCConfig

func TestRPCConfig() *RPCConfig

TestRPCConfig returns a configuration for testing the RPC server.

func (RPCConfig) CertFile

func (cfg RPCConfig) CertFile() string

func (*RPCConfig) IsCorsEnabled

func (cfg *RPCConfig) IsCorsEnabled() bool

IsCorsEnabled returns true if cross-origin resource sharing is enabled.

func (*RPCConfig) IsPprofEnabled

func (cfg *RPCConfig) IsPprofEnabled() bool

func (RPCConfig) IsTLSEnabled

func (cfg RPCConfig) IsTLSEnabled() bool

func (RPCConfig) KeyFile

func (cfg RPCConfig) KeyFile() string

func (*RPCConfig) ValidateBasic

func (cfg *RPCConfig) ValidateBasic() error

ValidateBasic performs basic validation (checking param bounds, etc.) and returns an error if any check fails.

type ServiceProvider

type ServiceProvider func(context.Context, *Config, log.Logger) (service.Service, error)

ServiceProvider takes a config and a logger and returns a ready to go Node.

type StateSyncConfig

type StateSyncConfig struct {
	Enable              bool          `mapstructure:"enable"`
	TempDir             string        `mapstructure:"temp_dir"`
	RPCServers          []string      `mapstructure:"rpc_servers"`
	TrustPeriod         time.Duration `mapstructure:"trust_period"`
	TrustHeight         int64         `mapstructure:"trust_height"`
	TrustHash           string        `mapstructure:"trust_hash"`
	DiscoveryTime       time.Duration `mapstructure:"discovery_time"`
	ChunkRequestTimeout time.Duration `mapstructure:"chunk_request_timeout"`
	ChunkFetchers       int32         `mapstructure:"chunk_fetchers"`
}

StateSyncConfig defines the configuration for the CometBFT state sync service.

func DefaultStateSyncConfig

func DefaultStateSyncConfig() *StateSyncConfig

DefaultStateSyncConfig returns a default configuration for the state sync service.

func TestStateSyncConfig

func TestStateSyncConfig() *StateSyncConfig

TestStateSyncConfig returns a default configuration for the state sync service.

func (*StateSyncConfig) TrustHashBytes

func (cfg *StateSyncConfig) TrustHashBytes() []byte

func (*StateSyncConfig) ValidateBasic

func (cfg *StateSyncConfig) ValidateBasic() error

ValidateBasic performs basic validation.

type StorageConfig

type StorageConfig struct {
	// Set to false to ensure ABCI responses are persisted. ABCI responses are
	// required for `/block_results` RPC queries, and to reindex events in the
	// command-line tool.
	DiscardABCIResponses bool `mapstructure:"discard_abci_responses"`
	// Configuration related to storage pruning.
	Pruning *PruningConfig `mapstructure:"pruning"`
	// Compaction on pruning - enable or disable in-process compaction.
	// If the DB backend supports it, this will force the DB to compact
	// the database levels and save on storage space. Setting this to true
	// is most beneficial when used in combination with pruning as it will
	// phyisically delete the entries marked for deletion.
	// false by default (forcing compaction is disabled).
	Compact bool `mapstructure:"compact"`
	// Compaction interval - number of blocks to try explicit compaction on.
	// This parameter should be tuned depending on the number of items
	// you expect to delete between two calls to forced compaction.
	// If your retain height is 1 block, it is too much of an overhead
	// to try compaction every block. But it should also not be a very
	// large multiple of your retain height as it might occur bigger overheads.
	// 1000 by default.
	CompactionInterval int64 `mapstructure:"compaction_interval"`
	// Hex representation of the hash of the genesis file.
	// This is an optional parameter set when an operator provides
	// a hash via the command line.
	// It is used to verify the hash of the actual genesis file.
	// Note that if the provided has does not match the hash of the genesis file
	// the node will report an error and not boot.
	GenesisHash string `mapstructure:"genesis_hash"`

	// The representation of keys in the database.
	// The current representation of keys in Comet's stores is considered to be v1
	// Users can experiment with a different layout by setting this field to v2.
	// Not that this is an experimental feature and switching back from v2 to v1
	// is not supported by CometBFT.
	ExperimentalKeyLayout string `mapstructure:"experimental_db_key_layout"`
}

StorageConfig allows more fine-grained control over certain storage-related behavior.

func DefaultStorageConfig

func DefaultStorageConfig() *StorageConfig

DefaultStorageConfig returns the default configuration options relating to CometBFT storage optimization.

func TestStorageConfig

func TestStorageConfig() *StorageConfig

TestStorageConfig returns storage configuration that can be used for testing.

func (*StorageConfig) ValidateBasic

func (cfg *StorageConfig) ValidateBasic() error

type TxIndexConfig

type TxIndexConfig struct {
	// What indexer to use for transactions
	//
	// Options:
	//   1) "null"
	//   2) "kv" (default) - the simplest possible indexer,
	//      backed by key-value storage (defaults to levelDB; see DBBackend).
	//   3) "psql" - the indexer services backed by PostgreSQL.
	Indexer string `mapstructure:"indexer"`

	// The PostgreSQL connection configuration, the connection format:
	// postgresql://<user>:<password>@<host>:<port>/<db>?<opts>
	PsqlConn string `mapstructure:"psql-conn"`
}

----------------------------------------------------------------------------- TxIndexConfig Remember that Event has the following structure: type: [

key: value,
...

]

CompositeKeys are constructed by `type.key` TxIndexConfig defines the configuration for the transaction indexer, including composite keys to index.

func DefaultTxIndexConfig

func DefaultTxIndexConfig() *TxIndexConfig

DefaultTxIndexConfig returns a default configuration for the transaction indexer.

func TestTxIndexConfig

func TestTxIndexConfig() *TxIndexConfig

TestTxIndexConfig returns a default configuration for the transaction indexer.

Jump to

Keyboard shortcuts

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