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

Speedup protorev by having route calculation phase not unmarshal pools #8157

Merged
merged 4 commits into from
Apr 29, 2024

Conversation

ValarDragon
Copy link
Member

@ValarDragon ValarDragon commented Apr 28, 2024

What is the purpose of the change

This is an expected .7% speedup to block syncing. It works by having protorev not unmarshal every pool in route cost estimation phase. It is state breaking due to gas differences.

Testing and Verifying

This adds a test to ensure that the new GetPoolType method returns a deterministic amount of gas.

Documentation and Release Note

  • Does this pull request introduce a new feature or user-facing behavior changes? - NO
  • Changelog entry added to Unreleased section of CHANGELOG.md? - Yes

Summary by CodeRabbit

  • New Features

    • Enhanced pool information retrieval by introducing a method to retrieve pool types.
  • Bug Fixes

    • Improved pool type comparison logic for accurate pool information processing.
  • Documentation

    • Updated CHANGELOG to reflect efficiency improvements in data handling during cost estimation.
  • Tests

    • Added tests to ensure consistency in gas consumption for new pool type retrieval functionality.

@ValarDragon ValarDragon added V:state/breaking State machine breaking PR A:backport/v25.x backport patches to v25.x branch labels Apr 28, 2024
Copy link
Contributor

coderabbitai bot commented Apr 28, 2024

Walkthrough

The recent updates focus on enhancing the pool management system by introducing a method to fetch pool types directly, optimizing performance and simplifying code. Modifications include adding and updating methods in the Keeper struct, adjusting test suites for gas consumption checks, and refining route calculations by utilizing pool types instead of pool objects. This streamlines interactions and improves efficiency in pool type handling.

Changes

File Path Change Summary
.../create_pool.go, .../expected_keepers.go Added GetPoolType method to Keeper struct and PoolManagerKeeper interface. Updated poolModuleCacheValue and GetPoolModule method to handle pooltype.
.../router_test.go Introduced TestGetPoolTypeGas to test gas usage for GetPoolType method under different cache scenarios.
.../routes.go Replaced pool object with poolType in CalculateRoutePoolPoints, added logic to retrieve pool details based on type.
.../pool.go Refactored code to store pool address before retrieving token balances for readability and potential performance improvement.
.../statistics.go Replaced references to osmomath.OneInt() with oneInt in IncrementNumberOfTrades and IncrementTradesByRoute functions.

🐇✨
In the code's garden, changes bloom,
New methods sprout, clearing gloom.
Swiftly hopping through the lines,
A rabbit's touch, as code refines.
Joy in bytes, in bits we trust,
In pools of data, a leap, a gust. 🌟🍃


Recent Review Details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits Files that changed from the base of the PR and between 9583829 and bc347c7.
Files selected for processing (2)
  • x/concentrated-liquidity/pool.go (1 hunks)
  • x/protorev/keeper/statistics.go (2 hunks)
Additional comments not posted (3)
x/protorev/keeper/statistics.go (2)

42-42: The variable oneInt is used but not defined in this file. Ensure it is properly defined and imported to avoid runtime errors.


192-192: The variable oneInt is used but not defined in this file. Ensure it is properly defined and imported to avoid runtime errors.

x/concentrated-liquidity/pool.go (1)

218-220: The changes to GetTotalPoolLiquidity method are correctly implemented to fetch the pool's liquidity based on the pool address and token balances.


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

