From e8d98267a61c2978448c52377203fe24cf5870ef Mon Sep 17 00:00:00 2001 From: "mergify[bot]" <37929162+mergify[bot]@users.noreply.github.com> Date: Thu, 17 Oct 2024 13:07:59 +0200 Subject: [PATCH] refactor: clean distribution logs (backport #2356) (#2360) refactor: clean distribution logs (#2356) * add check to remove logs * remove wrong condition (cherry picked from commit 4ec913bcc8171503cbcf668ca5a743cf96443371) Co-authored-by: Simon Noetzlin --- x/ccv/provider/keeper/distribution.go | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/x/ccv/provider/keeper/distribution.go b/x/ccv/provider/keeper/distribution.go index 7c0bf02764..8b5a0571d7 100644 --- a/x/ccv/provider/keeper/distribution.go +++ b/x/ccv/provider/keeper/distribution.go @@ -139,6 +139,9 @@ func (k Keeper) DeleteConsumerRewardsAllocationByDenom(ctx sdk.Context, consumer // AllocateConsumerRewards allocates the given rewards to provider consumer chain with the given consumer id func (k Keeper) AllocateConsumerRewards(ctx sdk.Context, consumerId string, alloc types.ConsumerRewardsAllocation) (types.ConsumerRewardsAllocation, error) { + if alloc.Rewards.IsZero() { + return types.ConsumerRewardsAllocation{}, nil + } chainId, err := k.GetConsumerChainId(ctx, consumerId) if err != nil { @@ -268,10 +271,6 @@ func (k Keeper) AllocateConsumerRewards(ctx sdk.Context, consumerId string, allo // AllocateTokens performs rewards distribution to the community pool and validators // based on the Partial Set Security distribution specification. func (k Keeper) AllocateTokens(ctx sdk.Context) { - // return if there is no coins in the consumer rewards pool - if k.GetConsumerRewardsPool(ctx).IsZero() { - return - } // Iterate over all launched consumer chains. // To avoid large iterations over all the consumer IDs, iterate only over @@ -312,6 +311,7 @@ func (k Keeper) AllocateTokens(ctx sdk.Context) { ) continue } + err = k.SetConsumerRewardsAllocationByDenom(cachedCtx, consumerId, denom, remainingRewardDec) if err != nil { k.Logger(ctx).Error( @@ -321,6 +321,7 @@ func (k Keeper) AllocateTokens(ctx sdk.Context) { ) continue } + writeCache() } }