From 7e6978ae551bbed439c69178184dea0a25d0e747 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?colin=20axn=C3=A9r?= <25233464+colin-axner@users.noreply.github.com> Date: Fri, 13 Nov 2020 20:01:33 +0100 Subject: [PATCH] ibc: tendermint misbehaviour should use block hash for equality check (#7928) * check block hash equality * update err msg * valid commit now uses block id hash Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com> Co-authored-by: Federico Kunze <31522760+fedekunze@users.noreply.github.com> --- x/ibc/light-clients/07-tendermint/types/misbehaviour.go | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/x/ibc/light-clients/07-tendermint/types/misbehaviour.go b/x/ibc/light-clients/07-tendermint/types/misbehaviour.go index 3e604e0f91..85fb615e5e 100644 --- a/x/ibc/light-clients/07-tendermint/types/misbehaviour.go +++ b/x/ibc/light-clients/07-tendermint/types/misbehaviour.go @@ -1,6 +1,7 @@ package types import ( + "bytes" "math" "time" @@ -107,8 +108,8 @@ func (misbehaviour Misbehaviour) ValidateBasic() error { } // Ensure that Commit Hashes are different - if blockID1.Equals(*blockID2) { - return sdkerrors.Wrap(clienttypes.ErrInvalidMisbehaviour, "headers blockIDs are equal") + if bytes.Equal(blockID1.Hash, blockID2.Hash) { + return sdkerrors.Wrap(clienttypes.ErrInvalidMisbehaviour, "headers block hashes are equal") } if err := ValidCommit(misbehaviour.Header1.Header.ChainID, misbehaviour.Header1.Commit, misbehaviour.Header1.ValidatorSet); err != nil { return err @@ -145,8 +146,8 @@ func ValidCommit(chainID string, commit *tmproto.Commit, valSet *tmproto.Validat blockID, ok := voteSet.TwoThirdsMajority() - // Check that ValidatorSet did indeed commit to blockID in Commit - if !ok || !blockID.Equals(tmCommit.BlockID) { + // Check that ValidatorSet did indeed commit to blockID hash in Commit + if !ok || !bytes.Equal(blockID.Hash, tmCommit.BlockID.Hash) { return sdkerrors.Wrap(clienttypes.ErrInvalidMisbehaviour, "validator set did not commit to header") }