-
Notifications
You must be signed in to change notification settings - Fork 607
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: Initialize tick minor gas optimization & cleanup #5923
Conversation
@@ -40,7 +40,7 @@ type positionAndLiquidity struct { | |||
} | |||
|
|||
func TestFuzz_Many(t *testing.T) { | |||
fuzz(t, defaultNumSwaps, defaultNumPositions, 100) | |||
fuzz(t, defaultNumSwaps, defaultNumPositions, 10) |
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.
Driveby change, now that were through CL, running 100 iterations on every save & CI run no longer make sense. (It also makes test on save expensive!)
pool, err := k.getPoolById(ctx, poolId) | ||
if err != nil { | ||
return tickStruct, err | ||
} |
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.
This is the core change, along with using pool as the arg for the next 3 functions
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.
LGTM, nice work!
This PR is simplifying the
GetTickInfo
code, by moving the initialization logic to its own function. Furthermore, we only get the pool once, removing repeated gets in every function this would otherwise call. (Saving a net of 2 GetPool operations). This has an added benefit of removing messiness from the test code, where it attempted to generate test cases with invalid pool ID's.The remainder of this PR is cleaning up tests.
The "TestGetInitialSpreadRewardGrowthOppositeDirectionOfLastTraversalForTick" was extremely messy, so just re-wrote the edge case that idt even makes sense to test into its own function, and made the main test use standard helpers.