Documentation ¶
Overview ¶
Package chain defines kwild's chain configuration types that model the genesis.json document. This is distinct from application runtime configuration (see config.toml) that does not affect consensus.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var Forks *forks.Forks
Forks is a singleton instance of the hardforks parsed from a GenesisConfig. This is a convenience to provide global access to loaded hardfork configuration to other packages used in an application. The application should set this following LoadGenesisConfig, and prior to starting operations that rely on the config.
Functions ¶
Types ¶
type ABCIParams ¶
type ABCIParams struct {
VoteExtensionsEnableHeight int64 `json:"vote_extensions_enable_height"`
}
type BaseConsensusParams ¶
type BaseConsensusParams struct { Block BlockParams `json:"block"` Evidence EvidenceParams `json:"evidence"` Validator ValidatorParams `json:"validator"` Votes VoteParams `json:"votes"` ABCI ABCIParams `json:"abci"` Migration MigrationParams `json:"migration"` }
type BlockParams ¶
type BlockParams struct { MaxBytes int64 `json:"max_bytes"` MaxGas int64 `json:"max_gas"` // AbciBlockSizeHandling indicates to give cometbft MaxBytes=-1 so it is the // ABCI application's job to respect MaxBytes when preparing block // proposals. If false, cometbft will limit the number of transactions // offered to ABCI. AbciBlockSizeHandling bool `json:"abci_max_bytes"` // if true, give -1 to consensus engine, and abci validator enforces instead }
type ConsensusParams ¶
type ConsensusParams struct { BaseConsensusParams // This is unchangeable after genesis. WithoutGasCosts bool `json:"without_gas_costs"` }
ConsensusParams combines BaseConsensusParams with WithoutGasCosts.
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"` // ForkHeights is a map of named forks to activation heights. This is a map // to support forks defined by extensions. Use the Forks method to get a // Forks structure containing named fields for the canonical forks. ForkHeights map[string]*uint64 `json:"activations"` // e.g. {"activations": {"longhorn": 12220000}} ConsensusParams *ConsensusParams `json:"consensus_params,omitempty"` Validators []*GenesisValidator `json:"validators,omitempty"` }
GenesisConfig is the genesis chain configuration. Use LoadGenesisConfig to load from a JSON file and populate the ForkHeights field.
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 (gc *GenesisConfig) ComputeGenesisHash() []byte
ComputeGenesisHash constructs the 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. The app hash in the genesis file corresponds to the initial database state.
CometBFT internally hashes specific fields from the ConsensusParams, but doesn't automatically validates the rest of the fields.
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) Forks ¶
func (gc *GenesisConfig) Forks() *forks.Forks
Forks creates a forks.Forks instance from the ForkHeights map field.
func (*GenesisConfig) SanityChecks ¶ added in v0.9.0
func (gc *GenesisConfig) SanityChecks() error
func (*GenesisConfig) SaveAs ¶
func (gc *GenesisConfig) SaveAs(file string) error
SaveAs writes the genesis config to a file.
type GenesisValidator ¶
type MigrationParams ¶ added in v0.9.0
type MigrationParams struct { // StartHeight is the height from which the state from the old chain is to be migrated. StartHeight int64 `json:"start_height,omitempty"` // EndHeight is the height till which the state from the old chain is to be migrated. EndHeight int64 `json:"end_height,omitempty"` }
func (*MigrationParams) IsMigration ¶ added in v0.9.0
func (m *MigrationParams) IsMigration() bool
IsMigration returns true if the migration parameters are set.
type ValidatorParams ¶
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"` // MaxVotesPerTx is the maximum number of votes to include in the voteID and voteBody transactions. MaxVotesPerTx int64 `json:"max_votes_per_tx"` }