Documentation
¶
Overview ¶
Package genutil contains a variety of genesis utility functionality for usage within a blockchain application. Namely:
- Genesis transactions related (gentx)
- Commands for collection and creation of gentxs
- `InitChain` processing of gentxs
- Genesis file validation
- Genesis file migration
- CometBFT related initialization (Translation of an app genesis to a CometBFT genesis)
Index ¶
- func AddGenesisAccount(cdc codec.Codec, accAddr sdk.AccAddress, appendAcct bool, ...) error
- func AddGenesisAccounts(cdc codec.Codec, ac address.Codec, accounts []GenesisAccount, appendAcct bool, ...) error
- func CollectTxs(cdc codec.JSONCodec, txJSONDecoder sdk.TxDecoder, moniker, genTxsDir string, ...) (appGenTxs []sdk.Tx, persistentPeers string, err error)
- func DeliverGenTxs(ctx sdk.Context, genTxs []json.RawMessage, stakingKeeper types.StakingKeeper, ...) ([]abci.ValidatorUpdate, error)
- func ExportGenesisFile(genesis *types.AppGenesis, genFile string) error
- func ExportGenesisFileWithTime(genFile string, appGenesis *types.AppGenesis, genTime time.Time) error
- func GenAppStateFromConfig(cdc codec.JSONCodec, txEncodingConfig client.TxEncodingConfig, ...) (appState json.RawMessage, err error)
- func InitGenesis(ctx sdk.Context, stakingKeeper types.StakingKeeper, ...) (validators []abci.ValidatorUpdate, err error)
- func InitializeNodeValidatorFiles(config *cfg.Config) (nodeID string, valPubKey cryptotypes.PubKey, err error)
- func InitializeNodeValidatorFilesFromMnemonic(config *cfg.Config, mnemonic string) (nodeID string, valPubKey cryptotypes.PubKey, err error)
- func InitializeNodeValidatorFilesFromMnemonicWithKeyType(config *cfg.Config, mnemonic, keyType string) (nodeID string, valPubKey cryptotypes.PubKey, err error)
- func NewAppModule(accountKeeper types.AccountKeeper, stakingKeeper types.StakingKeeper, ...) module.GenesisOnlyAppModule
- func ProvideModule(in ModuleInputs) appmodule.AppModule
- func SetGenTxsInAppGenesisState(cdc codec.JSONCodec, txJSONEncoder sdk.TxEncoder, ...) (map[string]json.RawMessage, error)
- func ValidateAccountInGenesis(appGenesisState map[string]json.RawMessage, ...) error
- type AppModule
- func (AppModule) ConsensusVersion() uint64
- func (am AppModule) ExportGenesis(_ sdk.Context, cdc codec.JSONCodec) json.RawMessage
- func (am AppModule) InitGenesis(ctx sdk.Context, cdc codec.JSONCodec, data json.RawMessage) []abci.ValidatorUpdate
- func (AppModule) IsAppModule()
- func (AppModule) IsOnePerModuleType()
- type AppModuleBasic
- func (AppModuleBasic) DefaultGenesis(cdc codec.JSONCodec) json.RawMessage
- func (AppModuleBasic) Name() string
- func (AppModuleBasic) RegisterGRPCGatewayRoutes(_ client.Context, _ *gwruntime.ServeMux)
- func (b AppModuleBasic) RegisterInterfaces(cdctypes.InterfaceRegistry)
- func (AppModuleBasic) RegisterLegacyAminoCodec(cdc *codec.LegacyAmino)
- func (b AppModuleBasic) ValidateGenesis(cdc codec.JSONCodec, txEncodingConfig client.TxEncodingConfig, ...) error
- type GenesisAccount
- type ModuleInputs
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AddGenesisAccount ¶ added in v0.50.0
func AddGenesisAccount( cdc codec.Codec, accAddr sdk.AccAddress, appendAcct bool, genesisFileURL, amountStr, vestingAmtStr string, vestingStart, vestingEnd int64, moduleName string, ) error
AddGenesisAccount adds a genesis account to the genesis state. Where `cdc` is client codec, `genesisFileUrl` is the path/url of current genesis file, `accAddr` is the address to be added to the genesis state, `amountStr` is the list of initial coins to be added for the account, `appendAcct` updates the account if already exists. `vestingStart, vestingEnd and vestingAmtStr` respectively are the schedule start time, end time (unix epoch) `moduleName“ is the module name for which the account is being created and coins to be appended to the account already in the genesis.json file.
func AddGenesisAccounts ¶ added in v0.50.10
func AddGenesisAccounts( cdc codec.Codec, ac address.Codec, accounts []GenesisAccount, appendAcct bool, genesisFileURL string, ) error
AddGenesisAccounts adds genesis accounts to the genesis state. Where `cdc` is the client codec, `accounts` are the genesis accounts to add, `appendAcct` updates the account if already exists, and `genesisFileURL` is the path/url of the current genesis file.
func CollectTxs ¶ added in v0.40.0
func CollectTxs(cdc codec.JSONCodec, txJSONDecoder sdk.TxDecoder, moniker, genTxsDir string, genesis *types.AppGenesis, genBalIterator types.GenesisBalancesIterator, validator types.MessageValidator, valAddrCodec sdkruntime.ValidatorAddressCodec, ) (appGenTxs []sdk.Tx, persistentPeers string, err error)
CollectTxs processes and validates application's genesis Txs and returns the list of appGenTxs, and persistent peers required to generate genesis.json.
func DeliverGenTxs ¶
func DeliverGenTxs( ctx sdk.Context, genTxs []json.RawMessage, stakingKeeper types.StakingKeeper, deliverTx genesis.TxHandler, txEncodingConfig client.TxEncodingConfig, ) ([]abci.ValidatorUpdate, error)
DeliverGenTxs iterates over all genesis txs, decodes each into a Tx and invokes the provided deliverTxfn with the decoded Tx. It returns the result of the staking module's ApplyAndReturnValidatorSetUpdates.
func ExportGenesisFile ¶
func ExportGenesisFile(genesis *types.AppGenesis, genFile string) error
ExportGenesisFile creates and writes the genesis configuration to disk. An error is returned if building or writing the configuration to file fails.
func ExportGenesisFileWithTime ¶
func ExportGenesisFileWithTime(genFile string, appGenesis *types.AppGenesis, genTime time.Time) error
ExportGenesisFileWithTime overwrites the genesis file at genFile with appGenesis, applying genTime as the genesis time. All other fields on appGenesis (validators, consensus params, app state, app hash, initial height, etc.) are preserved as the caller set them.
func GenAppStateFromConfig ¶
func GenAppStateFromConfig(cdc codec.JSONCodec, txEncodingConfig client.TxEncodingConfig, config *cfg.Config, initCfg types.InitConfig, genesis *types.AppGenesis, genBalIterator types.GenesisBalancesIterator, validator types.MessageValidator, valAddrCodec sdkruntime.ValidatorAddressCodec, ) (appState json.RawMessage, err error)
GenAppStateFromConfig gets the genesis app state from the config
func InitGenesis ¶
func InitGenesis( ctx sdk.Context, stakingKeeper types.StakingKeeper, deliverTx genesis.TxHandler, genesisState types.GenesisState, txEncodingConfig client.TxEncodingConfig, ) (validators []abci.ValidatorUpdate, err error)
InitGenesis - initialize accounts and deliver genesis transactions
func InitializeNodeValidatorFiles ¶
func InitializeNodeValidatorFiles(config *cfg.Config) (nodeID string, valPubKey cryptotypes.PubKey, err error)
InitializeNodeValidatorFiles creates private validator and p2p configuration files.
func InitializeNodeValidatorFilesFromMnemonic ¶ added in v0.40.0
func InitializeNodeValidatorFilesFromMnemonic(config *cfg.Config, mnemonic string) (nodeID string, valPubKey cryptotypes.PubKey, err error)
InitializeNodeValidatorFilesFromMnemonic creates private validator and p2p configuration files using the given mnemonic. If no valid mnemonic is given, a random one will be used instead.
func InitializeNodeValidatorFilesFromMnemonicWithKeyType ¶ added in v0.55.0
func InitializeNodeValidatorFilesFromMnemonicWithKeyType( config *cfg.Config, mnemonic, keyType string, ) (nodeID string, valPubKey cryptotypes.PubKey, err error)
InitializeNodeValidatorFilesFromMnemonicWithKeyType is a sibling of InitializeNodeValidatorFilesFromMnemonic that lets callers choose the validator consensus-key algorithm. Recognized keyType values are "ed25519", "secp256k1", "bls12_381", "ml_dsa_65", and "" (which is treated as ed25519, delegating to the original function so behavior is byte-for-byte unchanged for callers that don't opt in).
This function exists separately from InitializeNodeValidatorFilesFromMnemonic so the latter remains backwards compatible. Use this from test harnesses (e.g. testutil/network) that need to spin up validators backed by a non-default signature scheme.
func NewAppModule ¶
func NewAppModule(accountKeeper types.AccountKeeper, stakingKeeper types.StakingKeeper, deliverTx genesis.TxHandler, txEncodingConfig client.TxEncodingConfig, ) module.GenesisOnlyAppModule
NewAppModule creates a new AppModule object
func ProvideModule ¶ added in v0.47.0
func ProvideModule(in ModuleInputs) appmodule.AppModule
func SetGenTxsInAppGenesisState ¶
func SetGenTxsInAppGenesisState( cdc codec.JSONCodec, txJSONEncoder sdk.TxEncoder, appGenesisState map[string]json.RawMessage, genTxs []sdk.Tx, ) (map[string]json.RawMessage, error)
SetGenTxsInAppGenesisState - sets the genesis transactions in the app genesis state
func ValidateAccountInGenesis ¶
func ValidateAccountInGenesis( appGenesisState map[string]json.RawMessage, genBalIterator types.GenesisBalancesIterator, addr sdk.Address, coins sdk.Coins, cdc codec.JSONCodec, ) error
ValidateAccountInGenesis checks that the provided account has a sufficient balance in the set of genesis accounts.
Types ¶
type AppModule ¶
type AppModule struct {
AppModuleBasic
// contains filtered or unexported fields
}
AppModule implements an application module for the genutil module.
func (AppModule) ConsensusVersion ¶ added in v0.43.0
ConsensusVersion implements AppModule/ConsensusVersion.
func (AppModule) ExportGenesis ¶
ExportGenesis returns the exported genesis state as raw bytes for the genutil module.
func (AppModule) InitGenesis ¶
func (am AppModule) InitGenesis(ctx sdk.Context, cdc codec.JSONCodec, data json.RawMessage) []abci.ValidatorUpdate
InitGenesis performs genesis initialization for the genutil module.
func (AppModule) IsAppModule ¶ added in v0.47.0
func (AppModule) IsAppModule()
IsAppModule implements the appmodule.AppModule interface.
func (AppModule) IsOnePerModuleType ¶ added in v0.47.0
func (AppModule) IsOnePerModuleType()
IsOnePerModuleType implements the depinject.OnePerModuleType interface.
type AppModuleBasic ¶
type AppModuleBasic struct {
GenTxValidator types.MessageValidator
}
AppModuleBasic defines the basic application module used by the genutil module.
func NewAppModuleBasic ¶ added in v0.47.0
func NewAppModuleBasic(validator types.MessageValidator) AppModuleBasic
NewAppModuleBasic creates AppModuleBasic, validator is a function used to validate genesis transactions.
func (AppModuleBasic) DefaultGenesis ¶
func (AppModuleBasic) DefaultGenesis(cdc codec.JSONCodec) json.RawMessage
DefaultGenesis returns default genesis state as raw bytes for the genutil module.
func (AppModuleBasic) Name ¶
func (AppModuleBasic) Name() string
Name returns the genutil module's name.
func (AppModuleBasic) RegisterGRPCGatewayRoutes ¶ added in v0.40.0
func (AppModuleBasic) RegisterGRPCGatewayRoutes(_ client.Context, _ *gwruntime.ServeMux)
RegisterGRPCGatewayRoutes registers the gRPC Gateway routes for the genutil module.
func (AppModuleBasic) RegisterInterfaces ¶ added in v0.40.0
func (b AppModuleBasic) RegisterInterfaces(cdctypes.InterfaceRegistry)
RegisterInterfaces registers the module's interface types
func (AppModuleBasic) RegisterLegacyAminoCodec ¶ added in v0.40.0
func (AppModuleBasic) RegisterLegacyAminoCodec(cdc *codec.LegacyAmino)
RegisterLegacyAminoCodec registers the genutil module's types on the given LegacyAmino codec.
func (AppModuleBasic) ValidateGenesis ¶
func (b AppModuleBasic) ValidateGenesis(cdc codec.JSONCodec, txEncodingConfig client.TxEncodingConfig, bz json.RawMessage) error
ValidateGenesis performs genesis state validation for the genutil module.
type GenesisAccount ¶ added in v0.50.10
type GenesisAccount struct {
// Base
Address string `json:"address"`
Coins sdk.Coins `json:"coins"`
// Vesting
VestingAmt sdk.Coins `json:"vesting_amt,omitempty"`
VestingStart int64 `json:"vesting_start,omitempty"`
VestingEnd int64 `json:"vesting_end,omitempty"`
// Module
ModuleName string `json:"module_name,omitempty"`
}
type ModuleInputs ¶ added in v0.50.0
type ModuleInputs struct {
depinject.In
AccountKeeper types.AccountKeeper
StakingKeeper types.StakingKeeper
DeliverTx genesis.TxHandler
Config client.TxConfig
}
ModuleInputs defines the inputs needed for the genutil module.