Skip to content

Commit

Permalink
added upgrade handler to fix light clients migration
Browse files Browse the repository at this point in the history
  • Loading branch information
mtsitrin committed Dec 28, 2024
1 parent e8530b0 commit dbdab1f
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 1 deletion.
2 changes: 1 addition & 1 deletion app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ var (
DefaultNodeHome string

// Upgrades contains the upgrade handlers for the application
Upgrades = []upgrades.Upgrade{v4.Upgrade}
Upgrades = []upgrades.Upgrade{v4.Upgrade, v4.UpgradeBlumbusHotfix}
)

func init() {
Expand Down
45 changes: 45 additions & 0 deletions app/upgrades/v4/blumbus_hotfix.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
package v4

import (
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/module"
upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types"

"github.com/dymensionxyz/dymension/v3/app/keepers"
"github.com/dymensionxyz/dymension/v3/app/upgrades"
)

const (
UpgradeNameBlumbusHotfix = "v4_blumbus_hotfix"
)

var UpgradeBlumbusHotfix = upgrades.Upgrade{
Name: UpgradeNameBlumbusHotfix,
CreateHandler: CreateBlumbusHotfixUpgradeHandler,
}

// CreateUpgradeHandler creates an SDK upgrade handler for v4
func CreateBlumbusHotfixUpgradeHandler(
mm *module.Manager,
configurator module.Configurator,
_ upgrades.BaseAppParamManager,
keepers *keepers.AppKeepers,
) upgradetypes.UpgradeHandler {
return func(ctx sdk.Context, _ upgradetypes.Plan, fromVM module.VersionMap) (module.VersionMap, error) {
setKeyTables(keepers)

if err := migrateRollappLightClients(ctx, keepers.RollappKeeper, keepers.LightClientKeeper, keepers.IBCKeeper.ChannelKeeper); err != nil {
return nil, err
}

// terminate active streams
for _, stream := range keepers.StreamerKeeper.GetActiveStreams(ctx) {
err := keepers.StreamerKeeper.TerminateStream(ctx, stream.Id)
if err != nil {
return nil, err
}
}

return fromVM, nil
}
}

0 comments on commit dbdab1f

Please sign in to comment.