Skip to content

Commit

Permalink
fix: classify client states without consensus states as expired (back…
Browse files Browse the repository at this point in the history
…port #941) (#1011)

* fix: classify client states without consensus states as expired (#941)

## 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)

* add changelog entry

Co-authored-by: Tim Lind <[email protected]>
Co-authored-by: Carlos Rodriguez <[email protected]>
Co-authored-by: Carlos Rodriguez <[email protected]>
  • Loading branch information
4 people authored Mar 1, 2022
1 parent ac0a541 commit 1ff6913
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 4 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ Ref: https://keepachangelog.com/en/1.0.0/

### Bug Fixes

* (client) [\#941](https://github.com/cosmos/ibc-go/pull/941) Classify client states without consensus states as expired
* (transfer) [\#978](https://github.com/cosmos/ibc-go/pull/978) Support base denoms with slashes in denom validation

## [v2.0.3](https://github.com/cosmos/ibc-go/releases/tag/v2.0.2) - 2022-02-03
Expand Down
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 1ff6913

Please sign in to comment.