Skip to content

Commit

Permalink
Address comments
Browse files Browse the repository at this point in the history
  • Loading branch information
p-offtermatt committed Jul 2, 2024
1 parent 5e30dd9 commit 43aa65a
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 12 deletions.
2 changes: 1 addition & 1 deletion x/ccv/provider/keeper/provider_consensus.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down
4 changes: 2 additions & 2 deletions x/ccv/provider/keeper/validator_set_storage.go
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
16 changes: 8 additions & 8 deletions x/ccv/provider/keeper/validator_set_update.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

Expand All @@ -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
Expand All @@ -38,29 +38,29 @@ 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`
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`
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
Expand Down
2 changes: 1 addition & 1 deletion x/ccv/provider/types/keys.go
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit 43aa65a

Please sign in to comment.