From 1ce468333c45b6c5c5ca36c8f23886818f8c2ba5 Mon Sep 17 00:00:00 2001 From: puneetmahajan Date: Wed, 18 Dec 2024 13:55:28 +0400 Subject: [PATCH] sudo fail unbondings --- x/liquidstakeibc/keeper/msg_server.go | 9 +++++++++ x/liquidstakeibc/keeper/unbonding.go | 10 +++++++++- x/liquidstakeibc/types/errors.go | 2 +- x/liquidstakeibc/types/keys.go | 1 + x/liquidstakeibc/types/msgs.go | 6 ++++++ 5 files changed, 26 insertions(+), 2 deletions(-) diff --git a/x/liquidstakeibc/keeper/msg_server.go b/x/liquidstakeibc/keeper/msg_server.go index c734277ab..133a1d849 100644 --- a/x/liquidstakeibc/keeper/msg_server.go +++ b/x/liquidstakeibc/keeper/msg_server.go @@ -392,6 +392,15 @@ func (k msgServer) UpdateHostChain( return nil, err } } + case types.KeyForceFailUnbond: + epochNumber, err := strconv.ParseInt(update.Value, 10, 64) + if err != nil { + return nil, err + } + err = k.FailUnbondingsForEpoch(ctx, hc.ChainId, epochNumber) + if err != nil { + return nil, err + } default: return nil, fmt.Errorf("invalid or unexpected update key: %s", update.Key) } diff --git a/x/liquidstakeibc/keeper/unbonding.go b/x/liquidstakeibc/keeper/unbonding.go index 00ca2b0ad..492ad23e4 100644 --- a/x/liquidstakeibc/keeper/unbonding.go +++ b/x/liquidstakeibc/keeper/unbonding.go @@ -87,7 +87,15 @@ func (k *Keeper) FailAllUnbondingsForSequenceID(ctx sdk.Context, sequenceID stri k.SetUnbonding(ctx, unbonding) } } - +func (k *Keeper) FailUnbondingsForEpoch(ctx sdk.Context, chainID string, epochNumber int64) error { + unbonding, found := k.GetUnbonding(ctx, chainID, epochNumber) + if !found { + return types.ErrUnbondingNotFound + } + unbonding.State = types.Unbonding_UNBONDING_FAILED + k.SetUnbonding(ctx, unbonding) + return nil +} func (k *Keeper) RevertUnbondingsState(ctx sdk.Context, unbondings []*types.Unbonding) { for _, unbonding := range unbondings { unbonding.IbcSequenceId = "" diff --git a/x/liquidstakeibc/types/errors.go b/x/liquidstakeibc/types/errors.go index 80f7dbbcc..63e615219 100644 --- a/x/liquidstakeibc/types/errors.go +++ b/x/liquidstakeibc/types/errors.go @@ -26,5 +26,5 @@ var ( ErrLSMDepositProcessing = errorsmod.Register(ModuleName, 2020, "already processing LSM deposit") ErrLSMValidatorInvalidState = errorsmod.Register(ModuleName, 2021, "validator invalid state") ErrInsufficientDeposits = errorsmod.Register(ModuleName, 2022, "insufficient deposits") - ErrHostChainActive = errorsmod.Register(ModuleName, 2023, "host chain is active") + ErrUnbondingNotFound = errorsmod.Register(ModuleName, 2023, "unbonding not found") ) diff --git a/x/liquidstakeibc/types/keys.go b/x/liquidstakeibc/types/keys.go index 8df73a291..1894595a7 100644 --- a/x/liquidstakeibc/types/keys.go +++ b/x/liquidstakeibc/types/keys.go @@ -92,6 +92,7 @@ const ( KeyForceICATransferRewards string = "force_ica_transfer_rewards" KeyForceTransferDeposits string = "force_transfer_deposits" KeyForceTransferUnbonded string = "force_transfer_unbonded" + KeyForceFailUnbond string = "force_fail_unbond" ) var ( diff --git a/x/liquidstakeibc/types/msgs.go b/x/liquidstakeibc/types/msgs.go index 594f84746..d7d1ebbc5 100644 --- a/x/liquidstakeibc/types/msgs.go +++ b/x/liquidstakeibc/types/msgs.go @@ -433,6 +433,12 @@ func (m *MsgUpdateHostChain) ValidateBasic() error { if update.Value != "" { return fmt.Errorf("invalid force transfer unbonded, expected \"\" ") } + case KeyForceFailUnbond: + //expected , "123" + _, err := strconv.ParseInt(update.Value, 10, 64) + if err != nil { + return err + } default: return fmt.Errorf("invalid or unexpected update key: %s", update.Key) }