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

Refactor createGauge to accomodate for CL gauges #5383

Closed
wants to merge 8 commits into from

Conversation

hieuvubk
Copy link
Contributor

@hieuvubk hieuvubk commented Jun 1, 2023

Closes: #4833

What is the purpose of the change

  • Currently, LockQueryType enum has an index 0 as ByDuration. So if we pass lockuptypes.QueryCondition{}, distrTo.LockQueryType will default to ByDuration and enter the loop => I change the indexes for passing the loop.
  • Add test for case disTo.Denom = "" when we pass lockuptypes.QueryCondition{}

Testing and Verifying

(Please pick one of the following options)

This change is a trivial rework / code cleanup without any test coverage.

(or)

This change is already covered by existing tests, such as (please describe tests).

(or)

This change added tests and can be verified as follows:

(example:)

  • Added unit test that validates ...
  • Added integration tests for end-to-end deployment with ...
  • Extended integration test for ...
  • Manually verified the change by ...

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

@mattverse mattverse added V:state/compatible/no_backport State machine compatible PR, depends on prior breaks A:no-changelog V:state/breaking State machine breaking PR and removed V:state/compatible/no_backport State machine compatible PR, depends on prior breaks labels Jun 1, 2023
Copy link
Contributor

@stackman27 stackman27 left a comment

Choose a reason for hiding this comment

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

thank you for the PR

just have few questions before ACK :))

ByDuration = 0;
ByTime = 1;
ByTime = 0;
ByDuration = 1;
Copy link
Contributor

Choose a reason for hiding this comment

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

why was this changed again?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Even if we pass lockuptypes.QueryCondition{} to the function, it will still get the default value of distrTo.LockQueryType which is the first value of LockQueryType (In this case ByDuration => thus causing an error in the loop. )
So I just change the index to bypass.

Copy link
Contributor

Choose a reason for hiding this comment

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

for CL the we are not distributing via locktypes so, what i originally thought was that we could skip distrTo check below;

	if distrTo.LockQueryType == lockuptypes.ByDuration {
		durationOk := false
		for _, duration := range durations {
			if duration == distrTo.Duration {
				durationOk = true
				break
			}
		}
		if !durationOk {
			return 0, fmt.Errorf("invalid duration: %d", distrTo.Duration)
		}
	}

	// check if denom this gauge pays out to exists on-chain
	if distrTo.Denom != "" && !k.bk.HasSupply(ctx, distrTo.Denom) && !strings.Contains(distrTo.Denom, "osmovaloper") {
		return 0, fmt.Errorf("denom does not exist: %s", distrTo.Denom)
	}

by passing empty queryCondition. lmk if that makes sense

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah I understand ur idea. But the problem I face is even calling CreateGauge with empty queryCondition. It is still assigned a value in the function.
Thinking about adding new value to LockQueryType enum to bypass both ByDuration & ByTime. Lmk what u think about that

Copy link
Contributor

@stackman27 stackman27 Jun 6, 2023

Choose a reason for hiding this comment

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

i see what about changing the enumType to something like pretty much what you suggested;

enum LockQueryType {
  option (gogoproto.goproto_enum_prefix) = false;

  UNSPECIFIED = 0;
  ByTime = 0;
  ByDuration = 1;
}

if this works, hopefully we donot have to make lots of core logic changes and it works with existing queryCondition

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah we r same page 🙌

@@ -55,10 +55,6 @@ func (m MsgCreateGauge) ValidateBasic() error {
return errors.New("distribution period should be 1 epoch for perpetual gauge")
}

if lockuptypes.LockQueryType_name[int32(m.DistributeTo.LockQueryType)] != "ByDuration" {
Copy link
Contributor

Choose a reason for hiding this comment

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

why was this removed as well?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

In CreateGauge for CL pool we don't want to limit just using ByDuration right? Or lmk if im wrong

Copy link
Contributor

@stackman27 stackman27 Jun 7, 2023

Choose a reason for hiding this comment

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

can we add this back and add a clause that if lockTypes are used it has to be "byDuration"?

@@ -220,7 +219,7 @@ func (s *KeeperTestSuite) TestCreateConcentratedLiquidityPoolGauge() {
s.Require().True(gaugeInfo.IsPerpetual)
s.Require().Empty(gaugeInfo.Coins)
s.Require().Equal(s.Ctx.BlockTime(), gaugeInfo.StartTime)
s.Require().Equal(appParams.BaseCoinUnit, gaugeInfo.DistributeTo.Denom)
// s.Require().Equal(appParams.BaseCoinUnit, gaugeInfo.DistributeTo.Denom)
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
// s.Require().Equal(appParams.BaseCoinUnit, gaugeInfo.DistributeTo.Denom)
s.Require().Equal(appParams.BaseCoinUnit, gaugeInfo.DistributeTo.Denom)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

In CreateGauge we pass empty queryCondition so I dont think we should check gaugeInfo.DistributeTo.Denom cause its alway be "" as I think. If im wrong pls fix me

@@ -8,7 +8,6 @@ import (
"github.com/stretchr/testify/suite"

"github.com/osmosis-labs/osmosis/v16/app/apptesting"
appParams "github.com/osmosis-labs/osmosis/v16/app/params"
Copy link
Contributor

Choose a reason for hiding this comment

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

Assuming this was removed accidentally

@hieuvubk
Copy link
Contributor Author

hieuvubk commented Jun 8, 2023

Hey @stackman27 I updated your last request & got new err about cosmwasm, even reverting to the previous commit its still happen. Duno what cause the err.

@stackman27
Copy link
Contributor

hi @hieuvubk thank you so much for all the work you've put into this PR but recently we caught a feature that was lacking with external gauges and decided to work on it in this PR (#5459)

while doing so we also fixed this issue. So i believe we can hold this PR on for now and close it when we merge this PR

@hieuvubk
Copy link
Contributor Author

hieuvubk commented Jun 9, 2023

hi @hieuvubk thank you so much for all the work you've put into this PR but recently we caught a feature that was lacking with external gauges and decided to work on it in this PR (#5459)

while doing so we also fixed this issue. So i believe we can hold this PR on for now and close it when we merge this PR
I got it thank u

@AlpinYukseloglu
Copy link
Contributor

Closing this as the other PR got merged. Thanks for working on this @hieuvubk

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.

[Incentives] Refactor createGauge to accomodate for CL gauges
4 participants