feat(genutil): allow manually setting the consensus key type in genesis. (#19971)

Co-authored-by: Marko <marko@baricevic.me>
Co-authored-by: marbar3778 <marbar3778@yahoo.com>
This commit is contained in:
Devon Bear 2024-04-30 08:45:36 -04:00 committed by GitHub
parent 128bb968b2
commit abb2994a8f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 13 additions and 0 deletions

View File

@ -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

View File

@ -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"
@ -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 {
@ -158,8 +162,15 @@ 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")
}
@ -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
}