-
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
RegisterInterfaces registers service Msg type_urls #7671
Conversation
8e01a7e
to
132e5eb
Compare
Codecov Report
@@ Coverage Diff @@
## master #7671 +/- ##
=======================================
Coverage 54.11% 54.12%
=======================================
Files 611 611
Lines 38616 38631 +15
=======================================
+ Hits 20898 20909 +11
- Misses 15585 15590 +5
+ Partials 2133 2132 -1 |
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.
utACK
) | ||
|
||
// RegisterInterfaces register the ibc transfer module interfaces to protobuf | ||
// Any. | ||
func RegisterInterfaces(registry codectypes.InterfaceRegistry) { | ||
registry.RegisterImplementations((*sdk.Msg)(nil), &MsgTransfer{}) | ||
|
||
msgservice.RegisterMsgServiceDesc(registry, &_Msg_serviceDesc) |
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.
Co-authored-by: Robert Zaremba <robert@zaremba.ch>
Co-authored-by: Robert Zaremba <robert@zaremba.ch>
Co-authored-by: Robert Zaremba <robert@zaremba.ch>
…k into am-7647-msgserver
baseapp/msg_service_router.go
Outdated
// This function PANICs if it is called before the the service `Msg`s have been | ||
// registered using RegisterInterfaces. |
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.
I believe "running RegisterInterfaces
before running RegisterService
" is also worth mentioning in docs.
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.
Yes!
Co-authored-by: Marie Gauthier <marie.gauthier63@gmail.com>
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.
Left few comments and approving.
baseapp/msg_service_router.go
Outdated
// This function PANICs if it is called before the the service `Msg`s have been | ||
// registered using RegisterInterfaces. |
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.
Yes!
if !ok { | ||
// We panic here because there is no other alternative and the app cannot be initialized correctly | ||
// this should only happen if there is a problem with code generation in which case the app won't | ||
// work correctly anyway. |
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.
good comment 👍
panic(fmt.Errorf("can't register request type %T for service method %s", i, fqMethod)) | ||
} | ||
|
||
registry.RegisterCustomTypeURL((*sdk.MsgRequest)(nil), fqMethod, msg) |
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.
TBH, I don't know why we are typed nil
using it in SDK. It's good when we will like to optimize for memory allocation. But here this is called / created only once per app lifetime. So how about using new(sdk.MsgRequest)
?
// gRPC NOOP interceptor | ||
func noopInterceptor(_ context.Context, _ interface{}, _ *grpc.UnaryServerInfo, _ grpc.UnaryHandler) (interface{}, error) { | ||
return nil, nil | ||
} |
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.
We already have it in baseapp/msg_service_router.go
. Maybe we can move it somewhere and export it?
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.
I actually moved this function from baseapp/msg_service_router.go
to here 👍
fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), | ||
fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()), | ||
fmt.Sprintf("--gas=%d", flags.DefaultGasLimit), | ||
) |
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 is an integration test. Not related to this PR, because other code in this test is doing a similar things. In the future we will need to mark this tests as such and skip them if we just want to do unit-tests.
* Add RegisterMsgServiceDesc * Refactor newSendTxMsgServiceCmd * Add test * Register in all modules * Remove RegisterMsgServiceDesc from baseapp * Add explicit error message * Add comment * Update comment * Add test * Update comment * Remove duplicate import * Fix lint * Forgot vesting * Fix lint * Fix test * Put in types/module * Put in types/msgservice * Add comment about panic * Update baseapp/msg_service_router.go Co-authored-by: Robert Zaremba <robert@zaremba.ch> * Update baseapp/msg_service_router.go Co-authored-by: Robert Zaremba <robert@zaremba.ch> * Update baseapp/msg_service_router.go Co-authored-by: Robert Zaremba <robert@zaremba.ch> * Add comment * Add better test * Update baseapp/msg_service_router.go Co-authored-by: Marie Gauthier <marie.gauthier63@gmail.com> Co-authored-by: Robert Zaremba <robert@zaremba.ch> Co-authored-by: Marie Gauthier <marie.gauthier63@gmail.com> Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
Description
closes: #7647
Before we can merge this PR, please make sure that all the following items have been
checked off. If any of the checklist items are not applicable, please leave them but
write a little note why.
docs/
) or specification (x/<module>/spec/
)godoc
comments.Unreleased
section inCHANGELOG.md
Files changed
in the Github PR explorerCodecov Report
in the comment section below once CI passes