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(x/crisis): extract as go standalone go module #18378

Closed
wants to merge 3 commits into from

Conversation

julienrbrt
Copy link
Member

@julienrbrt julienrbrt commented Nov 6, 2023

Description

I was looking at #18290 but turns out some modules still need to be extracted for this to be properly done.


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
  • added ! to 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
  • followed the guidelines for building modules
  • included the necessary unit and integration tests
  • added a changelog entry to CHANGELOG.md
  • included comments for documenting Go code
  • updated the relevant documentation or specification
  • reviewed "Files changed" and left comments if necessary
  • run make lint and make test
  • 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.

I have...

  • confirmed the correct type prefix in the PR title
  • confirmed ! in the type prefix if API or client breaking change
  • confirmed all author checklist items have been addressed
  • reviewed state machine logic
  • reviewed API design and naming
  • reviewed documentation is accurate
  • reviewed tests and test coverage
  • manually tested (if applicable)

Summary by CodeRabbit

  • New Features
    • Introduced a new job "test-x-crisis" in the workflow.
    • Added a new package "crisis" in the codebase.
  • Refactor
    • Updated import paths across multiple files from "github.com/cosmos/cosmos-sdk/x/crisis" to "cosmossdk.io/x/crisis".
  • Tests
    • Added a "GenesisTestSuite" in the "genesis_test.go" file.
  • Chores
    • Updated SonarQube project configurations in "sonar-project.properties" files.
  • Documentation
    • Updated "CHANGELOG.md" files across multiple modules.

Copy link
Contributor

coderabbitai bot commented Nov 6, 2023

Walkthrough

The changes primarily involve the migration of the "crisis" module from the "github.com/cosmos/cosmos-sdk" path to the "cosmossdk.io" path across multiple files. This includes updates to import statements, protobuf definitions, and SonarQube configurations. Additionally, a new job "test-x-crisis" has been added to the GitHub workflow.

Changes

File(s) Change Summary
.github/workflows/test.yml Added a new job "test-x-crisis" to the workflow.
api/cosmos/crisis/module/v1/module.pulsar.go Modified the protobuf definition file module.proto.
go.work.example Added a new package "crisis".
proto/cosmos/crisis/module/v1/module.proto, proto/cosmos/crisis/v1beta1/genesis.proto, proto/cosmos/crisis/v1beta1/tx.proto Updated the import path of the crisis module.
simapp/... Imported the "crisis" package and updated the import paths.
x/accounts/CHANGELOG.md, x/authz/CHANGELOG.md, x/bank/CHANGELOG.md, x/crisis/CHANGELOG.md, x/gov/CHANGELOG.md, x/group/CHANGELOG.md, x/mint/CHANGELOG.md, x/slashing/CHANGELOG.md, x/staking/CHANGELOG.md Various changes to the changelog files.
x/crisis/... Updated the import paths and added new imports for the "crisis" module.
x/distribution/sonar-project.properties, x/crisis/sonar-project.properties Updated the SonarQube project configurations.

Poem

🐇 Hopping through the code, with a change in stride,

Paths have shifted, in the cosmos we abide. 🌌

From GitHub we depart, to cosmossdk.io we glide,

In the season of the fall, with the wind as our guide. 🍂

Celebrating this day, when in history, a satellite took its ride, 🛰️

Embracing change, in our codebase, far and wide. 🌍

So here's to the journey, come, join the ride,

In the world of code, where magic resides! ✨


Tips

Chat with CodeRabbit Bot (@coderabbitai)

  • If you reply to a review comment from CodeRabbit, the bot will automatically respond.
  • To engage with CodeRabbit bot directly around the specific lines of code in the PR, mention @coderabbitai in your review comment
  • Note: Review comments are made on code diffs or files, not on the PR overview.
  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

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 help to get help.
  • @coderabbitai resolve to resolve all the CodeRabbit review comments.

Note: For conversation with the bot, please use the review comments on code diffs or files.

