Skip to content

Commit

Permalink
Add no-op v6.0.0_testnet_fix upgrade for testnet (#2184)
Browse files Browse the repository at this point in the history
  • Loading branch information
roy-dydx authored Sep 3, 2024
1 parent d52316e commit c466502
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 0 deletions.
13 changes: 13 additions & 0 deletions protocol/app/upgrades.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"fmt"

v6_0_0 "github.com/dydxprotocol/v4-chain/protocol/app/upgrades/v6.0.0"
v6_0_0_testnet_fix "github.com/dydxprotocol/v4-chain/protocol/app/upgrades/v6.0.0_testnet_fix"

upgradetypes "cosmossdk.io/x/upgrade/types"
sdk "github.com/cosmos/cosmos-sdk/types"
Expand All @@ -15,6 +16,7 @@ var (
// New upgrades should be added to this slice after they are implemented.
Upgrades = []upgrades.Upgrade{
v6_0_0.Upgrade,
v6_0_0_testnet_fix.Upgrade,
}
Forks = []upgrades.Fork{}
)
Expand All @@ -37,6 +39,17 @@ func (app *App) setupUpgradeHandlers() {
app.VaultKeeper,
),
)
// v6_0_0_testnet_fix not intended for prod use.
if app.UpgradeKeeper.HasHandler(v6_0_0_testnet_fix.UpgradeName) {
panic(fmt.Sprintf("Cannot register duplicate upgrade handler '%s'", v6_0_0_testnet_fix.UpgradeName))
}
app.UpgradeKeeper.SetUpgradeHandler(
v6_0_0_testnet_fix.UpgradeName,
v6_0_0_testnet_fix.CreateUpgradeHandler(
app.ModuleManager,
app.configurator,
),
)
}

// setUpgradeStoreLoaders sets custom store loaders to customize the rootMultiStore
Expand Down
19 changes: 19 additions & 0 deletions protocol/app/upgrades/v6.0.0_testnet_fix/constants.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package v_6_0_0_testnet_fix

import (
store "cosmossdk.io/store/types"

"github.com/dydxprotocol/v4-chain/protocol/app/upgrades"
)

const (
// v6_0_0_testnet_fix not intended for prod use.
UpgradeName = "v6.0.0_testnet_fix"
)

var (
Upgrade = upgrades.Upgrade{
UpgradeName: UpgradeName,
StoreUpgrades: store.StoreUpgrades{},
}
)
21 changes: 21 additions & 0 deletions protocol/app/upgrades/v6.0.0_testnet_fix/upgrade.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package v_6_0_0_testnet_fix

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)
}
}

0 comments on commit c466502

Please sign in to comment.