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

perf(protorev): base denom as param #7508

Merged
merged 22 commits into from
Feb 21, 2024
Merged

Conversation

czarcas7ic
Copy link
Member

@czarcas7ic czarcas7ic commented Feb 16, 2024

Closes: #7495

What is the purpose of the change

Protorev currently requires iterators when retrieving baseDenoms, which is uncached and requires multiple IAVL reads.

This PR implements baseDenoms as a single state entry. This keeps the value in-memory, reducing overhead on sync speed.

Testing and Verifying

Old tests pass with the same values as when the KVStore iterator was used.

Upgrade handler test added and passes.

Full E2E testing should be done on state exported testnet closer to upgrade time.

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

@czarcas7ic czarcas7ic changed the title base denom protorev param performance change perf: base denom protorev param Feb 16, 2024
@github-actions github-actions bot added the C:app-wiring Changes to the app folder label Feb 16, 2024
@czarcas7ic czarcas7ic added the V:state/breaking State machine breaking PR label Feb 16, 2024
@czarcas7ic czarcas7ic changed the title perf: base denom protorev param perf(protorev): base denom as param Feb 16, 2024
@czarcas7ic czarcas7ic marked this pull request as ready for review February 16, 2024 23:25
Copy link
Member

@p0mvn p0mvn left a comment

Choose a reason for hiding this comment

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

LGTM

@ValarDragon
Copy link
Member

Wait this wasn't a param before right? How would base denoms get set? I think if we had old logic not going through the param store, we should prefer that

@ValarDragon
Copy link
Member

On first pass, this LGTM except the move to using params. Lets stay using a direct state entry as before, just lets write repeated BaseDenom.

Param usage is always slower than native, and deprecated anyways.

Comment on lines 28 to 30
// DEPRECATED: The pool weights that are being used to calculate the weight
// (compute cost) of each route. This field is deprecated and will be removed
// in the next release. It is replaced by the `info_by_pool_type` field.
Copy link
Member Author

Choose a reason for hiding this comment

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

Drive by change, Skip team agreed this should be marked as deprecated.

Copy link
Member

@ValarDragon ValarDragon Feb 18, 2024

Choose a reason for hiding this comment

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

LGTM, though I'm confused why we don't just mark this as reserved? Whats the point of deprecating?

Copy link
Member Author

@czarcas7ic czarcas7ic Feb 20, 2024

Choose a reason for hiding this comment

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

No you are right we can reserve, I can make the change now

Copy link
Member Author

Choose a reason for hiding this comment

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

Reserved here a838fc1

Comment on lines -152 to -153
// Delete the old base denoms
m.k.DeleteBaseDenoms(ctx)
Copy link
Member Author

Choose a reason for hiding this comment

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

We no longer need to delete the base denoms since we overwrite the single BaseDenoms value.

Comment on lines +101 to +103

// KeyPrefixBaseDenoms is the prefix that is used to store the base denoms that are used to create cyclic arbitrage routes
KeyPrefixBaseDenoms = []byte{prefixBaseDenoms}
Copy link
Member Author

Choose a reason for hiding this comment

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

I could have probably just used the same old key, but imo after dealing with some of the tests (specifically the upgrade tests) it seemed prudent to just create a new key.

Copy link
Member

Choose a reason for hiding this comment

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

SGTM

@czarcas7ic
Copy link
Member Author

This PR is R4R again, Devs requested changes have been made

@czarcas7ic czarcas7ic closed this Feb 18, 2024
@czarcas7ic czarcas7ic reopened this Feb 18, 2024
@czarcas7ic czarcas7ic added V:state/breaking State machine breaking PR and removed V:state/breaking State machine breaking PR labels Feb 18, 2024
Copy link
Member

@ValarDragon ValarDragon 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 job

@czarcas7ic czarcas7ic merged commit dc9b3b4 into main Feb 21, 2024
1 check passed
@czarcas7ic czarcas7ic deleted the adam/base-denom-param-perf branch February 21, 2024 05:08
@github-actions github-actions bot mentioned this pull request May 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C:app-wiring Changes to the app folder C:x/txfees V:state/breaking State machine breaking PR
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Performance]: Speedup Protorev.GetAllBaseDenoms
3 participants