CodeRabbit Configration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • The JSON schema for the configuration file is available here.
  • 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/coderabbit-overrides.v2.json

@@ -0,0 +1,14 @@
sonar.projectKey=cosmos-sdk-x-crisis
Copy link
Member Author

Choose a reason for hiding this comment

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

@@ -1191,3 +1191,34 @@ jobs:
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
with:
projectBaseDir: x/mint/

test-x-crisis:
Copy link
Member Author

Choose a reason for hiding this comment

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

I will be making the test-x-crisis required once this PR is merged.

@julienrbrt julienrbrt marked this pull request as ready for review November 6, 2023 17:33
@julienrbrt julienrbrt requested a review from a team as a code owner November 6, 2023 17:33
@github-prbot github-prbot requested review from a team, kocubinski and samricotta and removed request for a team November 6, 2023 17:34
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.

Review Status

Actionable comments generated: 0

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between fb9dadc and 60225a7.
Files ignored due to filter (9)
  • go.mod
  • go.sum
  • simapp/go.mod
  • tests/go.mod
  • tests/starship/tests/go.mod
  • x/crisis/go.mod
  • x/crisis/go.sum
  • x/crisis/types/genesis.pb.go
  • x/crisis/types/tx.pb.go
Files selected for processing (30)
  • .github/workflows/test.yml (1 hunks)
  • api/cosmos/crisis/module/v1/module.pulsar.go (1 hunks)
  • go.work.example (1 hunks)
  • proto/cosmos/crisis/module/v1/module.proto (1 hunks)
  • proto/cosmos/crisis/v1beta1/genesis.proto (1 hunks)
  • proto/cosmos/crisis/v1beta1/tx.proto (1 hunks)
  • simapp/app.go (2 hunks)
  • simapp/app_config.go (2 hunks)
  • simapp/app_test.go (2 hunks)
  • simapp/app_v2.go (2 hunks)
  • simapp/simd/cmd/commands.go (2 hunks)
  • x/accounts/CHANGELOG.md (1 hunks)
  • x/authz/CHANGELOG.md (1 hunks)
  • x/bank/CHANGELOG.md (1 hunks)
  • x/crisis/CHANGELOG.md (1 hunks)
  • x/crisis/abci.go (1 hunks)
  • x/crisis/keeper/genesis.go (1 hunks)
  • x/crisis/keeper/genesis_test.go (1 hunks)
  • x/crisis/keeper/keeper.go (1 hunks)
  • x/crisis/keeper/keeper_test.go (1 hunks)
  • x/crisis/keeper/msg_server.go (1 hunks)
  • x/crisis/keeper/msg_server_test.go (1 hunks)
  • x/crisis/module.go (2 hunks)
  • x/crisis/sonar-project.properties (1 hunks)
  • x/distribution/sonar-project.properties (1 hunks)
  • x/gov/CHANGELOG.md (1 hunks)
  • x/group/CHANGELOG.md (1 hunks)
  • x/mint/CHANGELOG.md (1 hunks)
  • x/slashing/CHANGELOG.md (1 hunks)
  • x/staking/CHANGELOG.md (1 hunks)
Files skipped from review due to trivial changes (23)
  • proto/cosmos/crisis/module/v1/module.proto
  • proto/cosmos/crisis/v1beta1/genesis.proto
  • proto/cosmos/crisis/v1beta1/tx.proto
  • simapp/app_test.go
  • simapp/app_v2.go
  • simapp/simd/cmd/commands.go
  • x/accounts/CHANGELOG.md
  • x/authz/CHANGELOG.md
  • x/bank/CHANGELOG.md
  • x/crisis/CHANGELOG.md
  • x/crisis/keeper/genesis.go
  • x/crisis/keeper/keeper.go
  • x/crisis/keeper/keeper_test.go
  • x/crisis/keeper/msg_server.go
  • x/crisis/keeper/msg_server_test.go
  • x/crisis/module.go
  • x/crisis/sonar-project.properties
  • x/distribution/sonar-project.properties
  • x/gov/CHANGELOG.md
  • x/group/CHANGELOG.md
  • x/mint/CHANGELOG.md
  • x/slashing/CHANGELOG.md
  • x/staking/CHANGELOG.md
