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

refactor: use corestore.StoreUpgrades #21259

Merged
merged 10 commits into from
Aug 13, 2024
Merged

refactor: use corestore.StoreUpgrades #21259

merged 10 commits into from
Aug 13, 2024

Conversation

tac0turtle
Copy link
Member

@tac0turtle tac0turtle commented Aug 12, 2024

Description

ref #21176

this pr adopts corestore.StoreUpgrades throughout the repository


Author Checklist

All items are required. Please add a note to the item if the item is not applicable and
please add links to any relevant follow up issues.

I have...

  • included the correct type prefix in the PR title, you can find examples of the prefixes below:
  • confirmed ! in the type prefix if API or client breaking change
  • targeted the correct branch (see PR Targeting)
  • provided a link to the relevant issue or specification
  • reviewed "Files changed" and left comments if necessary
  • included the necessary unit and integration tests
  • added a changelog entry to CHANGELOG.md
  • updated the relevant documentation or specification, including comments for documenting Go code
  • confirmed all CI checks have passed

Reviewers Checklist

All items are required. Please add a note if the item is not applicable and please add
your handle next to the items reviewed if you only reviewed selected items.

Please see Pull Request Reviewer section in the contributing guide for more information on how to review a pull request.

I have...

  • confirmed the correct type prefix in the PR title
  • confirmed all author checklist items have been addressed
  • reviewed state machine logic, API design and naming, documentation is accurate, tests and test coverage

Summary by CodeRabbit

  • New Features

    • Enhanced store upgrade handling with a new core module for improved management.
    • Updated initialization process for the NewKeeper constructor, simplifying environment configuration.
  • Bug Fixes

    • Removed redundant tests related to store loader functionality, streamlining the testing process.

Copy link
Contributor

coderabbitai bot commented Aug 12, 2024

Walkthrough

Walkthrough

The recent changes primarily focus on enhancing the upgrade mechanisms within the Cosmos SDK by modifying the UpgradeStoreLoader function and its testing framework. The parameter type for store upgrades has transitioned to corestore.StoreUpgrades, streamlining the upgrade logic by omitting checks for renamed stores. Additionally, related test cases and helper functions were removed, indicating a more efficient testing approach. Significant updates to the SimApp reflect architectural improvements in managing store upgrades.

Changes

File Summary
x/upgrade/types/storeloader.go Modified UpgradeStoreLoader to accept *corestore.StoreUpgrades instead of *storetypes.StoreUpgrades, simplifying the logic to focus only on added and deleted stores.
x/upgrade/types/storeloader_test.go Removed the useUpgradeLoader function and its associated test case, indicating a simplification in store loader handling and testing.
simapp/upgrades.go Updated import from storetypes to corestore, aligning store upgrades with the new core module structure while maintaining overall logic flow.
x/upgrade/CHANGELOG.md Updated to reflect substantial changes, including the migration of NewKeeper to accept appmodule.Environment and the transition to corestore.StoreUpgrades for upgrades.

Sequence Diagram(s)

sequenceDiagram
    participant CLI
    participant UpgradeStoreLoader
    participant StoreUpgrades
    participant BaseApp

    CLI->>UpgradeStoreLoader: Request upgrade with store upgrades
    UpgradeStoreLoader->>StoreUpgrades: Process added/deleted stores
    UpgradeStoreLoader->>BaseApp: Set new store loader
    BaseApp-->>CLI: Upgrade complete
Loading

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 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.

@github-actions github-actions bot removed the C:Store label Aug 12, 2024
@tac0turtle tac0turtle marked this pull request as ready for review August 12, 2024 21:16
@tac0turtle tac0turtle requested a review from a team as a code owner August 12, 2024 21:16
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 details

Configuration used: .coderabbit.yml
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 431b523 and fd1dcc61e973afe7d72a95aff6e2796e32917d80.

