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

RegisterInterfaces registers service Msg type_urls #7671

Merged
merged 31 commits into from
Oct 28, 2020
Merged

Conversation

amaury1093
Copy link
Contributor

@amaury1093 amaury1093 commented Oct 26, 2020

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.

  • Targeted PR against correct branch (see CONTRIBUTING.md)
  • Linked to Github issue with discussion and accepted design OR link to spec that describes this work.
  • Code follows the module structure standards.
  • Wrote unit and integration tests
  • Updated relevant documentation (docs/) or specification (x/<module>/spec/)
  • Added relevant godoc comments.
  • Added a relevant changelog entry to the Unreleased section in CHANGELOG.md
  • Re-reviewed Files changed in the Github PR explorer
  • Review Codecov Report in the comment section below once CI passes

@amaury1093 amaury1093 force-pushed the am-7647-msgserver branch 2 times, most recently from 8e01a7e to 132e5eb Compare October 26, 2020 13:35
@codecov
Copy link

codecov bot commented Oct 26, 2020

Codecov Report

Merging #7671 into master will increase coverage by 0.00%.
The diff coverage is 72.72%.

@@           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     

types/msg_service.go Outdated Show resolved Hide resolved
baseapp/msg_service_router.go Outdated Show resolved Hide resolved
baseapp/msg_service_router.go Outdated Show resolved Hide resolved
baseapp/msg_service_router.go Outdated Show resolved Hide resolved
Copy link
Contributor

@clevinson clevinson left a 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)
Copy link
Contributor

Choose a reason for hiding this comment

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

We should make sure this addition is accounted for in the "building a module" docs that @blushi is updating in #7660

Comment on lines 43 to 44
// This function PANICs if it is called before the the service `Msg`s have been
// registered using RegisterInterfaces.
Copy link
Contributor Author

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.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Yes!

@amaury1093 amaury1093 mentioned this pull request Oct 27, 2020
11 tasks
@amaury1093 amaury1093 added the A:automerge Automatically merge PR once all prerequisites pass. label Oct 27, 2020
Co-authored-by: Marie Gauthier <marie.gauthier63@gmail.com>
Copy link
Collaborator

@robert-zaremba robert-zaremba left a 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.

Comment on lines 43 to 44
// This function PANICs if it is called before the the service `Msg`s have been
// registered using RegisterInterfaces.
Copy link
Collaborator

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.
Copy link
Collaborator

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)
Copy link
Collaborator

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
}
Copy link
Collaborator

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?

Copy link
Contributor Author

@amaury1093 amaury1093 Oct 28, 2020

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),
)
Copy link
Collaborator

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.

@mergify mergify bot merged commit 82f15f3 into master Oct 28, 2020
@mergify mergify bot deleted the am-7647-msgserver branch October 28, 2020 19:20
clevinson pushed a commit that referenced this pull request Oct 29, 2020
* 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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A:automerge Automatically merge PR once all prerequisites pass. C:Encoding
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Register MsgServer type URLs in AppModuleBasic.RegisterInterfaces
5 participants