Skip to content

Commit

Permalink
Add no-op v6.0.0_testnet_fix upgrade for testnet
Browse files Browse the repository at this point in the history
  • Loading branch information
roy-dydx committed Sep 3, 2024
1 parent d52316e commit 0586fa1
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 0 deletions.
16 changes: 16 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,20 @@ func (app *App) setupUpgradeHandlers() {
app.VaultKeeper,
),
)
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_0v6_0_0_testnet_fix_0.UpgradeName,
v6_0_0_testnet_fix.CreateUpgradeHandler(
app.ModuleManager,
app.configurator,
app.ClobKeeper,
app.PricesKeeper,
app.MarketMapKeeper,
app.RevShareKeeper,
app.VaultKeeper,
),
}

// setUpgradeStoreLoaders sets custom store loaders to customize the rootMultiStore
Expand Down
18 changes: 18 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,18 @@
package v_6_0_0_testnet_fix

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

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

const (
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 0586fa1

Please sign in to comment.