From 43aa65ad4a893e46d127d76f23a1e871ce96479c Mon Sep 17 00:00:00 2001 From: Philip Offtermatt Date: Tue, 2 Jul 2024 17:23:35 +0200 Subject: [PATCH] Address comments --- x/ccv/provider/keeper/provider_consensus.go | 2 +- x/ccv/provider/keeper/validator_set_storage.go | 4 ++-- x/ccv/provider/keeper/validator_set_update.go | 16 ++++++++-------- x/ccv/provider/types/keys.go | 2 +- 4 files changed, 12 insertions(+), 12 deletions(-) diff --git a/x/ccv/provider/keeper/provider_consensus.go b/x/ccv/provider/keeper/provider_consensus.go index 7212842411..9b33189d2f 100644 --- a/x/ccv/provider/keeper/provider_consensus.go +++ b/x/ccv/provider/keeper/provider_consensus.go @@ -17,7 +17,7 @@ func (k Keeper) SetLastProviderConsensusValidator( } // SetLastProviderConsensusValSet resets the stored last validator set sent to the consensus engine on the provider -// to the provided nextValidators. +// to the provided `nextValidators“. func (k Keeper) SetLastProviderConsensusValSet(ctx sdk.Context, nextValidators []types.ConsumerValidator) { k.setValSet(ctx, []byte{types.LastProviderConsensusValsPrefix}, nextValidators) } diff --git a/x/ccv/provider/keeper/validator_set_storage.go b/x/ccv/provider/keeper/validator_set_storage.go index 71be6cca5a..d02dc7d92c 100644 --- a/x/ccv/provider/keeper/validator_set_storage.go +++ b/x/ccv/provider/keeper/validator_set_storage.go @@ -77,10 +77,10 @@ func (k Keeper) isValidator(ctx sdk.Context, prefix []byte, providerAddr types.P // getValSet returns all the validators stored under the given prefix. func (k Keeper) getValSet( ctx sdk.Context, - key []byte, + prefix []byte, ) (validators []types.ConsumerValidator) { store := ctx.KVStore(k.storeKey) - iterator := storetypes.KVStorePrefixIterator(store, key) + iterator := storetypes.KVStorePrefixIterator(store, prefix) defer iterator.Close() for ; iterator.Valid(); iterator.Next() { diff --git a/x/ccv/provider/keeper/validator_set_update.go b/x/ccv/provider/keeper/validator_set_update.go index 1bf12748ae..329c633b41 100644 --- a/x/ccv/provider/keeper/validator_set_update.go +++ b/x/ccv/provider/keeper/validator_set_update.go @@ -12,8 +12,8 @@ import ( ccv "github.com/cosmos/interchain-security/v5/x/ccv/types" ) -// GetConsumerChainKey returns the store key for consumer validators of the consumer chain with `chainID` -func (k Keeper) GetConsumerChainKey(ctx sdk.Context, chainID string) []byte { +// GetConsumerChainConsensusValidatorsKey returns the store key for consumer validators of the consumer chain with `chainID` +func (k Keeper) GetConsumerChainConsensusValidatorsKey(ctx sdk.Context, chainID string) []byte { return types.ChainIdWithLenKey(types.ConsumerValidatorBytePrefix, chainID) } @@ -23,13 +23,13 @@ func (k Keeper) SetConsumerValidator( chainID string, validator types.ConsumerValidator, ) { - k.setValidator(ctx, k.GetConsumerChainKey(ctx, chainID), validator) + k.setValidator(ctx, k.GetConsumerChainConsensusValidatorsKey(ctx, chainID), validator) } // SetConsumerValSet resets the current consumer validators with the `nextValidators` computed by // `FilterValidators` and hence this method should only be called after `FilterValidators` has completed. func (k Keeper) SetConsumerValSet(ctx sdk.Context, chainID string, nextValidators []types.ConsumerValidator) { - k.setValSet(ctx, k.GetConsumerChainKey(ctx, chainID), nextValidators) + k.setValSet(ctx, k.GetConsumerChainConsensusValidatorsKey(ctx, chainID), nextValidators) } // DeleteConsumerValidator removes consumer validator with `providerAddr` address @@ -38,7 +38,7 @@ func (k Keeper) DeleteConsumerValidator( chainID string, providerConsAddr types.ProviderConsAddress, ) { - k.deleteValidator(ctx, k.GetConsumerChainKey(ctx, chainID), providerConsAddr) + k.deleteValidator(ctx, k.GetConsumerChainConsensusValidatorsKey(ctx, chainID), providerConsAddr) } // DeleteConsumerValSet deletes all the stored consumer validators for chain `chainID` @@ -46,13 +46,13 @@ func (k Keeper) DeleteConsumerValSet( ctx sdk.Context, chainID string, ) { - k.deleteValSet(ctx, k.GetConsumerChainKey(ctx, chainID)) + k.deleteValSet(ctx, k.GetConsumerChainConsensusValidatorsKey(ctx, chainID)) } // IsConsumerValidator returns `true` if the consumer validator with `providerAddr` exists for chain `chainID` // and `false` otherwise func (k Keeper) IsConsumerValidator(ctx sdk.Context, chainID string, providerAddr types.ProviderConsAddress) bool { - return k.isValidator(ctx, k.GetConsumerChainKey(ctx, chainID), providerAddr) + return k.isValidator(ctx, k.GetConsumerChainConsensusValidatorsKey(ctx, chainID), providerAddr) } // GetConsumerValSet returns all the consumer validators for chain `chainID` @@ -60,7 +60,7 @@ func (k Keeper) GetConsumerValSet( ctx sdk.Context, chainID string, ) []types.ConsumerValidator { - return k.getValSet(ctx, k.GetConsumerChainKey(ctx, chainID)) + return k.getValSet(ctx, k.GetConsumerChainConsensusValidatorsKey(ctx, chainID)) } // DiffValidators compares the current and the next epoch's consumer validators and returns the `ValidatorUpdate` diff diff --git a/x/ccv/provider/types/keys.go b/x/ccv/provider/types/keys.go index 2e1315ff93..dba1b84254 100644 --- a/x/ccv/provider/types/keys.go +++ b/x/ccv/provider/types/keys.go @@ -187,7 +187,7 @@ const ( // minimum power required to be in the top N per consumer chain. MinimumPowerInTopNBytePrefix - // LastProviderConsensusValsPrefix is byte prefix for storing the last validator set + // LastProviderConsensusValsPrefix is the byte prefix for storing the last validator set // sent to the consensus engine of the provider chain LastProviderConsensusValsPrefix