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

Fix faulty iterator callsite callback return booleans #447

Merged
merged 5 commits into from
Nov 8, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion x/ccv/consumer/keeper/genesis.go
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ func (k Keeper) ExportGenesis(ctx sdk.Context) (genesis *consumertypes.GenesisSt
ValidatorConsensusAddress: addr,
}
outstandingDowntimes = append(outstandingDowntimes, od)
return false
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add comments describing the intended outcome, e.g., continue iterating. It will make it easier to change afterwards to the SDK pattern.

return true
})

genesis = types.NewRestartGenesisState(
Expand Down
2 changes: 1 addition & 1 deletion x/ccv/provider/keeper/grpc_query.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ func (k Keeper) QueryConsumerChains(goCtx context.Context, req *types.QueryConsu
ChainId: chainID,
ClientId: clientID,
})
return false
return true
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Until a better fix, change the return field from stop to continue, i.e.,

func (k Keeper) IterateConsumerChains(ctx sdk.Context, cb func(ctx sdk.Context, chainID, clientID string) (continue bool)) {

}
k.IterateConsumerChains(ctx, cb)

Expand Down
2 changes: 1 addition & 1 deletion x/ccv/provider/keeper/hooks.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ func (h Hooks) AfterUnbondingInitiated(ctx sdk.Context, ID uint64) {

h.k.IterateConsumerChains(ctx, func(ctx sdk.Context, chainID, clientID string) (stop bool) {
consumerChainIDS = append(consumerChainIDS, chainID)
return false
return true
})
if len(consumerChainIDS) == 0 {
// Do not put the unbonding op on hold if there are no consumer chains
Expand Down
4 changes: 2 additions & 2 deletions x/ccv/provider/keeper/relay.go
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ func (k Keeper) sendValidatorUpdates(ctx sdk.Context) {
k.AppendPendingVSC(ctx, chainID, packetData)
}
}
return false // do not stop the iteration
return true // do not stop the iteration
})
k.IncrementValidatorSetUpdateId(ctx)
}
Expand Down Expand Up @@ -354,7 +354,7 @@ func (k Keeper) EndBlockCCR(ctx sdk.Context) {
return false
})
// continue to iterate through all consumers
return true
return false
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ditto: IterateChannelToChain change stop to continue

})
// remove consumers that timed out
for _, chainID := range chainIdsToRemove {
Expand Down