From b9c020a83fe2548f4125f1e5526d0410837ce256 Mon Sep 17 00:00:00 2001 From: Simon Noetzlin Date: Wed, 4 Sep 2024 16:50:15 +0200 Subject: [PATCH] fix misbehaviour and double-signing CLI cmds + few nits --- .../ccv/provider/v1/query.proto | 4 ++-- x/ccv/provider/client/cli/tx.go | 21 ++++++++++--------- x/ccv/provider/types/msg.go | 7 ++++++- x/ccv/provider/types/query.pb.go | 4 ++-- 4 files changed, 21 insertions(+), 15 deletions(-) diff --git a/proto/interchain_security/ccv/provider/v1/query.proto b/proto/interchain_security/ccv/provider/v1/query.proto index e6b3c2d8d9..e63cf8e4c2 100644 --- a/proto/interchain_security/ccv/provider/v1/query.proto +++ b/proto/interchain_security/ccv/provider/v1/query.proto @@ -156,7 +156,7 @@ message QueryConsumerGenesisResponse { message QueryConsumerChainsRequest { // The phase of the consumer chains returned (optional) - // Registered=1|Initialized=2|Launched=3|Stopped=4|Deleted=5 + // All=0|Registered=1|Initialized=2|Launched=3|Stopped=4|Deleted=5 ConsumerPhase phase = 1; // The limit of consumer chains returned (optional) // default is 100 @@ -182,7 +182,7 @@ message Chain { repeated string allowlist = 7; // Corresponds to a list of provider consensus addresses of validators that CANNOT validate the consumer chain. repeated string denylist = 8; - // The phase the consumer chain (Registered=0|Initialized=1|FailedToLaunch=2|Launched=3|Stopped=4) + // The phase the consumer chain (Registered=1|Initialized=2|Launched=3|Stopped=4|Deleted=5) string phase = 9; // The metadata of the consumer chain ConsumerMetadata metadata = 10 [(gogoproto.nullable) = false ]; diff --git a/x/ccv/provider/client/cli/tx.go b/x/ccv/provider/client/cli/tx.go index 9a8a7e5046..03080fc8b3 100644 --- a/x/ccv/provider/client/cli/tx.go +++ b/x/ccv/provider/client/cli/tx.go @@ -1,12 +1,13 @@ package cli import ( - "cosmossdk.io/math" "encoding/json" "fmt" "os" "strings" + "cosmossdk.io/math" + ibctmtypes "github.com/cosmos/ibc-go/v8/modules/light-clients/07-tendermint" "github.com/spf13/cobra" @@ -47,7 +48,7 @@ func GetTxCmd() *cobra.Command { func NewAssignConsumerKeyCmd() *cobra.Command { cmd := &cobra.Command{ - Use: "assign-consensus-key [consumer-chain-id] [consumer-pubkey]", + Use: "assign-consensus-key [consumer-id] [consumer-pubkey]", Short: "assign a consensus public key to use for a consumer chain", Args: cobra.ExactArgs(2), RunE: func(cmd *cobra.Command, args []string) error { @@ -86,7 +87,7 @@ func NewAssignConsumerKeyCmd() *cobra.Command { func NewSubmitConsumerMisbehaviourCmd() *cobra.Command { cmd := &cobra.Command{ - Use: "submit-consumer-misbehaviour [misbehaviour]", + Use: "submit-consumer-misbehaviour [consumer-id] [misbehaviour]", Short: "submit an IBC misbehaviour for a consumer chain", Long: strings.TrimSpace( fmt.Sprintf(`Submit an IBC misbehaviour detected on a consumer chain. @@ -94,9 +95,9 @@ An IBC misbehaviour contains two conflicting IBC client headers, which are used The misbehaviour type definition can be found in the IBC client messages, see ibc-go/proto/ibc/core/client/v1/tx.proto. Example: -%s tx provider submit-consumer-misbehaviour [path/to/misbehaviour.json] --from node0 --home ../node0 --chain-id $CID +%s tx provider submit-consumer-misbehaviour [consumer-id] [path/to/misbehaviour.json] --from node0 --home ../node0 --chain-id $CID `, version.AppName)), - Args: cobra.ExactArgs(1), + Args: cobra.ExactArgs(2), RunE: func(cmd *cobra.Command, args []string) error { clientCtx, err := client.GetClientTxContext(cmd) if err != nil { @@ -122,7 +123,7 @@ Example: return fmt.Errorf("misbehaviour unmarshalling failed: %s", err) } - msg, err := types.NewMsgSubmitConsumerMisbehaviour(submitter, &misbehaviour) + msg, err := types.NewMsgSubmitConsumerMisbehaviour(args[0], submitter, &misbehaviour) if err != nil { return err } @@ -143,7 +144,7 @@ Example: func NewSubmitConsumerDoubleVotingCmd() *cobra.Command { cmd := &cobra.Command{ - Use: "submit-consumer-double-voting [evidence] [infraction_header]", + Use: "submit-consumer-double-voting [consumer-id] [evidence] [infraction_header]", Short: "submit a double voting evidence for a consumer chain", Long: strings.TrimSpace( fmt.Sprintf(`Submit a Tendermint duplicate vote evidence detected on a consumer chain with @@ -153,9 +154,9 @@ func NewSubmitConsumerDoubleVotingCmd() *cobra.Command { definition can be found in the IBC messages, see ibc-go/proto/ibc/lightclients/tendermint/v1/tendermint.proto. Example: -%s tx provider submit-consumer-double-voting [path/to/evidence.json] [path/to/infraction_header.json] --from node0 --home ../node0 --chain-id $CID +%s tx provider submit-consumer-double-voting [consumer-id] [path/to/evidence.json] [path/to/infraction_header.json] --from node0 --home ../node0 --chain-id $CID `, version.AppName)), - Args: cobra.ExactArgs(2), + Args: cobra.ExactArgs(3), RunE: func(cmd *cobra.Command, args []string) error { clientCtx, err := client.GetClientTxContext(cmd) if err != nil { @@ -192,7 +193,7 @@ Example: return fmt.Errorf("infraction IBC header unmarshalling failed: %s", err) } - msg, err := types.NewMsgSubmitConsumerDoubleVoting(submitter, &ev, &header) + msg, err := types.NewMsgSubmitConsumerDoubleVoting(args[0], submitter, &ev, &header) if err != nil { return err } diff --git a/x/ccv/provider/types/msg.go b/x/ccv/provider/types/msg.go index 0ce64b688a..78a75cc69a 100644 --- a/x/ccv/provider/types/msg.go +++ b/x/ccv/provider/types/msg.go @@ -3,10 +3,11 @@ package types import ( "encoding/json" "fmt" - cmttypes "github.com/cometbft/cometbft/types" "strconv" "strings" + cmttypes "github.com/cometbft/cometbft/types" + ibctmtypes "github.com/cosmos/ibc-go/v8/modules/light-clients/07-tendermint" errorsmod "cosmossdk.io/errors" @@ -126,12 +127,14 @@ func (msg *MsgChangeRewardDenoms) ValidateBasic() error { } func NewMsgSubmitConsumerMisbehaviour( + consumerId string, submitter sdk.AccAddress, misbehaviour *ibctmtypes.Misbehaviour, ) (*MsgSubmitConsumerMisbehaviour, error) { return &MsgSubmitConsumerMisbehaviour{ Submitter: submitter.String(), Misbehaviour: misbehaviour, + ConsumerId: consumerId, }, nil } @@ -148,6 +151,7 @@ func (msg MsgSubmitConsumerMisbehaviour) ValidateBasic() error { } func NewMsgSubmitConsumerDoubleVoting( + consumerId string, submitter sdk.AccAddress, ev *tmtypes.DuplicateVoteEvidence, header *ibctmtypes.Header, @@ -156,6 +160,7 @@ func NewMsgSubmitConsumerDoubleVoting( Submitter: submitter.String(), DuplicateVoteEvidence: ev, InfractionBlockHeader: header, + ConsumerId: consumerId, }, nil } diff --git a/x/ccv/provider/types/query.pb.go b/x/ccv/provider/types/query.pb.go index cc87ba0443..7ef6796493 100644 --- a/x/ccv/provider/types/query.pb.go +++ b/x/ccv/provider/types/query.pb.go @@ -128,7 +128,7 @@ func (m *QueryConsumerGenesisResponse) GetGenesisState() types.ConsumerGenesisSt type QueryConsumerChainsRequest struct { // The phase of the consumer chains returned (optional) - // Registered=1|Initialized=2|Launched=3|Stopped=4|Deleted=5 + // All=0|Registered=1|Initialized=2|Launched=3|Stopped=4|Deleted=5 Phase ConsumerPhase `protobuf:"varint,1,opt,name=phase,proto3,enum=interchain_security.ccv.provider.v1.ConsumerPhase" json:"phase,omitempty"` // The limit of consumer chains returned (optional) // default is 100 @@ -243,7 +243,7 @@ type Chain struct { Allowlist []string `protobuf:"bytes,7,rep,name=allowlist,proto3" json:"allowlist,omitempty"` // Corresponds to a list of provider consensus addresses of validators that CANNOT validate the consumer chain. Denylist []string `protobuf:"bytes,8,rep,name=denylist,proto3" json:"denylist,omitempty"` - // The phase the consumer chain (Registered=0|Initialized=1|FailedToLaunch=2|Launched=3|Stopped=4) + // The phase the consumer chain (Registered=1|Initialized=2|Launched=3|Stopped=4|Deleted=5) Phase string `protobuf:"bytes,9,opt,name=phase,proto3" json:"phase,omitempty"` // The metadata of the consumer chain Metadata ConsumerMetadata `protobuf:"bytes,10,opt,name=metadata,proto3" json:"metadata"`