Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: AttributeDistributionTotal in event emit #1097

Merged
merged 4 commits into from
Jul 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
9 changes: 4 additions & 5 deletions x/ccv/consumer/keeper/distribution.go
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand All @@ -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()
Expand All @@ -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()),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

would something like AttributeTotalFeePool be a better name here? Likely not important tho

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i can change it here, it is a var name, so not api breaking right?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure what API breaking would mean in this context, if you change the value string then the event will change (which seems ok? I don't think changing an event is state breaking but I could be wrong), if you just change the var naming then it's a pure refactor. Again not super important, so feel free to ignore my comment if we're not confident how the change would affect things

sdk.NewAttribute(ccv.AttributeDistributionToProvider, sentCoins.String()),
),
)
Expand Down
Loading