Documentation ¶
Overview ¶
Package config provides types and functions for node configuration loading and generation.
Index ¶
- Constants
- Variables
- func AddConfigFlags(flagSet *pflag.FlagSet, cfg *KwildConfig)
- func ExpandPath(path string) (string, error)
- func ReadOrCreatePrivateKeyFile(keyPath string, autogen bool) (priv, pub []byte, generated bool, err error)
- func ResetAll(rootDir, snapshotDir string) error
- func ResetChainState(rootDir string) error
- type AppConfig
- type BlockParams
- type ChainConfig
- type ChainRPCConfig
- type ConsensusConfig
- type ConsensusParams
- type Duration
- type EvidenceParams
- type GenesisAlloc
- type GenesisConfig
- type GenesisValidator
- type HexBytes
- type KwildConfig
- func (cfg *KwildConfig) InitPrivateKeyAndGenesis(autogen bool) (privateKey *crypto.Ed25519PrivateKey, genConfig *GenesisConfig, err error)
- func (cfg *KwildConfig) LogConfig() *log.Config
- func (a *KwildConfig) MarshalBinary() ([]byte, error)
- func (a *KwildConfig) Merge(b *KwildConfig) error
- func (a *KwildConfig) UnmarshalBinary(b []byte) error
- type Logging
- type MempoolConfig
- type P2PConfig
- type SnapshotConfig
- type StateSyncConfig
- type ValidatorParams
- type VersionParams
- type VoteParams
Constants ¶
const ( DefaultSnapshotsDir = "snapshots" DefaultTLSCertFile = "rpc.cert" )
const ( ABCIDirName = "abci" // cometBFT node's root folder ABCIInfoSubDirName = "info" // e.g. abci/info for kv state data ReceivedSnapsDirName = "rcvdSnaps" SigningDirName = "signing" ConfigFileName = "config.toml" PrivateKeyFileName = "private_key" )
Top-level directory structure for the Server's systems. These are not user configurable.
Variables ¶
var ErrConfigFileNotFound = fmt.Errorf("config file not found")
Functions ¶
func AddConfigFlags ¶
func AddConfigFlags(flagSet *pflag.FlagSet, cfg *KwildConfig)
AddConfigFlags adds all flags from KwildConfig to the given flagSet
func ExpandPath ¶
func ReadOrCreatePrivateKeyFile ¶
func ReadOrCreatePrivateKeyFile(keyPath string, autogen bool) (priv, pub []byte, generated bool, err error)
ReadOrCreatePrivateKeyFile will read the node key pair from the given file, or generate it if it does not exist and requested.
func ResetChainState ¶
Types ¶
type AppConfig ¶
type AppConfig struct { GrpcListenAddress string `mapstructure:"grpc_listen_addr"` HTTPListenAddress string `mapstructure:"http_listen_addr"` AdminListenAddress string `mapstructure:"admin_listen_addr"` PrivateKeyPath string `mapstructure:"private_key_path"` // PostgreSQL DB settings. DBName is the name if the PostgreSQL database to // connect to. The different data stores (e.g. engine, acct store, event // store, etc.) are all in the same database. Assuming "kwild" is the // DBName, this would be created with psql with the commands: // CREATE USER kwild WITH SUPERUSER REPLICATION; // CREATE DATABASE kwild OWNER kwild; // // All of these settings are strings and separate, but it is possible to // have a single DB "connection string" to pass to the PostgreSQL backend. // However, this is less error prone, and prevents passing settings that // would alter the functionality of the connection. An advanced option could // be added to supplement the conn string if that seems useful. DBHost string `mapstructure:"pg_db_host"` DBPort string `mapstructure:"pg_db_port"` DBUser string `mapstructure:"pg_db_user"` DBPass string `mapstructure:"pg_db_pass"` DBName string `mapstructure:"pg_db_name"` ExtensionEndpoints []string `mapstructure:"extension_endpoints"` TLSCertFile string `mapstructure:"tls_cert_file"` TLSKeyFile string `mapstructure:"tls_key_file"` EnableRPCTLS bool `mapstructure:"rpctls"` Hostname string `mapstructure:"hostname"` ProfileMode string `mapstructure:"profile_mode"` ProfileFile string `mapstructure:"profile_file"` Extensions map[string]map[string]string `mapstructure:"extensions"` }
type BlockParams ¶
type ChainConfig ¶
type ChainConfig struct { Moniker string `mapstructure:"moniker"` RPC *ChainRPCConfig `mapstructure:"rpc"` P2P *P2PConfig `mapstructure:"p2p"` Mempool *MempoolConfig `mapstructure:"mempool"` StateSync *StateSyncConfig `mapstructure:"statesync"` Consensus *ConsensusConfig `mapstructure:"consensus"` }
type ChainRPCConfig ¶
type ChainRPCConfig struct { // TCP or UNIX socket address for the RPC server to listen on ListenAddress string `mapstructure:"listen_addr"` }
type ConsensusConfig ¶
type ConsensusConfig struct { // TimeoutPropose is how long to wait for a proposal block before prevoting // nil. TimeoutPropose Duration `mapstructure:"timeout_propose"` // TimeoutPrevote is how long to wait after receiving +2/3 prevotes for // “anything” (i.e. not a single block or nil). TimeoutPrevote Duration `mapstructure:"timeout_prevote"` // TimeoutPrecommit is how long we wait after receiving +2/3 precommits for // “anything” (i.e. not a single block or nil). TimeoutPrecommit Duration `mapstructure:"timeout_precommit"` // TimeoutCommit is how long to 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). TimeoutCommit Duration `mapstructure:"timeout_commit"` }
type ConsensusParams ¶
type ConsensusParams struct { Block BlockParams `json:"block"` Evidence EvidenceParams `json:"evidence"` Version VersionParams `json:"version"` Validator ValidatorParams `json:"validator"` Votes VoteParams `json:"votes"` WithoutNonces bool `json:"without_nonces"` WithoutGasCosts bool `json:"without_gas_costs"` }
type Duration ¶
toml package does not support time.Duration, since time is not part of TOML spec Fix can be found here: https://github.com/pelletier/go-toml/issues/767 It implements both the TextUnmarshaler interface and the pflag.Value interface
func (*Duration) UnmarshalText ¶
type EvidenceParams ¶
type GenesisAlloc ¶
type GenesisConfig ¶
type GenesisConfig struct { GenesisTime time.Time `json:"genesis_time"` ChainID string `json:"chain_id"` InitialHeight int64 `json:"initial_height"` DataAppHash []byte `json:"app_hash"` Alloc GenesisAlloc `json:"alloc,omitempty"` /* TODO: Can introduce app state later if needed. Used to specify raw initial state such as tokens etc, abci init will generate a new app hash after applying this state */ // AppState json.RawMessage `json:"app_state"` ConsensusParams *ConsensusParams `json:"consensus_params,omitempty"` Validators []*GenesisValidator `json:"validators,omitempty"` }
func DefaultGenesisConfig ¶
func DefaultGenesisConfig() *GenesisConfig
DefaultGenesisConfig returns a new instance of a GenesisConfig with the default values set, which in particular includes no validators and a nil appHash. The chain ID will semi-random, with the prefix "kwil-chain-" followed by random alphanumeric characters.
func LoadGenesisConfig ¶
func LoadGenesisConfig(file string) (*GenesisConfig, error)
LoadGenesisConfig loads a genesis file from disk and parse it into a GenesisConfig.
func NewGenesisWithValidator ¶
func NewGenesisWithValidator(pubKey []byte) *GenesisConfig
func (*GenesisConfig) ComputeGenesisHash ¶
func (genConf *GenesisConfig) ComputeGenesisHash() []byte
AppHash: App hash in the genesis file corresponds to the initial database state.
CometBFT internally hashes specific fields from the ConsensusParams from the Genesis, but doesn't automatically validates the rest of the fields.
computeGenesisHash constructs app hash based on the fields introduced by the application in the genesis file which aren't monitored by cometBFT for consensus purposes.
This app hash is used by the ABCI application to initialize the blockchain.
Currently includes:
- AppHash (Datastores state)
- Join Expiry
- Without Gas Costs
- Without Nonces
- Allocs (account allocations, same format as ethereum genesis.json)
- Vote Expiry
func (*GenesisConfig) SaveAs ¶
func (genConfig *GenesisConfig) SaveAs(file string) error
SaveAs writes the genesis config to a file.
type GenesisValidator ¶
type KwildConfig ¶
type KwildConfig struct { RootDir string AppCfg *AppConfig `mapstructure:"app"` ChainCfg *ChainConfig `mapstructure:"chain"` Logging *Logging `mapstructure:"log"` }
func DefaultConfig ¶
func DefaultConfig() *KwildConfig
func EmptyConfig ¶
func EmptyConfig() *KwildConfig
EmptyConfig returns a config with all fields set to their zero values. This is useful for guaranteeing that all fields are set when merging
func GetCfg ¶
func GetCfg(flagCfg *KwildConfig, quickStart bool) (*KwildConfig, bool, error)
GetCfg gets the kwild config It has the following precedence (low to high): 1. Default 2. Config file 3. Env vars 4. Command line flags It takes the config generated from the command line flags to override default. It also takes a flag to indicate if the caller wants to modify the defaults for "quickstart" mode. Presently this just makes the HTTP RPC service listen on all interfaces instead of the default of localhost.
func LoadConfigFile ¶
func LoadConfigFile(configPath string) (*KwildConfig, error)
LoadConfig reads a config.toml at the given path and returns a KwilConfig. If the file does not exist, it will return an ErrConfigFileNotFound error.
func LoadEnvConfig ¶
func LoadEnvConfig() (*KwildConfig, error)
LoadEnvConfig loads a config from environment variables.
func (*KwildConfig) InitPrivateKeyAndGenesis ¶
func (cfg *KwildConfig) InitPrivateKeyAndGenesis(autogen bool) (privateKey *crypto.Ed25519PrivateKey, genConfig *GenesisConfig, err error)
func (*KwildConfig) LogConfig ¶
func (cfg *KwildConfig) LogConfig() *log.Config
func (*KwildConfig) MarshalBinary ¶
func (a *KwildConfig) MarshalBinary() ([]byte, error)
func (*KwildConfig) Merge ¶
func (a *KwildConfig) Merge(b *KwildConfig) error
Merge merges b onto a, overwriting any fields in a that are also set in b.
func (*KwildConfig) UnmarshalBinary ¶
func (a *KwildConfig) UnmarshalBinary(b []byte) error
type MempoolConfig ¶
type MempoolConfig struct { // Maximum number of transactions in the mempool Size int `mapstructure:"size"` // Size of the cache (used to filter transactions we saw earlier) in transactions CacheSize int `mapstructure:"cache_size"` // MaxTxBytes limits the size of any one transaction in mempool. MaxTxBytes int `mapstructure:"max_tx_bytes"` // MaxTxsBytes limits the total size of all txs in the mempool. // This only accounts for raw transactions (e.g. given 1MB transactions and // max_txs_bytes=5MB, mempool will only accept 5 transactions). MaxTxsBytes int `mapstructure:"max_txs_bytes"` }
type P2PConfig ¶
type P2PConfig struct { // ListenAddress is the address on which to listen for incoming connections. ListenAddress string `mapstructure:"listen_addr"` // ExternalAddress is the address to advertise to peers to dial us. ExternalAddress string `mapstructure:"external_address"` // PersistentPeers is a comma separated list of nodes to keep persistent // connections to. PersistentPeers string `mapstructure:"persistent_peers"` // AddrBookStrict enforces strict address routability rules. This must be // false for private or local networks. AddrBookStrict bool `mapstructure:"addr_book_strict"` // MaxNumInboundPeers is the maximum number of inbound peers. MaxNumInboundPeers int `mapstructure:"max_num_inbound_peers"` // MaxNumOutboundPeers is the maximum number of outbound peers to connect // to, excluding persistent peers. MaxNumOutboundPeers int `mapstructure:"max_num_outbound_peers"` // UnconditionalPeerIDs are the node IDs to which a connection will be // (re)established ignoring any existing limits. UnconditionalPeerIDs string `mapstructure:"unconditional_peer_ids"` // PexReactor enables the peer-exchange reactor. PexReactor bool `mapstructure:"pex"` // AllowDuplicateIP permits peers connecting from the same IP. AllowDuplicateIP bool `mapstructure:"allow_duplicate_ip"` // HandshakeTimeout is the peer connection handshake timeout. HandshakeTimeout Duration `mapstructure:"handshake_timeout"` // DialTimeout is the peer connection establishment timeout. DialTimeout Duration `mapstructure:"dial_timeout"` // SeedMode makes the node constantly crawls the network looking for peers. // If another node asks it for addresses, it responds and disconnects. // Requires peer-exchange. SeedMode bool `mapstructure:"seed_mode"` // Seeds is a comma-separated separated list of seed nodes to query for peer // addresses. Only used if the peers in the address book are unreachable. Seeds string `mapstructure:"seeds"` }
type SnapshotConfig ¶
type StateSyncConfig ¶
type ValidatorParams ¶
type VersionParams ¶
type VersionParams struct {
App uint64 `json:"app"`
}
type VoteParams ¶
type VoteParams struct { // VoteExpiry is the number of blocks after which the resolution expires if // consensus is not reached. VoteExpiry int64 `json:"vote_expiry"` }