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

feat: support multiple coins in bundles module #184

Merged
merged 7 commits into from
May 14, 2024

Conversation

troykessler
Copy link
Member

@troykessler troykessler commented May 7, 2024

This PR implements multiple coins for funding in the bundles module

Summary by CodeRabbit

  • New Features

    • Enhanced payout calculations in events to support multiple types of coins.
  • Refactor

    • Updated methods to handle coin types and weights more dynamically, improving financial calculations related to rewards and payouts.
  • Documentation

    • Added comments and updated method signatures to reflect changes in handling coin types.
    • Clarified descriptions and titles in openapi.yml and params.proto for better understanding of fields like storage_provider_id, cost, and coin_weight.

@troykessler troykessler requested a review from mbreithecker May 7, 2024 10:06
@troykessler troykessler self-assigned this May 7, 2024
Copy link

coderabbitai bot commented May 7, 2024

Warning

Rate Limit Exceeded

@troykessler has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 7 minutes and 16 seconds before requesting another review.

How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.
Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.
Please see our FAQ for further information.

Commits Files that changed from the base of the PR and between 66a8651 and a1d0bfa.

Walkthrough

The changes revolve around transitioning monetary-related fields to sdk.Coins type, improving financial precision. New structures manage whitelists and payouts, enhancing financial management in the codebase.

Changes

File Path Change Summary
x/bundles/keeper/keeper_suite_valid_bundles_test.go Adjusted storageReward calculation with whitelist factor.
x/bundles/keeper/logic_bundles.go Updated functions to use sdk.Coins for payouts.
docs/static/openapi.yml
proto/kyve/bundles/v1beta1/params.proto
Detailed descriptions and units for fields like cost.
proto/kyve/funders/v1beta1/params.proto Added explanation for coin_weight as market price.

🐇✨
A hop, a skip, a code deploy,
Changes abound, oh what joy!
Coins jingle, structures shift,
In our codebase, tides lift.
Celebrate, for we craft with care,
In the digital burrow, fresh air! 🌟
🐇✨


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.

@troykessler troykessler force-pushed the troy/bundles-multiple-coins branch from bc9ebeb to 6e2b3b6 Compare May 8, 2024 13:43
@troykessler troykessler marked this pull request as ready for review May 8, 2024 13:44
@troykessler troykessler requested a review from shifty11 as a code owner May 8, 2024 13:44
Copy link

@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: 2

Review Details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits Files that changed from the base of the PR and between b7d8eb0 and 6e2b3b6.
Files ignored due to path filters (1)
  • x/bundles/types/events.pb.go is excluded by !**/*.pb.go
Files selected for processing (6)
  • app/upgrades/v1_5/upgrade.go (1 hunks)
  • proto/kyve/bundles/v1beta1/events.proto (2 hunks)
  • x/bundles/keeper/keeper_suite_valid_bundles_test.go (1 hunks)
  • x/bundles/keeper/logic_bundles.go (9 hunks)
  • x/bundles/types/expected_keepers.go (1 hunks)
  • x/bundles/types/types.go (3 hunks)
Additional comments not posted (7)
x/bundles/types/types.go (2)

20-28: The changes to the BundleReward struct to use sdk.Coins instead of uint64 for various fields align with the PR's goal to support multiple coin types. This is a crucial update for handling multi-currency transactions and should work well with the Cosmos SDK's native support for multi-denominational coins.


54-54: The update of the FundersPayout field in the TallyResult struct to use sdk.Coins is consistent with the changes in the BundleReward struct and necessary for the multi-coin support. This ensures that all parts of the system that deal with payouts can handle multiple currencies.

x/bundles/types/expected_keepers.go (1)

52-52: Changing the GetCoinWhitelist method to GetCoinWhitelistMap and altering its return type from a slice to a map is a significant improvement. This change will likely enhance performance by providing O(1) access time for coin data, which is beneficial for operations that need to frequently access these data.

proto/kyve/bundles/v1beta1/events.proto (2)

5-6: The addition of imports for amino/amino.proto and cosmos/base/v1beta1/coin.proto is necessary for the new functionality to handle multiple coin types in the events. These imports are essential for the protobuf definitions that use these types.


92-136: The changes to the EventBundleFinalized message to use repeated cosmos.base.v1beta1.Coin for various reward-related fields are crucial for supporting multiple currencies. This allows the system to handle payouts in different coin types, which is a significant enhancement for the flexibility of the bundles module.

x/bundles/keeper/logic_bundles.go (2)

Line range hint 234-295: The refactoring of the calculatePayouts function to handle sdk.Coins instead of uint64 is a necessary change to support multiple currencies. The detailed implementation for handling different coin types, including the distribution of storage costs and rewards, is well-thought-out and should work effectively within the multi-coin framework.


Line range hint 361-409: The updates to the finalizeCurrentBundleProposal function to handle multiple coin types in the fundersPayout parameter and other related changes are well implemented. These changes are crucial for ensuring that the system can finalize bundles with payouts in multiple currencies, enhancing the module's flexibility.

x/bundles/keeper/keeper_suite_valid_bundles_test.go Outdated Show resolved Hide resolved
app/upgrades/v1_5/upgrade.go Show resolved Hide resolved
Copy link

@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 Details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits Files that changed from the base of the PR and between 6e2b3b6 and 87eb63e.
Files selected for processing (2)
  • x/bundles/keeper/keeper_suite_valid_bundles_test.go (1 hunks)
  • x/bundles/keeper/logic_bundles.go (8 hunks)
Files skipped from review as they are similar to previous changes (2)
  • x/bundles/keeper/keeper_suite_valid_bundles_test.go
  • x/bundles/keeper/logic_bundles.go

Copy link

@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: 3

Review Details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits Files that changed from the base of the PR and between 87eb63e and 66a8651.
Files ignored due to path filters (2)
  • x/bundles/types/params.pb.go is excluded by !**/*.pb.go
  • x/funders/types/params.pb.go is excluded by !**/*.pb.go
Files selected for processing (3)
  • docs/static/openapi.yml (3 hunks)
  • proto/kyve/bundles/v1beta1/params.proto (1 hunks)
  • proto/kyve/funders/v1beta1/params.proto (1 hunks)
Additional comments not posted (3)
docs/static/openapi.yml (3)

33-42: Descriptions and titles for storage_provider_id and cost fields are clear and informative.


4432-4441: Descriptions and titles for storage_provider_id and cost fields are clear and informative.


4740-4745: Description and title for coin_weight field are clear and informative.

proto/kyve/bundles/v1beta1/params.proto Outdated Show resolved Hide resolved
proto/kyve/bundles/v1beta1/params.proto Outdated Show resolved Hide resolved
proto/kyve/funders/v1beta1/params.proto Outdated Show resolved Hide resolved
@troykessler troykessler requested a review from mbreithecker May 14, 2024 08:20
@mbreithecker mbreithecker merged commit 50a1c3b into main May 14, 2024
5 checks passed
@mbreithecker mbreithecker deleted the troy/bundles-multiple-coins branch May 14, 2024 08:28
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.

2 participants