From b5dbdb504dc7b57fe2f4ca3bc7ad8855837ec3bd Mon Sep 17 00:00:00 2001 From: stana-ethernal Date: Wed, 4 Dec 2024 15:22:25 +0100 Subject: [PATCH] cr fix --- x/staking/keeper/slash.go | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/x/staking/keeper/slash.go b/x/staking/keeper/slash.go index 285a53e48a0d..e4ac5ce8b97a 100644 --- a/x/staking/keeper/slash.go +++ b/x/staking/keeper/slash.go @@ -404,14 +404,23 @@ func (k Keeper) SlashRedelegation(ctx context.Context, srcValidator types.Valida // if the delegator holds a validator bond to destination validator, decrease the destination validator bond shares if delegation.ValidatorBond { - k.SafelyDecreaseValidatorBond(ctx, valDstAddr, sharesToUnbond) + if err := k.SafelyDecreaseValidatorBond(ctx, valDstAddr, sharesToUnbond); err != nil { + // Log an error instead of panicking to handle operation failures gracefully + k.Logger(ctx).Error("failed to decrease validator bond", "error", err) + } } // if this delegation is from a liquid staking provider (identified if the delegator // is an ICA account), the global and validator liquid totals should be decremented if k.DelegatorIsLiquidStaker(delegatorAddress) { - k.DecreaseTotalLiquidStakedTokens(ctx, tokensToBurn) - k.DecreaseValidatorLiquidShares(ctx, valDstAddr, sharesToUnbond) + if err := k.DecreaseTotalLiquidStakedTokens(ctx, tokensToBurn); err != nil { + // Log an error instead of panicking to handle operation failures gracefully + k.Logger(ctx).Error("failed to decrease total liquid staked tokens", "error", err) + } + if _, err := k.DecreaseValidatorLiquidShares(ctx, valDstAddr, sharesToUnbond); err != nil { + // Log an error instead of panicking to handle operation failures gracefully + k.Logger(ctx).Error("failed to decrease validator liquid shares", "error", err) + } } // tokens of a redelegation currently live in the destination validator