config

package
v0.10.0-beta-1 Latest Latest
Warning

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

Go to latest
Published: Jan 27, 2025 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ConfigFileName  = "config.toml"
	GenesisFileName = "genesis.json"

	DefaultAdminRPCAddr = "/tmp/kwild.socket"
	AdminCertName       = "admin.cert"
)
View Source
const (
	NodeKeyFileName = "nodekey.json"
)

Variables

View Source
var (
	ErrorExtraFields = errors.New("unrecognized fields")
)

Functions

func ABCIDir

func ABCIDir(rootDir string) string

ABCIDir returns the directory where the ABCI node's data is stored

func ABCIInfoDir

func ABCIInfoDir(rootDir string) string

ABCIInfoDir returns the directory where the ABCI node's info is stored

func ConfigFilePath

func ConfigFilePath(rootDir string) string

ConfigFilePath returns the path to the config file

func DecodePubKeyAndType

func DecodePubKeyAndType(encodedPubKey string) ([]byte, crypto.KeyType, error)

func EncodePubKeyAndType

func EncodePubKeyAndType(pubKey []byte, pubKeyType crypto.KeyType) string

func FormatAccountID

func FormatAccountID(acctID *types.AccountID) string

func GenesisFilePath

func GenesisFilePath(rootDir string) string

func GenesisStateFileName

func GenesisStateFileName(rootDir string) string

GenesisStateFileName returns the genesis state file in the root directory.

func LocalSnapshotsDir

func LocalSnapshotsDir(rootDir string) string

LocalSnapshotsDir returns the directory where snapshots taken by the local node are stored

func MigrationDir

func MigrationDir(rootDir string) string

MigrationDir returns the directory where the node's migrations are stored

func NodeKeyFilePath

func NodeKeyFilePath(rootDir string) string

func ReceivedSnapshotsDir

func ReceivedSnapshotsDir(rootDir string) string

ReceivedSnapshotsDir returns the directory where snapshots are received

func SigningDir

func SigningDir(rootDir string) string

SigningDir returns the directory where the ABCI node's signing keys are stored

Types

type AdminConfig

type AdminConfig struct {
	Enable        bool   `toml:"enable" comment:"enable the admin RPC service"`
	ListenAddress string `toml:"listen" comment:"address in host:port format or UNIX socket path on which the admin RPC server will listen"`
	Pass          string `toml:"pass" comment:"optional password for the admin service"`
	NoTLS         bool   `toml:"notls" comment:"disable TLS when the listen address is not a loopback IP or UNIX socket"`
	TLSCertFile   string `toml:"cert" comment:"TLS certificate for use with a non-loopback listen address when notls is not true"`
	TLSKeyFile    string `toml:"key" comment:"TLS key for use with a non-loopback listen address when notls is not true"`
}

type Config

type Config struct {
	LogLevel  log.Level  `toml:"log_level" comment:"log level\npossible values: 'debug', 'info', 'warn', and 'error'"`
	LogFormat log.Format `toml:"log_format" comment:"log format\npossible values: 'json', 'text' (kv), and 'plain' (fmt-style)"`
	LogOutput []string   `toml:"log_output" comment:"output paths for the log"`

	ProfileMode string `toml:"profile_mode,commented" comment:"profile mode (http, cpu, mem, mutex, or block)"`
	ProfileFile string `toml:"profile_file,commented" comment:"profile output file path (e.g. cpu.pprof)"`

	P2P          PeerConfig                   `toml:"p2p" comment:"P2P related configuration"`
	Consensus    ConsensusConfig              `toml:"consensus" comment:"Consensus related configuration"`
	DB           DBConfig                     `toml:"db" comment:"DB (PostgreSQL) related configuration"`
	RPC          RPCConfig                    `toml:"rpc" comment:"User RPC service configuration"`
	Admin        AdminConfig                  `toml:"admin" comment:"Admin RPC service configuration"`
	Snapshots    SnapshotConfig               `toml:"snapshots" comment:"Snapshot creation and provider configuration"`
	StateSync    StateSyncConfig              `toml:"state_sync" comment:"Statesync configuration (vs block sync)"`
	Extensions   map[string]map[string]string `toml:"extensions" comment:"extension configuration"`
	GenesisState string                       `toml:"genesis_state" comment:"path to the genesis state file, relative to the root directory"`
	Migrations   MigrationConfig              `toml:"migrations" comment:"zero downtime migration configuration"`
}

