Skip to content

Commit 9a4ed68

Browse files
authored
chore: remove error return in IterateConsensusStateAscending (#1896)
* removing error return in tendermint store.go * updating tests and legacy code * updating changelog
1 parent fc4bfaf commit 9a4ed68

File tree

5 files changed

+9
-20
lines changed

5 files changed

+9
-20
lines changed

CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,8 @@ Ref: https://keepachangelog.com/en/1.0.0/
7171
* (06-solomachine) [\#1100](https://github.com/cosmos/ibc-go/pull/1100) Deprecate `ClientId` field in 06-solomachine `Misbehaviour` type.
7272
* (07-tendermint) [\#1097](https://github.com/cosmos/ibc-go/pull/1097) Remove `GetClientID` function from 07-tendermint `Misbehaviour` type.
7373
* (07-tendermint) [\#1097](https://github.com/cosmos/ibc-go/pull/1097) Deprecate `ClientId` field in 07-tendermint `Misbehaviour` type.
74-
* (modules/core/exported) [\#1107](https://github.com/cosmos/ibc-go/pull/1107) Merging the `Header` and `Misbehaviour` interfaces into a single `ClientMessage` type
74+
* (modules/core/exported) [\#1107](https://github.com/cosmos/ibc-go/pull/1107) Merging the `Header` and `Misbehaviour` interfaces into a single `ClientMessage` type.
75+
* (07-tendermint) [\#1896](https://github.com/cosmos/ibc-go/pull/1896) Remove error return from `IterateConsensusStateAscending` in `07-tendermint`.
7576

7677
### State Machine Breaking
7778

modules/core/02-client/legacy/v100/store.go

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -96,10 +96,7 @@ func MigrateStore(ctx sdk.Context, storeKey storetypes.StoreKey, cdc codec.Binar
9696
// add iteration keys so pruning will be successful
9797
addConsensusMetadata(ctx, clientStore)
9898

99-
if err = ibctm.PruneAllExpiredConsensusStates(ctx, clientStore, cdc, tmClientState); err != nil {
100-
return err
101-
}
102-
99+
ibctm.PruneAllExpiredConsensusStates(ctx, clientStore, cdc, tmClientState)
103100
default:
104101
continue
105102
}

modules/light-clients/07-tendermint/store.go

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -215,18 +215,17 @@ func GetHeightFromIterationKey(iterKey []byte) exported.Height {
215215

216216
// IterateConsensusStateAscending iterates through the consensus states in ascending order. It calls the provided
217217
// callback on each height, until stop=true is returned.
218-
func IterateConsensusStateAscending(clientStore sdk.KVStore, cb func(height exported.Height) (stop bool)) error {
218+
func IterateConsensusStateAscending(clientStore sdk.KVStore, cb func(height exported.Height) (stop bool)) {
219219
iterator := sdk.KVStorePrefixIterator(clientStore, []byte(KeyIterateConsensusStatePrefix))
220220
defer iterator.Close()
221221

222222
for ; iterator.Valid(); iterator.Next() {
223223
iterKey := iterator.Key()
224224
height := GetHeightFromIterationKey(iterKey)
225225
if cb(height) {
226-
return nil
226+
break
227227
}
228228
}
229-
return nil
230229
}
231230

232231
// GetNextConsensusState returns the lowest consensus state that is larger than the given height.
@@ -278,7 +277,7 @@ func GetPreviousConsensusState(clientStore sdk.KVStore, cdc codec.BinaryCodec, h
278277
func PruneAllExpiredConsensusStates(
279278
ctx sdk.Context, clientStore sdk.KVStore,
280279
cdc codec.BinaryCodec, clientState *ClientState,
281-
) (err error) {
280+
) {
282281
var heights []exported.Height
283282

284283
pruneCb := func(height exported.Height) bool {
@@ -294,17 +293,12 @@ func PruneAllExpiredConsensusStates(
294293
return false
295294
}
296295

297-
err = IterateConsensusStateAscending(clientStore, pruneCb)
298-
if err != nil {
299-
return err
300-
}
296+
IterateConsensusStateAscending(clientStore, pruneCb)
301297

302298
for _, height := range heights {
303299
deleteConsensusState(clientStore, height)
304300
deleteConsensusMetadata(clientStore, height)
305301
}
306-
307-
return nil
308302
}
309303

310304
// Helper function for GetNextConsensusState and GetPreviousConsensusState

modules/light-clients/07-tendermint/update.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -186,9 +186,7 @@ func (cs ClientState) pruneOldestConsensusState(ctx sdk.Context, cdc codec.Binar
186186
return true
187187
}
188188

189-
if err := IterateConsensusStateAscending(clientStore, pruneCb); err != nil {
190-
panic(err)
191-
}
189+
IterateConsensusStateAscending(clientStore, pruneCb)
192190

193191
// if pruneHeight is set, delete consensus state and metadata
194192
if pruneHeight != nil {

modules/light-clients/07-tendermint/update_test.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -488,8 +488,7 @@ func (suite *TendermintTestSuite) TestPruneConsensusState() {
488488
}
489489
ctx := path.EndpointA.Chain.GetContext()
490490
clientStore := path.EndpointA.Chain.App.GetIBCKeeper().ClientKeeper.ClientStore(ctx, path.EndpointA.ClientID)
491-
err := ibctm.IterateConsensusStateAscending(clientStore, getFirstHeightCb)
492-
suite.Require().Nil(err)
491+
ibctm.IterateConsensusStateAscending(clientStore, getFirstHeightCb)
493492

494493
// this height will be expired but not pruned
495494
path.EndpointA.UpdateClient()

0 commit comments

Comments
 (0)