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

CL: Initialize tick minor gas optimization & cleanup #5923

Merged
merged 3 commits into from
Jul 31, 2023

Conversation

ValarDragon
Copy link
Member

@ValarDragon ValarDragon commented Jul 30, 2023

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.

@ValarDragon ValarDragon changed the title Minor gas optimization & cleanup CL: Initialize tick minor gas optimization & cleanup Jul 30, 2023
@ValarDragon ValarDragon added the V:state/breaking State machine breaking PR label Jul 30, 2023
@@ -40,7 +40,7 @@ type positionAndLiquidity struct {
}

func TestFuzz_Many(t *testing.T) {
fuzz(t, defaultNumSwaps, defaultNumPositions, 100)
fuzz(t, defaultNumSwaps, defaultNumPositions, 10)
Copy link
Member Author

@ValarDragon ValarDragon Jul 30, 2023

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!)

Comment on lines +135 to +138
pool, err := k.getPoolById(ctx, poolId)
if err != nil {
return tickStruct, err
}
Copy link
Member Author

@ValarDragon ValarDragon Jul 30, 2023

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

Copy link
Contributor

@AlpinYukseloglu AlpinYukseloglu left a comment

Choose a reason for hiding this comment

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

LGTM, nice work!

@ValarDragon ValarDragon merged commit f8b75a1 into main Jul 31, 2023
@ValarDragon ValarDragon deleted the dev/remove_repeated_get_pools branch July 31, 2023 18:32
@github-actions github-actions bot mentioned this pull request Apr 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants