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: export HasRegisterServices #23488

Merged
merged 6 commits into from
Jan 23, 2025
Merged

refactor: export HasRegisterServices #23488

merged 6 commits into from
Jan 23, 2025

Conversation

aljo242
Copy link
Collaborator

@aljo242 aljo242 commented Jan 23, 2025

move hasServicesV1 to HasRegisterServices and use where needed.

  • also move the CoreAppModuleAdaptor type to just be used in testing. We don't need to export this

Summary by CodeRabbit

  • Refactor

    • Updated module service registration interfaces
    • Renamed hasServicesV1 to HasRegisterServices
    • Deprecated older service registration methods
    • Updated type assertions and mock implementations for module interfaces
    • Renamed CoreAppModuleAdaptor to newCoreAppModuleAdaptor
  • Documentation

    • Added deprecation notices for legacy service registration approaches
    • Updated CHANGELOG with new interface details and version information

The changes primarily focus on modernizing the module service registration process and improving interface clarity in the SDK.

@aljo242 aljo242 requested review from julienrbrt and a team as code owners January 23, 2025 18:34
Copy link
Contributor

coderabbitai bot commented Jan 23, 2025

📝 Walkthrough

Walkthrough

The pull request introduces a significant refactoring of module service registration interfaces across multiple files in the Cosmos SDK. The primary change involves replacing the deprecated hasServicesV1 interface with a new HasRegisterServices interface. This modification impacts runtime registration, mock implementations, and test utilities. The changes aim to streamline service registration processes while maintaining backward compatibility through deprecation notices.

Changes

File Change Summary
runtime/app.go Updated type assertion from hasServicesV1 to module.HasRegisterServices in RegisterModules method. Removed hasServicesV1 interface.
testutil/mock/types_module_module.go Renamed mock types and methods related to hasServicesV1 to HasRegisterServices. Updated method signatures accordingly.
types/module/core_module_test.go Restructured package from module to module_test. Updated interface implementations and type assertions in methods.
types/module/module.go Updated HasServices interface to indicate deprecation, renamed hasServicesV1 to HasRegisterServices, modified RegisterServices method.
types/module/module_test.go Replaced CoreAppModuleAdaptor with newCoreAppModuleAdaptor in test functions.
CHANGELOG.md Added entry for removal of CoreAppModuleAdaptor and addition of HasRegisterServices. Updated version and release date.

Possibly related PRs

Suggested labels

C:core/testing, C:x/upgrade, T:Docs

Suggested reviewers

  • julienrbrt
  • kocubinski
  • testinginprod
  • facundomedica

📜 Recent review details

Configuration used: .coderabbit.yml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between e728892 and ab11ed7.

