From 1d4a0c1f999099e22fa8a161a5ddaa81c1681115 Mon Sep 17 00:00:00 2001 From: MSalopek Date: Wed, 15 Nov 2023 10:47:42 +0100 Subject: [PATCH] refactor: make GetAllValidators a no-op (#1428) --- x/ccv/consumer/keeper/keeper.go | 15 --------------- x/ccv/consumer/keeper/validators.go | 6 ++++++ 2 files changed, 6 insertions(+), 15 deletions(-) diff --git a/x/ccv/consumer/keeper/keeper.go b/x/ccv/consumer/keeper/keeper.go index 0d0ac988ad..27076ac938 100644 --- a/x/ccv/consumer/keeper/keeper.go +++ b/x/ccv/consumer/keeper/keeper.go @@ -578,21 +578,6 @@ func (k Keeper) GetAllCCValidator(ctx sdk.Context) (validators []types.CrossChai return validators } -// Implement from stakingkeeper interface -func (k Keeper) GetAllValidators(ctx sdk.Context) (validators []stakingtypes.Validator) { - store := ctx.KVStore(k.storeKey) - - iterator := sdk.KVStorePrefixIterator(store, stakingtypes.ValidatorsKey) - defer iterator.Close() - - for ; iterator.Valid(); iterator.Next() { - validator := stakingtypes.MustUnmarshalValidator(k.cdc, iterator.Value()) - validators = append(validators, validator) - } - - return validators -} - // getAndIncrementPendingPacketsIdx returns the current pending packets index and increments it. // This index is used for implementing a FIFO queue of pending packets in the KV store. func (k Keeper) getAndIncrementPendingPacketsIdx(ctx sdk.Context) (toReturn uint64) { diff --git a/x/ccv/consumer/keeper/validators.go b/x/ccv/consumer/keeper/validators.go index 2233b22d28..c3c9638b4d 100644 --- a/x/ccv/consumer/keeper/validators.go +++ b/x/ccv/consumer/keeper/validators.go @@ -312,3 +312,9 @@ func (k Keeper) MustGetCurrentValidatorsAsABCIUpdates(ctx sdk.Context) []abci.Va func (k Keeper) ApplyAndReturnValidatorSetUpdates(sdk.Context) (updates []abci.ValidatorUpdate, err error) { return } + +// GetAllValidators is needed to implement StakingKeeper as expected by the Slashing module since cosmos-sdk/v0.47.x. +// Use GetAllCCValidator in places where access to all cross-chain validators is needed. +func (k Keeper) GetAllValidators(ctx sdk.Context) []stakingtypes.Validator { + return []stakingtypes.Validator{} +}