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

Don't load all poolmanager params every swap #7074

Merged
merged 1 commit into from
Dec 12, 2023

Conversation

ValarDragon
Copy link
Member

@ValarDragon ValarDragon commented Dec 11, 2023

Looking at the IAVL v2 benchmarks, loading params for taker fees somewhat appears to be a 2% CPU consumption for the entire state machine. (Its a bit hard to reliably tell, since I don't have the binary for better views)

This PR anyways stops loading all of the params, and thereby should improve CPU / native speed, and will improve gas.

Validity of this change should be covered by default taker fee already being tested

Comment on lines +29 to +30
// TODO: This logic is actually wrong imo, where it can be valid to set an override over the default.
if takerFee.Equal(k.GetDefaultTakerFee(ctx)) {
Copy link
Member

Choose a reason for hiding this comment

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

I don't think I understand the comment. It is valid to override over the default. Instead of storing every taker fee for every pair, we assume every pair is default, and if we pull the value for that pair and its non default, its an override.

Copy link
Member Author

Choose a reason for hiding this comment

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

This code comment is on SetDenomPairTakerFee, for when its being set.

Its saying if you override a taker fee to a value that is default, delete the state entry for this, and make it go to default.

However then if the default changes, this one changes as well, whereas you really wanted it to always stay at the old default value.

(This is independent of the main point of this PR)

@ValarDragon ValarDragon merged commit 5cea95c into main Dec 12, 2023
1 check passed
@ValarDragon ValarDragon deleted the dev/reduce_param_reading branch December 12, 2023 16:56
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.

2 participants