genutil

package
v0.0.0-...-095f669 Latest Latest
Warning

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

Go to latest
Published: Mar 7, 2023 License: Apache-2.0 Imports: 31 Imported by: 5

README

x/genutil

Concepts

The genutil package contains a variaety of genesis utility functionalities 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

Client

CLI

The genutil commands are available under the genesis subcommand.

add-genesis-account

Add a genesis account to genesis.json. Learn more here.

collect-gentxs

Collect genesis txs and output a genesis.json file.

simd genesis collect-gentxs

This will create a new genesis.json file that includes data from all the validators (we sometimes call it the "super genesis file" to distinguish it from single-validator genesis files).

gentx

Generate a genesis tx carrying a self delegation.

simd genesis gentx [key_name] [amount] --chain-id [chain-id]

This will create the genesis transaction for your new chain. Here amount should be at least 1000000000stake. If you provide too much or too little, you will encounter an error when starting a node.

migrate

Migrate genesis to a specified target (SDK) version.

simd genesis migrate [target-version]
validate-genesis

Validates the genesis file at the default location or at the location passed as an argument.

simd genesis validate-genesis

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

Constants

This section is empty.

Variables

This section is empty.

Functions

func CollectTxs

func CollectTxs(cdc codec.JSONCodec, txJSONDecoder sdk.TxDecoder, moniker, genTxsDir string,
	genesis *types.AppGenesis, genBalIterator types.GenesisBalancesIterator,
	validator types.MessageValidator,
) (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 deliverTxfn,
	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, chainID string, validators []cmttypes.GenesisValidator, appState json.RawMessage, genTime time.Time) error

ExportGenesisFileWithTime creates and writes the genesis configuration to disk. An error is returned if building or writing the configuration to file fails.

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,
) (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 deliverTxfn, 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

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 NewAppModule

func NewAppModule(accountKeeper types.AccountKeeper,
	stakingKeeper types.StakingKeeper, deliverTx deliverTxfn,
	txEncodingConfig client.TxEncodingConfig,
) module.GenesisOnlyAppModule

NewAppModule creates a new AppModule object

func ProvideModule

func ProvideModule(in GenutilInputs) 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

func (AppModule) ConsensusVersion() uint64

ConsensusVersion implements AppModule/ConsensusVersion.

func (AppModule) ExportGenesis

func (am AppModule) ExportGenesis(_ sdk.Context, cdc codec.JSONCodec) json.RawMessage

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

func (AppModule) IsAppModule()

IsAppModule implements the appmodule.AppModule interface.

func (AppModule) IsOnePerModuleType

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

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) GetQueryCmd

func (AppModuleBasic) GetQueryCmd() *cobra.Command

GetQueryCmd returns no root query command for the genutil module.

func (AppModuleBasic) GetTxCmd

func (AppModuleBasic) GetTxCmd() *cobra.Command

GetTxCmd returns no root tx command for the genutil module.

func (AppModuleBasic) Name

func (AppModuleBasic) Name() string

Name returns the genutil module's name.

func (AppModuleBasic) RegisterGRPCGatewayRoutes

func (AppModuleBasic) RegisterGRPCGatewayRoutes(_ client.Context, _ *gwruntime.ServeMux)

RegisterGRPCGatewayRoutes registers the gRPC Gateway routes for the genutil module.

func (AppModuleBasic) RegisterInterfaces

func (b AppModuleBasic) RegisterInterfaces(_ cdctypes.InterfaceRegistry)

RegisterInterfaces registers the module's interface types

func (AppModuleBasic) RegisterLegacyAminoCodec

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 GenutilInputs

type GenutilInputs struct {
	depinject.In

	AccountKeeper types.AccountKeeper
	StakingKeeper types.StakingKeeper
	DeliverTx     func(abci.RequestDeliverTx) abci.ResponseDeliverTx
	Config        client.TxConfig
}

GenutilInputs defines the inputs needed for the genutil module.

Directories

Path Synopsis
client
cli
migrations
Package testutil is a generated GoMock package.
Package testutil is a generated GoMock package.

Jump to

Keyboard shortcuts

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