diff --git a/x/ccv/provider/migrations/vX/migrations.go b/x/ccv/provider/migrations/vX/migrations.go new file mode 100644 index 0000000000..9040c82ee2 --- /dev/null +++ b/x/ccv/provider/migrations/vX/migrations.go @@ -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)) + } +}