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

chore: multiple coins migration #187

Merged
merged 16 commits into from
Jun 4, 2024
Merged

Conversation

troykessler
Copy link
Member

@troykessler troykessler commented May 16, 2024

Summary by CodeRabbit

  • New Features

    • Introduced migration functions for funders, delegations, stakers, bundles, and pools to handle the transition to the new version.
  • Bug Fixes

    • Updated and added functions to retrieve and set parameters for funders, delegations, stakers, and pools.
  • Refactor

    • Reordered parameters in various functions to improve code clarity and maintainability.
    • Updated imports and references to reflect changes in package structure.
  • Tests

    • Enhanced test logic to accommodate new migration functions and updated module imports.

@troykessler troykessler self-assigned this May 16, 2024
Copy link

coderabbitai bot commented May 16, 2024

Walkthrough

The updates introduce significant changes to the app and x directories, focusing on adding new parameters and migration functions to support funders, delegations, and stakers. The app/app.go and upgrade.go files see new parameters for various keepers, while multiple getter functions are added across different modules to facilitate data retrieval during migrations. Additionally, test cases in x/funders/keeper/keeper_test.go have been updated to reflect these changes.

Changes

Files Change Summary
app/app.go Added parameters for DelegationKeeper, FundersKeeper, and StakersKeeper in the New function.
app/upgrades/v1_5/upgrade.go Added migration functions and updated parameters for CreateUpgradeHandler. Updated imports and removed unused ones.
app/upgrades/v1_5/v1_4_types/bundles/getters_params.go Swapped order of storeKey and cdc parameters in GetParams function.
app/upgrades/v1_5/v1_4_types/delegation/getters_delegation.go Introduced functions for retrieving all delegation entries and data.
app/upgrades/v1_5/v1_4_types/funders/getters_funding.go Added function GetAllFundings to retrieve all fundings.
app/upgrades/v1_5/v1_4_types/funders/getters_params.go Added functions to get and set funders parameters.
app/upgrades/v1_5/v1_4_types/pool/getters_pool.go Added function GetParams to retrieve x/pool parameters.
app/upgrades/v1_5/v1_4_types/stakers/getters_staker.go Added function GetAllStakers to retrieve all stakers.
x/funders/keeper/keeper_test.go Updated imports and funders migration logic in test functions.
x/stakers/keeper/keeper.go Added Migration_SetStaker function to Keeper struct and updated imports.

Sequence Diagram(s) (Beta)

sequenceDiagram
    participant User
    participant App
    participant DelegationKeeper
    participant FundersKeeper
    participant StakersKeeper
    participant UpgradeHandler

    User ->> App: Initialize New()
    App ->> DelegationKeeper: Pass parameters
    App ->> FundersKeeper: Pass parameters
    App ->> StakersKeeper: Pass parameters

    User ->> UpgradeHandler: Trigger CreateUpgradeHandler()
    UpgradeHandler ->> DelegationKeeper: Migrate delegations
    UpgradeHandler ->> FundersKeeper: Migrate funders
    UpgradeHandler ->> StakersKeeper: Migrate stakers
Loading

Poem

In the code where keepers thrive,
New parameters now arrive,
Funders, stakers, delegations too,
All in sync, a grand debut.
Migrations smooth, the data flows,
Progress in each line shows.
🐇✨ Code's delight, as changes grow! 🌱


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.
    • @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 as 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.

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

@shifty11 shifty11 left a comment

Choose a reason for hiding this comment

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

For the testing part...
We already have the upgrade test in interchaintest/upgrades/v1_5/upgrade_test.go.
We could just extend this test if we want to test the migration better.

@mbreithecker mbreithecker marked this pull request as ready for review June 3, 2024 14:54
@mbreithecker mbreithecker self-requested a review as a code owner June 3, 2024 14:54
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: 4

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 87f6718 and 6aefa95.

Files ignored due to path filters (6)
  • app/upgrades/v1_5/v1_4_types/bundles/params.pb.go is excluded by !**/*.pb.go
  • app/upgrades/v1_5/v1_4_types/delegation/delegation.pb.go is excluded by !**/*.pb.go
  • app/upgrades/v1_5/v1_4_types/funders/funders.pb.go is excluded by !**/*.pb.go
  • app/upgrades/v1_5/v1_4_types/funders/params.pb.go is excluded by !**/*.pb.go
  • app/upgrades/v1_5/v1_4_types/pool/params.pb.go is excluded by !**/*.pb.go
  • app/upgrades/v1_5/v1_4_types/stakers/stakers.pb.go is excluded by !**/*.pb.go
