Skip to content

Commit

Permalink
sudo fail unbondings
Browse files Browse the repository at this point in the history
  • Loading branch information
puneet2019 committed Dec 18, 2024
1 parent fcc3703 commit 1ce4683
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 2 deletions.
9 changes: 9 additions & 0 deletions x/liquidstakeibc/keeper/msg_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down
10 changes: 9 additions & 1 deletion x/liquidstakeibc/keeper/unbonding.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 = ""
Expand Down
2 changes: 1 addition & 1 deletion x/liquidstakeibc/types/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
)
1 change: 1 addition & 0 deletions x/liquidstakeibc/types/keys.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand Down
6 changes: 6 additions & 0 deletions x/liquidstakeibc/types/msgs.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down

0 comments on commit 1ce4683

Please sign in to comment.