Share
Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (invoked as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger a review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

Out of diff range and nitpick comments (8)
CHANGELOG.md (8)

Line range hint 352-352: Consider removing the trailing punctuation in the heading for consistency with other headings.

-## [v1.0.0](https://github.com/osmosis-labs/osmosis/releases/tag/v1.0.0-rc0) - 2021-06-16.
+## [v1.0.0](https://github.com/osmosis-labs/osmosis/releases/tag/v1.0.0-rc0) - 2021-06-16

Line range hint 615-615: Convert the bare URL to a markdown link for better readability and consistency.

-See: [SDK v0.43.0 Release Notes](https://github.com/cosmos/cosmos-sdk/releases/tag/v0.43.0) For more details
+See: [SDK v0.43.0 Release Notes](https://github.com/cosmos/cosmos-sdk/releases/tag/v0.43.0) for more details

Line range hint 673-673: Convert the bare URL to a markdown link for better readability and consistency.

-See: [SDK v0.43.0 Release Notes](https://github.com/cosmos/cosmos-sdk/releases/tag/v0.43.0) For more details
+See: [SDK v0.43.0 Release Notes](https://github.com/cosmos/cosmos-sdk/releases/tag/v0.43.0) for more details

Line range hint 1013-1013: Ensure heading levels increment by one level at a time for better document structure and readability.

-#### Golang API breaks
+### Golang API breaks

Line range hint 1025-1025: Ensure heading levels increment by one level at a time for better document structure and readability.

-#### Bug Fixes
+### Bug Fixes

Line range hint 1034-1034: Ensure heading levels increment by one level at a time for better document structure and readability.

-#### Features
+### Features

Line range hint 1039-1039: Ensure heading levels increment by one level at a time for better document structure and readability.

-#### Minor improvements & Bug Fixes
+### Minor improvements & Bug Fixes

Line range hint 1091-1091: Ensure heading levels increment by one level at a time for better document structure and readability.

-#### SDK fork updates
+### SDK fork updates

Copy link
Member

@mattverse mattverse left a comment

Choose a reason for hiding this comment

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

This LGTM

@ValarDragon ValarDragon merged commit 64a9078 into main Apr 29, 2024
1 check passed
@ValarDragon ValarDragon deleted the dev/speedup_protorev branch April 29, 2024 05:01
mergify bot pushed a commit that referenced this pull request Apr 29, 2024
#8157)

* Another expected ~1% state machine speedup

* Add changelog

* minor other improvement

* Reduce addr decoding overhead

(cherry picked from commit 64a9078)
PaddyMc pushed a commit that referenced this pull request Apr 29, 2024
#8157) (#8164)

* Another expected ~1% state machine speedup

* Add changelog

* minor other improvement

* Reduce addr decoding overhead

(cherry picked from commit 64a9078)

Co-authored-by: Dev Ojha <[email protected]>
@github-actions github-actions bot mentioned this pull request May 1, 2024
czarcas7ic added a commit that referenced this pull request May 2, 2024
* chore: add v25.x backport tag to mergify github action (#8151)

* Try out making a read cache for poolmanager pool modules (#8128)

* Try out making a read cache

* Make this stored in the keeper to fix tests

* Fix test reset caches

* Auto: update go.mod after push to dev/test_out_read_cahce that modified dependencies locally

* Add changelog

---------

Co-authored-by: github-actions <[email protected]>

* chore(deps): bump github.com/hashicorp/go-getter from 1.7.1 to 1.7.4 (#8155)

Bumps [github.com/hashicorp/go-getter](https://github.com/hashicorp/go-getter) from 1.7.1 to 1.7.4.
- [Release notes](https://github.com/hashicorp/go-getter/releases)
- [Changelog](https://github.com/hashicorp/go-getter/blob/main/.goreleaser.yml)
- [Commits](hashicorp/go-getter@v1.7.1...v1.7.4)

---
updated-dependencies:
- dependency-name: github.com/hashicorp/go-getter
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* chore(deps): bump github.com/hashicorp/go-getter in /osmoutils (#8156)

Bumps [github.com/hashicorp/go-getter](https://github.com/hashicorp/go-getter) from 1.7.1 to 1.7.4.
- [Release notes](https://github.com/hashicorp/go-getter/releases)
- [Changelog](https://github.com/hashicorp/go-getter/blob/main/.goreleaser.yml)
- [Commits](hashicorp/go-getter@v1.7.1...v1.7.4)

---
updated-dependencies:
- dependency-name: github.com/hashicorp/go-getter
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* chore(deps): bump github.com/hashicorp/go-getter in /x/ibc-hooks (#8154)

Bumps [github.com/hashicorp/go-getter](https://github.com/hashicorp/go-getter) from 1.7.1 to 1.7.4.
- [Release notes](https://github.com/hashicorp/go-getter/releases)
- [Changelog](https://github.com/hashicorp/go-getter/blob/main/.goreleaser.yml)
- [Commits](hashicorp/go-getter@v1.7.1...v1.7.4)

---
updated-dependencies:
- dependency-name: github.com/hashicorp/go-getter
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* .5s epoch speedup (#8159)

* Speedup protorev by having route calculation phase not unmarshal pools (#8157)

* Another expected ~1% state machine speedup

* Add changelog

* minor other improvement

* Reduce addr decoding overhead

* chore: Create CI for bumping sdk version via GA (#8162)

* Create CI for updating sdk version

* Fix some comments

* On PR

* Use osmo v0.47.5 as default

* Fix

* Fix 2

* Fix 4

* Fix

* Final

* Final fix

* Fix PR ver

* Final

* Final

* Final

* fix: return err if type not in manager (#8170)

* chore(deps): bump actions/checkout from 3 to 4 (#8173)

Bumps [actions/checkout](https://github.com/actions/checkout) from 3 to 4.
- [Release notes](https://github.com/actions/checkout/releases)
- [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md)
- [Commits](actions/checkout@v3...v4)

---
updated-dependencies:
- dependency-name: actions/checkout
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* chore(deps): bump actions/setup-go from 3 to 5 (#8174)

Bumps [actions/setup-go](https://github.com/actions/setup-go) from 3 to 5.
- [Release notes](https://github.com/actions/setup-go/releases)
- [Commits](actions/setup-go@v3...v5)

---
updated-dependencies:
- dependency-name: actions/setup-go
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* auto: update Go import paths to v25 on branch main (#8172)

* auto: update Go import paths to v25

* Generated protofile changes

* chore: update sqsdomain to v25

* chore: update osmoutils to latest version

---------

Co-authored-by: PaddyMc <[email protected]>
Co-authored-by: github-actions <[email protected]>
Co-authored-by: PaddyMc <[email protected]>

* chore: don't use hardcoded "uosmo" string (#8145)

* check denoms for gauge creation

* changelog

* extract logic

* use uosmo var

* initial push of test fixes

* fix lint

* tidy

* tidy

* add comments

* add test cases

* chore: update cometbft and cosmos-sdk deps (#8179)

* chore: update cometbft and cosmos-sdk deps

* chore: update comments for cosmos-sdk

* auto: update asset lists (#8180)

Co-authored-by: czarcas7ic <[email protected]>

* Properly create the module account for auction (#8178)

* properly create the module account for auction

* typo

* lint

* preserve name

* updated osmoutils

* chore: consensus param change (#8177)

* consensus param change

* changelog

* err

* Update upgrades.go

---------

Co-authored-by: PaddyMc <[email protected]>

* fix: e2e and remove toolchain (#8191)

* remove toolchain

* remove exclude increment

* script

* remove build tags

* build script

* remove build arg

* fix: e2e and remove toolchain (#8191)

* remove toolchain

* remove exclude increment

* script

* remove build tags

* build script

* remove build arg

(cherry picked from commit 27548cc)

# Conflicts:
#	osmoutils/go.sum
#	x/ibc-hooks/go.sum

* fix conflict

* tidy

* Revert "tidy"

This reverts commit fabe8ea.

* Revert "fix conflict"

This reverts commit 32031fd.

* Revert "Merge branch 'main' into mergify/bp/v25.x/pr-8191"

This reverts commit 708dbdf, reversing
changes made to 29a0917.

* tidy

* run script

---------

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: PaddyMc <[email protected]>
Co-authored-by: Dev Ojha <[email protected]>
Co-authored-by: github-actions <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Matt, Park <[email protected]>
Co-authored-by: Osmosis <[email protected]>
Co-authored-by: PaddyMc <[email protected]>
Co-authored-by: Adam Tucker <[email protected]>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: czarcas7ic <[email protected]>
Co-authored-by: Nicolas Lara <[email protected]>
Co-authored-by: Adam Tucker <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A:backport/v25.x backport patches to v25.x branch C:x/concentrated-liquidity C:x/poolmanager V:state/breaking State machine breaking PR
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants