Skip to content

Commit

Permalink
fix: submit-consumer-misbehaviour command in the provider module CL…
Browse files Browse the repository at this point in the history
…I (backport #1496) (#1525)

* fix: `submit-consumer-misbehaviour` command in the provider module CLI (#1496)

* fix misbehaviour cli fix

* fix nits

(cherry picked from commit 5b0307c)

* lint

---------

Co-authored-by: Simon Noetzlin <[email protected]>
  • Loading branch information
mergify[bot] and sainoe authored Dec 19, 2023
1 parent 44e9fc7 commit 2ccb10a
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 4 deletions.
18 changes: 14 additions & 4 deletions x/ccv/provider/client/cli/tx.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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)
}

Expand Down
7 changes: 7 additions & 0 deletions x/ccv/provider/types/codec.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
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"
Expand Down Expand Up @@ -43,6 +46,10 @@ func RegisterInterfaces(registry codectypes.InterfaceRegistry) {
(*sdk.Msg)(nil),
&MsgSubmitConsumerDoubleVoting{},
)
registry.RegisterImplementations(
(*exported.ClientMessage)(nil),
&tendermint.Misbehaviour{},
)
msgservice.RegisterMsgServiceDesc(registry, &_Msg_serviceDesc)
}

Expand Down

0 comments on commit 2ccb10a

Please sign in to comment.