Skip to content

Commit

Permalink
fix: classify client states without consensus states as expired (#941)
Browse files Browse the repository at this point in the history
## 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/<module>/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 d48f576)
  • Loading branch information
timlind authored and mergify-bot committed Feb 24, 2022
1 parent 32c935e commit 2b9e9af
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 4 deletions.
2 changes: 1 addition & 1 deletion modules/core/02-client/keeper/grpc_query_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -452,7 +452,7 @@ func (suite *KeeperTestSuite) TestQueryClientStatus() {
ClientId: path.EndpointA.ClientID,
}
},
true, exported.Unknown.String(),
true, exported.Expired.String(),
},
{
"Frozen client status",
Expand Down
4 changes: 3 additions & 1 deletion modules/light-clients/07-tendermint/types/client_state.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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},
Expand Down

0 comments on commit 2b9e9af

Please sign in to comment.