From a5d36aee6da6a92ea341240e60cfbec6775d095b Mon Sep 17 00:00:00 2001 From: Simon Noetzlin Date: Tue, 19 Dec 2023 10:08:49 +0100 Subject: [PATCH 1/2] fix: `submit-consumer-misbehaviour` command in the provider module CLI (#1496) * fix misbehaviour cli fix * fix nits (cherry picked from commit 5b0307c05de6cfd7b2232a558e178c181e3a9f34) --- x/ccv/provider/client/cli/tx.go | 18 ++++++++++++++---- x/ccv/provider/types/codec.go | 6 ++++++ 2 files changed, 20 insertions(+), 4 deletions(-) diff --git a/x/ccv/provider/client/cli/tx.go b/x/ccv/provider/client/cli/tx.go index 78fbaaf9df..d0495cfe0d 100644 --- a/x/ccv/provider/client/cli/tx.go +++ b/x/ccv/provider/client/cli/tx.go @@ -12,6 +12,7 @@ import ( "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/client/flags" "github.com/cosmos/cosmos-sdk/client/tx" + "github.com/cosmos/cosmos-sdk/codec" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/version" @@ -101,11 +102,18 @@ Example: txf = txf.WithTxConfig(clientCtx.TxConfig).WithAccountRetriever(clientCtx.AccountRetriever) submitter := clientCtx.GetFromAddress() - var misbehaviour ibctmtypes.Misbehaviour - if err := clientCtx.Codec.UnmarshalInterfaceJSON([]byte(args[1]), &misbehaviour); err != nil { + misbJson, err := os.ReadFile(args[0]) + if err != nil { return err } + cdc := codec.NewProtoCodec(clientCtx.InterfaceRegistry) + + misbehaviour := ibctmtypes.Misbehaviour{} + if err := cdc.UnmarshalJSON(misbJson, &misbehaviour); err != nil { + return fmt.Errorf("misbehaviour unmarshalling failed: %s", err) + } + msg, err := types.NewMsgSubmitConsumerMisbehaviour(submitter, &misbehaviour) if err != nil { return err @@ -164,13 +172,15 @@ Example: return fmt.Errorf("duplicate vote evidence unmarshalling failed: %s", err) } - headerRaw, err := os.ReadFile(args[1]) + headerJson, err := os.ReadFile(args[1]) if err != nil { return err } + cdc := codec.NewProtoCodec(clientCtx.InterfaceRegistry) + header := ibctmtypes.Header{} - if err := types.ModuleCdc.UnmarshalJSON(headerRaw, &header); err != nil { + if err := cdc.UnmarshalJSON(headerJson, &header); err != nil { return fmt.Errorf("infraction IBC header unmarshalling failed: %s", err) } diff --git a/x/ccv/provider/types/codec.go b/x/ccv/provider/types/codec.go index d1b9203efb..6ab621f0e1 100644 --- a/x/ccv/provider/types/codec.go +++ b/x/ccv/provider/types/codec.go @@ -6,6 +6,8 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/msgservice" govv1beta1 "github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1" + "github.com/cosmos/ibc-go/v7/modules/core/exported" + tendermint "github.com/cosmos/ibc-go/v7/modules/light-clients/07-tendermint" ) // RegisterLegacyAminoCodec registers the necessary x/ibc transfer interfaces and concrete types @@ -43,6 +45,10 @@ func RegisterInterfaces(registry codectypes.InterfaceRegistry) { (*sdk.Msg)(nil), &MsgSubmitConsumerDoubleVoting{}, ) + registry.RegisterImplementations( + (*exported.ClientMessage)(nil), + &tendermint.Misbehaviour{}, + ) msgservice.RegisterMsgServiceDesc(registry, &_Msg_serviceDesc) } From e6ebf76debc6aefa8d44297dafaa4cb54d396fe6 Mon Sep 17 00:00:00 2001 From: Simon Noetzlin Date: Tue, 19 Dec 2023 10:35:30 +0100 Subject: [PATCH 2/2] lint --- x/ccv/provider/types/codec.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/x/ccv/provider/types/codec.go b/x/ccv/provider/types/codec.go index 6ab621f0e1..e5900bcf04 100644 --- a/x/ccv/provider/types/codec.go +++ b/x/ccv/provider/types/codec.go @@ -1,13 +1,14 @@ package types import ( + "github.com/cosmos/ibc-go/v7/modules/core/exported" + tendermint "github.com/cosmos/ibc-go/v7/modules/light-clients/07-tendermint" + "github.com/cosmos/cosmos-sdk/codec" codectypes "github.com/cosmos/cosmos-sdk/codec/types" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/msgservice" govv1beta1 "github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1" - "github.com/cosmos/ibc-go/v7/modules/core/exported" - tendermint "github.com/cosmos/ibc-go/v7/modules/light-clients/07-tendermint" ) // RegisterLegacyAminoCodec registers the necessary x/ibc transfer interfaces and concrete types