-
Notifications
You must be signed in to change notification settings - Fork 608
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
[CL Simulator] Fix existing simulator and test simulator flow for CollectFees, CollectIncentives #4832
Conversation
85c7c60
to
e09401c
Compare
4a0e23f
to
849c7c7
Compare
@@ -15,6 +15,7 @@ service Msg { | |||
rpc CollectFees(MsgCollectFees) returns (MsgCollectFeesResponse); | |||
rpc CollectIncentives(MsgCollectIncentives) | |||
returns (MsgCollectIncentivesResponse); | |||
rpc CreateIncentive(MsgCreateIncentive) returns (MsgCreateIncentiveResponse); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
note to reviewers: idk why this was missed while creating the msg, so i added it
@@ -113,7 +112,7 @@ func (k Keeper) CreateConcentratedLiquidityPoolGauge(ctx sdk.Context, poolId uin | |||
// lockQueryType as byTime. Although we donot need this check, we still cannot pass empty struct. | |||
lockuptypes.QueryCondition{ | |||
LockQueryType: lockuptypes.ByTime, | |||
Denom: appparams.BaseCoinUnit, | |||
Denom: sdk.DefaultBondDenom, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
note to reviewers: we technically donot care about the denom since, we donot use it while creating CL gauges. so i changed it to "stake" to make simulator testing easier. We cannot leave it empty as it is a require field in CreateGauge
0e09f10
to
940e906
Compare
remainingToken1Amt := tokens[1].Amount | ||
// create positions until the funds run out from positionCreator | ||
for remainingToken0Amt.GT(sdk.ZeroInt()) && remainingToken1Amt.GT(sdk.ZeroInt()) { | ||
//make sure the user always has tokens to create Position |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
//make sure the user always has tokens to create Position | |
// make sure the user always has tokens to create Position |
// positionCreator creates the position with pool denoms | ||
// get random user address with the pool denoms | ||
sender, _, senderExists := sim.SelAddrWithDenoms(ctx, poolDenoms) | ||
if !senderExists { | ||
return nil, fmt.Errorf("no sender with denoms %s exists", poolDenoms) | ||
} | ||
|
||
positions, err := k.GetUserPositions(ctx, sender.Address, 0) | ||
// get a random Position | ||
positions, err := k.GetUserPositions(ctx, sender.Address, clPool.GetId()) | ||
if err != nil { | ||
return nil, fmt.Errorf("position does not exist") | ||
} | ||
|
||
if len(positions) == 0 { | ||
return nil, fmt.Errorf("user does not have any position") | ||
if len(positions) < 1 { | ||
return nil, fmt.Errorf("user doesnot have any positions") | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The flow should be the following:
- Get a random CL pool
- Utilize the PoolId to PositionId mapping. This will allow you to iterate that store and select a random position ID form that list
- Use this position to attempt to withdraw
What you implemented does the following:
- Gets a random address
- Hopes the address has a position
^ this will result in lots of failed attempts to withdraw, while the first option will fail much less
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i see, the poolId -> positionid mapping flow was def very clean!
changed!
933f67f
to
de35d1a
Compare
What was the decision on this? I think I remember something about us holding off on merging until something was figured out. Would like to note whatever the blocker is here so we can track it appropriately. |
As far as I'm tracking, this is good to go as long as the non-deterministic failures are figured out and resolved. If this is still failing from time to time, I think we should get to the bottom of this prior to merge |
@stackman27 can you confirm if we are still having non-determinism in the test? |
@p0mvn @czarcas7ic i was waiting on #4973 to get merge. Will run some final test now and let you guys know |
de35d1a
to
94c0046
Compare
update on this i rebased and reran the tests. Everything seems good, haven't gotten the negative coin bug so far |
94c0046
to
c2a7350
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
great work!
Closes: #4753
What is the purpose of the change
Simulator: Testing flow createPool -> createPositions -> swap Randomly -> CollectFees
Simulator: Testing flow createPool -> createPosition -> collectIncentives
Extra features
Brief Changelog
Testing and Verifying
added sim test
Documentation and Release Note
Unreleased
section inCHANGELOG.md
? (yes / no)x/<module>/spec/
) / Osmosis docs repo / not documented)