Skip to content

Commit 16e71ab

Browse files
mergify[bot]yaruwangwayYaru Wang
authored
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 <[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]>
1 parent 362b7c0 commit 16e71ab

File tree

2 files changed

+11
-7
lines changed

2 files changed

+11
-7
lines changed

CHANGELOG.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
# CHANGELOG
22

3-
## v.2.0.0
3+
## [Unreleased]
4+
5+
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.
6+
7+
* (fix) [#720](https://github.com/cosmos/interchain-security/issues/720) Fix the attribute `AttributeDistributionTotal` value in `FeeDistribution` event emit.
8+
9+
## v2.0.0
410

511
Date: June 1st, 2023
612

x/ccv/consumer/keeper/distribution.go

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -113,11 +113,12 @@ func (k Keeper) SendRewardsToProvider(ctx sdk.Context) error {
113113
timeoutTimestamp := uint64(ctx.BlockTime().Add(transferTimeoutPeriod).UnixNano())
114114

115115
sentCoins := sdk.NewCoins()
116-
116+
var allBalances sdk.Coins
117117
// iterate over all whitelisted reward denoms
118118
for _, denom := range k.AllowedRewardDenoms(ctx) {
119119
// get the balance of the denom in the toSendToProviderTokens address
120120
balance := k.bankKeeper.GetBalance(ctx, tstProviderAddr, denom)
121+
allBalances = allBalances.Add(balance)
121122

122123
// if the balance is not zero,
123124
if !balance.IsZero() {
@@ -138,11 +139,8 @@ func (k Keeper) SendRewardsToProvider(ctx sdk.Context) error {
138139
}
139140
}
140141

141-
consumerFeePoolAddr := k.authKeeper.GetModuleAccount(ctx, k.feeCollectorName).GetAddress()
142-
fpTokens := k.bankKeeper.GetAllBalances(ctx, consumerFeePoolAddr)
143-
144142
k.Logger(ctx).Info("sent block rewards to provider",
145-
"total fee pool", fpTokens.String(),
143+
"total fee pool", allBalances.String(),
146144
"sent", sentCoins.String(),
147145
)
148146
currentHeight := ctx.BlockHeight()
@@ -153,7 +151,7 @@ func (k Keeper) SendRewardsToProvider(ctx sdk.Context) error {
153151
sdk.NewAttribute(ccv.AttributeDistributionCurrentHeight, strconv.Itoa(int(currentHeight))),
154152
sdk.NewAttribute(ccv.AttributeDistributionNextHeight, strconv.Itoa(int(currentHeight+k.GetBlocksPerDistributionTransmission(ctx)))),
155153
sdk.NewAttribute(ccv.AttributeDistributionFraction, (k.GetConsumerRedistributionFrac(ctx))),
156-
sdk.NewAttribute(ccv.AttributeDistributionTotal, fpTokens.String()),
154+
sdk.NewAttribute(ccv.AttributeDistributionTotal, allBalances.String()),
157155
sdk.NewAttribute(ccv.AttributeDistributionToProvider, sentCoins.String()),
158156
),
159157
)

0 commit comments

Comments
 (0)