From b6040302c0c9a50691ad2179839cda02b5947cf4 Mon Sep 17 00:00:00 2001 From: "mergify[bot]" <37929162+mergify[bot]@users.noreply.github.com> Date: Tue, 22 Feb 2022 11:43:40 +0000 Subject: [PATCH] fix: classify client states without consensus states as expired (#941) (#969) ## Description closes: #850 --- Before we can merge this PR, please make sure that all the following items have been checked off. If any of the checklist items are not applicable, please leave them but write a little note why. - [ ] Targeted PR against correct branch (see [CONTRIBUTING.md](https://github.com/cosmos/ibc-go/blob/master/CONTRIBUTING.md#pr-targeting)) - [ ] Linked to Github issue with discussion and accepted design OR link to spec that describes this work. - [ ] Code follows the [module structure standards](https://github.com/cosmos/cosmos-sdk/blob/master/docs/building-modules/structure.md). - [ ] Wrote unit and integration [tests](https://github.com/cosmos/ibc-go/blob/master/CONTRIBUTING.md#testing) - [ ] Updated relevant documentation (`docs/`) or specification (`x//spec/`) - [ ] Added relevant `godoc` [comments](https://blog.golang.org/godoc-documenting-go-code). - [ ] Added a relevant changelog entry to the `Unreleased` section in `CHANGELOG.md` - [ ] Re-reviewed `Files changed` in the Github PR explorer - [ ] Review `Codecov Report` in the comment section below once CI passes (cherry picked from commit d48f576a0b2fe752790339f9e6f99b99d9fe2486) Co-authored-by: Tim Lind --- modules/core/02-client/keeper/grpc_query_test.go | 2 +- modules/light-clients/07-tendermint/types/client_state.go | 4 +++- .../light-clients/07-tendermint/types/client_state_test.go | 4 ++-- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/modules/core/02-client/keeper/grpc_query_test.go b/modules/core/02-client/keeper/grpc_query_test.go index f4fa3c59322..5e393c33a97 100644 --- a/modules/core/02-client/keeper/grpc_query_test.go +++ b/modules/core/02-client/keeper/grpc_query_test.go @@ -452,7 +452,7 @@ func (suite *KeeperTestSuite) TestQueryClientStatus() { ClientId: path.EndpointA.ClientID, } }, - true, exported.Unknown.String(), + true, exported.Expired.String(), }, { "Frozen client status", diff --git a/modules/light-clients/07-tendermint/types/client_state.go b/modules/light-clients/07-tendermint/types/client_state.go index a0430337d0b..51f826979fd 100644 --- a/modules/light-clients/07-tendermint/types/client_state.go +++ b/modules/light-clients/07-tendermint/types/client_state.go @@ -78,7 +78,9 @@ func (cs ClientState) Status( // get latest consensus state from clientStore to check for expiry consState, err := GetConsensusState(clientStore, cdc, cs.GetLatestHeight()) if err != nil { - return exported.Unknown + // if the client state does not have an associated consensus state for its latest height + // then it must be expired + return exported.Expired } if cs.IsExpired(consState.Timestamp, ctx.BlockTime()) { diff --git a/modules/light-clients/07-tendermint/types/client_state_test.go b/modules/light-clients/07-tendermint/types/client_state_test.go index b0434579b76..cf52d2996b5 100644 --- a/modules/light-clients/07-tendermint/types/client_state_test.go +++ b/modules/light-clients/07-tendermint/types/client_state_test.go @@ -47,10 +47,10 @@ func (suite *TendermintTestSuite) TestStatus() { clientState.FrozenHeight = clienttypes.NewHeight(0, 1) path.EndpointA.SetClientState(clientState) }, exported.Frozen}, - {"client status is unknown", func() { + {"client status without consensus state", func() { clientState.LatestHeight = clientState.LatestHeight.Increment().(clienttypes.Height) path.EndpointA.SetClientState(clientState) - }, exported.Unknown}, + }, exported.Expired}, {"client status is expired", func() { suite.coordinator.IncrementTimeBy(clientState.TrustingPeriod) }, exported.Expired},