generated from dymensionxyz/rollapp
-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(drs): upgrade handler for DRS 5 (#431)
- Loading branch information
Showing
7 changed files
with
82 additions
and
17 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
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 drs5 | ||
|
||
import ( | ||
storetypes "github.com/cosmos/cosmos-sdk/store/types" | ||
|
||
"github.com/dymensionxyz/rollapp-evm/app/upgrades" | ||
) | ||
|
||
const ( | ||
UpgradeName = "drs-5" | ||
) | ||
|
||
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,39 @@ | ||
package drs5 | ||
|
||
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" | ||
|
||
drs4 "github.com/dymensionxyz/rollapp-evm/app/upgrades/drs-4" | ||
) | ||
|
||
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 err := HandleUpgrade(ctx, rpKeeper, evmKeeper); err != nil { | ||
return nil, err | ||
} | ||
return mm.RunMigrations(ctx, configurator, fromVM) | ||
} | ||
} | ||
|
||
func HandleUpgrade(ctx sdk.Context, rpKeeper rollappparamskeeper.Keeper, evmKeeper *evmkeeper.Keeper) error { | ||
if rpKeeper.Version(ctx) < 4 { | ||
// first run drs-4 migration | ||
if err := drs4.HandleUpgrade(ctx, rpKeeper, evmKeeper); err != nil { | ||
return err | ||
} | ||
} | ||
// upgrade drs to 5 | ||
if err := rpKeeper.SetVersion(ctx, uint32(5)); err != nil { | ||
return err | ||
} | ||
return nil | ||
} |
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