From 977a2cb4207369c7e75d26202e4df60e4d48907d Mon Sep 17 00:00:00 2001 From: itsdevbear Date: Sat, 6 Apr 2024 15:24:43 -0400 Subject: [PATCH 1/6] bet --- x/genutil/client/cli/init.go | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/x/genutil/client/cli/init.go b/x/genutil/client/cli/init.go index da33a1060b29..4b01570df635 100644 --- a/x/genutil/client/cli/init.go +++ b/x/genutil/client/cli/init.go @@ -35,6 +35,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,6 +163,12 @@ func InitCmd(mm *module.Manager) *cobra.Command { Validators: nil, } + 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 +185,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 (ed25519 or secp256k1)") return cmd } From 61fb733599aad9b331ba870a035a0eab531884e5 Mon Sep 17 00:00:00 2001 From: itsdevbear Date: Sat, 6 Apr 2024 15:25:28 -0400 Subject: [PATCH 2/6] update comment --- x/genutil/client/cli/init.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/x/genutil/client/cli/init.go b/x/genutil/client/cli/init.go index 4b01570df635..52af47f3068b 100644 --- a/x/genutil/client/cli/init.go +++ b/x/genutil/client/cli/init.go @@ -185,7 +185,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 (ed25519 or secp256k1)") + cmd.Flags().String(FlagConsensusKeyAlgo, "ed25519", "algorithm to use for the consensus key") return cmd } From 8cf122d29966857ed268c82d3b04a4648ce79007 Mon Sep 17 00:00:00 2001 From: itsdevbear Date: Sat, 13 Apr 2024 16:56:24 -0400 Subject: [PATCH 3/6] changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7a146f35db77..b87fe794b297 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 From 050516233be2055b0cae740675ca6887e7456d6f Mon Sep 17 00:00:00 2001 From: itsdevbear Date: Sat, 13 Apr 2024 17:23:15 -0400 Subject: [PATCH 4/6] fix --- x/genutil/client/cli/init.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/x/genutil/client/cli/init.go b/x/genutil/client/cli/init.go index 52af47f3068b..2a954983add9 100644 --- a/x/genutil/client/cli/init.go +++ b/x/genutil/client/cli/init.go @@ -15,6 +15,7 @@ import ( errorsmod "cosmossdk.io/errors" "cosmossdk.io/math/unsafe" + cmttypes "github.com/cometbft/cometbft/types" "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/client/flags" "github.com/cosmos/cosmos-sdk/client/input" @@ -161,6 +162,9 @@ func InitCmd(mm *module.Manager) *cobra.Command { appGenesis.InitialHeight = initHeight appGenesis.Consensus = &types.ConsensusGenesis{ Validators: nil, + Params: &cmttypes.ConsensusParams{ + Validator: cmttypes.ValidatorParams{}, + }, } consensusKey, err := cmd.Flags().GetString(FlagConsensusKeyAlgo) From ed8613bd7da19418866457d9def2086bc765709f Mon Sep 17 00:00:00 2001 From: itsdevbear Date: Sat, 13 Apr 2024 17:36:42 -0400 Subject: [PATCH 5/6] fix --- x/genutil/client/cli/init.go | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/x/genutil/client/cli/init.go b/x/genutil/client/cli/init.go index 2a954983add9..91fd96215661 100644 --- a/x/genutil/client/cli/init.go +++ b/x/genutil/client/cli/init.go @@ -162,9 +162,7 @@ func InitCmd(mm *module.Manager) *cobra.Command { appGenesis.InitialHeight = initHeight appGenesis.Consensus = &types.ConsensusGenesis{ Validators: nil, - Params: &cmttypes.ConsensusParams{ - Validator: cmttypes.ValidatorParams{}, - }, + Params: cmttypes.DefaultConsensusParams(), } consensusKey, err := cmd.Flags().GetString(FlagConsensusKeyAlgo) From b7afe7a56df80739797982194120cf70cea1fd88 Mon Sep 17 00:00:00 2001 From: marbar3778 Date: Tue, 30 Apr 2024 14:36:14 +0200 Subject: [PATCH 6/6] linting --- simapp/app_di.go | 2 +- simapp/upgrades.go | 1 + x/genutil/client/cli/init.go | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/simapp/app_di.go b/simapp/app_di.go index 2630778ebbc2..997565a4b1dc 100644 --- a/simapp/app_di.go +++ b/simapp/app_di.go @@ -306,7 +306,7 @@ func NewSimApp( return app } -// overwritte default ante handlers with custom ante handlers +// overwrite default ante handlers with custom ante handlers // set SkipAnteHandler to true in app config and set custom ante handler on baseapp func (app *SimApp) setCustomAnteHandler() { anteHandler, err := NewAnteHandler( diff --git a/simapp/upgrades.go b/simapp/upgrades.go index 4351e99f1063..ed6d35c0b490 100644 --- a/simapp/upgrades.go +++ b/simapp/upgrades.go @@ -8,6 +8,7 @@ import ( epochstypes "cosmossdk.io/x/epochs/types" protocolpooltypes "cosmossdk.io/x/protocolpool/types" upgradetypes "cosmossdk.io/x/upgrade/types" + "github.com/cosmos/cosmos-sdk/types/module" crisistypes "github.com/cosmos/cosmos-sdk/x/crisis/types" ) diff --git a/x/genutil/client/cli/init.go b/x/genutil/client/cli/init.go index 91fd96215661..2765eafc9acb 100644 --- a/x/genutil/client/cli/init.go +++ b/x/genutil/client/cli/init.go @@ -9,13 +9,13 @@ import ( "path/filepath" cfg "github.com/cometbft/cometbft/config" + cmttypes "github.com/cometbft/cometbft/types" "github.com/cosmos/go-bip39" "github.com/spf13/cobra" errorsmod "cosmossdk.io/errors" "cosmossdk.io/math/unsafe" - cmttypes "github.com/cometbft/cometbft/types" "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/client/flags" "github.com/cosmos/cosmos-sdk/client/input"