Unverified Commit 1a5d1206 authored by mergify[bot]'s avatar mergify[bot] Committed by GitHub
Browse files

feat: speedup epoch distribution, superfluid component (backport #2214) (#2215)


* feat: speedup epoch distribution, superfluid component (#2214)

* Speedup epoch distribution, superfluid component

* changelog entries

* lint

Co-authored-by: default avatarDev Ojha <dojha@berkeley.edu>
(cherry picked from commit 3cdfbccd

)

# Conflicts:
#	CHANGELOG.md
#	x/incentives/keeper/distribute.go

* merge conflicts

* Update CHANGELOG.md

* Update CHANGELOG.md

Co-authored-by: default avatarAdam Tucker <adam@osmosis.team>
Co-authored-by: default avatarAdam Tucker <adamleetucker@outlook.com>
parent dcda2e3e
Showing with 31 additions and 11 deletions
+31 -11
...@@ -40,6 +40,11 @@ All notable changes to this project will be documented in this file. ...@@ -40,6 +40,11 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
## v10.1.1
#### Improvements
* [#2214](https://github.com/osmosis-labs/osmosis/pull/2214) Speedup epoch distribution, superfluid component
## v10.1.0 ## v10.1.0
#### Bug Fixes #### Bug Fixes
...@@ -90,8 +95,6 @@ This release contains minor CLI bug fixes. ...@@ -90,8 +95,6 @@ This release contains minor CLI bug fixes.
* [1698](https://github.com/osmosis-labs/osmosis/pull/1698) Register wasm snapshotter extension. * [1698](https://github.com/osmosis-labs/osmosis/pull/1698) Register wasm snapshotter extension.
* [1931](https://github.com/osmosis-labs/osmosis/pull/1931) Add explicit check for input denoms to `CalcJoinPoolShares` * [1931](https://github.com/osmosis-labs/osmosis/pull/1931) Add explicit check for input denoms to `CalcJoinPoolShares`
## [v9.0.0 - Nitrogen](https://github.com/osmosis-labs/osmosis/releases/tag/v9.0.0) ## [v9.0.0 - Nitrogen](https://github.com/osmosis-labs/osmosis/releases/tag/v9.0.0)
The Nitrogen release brings with it a number of features enabling further cosmwasm development work in Osmosis. The Nitrogen release brings with it a number of features enabling further cosmwasm development work in Osmosis.
......
...@@ -227,20 +227,37 @@ func (k Keeper) doDistributionSends(ctx sdk.Context, distrs *distributionInfo) e ...@@ -227,20 +227,37 @@ func (k Keeper) doDistributionSends(ctx sdk.Context, distrs *distributionInfo) e
func (k Keeper) distributeSyntheticInternal( func (k Keeper) distributeSyntheticInternal(
ctx sdk.Context, gauge types.Gauge, locks []lockuptypes.PeriodLock, distrInfo *distributionInfo, ctx sdk.Context, gauge types.Gauge, locks []lockuptypes.PeriodLock, distrInfo *distributionInfo,
) (sdk.Coins, error) { ) (sdk.Coins, error) {
denom := gauge.DistributeTo.Denom qualifiedLocks := k.lk.GetLocksLongerThanDurationDenom(ctx, gauge.DistributeTo.Denom, gauge.DistributeTo.Duration)
qualifiedLocks := make([]lockuptypes.PeriodLock, 0, len(locks)) // 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 { for _, lock := range locks {
// See if this lock has a synthetic lockup. If so, err == nil, and we add to qualifiedLocks if v, ok := qualifiedLocksMap[lock.ID]; ok {
// otherwise it does not, and we continue. qualifiedLocksMap[lock.ID] = lockIndexPair{v.lock, curIndex}
_, err := k.lk.GetSyntheticLockup(ctx, lock.ID, denom) curIndex += 1
if err != nil { }
}
sortedAndTrimmedQualifiedLocks := make([]lockuptypes.PeriodLock, curIndex)
for _, v := range qualifiedLocksMap {
if v.index < 0 {
continue 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 // distributeInternal runs the distribution logic for a gauge, and adds the sends to
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment