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 6, 2023
1 parent b778c73 commit 26c69df
Show file tree
Hide file tree
Showing 5 changed files with 506 additions and 134 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 @@ -10,6 +10,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";

// ConsumerAdditionProposal is a governance proposal on the provider chain to spawn a new consumer chain.
Expand Down Expand Up @@ -85,6 +86,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
21 changes: 21 additions & 0 deletions third_party/proto/cosmos/evidence/v1beta1/evidence.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
syntax = "proto3";
package cosmos.evidence.v1beta1;

option go_package = "github.com/cosmos/cosmos-sdk/x/evidence/types";
option (gogoproto.equal_all) = true;

import "gogoproto/gogo.proto";
import "google/protobuf/timestamp.proto";

// Equivocation implements the Evidence interface and defines evidence of double
// signing misbehavior.
message Equivocation {
option (gogoproto.goproto_stringer) = false;
option (gogoproto.goproto_getters) = false;
option (gogoproto.equal) = false;

int64 height = 1;
google.protobuf.Timestamp time = 2 [(gogoproto.nullable) = false, (gogoproto.stdtime) = true];
int64 power = 3;
string consensus_address = 4 [(gogoproto.moretags) = "yaml:\"consensus_address\""];
}
11 changes: 4 additions & 7 deletions x/ccv/provider/types/codec.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,25 +27,22 @@ func RegisterInterfaces(registry codectypes.InterfaceRegistry) {
(*sdk.Msg)(nil),
&MsgAssignConsumerKey{},
)
registry.RegisterImplementations(
(*govtypes.Content)(nil),
&EquivocationProposal{},
)
registry.RegisterImplementations(
(*govtypes.Content)(nil),
&ChangeRewardDenomsProposal{},
)

registry.RegisterImplementations(
(*sdk.Msg)(nil),
&MsgSubmitConsumerMisbehaviour{},
)

registry.RegisterImplementations(
(*sdk.Msg)(nil),
&MsgSubmitConsumerDoubleVoting{},
)
registry.RegisterImplementations(
(*govtypes.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,13 +1,14 @@
package types

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

errorsmod "cosmossdk.io/errors"

sdk "github.com/cosmos/cosmos-sdk/types"
evidencetypes "github.com/cosmos/cosmos-sdk/x/evidence/types"
govtypes "github.com/cosmos/cosmos-sdk/x/gov/types"
clienttypes "github.com/cosmos/ibc-go/v4/modules/core/02-client/types"
ccvtypes "github.com/cosmos/interchain-security/v2/x/ccv/types"
Expand All @@ -16,18 +17,21 @@ import (
const (
ProposalTypeConsumerAddition = "ConsumerAddition"
ProposalTypeConsumerRemoval = "ConsumerRemoval"
ProposalTypeEquivocation = "Equivocation"
ProposalTypeChangeRewardDenoms = "ChangeRewardDenoms"
)

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

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

Expand Down Expand Up @@ -196,6 +200,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) govtypes.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 := govtypes.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,
) govtypes.Content {
Expand Down
Loading

0 comments on commit 26c69df

Please sign in to comment.