Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[LUM-789] Patch broken deposit entities #47

Merged
merged 2 commits into from
Aug 3, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 19 additions & 1 deletion x/millions/migrations/v152/store.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,34 @@ package v152
import (
sdk "github.com/cosmos/cosmos-sdk/types"

"github.com/lum-network/chain/x/millions/types"

millionskeeper "github.com/lum-network/chain/x/millions/keeper"
)

func MigrateFailedIcaUndelegationsToEpochUnbonding(ctx sdk.Context, k millionskeeper.Keeper) error {
// Batch failed ica undelegations
ctx.Logger().Info("Processing failed ICA undelegations and add them to pending queue...")
if err := k.AddFailedIcaUndelegationsToEpochUnbonding(ctx); err != nil {
return err
}

ctx.Logger().Info("Batch Failed ICA Undelegations")
// Patch broken deposit entities to allow for retry
// We acquire both entities that are broken. If there is any error, it shouldn't be returned to allow for testnet execution
// We require to ensure it here, cuz on a sub level, it would panic out in case entity does not exist
// Both entities are flagged on error state IcaDelegate to allow them to be retried out by their owner
poolId := uint64(2)
ctx.Logger().Info("Patching broken deposit entities...")
_, err := k.GetPoolDeposit(ctx, poolId, 429)
if err == nil {
k.UpdateDepositStatus(ctx, poolId, 429, types.DepositState_IcaDelegate, true)
ctx.Logger().Info("Deposit 429 patched")
}
_, err = k.GetPoolDeposit(ctx, poolId, 450)
if err == nil {
k.UpdateDepositStatus(ctx, poolId, 450, types.DepositState_IcaDelegate, true)
ctx.Logger().Info("Deposit 450 patched")
}

return nil
}