feat(genutil): Allow manually setting the consensus key type in genesis (#24018)
Co-authored-by: Alex | Interchain Labs <alex@interchainlabs.io>
This commit is contained in:
parent
64d4cd125b
commit
3ac5b7c912
@ -45,6 +45,7 @@ Ref: https://keepachangelog.com/en/1.0.0/
|
||||
* Adds a `--timeout-timestamp` flag that allows users to specify a block time at which the unordered transactions should expire from the mempool.
|
||||
* (x/epochs) [#23815](https://github.com/cosmos/cosmos-sdk/pull/23815) Upstream `x/epochs` from Osmosis
|
||||
* (client) [#23811](https://github.com/cosmos/cosmos-sdk/pull/23811) Add auto cli for node service.
|
||||
* (genutil) [#24018](https://github.com/cosmos/cosmos-sdk/pull/24018) Allow manually setting the consensus key type in genesis
|
||||
|
||||
### Improvements
|
||||
|
||||
|
||||
@ -33,7 +33,7 @@ const (
|
||||
// private key representations used by RFC 8032.
|
||||
SeedSize = 32
|
||||
|
||||
keyType = "ed25519"
|
||||
KeyType = "ed25519"
|
||||
)
|
||||
|
||||
var (
|
||||
@ -91,7 +91,7 @@ func (privKey *PrivKey) Equals(other cryptotypes.LedgerPrivKey) bool {
|
||||
}
|
||||
|
||||
func (privKey *PrivKey) Type() string {
|
||||
return keyType
|
||||
return KeyType
|
||||
}
|
||||
|
||||
// MarshalAmino overrides Amino binary marshaling.
|
||||
@ -192,7 +192,7 @@ func (pubKey *PubKey) String() string {
|
||||
}
|
||||
|
||||
func (pubKey *PubKey) Type() string {
|
||||
return keyType
|
||||
return KeyType
|
||||
}
|
||||
|
||||
func (pubKey *PubKey) Equals(other cryptotypes.PubKey) bool {
|
||||
|
||||
@ -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"
|
||||
|
||||
@ -18,6 +19,7 @@ import (
|
||||
"github.com/cosmos/cosmos-sdk/client"
|
||||
"github.com/cosmos/cosmos-sdk/client/flags"
|
||||
"github.com/cosmos/cosmos-sdk/client/input"
|
||||
"github.com/cosmos/cosmos-sdk/crypto/keys/ed25519"
|
||||
"github.com/cosmos/cosmos-sdk/server"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
"github.com/cosmos/cosmos-sdk/types/module"
|
||||
@ -35,6 +37,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 {
|
||||
@ -160,8 +165,16 @@ func InitCmd(mbm module.BasicManager, defaultNodeHome string) *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")
|
||||
}
|
||||
@ -179,6 +192,7 @@ func InitCmd(mbm module.BasicManager, defaultNodeHome string) *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.KeyType, "algorithm to use for the consensus key")
|
||||
|
||||
return cmd
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user