Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[VS Incentives] refactor/test: move group gauge creation to CreateGauge; address spam concerns #6536

Merged
merged 11 commits into from
Sep 26, 2023

Conversation

p0mvn
Copy link
Member

@p0mvn p0mvn commented Sep 25, 2023

Closes: #6513, #6491

What is the purpose of the change

This PR focuses low-level and repetitive group gauge creation logic in CreateGroup and, instead, moves that under CreateGauge.

This also addresses the spam concern in #6491 since CreateGauge already handles that.

This PR also added stricter checks for the input validation to CreateGauge

Testing and Verifying

  • Modified

Documentation and Release Note

  • Does this pull request introduce a new feature or user-facing behavior changes?
  • Changelog entry added to Unreleased section of CHANGELOG.md?

Where is the change documented?

  • Specification (x/{module}/README.md)
  • Osmosis documentation site
  • Code comments?
  • N/A

s.Require().NoError(err)
externalGauge, err := s.App.IncentivesKeeper.GetGaugeByID(s.Ctx, externalGaugeid)
s.Require().NoError(err)
externalGauge := s.createGaugeNoRestrictions(tc.isPerpertual, tc.gaugeCoins, tc.distrTo, tc.startTime, tc.numEpochsPaidOver, defaultCLPool)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note: it was required to modify the test and create this helper due to stricter validation in CreateGauge. The goal is to setup an invalid gauge state so that Distribute() function below fails. With the old logic, it was impossible to hit edge cases while keeping stricter validation

Comment on lines -470 to -491
const (
zeroPoolId = uint64(0)
balancerPoolId = uint64(1)
concentratedPoolId = uint64(2)
invalidPool = uint64(3)
// 3 are created for balancer pool and 1 for CL.
// As a result, the next gauge id should be 5.
defaultExpectedGaugeId = uint64(5)

defaultIsPerpetualParam = false

defaultNumEpochPaidOver = uint64(10)
)

var (
defaultCoins = sdk.NewCoins(
sdk.NewCoin("uosmo", osmomath.NewInt(100000)),
sdk.NewCoin("atom", osmomath.NewInt(99999)),
)

defaultTime = time.Unix(0, 0)
)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note: moved up to share across tests and reduce duplication

Comment on lines -239 to -242
if numEpochPaidOver == 0 {
return 0, types.ErrZeroNumEpochsPaidOver
}
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note: perpetual gauges are signified by numEpochPaidOver of 0

@p0mvn p0mvn marked this pull request as ready for review September 25, 2023 17:51
@p0mvn p0mvn marked this pull request as draft September 25, 2023 18:45
@p0mvn p0mvn force-pushed the roman/move-group-gauge-create branch from d25ea9f to 4c795aa Compare September 25, 2023 21:08
@p0mvn p0mvn marked this pull request as ready for review September 25, 2023 21:48
Copy link
Member

@czarcas7ic czarcas7ic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice 👍

x/incentives/keeper/gauge_test.go Outdated Show resolved Hide resolved
x/incentives/keeper/gauge_test.go Outdated Show resolved Hide resolved
Comment on lines +1037 to +1044
func (s KeeperTestSuite) validateNoGaugeIDInSlice(slice []types.Gauge, gaugeID uint64) {
gaugeMatch := osmoutils.Filter(func(gauge types.Gauge) bool {
return gauge.Id == gaugeID
}, slice)
// No gauge matched ID.
s.Require().Empty(gaugeMatch)

}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can ignore but this feels like we could maybe abstract this helper as a whole to osmoutils

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably not osmoutils because this depends on apptesting.Suite. I will move this to apptesting though, good idea!

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will address in next PR

Base automatically changed from roman/group-creation-fee to main September 26, 2023 21:31
@p0mvn p0mvn added V:state/breaking State machine breaking PR A:no-changelog labels Sep 26, 2023
@p0mvn p0mvn merged commit 118fd74 into main Sep 26, 2023
@p0mvn p0mvn deleted the roman/move-group-gauge-create branch September 26, 2023 21:55
pysel pushed a commit that referenced this pull request Sep 27, 2023
…ge; address spam concerns (#6536)

* [Volume Splitting] feat: implement initGaugeInfo helper

* comments

* refactor/test: CreateGroup takes pool IDs; new tests

* lint

* [VS Incentives]: feat: group creation fee

* comment updates

* fixes issues

* [VS Incentives] refactor/test: move group gauge creation to CreateGauge; address spam concerns

* Update x/incentives/keeper/gauge_test.go

Co-authored-by: Adam Tucker <[email protected]>

* Update x/incentives/keeper/gauge_test.go

Co-authored-by: Adam Tucker <[email protected]>

---------

Co-authored-by: Adam Tucker <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[VS Incentives]: remove gauge creation logic from CreateGroup, call CreateGauge instead
2 participants