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/group): use core migrations api #19423

Merged
merged 4 commits into from
Feb 14, 2024

Conversation

julienrbrt
Copy link
Member

@julienrbrt julienrbrt commented Feb 14, 2024

Description

Follow-up of #19410 to make core use the latest migration api now that it is possible.


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

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

  • Refactor
    • Updated the context type from sdk.Context to context.Context in migration functions, aligning with broader context handling practices.
  • New Features
    • Enhanced module capabilities with the addition of gRPC service registration and migration handling functions.
  • Chores
    • Improved codebase consistency in migration registration across different modules.

@julienrbrt julienrbrt requested a review from a team as a code owner February 14, 2024 00:07
Copy link
Contributor

coderabbitai bot commented Feb 14, 2024

Walkthrough

The recent updates aim to enhance context handling and migration processes across specific modules. Changes involve transitioning from sdk.Context to context.Context, introducing GRPC service registration, and refining migration management. These adjustments align with contemporary practices to facilitate seamless migrations and service integrations.

Changes

Files Changes Summary
x/group/keeper/migrations.go
x/group/migrations/v2/migrate.go
Updated context type to context.Context in Migrate1to2 and Migrate functions for migration process improvements.
x/group/module/module.go - Added google.golang.org/grpc import.
- Enhanced AppModule to support appmodule.HasServices and appmodule.HasMigrations.
- Modified RegisterServices to use grpc.ServiceRegistrar.
- Introduced RegisterMigrations for migration management.
x/slashing/module.go Updated RegisterMigrations in AppModule to use MigrationRegistrar correctly, ensuring accurate migration registration.

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-tests for this file.
  • 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 tests 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 from git and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit tests.
    • @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.
  • 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

CodeRabbit Discord Community

Join our Discord Community to get help, request features, and share feedback.

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

Commits Files that changed from the base of the PR and between 3386860 and b129d49.
Files selected for processing (4)
  • x/group/keeper/migrations.go (2 hunks)
  • x/group/migrations/v2/migrate.go (2 hunks)
  • x/group/module/module.go (3 hunks)
  • x/slashing/module.go (1 hunks)
Additional comments: 9
x/group/keeper/migrations.go (2)
  • 4-4: LGTM!
  • 20-20: LGTM!
x/group/migrations/v2/migrate.go (2)
  • 4-4: LGTM!
  • 28-28: LGTM!
x/group/module/module.go (4)
  • 10-10: LGTM!
  • 38-39: LGTM!
  • 129-135: LGTM!
  • 137-143: LGTM!
x/slashing/module.go (1)
  • 121-132: 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.

Review Status

Actionable comments generated: 2

Configuration used: .coderabbit.yml

Commits Files that changed from the base of the PR and between b129d49 and fc8b13c.
Files selected for processing (7)
  • runtime/app.go (2 hunks)
  • runtime/module.go (1 hunks)
  • runtime/services.go (1 hunks)
  • runtime/services/autocli.go (1 hunks)
  • simapp/app.go (2 hunks)
  • types/module/configurator.go (1 hunks)
  • x/accounts/module.go (3 hunks)
Files skipped from review due to trivial changes (1)
  • runtime/services/autocli.go
Additional comments: 8
runtime/services.go (1)
  • 11-11: The deprecation warning comment is correctly placed. Ensure to plan for the removal of deprecated elements in future versions.
x/accounts/module.go (3)
  • 9-9: Correctly added google.golang.org/grpc import for updated service registration methods.
  • 36-37: Correctly updated AppModule to implement HasServices for compliance with updated interfaces.
  • 64-68: Updated RegisterServices function signature to use grpc.ServiceRegistrar correctly aligns with the updated service registration methods.
types/module/configurator.go (1)
  • 17-22: > 📝 NOTE

This review was outside the diff hunks, and no overlapping diff hunk was found. Original lines [10-10]

The deprecation notice for the Configurator interface is correctly documented, providing clear guidance on using core services for future developments.

runtime/app.go (2)
  • 44-44: Correctly updated the configurator field type to module.Configurator with an appropriate deprecation note.
  • 236-236: Correctly updated the Configurator method signature to return module.Configurator with an appropriate deprecation note.
runtime/module.go (1)
  • 39-39: The deprecation warning comment is correctly placed for the RegisterServices method. Ensure to plan for the removal of deprecated elements in future versions.

@@ -177,7 +177,7 @@ type SimApp struct {
sm *module.SimulationManager

// module configurator
configurator module.Configurator
configurator module.Configurator // nolint:staticcheck // SA1019: Configurator is deprecated but still used in runtime v1.
Copy link
Contributor

Choose a reason for hiding this comment

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

The change to the configurator field's type to module.Configurator aligns with the PR's objective to utilize the latest migration API. However, the use of nolint:staticcheck to suppress the deprecation warning SA1019 should be accompanied by a comment explaining why this deprecated feature is still being used and any plans for future migration away from it.

- configurator module.Configurator // nolint:staticcheck // SA1019: Configurator is deprecated but still used in runtime v1.
+ configurator module.Configurator // nolint:staticcheck // SA1019: Configurator is deprecated but still used in runtime v1. Explain why and future plans.

Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.

Suggested change
configurator module.Configurator // nolint:staticcheck // SA1019: Configurator is deprecated but still used in runtime v1.
configurator module.Configurator // nolint:staticcheck // SA1019: Configurator is deprecated but still used in runtime v1. Explain why and future plans.

@@ -651,7 +651,7 @@
return app.ModuleManager.EndBlock(ctx)
}

func (a *SimApp) Configurator() module.Configurator {
func (a *SimApp) Configurator() module.Configurator { // nolint:staticcheck // SA1019: Configurator is deprecated but still used in runtime v1.
Copy link
Contributor

Choose a reason for hiding this comment

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

The method Configurator() correctly returns the module.Configurator type, consistent with the changes made to the configurator field. The suppression of the deprecation warning SA1019 is noted. As with the field change, it's important to document the rationale behind continuing to use a deprecated feature and any intended migration strategy.

- func (a *SimApp) Configurator() module.Configurator { // nolint:staticcheck // SA1019: Configurator is deprecated but still used in runtime v1.
+ func (a *SimApp) Configurator() module.Configurator { // nolint:staticcheck // SA1019: Configurator is deprecated but still used in runtime v1. Document why and future plans.

Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.

Suggested change
func (a *SimApp) Configurator() module.Configurator { // nolint:staticcheck // SA1019: Configurator is deprecated but still used in runtime v1.
func (a *SimApp) Configurator() module.Configurator { // nolint:staticcheck // SA1019: Configurator is deprecated but still used in runtime v1. Document why and future plans.

@alexanderbez alexanderbez added this pull request to the merge queue Feb 14, 2024
Merged via the queue into main with commit f6d970d Feb 14, 2024
56 of 57 checks passed
@alexanderbez alexanderbez deleted the julien/group-core-migrations branch February 14, 2024 18:28
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.

4 participants