Skip to content

Commit

Permalink
feat: speedup epoch distribution, superfluid component (#2214)
Browse files Browse the repository at this point in the history
* Speedup epoch distribution, superfluid component

* changelog entries

* lint

Co-authored-by: Dev Ojha <dojha@berkeley.edu>
(cherry picked from commit 3cdfbcc)

# Conflicts:
#	CHANGELOG.md
#	x/incentives/keeper/distribute.go
  • Loading branch information
czarcas7ic authored and mergify[bot] committed Jul 23, 2022
1 parent dcda2e3 commit d93ced3
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 5 deletions.
14 changes: 14 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,24 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## v10.1.0

<<<<<<< HEAD
#### Bug Fixes
* [2011](https://github.com/osmosis-labs/osmosis/pull/2011) Fix bug in TokenFactory initGenesis, relating to denom creation fee param.

#### Improvements
* [#2130](https://github.com/osmosis-labs/osmosis/pull/2130) Introduce errors in mint types.
* [#2000](https://github.com/osmosis-labs/osmosis/pull/2000) Update import paths from v9 to v10.
=======
* [#1889](https://github.com/osmosis-labs/osmosis/pull/1825) Add proto responses to gamm LP messages:
* MsgJoinPoolResponse: share_out_amount and token_in fields
* MsgExitPoolResponse: token_out field
* [#1825](https://github.com/osmosis-labs/osmosis/pull/1825) Fixes Interchain Accounts (host side) by adding it to AppModuleBasics
* [#1699](https://github.com/osmosis-labs/osmosis/pull/1699) Fixes bug in sig fig rounding on spot price queries for small values
* [#1994](https://github.com/osmosis-labs/osmosis/pull/1994) Removed bech32ibc module
* [#2016](https://github.com/osmosis-labs/osmosis/pull/2016) Add fixed 10000 gas cost for each Balancer swap
* [#2147](https://github.com/osmosis-labs/osmosis/pull/2147) Set MaxAgeNumBlocks in v11 Upgrade Handler to two weeks.
* [#2193](https://github.com/osmosis-labs/osmosis/pull/2193) Add TwapKeeper to the Osmosis app
>>>>>>> 3cdfbccd (feat: speedup epoch distribution, superfluid component (#2214))
#### Golang API breaks
* [#1937](https://github.com/osmosis-labs/osmosis/pull/1937) Change `lockupKeeper.ExtendLock` to take in lockID instead of the direct lock struct.
Expand Down Expand Up @@ -91,6 +103,8 @@ This release contains minor CLI bug fixes.
* [1931](https://github.com/osmosis-labs/osmosis/pull/1931) Add explicit check for input denoms to `CalcJoinPoolShares`


### Improvements
* [#2214](https://github.com/osmosis-labs/osmosis/pull/2214) Speedup epoch distribution, superfluid component

## [v9.0.0 - Nitrogen](https://github.com/osmosis-labs/osmosis/releases/tag/v9.0.0)

Expand Down
34 changes: 29 additions & 5 deletions x/incentives/keeper/distribute.go
Original file line number Diff line number Diff line change
Expand Up @@ -227,20 +227,44 @@ func (k Keeper) doDistributionSends(ctx sdk.Context, distrs *distributionInfo) e
func (k Keeper) distributeSyntheticInternal(
ctx sdk.Context, gauge types.Gauge, locks []lockuptypes.PeriodLock, distrInfo *distributionInfo,
) (sdk.Coins, error) {
denom := gauge.DistributeTo.Denom

qualifiedLocks := make([]lockuptypes.PeriodLock, 0, len(locks))
qualifiedLocks := k.lk.GetLocksLongerThanDurationDenom(ctx, gauge.DistributeTo.Denom, gauge.DistributeTo.Duration)

// map from lockID to present index in resultant list
// to be state compatible with what we had before, we iterate over locks, to get qualified locks
// to be in the same order as what is present in locks.
// in a future release, we can just use qualified locks directly.
type lockIndexPair struct {
lock lockuptypes.PeriodLock
index int
}
qualifiedLocksMap := make(map[uint64]lockIndexPair, len(qualifiedLocks))
for _, lock := range qualifiedLocks {
qualifiedLocksMap[lock.ID] = lockIndexPair{lock, -1}
}
curIndex := 0
for _, lock := range locks {
<<<<<<< HEAD
// See if this lock has a synthetic lockup. If so, err == nil, and we add to qualifiedLocks
// otherwise it does not, and we continue.
_, err := k.lk.GetSyntheticLockup(ctx, lock.ID, denom)
if err != nil {
=======
if v, ok := qualifiedLocksMap[lock.ID]; ok {
qualifiedLocksMap[lock.ID] = lockIndexPair{v.lock, curIndex}
curIndex += 1
}
}

sortedAndTrimmedQualifiedLocks := make([]lockuptypes.PeriodLock, curIndex)
for _, v := range qualifiedLocksMap {
if v.index < 0 {
>>>>>>> 3cdfbccd (feat: speedup epoch distribution, superfluid component (#2214))
continue
}
qualifiedLocks = append(qualifiedLocks, lock)
sortedAndTrimmedQualifiedLocks[v.index] = v.lock
}

return k.distributeInternal(ctx, gauge, qualifiedLocks, distrInfo)
return k.distributeInternal(ctx, gauge, sortedAndTrimmedQualifiedLocks, distrInfo)
}

// distributeInternal runs the distribution logic for a gauge, and adds the sends to
Expand Down

0 comments on commit d93ced3

Please sign in to comment.