From 3a684c01659c1a522b50c05e037c42487f0b31fd Mon Sep 17 00:00:00 2001 From: Simon Noetzlin Date: Fri, 10 Nov 2023 11:29:15 +0100 Subject: [PATCH] doc --- tests/integration/misbehaviour.go | 17 +++++++++-------- x/ccv/provider/keeper/misbehaviour.go | 7 ++++++- 2 files changed, 15 insertions(+), 9 deletions(-) diff --git a/tests/integration/misbehaviour.go b/tests/integration/misbehaviour.go index 2d40c05bd3..910571d227 100644 --- a/tests/integration/misbehaviour.go +++ b/tests/integration/misbehaviour.go @@ -337,19 +337,18 @@ func (s *CCVTestSuite) TestCheckMisbehaviour() { { "identical headers - shouldn't pass", &ibctmtypes.Misbehaviour{ - ClientId: "clientID", + ClientId: s.path.EndpointA.ClientID, Header1: clientHeader, Header2: clientHeader, }, false, }, { - "client state not found - shouldn't pass", + "misbehaviour isn't for a consumer chain - shouldn't pass", &ibctmtypes.Misbehaviour{ - ClientId: "clientID", - Header1: clientHeader, - Header2: s.consumerChain.CreateTMClientHeader( - s.consumerChain.ChainID, + ClientId: s.path.EndpointA.ClientID, + Header1: s.consumerChain.CreateTMClientHeader( + "aChainID", int64(clientHeight.RevisionHeight+1), clientHeight, headerTs, @@ -358,13 +357,15 @@ func (s *CCVTestSuite) TestCheckMisbehaviour() { clientTMValset, altSigners, ), + Header2: clientHeader, }, false, }, { - "invalid misbehaviour with empty header1 - shouldn't pass", + "client state not found - shouldn't pass", &ibctmtypes.Misbehaviour{ - Header1: &ibctmtypes.Header{}, + ClientId: "clientID", + Header1: clientHeader, Header2: s.consumerChain.CreateTMClientHeader( s.consumerChain.ChainID, int64(clientHeight.RevisionHeight+1), diff --git a/x/ccv/provider/keeper/misbehaviour.go b/x/ccv/provider/keeper/misbehaviour.go index 4890c22171..d01689d96b 100644 --- a/x/ccv/provider/keeper/misbehaviour.go +++ b/x/ccv/provider/keeper/misbehaviour.go @@ -142,8 +142,13 @@ 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 +// a valid light client attack from an ICS consumer chain and that the light client isn't expired func (k Keeper) CheckMisbehaviour(ctx sdk.Context, misbehaviour ibctmtypes.Misbehaviour) error { + // check that the misbehaviour is for an ICS consumer chain + if _, found := k.GetConsumerClientId(ctx, misbehaviour.Header1.Header.ChainID); !found { + return fmt.Errorf("incorrect misbehaviour with conflicting headers from a non-existent consumer chain: %s", misbehaviour.Header1.Header.ChainID) + } + 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())