Additional comments: 11
go.work.example (1)
  • 24-34: The new crisis module has been added to the workspace. Ensure that all dependencies and imports are correctly updated to reflect this change.
x/crisis/keeper/genesis_test.go (2)
  • 9-22: The import paths have been updated to reflect the new module location. Ensure that the new module is correctly set up and accessible at the new location.

  • 9-24: > Note: This review was outside of the patch, so it was mapped to the patch with the greatest overlap. Original lines [24-28]

The GenesisTestSuite struct has been defined. This is a good practice as it groups related test cases together and allows for setup and teardown methods that apply to all tests in the suite.

simapp/app_config.go (2)
  • 59-66: The import paths have been updated to reflect the new location of the crisis module. Ensure that the new location is accessible and the module is correctly installed there.

  • 69-74: The old import paths for the crisis module have been removed. Ensure that there are no remaining references to the old paths in the codebase.

x/crisis/abci.go (2)
  • 4-11: The import paths have been updated correctly to reflect the new location of the crisis module. Ensure that the new module at "cosmossdk.io/x/crisis" is accessible and contains the expected "keeper" and "types" packages.

  • 4-13: > Note: This review was outside of the patch, so it was mapped to the patch with the greatest overlap. Original lines [13-24]

The logic of the EndBlocker function remains unchanged. It continues to check invariants at the specified interval and asserts them. No issues found here.

simapp/app.go (2)
  • 69-74: The new import paths for the crisis module look correct. Ensure that the new module at "cosmossdk.io/x/crisis" is accessible and that the codebase has been updated to reflect these changes.

  • 107-112: No changes were made in this hunk. The import paths remain the same.

.github/workflows/test.yml (1)
  • 1195-1224: The new job test-x-crisis is well defined and follows the same pattern as other jobs in the workflow. It checks out the code, sets up Go, checks for changes in the x/crisis directory, runs tests if there are changes, and performs SonarCloud analysis if it's not a draft PR and the SONAR_TOKEN is available. This job will help ensure that any changes to the x/crisis module are properly tested and analyzed.
api/cosmos/crisis/module/v1/module.pulsar.go (1)
  • 565-592: > Note: This review was outside of the patch, so it was mapped to the patch with the greatest overlap. Original lines [0-589]

This hunk represents a protobuf definition in Go, which is a binary serialization format. It's hard to review this code because it's auto-generated and not meant to be human-readable. However, it's important to ensure that the protobuf definitions from which this code is generated are correct and up-to-date.

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.

Review Status

Actionable comments generated: 1

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between 60225a7 and a4002c9.
Files selected for processing (12)
  • simapp/app.go (2 hunks)
  • simapp/app_config.go (2 hunks)
  • simapp/app_test.go (2 hunks)
  • simapp/app_v2.go (2 hunks)
  • simapp/simd/cmd/commands.go (2 hunks)
  • x/crisis/abci.go (1 hunks)
  • x/crisis/keeper/genesis_test.go (1 hunks)
  • x/crisis/keeper/keeper.go (1 hunks)
  • x/crisis/keeper/keeper_test.go (1 hunks)
  • x/crisis/keeper/msg_server.go (1 hunks)
  • x/crisis/keeper/msg_server_test.go (1 hunks)
  • x/crisis/module.go (2 hunks)
Files skipped from review due to trivial changes (7)
  • simapp/simd/cmd/commands.go
  • x/crisis/abci.go
  • x/crisis/keeper/genesis_test.go
  • x/crisis/keeper/keeper.go
  • x/crisis/keeper/keeper_test.go
  • x/crisis/keeper/msg_server_test.go
  • x/crisis/module.go
