Skip to content

Commit

Permalink
x/incentives: Lower Epoch allocation overhead (#7100) (#7104)
Browse files Browse the repository at this point in the history
* Lower allocation overhead

* Add changelog

(cherry picked from commit 63d2551)

Co-authored-by: Dev Ojha <[email protected]>
  • Loading branch information
mergify[bot] and ValarDragon committed Dec 20, 2023
1 parent 1a243ab commit e0ff843
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 3 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
* [#6890](https://github.com/osmosis-labs/osmosis/pull/6890) Enable arb filter for affiliate swap contract
* [#6884](https://github.com/osmosis-labs/osmosis/pull/6914) Update ListPoolsByDenom function by using pool.GetPoolDenoms to filter denom directly
* [#6959](https://github.com/osmosis-labs/osmosis/pull/6959) Increase high gas threshold to 2m from 1m
* [#7093](https://github.com/osmosis-labs/osmosis/pull/7093),[#7100](https://github.com/osmosis-labs/osmosis/pull/7100) Lower CPU overheads of the Osmosis epoch.

### API Breaks

Expand Down
5 changes: 3 additions & 2 deletions x/incentives/keeper/distribute.go
Original file line number Diff line number Diff line change
Expand Up @@ -652,13 +652,14 @@ func (k Keeper) distributeInternal(
if lockSum.IsZero() {
return nil, nil
}
remainingEpochsAsInt := osmomath.NewInt(int64(remainEpochs))
// total_denom_lock_amount * remain_epochs
lockSumTimesRemainingEpochs := lockSum.Mul(remainingEpochsAsInt)
lockSumTimesRemainingEpochs := lockSum.MulRaw(int64(remainEpochs))

for _, lock := range locks {
distrCoins := sdk.Coins{}
// too expensive + verbose even in debug mode.
// ctx.Logger().Debug("distributeInternal, distribute to lock", "module", types.ModuleName, "gaugeId", gauge.Id, "lockId", lock.ID, "remainCons", remainCoins, "height", ctx.BlockHeight())

for _, coin := range remainCoins {
// distribution amount = gauge_size * denom_lock_amount / (total_denom_lock_amount * remain_epochs)
denomLockAmt := lock.Coins.AmountOfNoDenomValidation(denom)
Expand Down
2 changes: 1 addition & 1 deletion x/incentives/keeper/iterator.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ func (k Keeper) FinishedGaugesIterator(ctx sdk.Context) sdk.Iterator {

// FilterLocksByMinDuration returns locks whose lock duration is greater than the provided minimum duration.
func FilterLocksByMinDuration(locks []lockuptypes.PeriodLock, minDuration time.Duration) []lockuptypes.PeriodLock {
filteredLocks := make([]lockuptypes.PeriodLock, 0, len(locks)/2)
filteredLocks := make([]lockuptypes.PeriodLock, 0, len(locks))
for _, lock := range locks {
if lock.Duration >= minDuration {
filteredLocks = append(filteredLocks, lock)
Expand Down

0 comments on commit e0ff843

Please sign in to comment.