-
Notifications
You must be signed in to change notification settings - Fork 634
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 CL pool hooks, by only JSON marshalling if there is ahook #7685
Conversation
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
msgBz, err := json.Marshal(types.BeforeCreatePositionSudoMsg{BeforeCreatePosition: msg}) | ||
if err != nil { | ||
return err | ||
msgBuilderFn := func(poolId uint64) ([]byte, error) { |
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.
I'm surprised that this was getting called every time! Good catch :)
WalkthroughThe recent updates focus on enhancing performance and efficiency within the concentrated liquidity module. By introducing a Changes
Assessment against linked issues
Poem
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? TipsChatThere are 3 ways to chat with CodeRabbit:
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)
Additionally, you can add CodeRabbit Configration File (
|
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.
Review Status
Actionable comments generated: 1
Configuration used: CodeRabbit UI
Files selected for processing (4)
- CHANGELOG.md (1 hunks)
- x/concentrated-liquidity/export_test.go (1 hunks)
- x/concentrated-liquidity/pool_hooks.go (3 hunks)
- x/concentrated-liquidity/pool_hooks_test.go (1 hunks)
Additional comments: 6
x/concentrated-liquidity/pool_hooks.go (3)
- 16-17: The introduction of
msgBuilderFn
type is a significant improvement in terms of performance optimization. By deferring the message construction and marshalling to only when necessary, it reduces unnecessary computational overhead. This change aligns well with the PR's objective to optimize the handling of Concentrated Liquidity pool hooks.- 20-24: The implementation of
msgBuilderFn
withinBeforeCreatePosition
is correctly done. It ensures that message marshalling only occurs if a CL pool hook is set for the action. This approach is consistent across all modified functions in this file, which is good for maintainability and readability.- 106-116: > 📝 NOTE
This review was outside the diff hunks and was mapped to the diff hunk with the greatest overlap. Original lines [97-113]
The
callPoolActionListener
function has been refactored to accept amsgBuilderFn
and construct the message only if a contract address is found for the given pool ID and action prefix. This is a crucial part of the optimization, ensuring that unnecessary message construction and marshalling are avoided. The error handling and gas metering logic within this function appear to be correctly implemented.x/concentrated-liquidity/pool_hooks_test.go (1)
- 170-174: The test implementation for
msgBuilderFn
withinTestCallPoolActionListener
correctly simulates the marshalling process for a test message. This ensures that thecallPoolActionListener
function's new behavior is adequately tested. It's good to see that the test suite has been updated to reflect the changes in the main implementation.x/concentrated-liquidity/export_test.go (1)
- 339-340: The modification of the
CallPoolActionListener
function in the test export file to accept amsgBuilderFn
is consistent with the changes made in the main implementation file. This ensures that the test environment can accurately reflect and test the behavior of the main codebase. It's crucial for maintaining the integrity of the test suite.CHANGELOG.md (1)
- 62-62: The optimization for CL actions by only marshalling for CL hooks if they will be used, as mentioned in pull request Speedup CL pool hooks, by only JSON marshalling if there is ahook #7685, is a significant performance improvement. It's crucial to ensure that all dependent functionalities and tests are updated to accommodate this change, considering its impact on the system's efficiency.
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.
Review Status
Actionable comments generated: 0
Configuration used: CodeRabbit UI
Files selected for processing (1)
- CHANGELOG.md (1 hunks)
Files skipped from review as they are similar to previous changes (1)
- CHANGELOG.md
Closes: #7680
What is the purpose of the change
See linked issue! TL;DR saves JSON marshalling times when its not needed.
Testing and Verifying
This change is already covered by existing tests.
Documentation and Release Note
Unreleased
section ofCHANGELOG.md
? - YesSummary by CodeRabbit
msgBuilderFn
for improved efficiency and maintainability.