Files selected for processing (10)
  • app/app.go (1 hunks)
  • app/upgrades/v1_5/upgrade.go (2 hunks)
  • app/upgrades/v1_5/v1_4_types/bundles/getters_params.go (2 hunks)
  • app/upgrades/v1_5/v1_4_types/delegation/getters_delegation.go (1 hunks)
  • app/upgrades/v1_5/v1_4_types/funders/getters_funding.go (1 hunks)
  • app/upgrades/v1_5/v1_4_types/funders/getters_params.go (1 hunks)
  • app/upgrades/v1_5/v1_4_types/pool/getters_pool.go (1 hunks)
  • app/upgrades/v1_5/v1_4_types/stakers/getters_staker.go (1 hunks)
  • x/funders/keeper/keeper_test.go (2 hunks)
  • x/stakers/keeper/keeper.go (2 hunks)
Additional comments not posted (9)
app/upgrades/v1_5/v1_4_types/pool/getters_pool.go (1)

11-18: The use of MustUnmarshal in GetParams could lead to panics if unmarshalling fails. Ensure that this behavior is acceptable in your error handling strategy.

app/upgrades/v1_5/v1_4_types/stakers/getters_staker.go (1)

12-27: The implementation of GetAllStakers follows best practices for handling iterators and unmarshalling data. Good job ensuring the iterator is closed with defer.

app/upgrades/v1_5/v1_4_types/funders/getters_params.go (1)

10-28: Both GetParams and SetParams are implemented correctly. Note the use of MustMarshal in SetParams, which could lead to panics if marshalling fails. Ensure that this behavior is acceptable in your error handling strategy.

app/upgrades/v1_5/v1_4_types/funders/getters_funding.go (1)

11-24: The implementation of GetAllFundings is robust, correctly using an iterator to fetch data and ensuring the iterator is closed. Well done.

app/upgrades/v1_5/v1_4_types/delegation/getters_delegation.go (1)

11-41: Both GetAllDelegationEntries and GetAllDelegationData are implemented correctly, using iterators efficiently and ensuring they are closed properly. Excellent adherence to best practices.

x/stakers/keeper/keeper.go (1)

6-6: Import of sdk "github.com/cosmos/cosmos-sdk/types" is correctly added to support the new function Migration_SetStaker.

x/funders/keeper/keeper_test.go (1)

7-11: The imports for the migration testing are correctly updated to include necessary modules and types for the funders migration.

app/upgrades/v1_5/upgrade.go (1)

40-62: The CreateUpgradeHandler function correctly integrates the new keepers and their migration functions. Ensure that the migration logic is thoroughly tested, especially the interactions between different modules during the upgrade process.

Would you like assistance in setting up integration tests for this upgrade process?

app/app.go (1)

419-421: The New function is updated to include new keepers as parameters, aligning with the changes in the upgrade logic. This is a crucial update for the application's functionality post-upgrade.

x/stakers/keeper/keeper.go Show resolved Hide resolved
x/funders/keeper/keeper_test.go Outdated Show resolved Hide resolved
app/upgrades/v1_5/upgrade.go Show resolved Hide resolved
mbreithecker
mbreithecker previously approved these changes Jun 4, 2024
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 6aefa95 and 495de42.

Files selected for processing (1)
  • x/funders/keeper/keeper_test.go (1 hunks)
Files skipped from review as they are similar to previous changes (1)
  • x/funders/keeper/keeper_test.go

@troykessler
Copy link
Member Author

For the testing part... We already have the upgrade test in interchaintest/upgrades/v1_5/upgrade_test.go. We could just extend this test if we want to test the migration better.

Removed the unit tests now

@mbreithecker mbreithecker merged commit 6bbd4d8 into main Jun 4, 2024
5 checks passed
@mbreithecker mbreithecker deleted the troy/multiple-coins-migration branch June 4, 2024 07:51
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.

3 participants