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

Revert "perf: reduce supported uptimes (#7651)" #7766

Merged
merged 1 commit into from
Mar 19, 2024

Conversation

czarcas7ic
Copy link
Member

@czarcas7ic czarcas7ic commented Mar 18, 2024

This reverts commit f4c546c.

Closes: #XXX

What is the purpose of the change

Decided to revert and come back to another time, we have external incentives using the 2w duration ATM.

Summary by CodeRabbit

  • Refactor
    • Enhanced code efficiency by removing duplicate logic.
  • New Features
    • Increased support for more uptime durations in concentrated liquidity calculations.
    • Expanded the range of supported uptimes to include 1 week and 2 weeks.
  • Tests
    • Updated test scenarios to reflect new uptime duration units and expanded uptime support.
    • Adjusted incentive and reward calculation tests to use new time durations.

@czarcas7ic czarcas7ic added V:state/breaking State machine breaking PR A:backport/v24.x backport patches to v24.x branch labels Mar 18, 2024
Copy link
Contributor

coderabbitai bot commented Mar 18, 2024

Walkthrough

The recent updates focus on enhancing efficiency and extending functionality within the concentrated liquidity and incentives modules. Key improvements include the removal of redundant code, expansion of supported uptimes, and adjustments in time units for better accuracy in incentive calculations. These changes aim to refine the system's performance and adaptability to different time-based scenarios, ensuring more precise and efficient operations.

Changes

Files Change Summary
CHANGELOG.md Removed redundant code logic in PR #7622.
x/.../genesis_test.go Increased supported uptimes and added accumRecord entries in tests.
x/.../incentives_test.go, .../msg_server_test.go, .../keeper/distribute_test.go Updated time units from hours to days and introduced weeks for uptime and incentive calculations.
x/.../keeper_test.go, x/.../types/constants.go Included additional durations like 1 week and 2 weeks in supported uptimes and test scenarios.

"In the realm of code, where logic does thrive,
🐰 A rabbit hopped in, making changes come alive.
From hours to days, and weeks now in sight,
Efficiency blooms, under the moonlight.
With every hop, a bug takes flight,
Leaving behind, a codebase so bright."

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 be76d37 and 7076078.
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: 9
x/concentrated-liquidity/types/constants.go (1)
  • 46-47: The change to expand the SupportedUptimes array to include durations like 1 week and 2 weeks aligns with the PR's objective to revert a previous commit. This increases the system's flexibility but consider adding a comment or documentation to explain the rationale behind these specific uptimes, especially if there are performance implications.
x/concentrated-liquidity/msg_server_test.go (3)
  • 341-341: Changing the duration from one day to two weeks in the TestCollectIncentives_Events test case aligns with the PR's objective to revert previous changes and expand supported uptimes. This adjustment is crucial for accurately testing the system's behavior with the reintroduced longer uptimes.
  • 417-417: Adjusting the block time manipulation from one hour to one day in the TestCollectIncentives_Events test case is appropriate for testing incentive claiming scenarios with the reintroduced longer uptimes. This change ensures that the tests accurately reflect the system's behavior with the expanded range of supported uptimes.
  • 429-429: The calculation of incentives to be sent to the community pool based on a two-week duration in the TestCollectIncentives_Events test case is consistent with the PR's objective to revert previous changes and test the system's behavior with longer supported uptimes. This adjustment is necessary for accurately simulating incentive distribution over the expanded range of uptimes.
x/concentrated-liquidity/keeper_test.go (1)
  • 74-74: The change to ThreeUnorderedNonConsecutiveAuthorizedUptimes from time.Hour * 24 to time.Hour * 24 * 7 correctly aligns with the PR's objective to reintroduce longer uptime durations. Ensure to verify the impact of this change on related tests and system behavior to confirm it integrates smoothly without unintended side effects.
x/concentrated-liquidity/genesis_test.go (1)
  • 87-94: The addition of extra accumRecord entries to testUptimeAccumRecord reflects the increase in supported uptimes from 4 to 5. This change aligns with the PR's objective to revert a previous performance enhancement by reintroducing longer uptime durations. Ensure that the added uptime durations are correctly represented in all relevant test cases and that the logic for handling these uptimes is properly tested.
CHANGELOG.md (1)
  • 62-62: The removal of the duplicate CL accumulator update logic is mentioned. Ensure that this change aligns with the project's current requirements and does not affect any dependent functionalities.
