From 0c2b4271cea1f429fb0f2d52e50a92ca58ec43c9 Mon Sep 17 00:00:00 2001 From: Philip Offtermatt Date: Mon, 29 Jul 2024 14:18:25 +0200 Subject: [PATCH] Add migration in UPGRADING.md --- UPGRADING.md | 27 ++++++++++++++++++++++ x/ccv/provider/migrations/vX/migrations.go | 25 -------------------- 2 files changed, 27 insertions(+), 25 deletions(-) delete mode 100644 x/ccv/provider/migrations/vX/migrations.go diff --git a/UPGRADING.md b/UPGRADING.md index 1f25aa3d08..0986fb6279 100644 --- a/UPGRADING.md +++ b/UPGRADING.md @@ -1,5 +1,32 @@ # Upgrading Replicated Security +## ... + +### Provider + +Upgrading a provider from X to Y requires state migrations. The following migrators should be added to the upgrade handler of the provider chain: + +```go +// 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)) + } +} + +// InitializeMaxProviderConsensusParam initializes the MaxProviderConsensusValidators parameter. +func InitializeMaxProviderConsensusParam(ctx sdk.Context, providerKeeper providerkeeper.Keeper) { + params := providerKeeper.GetParams(ctx) + if params.MaxProviderConsensusValidators == 0 { + params.MaxProviderConsensusValidators = 180 + providerKeeper.SetParams(ctx, params) + } +} +``` + ## [v5.1.x](https://github.com/cosmos/interchain-security/releases/tag/v5.1.0) ### Provider diff --git a/x/ccv/provider/migrations/vX/migrations.go b/x/ccv/provider/migrations/vX/migrations.go deleted file mode 100644 index acf8399ba8..0000000000 --- a/x/ccv/provider/migrations/vX/migrations.go +++ /dev/null @@ -1,25 +0,0 @@ -package vX - -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)) - } -} - -// InitializeMaxProviderConsensusParam initializes the MaxProviderConsensusValidators parameter. -func InitializeMaxProviderConsensusParam(ctx sdk.Context, providerKeeper providerkeeper.Keeper) { - params := providerKeeper.GetParams(ctx) - if params.MaxProviderConsensusValidators == 0 { - params.MaxProviderConsensusValidators = 180 - providerKeeper.SetParams(ctx, params) - } -}