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

use correct supply when determining proportions #1389

Merged
merged 5 commits into from
Apr 8, 2024
Merged

Conversation

joe-bowman
Copy link
Contributor

@joe-bowman joe-bowman commented Apr 4, 2024

1. Summary

Fixes #1388

2.Type of change

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

3. Implementation details

Use supply of zone.LocalDenom and not zone.BaseDenom to determine how to distribute rewards.

Summary by CodeRabbit

  • Refactor
    • Modified the supply retrieval process in interchain staking to enhance accuracy and efficiency.

Copy link

vercel bot commented Apr 4, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
quicksilver ✅ Ready (Inspect) Visit Preview 💬 Add feedback Apr 8, 2024 4:19pm

Copy link
Contributor

coderabbitai bot commented Apr 4, 2024

Walkthrough

This update involves a crucial fix in the HandleMsgTransfer function within the ibc_packet_handlers.go file, specifically in the way the DistributeToClaimants function retrieves supply information. The modification transitions from using zone.BaseDenom to zone.LocalDenom when interacting with BankKeeper, addressing a critical divide by zero error encountered during IBC transfer packet delivery.

Changes

File Change Summary
x/interchainstaking/keeper/ibc_packet_handlers.go Modified DistributeToClaimants to use zone.LocalDenom for supply retrieval from BankKeeper.

Assessment against linked issues

Objective Addressed Explanation
#1388: Fix divide by zero error during IBC transfer packet delivery

A Bunny's Ode to Code

In the realm of chains that intertwine,
A bug did lurk, unseen, malign.
'Twas a rabbit, swift and keen,
Who found the glitch, wiped the slate clean.
With a hop and a skip, the code did align,
🌟 "No more errors, all is fine!"
Cheers to the devs, with minds so divine.

🐇🎉

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: 4

Review Status

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between cacb972 and 8833564.
Files selected for processing (1)
  • x/interchainstaking/keeper/ibc_packet_handlers.go (1 hunks)

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

Review Status

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between 8833564 and d1da428.
Files selected for processing (1)
  • x/interchainstaking/keeper/ibc_packet_handlers_test.go (5 hunks)

Copy link

codecov bot commented Apr 5, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 63.60%. Comparing base (1683da8) to head (6eaac54).
Report is 1 commits behind head on main.

Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff           @@
##             main    #1389   +/-   ##
=======================================
  Coverage   63.60%   63.60%           
=======================================
  Files         171      171           
  Lines       11652    11652           
=======================================
  Hits         7411     7411           
  Misses       3497     3497           
  Partials      744      744           
Flag Coverage Δ
unittests 63.60% <100.00%> (ø)

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

Files Coverage Δ
x/interchainstaking/keeper/ibc_packet_handlers.go 65.25% <100.00%> (ø)

Copy link
Contributor

@tuantran1702 tuantran1702 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
Copy link
Contributor Author

This pull request has been deployed to Vercel.

Latest commit: 6eaac54
✅ Preview: https://pr-1389.app-dev.quicksilver.zone
🔍 Inspect: https://vercel.com/quicksilver/quicksilver/7kn33QzC47ohCZobSUyAQEMZhhAu

View Workflow Logs

@joe-bowman joe-bowman merged commit 0e8a129 into main Apr 8, 2024
26 checks passed
@joe-bowman joe-bowman deleted the fix-supply-calc branch April 8, 2024 16:30
@faddat faddat mentioned this pull request Apr 11, 2024
5 tasks
faddat added a commit that referenced this pull request Apr 11, 2024
* fix undefined window error (#1396)

* chore(deps): bump github.com/cosmos/ibc-go/v5 from 5.3.2 to 5.4.0 (#1398)

Bumps [github.com/cosmos/ibc-go/v5](https://github.com/cosmos/ibc-go) from 5.3.2 to 5.4.0.
- [Release notes](https://github.com/cosmos/ibc-go/releases)
- [Changelog](https://github.com/cosmos/ibc-go/blob/v5.4.0/CHANGELOG.md)
- [Commits](cosmos/ibc-go@v5.3.2...v5.4.0)

---
updated-dependencies:
- dependency-name: github.com/cosmos/ibc-go/v5
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

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

* chore(deps): bump golang.org/x/tools from 0.19.0 to 0.20.0 (#1392)

Bumps [golang.org/x/tools](https://github.com/golang/tools) from 0.19.0 to 0.20.0.
- [Release notes](https://github.com/golang/tools/releases)
- [Commits](golang/tools@v0.19.0...v0.20.0)

---
updated-dependencies:
- dependency-name: golang.org/x/tools
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

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

* chore(deps): bump google.golang.org/grpc from 1.62.1 to 1.63.0 (#1383)

Bumps [google.golang.org/grpc](https://github.com/grpc/grpc-go) from 1.62.1 to 1.63.0.
- [Release notes](https://github.com/grpc/grpc-go/releases)
- [Commits](grpc/grpc-go@v1.62.1...v1.63.0)

---
updated-dependencies:
- dependency-name: google.golang.org/grpc
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

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

* use correct supply when determining proportions (#1389)

* use correct supply when determining proportions

* fix HandleMsgTransfer tests

---------

Co-authored-by: Tuan Tran <[email protected]>

* Reinstate the TestAggregateIntentWithPRClaims (#1320)

* fix(intent-test): fix the claim to match the supply

* refactor: enable some tests and convert them to keeper tests

* fix int64 to sdkmath.Int

* rename alias to sdkmath to avoid confusion

* fix claim to match supply

* remove balance

* add unclaimedRatio

* add multi claim, less than 100% supply

* add tests, write comment for reasoning expected output

* fix tests failing due to #1345

* fix test

---------

Co-authored-by: Jacob Gadikian <[email protected]>
Co-authored-by: Joe Bowman <[email protected]>

* fix: Withdrawal records should not exist with 0 burnAmount (#1284)

* add guard to ```AddWithdrawalRecord```  and ```SetWithdrawalRecord```

* fix tests missing BurnAmount field

* return error instead of panic for ```SetwithdrawalRecord```  and ```AddWithdrawalRecord```

* fix linting

* return error

* refactor to check for error

* add missing BurnAmount field in TestGetRatio

* refactor test

* add old function for testing upgrade handler

* add upgrade handler and test

* add Upgrade handler to testnet upgrades

* Update x/interchainstaking/keeper/withdrawal_record.go comment

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>

* add test for set withdrawal records

* refactor: remove old code from keeper

* linting

* linting

* resolve conflict, fix upgrade name

* linting

---------

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
Co-authored-by: Jacob Gadikian <[email protected]>
Co-authored-by: Joe Bowman <[email protected]>

---------

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: Joseph Chalabi <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Joe Bowman <[email protected]>
Co-authored-by: Tuan Tran <[email protected]>
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Unable to deliver IBC transfer packet due to divide by zero
2 participants