From 16e71ab22104396b7ca3a08c83cd0a99810c31c9 Mon Sep 17 00:00:00 2001 From: "mergify[bot]" <37929162+mergify[bot]@users.noreply.github.com> Date: Thu, 6 Jul 2023 11:22:43 +0200 Subject: [PATCH] fix: `AttributeDistributionTotal` in event emit (backport #1097) (#1114) * fix: `AttributeDistributionTotal` in event emit (#1097) * fix: emitted distribution events * docs: update changelog * fix: lint --------- Co-authored-by: MSalopek (cherry picked from commit d16c7669b4f23380a50c8dedfaf6d25f50ca0edd) # Conflicts: # CHANGELOG.md # x/ccv/consumer/keeper/distribution.go * resolve conflicts * docs: remove v3 changelog from v2 release line --------- Co-authored-by: yaruwangway <69694322+yaruwangway@users.noreply.github.com> Co-authored-by: Yaru Wang --- CHANGELOG.md | 8 +++++++- x/ccv/consumer/keeper/distribution.go | 10 ++++------ 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1528717b13..11fc543bc9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,12 @@ # CHANGELOG -## v.2.0.0 +## [Unreleased] + +Add an entry to the unreleased section whenever merging a PR to main that is not targeted at a specific release. These entries will eventually be included in a release. + +* (fix) [#720](https://github.com/cosmos/interchain-security/issues/720) Fix the attribute `AttributeDistributionTotal` value in `FeeDistribution` event emit. + +## v2.0.0 Date: June 1st, 2023 diff --git a/x/ccv/consumer/keeper/distribution.go b/x/ccv/consumer/keeper/distribution.go index 6d56f6c901..1209d433f6 100644 --- a/x/ccv/consumer/keeper/distribution.go +++ b/x/ccv/consumer/keeper/distribution.go @@ -113,11 +113,12 @@ func (k Keeper) SendRewardsToProvider(ctx sdk.Context) error { timeoutTimestamp := uint64(ctx.BlockTime().Add(transferTimeoutPeriod).UnixNano()) sentCoins := sdk.NewCoins() - + var allBalances sdk.Coins // iterate over all whitelisted reward denoms for _, denom := range k.AllowedRewardDenoms(ctx) { // get the balance of the denom in the toSendToProviderTokens address balance := k.bankKeeper.GetBalance(ctx, tstProviderAddr, denom) + allBalances = allBalances.Add(balance) // if the balance is not zero, if !balance.IsZero() { @@ -138,11 +139,8 @@ func (k Keeper) SendRewardsToProvider(ctx sdk.Context) error { } } - consumerFeePoolAddr := k.authKeeper.GetModuleAccount(ctx, k.feeCollectorName).GetAddress() - fpTokens := k.bankKeeper.GetAllBalances(ctx, consumerFeePoolAddr) - k.Logger(ctx).Info("sent block rewards to provider", - "total fee pool", fpTokens.String(), + "total fee pool", allBalances.String(), "sent", sentCoins.String(), ) currentHeight := ctx.BlockHeight() @@ -153,7 +151,7 @@ func (k Keeper) SendRewardsToProvider(ctx sdk.Context) error { sdk.NewAttribute(ccv.AttributeDistributionCurrentHeight, strconv.Itoa(int(currentHeight))), sdk.NewAttribute(ccv.AttributeDistributionNextHeight, strconv.Itoa(int(currentHeight+k.GetBlocksPerDistributionTransmission(ctx)))), sdk.NewAttribute(ccv.AttributeDistributionFraction, (k.GetConsumerRedistributionFrac(ctx))), - sdk.NewAttribute(ccv.AttributeDistributionTotal, fpTokens.String()), + sdk.NewAttribute(ccv.AttributeDistributionTotal, allBalances.String()), sdk.NewAttribute(ccv.AttributeDistributionToProvider, sentCoins.String()), ), )