From 3ae52c2ece62402ab2d179eb105beb6e419a043b Mon Sep 17 00:00:00 2001 From: Bernd Mueller Date: Wed, 15 Nov 2023 11:47:41 +0100 Subject: [PATCH] Addressed review comments --- x/ccv/consumer/keeper/legacy_params.go | 2 +- x/ccv/consumer/keeper/params.go | 6 +----- x/ccv/consumer/types/keys.go | 3 ++- x/ccv/provider/client/cli/query.go | 10 +--------- x/ccv/provider/keeper/grpc_query.go | 8 ++++---- x/ccv/provider/types/keys.go | 3 ++- 6 files changed, 11 insertions(+), 21 deletions(-) diff --git a/x/ccv/consumer/keeper/legacy_params.go b/x/ccv/consumer/keeper/legacy_params.go index abbb2a8d35..81b5f331ae 100644 --- a/x/ccv/consumer/keeper/legacy_params.go +++ b/x/ccv/consumer/keeper/legacy_params.go @@ -11,7 +11,7 @@ import ( // Legacy: used for migration only! // GetConsumerParamsLegacy returns the params for the consumer ccv module from x/param subspace -// which will be depreacted soon +// which will be deprecated soon func (k Keeper) GetConsumerParamsLegacy(ctx sdk.Context, paramSpace paramtypes.Subspace) ccvtypes.Params { return ccvtypes.NewParams( getEnabled(ctx, paramSpace), diff --git a/x/ccv/consumer/keeper/params.go b/x/ccv/consumer/keeper/params.go index ce680e4860..a9e52b7b30 100644 --- a/x/ccv/consumer/keeper/params.go +++ b/x/ccv/consumer/keeper/params.go @@ -2,7 +2,6 @@ package keeper import ( "context" - "fmt" "time" sdk "github.com/cosmos/cosmos-sdk/types" @@ -18,10 +17,7 @@ func (k Keeper) GetConsumerParams(ctx sdk.Context) ccvtypes.Params { store := ctx.KVStore(k.storeKey) bz := store.Get(types.ParametersKey()) var params ccvtypes.Params - err := k.cdc.Unmarshal(bz, ¶ms) - if err != nil { - panic(fmt.Sprintf("error unmarshalling module parameters: %v:", err)) - } + k.cdc.MustUnmarshal(bz, ¶ms) return params } diff --git a/x/ccv/consumer/types/keys.go b/x/ccv/consumer/types/keys.go index 379f52246c..6226bf61e2 100644 --- a/x/ccv/consumer/types/keys.go +++ b/x/ccv/consumer/types/keys.go @@ -106,7 +106,7 @@ const ( // SlashRecordByteKey is the single byte key storing the consumer's slash record. SlashRecordByteKey - // ParametersKey is the is the single byte key for storing consumer's parameters. + // ParametersKey is the single byte key for storing consumer's parameters. ParametersByteKey // NOTE: DO NOT ADD NEW BYTE PREFIXES HERE WITHOUT ADDING THEM TO getAllKeyPrefixes() IN keys_test.go @@ -116,6 +116,7 @@ const ( // Fully defined key func section // +// ParametersKey returns the key for the consumer parameters in the store func ParametersKey() []byte { return []byte{ParametersByteKey} } diff --git a/x/ccv/provider/client/cli/query.go b/x/ccv/provider/client/cli/query.go index 119ee90b82..6dabfefb8b 100644 --- a/x/ccv/provider/client/cli/query.go +++ b/x/ccv/provider/client/cli/query.go @@ -363,15 +363,7 @@ func CmdProviderParams() *cobra.Command { cmd := &cobra.Command{ Use: "params [flags]", Short: "Query values set as provider parameters", - /* Long: strings.TrimSpace( - fmt.Sprintf(`Returns the registered consumer reward denoms. - Example: - $ %s query provider registered-consumer-reward-denoms - `, - version.AppName, - ), - ), */ - Args: cobra.NoArgs, + Args: cobra.NoArgs, RunE: func(cmd *cobra.Command, args []string) error { clientCtx, err := client.GetClientQueryContext(cmd) if err != nil { diff --git a/x/ccv/provider/keeper/grpc_query.go b/x/ccv/provider/keeper/grpc_query.go index 4e896525cc..09198e0e7d 100644 --- a/x/ccv/provider/keeper/grpc_query.go +++ b/x/ccv/provider/keeper/grpc_query.go @@ -230,9 +230,9 @@ func (k Keeper) QueryThrottledConsumerPacketData(goCtx context.Context, req *typ // getSlashPacketData fetches a slash packet data from the store using consumerChainId and ibcSeqNum (direct access) // If the returned bytes do not unmarshal to SlashPacketData, the data is considered not found. func (k Keeper) getSlashPacketData(ctx sdk.Context, consumerChainID string, ibcSeqNum uint64) (ccvtypes.SlashPacketData, bool) { - store := k.storeService.OpenKVStore(ctx) - bz, err := store.Get(types.ThrottledPacketDataKey(consumerChainID, ibcSeqNum)) - if err != nil || len(bz) == 0 { + store := ctx.KVStore(k.storeKey) + bz := store.Get(types.ThrottledPacketDataKey(consumerChainID, ibcSeqNum)) + if len(bz) == 0 { return ccvtypes.SlashPacketData{}, false } @@ -241,7 +241,7 @@ func (k Keeper) getSlashPacketData(ctx sdk.Context, consumerChainID string, ibcS } packet := ccvtypes.SlashPacketData{} - err = packet.Unmarshal(bz[1:]) + err := packet.Unmarshal(bz[1:]) if err != nil { // If the data cannot be unmarshaled, it is considered not found return ccvtypes.SlashPacketData{}, false diff --git a/x/ccv/provider/types/keys.go b/x/ccv/provider/types/keys.go index f34f29bc4c..643946258a 100644 --- a/x/ccv/provider/types/keys.go +++ b/x/ccv/provider/types/keys.go @@ -138,7 +138,7 @@ const ( // handled in the current block VSCMaturedHandledThisBlockBytePrefix - // ParametersKey is the is the single byte key for storing consumer's parameters. + // ParametersKey is the is the single byte key for storing provider's parameters. ParametersByteKey // NOTE: DO NOT ADD NEW BYTE PREFIXES HERE WITHOUT ADDING THEM TO getAllKeyPrefixes() IN keys_test.go @@ -148,6 +148,7 @@ const ( // Fully defined key func section // +// ParametersKey returns the key for the parameters of the provider module in the store func ParametersKey() []byte { return []byte{ParametersByteKey} }