From de64786b9817aa158d146429aa00d665af26247d Mon Sep 17 00:00:00 2001 From: Ehsan-saradar Date: Wed, 17 Apr 2024 12:08:20 +0330 Subject: [PATCH 1/5] Modify error logs acording to liquidstakeibc module --- x/liquidstake/keeper/liquidstake.go | 12 +++++----- x/liquidstake/keeper/rebalancing.go | 35 ++++++++++++++++++----------- x/liquidstake/types/logging.go | 11 +++++++++ 3 files changed, 38 insertions(+), 20 deletions(-) create mode 100644 x/liquidstake/types/logging.go diff --git a/x/liquidstake/keeper/liquidstake.go b/x/liquidstake/keeper/liquidstake.go index 9d22da3f..9297a63b 100644 --- a/x/liquidstake/keeper/liquidstake.go +++ b/x/liquidstake/keeper/liquidstake.go @@ -226,7 +226,6 @@ func (k Keeper) DelegateWithCap( } res, err := handler(ctx, msgDelegate) if err != nil { - k.Logger(ctx).Error("failed to execute delegate msg,", "msg", msgDelegate.String(), "err", err) return errorsmod.Wrapf(types.ErrDelegationFailed, "failed to send delegate msg with err: %v", err) } ctx.EventManager().EmitEvents(res.GetEvents()) @@ -807,18 +806,17 @@ func (k Keeper) WithdrawLiquidRewards(ctx sdk.Context, proxyAcc sdk.AccAddress) // run the message handler handler := k.router.Handler(msgWithdraw) if handler == nil { - k.Logger(ctx).Error( - "unrecognized message route", - "msgRoute", sdk.MsgTypeURL(msgWithdraw), - ) + k.Logger(ctx).Error("could not find distribution handler for withdraw rewards msg") return true } res, err := handler(ctx, msgWithdraw) if err != nil { k.Logger(ctx).Error( "failed to execute withdraw rewards msg", - "msg", msgWithdraw.String(), - "err", err, + types.MsgKeyVal, + msgWithdraw.String(), + types.ErrorKeyVal, + err, ) // no need to return here, will be picked up in the next epoch } else { diff --git a/x/liquidstake/keeper/rebalancing.go b/x/liquidstake/keeper/rebalancing.go index 0232e894..548bfa7f 100644 --- a/x/liquidstake/keeper/rebalancing.go +++ b/x/liquidstake/keeper/rebalancing.go @@ -56,7 +56,6 @@ func (k Keeper) Rebalance( whitelistedValsMap types.WhitelistedValsMap, rebalancingTrigger math.LegacyDec, ) (redelegations []types.Redelegation) { - logger := k.Logger(ctx) totalLiquidTokens, liquidTokenMap := liquidVals.TotalLiquidTokens(ctx, k.stakingKeeper, false) if !totalLiquidTokens.IsPositive() { return redelegations @@ -116,15 +115,20 @@ func (k Keeper) Rebalance( if err != nil { redelegation.Error = err failCount++ + + k.Logger(ctx).Error( + "redelegation failed", + types.DelegatorKeyVal, proxyAcc.String(), + types.SrcValidatorKeyVal, maxVal.OperatorAddress, + types.DstValidatorKeyVal, minVal.OperatorAddress, + types.AmountKeyVal, amountNeeded.String(), + types.ErrorKeyVal, err.Error(), + ) } redelegations = append(redelegations, redelegation) } - if failCount > 0 { - logger.Error("rebalancing failed due to redelegation hopping", "redelegations", redelegations) - } - if len(redelegations) != 0 { ctx.EventManager().EmitEvents(sdk.Events{ sdk.NewEvent( @@ -134,7 +138,7 @@ func (k Keeper) Rebalance( sdk.NewAttribute(types.AttributeKeyRedelegationFailCount, strconv.Itoa(failCount)), ), }) - logger.Info(types.EventTypeBeginRebalancing, + k.Logger(ctx).Info(types.EventTypeBeginRebalancing, types.AttributeKeyDelegator, types.LiquidStakeProxyAcc.String(), types.AttributeKeyRedelegationCount, strconv.Itoa(len(redelegations)), types.AttributeKeyRedelegationFailCount, strconv.Itoa(failCount)) @@ -144,7 +148,6 @@ func (k Keeper) Rebalance( } func (k Keeper) UpdateLiquidValidatorSet(ctx sdk.Context) (redelegations []types.Redelegation) { - logger := k.Logger(ctx) params := k.GetParams(ctx) liquidValidators := k.GetAllLiquidValidators(ctx) liquidValsMap := liquidValidators.Map() @@ -165,7 +168,7 @@ func (k Keeper) UpdateLiquidValidatorSet(ctx sdk.Context) (redelegations []types sdk.NewAttribute(types.AttributeKeyLiquidValidator, lv.OperatorAddress), ), }) - logger.Info(types.EventTypeAddLiquidValidator, types.AttributeKeyLiquidValidator, lv.OperatorAddress) + k.Logger(ctx).Info(types.EventTypeAddLiquidValidator, types.AttributeKeyLiquidValidator, lv.OperatorAddress) } } } @@ -233,8 +236,11 @@ func (k Keeper) AutocompoundStakingRewards(ctx sdk.Context, whitelistedValsMap t delegableAmount := autoCompoundableAmount.Sub(autocompoundFee.Amount) err := k.LiquidDelegate(cachedCtx, types.LiquidStakeProxyAcc, activeVals, delegableAmount, whitelistedValsMap) if err != nil { - logger := k.Logger(ctx) - logger.Error("re-staking failed", "error", err) + k.Logger(ctx).Error( + "failed to re-stake the accumulated rewards", + types.ErrorKeyVal, + err, + ) return // skip errors as they might occur due to reaching global liquid cap } @@ -244,11 +250,14 @@ func (k Keeper) AutocompoundStakingRewards(ctx sdk.Context, whitelistedValsMap t feeAccountAddr := sdk.MustAccAddressFromBech32(params.FeeAccountAddress) err = k.bankKeeper.SendCoins(ctx, types.LiquidStakeProxyAcc, feeAccountAddr, sdk.NewCoins(autocompoundFee)) if err != nil { - k.Logger(ctx).Error("re-staking failed upon fee collection", "error", err) + k.Logger(ctx).Error( + "failed to send autocompound fee to fee account", + types.ErrorKeyVal, + err, + ) return } - logger := k.Logger(ctx) ctx.EventManager().EmitEvents(sdk.Events{ sdk.NewEvent( types.EventTypeAutocompound, @@ -257,7 +266,7 @@ func (k Keeper) AutocompoundStakingRewards(ctx sdk.Context, whitelistedValsMap t sdk.NewAttribute(types.AttributeKeyAutocompoundFee, autocompoundFee.String()), ), }) - logger.Info(types.EventTypeAutocompound, + k.Logger(ctx).Info(types.EventTypeAutocompound, types.AttributeKeyDelegator, types.LiquidStakeProxyAcc.String(), sdk.AttributeKeyAmount, delegableAmount.String(), types.AttributeKeyAutocompoundFee, autocompoundFee.String()) diff --git a/x/liquidstake/types/logging.go b/x/liquidstake/types/logging.go new file mode 100644 index 00000000..4dfdf1d3 --- /dev/null +++ b/x/liquidstake/types/logging.go @@ -0,0 +1,11 @@ +package types + +const ( + // keyvals + DelegatorKeyVal string = "delegator" + SrcValidatorKeyVal string = "src_validator" + DstValidatorKeyVal string = "dst_validator" + AmountKeyVal string = "amount" + MsgKeyVal string = "msg" + ErrorKeyVal string = "error" +) From 456da05c8c7e1f8fac10d758ab9cc2513c668e99 Mon Sep 17 00:00:00 2001 From: Ehsan-saradar Date: Wed, 17 Apr 2024 20:06:28 +0330 Subject: [PATCH 2/5] Add more description for some errors --- x/liquidstake/keeper/liquidstake.go | 3 ++- x/liquidstake/keeper/rebalancing.go | 5 +++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/x/liquidstake/keeper/liquidstake.go b/x/liquidstake/keeper/liquidstake.go index 9297a63b..b580446a 100644 --- a/x/liquidstake/keeper/liquidstake.go +++ b/x/liquidstake/keeper/liquidstake.go @@ -2,6 +2,7 @@ package keeper import ( "encoding/json" + "fmt" "sort" "time" @@ -560,7 +561,7 @@ func (k Keeper) LiquidDelegate(ctx sdk.Context, proxyAcc sdk.AccAddress, activeV validator, _ := k.stakingKeeper.GetValidator(ctx, val.GetOperator()) err = k.DelegateWithCap(ctx, proxyAcc, validator, weightedAmt[i]) if err != nil { - return err + return fmt.Errorf("failed to delegate to validator %s: %w", val.GetOperator(), err) } } return nil diff --git a/x/liquidstake/keeper/rebalancing.go b/x/liquidstake/keeper/rebalancing.go index 548bfa7f..214816cc 100644 --- a/x/liquidstake/keeper/rebalancing.go +++ b/x/liquidstake/keeper/rebalancing.go @@ -1,6 +1,7 @@ package keeper import ( + "fmt" "strconv" "time" @@ -32,7 +33,7 @@ func (k Keeper) TryRedelegation(ctx sdk.Context, re types.Redelegation) (complet ctx, re.Delegator, srcVal, re.Amount, ) if err != nil { - return time.Time{}, err + return time.Time{}, fmt.Errorf("failed to validate unbond amount: %w", err) } // when last, full redelegation of shares from delegation @@ -42,7 +43,7 @@ func (k Keeper) TryRedelegation(ctx sdk.Context, re types.Redelegation) (complet cachedCtx, writeCache := ctx.CacheContext() completionTime, err = k.stakingKeeper.BeginRedelegation(cachedCtx, re.Delegator, srcVal, dstVal, shares) if err != nil { - return time.Time{}, err + return time.Time{}, fmt.Errorf("failed to begin redelegation: %w", err) } writeCache() return completionTime, nil From f4e9df45d6736f3dea289b7a452106aa23ae5e1a Mon Sep 17 00:00:00 2001 From: Ehsan-saradar Date: Fri, 19 Apr 2024 12:22:26 +0330 Subject: [PATCH 3/5] Using cosmos errors pkg for wrapping --- x/liquidstake/keeper/liquidstake.go | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/x/liquidstake/keeper/liquidstake.go b/x/liquidstake/keeper/liquidstake.go index b580446a..e9ac5e4c 100644 --- a/x/liquidstake/keeper/liquidstake.go +++ b/x/liquidstake/keeper/liquidstake.go @@ -2,7 +2,6 @@ package keeper import ( "encoding/json" - "fmt" "sort" "time" @@ -561,7 +560,7 @@ func (k Keeper) LiquidDelegate(ctx sdk.Context, proxyAcc sdk.AccAddress, activeV validator, _ := k.stakingKeeper.GetValidator(ctx, val.GetOperator()) err = k.DelegateWithCap(ctx, proxyAcc, validator, weightedAmt[i]) if err != nil { - return fmt.Errorf("failed to delegate to validator %s: %w", val.GetOperator(), err) + return errorsmod.Wrapf(err, "failed to delegate to validator %s", val.GetOperator()) } } return nil From dba4620a7cfbcf715483bb2b4fd9c6aeea2d1b24 Mon Sep 17 00:00:00 2001 From: Ehsan-saradar Date: Fri, 19 Apr 2024 12:28:49 +0330 Subject: [PATCH 4/5] Add log for MsgDelegate execution failure --- x/liquidstake/keeper/liquidstake.go | 14 +++++++++++++- x/liquidstake/types/logging.go | 1 + 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/x/liquidstake/keeper/liquidstake.go b/x/liquidstake/keeper/liquidstake.go index e9ac5e4c..0e424c5f 100644 --- a/x/liquidstake/keeper/liquidstake.go +++ b/x/liquidstake/keeper/liquidstake.go @@ -222,10 +222,22 @@ func (k Keeper) DelegateWithCap( } handler := k.router.Handler(msgDelegate) if handler == nil { - return sdkerrors.ErrUnknownRequest.Wrapf("unrecognized message route: %s", sdk.MsgTypeURL(msgDelegate)) + return errorsmod.Wrapf(sdkerrors.ErrUnknownRequest, "unrecognized message route: %s", sdk.MsgTypeURL(msgDelegate)) } res, err := handler(ctx, msgDelegate) if err != nil { + k.Logger(ctx).Error( + "failed to send delegate msg", + types.ErrorKeyVal, + err, + types.DelegatorKeyVal, + delegatorAddress.String(), + types.ValidatorKeyVal, + validator.OperatorAddress, + types.AmountKeyVal, + bondAmt.String(), + ) + return errorsmod.Wrapf(types.ErrDelegationFailed, "failed to send delegate msg with err: %v", err) } ctx.EventManager().EmitEvents(res.GetEvents()) diff --git a/x/liquidstake/types/logging.go b/x/liquidstake/types/logging.go index 4dfdf1d3..228ee994 100644 --- a/x/liquidstake/types/logging.go +++ b/x/liquidstake/types/logging.go @@ -3,6 +3,7 @@ package types const ( // keyvals DelegatorKeyVal string = "delegator" + ValidatorKeyVal string = "validator" SrcValidatorKeyVal string = "src_validator" DstValidatorKeyVal string = "dst_validator" AmountKeyVal string = "amount" From cde1feb5f0f9e8780912cd91460c6ba1e426e411 Mon Sep 17 00:00:00 2001 From: Ehsan-saradar Date: Sat, 20 Apr 2024 16:47:38 +0330 Subject: [PATCH 5/5] Add more error logs --- x/liquidstake/keeper/liquidstake.go | 141 ++++++++++++++++++++++++++-- x/liquidstake/types/logging.go | 21 +++-- 2 files changed, 148 insertions(+), 14 deletions(-) diff --git a/x/liquidstake/keeper/liquidstake.go b/x/liquidstake/keeper/liquidstake.go index 0e424c5f..aded0f73 100644 --- a/x/liquidstake/keeper/liquidstake.go +++ b/x/liquidstake/keeper/liquidstake.go @@ -85,6 +85,14 @@ func (k Keeper) LiquidStake( math.LegacyNewDecFromInt(types.TotalValidatorWeight), ) if activeWeightQuorum.LT(types.ActiveLiquidValidatorsWeightQuorum) { + k.Logger(ctx).Error( + "active liquid validators weight quorum not reached", + types.ActiveWeightQuorumKeyVal, + activeWeightQuorum.String(), + types.MinActiveWeightQuorumKeyVal, + types.ActiveLiquidValidatorsWeightQuorum.String(), + ) + return sdk.ZeroInt(), errorsmod.Wrapf( types.ErrActiveLiquidValidatorsWeightQuorumNotReached, "%s < %s", activeWeightQuorum.String(), types.ActiveLiquidValidatorsWeightQuorum.String(), @@ -108,6 +116,12 @@ func (k Keeper) LiquidStake( if nas.NetAmount.IsZero() { // this case must not be reachable, consider stopping module for investigation // c_value -> inf + k.Logger(ctx).Error( + "infinite c value", + types.NetAmountStateKeyVal, + nas.String(), + ) + return sdk.ZeroInt(), types.ErrInsufficientProxyAccBalance } @@ -126,6 +140,12 @@ func (k Keeper) LiquidStake( } err = k.bankKeeper.SendCoinsFromModuleToAccount(ctx, types.ModuleName, liquidStaker, mintCoin) if err != nil { + k.Logger(ctx).Error( + "failed to send minted coins to liquid staker", + types.ErrorKeyVal, + err, + ) + return stkXPRTMintAmount, err } @@ -172,11 +192,21 @@ func (k Keeper) LockOnLP(ctx sdk.Context, delegator sdk.AccAddress, amount sdk.C handler := k.router.Handler(cwMsg) if handler == nil { + k.Logger(ctx).Error("failed to find CW contract handler") + return nil, sdkerrors.ErrUnknownRequest.Wrapf("unrecognized message route: %s", sdk.MsgTypeURL(cwMsg)) } msgResp, err := handler(ctx, cwMsg) if err != nil { + k.Logger(ctx).Error( + "failed to execute CW contract message", + types.ErrorKeyVal, + err, + types.MsgKeyVal, + cwMsg.String(), + ) + return nil, types.ErrLPContract.Wrapf("error: %s, message %v", err.Error(), cwMsg) } @@ -222,20 +252,18 @@ func (k Keeper) DelegateWithCap( } handler := k.router.Handler(msgDelegate) if handler == nil { + k.Logger(ctx).Error("failed to find delegate handler") + return errorsmod.Wrapf(sdkerrors.ErrUnknownRequest, "unrecognized message route: %s", sdk.MsgTypeURL(msgDelegate)) } res, err := handler(ctx, msgDelegate) if err != nil { k.Logger(ctx).Error( - "failed to send delegate msg", + "failed to execute delegate msg", types.ErrorKeyVal, err, - types.DelegatorKeyVal, - delegatorAddress.String(), - types.ValidatorKeyVal, - validator.OperatorAddress, - types.AmountKeyVal, - bondAmt.String(), + types.MsgKeyVal, + msgDelegate.String(), ) return errorsmod.Wrapf(types.ErrDelegationFailed, "failed to send delegate msg with err: %v", err) @@ -281,12 +309,22 @@ func (k Keeper) UnbondWithCap( handler := k.router.Handler(lsmTokenizeMsg) if handler == nil { + k.Logger(ctx).Error("failed to find tokenize handler") + return sdk.ZeroInt(), sdkerrors.ErrUnknownRequest.Wrapf("unrecognized message route: %s", sdk.MsgTypeURL(lsmTokenizeMsg)) } // [1] tokenize delegation into LSM shares msgResp, err := handler(ctx, lsmTokenizeMsg) if err != nil { + k.Logger(ctx).Error( + "failed to execute tokenize shares message", + types.ErrorKeyVal, + err, + types.MsgKeyVal, + lsmTokenizeMsg.String(), + ) + return sdk.ZeroInt(), types.ErrLSMTokenizeFailed.Wrapf("error: %s; message: %v", err.Error(), lsmTokenizeMsg) } ctx.EventManager().EmitEvents(msgResp.GetEvents()) @@ -321,12 +359,21 @@ func (k Keeper) UnbondWithCap( handler = k.router.Handler(lsmRedeemMsg) if handler == nil { + k.Logger(ctx).Error("failed to find redeem handler") return sdk.ZeroInt(), sdkerrors.ErrUnknownRequest.Wrapf("unrecognized message route: %s", sdk.MsgTypeURL(lsmRedeemMsg)) } // [3] redeem LSM shares from proxyAcc, to obtain a delegation msgResp, err = handler(ctx, lsmRedeemMsg) if err != nil { + k.Logger(ctx).Error( + "failed to execute redeem tokens for shares message", + types.ErrorKeyVal, + err, + types.MsgKeyVal, + lsmRedeemMsg.String(), + ) + return sdk.ZeroInt(), types.ErrLSMRedeemFailed.Wrapf("error: %s; message: %v", err.Error(), lsmRedeemMsg) } ctx.EventManager().EmitEvents(msgResp.GetEvents()) @@ -357,11 +404,21 @@ func (k Keeper) UnbondWithCap( handler = k.router.Handler(unstakeMsg) if handler == nil { + k.Logger(ctx).Error("failed to find undelegate handler") + return sdk.ZeroInt(), sdkerrors.ErrUnknownRequest.Wrapf("unrecognized message route: %s", sdk.MsgTypeURL(unstakeMsg)) } msgResp, err = handler(ctx, unstakeMsg) if err != nil { + k.Logger(ctx).Error( + "failed to execute undelegate message", + types.ErrorKeyVal, + err, + types.MsgKeyVal, + unstakeMsg.String(), + ) + return sdk.ZeroInt(), types.ErrUnstakeFailed.Wrapf("error: %s; message: %v", err.Error(), unstakeMsg) } ctx.EventManager().EmitEvents(msgResp.GetEvents()) @@ -428,6 +485,14 @@ func (k Keeper) LSMDelegate( math.LegacyNewDecFromInt(types.TotalValidatorWeight), ) if activeWeightQuorum.LT(types.ActiveLiquidValidatorsWeightQuorum) { + k.Logger(ctx).Error( + "active liquid validators weight quorum not reached", + types.ActiveWeightQuorumKeyVal, + activeWeightQuorum.String(), + types.MinActiveWeightQuorumKeyVal, + types.ActiveLiquidValidatorsWeightQuorum.String(), + ) + return sdk.ZeroInt(), errorsmod.Wrapf( types.ErrActiveLiquidValidatorsWeightQuorumNotReached, "%s < %s", activeWeightQuorum.String(), types.ActiveLiquidValidatorsWeightQuorum.String(), @@ -452,12 +517,22 @@ func (k Keeper) LSMDelegate( handler := k.router.Handler(lsmTokenizeMsg) if handler == nil { + k.Logger(ctx).Error("failed to find tokenize handler") + return sdk.ZeroInt(), sdkerrors.ErrUnknownRequest.Wrapf("unrecognized message route: %s", sdk.MsgTypeURL(lsmTokenizeMsg)) } // [1] tokenize delegation into LSM shares msgResp, err := handler(ctx, lsmTokenizeMsg) if err != nil { + k.Logger(ctx).Error( + "failed to execute tokenize shares message", + types.ErrorKeyVal, + err, + types.MsgKeyVal, + lsmTokenizeMsg.String(), + ) + return sdk.ZeroInt(), types.ErrLSMTokenizeFailed.Wrapf("error: %s; message: %v", err.Error(), lsmTokenizeMsg) } ctx.EventManager().EmitEvents(msgResp.GetEvents()) @@ -492,12 +567,22 @@ func (k Keeper) LSMDelegate( handler = k.router.Handler(lsmRedeemMsg) if handler == nil { + k.Logger(ctx).Error("failed to find redeem handler") + return sdk.ZeroInt(), sdkerrors.ErrUnknownRequest.Wrapf("unrecognized message route: %s", sdk.MsgTypeURL(lsmRedeemMsg)) } // [3] redeem LSM shares from proxyAcc, to obtain a delegation msgResp, err = handler(ctx, lsmRedeemMsg) if err != nil { + k.Logger(ctx).Error( + "failed to execute redeem tokens for shares message", + types.ErrorKeyVal, + err, + types.MsgKeyVal, + lsmRedeemMsg.String(), + ) + return sdk.ZeroInt(), types.ErrLSMRedeemFailed.Wrapf("error: %s; message: %v", err.Error(), lsmRedeemMsg) } ctx.EventManager().EmitEvents(msgResp.GetEvents()) @@ -562,6 +647,16 @@ func (k Keeper) LiquidDelegate(ctx sdk.Context, proxyAcc sdk.AccAddress, activeV // crumb may occur due to a decimal point error in dividing the staking amount into the weight of liquid validators, It added on first active liquid validator weightedAmt, crumb := types.DivideByWeight(activeVals, stakingAmt, whitelistedValsMap) if len(weightedAmt) == 0 { + k.Logger(ctx).Error( + "invalid active liquid validators", + types.ActiveValidatorsKeyVal, + activeVals, + types.AmountKeyVal, + stakingAmt.String(), + types.WhitelistedValidatorsMapKeyVal, + whitelistedValsMap, + ) + return types.ErrInvalidActiveLiquidValidators } weightedAmt[0] = weightedAmt[0].Add(crumb) @@ -645,12 +740,26 @@ func (k Keeper) LiquidUnstake( return time.Time{}, sdk.ZeroInt(), []stakingtypes.UnbondingDelegation{}, unbondingAmountInt, nil } + k.Logger(ctx).Error( + "non-positive total liquid tokens", + types.ValidatorsKeyVal, + liquidVals, + types.TotalLiquidTokensKeyVal, + totalLiquidTokens.String(), + ) + // error case where there is a quantity that are unbonding balance or remaining rewards that is not re-stake or withdrawn in netAmount. return time.Time{}, sdk.ZeroInt(), []stakingtypes.UnbondingDelegation{}, sdk.ZeroInt(), types.ErrInsufficientProxyAccBalance } // fail when no liquid validators to unbond if liquidVals.Len() == 0 { + k.Logger(ctx).Error( + "no liquid validators to unbond", + types.ValidatorsKeyVal, + liquidVals, + ) + return time.Time{}, sdk.ZeroInt(), []stakingtypes.UnbondingDelegation{}, sdk.ZeroInt(), types.ErrLiquidValidatorsNotExists } @@ -680,6 +789,16 @@ func (k Keeper) LiquidUnstake( // calculate delShares from tokens with validation weightedShare, err = k.stakingKeeper.ValidateUnbondAmount(ctx, proxyAcc, val.GetOperator(), unbondingAmounts[i].TruncateInt()) if err != nil { + k.Logger(ctx).Error( + "failed to validate unbond amount", + types.ErrorKeyVal, + err, + types.ValidatorKeyVal, + val.GetOperator().String(), + types.AmountKeyVal, + unbondingAmounts[i].TruncateInt().String(), + ) + return time.Time{}, sdk.ZeroInt(), []stakingtypes.UnbondingDelegation{}, sdk.ZeroInt(), err } @@ -724,6 +843,14 @@ func (k Keeper) LiquidUnbond( completionTime := ctx.BlockHeader().Time.Add(k.stakingKeeper.UnbondingTime(ctx)) ubd, found := k.stakingKeeper.GetUnbondingDelegation(ctx, liquidStaker, valAddr) if !found { + k.Logger(ctx).Error( + "failed to find unbonding delegation", + types.DelegatorKeyVal, + liquidStaker.String(), + types.ValidatorKeyVal, + valAddr.String(), + ) + return time.Time{}, sdk.ZeroInt(), stakingtypes.UnbondingDelegation{}, types.ErrInvalidResponse.Wrap("expected undelegation entry, found none") } diff --git a/x/liquidstake/types/logging.go b/x/liquidstake/types/logging.go index 228ee994..15cfa463 100644 --- a/x/liquidstake/types/logging.go +++ b/x/liquidstake/types/logging.go @@ -2,11 +2,18 @@ package types const ( // keyvals - DelegatorKeyVal string = "delegator" - ValidatorKeyVal string = "validator" - SrcValidatorKeyVal string = "src_validator" - DstValidatorKeyVal string = "dst_validator" - AmountKeyVal string = "amount" - MsgKeyVal string = "msg" - ErrorKeyVal string = "error" + DelegatorKeyVal string = "delegator" + ValidatorKeyVal string = "validator" + SrcValidatorKeyVal string = "src_validator" + DstValidatorKeyVal string = "dst_validator" + AmountKeyVal string = "amount" + MsgKeyVal string = "msg" + ErrorKeyVal string = "error" + ActiveWeightQuorumKeyVal string = "active_weight_quorum" + MinActiveWeightQuorumKeyVal string = "min_active_weight_quorum" + ActiveValidatorsKeyVal string = "active_validators" + WhitelistedValidatorsMapKeyVal string = "whitelisted_validators_map" + ValidatorsKeyVal string = "validators" + NetAmountStateKeyVal string = "net_amount_state" + TotalLiquidTokensKeyVal string = "total_liquid_tokens" )