From 996da0f5fc5783fc4aae896be643500df88680c2 Mon Sep 17 00:00:00 2001 From: Yun Date: Sat, 15 Oct 2022 05:12:46 +0900 Subject: [PATCH] rollback state breaking SDK update - https://github.com/cosmos/cosmos-sdk/pull/13340 --- x/distribution/keeper/delegation.go | 39 ++++++++++++++++------------- x/distribution/keeper/keeper.go | 11 ++++++++ 2 files changed, 32 insertions(+), 18 deletions(-) diff --git a/x/distribution/keeper/delegation.go b/x/distribution/keeper/delegation.go index c70062c11d3f..005dffdbb6dd 100644 --- a/x/distribution/keeper/delegation.go +++ b/x/distribution/keeper/delegation.go @@ -188,24 +188,27 @@ func (k Keeper) withdrawDelegationRewards(ctx sdk.Context, val stakingtypes.Vali // remove delegator starting info k.DeleteDelegatorStartingInfo(ctx, del.GetValidatorAddr(), del.GetDelegatorAddr()) - if finalRewards.IsZero() { - baseDenom, _ := sdk.GetBaseDenom() - if baseDenom == "" { - baseDenom = sdk.DefaultBondDenom - } - - // Note, we do not call the NewCoins constructor as we do not want the zero - // coin removed. - finalRewards = sdk.Coins{sdk.NewCoin(baseDenom, sdk.ZeroInt())} - } - - ctx.EventManager().EmitEvent( - sdk.NewEvent( - types.EventTypeWithdrawRewards, - sdk.NewAttribute(sdk.AttributeKeyAmount, finalRewards.String()), - sdk.NewAttribute(types.AttributeKeyValidator, val.GetOperator().String()), - ), - ) + // TODO - rollback https://github.com/cosmos/cosmos-sdk/pull/13340 + // to prevent state breaking + // + // if finalRewards.IsZero() { + // baseDenom, _ := sdk.GetBaseDenom() + // if baseDenom == "" { + // baseDenom = sdk.DefaultBondDenom + // } + + // // Note, we do not call the NewCoins constructor as we do not want the zero + // // coin removed. + // finalRewards = sdk.Coins{sdk.NewCoin(baseDenom, sdk.ZeroInt())} + // } + + // ctx.EventManager().EmitEvent( + // sdk.NewEvent( + // types.EventTypeWithdrawRewards, + // sdk.NewAttribute(sdk.AttributeKeyAmount, finalRewards.String()), + // sdk.NewAttribute(types.AttributeKeyValidator, val.GetOperator().String()), + // ), + // ) return finalRewards, nil } diff --git a/x/distribution/keeper/keeper.go b/x/distribution/keeper/keeper.go index 22e1a2894402..cdc57e9e0ef0 100644 --- a/x/distribution/keeper/keeper.go +++ b/x/distribution/keeper/keeper.go @@ -98,6 +98,17 @@ func (k Keeper) WithdrawDelegationRewards(ctx sdk.Context, delAddr sdk.AccAddres return nil, err } + // TODO - rollback https://github.com/cosmos/cosmos-sdk/pull/13340 + // to prevent state breaking + // + ctx.EventManager().EmitEvent( + sdk.NewEvent( + types.EventTypeWithdrawRewards, + sdk.NewAttribute(sdk.AttributeKeyAmount, rewards.String()), + sdk.NewAttribute(types.AttributeKeyValidator, valAddr.String()), + ), + ) + // reinitialize the delegation k.initializeDelegation(ctx, valAddr, delAddr) return rewards, nil