Skip to content

Commit

Permalink
fix: AttributeDistributionTotal in event emit (backport #1097) (#1114)
Browse files Browse the repository at this point in the history
* fix: `AttributeDistributionTotal` in event emit (#1097)

* fix: emitted distribution events

* docs: update changelog

* fix: lint

---------

Co-authored-by: MSalopek <[email protected]>
(cherry picked from commit d16c766)

# Conflicts:
#	CHANGELOG.md
#	x/ccv/consumer/keeper/distribution.go

* resolve conflicts

* docs: remove v3 changelog from v2 release line

---------

Co-authored-by: yaruwangway <[email protected]>
Co-authored-by: Yaru Wang <[email protected]>
  • Loading branch information
3 people authored Jul 6, 2023
1 parent 362b7c0 commit 16e71ab
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
8 changes: 7 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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

Expand Down
10 changes: 4 additions & 6 deletions x/ccv/consumer/keeper/distribution.go
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand All @@ -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()
Expand All @@ -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()),
),
)
Expand Down

0 comments on commit 16e71ab

Please sign in to comment.