Skip to content

Commit

Permalink
fix misbehaviour and double-signing CLI cmds + few nits
Browse files Browse the repository at this point in the history
  • Loading branch information
sainoe committed Sep 4, 2024
1 parent b275fa0 commit b9c020a
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 15 deletions.
4 changes: 2 additions & 2 deletions proto/interchain_security/ccv/provider/v1/query.proto
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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 ];
Expand Down
21 changes: 11 additions & 10 deletions x/ccv/provider/client/cli/tx.go
Original file line number Diff line number Diff line change
@@ -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"

Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -86,17 +87,17 @@ 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.
An IBC misbehaviour contains two conflicting IBC client headers, which are used to form a light client attack evidence.
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 {
Expand All @@ -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
}
Expand All @@ -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
Expand All @@ -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 {
Expand Down Expand Up @@ -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
}
Expand Down
7 changes: 6 additions & 1 deletion x/ccv/provider/types/msg.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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
}

Expand All @@ -148,6 +151,7 @@ func (msg MsgSubmitConsumerMisbehaviour) ValidateBasic() error {
}

func NewMsgSubmitConsumerDoubleVoting(
consumerId string,
submitter sdk.AccAddress,
ev *tmtypes.DuplicateVoteEvidence,
header *ibctmtypes.Header,
Expand All @@ -156,6 +160,7 @@ func NewMsgSubmitConsumerDoubleVoting(
Submitter: submitter.String(),
DuplicateVoteEvidence: ev,
InfractionBlockHeader: header,
ConsumerId: consumerId,
}, nil
}

Expand Down
4 changes: 2 additions & 2 deletions x/ccv/provider/types/query.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit b9c020a

Please sign in to comment.