Config is the node's config.

func DefaultConfig

func DefaultConfig() *Config

DefaultConfig generates an instance of the default config.

func LoadConfig

func LoadConfig(filename string) (*Config, error)

func (*Config) FromTOML

func (nc *Config) FromTOML(b []byte) error

func (*Config) SaveAs

func (nc *Config) SaveAs(filename string) error

SaveAs writes the Config to the specified TOML file.

func (Config) ToTOML

func (nc Config) ToTOML() ([]byte, error)

ToTOML marshals the config to TOML. The `toml` struct field tag specifies the field names. For example:

Enable  bool  `toml:"enable,commented" comment:"enable the thing"`

The above field will be written like:

# enable the thing
#enable=false

type ConsensusConfig

type ConsensusConfig struct {
	ProposeTimeout types.Duration `` /* 212-byte string literal not displayed */

	EmptyBlockTimeout types.Duration `` /* 193-byte string literal not displayed */

	// BlockProposalInterval is the interval between block proposal reannouncements by the leader.
	// This affects the time it takes for an out-of-sync validator to receive the current block proposal,
	// thereby impacting the block times. Default is 1 second.
	BlockProposalInterval types.Duration `toml:"block_proposal_interval" comment:"interval between block proposal reannouncements by the leader"`

	// BlockAnnInterval is the frequency with which the block commit messages are reannounced by the leader,
	// and votes reannounced by validators. Default is 3 seconds. This affects the time it takes for
	// out-of-sync nodes to catch up with the latest block.
	BlockAnnInterval types.Duration `` /* 136-byte string literal not displayed */
}

type DBConfig

type DBConfig struct {
	// 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.
	Host          string         `toml:"host" comment:"postgres host name (IP or UNIX socket path)"`
	Port          string         `toml:"port" comment:"postgres TCP port (leave empty for UNIX socket)"`
	User          string         `toml:"user" comment:"postgres role/user name"`
	Pass          string         `toml:"pass" comment:"postgres password if required for the user and host"`
	DBName        string         `toml:"dbname" comment:"postgres database name"`
	ReadTxTimeout types.Duration `toml:"read_timeout" comment:"timeout on read transactions from user RPC calls and queries"`
	MaxConns      uint32         `toml:"max_connections" comment:"maximum number of DB connections to permit"`
}

type GenesisAlloc

type GenesisAlloc struct {
	ID      KeyHexBytes `json:"id"`
	KeyType string      `json:"key_type"`
	Amount  *big.Int    `json:"amount"`
}

type GenesisConfig

type GenesisConfig struct {
	ChainID       string `json:"chain_id"`
	InitialHeight int64  `json:"initial_height"`
	// Validators is the list of genesis validators (including the leader).
	Validators []*types.Validator `json:"validators"`

	// StateHash is the hash of the initial state of the chain, used when bootstrapping
	// the chain with a network snapshot during migration.
	StateHash types.HexBytes `json:"state_hash,omitempty"` // TODO: make it a *types.Hash

	// Alloc is the initial allocation of balances.
	Allocs []GenesisAlloc `json:"alloc,omitempty"`

	// Migration specifies the migration configuration required for zero downtime migration.
	Migration MigrationParams `json:"migration"`

	// NetworkParameters are network level configurations that can be
	// evolved over the lifetime of a network.
	types.NetworkParameters
}

func DefaultGenesisConfig

func DefaultGenesisConfig() *GenesisConfig

