Skip to content

Commit

Permalink
Add upgrade handler for v4.1.0 (#1374)
Browse files Browse the repository at this point in the history
* Add upgrade handler for v4.1.0

* update upgrade to version

* update package name
  • Loading branch information
jayy04 authored Apr 10, 2024
1 parent cdb49b0 commit db2b93a
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 8 deletions.
13 changes: 6 additions & 7 deletions protocol/app/upgrades.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,30 +6,29 @@ 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{}
)

// 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,
),
)
}
Expand Down
13 changes: 13 additions & 0 deletions protocol/app/upgrades/v4.1.0/constants.go
Original file line number Diff line number Diff line change
@@ -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,
}
21 changes: 21 additions & 0 deletions protocol/app/upgrades/v4.1.0/upgrade.go
Original file line number Diff line number Diff line change
@@ -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)
}
}
2 changes: 1 addition & 1 deletion protocol/testing/containertest/testnet.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Expand Down

0 comments on commit db2b93a

Please sign in to comment.