self height uses GTE in self client check (#7945)

Co-authored-by: Federico Kunze <31522760+fedekunze@users.noreply.github.com>
Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
This commit is contained in:
colin axnér 2020-11-17 12:40:12 +01:00 committed by GitHub
parent f962f3a28c
commit e93b18e60e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 5 deletions

View File

@ -220,9 +220,9 @@ func (k Keeper) ValidateSelfClient(ctx sdk.Context, clientState exported.ClientS
}
selfHeight := types.NewHeight(version, uint64(ctx.BlockHeight()))
if tmClient.LatestHeight.GT(selfHeight) {
return sdkerrors.Wrapf(types.ErrInvalidClient, "client has LatestHeight %d greater than chain height %d",
tmClient.LatestHeight, ctx.BlockHeight())
if tmClient.LatestHeight.GTE(selfHeight) {
return sdkerrors.Wrapf(types.ErrInvalidClient, "client has LatestHeight %d greater than or equal to chain height %d",
tmClient.LatestHeight, selfHeight)
}
expectedProofSpecs := commitmenttypes.GetSDKSpecs()

View File

@ -152,7 +152,7 @@ func (suite *KeeperTestSuite) TestSetClientConsensusState() {
}
func (suite *KeeperTestSuite) TestValidateSelfClient() {
testClientHeight := types.NewHeight(0, uint64(suite.chainA.GetContext().BlockHeight()))
testClientHeight := types.NewHeight(0, uint64(suite.chainA.GetContext().BlockHeight()-1))
testCases := []struct {
name string
@ -186,7 +186,7 @@ func (suite *KeeperTestSuite) TestValidateSelfClient() {
},
{
"invalid client height",
ibctmtypes.NewClientState(suite.chainA.ChainID, ibctmtypes.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, types.NewHeight(0, testClientHeight.VersionHeight+10), commitmenttypes.GetSDKSpecs(), ibctesting.UpgradePath, false, false),
ibctmtypes.NewClientState(suite.chainA.ChainID, ibctmtypes.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, types.NewHeight(0, uint64(suite.chainA.GetContext().BlockHeight())), commitmenttypes.GetSDKSpecs(), ibctesting.UpgradePath, false, false),
false,
},
{