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

Require valid amino.* annotations #14682

Closed
3 tasks
Tracked by #13310
amaury1093 opened this issue Jan 18, 2023 · 10 comments
Closed
3 tasks
Tracked by #13310

Require valid amino.* annotations #14682

amaury1093 opened this issue Jan 18, 2023 · 10 comments

Comments

@amaury1093
Copy link
Contributor

amaury1093 commented Jan 18, 2023

Summary

Validate amino.* annotations:

  • Require that amino.name and amino.oneof_name proto annotations matches go-amino's RegisterConcrete name.
  • Make sure that all chains update their proto files to use:
    • amino.encoding, amino.message_encoding
    • amino.dont_omitempty, amino.field_name

ref: #13405 (comment)

Problem Definition

With #14353, SDK msgs can have an amino.name proto annotation to define how they are encoded in Anys in amino. This is the same functionality as aminoCdc.RegisterConcrete. We should:

  1. (ideal solution) either remove aminoCdc.RegisterConcrete altogether, but this needs Implement protoreflect based amino JSON encoder #10993
  2. (okay solution) or have some sort of validation that checks that the proto annotation string matches the string in RegisterConcrete

Solution

  • Validate amino.name against aminoCdc.RegisterConcrete registry
  • Validate amino.oneof_name against aminoCdc.RegisterConcrete registry
  • Validate amino.dont_omitempty, amino.field_name against existing gogoproto annotations.
@amaury1093 amaury1093 changed the title Require valid amino.name annotations. Require valid amino.name annotations Jan 18, 2023
@amaury1093 amaury1093 changed the title Require valid amino.name annotations Require valid amino.* annotations Feb 14, 2023
@kocubinski kocubinski self-assigned this Feb 16, 2023
@kocubinski
Copy link
Member

kocubinski commented Mar 15, 2023

The test suite in https://github.com/cosmos/cosmos-sdk/blob/e9478df1619d7d0845dab3308852a9e2948269ac/tests/integration/aminojson/aminojson_test.go seems robust enough to catch the consistencies described in this issue as in the case of #15165

This also raises the question for me; is fuzz testing (the approach in the test suite) good enough or do we need a set of deterministic rules?

@amaury1093
Copy link
Contributor Author

This also raises the question for me; is fuzz testing (the approach in the test suite) good enough or do we need a set of deterministic rules?

For a set of deterministic rules, we need a spec. However, go-amino implementation is currently the amino spec. So fuzz testing is IMO the best way to test that the new amino encoder is "spec"-compliant.

@amaury1093
Copy link
Contributor Author

My biggest concern here is not our own types, but making sure other chains adopt the new amino.* annotations correctly. I don't see each chain creating such a comprehensive test suite like ours.

Maybe an entry in the UPGRADING.md guide is enough. Or maybe it's a script that we write, that each chain runs before updating, which will modify the *.proto files to add the correct amino.name,dont_omitempty,message_encoding annotations.

The original issue proposed a startup check, which may not be the ideal UX, but I believe is still the simplest solution.

@tac0turtle
Copy link
Member

tac0turtle commented Mar 16, 2023

For a time being its either/or right, Its not one or the other?

@kocubinski
Copy link
Member

Maybe the first step to tackling this issue ought to be just defining the spec of valid amino annotations as docs? Also if that already exists let me know where.

@amaury1093
Copy link
Contributor Author

I think that's a good idea 👍. There are no such docs currently, the only thing we have written are the proto comments.

@kocubinski
Copy link
Member

Related work: #13793

@amaury1093
Copy link
Contributor Author

Related work: #13793

Also see the higher-level tracking issue #13310

@tac0turtle
Copy link
Member

closing as we added this to documentation

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants
@kocubinski @amaury1093 @tac0turtle and others