Skip to content

Commit

Permalink
feat: Initialize the max validators parameter for existing consumers (#…
Browse files Browse the repository at this point in the history
…2012)

* Add initialization for validator cap

* Remove migration test

* Fix inconsistent naming
  • Loading branch information
p-offtermatt authored Jul 15, 2024
1 parent 9c5028b commit 60e9e7f
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions x/ccv/provider/migrations/vX/migrations.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package v6

import (
sdk "github.com/cosmos/cosmos-sdk/types"
providerkeeper "github.com/cosmos/interchain-security/v5/x/ccv/provider/keeper"
)

// InitializeMaxValidatorsForExistingConsumers initializes the max validators
// parameter for existing consumers to the MaxProviderConsensusValidators parameter.
// This is necessary to avoid those consumer chains having an excessive amount of validators.
func InitializeMaxValidatorsForExistingConsumers(ctx sdk.Context, providerKeeper providerkeeper.Keeper) {
maxVals := providerKeeper.GetParams(ctx).MaxProviderConsensusValidators
for _, chainID := range providerKeeper.GetAllRegisteredConsumerChainIDs(ctx) {
providerKeeper.SetValidatorSetCap(ctx, chainID, uint32(maxVals))
}
}

0 comments on commit 60e9e7f

Please sign in to comment.