From 0e86503e0f9307a8867dbb563c8ed2494d61de6f Mon Sep 17 00:00:00 2001 From: Simon Noetzlin Date: Mon, 21 Aug 2023 15:41:43 +0200 Subject: [PATCH 1/4] remove interface --- x/ccv/provider/types/codec.go | 5 ----- 1 file changed, 5 deletions(-) diff --git a/x/ccv/provider/types/codec.go b/x/ccv/provider/types/codec.go index 2f28b398f5..0ef3c2d296 100644 --- a/x/ccv/provider/types/codec.go +++ b/x/ccv/provider/types/codec.go @@ -6,7 +6,6 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/msgservice" govtypes "github.com/cosmos/cosmos-sdk/x/gov/types" - "github.com/cosmos/ibc-go/v4/modules/core/exported" ) // RegisterLegacyAminoCodec registers the necessary x/ibc transfer interfaces and concrete types @@ -41,10 +40,6 @@ func RegisterInterfaces(registry codectypes.InterfaceRegistry) { (*sdk.Msg)(nil), &MsgSubmitConsumerMisbehaviour{}, ) - registry.RegisterInterface( - "ibc.core.client.v1.Misbehaviour", - (*exported.Misbehaviour)(nil), - ) msgservice.RegisterMsgServiceDesc(registry, &_Msg_serviceDesc) } From 4535c2b346afaf046ee41be576e8cc3b7c165f48 Mon Sep 17 00:00:00 2001 From: Simon Noetzlin Date: Mon, 21 Aug 2023 15:50:15 +0200 Subject: [PATCH 2/4] improve comment --- x/ccv/provider/keeper/misbehaviour.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/x/ccv/provider/keeper/misbehaviour.go b/x/ccv/provider/keeper/misbehaviour.go index 4d8f517e95..79efe74238 100644 --- a/x/ccv/provider/keeper/misbehaviour.go +++ b/x/ccv/provider/keeper/misbehaviour.go @@ -147,14 +147,15 @@ func (k Keeper) CheckMisbehaviour(ctx sdk.Context, misbehaviour ibctmtypes.Misbe // Check that the headers are at the same height to ensure that // the misbehaviour is for a light client attack and not a time violation, - // see https://github.com/cosmos/ibc-go/blob/8f53c21361f9d65448a850c2eafcf3ab3c384a61/modules/light-clients/07-tendermint/types/misbehaviour_handle.go#L56 + // see https://github.com/cosmos/ibc-go/blob/v4.2.0/modules/light-clients/07-tendermint/types/misbehaviour_handle.go#L24 if !misbehaviour.Header1.GetHeight().EQ(misbehaviour.Header2.GetHeight()) { return sdkerrors.Wrap(ibcclienttypes.ErrInvalidMisbehaviour, "headers are not at same height") } // CheckMisbehaviourAndUpdateState verifies the misbehaviour against the trusted consensus states // but does NOT update the light client state. - // Note CheckMisbehaviourAndUpdateState returns an error if the trusted consensus states are expired + // Note that the CometBFT CheckMisbehaviourAndUpdateState method returns an error if the trusted consensus states are expired, + // see https://github.com/cosmos/ibc-go/blob/v4.2.0/modules/light-clients/07-tendermint/types/misbehaviour_handle.go#L120 _, err := clientState.CheckMisbehaviourAndUpdateState(ctx, k.cdc, clientStore, &misbehaviour) if err != nil { return err From 52c34c8659dc205292bd5c6b0d60fb07f45e3fac Mon Sep 17 00:00:00 2001 From: Simon Noetzlin Date: Mon, 21 Aug 2023 21:04:57 +0200 Subject: [PATCH 3/4] update godoc --- x/ccv/provider/keeper/misbehaviour.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/x/ccv/provider/keeper/misbehaviour.go b/x/ccv/provider/keeper/misbehaviour.go index 79efe74238..8088044304 100644 --- a/x/ccv/provider/keeper/misbehaviour.go +++ b/x/ccv/provider/keeper/misbehaviour.go @@ -147,7 +147,7 @@ func (k Keeper) CheckMisbehaviour(ctx sdk.Context, misbehaviour ibctmtypes.Misbe // Check that the headers are at the same height to ensure that // the misbehaviour is for a light client attack and not a time violation, - // see https://github.com/cosmos/ibc-go/blob/v4.2.0/modules/light-clients/07-tendermint/types/misbehaviour_handle.go#L24 + // https://github.com/cosmos/ibc-go/blob/v4.2.0/modules/light-clients/07-tendermint/types/misbehaviour_handle.go#L53-L58 if !misbehaviour.Header1.GetHeight().EQ(misbehaviour.Header2.GetHeight()) { return sdkerrors.Wrap(ibcclienttypes.ErrInvalidMisbehaviour, "headers are not at same height") } From f54041f4147f49eb59aea933eba0f7d3b985057f Mon Sep 17 00:00:00 2001 From: Simon Noetzlin Date: Tue, 22 Aug 2023 09:36:39 +0200 Subject: [PATCH 4/4] address last comments --- x/ccv/provider/keeper/misbehaviour.go | 7 ------- 1 file changed, 7 deletions(-) diff --git a/x/ccv/provider/keeper/misbehaviour.go b/x/ccv/provider/keeper/misbehaviour.go index 8088044304..0438df36e3 100644 --- a/x/ccv/provider/keeper/misbehaviour.go +++ b/x/ccv/provider/keeper/misbehaviour.go @@ -1,8 +1,6 @@ package keeper import ( - "sort" - "github.com/cosmos/interchain-security/v2/x/ccv/provider/types" sdk "github.com/cosmos/cosmos-sdk/types" @@ -109,7 +107,6 @@ func (k Keeper) GetByzantineValidators(ctx sdk.Context, misbehaviour ibctmtypes. } } - sort.Sort(tmtypes.ValidatorsByVotingPower(validators)) return validators, nil } @@ -134,10 +131,6 @@ func headerToLightBlock(h ibctmtypes.Header) (*tmtypes.LightBlock, error) { // CheckMisbehaviour checks that headers in the given misbehaviour forms // a valid light client attack and that the corresponding light client isn't expired func (k Keeper) CheckMisbehaviour(ctx sdk.Context, misbehaviour ibctmtypes.Misbehaviour) error { - if err := misbehaviour.ValidateBasic(); err != nil { - return err - } - clientState, found := k.clientKeeper.GetClientState(ctx, misbehaviour.GetClientID()) if !found { return sdkerrors.Wrapf(ibcclienttypes.ErrClientNotFound, "cannot check misbehaviour for client with ID %s", misbehaviour.GetClientID())