Files selected for processing (2)
  • x/upgrade/types/storeloader.go (1 hunks)
  • x/upgrade/types/storeloader_test.go (2 hunks)
Additional context used
Path-based instructions (2)
x/upgrade/types/storeloader.go (1)

Pattern **/*.go: Review the Golang code for conformity with the Uber Golang style guide, highlighting any deviations.

x/upgrade/types/storeloader_test.go (2)

Pattern **/*.go: Review the Golang code for conformity with the Uber Golang style guide, highlighting any deviations.


Pattern **/*_test.go: "Assess the unit test code assessing sufficient code coverage for the changes associated in the pull request"

Additional comments not posted (5)
x/upgrade/types/storeloader.go (2)

4-4: Conform to Uber Golang style guide for import aliasing.

The alias corestore is correctly used here to avoid potential conflicts and improve readability.


12-20: Update function signature and logic for UpgradeStoreLoader.

The function signature change from *storetypes.StoreUpgrades to *corestore.StoreUpgrades reflects the refactoring goal. The logic now only checks for added or deleted stores, which simplifies the upgrade process by excluding renamed stores. This aligns with the PR's objective to streamline store upgrade handling.

x/upgrade/types/storeloader_test.go (3)

Line range hint 1-1: Ensure test package imports align with the Uber Golang style guide.

The import statements are well-organized, following the standard practice of grouping and aliasing where necessary.


Line range hint 99-99: Assess the completeness of TestSetLoader.

The test case effectively checks the loading and committing of store versions. Ensure that it adequately reflects the changes in UpgradeStoreLoader, particularly the handling of added and deleted stores.


Line range hint 48-48: Verify test coverage for store upgrade logic.

The test TestSetLoader focuses on loading and committing store versions, which aligns with the core functionality of the UpgradeStoreLoader. However, ensure that the removal of useUpgradeLoader does not leave any critical paths untested, especially concerning the handling of added and deleted stores.

Copy link
Member

@julienrbrt julienrbrt left a comment

Choose a reason for hiding this comment

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

Lgtm, can we add a deprecation notice in x/upgrade changelog about removing renaming stores when using x/upgrade method?

@julienrbrt julienrbrt added the backport/v0.52.x PR scheduled for inclusion in the v0.52's next stable release label Aug 12, 2024
Copy link
Contributor

@hieuvubk hieuvubk left a comment

Choose a reason for hiding this comment

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

lgtm

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

Outside diff range, codebase verification and nitpick comments (1)
simapp/upgrades.go (1)

7-7: Potential Issue with corestore Usage: Missing Renamed Field

The corestore package's StoreUpgrades type lacks the Renamed field found in the storetypes version. This might affect functionality if the Renamed field was previously utilized. Ensure that this change aligns with the project's requirements and that any necessary adjustments are made to accommodate the missing field.

  • core/store/upgrade.go defines StoreUpgrades with Added and Deleted.
  • store/types/store.go defines StoreUpgrades with Added, Renamed, and Deleted.
Analysis chain

Verify the functionality of corestore.

Ensure that corestore provides the necessary functionality previously handled by storetypes. This change may affect how store upgrades are managed, so verify that it aligns with the project's architectural goals.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify if `corestore` provides the necessary functionality for store upgrades.

# Test: Search for the `StoreUpgrades` type in `corestore`.
ast-grep --lang go --pattern 'type StoreUpgrades struct { $$$ }'

Length of output: 528

Review details

Configuration used: .coderabbit.yml
Review profile: CHILL

Commits

Files that changed from the base of the PR and between fd1dcc61e973afe7d72a95aff6e2796e32917d80 and acf2933fca76a01ad67d1bd0defaf09b4fcd5d72.

Files selected for processing (1)
  • simapp/upgrades.go (2 hunks)
Additional context used
Path-based instructions (1)
simapp/upgrades.go (1)

Pattern **/*.go: Review the Golang code for conformity with the Uber Golang style guide, highlighting any deviations.

