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

Proto Auditing: Replace ID with Id #7032

Merged
merged 6 commits into from
Aug 14, 2020
Merged

Proto Auditing: Replace ID with Id #7032

merged 6 commits into from
Aug 14, 2020

Conversation

amaury1093
Copy link
Contributor

@amaury1093 amaury1093 commented Aug 13, 2020

closes #7033

Description

In proto files, don't allow customname which renames Id to ID.

Rationale

In our proto files, we sometimes use gogoproto's customname tag to rename fields, e.g. ClientId to ClientID, to fit what the Go linter recommends. In the generated *.pb.go files, we indeed see fields with ...ID (capitalized).

In #6918, we are adding grpc-gateway, who generates other files *.pb.gw.go. However, grpc-gateway ignores gogoproto's customname tag, and outputs fields with ...Id (PascalCase). See here for an example.

The Go compiler then obviously complains.

Potential solutions

  1. Create a PR on grpc-gateway, to make them take into account gogoproto.
  2. Add some plugins/hacks in our ./scripts to manually change Id->ID inside grpc-gateway-generated files *.pb.gw.go.
  3. Don't allow custonname on Id renaming.

This PR implements 3.

Notes

  • Most of the changes happened in ibc proto files.
  • You're still free to use ...ID in variable names and elsewhere in the code, so this PR creates some small inconsistencies in namings.
  • I didn't remove all custonnames (e.g. Ed25519->ED25519, Url->URL are kept). When generating grpc-gateway files, they didn't seem to interfere. This PR only changes ID->Id, as these were the ones that made the compiler shout.

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

@codecov
Copy link

codecov bot commented Aug 13, 2020

Codecov Report

Merging #7032 into master will increase coverage by 0.41%.
The diff coverage is 83.67%.

@@            Coverage Diff             @@
##           master    #7032      +/-   ##
==========================================
+ Coverage   61.56%   61.98%   +0.41%     
==========================================
  Files         421      520      +99     
  Lines       25463    32015    +6552     
==========================================
+ Hits        15677    19843    +4166     
- Misses       8433    10542    +2109     
- Partials     1353     1630     +277     

@colin-axner
Copy link
Contributor

colin-axner commented Aug 13, 2020

this is sad from an aesthetic point of view 😢 , but understandable. Could we open an issue to have a short ADR on why we don't use "ID" so future implementers can be aware of the potential issue. Literally could be a copy paste of what you wrote in the pr description, but then I could link the ADR in the IBC code spec's

ref on why ADR is useful here

@amaury1093
Copy link
Contributor Author

@colin-axner yes, see #7033.

Copy link
Contributor

@colin-axner colin-axner left a comment

Choose a reason for hiding this comment

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

could you update IBC specs 🙏

proto/cosmos/gov/v1beta1/gov.proto Show resolved Hide resolved
@fedekunze fedekunze added the T: API Breaking Breaking changes that impact APIs and the SDK only (not state machine). label Aug 13, 2020
Copy link
Collaborator

@fedekunze fedekunze left a comment

Choose a reason for hiding this comment

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

utACK

Copy link
Collaborator

@anilcse anilcse left a comment

Choose a reason for hiding this comment

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

lgtm

@fedekunze fedekunze added the A:automerge Automatically merge PR once all prerequisites pass. label Aug 14, 2020
@mergify mergify bot merged commit 5559af8 into master Aug 14, 2020
@mergify mergify bot deleted the am-proto-id branch August 14, 2020 08:55
@dongsam dongsam mentioned this pull request Jun 2, 2021
9 tasks
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.

Don't allow custonname which renames Id to ID
4 participants