package
0.53.0-beta.2
Repository: https://github.com/cosmos/cosmos-sdk.git
Documentation: pkg.go.dev

# README

x/genutil

Concepts

The genutil package contains a variety 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 creation
  • Genesis file validation
  • Genesis file migration
  • CometBFT related initialization
    • Translation of an app genesis to a CometBFT genesis
  • Application state export into a genesis file

Genesis

Genutil contains the data structure that defines an application genesis. An application genesis consist of a consensus genesis (g.e. CometBFT genesis) and application related genesis data.

https://github.com/cosmos/cosmos-sdk/blob/v0.50.0-rc.0/x/genutil/types/genesis.go#L24-L34

The application genesis can then be translated to the consensus engine to the right format:

https://github.com/cosmos/cosmos-sdk/blob/v0.50.0-rc.0/x/genutil/types/genesis.go#L126-L136
https://github.com/cosmos/cosmos-sdk/blob/v0.50.0-rc.0/server/start.go#L397-L407

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]

:::tip The migrate command is extensible and takes a MigrationMap. This map is a mapping of target versions to genesis migrations functions. When not using the default MigrationMap, it is recommended to still call the default MigrationMap corresponding the SDK version of the chain and prepend/append your own genesis migrations. :::

validate-genesis

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

simd genesis validate-genesis

:::warning Validate genesis only validates if the genesis is valid at the current application binary. For validating a genesis from a previous version of the application, use the migrate command to migrate the genesis to the current version. :::

export

Export state to genesis file.

simd genesis export

Some flags are available to customize the export:

  • --for-zero-height: export the genesis file for a chain with zero height
  • --height [height]: export the genesis file for a chain with a given height

Read the help for more information.

# Packages

No description provided by the author
No description provided by the author
Package testutil is a generated GoMock package.
No description provided by the author
v2 contains logic and CLI used for genutil by server/v2 / runtime/v2 applications.

# Functions

AddGenesisAccounts adds genesis accounts to the genesis state.
AddGenesisAccountsWithGenesis modifies the provided appState by adding the provided genesis accounts.
CollectTxs processes and validates application's genesis Txs and returns the list of appGenTxs, and persistent peers required to generate genesis.json.
DeliverGenTxs iterates over all genesis txs, decodes each into a Tx and invokes the provided deliverTxfn with the decoded Tx.
ExportGenesisFile creates and writes the genesis configuration to disk.
ExportGenesisFileWithTime creates and writes the genesis configuration to disk.
GenAppStateFromConfig gets the genesis app state from the config.
InitGenesis - initialize accounts and deliver genesis transactions NOTE: It isn't used in server/v2 applications.
InitializeNodeValidatorFiles creates private validator and p2p configuration files.
InitializeNodeValidatorFilesFromMnemonic creates private validator and p2p configuration files using the given mnemonic.
NewAppModule creates a new AppModule object.
No description provided by the author
SetGenTxsInAppGenesisState - sets the genesis transactions in the app genesis state.
ValidateAccountInGenesis checks that the provided account has a sufficient balance in the set of genesis accounts.

# Structs

AppModule implements an application module for the genutil module.
No description provided by the author
ModuleInputs defines the inputs needed for the genutil module.

# Interfaces

TxHandler is an interface that defines how genesis txs are handled.