Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Efficient Consensus State Iteration #125

Merged
merged 12 commits into from
Apr 23, 2021
Prev Previous commit
Next Next commit
fix return
  • Loading branch information
AdityaSripal committed Apr 23, 2021
commit c0f9513cdf3a908406b990c84ee57404feeb0168
1 change: 1 addition & 0 deletions modules/light-clients/07-tendermint/types/store.go
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,7 @@ func getTmConsensusState(clientStore sdk.KVStore, cdc codec.BinaryMarshaler, key
if !ok {
return nil, false
}
return consensusState, true
}

func bigEndianHeightBytes(height exported.Height) []byte {
Expand Down
8 changes: 4 additions & 4 deletions modules/light-clients/07-tendermint/types/update_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -298,14 +298,14 @@ func (suite *TendermintTestSuite) TestPruneConsensusState() {
// this height will be expired but not pruned
path.EndpointA.UpdateClient()
expiredHeight := path.EndpointA.GetClientState().GetLatestHeight()
// store expected values that must still remain in store after pruning

// expected values that must still remain in store after pruning
expectedConsState, ok := path.EndpointA.Chain.GetConsensusState(path.EndpointA.ClientID, expiredHeight)
suite.Require().True(ok)
ctx := path.EndpointA.Chain.GetContext()
clientStore := path.EndpointA.Chain.App.GetIBCKeeper().ClientKeeper.ClientStore(ctx, path.EndpointA.ClientID)
expectedProcessTime, ok := types.GetProcessedTime(clientStore, expiredHeight)
suite.Require().True(ok)
// check iteration key metadata is pruned
expectedConsKey := types.GetIterationKey(clientStore, expiredHeight)
suite.Require().NotNil(expectedConsKey)

Expand Down Expand Up @@ -340,11 +340,11 @@ func (suite *TendermintTestSuite) TestPruneConsensusState() {
consState, ok = path.EndpointA.Chain.GetConsensusState(path.EndpointA.ClientID, expiredHeight)
suite.Require().Equal(expectedConsState, consState, "consensus state incorrectly pruned")
suite.Require().True(ok)
// check processed time metadata is pruned
// check processed time metadata is not pruned
processTime, ok = types.GetProcessedTime(clientStore, expiredHeight)
suite.Require().Equal(expectedProcessTime, processTime, "processed time metadata incorrectly pruned")
suite.Require().True(ok)
// check iteration key metadata is pruned
// check iteration key metadata is not pruned
consKey = types.GetIterationKey(clientStore, expiredHeight)
suite.Require().Equal(expectedConsKey, consKey, "iteration key incorrectly pruned")
}