From 525b2d5bbc2f12761c5b608957cae7d5e624fce9 Mon Sep 17 00:00:00 2001 From: likhita-809 Date: Thu, 8 Jul 2021 14:54:42 +0530 Subject: [PATCH 01/12] return MaxUint64 for Limit on InfiniteGasMeter and add a func to return GasLeft on GasMeter --- store/types/gas.go | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/store/types/gas.go b/store/types/gas.go index bf44e717d09..53121bb06f1 100644 --- a/store/types/gas.go +++ b/store/types/gas.go @@ -41,6 +41,7 @@ type ErrorGasOverflow struct { type GasMeter interface { GasConsumed() Gas GasConsumedToLimit() Gas + GasLeft() Gas Limit() Gas ConsumeGas(amount Gas, descriptor string) RefundGas(amount Gas, descriptor string) @@ -66,6 +67,10 @@ func (g *basicGasMeter) GasConsumed() Gas { return g.consumed } +func (g *basicGasMeter) GasLeft() Gas { + return g.limit - g.consumed +} + func (g *basicGasMeter) Limit() Gas { return g.limit } @@ -145,8 +150,12 @@ func (g *infiniteGasMeter) GasConsumedToLimit() Gas { return g.consumed } +func (g *infiniteGasMeter) GasLeft() Gas { + return math.MaxUint64 +} + func (g *infiniteGasMeter) Limit() Gas { - return 0 + return math.MaxUint64 } func (g *infiniteGasMeter) ConsumeGas(amount Gas, descriptor string) { From e8addcb96ffcdaa7cd4cbada9ac115105275a4f2 Mon Sep 17 00:00:00 2001 From: likhita-809 Date: Mon, 26 Jul 2021 21:13:12 +0530 Subject: [PATCH 02/12] add stakingBondDenom flag to init chain command --- x/genutil/client/cli/init.go | 46 +++++++++++++++++++++++++++++++++--- 1 file changed, 43 insertions(+), 3 deletions(-) diff --git a/x/genutil/client/cli/init.go b/x/genutil/client/cli/init.go index a51d4b90757..63573abf927 100644 --- a/x/genutil/client/cli/init.go +++ b/x/genutil/client/cli/init.go @@ -6,8 +6,8 @@ import ( "fmt" "os" "path/filepath" + "strings" - "github.com/cosmos/go-bip39" "github.com/pkg/errors" "github.com/spf13/cobra" cfg "github.com/tendermint/tendermint/config" @@ -23,6 +23,7 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/module" "github.com/cosmos/cosmos-sdk/x/genutil" + "github.com/cosmos/go-bip39" ) const ( @@ -31,6 +32,9 @@ const ( // FlagSeed defines a flag to initialize the private validator key from a specific seed. FlagRecover = "recover" + + // FlagStakingBondDenom defines a flag to specify the staking token in the genesis file. + FlagStakingBondDenom = "stakingBondDenom" ) type printInfo struct { @@ -110,12 +114,47 @@ func InitCmd(mbm module.BasicManager, defaultNodeHome string) *cobra.Command { genFile := config.GenesisFile() overwrite, _ := cmd.Flags().GetBool(FlagOverwrite) + stakingBondDenom, _ := cmd.Flags().GetString(FlagStakingBondDenom) + if !overwrite && tmos.FileExists(genFile) { return fmt.Errorf("genesis.json file already exists: %v", genFile) } - appState, err := json.MarshalIndent(mbm.DefaultGenesis(cdc), "", " ") + + var defaultGenesis map[string]json.RawMessage + + if stakingBondDenom != "" { + defaultGenesis = mbm.DefaultGenesis(cdc) + stakingRaw := defaultGenesis["staking"] + var initialStakingData, finalStakingdata interface{} + err = json.Unmarshal(stakingRaw, &initialStakingData) + if err != nil { + return err + } + stakingbz, err := json.Marshal(initialStakingData) + if err != nil { + return err + } + + stakingStr := string(stakingbz) + modifiedStakingStr := strings.Replace(stakingStr, "stake", stakingBondDenom, 1) + stakingbytes := []byte(modifiedStakingStr) + err = json.Unmarshal(stakingbytes, &finalStakingdata) + if err != nil { + return err + } + stakingResult, err := json.Marshal(finalStakingdata) + if err != nil { + return err + } + defaultGenesis["staking"] = stakingResult + + } else { + defaultGenesis = mbm.DefaultGenesis(cdc) + } + + appState, err := json.MarshalIndent(defaultGenesis, "", " ") if err != nil { - return errors.Wrap(err, "Failed to marshall default genesis state") + return errors.Wrap(err, "Failed to marshal default genesis state") } genDoc := &types.GenesisDoc{} @@ -148,6 +187,7 @@ func InitCmd(mbm module.BasicManager, defaultNodeHome string) *cobra.Command { cmd.Flags().BoolP(FlagOverwrite, "o", false, "overwrite the genesis.json file") cmd.Flags().Bool(FlagRecover, false, "provide seed phrase to recover existing key instead of creating") cmd.Flags().String(flags.FlagChainID, "", "genesis file chain-id, if left blank will be randomly created") + cmd.Flags().String(FlagStakingBondDenom, "", "genesis file staking bond_denom, if left blank default value is stake") return cmd } From 76a0de478501216b5ed92ba8676ac934b4eb680f Mon Sep 17 00:00:00 2001 From: likhita-809 Date: Mon, 26 Jul 2021 21:21:27 +0530 Subject: [PATCH 03/12] add changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 50af835d31d..d47b0e557f9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -68,6 +68,7 @@ Ref: https://keepachangelog.com/en/1.0.0/ ### CLI Breaking Changes +* [\#9776](https://github.com/cosmos/cosmos-sdk/pull/9776) Add flag `stakingBondDenom` to specify the staking bond_denom value when initializing a new chain. * [\#9246](https://github.com/cosmos/cosmos-sdk/pull/9246) Removed the CLI flag `--setup-config-only` from the `testnet` command and added the subcommand `init-files`. * [\#9371](https://github.com/cosmos/cosmos-sdk/pull/9371) Non-zero default fees/Server will error if there's an empty value for min-gas-price in app.toml From fef4eb3fd7edb7407e9df2a9e9b5d623fbca42c2 Mon Sep 17 00:00:00 2001 From: likhita-809 Date: Tue, 27 Jul 2021 15:24:18 +0530 Subject: [PATCH 04/12] add tests for stakingBondDenom --- x/genutil/client/cli/init_test.go | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/x/genutil/client/cli/init_test.go b/x/genutil/client/cli/init_test.go index b64d792c29f..fd8427988ed 100644 --- a/x/genutil/client/cli/init_test.go +++ b/x/genutil/client/cli/init_test.go @@ -118,6 +118,30 @@ func TestInitRecover(t *testing.T) { require.NoError(t, cmd.ExecuteContext(ctx)) } +func TestInitStakingBondDenom(t *testing.T) { + home := t.TempDir() + logger := log.NewNopLogger() + cfg, err := genutiltest.CreateDefaultTendermintConfig(home) + require.NoError(t, err) + + serverCtx := server.NewContext(viper.New(), cfg, logger) + interfaceRegistry := types.NewInterfaceRegistry() + marshaler := codec.NewProtoCodec(interfaceRegistry) + clientCtx := client.Context{}. + WithCodec(marshaler). + WithLegacyAmino(makeCodec()). + WithHomeDir(home) + + ctx := context.Background() + ctx = context.WithValue(ctx, client.ClientContextKey, &clientCtx) + ctx = context.WithValue(ctx, server.ServerContextKey, serverCtx) + + cmd := genutilcli.InitCmd(testMbm, home) + + cmd.SetArgs([]string{"appnode-test", fmt.Sprintf("--%s=%s --%s=testtoken", cli.HomeFlag, home, genutilcli.FlagStakingBondDenom)}) + require.NoError(t, cmd.ExecuteContext(ctx)) +} + func TestEmptyState(t *testing.T) { home := t.TempDir() logger := log.NewNopLogger() From 8d66eb6a721faf578ac65e796038bbad56faae8f Mon Sep 17 00:00:00 2001 From: likhita-809 Date: Tue, 27 Jul 2021 19:28:41 +0530 Subject: [PATCH 05/12] address review comments --- CHANGELOG.md | 2 +- x/genutil/client/cli/init.go | 19 ++++++++++++------- 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c50d3767039..9052a938668 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -68,7 +68,7 @@ Ref: https://keepachangelog.com/en/1.0.0/ ### CLI Breaking Changes -* [\#9776](https://github.com/cosmos/cosmos-sdk/pull/9776) Add flag `stakingBondDenom` to specify the staking bond_denom value when initializing a new chain. +* [\#9776](https://github.com/cosmos/cosmos-sdk/pull/9776) Add flag `staking-bond-denom` to specify the staking bond denomination value when initializing a new chain. * [\#9246](https://github.com/cosmos/cosmos-sdk/pull/9246) Removed the CLI flag `--setup-config-only` from the `testnet` command and added the subcommand `init-files`. * [\#9371](https://github.com/cosmos/cosmos-sdk/pull/9371) Non-zero default fees/Server will error if there's an empty value for min-gas-price in app.toml diff --git a/x/genutil/client/cli/init.go b/x/genutil/client/cli/init.go index f710e8e5004..76a551baa10 100644 --- a/x/genutil/client/cli/init.go +++ b/x/genutil/client/cli/init.go @@ -23,6 +23,7 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/module" "github.com/cosmos/cosmos-sdk/x/genutil" + stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" "github.com/cosmos/go-bip39" ) @@ -34,7 +35,7 @@ const ( FlagRecover = "recover" // FlagStakingBondDenom defines a flag to specify the staking token in the genesis file. - FlagStakingBondDenom = "stakingBondDenom" + FlagStakingBondDenom = "staking-bond-denom" ) type printInfo struct { @@ -128,18 +129,22 @@ func InitCmd(mbm module.BasicManager, defaultNodeHome string) *cobra.Command { if stakingBondDenom != "" { defaultGenesis = mbm.DefaultGenesis(cdc) - stakingRaw := defaultGenesis["staking"] - var initialStakingData, finalStakingdata interface{} - err = json.Unmarshal(stakingRaw, &initialStakingData) - if err != nil { + stakingRaw := defaultGenesis[stakingtypes.ModuleName] + var ( + initialStakingData interface{} + finalStakingdata interface{} + ) + + if err := json.Unmarshal(stakingRaw, &initialStakingData); err != nil { return err } - stakingbz, err := json.Marshal(initialStakingData) + + bz, err := json.Marshal(initialStakingData) if err != nil { return err } - stakingStr := string(stakingbz) + stakingStr := string(bz) modifiedStakingStr := strings.Replace(stakingStr, "stake", stakingBondDenom, 1) stakingbytes := []byte(modifiedStakingStr) err = json.Unmarshal(stakingbytes, &finalStakingdata) From 0d894c90d7574b8b39814cf3e512907347b5bdca Mon Sep 17 00:00:00 2001 From: likhita-809 Date: Wed, 28 Jul 2021 12:05:20 +0530 Subject: [PATCH 06/12] use tendermint json pkg for serializing data --- x/genutil/client/cli/init.go | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/x/genutil/client/cli/init.go b/x/genutil/client/cli/init.go index 76a551baa10..890fa8439eb 100644 --- a/x/genutil/client/cli/init.go +++ b/x/genutil/client/cli/init.go @@ -12,6 +12,7 @@ import ( "github.com/spf13/cobra" cfg "github.com/tendermint/tendermint/config" "github.com/tendermint/tendermint/libs/cli" + tmjson "github.com/tendermint/tendermint/libs/json" tmos "github.com/tendermint/tendermint/libs/os" tmrand "github.com/tendermint/tendermint/libs/rand" "github.com/tendermint/tendermint/types" @@ -135,11 +136,11 @@ func InitCmd(mbm module.BasicManager, defaultNodeHome string) *cobra.Command { finalStakingdata interface{} ) - if err := json.Unmarshal(stakingRaw, &initialStakingData); err != nil { + if err := tmjson.Unmarshal(stakingRaw, &initialStakingData); err != nil { return err } - bz, err := json.Marshal(initialStakingData) + bz, err := tmjson.Marshal(initialStakingData) if err != nil { return err } @@ -147,11 +148,11 @@ func InitCmd(mbm module.BasicManager, defaultNodeHome string) *cobra.Command { stakingStr := string(bz) modifiedStakingStr := strings.Replace(stakingStr, "stake", stakingBondDenom, 1) stakingbytes := []byte(modifiedStakingStr) - err = json.Unmarshal(stakingbytes, &finalStakingdata) + err = tmjson.Unmarshal(stakingbytes, &finalStakingdata) if err != nil { return err } - stakingResult, err := json.Marshal(finalStakingdata) + stakingResult, err := tmjson.Marshal(finalStakingdata) if err != nil { return err } From 370f51089e3c8aa63ae7b14211f3449380cd89e1 Mon Sep 17 00:00:00 2001 From: likhita-809 Date: Wed, 28 Jul 2021 12:45:20 +0530 Subject: [PATCH 07/12] fix something --- x/genutil/client/cli/init.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/x/genutil/client/cli/init.go b/x/genutil/client/cli/init.go index 890fa8439eb..514308f8a67 100644 --- a/x/genutil/client/cli/init.go +++ b/x/genutil/client/cli/init.go @@ -21,6 +21,7 @@ import ( "github.com/cosmos/cosmos-sdk/client/flags" "github.com/cosmos/cosmos-sdk/client/input" "github.com/cosmos/cosmos-sdk/server" + "github.com/cosmos/cosmos-sdk/simapp" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/module" "github.com/cosmos/cosmos-sdk/x/genutil" @@ -132,8 +133,8 @@ func InitCmd(mbm module.BasicManager, defaultNodeHome string) *cobra.Command { defaultGenesis = mbm.DefaultGenesis(cdc) stakingRaw := defaultGenesis[stakingtypes.ModuleName] var ( - initialStakingData interface{} - finalStakingdata interface{} + initialStakingData simapp.GenesisState + finalStakingdata simapp.GenesisState ) if err := tmjson.Unmarshal(stakingRaw, &initialStakingData); err != nil { From 73e72fddf13ce42974083db5f1e2beaa050db4ec Mon Sep 17 00:00:00 2001 From: likhita-809 Date: Wed, 28 Jul 2021 17:48:59 +0530 Subject: [PATCH 08/12] address review comments --- x/genutil/client/cli/init.go | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/x/genutil/client/cli/init.go b/x/genutil/client/cli/init.go index 514308f8a67..bb91ee6c580 100644 --- a/x/genutil/client/cli/init.go +++ b/x/genutil/client/cli/init.go @@ -127,11 +127,11 @@ func InitCmd(mbm module.BasicManager, defaultNodeHome string) *cobra.Command { return fmt.Errorf("genesis.json file already exists: %v", genFile) } - var defaultGenesis map[string]json.RawMessage + var stakingGenState map[string]json.RawMessage if stakingBondDenom != "" { - defaultGenesis = mbm.DefaultGenesis(cdc) - stakingRaw := defaultGenesis[stakingtypes.ModuleName] + stakingGenState = mbm.DefaultGenesis(cdc) + stakingRaw := stakingGenState[stakingtypes.ModuleName] var ( initialStakingData simapp.GenesisState finalStakingdata simapp.GenesisState @@ -157,13 +157,13 @@ func InitCmd(mbm module.BasicManager, defaultNodeHome string) *cobra.Command { if err != nil { return err } - defaultGenesis["staking"] = stakingResult + stakingGenState["staking"] = stakingResult } else { - defaultGenesis = mbm.DefaultGenesis(cdc) + stakingGenState = mbm.DefaultGenesis(cdc) } - appState, err := json.MarshalIndent(defaultGenesis, "", " ") + appState, err := json.MarshalIndent(stakingGenState, "", " ") if err != nil { return errors.Wrap(err, "Failed to marshal default genesis state") } @@ -198,7 +198,7 @@ func InitCmd(mbm module.BasicManager, defaultNodeHome string) *cobra.Command { cmd.Flags().BoolP(FlagOverwrite, "o", false, "overwrite the genesis.json file") cmd.Flags().Bool(FlagRecover, false, "provide seed phrase to recover existing key instead of creating") cmd.Flags().String(flags.FlagChainID, "", "genesis file chain-id, if left blank will be randomly created") - cmd.Flags().String(FlagStakingBondDenom, "", "genesis file staking bond_denom, if left blank default value is stake") + cmd.Flags().String(FlagStakingBondDenom, "", "genesis file staking bond denomination, if left blank default value is 'stake'") return cmd } From b54c08674d9d66b30d4e444cfd13e286a013ffc8 Mon Sep 17 00:00:00 2001 From: likhita-809 Date: Wed, 28 Jul 2021 17:53:23 +0530 Subject: [PATCH 09/12] address review 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 bb91ee6c580..348be683b34 100644 --- a/x/genutil/client/cli/init.go +++ b/x/genutil/client/cli/init.go @@ -157,7 +157,7 @@ func InitCmd(mbm module.BasicManager, defaultNodeHome string) *cobra.Command { if err != nil { return err } - stakingGenState["staking"] = stakingResult + stakingGenState[stakingtypes.ModuleName] = stakingResult } else { stakingGenState = mbm.DefaultGenesis(cdc) From 4df9b2b2bbb150ff7d2ff9cb18dec3429494ac1d Mon Sep 17 00:00:00 2001 From: likhita-809 Date: Wed, 28 Jul 2021 18:31:10 +0530 Subject: [PATCH 10/12] address one more 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 348be683b34..3e7e13deecf 100644 --- a/x/genutil/client/cli/init.go +++ b/x/genutil/client/cli/init.go @@ -147,7 +147,7 @@ func InitCmd(mbm module.BasicManager, defaultNodeHome string) *cobra.Command { } stakingStr := string(bz) - modifiedStakingStr := strings.Replace(stakingStr, "stake", stakingBondDenom, 1) + modifiedStakingStr := strings.Replace(stakingStr, sdk.DefaultBondDenom, stakingBondDenom, 1) stakingbytes := []byte(modifiedStakingStr) err = tmjson.Unmarshal(stakingbytes, &finalStakingdata) if err != nil { From 2e8b63e9e52ef828709c325c9de35d890a1c6a56 Mon Sep 17 00:00:00 2001 From: likhita-809 Date: Fri, 30 Jul 2021 15:33:00 +0530 Subject: [PATCH 11/12] apply review suggestions --- CHANGELOG.md | 2 +- x/genutil/client/cli/init.go | 41 +++++++----------------------------- 2 files changed, 9 insertions(+), 34 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 93b9d28089d..1e457867e24 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -39,6 +39,7 @@ Ref: https://keepachangelog.com/en/1.0.0/ ### Features +* [\#9776](https://github.com/cosmos/cosmos-sdk/pull/9776) Add flag `staking-bond-denom` to specify the staking bond denomination value when initializing a new chain. * [\#9533](https://github.com/cosmos/cosmos-sdk/pull/9533) Added a new gRPC method, `DenomOwners`, in `x/bank` to query for all account holders of a specific denomination. * (bank) [\#9618](https://github.com/cosmos/cosmos-sdk/pull/9618) Update bank.Metadata: add URI and URIHash attributes. * [\#9750](https://github.com/cosmos/cosmos-sdk/pull/9750) Emit events for tx signature and sequence, so clients can now query txs by signature (`tx.signature=''`) or by address and sequence combo (`tx.acc_seq='/'`). @@ -70,7 +71,6 @@ Ref: https://keepachangelog.com/en/1.0.0/ ### CLI Breaking Changes -* [\#9776](https://github.com/cosmos/cosmos-sdk/pull/9776) Add flag `staking-bond-denom` to specify the staking bond denomination value when initializing a new chain. * [\#9246](https://github.com/cosmos/cosmos-sdk/pull/9246) Removed the CLI flag `--setup-config-only` from the `testnet` command and added the subcommand `init-files`. * [\#9371](https://github.com/cosmos/cosmos-sdk/pull/9371) Non-zero default fees/Server will error if there's an empty value for min-gas-price in app.toml diff --git a/x/genutil/client/cli/init.go b/x/genutil/client/cli/init.go index 3e7e13deecf..0ea4c836faa 100644 --- a/x/genutil/client/cli/init.go +++ b/x/genutil/client/cli/init.go @@ -6,13 +6,11 @@ import ( "fmt" "os" "path/filepath" - "strings" "github.com/pkg/errors" "github.com/spf13/cobra" cfg "github.com/tendermint/tendermint/config" "github.com/tendermint/tendermint/libs/cli" - tmjson "github.com/tendermint/tendermint/libs/json" tmos "github.com/tendermint/tendermint/libs/os" tmrand "github.com/tendermint/tendermint/libs/rand" "github.com/tendermint/tendermint/types" @@ -21,7 +19,6 @@ import ( "github.com/cosmos/cosmos-sdk/client/flags" "github.com/cosmos/cosmos-sdk/client/input" "github.com/cosmos/cosmos-sdk/server" - "github.com/cosmos/cosmos-sdk/simapp" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/module" "github.com/cosmos/cosmos-sdk/x/genutil" @@ -127,43 +124,21 @@ func InitCmd(mbm module.BasicManager, defaultNodeHome string) *cobra.Command { return fmt.Errorf("genesis.json file already exists: %v", genFile) } - var stakingGenState map[string]json.RawMessage + appGenState := mbm.DefaultGenesis(cdc) if stakingBondDenom != "" { - stakingGenState = mbm.DefaultGenesis(cdc) - stakingRaw := stakingGenState[stakingtypes.ModuleName] - var ( - initialStakingData simapp.GenesisState - finalStakingdata simapp.GenesisState - ) - - if err := tmjson.Unmarshal(stakingRaw, &initialStakingData); err != nil { - return err - } - - bz, err := tmjson.Marshal(initialStakingData) - if err != nil { - return err - } - - stakingStr := string(bz) - modifiedStakingStr := strings.Replace(stakingStr, sdk.DefaultBondDenom, stakingBondDenom, 1) - stakingbytes := []byte(modifiedStakingStr) - err = tmjson.Unmarshal(stakingbytes, &finalStakingdata) - if err != nil { - return err - } - stakingResult, err := tmjson.Marshal(finalStakingdata) + stakingRaw := appGenState[stakingtypes.ModuleName] + var stakingGenesis stakingtypes.GenesisState + clientCtx.Codec.UnmarshalJSON(stakingRaw, &stakingGenesis) + stakingGenesis.Params.BondDenom = stakingBondDenom + modifiedStakingStr, err := clientCtx.Codec.MarshalJSON(&stakingGenesis) if err != nil { return err } - stakingGenState[stakingtypes.ModuleName] = stakingResult - - } else { - stakingGenState = mbm.DefaultGenesis(cdc) + appGenState[stakingtypes.ModuleName] = modifiedStakingStr } - appState, err := json.MarshalIndent(stakingGenState, "", " ") + appState, err := json.MarshalIndent(appGenState, "", " ") if err != nil { return errors.Wrap(err, "Failed to marshal default genesis state") } From e7821a168e88e2dcc253ac6fecc796945e86f10b Mon Sep 17 00:00:00 2001 From: likhita-809 Date: Fri, 30 Jul 2021 16:06:34 +0530 Subject: [PATCH 12/12] check for error on unmarshalJSONO --- x/genutil/client/cli/init.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/x/genutil/client/cli/init.go b/x/genutil/client/cli/init.go index 0ea4c836faa..87d1223f802 100644 --- a/x/genutil/client/cli/init.go +++ b/x/genutil/client/cli/init.go @@ -129,7 +129,10 @@ func InitCmd(mbm module.BasicManager, defaultNodeHome string) *cobra.Command { if stakingBondDenom != "" { stakingRaw := appGenState[stakingtypes.ModuleName] var stakingGenesis stakingtypes.GenesisState - clientCtx.Codec.UnmarshalJSON(stakingRaw, &stakingGenesis) + err := clientCtx.Codec.UnmarshalJSON(stakingRaw, &stakingGenesis) + if err != nil { + return err + } stakingGenesis.Params.BondDenom = stakingBondDenom modifiedStakingStr, err := clientCtx.Codec.MarshalJSON(&stakingGenesis) if err != nil {