func LoadGenesisConfig

func LoadGenesisConfig(filename string) (*GenesisConfig, error)

func (*GenesisConfig) SanityChecks

func (gc *GenesisConfig) SanityChecks() error

func (*GenesisConfig) SaveAs

func (nc *GenesisConfig) SaveAs(filename string) error

type KeyHexBytes

type KeyHexBytes struct{ types.HexBytes }

KeyHexBytes wraps hex bytes, and allows it to receive Ethereum 0x addresses

func (*KeyHexBytes) MarshalJSON

func (l *KeyHexBytes) MarshalJSON() ([]byte, error)

func (*KeyHexBytes) UnmarshalJSON

func (l *KeyHexBytes) UnmarshalJSON(b []byte) error

type MigrationConfig

type MigrationConfig struct {
	Enable      bool   `toml:"enable" comment:"enable zero downtime migrations"`
	MigrateFrom string `toml:"migrate_from" comment:"JSON-RPC listening address of the node to replicate the state from"`
}

type MigrationParams

type MigrationParams struct {
	// StartHeight is the height from which the state from the old chain is to be migrated.
	StartHeight int64 `json:"start_height"`
	// EndHeight is the height till which the state from the old chain is to be migrated.
	EndHeight int64 `json:"end_height"`
}

MigrationParams is the migration configuration required for zero downtime migration. The height values refer to the height of the old/from chain.

func (*MigrationParams) IsMigration

func (m *MigrationParams) IsMigration() bool

type PeerConfig

type PeerConfig struct {
	ListenAddress     string   `toml:"listen" comment:"address in host:port format to listen on for P2P connections"`
	Pex               bool     `toml:"pex" comment:"enable peer exchange"`
	BootNodes         []string `toml:"bootnodes" comment:"bootnodes to connect to on startup"`
	PrivateMode       bool     `toml:"private" comment:"operate in private mode using a node ID whitelist"`
	Whitelist         []string `toml:"whitelist" comment:"allowed node IDs when in private mode"`
	TargetConnections int      `toml:"target_connections" comment:"target number of connections to maintain"`
}

PeerConfig corresponds to the [p2p] section of the config.

type RPCConfig

type RPCConfig struct {
	ListenAddress      string         `toml:"listen" comment:"address in host:port format on which the RPC server will listen"`
	BroadcastTxTimeout types.Duration `` /* 127-byte string literal not displayed */
	Timeout            types.Duration `toml:"timeout" comment:"user request duration limit after which it is cancelled"`
	MaxReqSize         int            `toml:"max_req_size" comment:"largest permissible user request size"`
	Private            bool           `toml:"private" comment:"enable private mode that requires challenge authentication for each call"`
	ChallengeExpiry    types.Duration `toml:"challenge_expiry" comment:"lifetime of a server-generated challenge"`
	ChallengeRateLimit float64        `toml:"challenge_rate_limit" comment:"maximum number of challenges per second that a user can request"`
}

type SnapshotConfig

type SnapshotConfig struct {
	Enable          bool   `toml:"enable" comment:"enable creating and providing snapshots for peers using statesync"`
	RecurringHeight uint64 `toml:"recurring_height" comment:"snapshot creation period in blocks"`
	MaxSnapshots    uint64 `toml:"max_snapshots" comment:"number of snapshots to keep, after the oldest is removed when creating a new one"`
}

type StateSyncConfig

type StateSyncConfig struct {
	Enable           bool     `toml:"enable" comment:"enable using statesync rather than blocksync"`
	TrustedProviders []string `toml:"trusted_providers" comment:"trusted snapshot providers in node ID format (see bootnodes)"`

	DiscoveryTimeout types.Duration `toml:"discovery_time" comment:"how long to discover snapshots before selecting one to use"`
	MaxRetries       uint64         `toml:"max_retries" comment:"how many times to try after failing to apply a snapshot before switching to blocksync"`
}

Jump to

Keyboard shortcuts

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