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: reduce supported uptimes #7651

Merged
merged 11 commits into from
Mar 14, 2024
Merged

perf: reduce supported uptimes #7651

merged 11 commits into from
Mar 14, 2024

Conversation

czarcas7ic
Copy link
Member

@czarcas7ic czarcas7ic commented Mar 2, 2024

Closes: #7537

What is the purpose of the change

When calling updateAccumulatorsToNow, we update all 6 accumulators, despite not using the 1W and 2W accumulators. We should remove these for now, and if we decide we need these later we can implement them at that time (and maybe just enable at the per pool level, so we don't need to go through this unnecessary overhead).

Summary by CodeRabbit

  • Refactor
    • Simplified and optimized uptime calculation logic for better performance.
  • New Features
    • Introduced a new query for all before send hooks, enhancing the app's functionality.
  • Bug Fixes
    • Removed duplicate logic and entries to ensure data consistency.
  • Tests
    • Adjusted test scenarios to reflect changes in uptime calculations and incentive distribution, ensuring accurate testing environments.
  • Documentation
    • Updated test case descriptions to reflect changes in time durations and incentive calculations.

@czarcas7ic czarcas7ic marked this pull request as draft March 2, 2024 23:04
@czarcas7ic czarcas7ic closed this Mar 3, 2024
@czarcas7ic czarcas7ic reopened this Mar 3, 2024
@czarcas7ic czarcas7ic marked this pull request as ready for review March 3, 2024 00:54
@mattverse mattverse self-assigned this Mar 5, 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.

Reviewed everything except incentives test! Lgtm thus far.

We're sure e2e is making cl positions lre upgrade and swapping in that pool pre + post upgrade right? And claiming?

Just want to make sure there's no edge case around this possible

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.

LGTM

Copy link
Contributor

coderabbitai bot commented Mar 12, 2024

Walkthrough

The recent updates focus on optimizing performance by removing less utilized features and refining test scenarios. Notably, the changes eliminate one-week and two-week uptime accumulators, adjust time calculations in tests for incentives and uptime, and streamline data in genesis tests. These modifications aim to enhance efficiency and reduce unnecessary computational overhead.

Changes

Files Change Summary
CHANGELOG.md, x/concentrated-liquidity/types/constants.go Removed 1W and 2W uptime accumulators; added query for before send hooks; modified SupportedUptimes array.
x/concentrated-liquidity/genesis_test.go, x/concentrated-liquidity/incentives_test.go, x/concentrated-liquidity/keeper_test.go, x/concentrated-liquidity/msg_server_test.go, x/incentives/keeper/distribute_test.go Adjusted time durations in test scenarios; streamlined test records and removed duplicates; reordered durations.

Assessment against linked issues

Objective Addressed Explanation
Delete One Week and Two Week uptime accumulators (#7537)

Poem

"In the realm of code, where time is gold,
A rabbit hopped, bold and bold.
🐇💨 It saw the weeks, too long, too vast,
And with a hop, made them past.

'One day, one hour, let's make it tight,'
The rabbit said, in the moonlight.
Now the code runs swift and free,
A hop, a skip, in glee, we see."

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-tests 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 tests 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 tests.
    • @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.
  • The JSON schema for the configuration file is available here.
  • 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/coderabbit-overrides.v2.json

CodeRabbit Discord Community

Join our Discord Community to get help, request features, and share feedback.

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.

Review Status

Actionable comments generated: 4

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between 6a97c26 and a2c9235.
Files selected for processing (7)
  • CHANGELOG.md (1 hunks)
  • x/concentrated-liquidity/genesis_test.go (6 hunks)
  • x/concentrated-liquidity/incentives_test.go (10 hunks)
  • x/concentrated-liquidity/keeper_test.go (1 hunks)
  • x/concentrated-liquidity/msg_server_test.go (4 hunks)
  • x/concentrated-liquidity/types/constants.go (1 hunks)
  • x/incentives/keeper/distribute_test.go (1 hunks)
Additional comments: 7
x/concentrated-liquidity/types/constants.go (1)
  • 46-47: The modification to the SupportedUptimes array, removing 1 Week and 2 Week durations, aligns with the PR's objective to enhance performance by eliminating underutilized accumulators. Ensure that other parts of the system that may have relied on these accumulators are also updated or verified to not be negatively impacted by this change.
x/concentrated-liquidity/msg_server_test.go (1)
  • 414-420: > 📝 NOTE

This review was outside the diff hunks and was mapped to the diff hunk with the greatest overlap. Original lines [341-429]

Adjusting time calculations from two weeks to one day in test scenarios aligns with the removal of 1 Week and 2 Week accumulators. This ensures that the tests remain relevant to the updated system configuration. Consider reviewing the overall test coverage to ensure it remains comprehensive and covers a wide range of scenarios for robust system validation.

Verification successful

The verification process has confirmed that the concentrated liquidity module has comprehensive test coverage, including various scenarios related to position management, swaps, and incentives. This ensures that the adjustments to time calculations in test scenarios are well-supported by a robust set of tests, maintaining the integrity and relevance of the module's test suite.

Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Search for test cases to ensure comprehensive coverage.
rg 'func \(s \*KeeperTestSuite\) Test' --type go

Length of output: 54056

x/concentrated-liquidity/keeper_test.go (2)
  • 74-74: The change in the ThreeUnorderedNonConsecutiveAuthorizedUptimes slice, from a week duration to a day, aligns well with the PR's objective to remove longer-duration accumulators. This should help in reducing unnecessary overhead as intended.
  • 71-77: > 📝 NOTE

This review was outside the diff hunks, and no overlapping diff hunk was found. Original lines [5-5]

The use of math/rand is noted for generating randomness in tests. While this is standard practice in test environments to ensure predictability and reproducibility, it's important to use crypto/rand instead for any security-sensitive operations requiring cryptographically secure randomness.

x/concentrated-liquidity/genesis_test.go (1)
  • 87-87: The reduction in the number of testUptimeAccumRecord entries from five to four aligns with the PR's objective to remove the 1W and 2W uptime accumulators. This change is consistent with the removal of these accumulators and correctly reflects the updated system configuration in the test setup.
CHANGELOG.md (1)
  • 62-62: The entry for removing 1W and 2W supported uptimes for performance improvement is correctly documented. This aligns with the PR objectives and contributes to the system's optimization by eliminating underutilized functionalities.
x/incentives/keeper/distribute_test.go (1)
  • 559-565: The test cases "non-perpetual, 1 coin, paid over 1 epoch, authorized 1h uptime" and "non-perpetual, 2 coins, paid over 3 epochs, authorized 1d uptime" are designed to verify the behavior of distributing incentives with authorized uptimes. However, it's crucial to ensure that the authorized uptimes are correctly set up in the system's parameters and that the gauge's distribute-to conditions match these authorized uptimes. This verification is essential to confirm that the system behaves as expected when distributing incentives based on authorized uptimes.

Additionally, the test cases "non-perpetual, 1 coin, paid over 1 epoch, unauthorized 1h uptime" and "non-perpetual, 2 coins, paid over 3 epochs, unauthorized 1d uptime" aim to test the behavior when the uptimes are not authorized. It's important to verify that the system correctly falls back to the default uptime in these scenarios and that the incentives are distributed accordingly.

Ensure that the system's parameters for authorized uptimes are correctly set up and that the gauge's distribute-to conditions accurately reflect these settings. This verification will help confirm that the system behaves as expected under both authorized and unauthorized uptime scenarios.

CHANGELOG.md Outdated Show resolved Hide resolved
x/concentrated-liquidity/incentives_test.go Show resolved Hide resolved
x/concentrated-liquidity/incentives_test.go Show resolved Hide resolved
x/concentrated-liquidity/incentives_test.go Show resolved Hide resolved
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.

Review Status

Actionable comments generated: 0

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between a2c9235 and d03c388.
Files selected for processing (1)
  • CHANGELOG.md (1 hunks)
Files skipped from review as they are similar to previous changes (1)
  • CHANGELOG.md

@czarcas7ic czarcas7ic merged commit f4c546c into main Mar 14, 2024
1 check passed
@czarcas7ic czarcas7ic deleted the adam/reduce-supported-uptimes branch March 14, 2024 04:26
czarcas7ic added a commit that referenced this pull request Mar 18, 2024
ValarDragon pushed a commit that referenced this pull request Mar 19, 2024
PaddyMc added a commit that referenced this pull request Mar 19, 2024
This reverts commit f4c546c.

Co-authored-by: Adam Tucker <adamleetucker@outlook.com>
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.

[Feature]: Delete One Week and Two Week uptime accumulators
4 participants