Skip to content

Commit

Permalink
remove consensus bump + add logic to handler
Browse files Browse the repository at this point in the history
  • Loading branch information
kruspy committed Jan 9, 2024
1 parent ad655cb commit f483a97
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 72 deletions.
40 changes: 40 additions & 0 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -1018,7 +1018,47 @@ func (app *PstakeApp) RegisterUpgradeHandler() {
app.UpgradeKeeper.SetUpgradeHandler(
UpgradeName,
func(ctx sdk.Context, _ upgradetypes.Plan, fromVM module.VersionMap) (module.VersionMap, error) {

// stuck unbonding epoch numbers
RemovableUnbondings := map[string]map[int64]any{"cosmoshub-4": {312: nil}, "osmosis-1": {429: nil, 432: nil}}

// get the stuck unbondings from the store
unbondings := app.LiquidStakeIBCKeeper.FilterUnbondings(
ctx,
func(u liquidstakeibctypes.Unbonding) bool {
_, chain := RemovableUnbondings[u.ChainId]
if chain {
_, epoch := RemovableUnbondings[u.ChainId][u.EpochNumber]
if epoch {
return true
}
}
return false
},
)

// mark the stuck unbondings as failed, so they can be processed
for _, unbonding := range unbondings {
unbonding.State = liquidstakeibctypes.Unbonding_UNBONDING_FAILED
app.LiquidStakeIBCKeeper.SetUnbonding(ctx, unbonding)
}

return app.mm.RunMigrations(ctx, app.configurator, fromVM)
},
)

upgradeInfo, err := app.UpgradeKeeper.ReadUpgradeInfoFromDisk()
if err != nil {
panic(err)
}

if upgradeInfo.Name == UpgradeName && !app.UpgradeKeeper.IsSkipHeight(upgradeInfo.Height) {
storeUpgrades := store.StoreUpgrades{
Added: []string{},
Deleted: []string{},
}

// configure store loader that checks if version == upgradeHeight and applies store upgrades
app.SetStoreLoader(upgradetypes.UpgradeStoreLoader(upgradeInfo.Height, &storeUpgrades))
}
}
6 changes: 0 additions & 6 deletions x/liquidstakeibc/keeper/migrations.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (

v2 "github.com/persistenceOne/pstake-native/v2/x/liquidstakeibc/migrations/v2"
v3 "github.com/persistenceOne/pstake-native/v2/x/liquidstakeibc/migrations/v3"
v4 "github.com/persistenceOne/pstake-native/v2/x/liquidstakeibc/migrations/v4"
)

// Migrator is a struct for handling in-place store migrations.
Expand All @@ -27,8 +26,3 @@ func (m Migrator) Migrate1to2(ctx sdk.Context) error {
func (m Migrator) Migrate2to3(ctx sdk.Context) error {
return v3.MigrateStore(ctx, m.keeper.storeKey, m.keeper.cdc)
}

// Migrate3to4 migrates from version 3 to 4.
func (m Migrator) Migrate3to4(ctx sdk.Context) error {
return v4.MigrateStore(ctx, m.keeper.storeKey, m.keeper.cdc)
}
61 changes: 0 additions & 61 deletions x/liquidstakeibc/migrations/v4/store.go

This file was deleted.

6 changes: 1 addition & 5 deletions x/liquidstakeibc/module.go
Original file line number Diff line number Diff line change
Expand Up @@ -134,14 +134,10 @@ func (a AppModule) RegisterServices(configurator module.Configurator) {
if err != nil {
panic(fmt.Sprintf("failed to migrate x/%s from version 2 to 3: %v", types.ModuleName, err))
}
err = configurator.RegisterMigration(types.ModuleName, 3, keeper.NewMigrator(a.keeper).Migrate3to4)
if err != nil {
panic(fmt.Sprintf("failed to migrate x/%s from version 3 to 4: %v", types.ModuleName, err))
}
}

func (a AppModule) ConsensusVersion() uint64 {
return 4
return 3
}

// TODO simulations
Expand Down

0 comments on commit f483a97

Please sign in to comment.