Skip to content

Commit

Permalink
chore: improve error handling in upgrades
Browse files Browse the repository at this point in the history
  • Loading branch information
shifty11 committed Apr 24, 2024
1 parent 9878c63 commit 256ffc5
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions app/upgrades/v1_5/upgrade.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,17 @@ func CreateUpgradeHandler(mm *module.Manager, configurator module.Configurator,
logger := sdk.UnwrapSDKContext(ctx).Logger().With("upgrade", UpgradeName)
logger.Info(fmt.Sprintf("performing upgrade %v", UpgradeName))

migrateStorageCosts(ctx, bundlesKeeper, poolKeeper, storeKeys, cdc)
if err := migrateStorageCosts(ctx, bundlesKeeper, poolKeeper, storeKeys, cdc); err != nil {
return nil, err
}

// TODO: migrate gov params

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

func migrateStorageCosts(ctx context.Context, bundlesKeeper keeper.Keeper, poolKeeper *poolkeeper.Keeper, storeKeys []storetypes.StoreKey, cdc codec.Codec) {
func migrateStorageCosts(ctx context.Context, bundlesKeeper keeper.Keeper, poolKeeper *poolkeeper.Keeper, storeKeys []storetypes.StoreKey, cdc codec.Codec) error {
sdkCtx := sdk.UnwrapSDKContext(ctx)

var bundlesStoreKey storetypes.StoreKey
Expand All @@ -44,7 +46,7 @@ func migrateStorageCosts(ctx context.Context, bundlesKeeper keeper.Keeper, poolK
}
}
if bundlesStoreKey == nil {
panic("bundles store key not found")
return fmt.Errorf("store key not found: bundles")
}

// Get all storage providers
Expand All @@ -69,4 +71,5 @@ func migrateStorageCosts(ctx context.Context, bundlesKeeper keeper.Keeper, poolK
}

bundlesKeeper.SetParams(sdkCtx, newParams)
return nil
}

0 comments on commit 256ffc5

Please sign in to comment.