📒 Files selected for processing (1)
  • runtime/app.go (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • runtime/app.go
⏰ Context from checks skipped due to timeout of 90000ms (5)
  • GitHub Check: tests (00)
  • GitHub Check: test-system-v2
  • GitHub Check: build (amd64)
  • GitHub Check: Analyze
  • GitHub Check: Summary

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>, please review it.
    • 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 gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @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 using 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 generate docstrings to generate docstrings for this PR. (Beta)
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

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.

@aljo242 aljo242 added the backport/v0.52.x PR scheduled for inclusion in the v0.52's next stable release label Jan 23, 2025
@aljo242 aljo242 changed the title refactor/export HasRegisterServices refactor: export HasRegisterServices Jan 23, 2025
Copy link
Contributor

@technicallyty technicallyty 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 comments (1)
runtime/app.go (1)

Line range hint 272-272: Remove unused type hasServicesV1.

The linter has flagged that the hasServicesV1 type is unused. Since it's been replaced by module.HasRegisterServices, this type definition should be removed.

Apply this diff to remove the unused type:

-// hasServicesV1 is the interface for registering service in baseapp Cosmos SDK.
-// This API is part of core/appmodule but commented out for dependencies.
-type hasServicesV1 interface {
-	RegisterServices(grpc.ServiceRegistrar) error
-}
🧹 Nitpick comments (1)
types/module/module.go (1)

93-94: Fix typo in deprecation notice.

The deprecation notice contains a typo: "instea" should be "instead".

-// Deprecated: use HasRegisterServices and its interface in your modules instea.
+// Deprecated: use HasRegisterServices and its interface in your modules instead.
📜 Review details

Configuration used: .coderabbit.yml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 1253ee5 and 8fb1c46.

📒 Files selected for processing (5)
  • runtime/app.go (1 hunks)
  • testutil/mock/types_module_module.go (1 hunks)
  • types/module/core_module_test.go (14 hunks)
  • types/module/module.go (2 hunks)
  • types/module/module_test.go (6 hunks)
🧰 Additional context used
📓 Path-based instructions (5)
types/module/module_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"

types/module/module.go (1)

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

runtime/app.go (1)

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

types/module/core_module_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"

testutil/mock/types_module_module.go (1)

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

🪛 GitHub Actions: Lint
runtime/app.go

[error] 272-272: type hasServicesV1 is unused (unused)

⏰ Context from checks skipped due to timeout of 90000ms (9)
  • GitHub Check: tests (00)
  • GitHub Check: test-sim-nondeterminism
  • GitHub Check: test-simapp-v2
  • GitHub Check: test-integration
  • GitHub Check: test-system-v2
  • GitHub Check: build (arm64)
  • GitHub Check: Analyze
  • GitHub Check: build (amd64)
  • GitHub Check: Summary
🔇 Additional comments (7)
types/module/core_module_test.go (2)

117-117: Address the TODO comment about Core API modules.

The comment indicates that something is not working for Core API modules. This needs to be clarified and addressed.

Would you like me to help investigate what's not working with Core API modules and propose a solution?


44-44: LGTM! Consistent renaming of CoreAppModuleAdaptor to newCoreAppModuleAdaptor.

The changes consistently rename the function across all test cases, maintaining the expected behavior.

Also applies to: 74-74, 117-117, 149-149, 181-181, 198-198

runtime/app.go (1)

83-86: LGTM! Updated type assertion to use module.HasRegisterServices.

The change correctly updates the type assertion to use the new interface, maintaining error handling.

testutil/mock/types_module_module.go (1)

279-338: LGTM! Auto-generated mock implementation.

The mock implementation for HasRegisterServices has been correctly generated with all necessary methods.

types/module/module_test.go (1)

Line range hint 1-600: LGTM! No direct changes to review.

The test file is comprehensive and well-structured.

types/module/module.go (2)

100-102: LGTM!

The new HasRegisterServices interface is well-defined and properly embeds appmodulev2.AppModule.


Line range hint 410-425: LGTM!

The implementation properly handles both interfaces with comprehensive error handling:

  1. Supports the deprecated HasServices interface for backward compatibility
  2. Implements the new HasRegisterServices interface with proper error handling
  3. Maintains support for appmodule.HasMigrations

Copy link
Contributor

@technicallyty technicallyty left a comment

Choose a reason for hiding this comment

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

just want to make sure this doesn't break anyone

Copy link
Contributor

@technicallyty technicallyty left a comment

Choose a reason for hiding this comment

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

✅ looks like you'll need to delete the old hasServicesV1 to appease the linter

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: 1

📜 Review details

Configuration used: .coderabbit.yml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 8fb1c46 and e728892.

📒 Files selected for processing (2)
  • CHANGELOG.md (1 hunks)
  • runtime/app.go (2 hunks)
✅ Files skipped from review due to trivial changes (1)
  • CHANGELOG.md
🧰 Additional context used
📓 Path-based instructions (1)
runtime/app.go (1)

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

🪛 golangci-lint (1.62.2)
runtime/app.go

13-13: File is not gci-ed with --skip-generated -s standard -s default -s prefix(cosmossdk.io) -s prefix(github.com/cosmos/cosmos-sdk) --custom-order

(gci)

🪛 GitHub Actions: Lint
runtime/app.go

[error] 7-7: File is not gci-ed with --skip-generated -s standard -s default -s prefix(cosmossdk.io) -s prefix(github.com/cosmos/cosmos-sdk) --custom-order


[error] 13-13: File is not gci-ed with --skip-generated -s standard -s default -s prefix(cosmossdk.io) -s prefix(github.com/cosmos/cosmos-sdk) --custom-order

⏰ Context from checks skipped due to timeout of 90000ms (4)
  • GitHub Check: tests (00)
  • GitHub Check: Analyze
  • GitHub Check: test-system-v2
  • GitHub Check: Summary
🔇 Additional comments (1)
runtime/app.go (1)

81-84: LGTM! Clean interface migration.

The change from hasServicesV1 to module.HasRegisterServices is well-structured:

  • Maintains backward compatibility
  • Includes proper error handling
  • Uses a more descriptive interface name

runtime/app.go Outdated Show resolved Hide resolved
@aljo242 aljo242 added this pull request to the merge queue Jan 23, 2025
Merged via the queue into main with commit 8493d4f Jan 23, 2025
71 of 72 checks passed
@aljo242 aljo242 deleted the refactor/export-services branch January 23, 2025 21:08
mergify bot pushed a commit that referenced this pull request Jan 23, 2025
(cherry picked from commit 8493d4f)

# Conflicts:
#	CHANGELOG.md
#	runtime/app.go
#	testutil/mock/types_module_module.go
aljo242 added a commit that referenced this pull request Jan 24, 2025
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
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants