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(upgrade): add drs 2 upgrade handler (#396)
Co-authored-by: omritoptix <[email protected]> Co-authored-by: keruch <[email protected]>
- Loading branch information
1 parent
6555be4
commit 950d2ba
Showing
9 changed files
with
132 additions
and
60 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,19 @@ | ||
package drs2 | ||
|
||
import ( | ||
storetypes "github.com/cosmos/cosmos-sdk/store/types" | ||
"github.com/dymensionxyz/rollapp-evm/app/upgrades" | ||
claimstypes "github.com/evmos/evmos/v12/x/claims/types" | ||
) | ||
|
||
const ( | ||
UpgradeName = "drs-2" | ||
) | ||
|
||
var Upgrade = upgrades.Upgrade{ | ||
Name: UpgradeName, | ||
CreateHandler: CreateUpgradeHandler, | ||
StoreUpgrades: storetypes.StoreUpgrades{ | ||
Deleted: []string{claimstypes.ModuleName}, | ||
}, | ||
} |
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 drs2 | ||
|
||
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" | ||
rollappparamstypes "github.com/dymensionxyz/dymension-rdk/x/rollappparams/types" | ||
evmkeeper "github.com/evmos/evmos/v12/x/evm/keeper" | ||
evmtypes "github.com/evmos/evmos/v12/x/evm/types" | ||
) | ||
|
||
func CreateUpgradeHandler( | ||
rpKeeper rollappparamskeeper.Keeper, | ||
evmKeeper *evmkeeper.Keeper, | ||
mm *module.Manager, | ||
configurator module.Configurator, | ||
) upgradetypes.UpgradeHandler { | ||
return func(ctx sdk.Context, _ upgradetypes.Plan, fromVM module.VersionMap) (module.VersionMap, error) { | ||
|
||
//migrate rollapp params with missing min-gas-prices and updating drs to 2 | ||
err := rpKeeper.SetVersion(ctx, uint32(2)) | ||
if err != nil { | ||
return nil, err | ||
} | ||
err = rpKeeper.SetMinGasPrices(ctx, rollappparamstypes.DefaultParams().MinGasPrices) | ||
if err != nil { | ||
return nil, err | ||
} | ||
//migrate evm params with missing gasDenom | ||
evmOldParams := evmKeeper.GetParams(ctx) | ||
evmOldParams.GasDenom = evmtypes.DefaultParams().GasDenom | ||
err = evmKeeper.SetParams(ctx, evmOldParams) | ||
if err != nil { | ||
return nil, err | ||
} | ||
return mm.RunMigrations(ctx, configurator, fromVM) | ||
} | ||
} |
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,29 @@ | ||
package upgrades | ||
|
||
import ( | ||
storetypes "github.com/cosmos/cosmos-sdk/store/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" | ||
) | ||
|
||
// Upgrade defines a struct containing necessary fields that a SoftwareUpgradeProposal | ||
// must have written, in order for the state migration to go smoothly. | ||
// An upgrade must implement this struct, and then set it in the app.go. | ||
// The app.go will then define the handler. | ||
type Upgrade struct { | ||
// Upgrade version name, for the upgrade handler, e.g. `v4` | ||
Name string | ||
|
||
// CreateHandler defines the function that creates an upgrade handler | ||
CreateHandler func( | ||
rpKeeper rollappparamskeeper.Keeper, | ||
evmKeeper *evmkeeper.Keeper, | ||
mm *module.Manager, | ||
configurator module.Configurator, | ||
) upgradetypes.UpgradeHandler | ||
|
||
// Store upgrades, should be used for any new modules introduced, new modules deleted, or store names renamed. | ||
StoreUpgrades storetypes.StoreUpgrades | ||
} |
This file was deleted.
Oops, something went wrong.
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