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

Make sdk.Msg implement proto.Message #6327

Merged
merged 10 commits into from
Jun 3, 2020
Merged

Make sdk.Msg implement proto.Message #6327

merged 10 commits into from
Jun 3, 2020

Conversation

aaronc
Copy link
Member

@aaronc aaronc commented Jun 2, 2020

ref: #6213

This PR makes sdk.Msg inherit proto.Message. As a result all sdk.Msg types now must use pointer sematnics.

This is necessary for packing sdk.Msgs in proto Anys and in particular to complete #6216.

In some cases I forced certain Msg's to implement proto.Message with dummy implementations (in particular ibc/07-tendermint and a few test Msg's), but I tried to avoid this where possible and added a proto file for ibc/09-localhost MsgCreateClient.


For contributor use:

  • 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

@codecov
Copy link

codecov bot commented Jun 2, 2020

Codecov Report

Merging #6327 into master will decrease coverage by 0.03%.
The diff coverage is 69.51%.

@@            Coverage Diff             @@
##           master    #6327      +/-   ##
==========================================
- Coverage   55.69%   55.66%   -0.04%     
==========================================
  Files         448      448              
  Lines       26941    26956      +15     
==========================================
  Hits        15005    15005              
- Misses      10862    10877      +15     
  Partials     1074     1074              

@aaronc aaronc added T: API Breaking Breaking changes that impact APIs and the SDK only (not state machine). R4R labels Jun 2, 2020
@aaronc aaronc marked this pull request as ready for review June 2, 2020 22:57
@aaronc aaronc marked this pull request as draft June 2, 2020 22:59
@aaronc aaronc marked this pull request as ready for review June 2, 2020 23:02
@jaekwon
Copy link
Contributor

jaekwon commented Jun 3, 2020

It isn't clear why Msgs need to become pointer receivers everywhere. Msgs should stay immutable, and keeping them as non-pointers helps with that (though not all the way, as slices for example are still mutable, but regardless it helps). The Reset() function could still take a pointer receiver but everything else can and arguably should stay the same.

Pointer-fying also comes with baggage like needing to check for nils, so ideally we don't change anything that isn't already working.

What is the API for unmarshaling any, UnmarshalAny()? The above should work for this purpose.

@alexanderbez
Copy link
Contributor

alexanderbez commented Jun 3, 2020

@jaekwon I believe specifically because:

This is necessary for packing sdk.Msgs in proto Anys

I advocated for clear semantics -- pointer or non-pointer only, don't mix. @aaronc brought to my attention that in order for a sdk.Msg to be packed into a tx's Any, it must obey proto.Message, which requires pointer semantics

@aaronc
Copy link
Member Author

aaronc commented Jun 3, 2020

Protobuf code generation only supports pointer types. That is why the change is needed. In the future making changes to the code generation itself could be an option, but it isn't right now. So unfortunately l don't think the migration can proceed without this change.

Copy link
Contributor

@alexanderbez alexanderbez left a comment

Choose a reason for hiding this comment

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

conceptACK

@aaronc aaronc added the A:automerge Automatically merge PR once all prerequisites pass. label Jun 3, 2020
@mergify mergify bot merged commit 2e11c81 into master Jun 3, 2020
@mergify mergify bot deleted the aaronc/6213-msg-proto branch June 3, 2020 19:52
@clevinson clevinson added this to the v0.39 milestone Jun 11, 2020
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. T: API Breaking Breaking changes that impact APIs and the SDK only (not state machine).
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants