Skip to content

Commit

Permalink
nits
Browse files Browse the repository at this point in the history
  • Loading branch information
sainoe committed Aug 24, 2023
1 parent 34b7dda commit 1e301d5
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 21 deletions.
18 changes: 5 additions & 13 deletions tests/integration/double_vote.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,8 @@ import (
"time"

sdk "github.com/cosmos/cosmos-sdk/types"
ibctmtypes "github.com/cosmos/ibc-go/v4/modules/light-clients/07-tendermint/types"
"github.com/cosmos/interchain-security/v2/x/ccv/provider/types"
"github.com/tendermint/tendermint/crypto/tmhash"
tmproto "github.com/tendermint/tendermint/proto/tendermint/types"
tmtypes "github.com/tendermint/tendermint/types"
)

Expand Down Expand Up @@ -53,7 +51,7 @@ func (s *CCVTestSuite) TestHandleConsumerDoubleVoting() {
testCases := []struct {
name string
ev *tmtypes.DuplicateVoteEvidence
header *ibctmtypes.Header
chainID string
expPass bool
}{
{
Expand All @@ -65,13 +63,7 @@ func (s *CCVTestSuite) TestHandleConsumerDoubleVoting() {
TotalVotingPower: val.VotingPower,
Timestamp: s.consumerCtx().BlockTime(),
},
&ibctmtypes.Header{
SignedHeader: &tmproto.SignedHeader{
Header: &tmproto.Header{
ChainID: "chainID",
},
},
},
"chainID",
false,
},
{
Expand All @@ -84,7 +76,7 @@ func (s *CCVTestSuite) TestHandleConsumerDoubleVoting() {
TotalVotingPower: val.VotingPower,
Timestamp: s.consumerCtx().BlockTime(),
},
s.consumerChain.LastHeader,
s.consumerChain.ChainID,
false,
},
{
Expand All @@ -99,7 +91,7 @@ func (s *CCVTestSuite) TestHandleConsumerDoubleVoting() {
TotalVotingPower: val.VotingPower,
Timestamp: s.consumerCtx().BlockTime(),
},
s.consumerChain.LastHeader,
s.consumerChain.ChainID,
true,
},
}
Expand All @@ -112,7 +104,7 @@ func (s *CCVTestSuite) TestHandleConsumerDoubleVoting() {
err = s.providerApp.GetProviderKeeper().HandleConsumerDoubleVoting(
s.providerCtx(),
tc.ev,
tc.header,
tc.chainID,
)
if tc.expPass {
s.Require().NoError(err)
Expand Down
6 changes: 1 addition & 5 deletions x/ccv/provider/keeper/double_vote.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import (
cryptocodec "github.com/cosmos/cosmos-sdk/crypto/codec"
sdk "github.com/cosmos/cosmos-sdk/types"
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
ibctmtypes "github.com/cosmos/ibc-go/v4/modules/light-clients/07-tendermint/types"
"github.com/cosmos/interchain-security/v2/x/ccv/provider/types"
ccvtypes "github.com/cosmos/interchain-security/v2/x/ccv/types"
tmprotocrypto "github.com/tendermint/tendermint/proto/tendermint/crypto"
Expand All @@ -16,10 +15,7 @@ import (

// HandleConsumerDoubleVoting verifies a double voting evidence for a given a consumer chain and,
// if successful, executes the the jailing and the tombstoning of the malicious validator.
// Note that the infraction header argument is temporarily only used to get the consumer chain ID.
func (k Keeper) HandleConsumerDoubleVoting(ctx sdk.Context, evidence *tmtypes.DuplicateVoteEvidence, h *ibctmtypes.Header) error {
chainID := h.Header.ChainID

func (k Keeper) HandleConsumerDoubleVoting(ctx sdk.Context, evidence *tmtypes.DuplicateVoteEvidence, chainID string) error {
// get the validator's consensus address on the provider
providerAddr := k.GetProviderAddrFromConsumerAddr(
ctx,
Expand Down
4 changes: 2 additions & 2 deletions x/ccv/provider/keeper/msg_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -156,15 +156,15 @@ func (k msgServer) SubmitConsumerDoubleVoting(goCtx context.Context, msg *types.
return nil, err
}

if err := k.Keeper.HandleConsumerDoubleVoting(ctx, evidence, msg.InfractionBlockHeader); err != nil {
if err := k.Keeper.HandleConsumerDoubleVoting(ctx, evidence, msg.InfractionBlockHeader.Header.ChainID); err != nil {
return &types.MsgSubmitConsumerDoubleVotingResponse{}, err
}

ctx.EventManager().EmitEvents(sdk.Events{
sdk.NewEvent(
ccvtypes.EventTypeSubmitConsumerMisbehaviour,
sdk.NewAttribute(ccvtypes.AttributeConsumerDoubleVoting, msg.DuplicateVoteEvidence.String()),
sdk.NewAttribute(ccvtypes.AttributeInfractionBlockHeader, msg.InfractionBlockHeader.String()),
sdk.NewAttribute(ccvtypes.AttributeChainID, msg.InfractionBlockHeader.Header.ChainID),
sdk.NewAttribute(ccvtypes.AttributeSubmitterAddress, msg.Submitter),
),
})
Expand Down
1 change: 0 additions & 1 deletion x/ccv/types/events.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ const (
AttributeMisbehaviourHeight1 = "misbehaviour_height_1"
AttributeMisbehaviourHeight2 = "misbehaviour_height_2"
AttributeConsumerDoubleVoting = "consumer_double_voting"
AttributeInfractionBlockHeader = "infraction_block_header"

AttributeDistributionCurrentHeight = "current_distribution_height"
AttributeDistributionNextHeight = "next_distribution_height"
Expand Down

0 comments on commit 1e301d5

Please sign in to comment.