From ff4bd5e2988b064bd8f987ecc74d0f1218ae0f9b Mon Sep 17 00:00:00 2001 From: Roman Date: Tue, 29 Aug 2023 17:34:22 -0400 Subject: [PATCH] State compatible epoch speedup from v18 (backport #6161) --- x/incentives/keeper/distribute.go | 16 ++++++++++++++++ x/superfluid/keeper/stake.go | 3 +++ 2 files changed, 19 insertions(+) diff --git a/x/incentives/keeper/distribute.go b/x/incentives/keeper/distribute.go index f778a8f9962..39457b61e05 100644 --- a/x/incentives/keeper/distribute.go +++ b/x/incentives/keeper/distribute.go @@ -381,6 +381,22 @@ func (k Keeper) distributeInternal( return nil, nil } + // In this case, remove redundant cases. + // Namely: gauge empty OR gauge coins undistributable. + if remainCoins.Empty() { + ctx.Logger().Debug(fmt.Sprintf("gauge debug, this gauge is empty, why is it being ran %d. Balancer code", gauge.Id)) + err := k.updateGaugePostDistribute(ctx, gauge, totalDistrCoins) + return totalDistrCoins, err + } + + // Remove some spam gauges, is state compatible. + // If they're to pool 1 they can't distr at this small of a quantity. + if remainCoins.Len() == 1 && remainCoins[0].Amount.LTE(sdk.NewInt(10)) && gauge.DistributeTo.Denom == "gamm/pool/1" && remainCoins[0].Denom != "uosmo" { + ctx.Logger().Debug(fmt.Sprintf("gauge debug, this gauge is perceived spam, skipping %d", gauge.Id)) + err := k.updateGaugePostDistribute(ctx, gauge, totalDistrCoins) + return totalDistrCoins, err + } + for _, lock := range locks { distrCoins := sdk.Coins{} ctx.Logger().Debug("distributeInternal, distribute to lock", "module", types.ModuleName, "gaugeId", gauge.Id, "lockId", lock.ID, "remainCons", remainCoins, "height", ctx.BlockHeight()) diff --git a/x/superfluid/keeper/stake.go b/x/superfluid/keeper/stake.go index 8fc7b24622c..167a6ce4227 100644 --- a/x/superfluid/keeper/stake.go +++ b/x/superfluid/keeper/stake.go @@ -66,7 +66,10 @@ func (k Keeper) RefreshIntermediaryDelegationAmounts(ctx sdk.Context) { if !found { // continue if current delegation is 0, in case its really a dust delegation // that becomes worth something after refresh. +<<<<<<< HEAD // TODO: We have a correct explanation for this in some github issue, lets amend this correctly. +======= +>>>>>>> 19c3c508 (State compatible epoch speedup from v18 (#6161)) k.Logger(ctx).Debug(fmt.Sprintf("Existing delegation not found for %s with %s during superfluid refresh."+ " It may have been previously bonded, but now unbonded.", mAddr.String(), acc.ValAddr)) } else {