x/incentives/keeper/distribute_test.go (2)
  • 627-628: The test cases "non-perpetual, 1 coin, paid over 1 epoch, authorized 1d uptime" and "non-perpetual, 2 coins, paid over 3 epochs, authorized 7d uptime" are designed to verify the behavior of distributing incentives for gauges with authorized uptimes. It's crucial to ensure that the authorized uptimes are correctly recognized and applied during the distribution process. This validation is essential for maintaining the integrity of the incentives distribution based on the configured uptimes.
  • 632-633: The test cases "non-perpetual, 1 coin, paid over 1 epoch, unauthorized 1d uptime" and "non-perpetual, 2 coins, paid over 3 epochs, unauthorized 7d uptime" aim to verify the fallback mechanism to the default uptime when the specified uptime is not authorized. This behavior is critical to ensure that the system gracefully handles unauthorized uptimes by reverting to a predefined default, thereby preserving the consistency and predictability of the incentives distribution process.

Comment on lines +241 to +242
accumRecordWithDefinedValues(accumRecord, osmomath.NewDec(1), osmomath.NewInt(100), osmomath.NewInt(50)),
accumRecordWithDefinedValues(accumRecord, osmomath.NewDec(1), osmomath.NewInt(100), osmomath.NewInt(50)),
Copy link
Contributor

Choose a reason for hiding this comment

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

The addition of two identical accumRecordWithDefinedValues calls with the same parameters in the TestInitGenesis test case seems redundant. Given the context of increasing supported uptimes, it's likely that only one additional record was intended to be added. Please verify if this duplication is intentional or if one of these lines should be removed or modified to reflect a different test scenario.

Comment on lines +303 to +304
accumRecordWithDefinedValues(accumRecord, osmomath.NewDec(1), osmomath.NewInt(100), osmomath.NewInt(50)),
accumRecordWithDefinedValues(accumRecord, osmomath.NewDec(1), osmomath.NewInt(100), osmomath.NewInt(50)),
Copy link
Contributor

Choose a reason for hiding this comment

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

Similar to the previous comment, the addition of two identical accumRecordWithDefinedValues calls in the TestInitGenesis test case appears to be redundant. This duplication might be an oversight. Please confirm the intention behind these additions and consider removing or altering one of them if they were not meant to be identical.

Comment on lines +390 to +391
accumRecordWithDefinedValues(accumRecord, osmomath.NewDec(9), osmomath.NewInt(50), osmomath.NewInt(25)),
accumRecordWithDefinedValues(accumRecord, osmomath.NewDec(9), osmomath.NewInt(50), osmomath.NewInt(25)),
Copy link
Contributor

Choose a reason for hiding this comment

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

In the TestInitGenesis test case, the addition of two identical accumRecordWithDefinedValues calls for the second pool scenario also seems redundant. This pattern of duplication is consistent with previous observations. Please review these additions to ensure they accurately represent the intended test scenarios and adjust as necessary.

Comment on lines +753 to +754
accumRecordWithDefinedValues(accumRecord, osmomath.NewDec(9), osmomath.NewInt(50), osmomath.NewInt(25)),
accumRecordWithDefinedValues(accumRecord, osmomath.NewDec(9), osmomath.NewInt(50), osmomath.NewInt(25)),
Copy link
Contributor

Choose a reason for hiding this comment

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

The duplication of accumRecordWithDefinedValues calls in the TestExportGenesis test case for the second pool scenario mirrors the issues identified in the TestInitGenesis test case. This repetition may not be intentional and could potentially obscure the test's purpose. Please review and correct if necessary.

@ValarDragon ValarDragon merged commit d7a4cb4 into main Mar 19, 2024
1 check passed
@ValarDragon ValarDragon deleted the adam/revert-removal-supported-uptimes branch March 19, 2024 09:26
@PaddyMc PaddyMc restored the adam/revert-removal-supported-uptimes branch March 19, 2024 10:18
@PaddyMc PaddyMc deleted the adam/revert-removal-supported-uptimes branch March 19, 2024 10:34
@czarcas7ic czarcas7ic added A:backport/v24.x backport patches to v24.x branch and removed A:backport/v24.x backport patches to v24.x branch labels Mar 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A:backport/v24.x backport patches to v24.x branch C:x/concentrated-liquidity C:x/incentives V:state/breaking State machine breaking PR
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants