Skip to content

Commit

Permalink
fix: AttributeDistributionTotal in event emit (#1097)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
yaruwangway authored and mergify[bot] committed Jul 5, 2023
1 parent 362b7c0 commit be17263
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 5 deletions.
25 changes: 25 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,31 @@
# CHANGELOG

<<<<<<< HEAD
## 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.

## v3.0.0

Date: June 21st, 2023

Interchain Security v3 uses SDK 0.47 and IBC 7.

* (fix) [#1093](https://github.com/cosmos/interchain-security/pull/1093) Make SlashPacketData backward compatible when sending data over the wire
* (deps) [#1019](https://github.com/cosmos/interchain-security/pull/1019) Bump multiple dependencies.
* Bump [cosmos-sdk](https://github.com/cosmos/cosmos-sdk) to [v0.47.3](https://github.com/cosmos/cosmos-sdk/releases/tag/v0.47.3).
* Bump [ibc-go](https://github.com/cosmos/ibc-go) to [v7.1.0](https://github.com/cosmos/ibc-go/releases/tag/v7.1.0).
* Bump [CometBFT](https://github.com/cometbft/cometbft) to [v0.37.1](https://github.com/cometbft/cometbft/releases/tag/v0.37.1).
* `[x/ccv/provider]` (fix) [#945](https://github.com/cosmos/interchain-security/issues/945) Refactor `AfterUnbondingInitiated` to not panic when `PutUnbondingOnHold` returns error.
* `[x/ccv/provider]` (fix) [#977](https://github.com/cosmos/interchain-security/pull/977) Avoids panicking the provider when an unbonding delegation was removed through a `CancelUnbondingDelegation` message.
* `[x/ccv/democracy]` (feat) [#1019](https://github.com/cosmos/interchain-security/pull/1019) Whitelisting non-legacy params in the "democracy module" require the entire module to be whitelisted.

## v2.0.0
>>>>>>> d16c766 (fix: `AttributeDistributionTotal` in event emit (#1097))
Date: June 1st, 2023

Expand Down
12 changes: 7 additions & 5 deletions x/ccv/consumer/keeper/distribution.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,11 +113,16 @@ func (k Keeper) SendRewardsToProvider(ctx sdk.Context) error {
timeoutTimestamp := uint64(ctx.BlockTime().Add(transferTimeoutPeriod).UnixNano())

sentCoins := sdk.NewCoins()
<<<<<<< HEAD

Check failure on line 116 in x/ccv/consumer/keeper/distribution.go

View workflow job for this annotation

GitHub Actions / Automated_Tests

syntax error: unexpected <<, expecting }

Check failure on line 116 in x/ccv/consumer/keeper/distribution.go

View workflow job for this annotation

GitHub Actions / lint

expected statement, found '<<' (typecheck)

=======

Check failure on line 118 in x/ccv/consumer/keeper/distribution.go

View workflow job for this annotation

GitHub Actions / Automated_Tests

syntax error: unexpected ==, expecting }
var allBalances sdk.Coins
>>>>>>> d16c766 (fix: `AttributeDistributionTotal` in event emit (#1097))

Check failure on line 120 in x/ccv/consumer/keeper/distribution.go

View workflow job for this annotation

GitHub Actions / Automated_Tests

syntax error: non-declaration statement outside function body

Check failure on line 120 in x/ccv/consumer/keeper/distribution.go

View workflow job for this annotation

GitHub Actions / Automated_Tests

invalid character U+0023 '#'

Check failure on line 120 in x/ccv/consumer/keeper/distribution.go

View workflow job for this annotation

GitHub Actions / lint

expected statement, found '>>' (typecheck)
// 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 +143,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 +155,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 be17263

Please sign in to comment.