Skip to content

Commit

Permalink
feat(genutil): allow manually setting the consensus key type in genes…
Browse files Browse the repository at this point in the history
…is. (cosmos#19971)

Co-authored-by: Marko <[email protected]>
Co-authored-by: marbar3778 <[email protected]>
  • Loading branch information
3 people authored Apr 30, 2024
1 parent 128bb96 commit abb2994
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ Every module contains its own CHANGELOG.md. Please refer to the module you are i
* (x/consensus) [#19483](https://github.com/cosmos/cosmos-sdk/pull/19483) Add consensus messages registration to consensus module.
* (types) [#19759](https://github.com/cosmos/cosmos-sdk/pull/19759) Align SignerExtractionAdapter in PriorityNonceMempool Remove.
* (client) [#19870](https://github.com/cosmos/cosmos-sdk/pull/19870) Add new query command `wait-tx`. Alias `event-query-tx-for` to `wait-tx` for backward compatibility.
* (genutil) [#19971](https://github.com/cosmos/cosmos-sdk/pull/19971) Allow manually setting the consensus key type in genesis

### Improvements

Expand Down
12 changes: 12 additions & 0 deletions x/genutil/client/cli/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"path/filepath"

cfg "github.com/cometbft/cometbft/config"
cmttypes "github.com/cometbft/cometbft/types"
"github.com/cosmos/go-bip39"
"github.com/spf13/cobra"

Expand All @@ -35,6 +36,9 @@ const (

// FlagDefaultBondDenom defines the default denom to use in the genesis file.
FlagDefaultBondDenom = "default-denom"

// FlagConsensusKeyAlgo defines the algorithm to use for the consensus signing key.
FlagConsensusKeyAlgo = "consensus-key-algo"
)

type printInfo struct {
Expand Down Expand Up @@ -158,7 +162,14 @@ func InitCmd(mm *module.Manager) *cobra.Command {
appGenesis.InitialHeight = initHeight
appGenesis.Consensus = &types.ConsensusGenesis{
Validators: nil,
Params: cmttypes.DefaultConsensusParams(),
}

consensusKey, err := cmd.Flags().GetString(FlagConsensusKeyAlgo)
if err != nil {
return errorsmod.Wrap(err, "Failed to get consensus key algo")
}
appGenesis.Consensus.Params.Validator.PubKeyTypes = []string{consensusKey}

if err = genutil.ExportGenesisFile(appGenesis, genFile); err != nil {
return errorsmod.Wrap(err, "Failed to export genesis file")
Expand All @@ -176,6 +187,7 @@ func InitCmd(mm *module.Manager) *cobra.Command {
cmd.Flags().String(flags.FlagChainID, "", "genesis file chain-id, if left blank will be randomly created")
cmd.Flags().String(FlagDefaultBondDenom, "", "genesis file default denomination, if left blank default value is 'stake'")
cmd.Flags().Int64(flags.FlagInitHeight, 1, "specify the initial block height at genesis")
cmd.Flags().String(FlagConsensusKeyAlgo, "ed25519", "algorithm to use for the consensus key")

return cmd
}

0 comments on commit abb2994

Please sign in to comment.