From 9aa63aca000e7287ad912a5855f390ae317fe839 Mon Sep 17 00:00:00 2001 From: Yaru Wang Date: Wed, 28 Jun 2023 16:30:03 +0200 Subject: [PATCH 1/3] fix: emitted distribution events --- x/ccv/consumer/keeper/distribution.go | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/x/ccv/consumer/keeper/distribution.go b/x/ccv/consumer/keeper/distribution.go index e2c8d2a403..d150d3bf05 100644 --- a/x/ccv/consumer/keeper/distribution.go +++ b/x/ccv/consumer/keeper/distribution.go @@ -113,10 +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 +140,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 +152,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()), ), ) @@ -212,7 +211,7 @@ func (k Keeper) SetLastTransmissionBlockHeight(ctx sdk.Context, ltbh types.LastT } func (k Keeper) ChannelOpenInit(ctx sdk.Context, msg *channeltypes.MsgChannelOpenInit) ( - *channeltypes.MsgChannelOpenInitResponse, error, + *channeltypes.MsgChannelOpenInitResponse, error, ) { return k.ibcCoreKeeper.ChannelOpenInit(sdk.WrapSDKContext(ctx), msg) } From 0841a7e48e68dd4e5f6646e1f342f91f72fe26cf Mon Sep 17 00:00:00 2001 From: Yaru Wang Date: Wed, 28 Jun 2023 16:51:52 +0200 Subject: [PATCH 2/3] docs: update changelog --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index c7cb03404c..f98847efb3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,8 @@ 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. + ## v3.0.0 Date: June 21st, 2023 From f6d52342c2008e37e035319e6fd18e726b2fd49f Mon Sep 17 00:00:00 2001 From: Yaru Wang Date: Wed, 28 Jun 2023 17:43:20 +0200 Subject: [PATCH 3/3] fix: lint --- x/ccv/consumer/keeper/distribution.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/x/ccv/consumer/keeper/distribution.go b/x/ccv/consumer/keeper/distribution.go index d150d3bf05..9d59be2f89 100644 --- a/x/ccv/consumer/keeper/distribution.go +++ b/x/ccv/consumer/keeper/distribution.go @@ -211,7 +211,7 @@ func (k Keeper) SetLastTransmissionBlockHeight(ctx sdk.Context, ltbh types.LastT } func (k Keeper) ChannelOpenInit(ctx sdk.Context, msg *channeltypes.MsgChannelOpenInit) ( - *channeltypes.MsgChannelOpenInitResponse, error, + *channeltypes.MsgChannelOpenInitResponse, error, ) { return k.ibcCoreKeeper.ChannelOpenInit(sdk.WrapSDKContext(ctx), msg) }