Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ibc: tendermint misbehaviour should use block hash for equality check #7928

Merged
merged 8 commits into from
Nov 13, 2020
9 changes: 5 additions & 4 deletions x/ibc/light-clients/07-tendermint/types/misbehaviour.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package types

import (
"bytes"
"math"
"time"

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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")
}

Expand Down