Skip to content

Commit

Permalink
fix: add equivocation proposal message back in protos (#1394)
Browse files Browse the repository at this point in the history
* add depreacted equiv prop msg def

* add codec and content for equivo proposal msg

* doc

* proto
  • Loading branch information
sainoe committed Nov 14, 2023
1 parent 80e9d25 commit 310788e
Show file tree
Hide file tree
Showing 5 changed files with 496 additions and 142 deletions.
17 changes: 17 additions & 0 deletions proto/interchain_security/ccv/provider/v1/provider.proto
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import "google/protobuf/duration.proto";
import "ibc/core/client/v1/client.proto";
import "ibc/lightclients/tendermint/v1/tendermint.proto";
import "tendermint/crypto/keys.proto";
import "cosmos/evidence/v1beta1/evidence.proto";
import "cosmos/base/v1beta1/coin.proto";

//
Expand Down Expand Up @@ -102,6 +103,22 @@ message ConsumerRemovalProposal {
[ (gogoproto.stdtime) = true, (gogoproto.nullable) = false ];
}

// EquivocationProposal is a governance proposal on the provider chain to
// punish a validator for equivocation on a consumer chain.
//
// This type is only used internally to the consumer CCV module.
// WARNING: This message is deprecated now that equivocations can be submitted
// and verified automatically on the provider. (see SubmitConsumerDoubleVoting in proto/interchain-security/ccv/provider/v1/tx.proto).
message EquivocationProposal {
option deprecated = true;
// the title of the proposal
string title = 1;
// the description of the proposal
string description = 2;
// the list of equivocations that will be processed
repeated cosmos.evidence.v1beta1.Equivocation equivocations = 3;
}

// ChangeRewardDenomsProposal is a governance proposal on the provider chain to
// mutate the set of denoms accepted by the provider as rewards.
message ChangeRewardDenomsProposal {
Expand Down
14 changes: 8 additions & 6 deletions x/ccv/provider/types/codec.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,20 +27,22 @@ func RegisterInterfaces(registry codectypes.InterfaceRegistry) {
(*sdk.Msg)(nil),
&MsgAssignConsumerKey{},
)
registry.RegisterImplementations(
(*govv1beta1.Content)(nil),
&EquivocationProposal{},
)
registry.RegisterImplementations(
(*govv1beta1.Content)(nil),
&ChangeRewardDenomsProposal{},
)
registry.RegisterImplementations(
(*sdk.Msg)(nil),
&MsgSubmitConsumerMisbehaviour{},
)

registry.RegisterImplementations(
(*sdk.Msg)(nil),
&MsgSubmitConsumerDoubleVoting{},
)
registry.RegisterImplementations(
(*govv1beta1.Content)(nil),
&ChangeRewardDenomsProposal{},
)

msgservice.RegisterMsgServiceDesc(registry, &_Msg_serviceDesc)
}

Expand Down
40 changes: 39 additions & 1 deletion x/ccv/provider/types/proposal.go
Original file line number Diff line number Diff line change
@@ -1,36 +1,40 @@
package types

import (
"errors"
"fmt"
"strings"
time "time"

clienttypes "github.com/cosmos/ibc-go/v7/modules/core/02-client/types"

errorsmod "cosmossdk.io/errors"

sdk "github.com/cosmos/cosmos-sdk/types"
govv1beta1 "github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1"

evidencetypes "github.com/cosmos/cosmos-sdk/x/evidence/types"
ccvtypes "github.com/cosmos/interchain-security/v3/x/ccv/types"
)

const (
ProposalTypeConsumerAddition = "ConsumerAddition"
ProposalTypeConsumerRemoval = "ConsumerRemoval"
ProposalTypeEquivocation = "Equivocation"
ProposalTypeChangeRewardDenoms = "ChangeRewardDenoms"
)

var (
_ govv1beta1.Content = &ConsumerAdditionProposal{}
_ govv1beta1.Content = &ConsumerRemovalProposal{}
_ govv1beta1.Content = &ChangeRewardDenomsProposal{}
_ govv1beta1.Content = &EquivocationProposal{}
)

func init() {
govv1beta1.RegisterProposalType(ProposalTypeConsumerAddition)
govv1beta1.RegisterProposalType(ProposalTypeConsumerRemoval)
govv1beta1.RegisterProposalType(ProposalTypeChangeRewardDenoms)
govv1beta1.RegisterProposalType(ProposalTypeEquivocation)
}

// NewConsumerAdditionProposal creates a new consumer addition proposal.
Expand Down Expand Up @@ -198,6 +202,40 @@ func (sccp *ConsumerRemovalProposal) ValidateBasic() error {
return nil
}

// NewEquivocationProposal creates a new equivocation proposal.
// [DEPRECATED]: do not use
func NewEquivocationProposal(title, description string, equivocations []*evidencetypes.Equivocation) govv1beta1.Content {
return &EquivocationProposal{
Title: title,
Description: description,
Equivocations: equivocations,
}
}

// ProposalRoute returns the routing key of an equivocation proposal.
func (sp *EquivocationProposal) ProposalRoute() string { return RouterKey }

// ProposalType returns the type of a equivocation proposal.
func (sp *EquivocationProposal) ProposalType() string {
return ProposalTypeEquivocation
}

// ValidateBasic runs basic stateless validity checks
func (sp *EquivocationProposal) ValidateBasic() error {
if err := govv1beta1.ValidateAbstract(sp); err != nil {
return err
}
if len(sp.Equivocations) == 0 {
return errors.New("invalid equivocation proposal: empty equivocations")
}
for i := 0; i < len(sp.Equivocations); i++ {
if err := sp.Equivocations[i].ValidateBasic(); err != nil {
return err
}
}
return nil
}

func NewChangeRewardDenomsProposal(title, description string,
denomsToAdd, denomsToRemove []string,
) govv1beta1.Content {
Expand Down
Loading

0 comments on commit 310788e

Please sign in to comment.