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

update rr logic to exclude queued unbondings; fixes #1760 #1765

Merged
merged 2 commits into from
Dec 2, 2024

Conversation

joe-bowman
Copy link
Contributor

@joe-bowman joe-bowman commented Dec 2, 2024

1. Summary

Fixes #1760

Update redemption rate logic to exclude unbondings in queued state from escrow amount that is subtracted from supply.

2.Type of change

  • Bug fix (non-breaking change which fixes an issue)

Summary by CodeRabbit

  • New Features

    • Enhanced withdrawal record handling for improved redemption rate calculations.
    • Introduced new functionality to iterate through withdrawal records with a status of Queued.
  • Bug Fixes

    • Improved accuracy of ratio calculations by including queued assets.
  • Tests

    • Added comprehensive test cases for withdrawal and delegation scenarios to ensure correct behavior of the system under various conditions.

Copy link
Contributor

coderabbitai bot commented Dec 2, 2024

Walkthrough

The changes in this pull request primarily focus on enhancing the Keeper struct and its methods within the x/interchainstaking/keeper/keeper.go file. Key modifications include the addition of logic in the GetRatio method to account for withdrawal records with a status of Queued, improving the accuracy of redemption rate calculations. New logging statements have been introduced for better operational insights. Additionally, the test suite in keeper_test.go has been expanded with new test cases to ensure robust validation of the updated functionality, particularly concerning queued withdrawals and their impact on staking logic.

Changes

File Change Summary
x/interchainstaking/keeper/keeper.go - Updated GetRatio method to include logic for handling Queued withdrawal records.
- Introduced IterateZoneStatusWithdrawalRecords method for iterating through withdrawal records.
x/interchainstaking/keeper/keeper_test.go - Added new test cases to TestGetRatio for scenarios with queued withdrawals and delegations.
- Expanded TestGetQueuedTokensAndCount for comprehensive testing of queued withdrawals.

Assessment against linked issues

Objective Addressed Explanation
New redemption rate logic should not consider QUEUED unbondings (#1760) The updated logic still includes queued unbondings in calculations.

Possibly related PRs

  • v1.7.4 upgrade #1758: The changes in the V010704UpgradeHandler include logic for managing withdrawal records and updating zone redemption rates, which directly relates to the modifications made in the GetRatio method of the Keeper struct in the main PR.

Suggested reviewers

  • faddat

Poem

In the fields where tokens play,
Queued unbondings led astray.
With new logic, we refine,
To ensure our rates align.
Hopping through tests, we celebrate,
A brighter path for all our fate! 🐇✨


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 1bd45ff and deceb1c.

📒 Files selected for processing (2)
  • x/interchainstaking/keeper/keeper.go (1 hunks)
  • x/interchainstaking/keeper/keeper_test.go (2 hunks)
🔇 Additional comments (3)
x/interchainstaking/keeper/keeper.go (1)

736-739: Logic update correctly excludes queued unbondings from escrow amount

The addition of queued withdrawal amounts to qAssetAmount in the GetRatio method effectively modifies the redemption rate calculation, ensuring that unbondings with status Queued are excluded from the escrow amount deducted from the total supply. This change aligns with the objectives outlined in issue #1760.

x/interchainstaking/keeper/keeper_test.go (2)

463-483: New test case accurately validates logic with queued withdrawals

The added test case "multi unbonding withdrawal, inc queued, delegation, expect 1.0" in the TestGetRatio function effectively tests the scenario where both unbonding and queued withdrawals are present alongside delegations. This ensures that the redemption rate calculation handles queued withdrawals correctly, as per the updated logic.


523-543: Additional test enhances coverage for redemption rates greater than 1.0

The test case "multi unbonding withdrawal inc. withdrawal, delegation, gt 1.0" extends the test coverage to scenarios where the redemption rate exceeds 1.0 due to the presence of queued withdrawals and unbondings. This comprehensive test strengthens the validation of the system's behavior under various conditions.


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>, please review it.
    • 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 gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @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.
    • @coderabbitai help me debug CodeRabbit configuration file.

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 using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration 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

codecov bot commented Dec 2, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 61.41%. Comparing base (1bd45ff) to head (deceb1c).
Report is 2 commits behind head on main.

Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff           @@
##             main    #1765   +/-   ##
=======================================
  Coverage   61.40%   61.41%           
=======================================
  Files         196      196           
  Lines       17075    17077    +2     
=======================================
+ Hits        10485    10487    +2     
  Misses       5742     5742           
  Partials      848      848           
Flag Coverage Δ
unittests 61.41% <100.00%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
x/interchainstaking/keeper/keeper.go 72.00% <100.00%> (+0.08%) ⬆️

Copy link
Contributor

@ajansari95 ajansari95 left a comment

Choose a reason for hiding this comment

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

LGTM

@joe-bowman joe-bowman merged commit fe73f54 into main Dec 2, 2024
21 checks passed
@joe-bowman joe-bowman deleted the bug/1760-dont-include-queued-in-rr branch December 2, 2024 18:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

New redemption rate logic should not consider QUEUED unbondings
2 participants