Skip to content

Commit

Permalink
tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
danwt committed Jan 13, 2025
1 parent dc11167 commit d173a9e
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 6 deletions.
7 changes: 4 additions & 3 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -1156,9 +1156,10 @@ func (app *App) setupUpgradeHandler(u upgrades.Upgrade) {
u.Name,
u.CreateHandler(
upgrades.UpgradeKeepers{
RpKeeper: app.RollappParamsKeeper,
EvmKeeper: app.EvmKeeper,
HubgenK: app.HubGenesisKeeper,
RpKeeper: app.RollappParamsKeeper,
EvmKeeper: app.EvmKeeper,
HubgenK: app.HubGenesisKeeper,
Erc20keeper: app.Erc20Keeper,
},
app.mm,
app.configurator,
Expand Down
31 changes: 31 additions & 0 deletions app/upgrades/drs-5-from2d/upgrade.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,17 @@ package drs5from2d
import (
"fmt"

errorsmod "cosmossdk.io/errors"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/module"
upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types"
hubgenkeeper "github.com/dymensionxyz/dymension-rdk/x/hub-genesis/keeper"
hubgenesistypes "github.com/dymensionxyz/dymension-rdk/x/hub-genesis/types"
rollappparamskeeper "github.com/dymensionxyz/dymension-rdk/x/rollappparams/keeper"
"github.com/dymensionxyz/rollapp-evm/app/upgrades"
erc20keeper "github.com/evmos/evmos/v12/x/erc20/keeper"
erc20types "github.com/evmos/evmos/v12/x/erc20/types"
evmkeeper "github.com/evmos/evmos/v12/x/evm/keeper"
)

func CreateUpgradeHandler(
Expand All @@ -33,6 +37,10 @@ func CreateUpgradeHandler(
return nil, fmt.Errorf("migrate rollapp params: %w", err)
}

if err := migrateEvmosParams(ctx, kk.EvmKeeper, kk.Erc20keeper); err != nil {
return nil, fmt.Errorf("migrate rollapp params: %w", err)
}

return vmap, nil
}
}
Expand Down Expand Up @@ -61,3 +69,26 @@ func migrateRollappParams(ctx sdk.Context, k rollappparamskeeper.Keeper) error {
// no need to set min gas prices, rollapp can do it when it likes
return nil
}

// migration v12.1.6-dymension-v0.4.3 -> v12.1.6-dymension-v0.5.0-rc02
func migrateEvmosParams(ctx sdk.Context, evmK *evmkeeper.Keeper, erc20K erc20keeper.Keeper) error {

{
p := evmK.GetParams(ctx)
p.GasDenom = p.EvmDenom

if err := evmK.SetParams(ctx, p); err != nil {
return errorsmod.Wrap(err, "evm set params")
}
}

{
p := erc20K.GetParams(ctx)
p.RegistrationFee = erc20types.DefaultRegistrationFee
if err := erc20K.SetParams(ctx, p); err != nil {
return errorsmod.Wrap(err, "erc20 set params")
}
}

return nil
}
7 changes: 7 additions & 0 deletions app/upgrades/drs-5-from2d/upgrade_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"testing"

up "github.com/dymensionxyz/rollapp-evm/app/upgrades/drs-5-from2d"
erc20types "github.com/evmos/evmos/v12/x/erc20/types"
abci "github.com/tendermint/tendermint/abci/types"

upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types"
Expand Down Expand Up @@ -52,4 +53,10 @@ func TestBeginBlocker(t *testing.T) {
p := app.RollappParamsKeeper.GetParams(ctx)
require.Equal(t, up.DRS, p.DrsVersion, "Version should be set to DRS")
require.Equal(t, up.DA, p.Da, "Version should be set to DRS")

evmParams := app.EvmKeeper.GetParams(ctx)
require.Equal(t, evmParams.GasDenom, evmParams.EvmDenom, "GasDenom should be set to EvmDenom")

erc20Params := app.Erc20Keeper.GetParams(ctx)
require.Equal(t, erc20Params.RegistrationFee, erc20types.DefaultRegistrationFee, "RegistrationFee should be set to DefaultRegistrationFee")
}
8 changes: 5 additions & 3 deletions app/upgrades/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,15 @@ import (
upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types"
hubgenkeeper "github.com/dymensionxyz/dymension-rdk/x/hub-genesis/keeper"
rollappparamskeeper "github.com/dymensionxyz/dymension-rdk/x/rollappparams/keeper"
erc20keeper "github.com/evmos/evmos/v12/x/erc20/keeper"
evmkeeper "github.com/evmos/evmos/v12/x/evm/keeper"
)

type UpgradeKeepers struct {
RpKeeper rollappparamskeeper.Keeper
EvmKeeper *evmkeeper.Keeper
HubgenK hubgenkeeper.Keeper
RpKeeper rollappparamskeeper.Keeper
EvmKeeper *evmkeeper.Keeper
Erc20keeper erc20keeper.Keeper
HubgenK hubgenkeeper.Keeper
}

// Upgrade defines a struct containing necessary fields that a SoftwareUpgradeProposal
Expand Down

0 comments on commit d173a9e

Please sign in to comment.