Skip to content

Commit

Permalink
typo in GetAllConsumersWithIBCClients
Browse files Browse the repository at this point in the history
  • Loading branch information
mpoke committed Sep 4, 2024
1 parent 2f7e04c commit e41f7fd
Show file tree
Hide file tree
Showing 10 changed files with 16 additions and 16 deletions.
2 changes: 1 addition & 1 deletion x/ccv/provider/keeper/distribution.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ func (k Keeper) AllocateTokens(ctx sdk.Context) {
// Iterate over all launched consumer chains.
// To avoid large iterations over all the consumer IDs, iterate only over
// chains with an IBC client created.
for _, consumerId := range k.GetAllConsumerWithIBCClients(ctx) {
for _, consumerId := range k.GetAllConsumersWithIBCClients(ctx) {

// note that it's possible that no rewards are collected even though the
// reward pool isn't empty. This can happen if the reward pool holds some tokens
Expand Down
4 changes: 2 additions & 2 deletions x/ccv/provider/keeper/genesis.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,13 +119,13 @@ func (k Keeper) InitGenesisValUpdates(ctx sdk.Context) []abci.ValidatorUpdate {

// ExportGenesis returns the CCV provider module's exported genesis
func (k Keeper) ExportGenesis(ctx sdk.Context) *types.GenesisState {
launchedConsumerIds := k.GetAllConsumerWithIBCClients(ctx)
launchedConsumerIds := k.GetAllConsumersWithIBCClients(ctx)

// export states for each consumer chains
var consumerStates []types.ConsumerState
for _, consumerId := range launchedConsumerIds {
// no need for the second return value of GetConsumerClientId
// as GetAllConsumerWithIBCClients already iterated through
// as GetAllConsumersWithIBCClients already iterated through
// the entire prefix range
clientId, _ := k.GetConsumerClientId(ctx, consumerId)
gen, found := k.GetConsumerGenesis(ctx, consumerId)
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 @@ -426,7 +426,7 @@ func (k Keeper) QueryConsumerChainsValidatorHasToValidate(goCtx context.Context,
consumersToValidate := []string{}
// To avoid large iterations over all the consumer IDs, iterate only over
// chains with an IBC client created.
for _, consumerId := range k.GetAllConsumerWithIBCClients(ctx) {
for _, consumerId := range k.GetAllConsumersWithIBCClients(ctx) {
if hasToValidate, err := k.hasToValidate(ctx, provAddr, consumerId); err == nil && hasToValidate {
consumersToValidate = append(consumersToValidate, consumerId)
}
Expand Down
2 changes: 1 addition & 1 deletion x/ccv/provider/keeper/grpc_query_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,7 @@ func TestQueryConsumerChainsValidatorHasToValidate(t *testing.T) {
require.NoError(t, err)
consumerId := resp.ConsumerId

// set a consumer client id, so that `GetAllConsumerWithIBCClients` is non-empty
// set a consumer client id, so that `GetAllConsumersWithIBCClients` is non-empty
clientID := "client-" + strconv.Itoa(i)
pk.SetConsumerClientId(ctx, consumerId, clientID)

Expand Down
4 changes: 2 additions & 2 deletions x/ccv/provider/keeper/keeper.go
Original file line number Diff line number Diff line change
Expand Up @@ -211,8 +211,8 @@ func (k Keeper) DeleteConsumerIdToChannelId(ctx sdk.Context, consumerId string)
store.Delete(types.ConsumerIdToChannelIdKey(consumerId))
}

// GetAllConsumerWithIBCClients returns all ids of consumer chains that with IBC clients created.
func (k Keeper) GetAllConsumerWithIBCClients(ctx sdk.Context) []string {
// GetAllConsumersWithIBCClients returns all ids of consumer chains that with IBC clients created.
func (k Keeper) GetAllConsumersWithIBCClients(ctx sdk.Context) []string {
consumerIds := []string{}

// All launched chains have created an IBC client when they launched (see `LaunchConsumer`), so we traverse over
Expand Down
4 changes: 2 additions & 2 deletions x/ccv/provider/keeper/keeper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ func TestInitHeight(t *testing.T) {
}
}

func TestGetAllConsumerWithIBCClients(t *testing.T) {
func TestGetAllConsumersWithIBCClients(t *testing.T) {
pk, ctx, ctrl, _ := testkeeper.GetProviderKeeperAndCtx(t, testkeeper.NewInMemKeeperParams(t))
defer ctrl.Finish()

Expand All @@ -234,7 +234,7 @@ func TestGetAllConsumerWithIBCClients(t *testing.T) {
pk.SetConsumerPhase(ctx, consumerId, providertypes.ConsumerPhase_CONSUMER_PHASE_LAUNCHED)
}

actualConsumerIds := pk.GetAllConsumerWithIBCClients(ctx)
actualConsumerIds := pk.GetAllConsumersWithIBCClients(ctx)
require.Len(t, actualConsumerIds, len(consumerIds))

// sort the consumer ids before comparing they are equal
Expand Down
6 changes: 3 additions & 3 deletions x/ccv/provider/keeper/relay.go
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ func (k Keeper) BlocksUntilNextEpoch(ctx sdk.Context) int64 {
//
// TODO (mpoke): iterate only over consumers with established channel
func (k Keeper) SendVSCPackets(ctx sdk.Context) error {
for _, consumerId := range k.GetAllConsumerWithIBCClients(ctx) {
for _, consumerId := range k.GetAllConsumersWithIBCClients(ctx) {
// check if CCV channel is established and send
if channelID, found := k.GetConsumerIdToChannelId(ctx, consumerId); found {
if err := k.SendVSCPacketsToChain(ctx, consumerId, channelID); err != nil {
Expand Down Expand Up @@ -213,7 +213,7 @@ func (k Keeper) QueueVSCPackets(ctx sdk.Context) error {
return fmt.Errorf("getting provider active validators: %w", err)
}

for _, consumerId := range k.GetAllConsumerWithIBCClients(ctx) {
for _, consumerId := range k.GetAllConsumersWithIBCClients(ctx) {
currentValidators, err := k.GetConsumerValSet(ctx, consumerId)
if err != nil {
return fmt.Errorf("getting consumer validators, consumerId(%s): %w", consumerId, err)
Expand Down Expand Up @@ -286,7 +286,7 @@ func (k Keeper) EndBlockCIS(ctx sdk.Context) {
k.Logger(ctx).Debug("vscID was mapped to block height", "vscID", valUpdateID, "height", blockHeight)

// prune previous consumer validator addresses that are no longer needed
for _, consumerId := range k.GetAllConsumerWithIBCClients(ctx) {
for _, consumerId := range k.GetAllConsumersWithIBCClients(ctx) {
k.PruneKeyAssignments(ctx, consumerId)
}
}
Expand Down
4 changes: 2 additions & 2 deletions x/ccv/provider/keeper/relay_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ func TestQueueVSCPacketsDoesNotResetConsumerValidatorsHeights(t *testing.T) {
mocks.MockStakingKeeper.EXPECT().GetValidatorByConsAddr(ctx, valBConsAddr).Return(valB, nil).AnyTimes()
testkeeper.SetupMocksForLastBondedValidatorsExpectation(mocks.MockStakingKeeper, 2, []stakingtypes.Validator{valA, valB}, -1)

// set a consumer client id and its phase, so we have a consumer chain (i.e., `GetAllConsumerWithIBCClients` is non-empty)
// set a consumer client id and its phase, so we have a consumer chain (i.e., `GetAllConsumersWithIBCClients` is non-empty)
providerKeeper.SetConsumerClientId(ctx, "consumerId", "clientID")
providerKeeper.SetConsumerPhase(ctx, "consumerId", providertypes.ConsumerPhase_CONSUMER_PHASE_LAUNCHED)

Expand Down Expand Up @@ -667,7 +667,7 @@ func TestEndBlockVSU(t *testing.T) {
})
mocks.MockStakingKeeper.EXPECT().GetBondedValidatorsByPower(gomock.Any()).Return(lastValidators, nil).AnyTimes()

// set a sample client for a launched consumer chain so that `GetAllConsumerWithIBCClients` in `QueueVSCPackets` iterates at least once
// set a sample client for a launched consumer chain so that `GetAllConsumersWithIBCClients` in `QueueVSCPackets` iterates at least once
providerKeeper.SetConsumerClientId(ctx, consumerId, "clientId")
providerKeeper.SetConsumerPowerShapingParameters(ctx, consumerId, providertypes.PowerShapingParameters{Top_N: 100})
providerKeeper.SetConsumerPhase(ctx, consumerId, providertypes.ConsumerPhase_CONSUMER_PHASE_LAUNCHED)
Expand Down
2 changes: 1 addition & 1 deletion x/ccv/provider/migrations/v5/migrations.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import (
// TODO (PERMISSIONLESS): this migration needs to be fix or removed
func MigrateTopNForRegisteredChains(ctx sdk.Context, providerKeeper providerkeeper.Keeper) {
// Set the topN of each chain to 95
for _, consumerId := range providerKeeper.GetAllConsumerWithIBCClients(ctx) {
for _, consumerId := range providerKeeper.GetAllConsumersWithIBCClients(ctx) {
// TODO (PERMISSIONLESS): this migration already took place and does not make much sense in the Permissionless world
// living here for now and we should totally remove
providerKeeper.SetConsumerPowerShapingParameters(ctx, consumerId, types.PowerShapingParameters{
Expand Down
2 changes: 1 addition & 1 deletion x/ccv/provider/migrations/v6/migrations.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ func MigrateParams(ctx sdk.Context, paramsSubspace paramtypes.Subspace) {
func MigrateMinPowerInTopN(ctx sdk.Context, providerKeeper providerkeeper.Keeper) {
// we only get the registered consumer chains and not also the proposed consumer chains because
// the minimal power is first set when the consumer chain addition proposal passes
registeredConsumerChains := providerKeeper.GetAllConsumerWithIBCClients(ctx)
registeredConsumerChains := providerKeeper.GetAllConsumersWithIBCClients(ctx)

for _, chain := range registeredConsumerChains {
// get the top N
Expand Down

0 comments on commit e41f7fd

Please sign in to comment.