Skip to content

Commit

Permalink
feat(simapp): move genesis related commands under one genesis comma…
Browse files Browse the repository at this point in the history
…nd (cosmos#14149)
  • Loading branch information
pysel committed Dec 7, 2022
1 parent 8d791e1 commit 4cf99e9
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 212 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,14 @@ in this testnet.
two names can be anything, but you will need to use the same "chain id" in the following steps.
4. `$ ./simd keys add [key_name]`. This will create a new key, with a name of your choosing.
Save the output of this command somewhere; you'll need the address generated here later.
5. `$ ./simd add-genesis-account [key_name] [amount]`, where `key_name` is the same key name as
5. `$ ./simd genesis add-genesis-account [key_name] [amount]`, where `key_name` is the same key name as
before; and `amount` is something like `10000000000000000000000000stake`.
6. `$ ./simd gentx [key_name] [amount] --chain-id [chain-id]`. This will create the genesis
6. `$ ./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 your node.
7. Now, one person needs to create the genesis file `genesis.json` using the genesis transactions
from every participant, by gathering all the genesis transactions under `config/gentx` and then
calling `$ ./simd collect-gentxs`. This will create a new `genesis.json` file that includes data
calling `$ ./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).
8. Once you've received the super genesis file, overwrite your original `genesis.json` file with
Expand Down
87 changes: 0 additions & 87 deletions simd/cmd/genaccounts.go

This file was deleted.

111 changes: 0 additions & 111 deletions simd/cmd/genaccounts_test.go

This file was deleted.

23 changes: 12 additions & 11 deletions simd/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,7 @@ import (
"github.com/cosmos/cosmos-sdk/x/auth/types"
banktypes "github.com/cosmos/cosmos-sdk/x/bank/types"
"github.com/cosmos/cosmos-sdk/x/crisis"
"github.com/cosmos/cosmos-sdk/x/genutil"
genutilcli "github.com/cosmos/cosmos-sdk/x/genutil/client/cli"
genutiltypes "github.com/cosmos/cosmos-sdk/x/genutil/types"
)

// NewRootCmd creates a new root command for simd. It is called once in the
Expand Down Expand Up @@ -165,17 +163,9 @@ lru_size = 0`
func initRootCmd(rootCmd *cobra.Command, encodingConfig params.EncodingConfig) {
cfg := sdk.GetConfig()
cfg.Seal()
gentxModule := simapp.ModuleBasics[genutiltypes.ModuleName].(genutil.AppModuleBasic)

rootCmd.AddCommand(
genutilcli.InitCmd(simapp.ModuleBasics, simapp.DefaultNodeHome),
genutilcli.CollectGenTxsCmd(banktypes.GenesisBalancesIterator{}, simapp.DefaultNodeHome,
gentxModule.GenTxValidator),
genutilcli.MigrateGenesisCmd(),
genutilcli.GenTxCmd(simapp.ModuleBasics, encodingConfig.TxConfig,
banktypes.GenesisBalancesIterator{}, simapp.DefaultNodeHome),
genutilcli.ValidateGenesisCmd(simapp.ModuleBasics),
AddGenesisAccountCmd(simapp.DefaultNodeHome),
NewTestnetCmd(simapp.ModuleBasics, banktypes.GenesisBalancesIterator{}),
debug.Cmd(),
config.Cmd(),
Expand All @@ -184,9 +174,10 @@ func initRootCmd(rootCmd *cobra.Command, encodingConfig params.EncodingConfig) {

server.AddCommands(rootCmd, simapp.DefaultNodeHome, newApp, appExport, addModuleInitFlags)

// add keybase, auxiliary RPC, query, and tx child commands
// add keybase, auxiliary RPC, query, genesis, and tx child commands
rootCmd.AddCommand(
rpc.StatusCommand(),
genesisCommand(encodingConfig),
queryCommand(),
txCommand(),
keys.Commands(simapp.DefaultNodeHome),
Expand All @@ -200,6 +191,16 @@ func addModuleInitFlags(startCmd *cobra.Command) {
crisis.AddModuleInitFlags(startCmd)
}

// genesisCommand builds genesis-related `simd genesis` command. Users may provide application specific commands as a parameter
func genesisCommand(encodingConfig params.EncodingConfig, cmds ...*cobra.Command) *cobra.Command {
cmd := genutilcli.GenesisCoreCommand(encodingConfig.TxConfig, simapp.ModuleBasics, simapp.DefaultNodeHome)

for _, sub_cmd := range cmds {
cmd.AddCommand(sub_cmd)
}
return cmd
}

func queryCommand() *cobra.Command {
cmd := &cobra.Command{
Use: "query",
Expand Down

0 comments on commit 4cf99e9

Please sign in to comment.