Additional comments not posted (1)
simapp/upgrades.go (1)

Line range hint 45-54:
Verify the usage of corestore.StoreUpgrades.

Ensure that the corestore.StoreUpgrades is used correctly within the RegisterUpgradeHandlers function. This change should align with the intended design and functionality of the store upgrade process.

Verification successful

Usage of corestore.StoreUpgrades is correct.

The corestore.StoreUpgrades is used appropriately in the RegisterUpgradeHandlers function. The Added and Deleted fields are consistent with the intended design for handling store upgrades, and the comments align with the SDK changes. No issues were found.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the correctness of `corestore.StoreUpgrades` usage.

# Test: Search for the `StoreUpgrades` usage in the codebase to ensure consistent application.
rg --type go -A 5 'StoreUpgrades'

Length of output: 14295

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

Outside diff range, codebase verification and nitpick comments (2)
x/upgrade/CHANGELOG.md (2)

35-35: Clarify the migration details.

The entry "Upgrade has been migrated to cosrestore.StoreUpgrades" could benefit from additional context regarding the impact on existing users. Consider specifying any necessary migration steps or implications for developers.

- * [#21259](https://github.com/cosmos/cosmos-sdk/pull/21259) Upgrade has been migrated to cosrestore.StoreUpgrades. Renaming keys support has been removed from the upgrade module.
+ * [#21259](https://github.com/cosmos/cosmos-sdk/pull/21259) Upgrade process has been migrated to `cosrestore.StoreUpgrades`. Note that support for renaming keys has been removed, which may require developers to adjust their upgrade strategies accordingly.

37-37: Ensure clarity on state machine changes.

The entry regarding app version storage should provide more context about the implications of this change. Consider elaborating on how this affects the state machine and any necessary adjustments for developers.

- * (x/upgrade) [#16244](https://github.com/cosmos/cosmos-sdk/pull/16244) Upgrade module no longer stores the app version but gets and sets the app version stored in the `ParamStore` of baseapp.
+ * (x/upgrade) [#16244](https://github.com/cosmos/cosmos-sdk/pull/16244) The upgrade module no longer stores the app version internally. Instead, it retrieves and updates the app version using the `ParamStore` of `baseapp`. Developers may need to verify their version management logic to ensure compatibility.
Review details

Configuration used: .coderabbit.yml
Review profile: CHILL

Commits

Files that changed from the base of the PR and between acf2933fca76a01ad67d1bd0defaf09b4fcd5d72 and 99e38dadf2e6ccd9a5ba1ec6357f643a988a9b82.

Files selected for processing (1)
  • x/upgrade/CHANGELOG.md (1 hunks)
Additional context used
Path-based instructions (1)
x/upgrade/CHANGELOG.md (1)

Pattern **/*.md: "Assess the documentation for misspellings, grammatical errors, missing documentation and correctness"

@tac0turtle tac0turtle mentioned this pull request Aug 13, 2024
15 tasks
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 details

Configuration used: .coderabbit.yml
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 99e38dadf2e6ccd9a5ba1ec6357f643a988a9b82 and aca492c.

Files selected for processing (1)
  • simapp/upgrades.go (2 hunks)
Files skipped from review as they are similar to previous changes (1)
  • simapp/upgrades.go

@tac0turtle tac0turtle added this pull request to the merge queue Aug 13, 2024
Merged via the queue into main with commit 072a29c Aug 13, 2024
77 checks passed
@tac0turtle tac0turtle deleted the marko/storeupgrade branch August 13, 2024 13:57
mergify bot pushed a commit that referenced this pull request Aug 13, 2024
tac0turtle added a commit that referenced this pull request Aug 13, 2024
Co-authored-by: Marko <marko@baricevic.me>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport/v0.52.x PR scheduled for inclusion in the v0.52's next stable release C:x/upgrade
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants