-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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
feat(runtime): message router service #19571
Conversation
WalkthroughThe recent updates introduce significant enhancements across the board, focusing on routing services, codec implementations, and command-line interface improvements. A notable addition is the Changes
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? TipsChatThere are 3 ways to chat with CodeRabbit:
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)
Additionally, you can add CodeRabbit Configration File (
|
core/go.mod
Outdated
@@ -4,6 +4,7 @@ go 1.20 | |||
|
|||
require ( | |||
cosmossdk.io/log v1.3.1 | |||
github.com/cosmos/gogoproto v1.4.11 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this dep will be gone in server_modular as I can make use of this: https://github.com/cosmos/cosmos-sdk/pull/19499/files#diff-c1fc6f9f872ad64b8a1e6dee2e5e8bb2d675b920a403e621b8cf1f4ac5d6938cR12-R21
There was a problem hiding this 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.yml
Files selected for processing (11)
- CHANGELOG.md (1 hunks)
- baseapp/msg_service_router.go (1 hunks)
- core/CHANGELOG.md (1 hunks)
- core/appmodule/environment.go (1 hunks)
- core/go.mod (2 hunks)
- core/go.sum (3 hunks)
- core/router/service.go (1 hunks)
- runtime/environment.go (1 hunks)
- runtime/module.go (2 hunks)
- runtime/router.go (1 hunks)
- testutil/integration/router.go (1 hunks)
Additional comments: 14
core/router/service.go (1)
- 9-13: The introduction of the
Service
interface withInvokeTyped
andInvokeUntyped
methods is well-designed, adhering to Go's naming conventions and best practices for handling typed and untyped requests. The use ofcontext.Context
andprotoiface.MessageV1
is appropriate for the operations being performed.core/appmodule/environment.go (1)
- 15-22: The addition of the
MessageRouterService
field to theEnvironment
struct is well-integrated and follows Go's naming conventions and struct organization best practices. This change effectively incorporates the new message router service into the application's environment for broader access across modules.core/go.mod (2)
- 7-7: The addition of
github.com/cosmos/gogoproto v1.4.11
is relevant for protobuf handling within the project. Ensure this aligns with the project's long-term dependencies strategy, especially considering the note about future removal in server modular updates.- 16-16: The addition of
github.com/google/go-cmp v0.6.0
is suitable for implementing comparison functionality in tests or other parts of the project. This dependency should be used judiciously to avoid unnecessary complexity in comparisons.runtime/environment.go (1)
- 12-33: The introduction of
EnvOption
functions for configuring theEnvironment
struct with optional services like the message router and memory store is a well-implemented use of the functional options pattern. This approach enhances flexibility and scalability for theEnvironment
configuration.runtime/router.go (1)
- 19-77: The implementation of the
msgRouterService
struct and its methodsInvokeTyped
andInvokeUntyped
is well-designed, adhering to best practices for error handling, context usage, and dynamic protobuf message handling. The use ofprotoregistry.GlobalTypes
for message type resolution is appropriate and demonstrates a good understanding of protobuf's capabilities.core/go.sum (1)
- 12-18: > 📝 NOTE
This review was outside the diff hunks and was mapped to the diff hunk with the greatest overlap. Original lines [4-43]
The updates to the
go.sum
file correctly reflect the addition of new dependencies and updates to existing ones as outlined in thego.mod
file. These changes are essential for ensuring the integrity and reproducibility of builds.testutil/integration/router.go (1)
- 84-84: The integration of the message router service into the test application environment through the
runtime.EnvWithMessageRouterService(router)
option in theruntime.NewEnvironment
function call is correctly implemented. This ensures that the message router service is available and properly configured during integration tests.core/CHANGELOG.md (1)
- 45-45: The changelog entry for PR feat(runtime): message router service #19571 is correctly formatted and accurately describes the addition of
router.Service
and its integration intoappmodule.Environment
. Good adherence to the changelog's guiding principles.runtime/module.go (1)
- 214-226: The changes made to
ProvideEnvironment
and the refactoring ofProvideMemoryStoreService
improve the modularity and clarity of service provision within the module. These changes appear to be logically sound and correctly implemented.Please verify the impact of these changes on modules that previously depended on
ProvideMemoryStoreService
to ensure they are still functioning as expected.baseapp/msg_service_router.go (1)
- 28-29: The addition of
ResponseNameByRequestName
andHybridHandlerByMsgName
to theMessageRouter
interface enhances the message router's functionality by allowing for more flexible and efficient message handling. These changes are correctly implemented and follow best practices.Please verify the integration and testing of these new methods to ensure they work as expected in the broader system.
CHANGELOG.md (3)
- 45-45: The entry for the implementation of
core/router.Service
is clear and correctly links to the PR. It succinctly describes the feature's impact on the runtime and its presence in all modules using dependency injection.- 45-45: The description of the new method
IsGT
fortypes.Coin
is clear and straightforward. It's good that it specifies the method's functionality, making it easy for readers to understand its purpose.- 45-45: The addition of the
--qrcode
flag to thekeys show
command is a user-friendly feature that enhances the command's usability. The description is clear and directly states the new capability. However, ensuring that the documentation elsewhere (e.g., command help text or user guides) is updated to reflect this new flag would be important for user awareness.
There was a problem hiding this 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
Files selected for processing (1)
- runtime/router.go (1 hunks)
Files skipped from review as they are similar to previous changes (1)
- runtime/router.go
There was a problem hiding this 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
Files selected for processing (2)
- baseapp/msg_service_router.go (2 hunks)
- runtime/router.go (1 hunks)
Files skipped from review as they are similar to previous changes (2)
- baseapp/msg_service_router.go
- runtime/router.go
There was a problem hiding this 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
Files selected for processing (2)
- core/router/service.go (1 hunks)
- runtime/router.go (1 hunks)
Files skipped from review as they are similar to previous changes (2)
- core/router/service.go
- runtime/router.go
There was a problem hiding this 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
Files selected for processing (1)
- runtime/router_test.go (1 hunks)
Files skipped from review as they are similar to previous changes (1)
- runtime/router_test.go
There was a problem hiding this 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
Files selected for processing (1)
- runtime/router_test.go (1 hunks)
Files skipped from review as they are similar to previous changes (1)
- runtime/router_test.go
There was a problem hiding this 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
Files selected for processing (15)
- baseapp/baseapp.go (1 hunks)
- baseapp/grpcrouter.go (3 hunks)
- baseapp/grpcserver.go (1 hunks)
- baseapp/msg_service_router.go (4 hunks)
- baseapp/options.go (1 hunks)
- core/appmodule/environment.go (1 hunks)
- core/router/service.go (1 hunks)
- runtime/app.go (1 hunks)
- runtime/builder.go (1 hunks)
- runtime/environment.go (1 hunks)
- runtime/module.go (4 hunks)
- runtime/router.go (1 hunks)
- runtime/router_test.go (1 hunks)
- testutil/integration/router.go (1 hunks)
- x/accounts/keeper.go (1 hunks)
Files skipped from review as they are similar to previous changes (7)
- baseapp/msg_service_router.go
- core/appmodule/environment.go
- core/router/service.go
- runtime/environment.go
- runtime/router.go
- runtime/router_test.go
- testutil/integration/router.go
Additional comments: 11
runtime/builder.go (1)
- 34-34: The addition of
SetGRPCQueryRouter
correctly integrates the newgrpcQueryRouter
into the application's base setup, aligning with the PR's objectives to enhance message routing capabilities within the Cosmos SDK.baseapp/grpcrouter.go (3)
- 27-28: The addition of the
responseByRequestName
map in theGRPCQueryRouter
struct is a valuable enhancement, enabling the mapping of request names to response names and supporting the PR's goal of improving message routing capabilities.- 139-141: The introduction of the
ResponseNameByRequestName
method is a logical extension of theresponseByRequestName
map, facilitating easy retrieval of response names by request names, which aligns with the PR's objectives.- 149-158: Updating the
registerHybridHandler
method to map input names to output names supports the enhanced message routing mechanism by ensuring the correct response type is associated with each request.runtime/app.go (1)
- 52-52: The addition of the
grpcQueryRouter
field to theApp
struct correctly integrates the newGRPCQueryRouter
into the application, supporting the PR's goal of enhancing message routing capabilities.runtime/module.go (1)
- 217-236: The updates to the
ProvideEnvironment
function, including the addition ofmsgServiceRouter
andqueryServiceRouter
parameters, correctly support the enhanced message routing mechanism by ensuring the necessary routers are available within the application's environment.baseapp/options.go (2)
- 390-392: The method
SetMsgServiceRouter
correctly assigns the providedMsgServiceRouter
to theBaseApp
instance. This change enhances the configurability of message routing within the SDK. The method is straightforward and adheres to Go best practices.- 395-397: The method
SetGRPCQueryRouter
correctly assigns the providedGRPCQueryRouter
to theBaseApp
instance. This addition allows for more flexible configuration of gRPC query routing, aligning with the SDK's goals of enhancing routing mechanisms. The implementation is concise and follows Go best practices.x/accounts/keeper.go (2)
- 107-107: The comment added to the
msgRouter
field indicates a future intention to utilize the environment for message routing. This comment is clear and provides valuable insight into planned architectural enhancements. It's important for future development to ensure that the transition to using the environment is seamless and well-documented.- 109-109: Similarly, the comment added to the
queryRouter
field suggests an intention to leverage the environment for query routing. This comment is concise and informative, highlighting a strategic direction for enhancing routing capabilities. Future implementations should carefully consider the impact on existing functionality and ensure backward compatibility.baseapp/baseapp.go (1)
- 284-285: The introduction of
GRPCQueryRouter
in place ofMsgServiceRouter
represents a significant change in how queries are routed within the application. This shift towards gRPC for query handling could enhance the application's scalability and performance by leveraging gRPC's efficient communication protocols. However, it's crucial to ensure that all existing functionalities that relied onMsgServiceRouter
are adequately adapted to useGRPCQueryRouter
. Additionally, thorough testing is necessary to verify that the new routing mechanism works as expected across different scenarios and does not introduce any regressions.
There was a problem hiding this 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
Files selected for processing (4)
- core/CHANGELOG.md (1 hunks)
- core/appmodule/v2/environment.go (1 hunks)
- runtime/app.go (1 hunks)
- x/accounts/keeper.go (1 hunks)
Files skipped from review as they are similar to previous changes (3)
- core/CHANGELOG.md
- runtime/app.go
- x/accounts/keeper.go
Additional comments: 3
core/appmodule/v2/environment.go (3)
- 8-8: The addition of the
router
package in the import statements is necessary for the newRouterService
field. This change is correctly implemented.- 15-15: The addition of the
Logger
field to theEnvironment
struct enhances logging capabilities within the SDK's runtime environment. This is a positive change for debugging and monitoring purposes.- 21-21: Introducing the
RouterService
field of typerouter.Router
is a key part of this PR's objective to enhance message routing within the SDK. This change aligns with the PR's goals and is correctly implemented.
lint failure is unrelated |
There was a problem hiding this 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
Files selected for processing (5)
- core/appmodule/v2/environment.go (1 hunks)
- core/router/service.go (1 hunks)
- runtime/router.go (1 hunks)
- x/accounts/keeper.go (3 hunks)
- x/accounts/utils_test.go (1 hunks)
Files skipped from review as they are similar to previous changes (4)
- core/appmodule/v2/environment.go
- core/router/service.go
- runtime/router.go
- x/accounts/keeper.go
Additional comments: 1
x/accounts/utils_test.go (1)
- 92-92: The method
ResponseNameByMsgName
correctly reflects its purpose of determining the response name based on the message name. This change aligns with the broader PR objectives of enhancing message routing within the Cosmos SDK. The implementation appears straightforward and adheres to Go best practices. However, ensure that all references to the old method nameResponseNameByRequestName
across the codebase have been updated toResponseNameByMsgName
to maintain consistency and avoid potential runtime errors.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm, but i think we'll need to investigate if the InvokeUntyped API is good enough and safe
I have added tests, and migrating gov to use it here: #19481. |
Description
ref: #19542
Implement msg router service on main.
Once this is merged, I'll be adding the same in runtime/v2
Additionally, I'll update main to use the service in gov, group and authz
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...
!
in the type prefix if API or client breaking changeCHANGELOG.md
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...
Summary by CodeRabbit
keys show
command.Keeper
struct in various modules to correctly utilize the environment for event service access, addressing issues with message handling and routing.