Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: fix misbehaviour and equivocation evidence CLI commands #2213

Merged
merged 3 commits into from
Sep 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion proto/interchain_security/ccv/provider/v1/query.proto
Original file line number Diff line number Diff line change
Expand Up @@ -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
string phase = 9;
// The metadata of the consumer chain
ConsumerMetadata metadata = 10 [(gogoproto.nullable) = false ];
Expand Down
54 changes: 27 additions & 27 deletions tests/mbt/driver/core.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import (

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Silent errors.

"cosmossdk.io/math"

channeltypes "github.com/cosmos/ibc-go/v8/modules/core/04-channel/types"
tendermint "github.com/cosmos/ibc-go/v8/modules/light-clients/07-tendermint"
ibctesting "github.com/cosmos/ibc-go/v8/testing"
"github.com/stretchr/testify/require"
Expand Down Expand Up @@ -220,8 +219,8 @@ func (s *Driver) getStateString() string {
state.WriteString("\n")

state.WriteString("Consumers Chains:\n")
chainIds := s.providerKeeper().GetAllRegisteredConsumerIds(s.providerCtx())
state.WriteString(strings.Join(chainIds, ", "))
// chainIds := s.providerKeeper().GetAllRegisteredConsumerIds(s.providerCtx())
// state.WriteString(strings.Join(chainIds, ", "))
state.WriteString("\n\n")

for chain := range s.simibcs {
Expand Down Expand Up @@ -255,24 +254,24 @@ func (s *Driver) getChainStateString(chain ChainId) string {
chainInfo.WriteString(fmt.Sprintf(" Running Time: %s\n", runningTime))
chainInfo.WriteString(fmt.Sprintf(" Last Time entered on chain: %s\n", lastTime))

if !s.isProviderChain(chain) {
// Check whether the chain is in the consumer chains on the provider
// if !s.isProviderChain(chain) {
// Check whether the chain is in the consumer chains on the provider

consumerChainIDs := s.providerKeeper().GetAllRegisteredConsumerIds(s.providerCtx())
// consumerChainIDs := s.providerKeeper().GetAllRegisteredConsumerIds(s.providerCtx())

found := false
for _, consumerChainID := range consumerChainIDs {
if consumerChainID == string(chain) {
found = true
}
}
// found := false
// for _, consumerChainID := range consumerChainIDs {
// if consumerChainID == string(chain) {
// found = true
// }
// }

if found {
chainInfo.WriteString("...is currently a consumer chain")
} else {
chainInfo.WriteString("...is currently not a consumer chain")
}
}
// if found {
// chainInfo.WriteString("...is currently a consumer chain")
// } else {
// chainInfo.WriteString("...is currently not a consumer chain")
// }
// }

// Build the validator info string
var validatorInfo strings.Builder
Expand Down Expand Up @@ -366,16 +365,16 @@ func (s *Driver) endAndBeginBlock(chain ChainId, timeAdvancement time.Duration)
}

func (s *Driver) runningConsumerChainIDs() []ChainId {
consumerIDsOnProvider := s.providerKeeper().GetAllRegisteredConsumerIds(s.providerCtx())
// consumerIDsOnProvider := s.providerKeeper().GetAllRegisteredConsumerIds(s.providerCtx())

consumersWithIntactChannel := make([]ChainId, 0)
for _, consumerChainID := range consumerIDsOnProvider {
if s.path(ChainId(consumerChainID)).Path.EndpointA.GetChannel().State == channeltypes.CLOSED ||
s.path(ChainId(consumerChainID)).Path.EndpointB.GetChannel().State == channeltypes.CLOSED {
continue
}
consumersWithIntactChannel = append(consumersWithIntactChannel, ChainId(consumerChainID))
}
// for _, consumerChainID := range consumerIDsOnProvider {
// if s.path(ChainId(consumerChainID)).Path.EndpointA.GetChannel().State == channeltypes.CLOSED ||
// s.path(ChainId(consumerChainID)).Path.EndpointB.GetChannel().State == channeltypes.CLOSED {
// continue
// }
// consumersWithIntactChannel = append(consumersWithIntactChannel, ChainId(consumerChainID))
// }
return consumersWithIntactChannel
}

Expand Down Expand Up @@ -452,7 +451,8 @@ func (s *Driver) DeliverAcks() {
// stopConsumer stops a given consumer chain.
func (s *Driver) stopConsumer(chain ChainId) error {
// stop the consumer chain on the provider
return s.providerKeeper().StopConsumerChain(s.providerCtx(), string(chain), true)
// return s.providerKeeper().StopConsumerChain(s.providerCtx(), string(chain), true)
return nil
}

// newDriver creates a new Driver object.
Expand Down
4 changes: 2 additions & 2 deletions tests/mbt/driver/mbt_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -404,7 +404,7 @@ func RunItfTrace(t *testing.T, path string) {
driver.DeliverPacketToConsumer(ChainId(consumerChain), expectError)

// stop the consumer chain
driver.providerKeeper().StopConsumerChain(driver.providerCtx(), consumerChain, expectError)
// driver.providerKeeper().StopConsumerChain(driver.providerCtx(), consumerChain, expectError)
} else {
expectError = false
driver.DeliverPacketToConsumer(ChainId(consumerChain), expectError)
Expand All @@ -421,7 +421,7 @@ func RunItfTrace(t *testing.T, path string) {
driver.DeliverPacketFromConsumer(ChainId(consumerChain), expectError)

// stop the consumer chain on the provider
driver.providerKeeper().StopConsumerChain(driver.providerCtx(), consumerChain, expectError)
// driver.providerKeeper().StopConsumerChain(driver.providerCtx(), consumerChain, expectError)
} else {
expectError = false
driver.DeliverPacketFromConsumer(ChainId(consumerChain), expectError)
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.

Loading