From 4358459650b186effc5754da8c1a69b139e5c5a8 Mon Sep 17 00:00:00 2001 From: Arnaud Mimart <33665250+amimart@users.noreply.github.com> Date: Thu, 29 Feb 2024 12:58:49 +0100 Subject: [PATCH] feat(app): register v7.0.0 software upgrade --- app/app.go | 2 +- app/upgrades.go | 24 ++++++++++++++++++++++++ app/upgrades/v7/upgrade.go | 20 ++++++++++++++++++++ 3 files changed, 45 insertions(+), 1 deletion(-) create mode 100644 app/upgrades.go create mode 100644 app/upgrades/v7/upgrade.go diff --git a/app/app.go b/app/app.go index 0f521b55..ca19bd4e 100644 --- a/app/app.go +++ b/app/app.go @@ -797,7 +797,7 @@ func New( // RegisterUpgradeHandlers is used for registering any on-chain upgrades. // Make sure it's called after `app.ModuleManager` and `app.configurator` are set. - // app.setupUpgradeHandlers() + app.RegisterUpgradeHandlers() autocliv1.RegisterQueryServer(app.GRPCQueryRouter(), runtimeservices.NewAutoCLIQueryService(app.ModuleManager.Modules)) reflectionSvc, err := runtimeservices.NewReflectionService() diff --git a/app/upgrades.go b/app/upgrades.go new file mode 100644 index 00000000..30e90650 --- /dev/null +++ b/app/upgrades.go @@ -0,0 +1,24 @@ +package app + +import ( + "fmt" + + v7 "github.com/okp4/okp4d/app/upgrades/v7" +) + +// RegisterUpgradeHandlers registers the chain upgrade handlers. +func (app *App) RegisterUpgradeHandlers() { + app.UpgradeKeeper.SetUpgradeHandler( + v7.UpgradeName, + v7.CreateUpgradeHandler(app.ModuleManager, app.configurator), + ) + + upgradeInfo, err := app.UpgradeKeeper.ReadUpgradeInfoFromDisk() + if err != nil { + panic(fmt.Sprintf("failed to read upgrade info from disk %s", err)) + } + + if app.UpgradeKeeper.IsSkipHeight(upgradeInfo.Height) { + return + } +} diff --git a/app/upgrades/v7/upgrade.go b/app/upgrades/v7/upgrade.go new file mode 100644 index 00000000..036d8346 --- /dev/null +++ b/app/upgrades/v7/upgrade.go @@ -0,0 +1,20 @@ +package v7 + +import ( + "context" + + upgradetypes "cosmossdk.io/x/upgrade/types" + + "github.com/cosmos/cosmos-sdk/types/module" +) + +var UpgradeName = "v7.0.0" + +func CreateUpgradeHandler( + mm *module.Manager, + configurator module.Configurator, +) upgradetypes.UpgradeHandler { + return func(ctx context.Context, _ upgradetypes.Plan, vm module.VersionMap) (module.VersionMap, error) { + return mm.RunMigrations(ctx, configurator, vm) + } +}