Skip to content

Commit

Permalink
fix!: drop nil votes in misbehaviour handling (#1404)
Browse files Browse the repository at this point in the history
* update CHANGELOG for final release

* save

* update test to extract byzantine validators

* improve testing

* nits

* nits

* Update tests/integration/misbehaviour.go

Co-authored-by: insumity <[email protected]>

* Update testutil/crypto/evidence.go

Co-authored-by: insumity <[email protected]>

* update util func

* doc

* check misb client ID

* Update x/ccv/provider/keeper/misbehaviour.go

Co-authored-by: insumity <[email protected]>

* nits

---------

Co-authored-by: insumity <[email protected]>
  • Loading branch information
sainoe and insumity committed Nov 14, 2023
1 parent 291fbf7 commit a8bb748
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions x/ccv/provider/keeper/misbehaviour.go
Original file line number Diff line number Diff line change
Expand Up @@ -153,9 +153,21 @@ 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 {
clientState, found := k.clientKeeper.GetClientState(ctx, misbehaviour.ClientId)
// check that the misbehaviour is for an ICS consumer chain
clientId, found := k.GetConsumerClientId(ctx, misbehaviour.Header1.Header.ChainID)
if !found {
return fmt.Errorf("incorrect misbehaviour with conflicting headers from a non-existent consumer chain: %s", misbehaviour.Header1.Header.ChainID)
} else if misbehaviour.ClientId != clientId {
return fmt.Errorf("incorrect misbehaviour: expected client ID for consumer chain %s is %s got %s",
misbehaviour.Header1.Header.ChainID,
clientId,
misbehaviour.ClientId,
)
}

clientState, found := k.clientKeeper.GetClientState(ctx, clientId)
if !found {
return errorsmod.Wrapf(ibcclienttypes.ErrClientNotFound, "cannot check misbehaviour for client with ID %s", misbehaviour.ClientId)
}
Expand Down

0 comments on commit a8bb748

Please sign in to comment.