Additional comments: 7
simapp/app_v2.go (1)
  • 18-18: The import path for the crisis module has been updated to reflect its new location as a standalone module. Ensure that the new module is correctly set up and that all dependencies are properly managed.
simapp/app_test.go (1)
  • 20-26: The import statement "cosmossdk.io/x/crisis" has been added and the import statement "github.com/cosmos/cosmos-sdk/x/crisis" has been removed. Ensure that all references to the crisis module in this file have been updated to use the new import path.
simapp/app_config.go (1)
  • 35-39: The import paths for the crisis module have been updated to the new standalone module path. Ensure that all references to the crisis module in the codebase have been updated to use the new import paths.
x/crisis/keeper/msg_server.go (2)
  • 4-12: The import paths have been updated correctly. Ensure that the new paths are accessible and the packages are available at the new location.

  • 14-14: The Keeper struct is correctly implementing the types.MsgServer interface. This is a good practice to ensure that the struct meets the interface requirements at compile time.

simapp/app.go (2)
  • 35-37: The new import paths for the crisis module look correct. Ensure that the new module is available at the specified path and that it is compatible with the current version of the Cosmos SDK used in this project.

  • 107-112: No changes have been made in this hunk. The import paths for the consensus and genutil modules remain the same.

Comment on lines 69 to 74
vestingtypes "github.com/cosmos/cosmos-sdk/x/auth/vesting/types"
_ "github.com/cosmos/cosmos-sdk/x/consensus" // import for side-effects
consensustypes "github.com/cosmos/cosmos-sdk/x/consensus/types"
_ "github.com/cosmos/cosmos-sdk/x/crisis" // import for side-effects
crisistypes "github.com/cosmos/cosmos-sdk/x/crisis/types"
"github.com/cosmos/cosmos-sdk/x/genutil"
genutiltypes "github.com/cosmos/cosmos-sdk/x/genutil/types"
)
Copy link
Contributor

Choose a reason for hiding this comment

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

The import paths for the consensus module are still using the old paths. If the consensus module has also been extracted as a standalone module, its import paths should be updated as well.

- _ "github.com/cosmos/cosmos-sdk/x/consensus" // import for side-effects
- consensustypes "github.com/cosmos/cosmos-sdk/x/consensus/types"
+ _ "cosmossdk.io/x/consensus" // import for side-effects
+ consensustypes "cosmossdk.io/x/consensus/types"

Commitable suggestion

[!IMPORTANT]
Carefully review the code before committing. Make sure it correctly replaces the highlighted code, has no missing lines and indentaion issues.

Suggested change
vestingtypes "github.com/cosmos/cosmos-sdk/x/auth/vesting/types"
_ "github.com/cosmos/cosmos-sdk/x/consensus" // import for side-effects
consensustypes "github.com/cosmos/cosmos-sdk/x/consensus/types"
_ "github.com/cosmos/cosmos-sdk/x/crisis" // import for side-effects
crisistypes "github.com/cosmos/cosmos-sdk/x/crisis/types"
"github.com/cosmos/cosmos-sdk/x/genutil"
genutiltypes "github.com/cosmos/cosmos-sdk/x/genutil/types"
)
vestingtypes "github.com/cosmos/cosmos-sdk/x/auth/vesting/types"
_ "cosmossdk.io/x/consensus" // import for side-effects
consensustypes "cosmossdk.io/x/consensus/types"
"github.com/cosmos/cosmos-sdk/x/genutil"
genutiltypes "github.com/cosmos/cosmos-sdk/x/genutil/types"
)

Copy link

sonarcloud bot commented Nov 6, 2023

[Cosmos SDK - x/crisis] Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
No Duplication information No Duplication information

@julienrbrt
Copy link
Member Author

Closing this until we fix x/crisis. Then we can extract it.

@julienrbrt julienrbrt closed this Nov 6, 2023
@julienrbrt julienrbrt deleted the julien/remove-modules-from-sdk branch November 6, 2023 20:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant