Skip to content

Commit

Permalink
self height uses GTE in self client check (cosmos#7945)
Browse files Browse the repository at this point in the history
Co-authored-by: Federico Kunze <[email protected]>
Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
  • Loading branch information
3 people authored Nov 17, 2020
1 parent f962f3a commit e93b18e
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
6 changes: 3 additions & 3 deletions x/ibc/core/02-client/keeper/keeper.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
4 changes: 2 additions & 2 deletions x/ibc/core/02-client/keeper/keeper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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,
},
{
Expand Down

0 comments on commit e93b18e

Please sign in to comment.