generated from dymensionxyz/rollapp
-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add DRS3 upgrade handler (#409)
- Loading branch information
Showing
5 changed files
with
78 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package drs3 | ||
|
||
import ( | ||
storetypes "github.com/cosmos/cosmos-sdk/store/types" | ||
|
||
"github.com/dymensionxyz/rollapp-evm/app/upgrades" | ||
) | ||
|
||
const ( | ||
UpgradeName = "drs-3" | ||
) | ||
|
||
var Upgrade = upgrades.Upgrade{ | ||
Name: UpgradeName, | ||
CreateHandler: CreateUpgradeHandler, | ||
StoreUpgrades: storetypes.StoreUpgrades{}, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package drs3 | ||
|
||
import ( | ||
sdk "github.com/cosmos/cosmos-sdk/types" | ||
"github.com/cosmos/cosmos-sdk/types/module" | ||
upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types" | ||
rollappparamskeeper "github.com/dymensionxyz/dymension-rdk/x/rollappparams/keeper" | ||
evmkeeper "github.com/evmos/evmos/v12/x/evm/keeper" | ||
|
||
drs2 "github.com/dymensionxyz/rollapp-evm/app/upgrades/drs-2" | ||
) | ||
|
||
func CreateUpgradeHandler( | ||
rpKeeper rollappparamskeeper.Keeper, | ||
evmKeeper *evmkeeper.Keeper, | ||
mm *module.Manager, | ||
configurator module.Configurator, | ||
) upgradetypes.UpgradeHandler { | ||
return func(ctx sdk.Context, plan upgradetypes.Plan, fromVM module.VersionMap) (module.VersionMap, error) { | ||
if rpKeeper.GetParams(ctx).DrsVersion == 1 { | ||
// first run drs-2 migration | ||
if err := drs2.HandleUpgrade(ctx, rpKeeper, evmKeeper); err != nil { | ||
return nil, err | ||
} | ||
} | ||
// upgrade drs to 3 | ||
err := rpKeeper.SetVersion(ctx, uint32(3)) | ||
if err != nil { | ||
return nil, err | ||
} | ||
return mm.RunMigrations(ctx, configurator, fromVM) | ||
} | ||
} |