-
Notifications
You must be signed in to change notification settings - Fork 3.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(genutil): allow manually setting the consensus key type in genesis. #19971
Changes from all commits
977a2cb
61fb733
80c5125
8cf122d
0505162
ed8613b
4b7892d
965b6ea
b7afe7a
0b4e5a7
3aff845
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -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,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} | ||||||||||||||||||||||||||||
Comment on lines
+168
to
+172
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Proper error handling is implemented for the + if consensusKey != "ed25519" && consensusKey != "secp256k1" {
+ return errorsmod.Wrapf(errors.New("invalid consensus key algorithm"), "Invalid consensus key algo: %s", consensusKey)
+ } Committable suggestion
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. the consensus key is validated in the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @alpe, thank you for clarifying the validation process for the consensus key in the 🐰 New Learnings Added
|
||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||
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 | ||||||||||||||||||||||||||||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The changelog entry clearly communicates the addition of the new feature allowing manual setting of the consensus key type during genesis. However, consider adding more detail about the impact or benefits of this change to provide better context for users.
Committable suggestion