From db2b93ae17c005cc68e7df941cac156d35aeb94a Mon Sep 17 00:00:00 2001 From: jayy04 <103467857+jayy04@users.noreply.github.com> Date: Wed, 10 Apr 2024 13:32:07 -0400 Subject: [PATCH] Add upgrade handler for v4.1.0 (#1374) * Add upgrade handler for v4.1.0 * update upgrade to version * update package name --- protocol/app/upgrades.go | 13 ++++++------- protocol/app/upgrades/v4.1.0/constants.go | 13 +++++++++++++ protocol/app/upgrades/v4.1.0/upgrade.go | 21 +++++++++++++++++++++ protocol/testing/containertest/testnet.go | 2 +- 4 files changed, 41 insertions(+), 8 deletions(-) create mode 100644 protocol/app/upgrades/v4.1.0/constants.go create mode 100644 protocol/app/upgrades/v4.1.0/upgrade.go diff --git a/protocol/app/upgrades.go b/protocol/app/upgrades.go index 41d69b8577..bdddd819ba 100644 --- a/protocol/app/upgrades.go +++ b/protocol/app/upgrades.go @@ -6,14 +6,14 @@ import ( upgradetypes "cosmossdk.io/x/upgrade/types" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/dydxprotocol/v4-chain/protocol/app/upgrades" - v4_0_0 "github.com/dydxprotocol/v4-chain/protocol/app/upgrades/v4.0.0" + v4_1_0 "github.com/dydxprotocol/v4-chain/protocol/app/upgrades/v4.1.0" ) var ( // `Upgrades` defines the upgrade handlers and store loaders for the application. // New upgrades should be added to this slice after they are implemented. Upgrades = []upgrades.Upgrade{ - v4_0_0.Upgrade, + v4_1_0.Upgrade, } Forks = []upgrades.Fork{} ) @@ -21,15 +21,14 @@ var ( // setupUpgradeHandlers registers the upgrade handlers to perform custom upgrade // logic and state migrations for software upgrades. func (app *App) setupUpgradeHandlers() { - if app.UpgradeKeeper.HasHandler(v4_0_0.UpgradeName) { - panic(fmt.Sprintf("Cannot register duplicate upgrade handler '%s'", v4_0_0.UpgradeName)) + if app.UpgradeKeeper.HasHandler(v4_1_0.UpgradeName) { + panic(fmt.Sprintf("Cannot register duplicate upgrade handler '%s'", v4_1_0.UpgradeName)) } app.UpgradeKeeper.SetUpgradeHandler( - v4_0_0.UpgradeName, - v4_0_0.CreateUpgradeHandler( + v4_1_0.UpgradeName, + v4_1_0.CreateUpgradeHandler( app.ModuleManager, app.configurator, - app.RatelimitKeeper, ), ) } diff --git a/protocol/app/upgrades/v4.1.0/constants.go b/protocol/app/upgrades/v4.1.0/constants.go new file mode 100644 index 0000000000..442abc51bf --- /dev/null +++ b/protocol/app/upgrades/v4.1.0/constants.go @@ -0,0 +1,13 @@ +package v_4_1_0 + +import ( + "github.com/dydxprotocol/v4-chain/protocol/app/upgrades" +) + +const ( + UpgradeName = "v4.1.0" +) + +var Upgrade = upgrades.Upgrade{ + UpgradeName: UpgradeName, +} diff --git a/protocol/app/upgrades/v4.1.0/upgrade.go b/protocol/app/upgrades/v4.1.0/upgrade.go new file mode 100644 index 0000000000..253dbd47ba --- /dev/null +++ b/protocol/app/upgrades/v4.1.0/upgrade.go @@ -0,0 +1,21 @@ +package v_4_1_0 + +import ( + "context" + "fmt" + + upgradetypes "cosmossdk.io/x/upgrade/types" + "github.com/cosmos/cosmos-sdk/types/module" + "github.com/dydxprotocol/v4-chain/protocol/lib" +) + +func CreateUpgradeHandler( + mm *module.Manager, + configurator module.Configurator, +) upgradetypes.UpgradeHandler { + return func(ctx context.Context, plan upgradetypes.Plan, vm module.VersionMap) (module.VersionMap, error) { + sdkCtx := lib.UnwrapSDKContext(ctx, "app/upgrades") + sdkCtx.Logger().Info(fmt.Sprintf("Running %s Upgrade...", UpgradeName)) + return mm.RunMigrations(ctx, configurator, vm) + } +} diff --git a/protocol/testing/containertest/testnet.go b/protocol/testing/containertest/testnet.go index 660ef58224..72ee7bf08b 100644 --- a/protocol/testing/containertest/testnet.go +++ b/protocol/testing/containertest/testnet.go @@ -25,7 +25,7 @@ const persistentPeers = "17e5e45691f0d01449c84fd4ae87279578cdd7ec@testnet-local- const resourceLifetimeSecs = 600 // The version of that we're upgrading to (aka the current commit) -const UpgradeToVersion = "v4.0.0" +const UpgradeToVersion = "v4.1.0" func monikers() map[string]string { return map[string]string{