From ce1c208876a3c0433e1bf6393edb1b85d7c4eb7b Mon Sep 17 00:00:00 2001 From: Dev Ojha Date: Fri, 25 Aug 2023 08:22:24 -0500 Subject: [PATCH 1/2] The state compatible epoch speedup --- x/incentives/keeper/distribute.go | 16 ++++++++++++++++ x/superfluid/keeper/stake.go | 4 ++-- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/x/incentives/keeper/distribute.go b/x/incentives/keeper/distribute.go index b599b40eb71..9f414f0a0d6 100644 --- a/x/incentives/keeper/distribute.go +++ b/x/incentives/keeper/distribute.go @@ -421,6 +421,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 d9c5beb8990..5b5d65e6253 100644 --- a/x/superfluid/keeper/stake.go +++ b/x/superfluid/keeper/stake.go @@ -66,7 +66,7 @@ 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. - k.Logger(ctx).Info(fmt.Sprintf("Existing delegation not found for %s with %s during superfluid refresh."+ + 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 { currentAmount = validator.TokensFromShares(delegation.Shares).RoundInt() @@ -95,7 +95,7 @@ func (k Keeper) RefreshIntermediaryDelegationAmounts(ctx sdk.Context) { ctx.Logger().Error("Error in forceUndelegateAndBurnOsmoTokens, state update reverted", err) } } else { - ctx.Logger().Info("Intermediary account already has correct delegation amount?" + + ctx.Logger().Debug("Intermediary account already has correct delegation amount?" + " This with high probability implies the exact same spot price as the last epoch," + "and no delegation changes.") } From e08ad736cbe3a4a55071c9b2185b312fc6fb9053 Mon Sep 17 00:00:00 2001 From: devbot-wizard <141283918+devbot-wizard@users.noreply.github.com> Date: Fri, 25 Aug 2023 13:27:29 +0000 Subject: [PATCH 2/2] update changelog --- CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index b770c2af6bd..64efd790149 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -42,6 +42,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## Unreleased +### Misc Improvements + +* [#6161](https://github.com/osmosis-labs/osmosis/pull/6161) Reduce CPU time of epochs + ### API breaks * [#6071](https://github.com/osmosis-labs/osmosis/pull/6071) reduce number of returns for UpdatePosition and TicksToSqrtPrice functions