-
Notifications
You must be signed in to change notification settings - Fork 3.8k
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
feat: add autocli service proto #13597
Conversation
Following up on #13281 (comment), the rationale for putting Some of the earlier reflection services in Happy to consider alternate approaches. One alternative is to just add an endpoint to list all the file descriptors and then grpc reflection can be used to query each one individually. Currently, grpc reflection doesn't have a way to list all descriptors. The downside of this approach is that it's more work on the client side to build the full FileDescriptorSet. Also, grpc reflection by default is implemented as a blackbox - we probably want to re-implement to make sure we're actually serving the right descriptors (which could be a problem with mixed gogo and proto v2 code and future semver codegen ideas). |
Codecov Report
Additional details and impacted files@@ Coverage Diff @@
## main #13597 +/- ##
==========================================
+ Coverage 54.69% 54.76% +0.07%
==========================================
Files 645 652 +7
Lines 55745 56023 +278
==========================================
+ Hits 30490 30683 +193
- Misses 22765 22833 +68
- Partials 2490 2507 +17
|
|
||
// FileDescriptorSet returns the full FileDescriptorSet of the app in order | ||
// to enable easier generation of dynamic clients. | ||
rpc FileDescriptorSet(QueryFileDescriptorSetRequest) returns (QueryFileDescriptorSetResponse) { |
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.
why not add this to
option go_package = "github.com/cosmos/cosmos-sdk/server/grpc/reflection/v2alpha1"; |
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.
Or reflection.v1beta1 (or mark it as v1).
I would put cosmos-related stuff here (e.g. chain id), and proto-related stuff (e.g. file descriptors) in cosmos.(base).reflection
, even though there's only one method there to get the FileDescriptors
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.
agree here. I would like this approach as it cleans up some random grpc services
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.
So how about moving the file descriptors query to cosmos.reflection.v1
(not sure we need base
) as the solo query there for now? And then we move or deprecate the stuff in the other reflection
packages piece by piece?
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 like this approach
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.
moved to cosmos.reflection.v1
. how does that look?
@tac0turtle @AmauryM one additional thing related to this PR in the context the of the presentation I gave on the ORM is that ideally the FileDescriptorSet and app config are committed to state (probably in the runtime module) whenver a chain starts or there is an upgrade. This way, if a light client wants to do proofs - first it does a proof on the app config + FileDescriptorSet and then it can prove anything else that uses the ORM. That maybe explains a bit why they're together here and the long term idea. But maybe it does make sense to put proto stuff in cosmos.reflection because it's more similar to grpc reflection. |
If we commit the FileDescriptorSet to state, then we're not allowed to modify the proto files between minor releases anymore, correct? Or in general how to deal with FileDescriptorSet mismatch between state and binary-embeded |
I don't think its a good idea to add it to consensus. we wouldn't be able to do non breaking things to proto files going forward |
Good point. What about adding app config to consensus? Or should we say those things are to be proven out of band? |
Then light clients would need 2 trusted sources: one for the initial header, and another for the filedescriptors. What we can do is only commit the |
Yeah, but maybe that's okay?
I'm fine to defer this decision till a bit later. Maybe we just do this basic query and deal with proofs when we get to that. |
@tac0turtle @AmauryM does this look better? Is |
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.
LGTM
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.
LGTM, but I would omit module_query_safe
service RemoteInfoService { | ||
// AppOptions returns the autocli options for all of the modules in an app. | ||
rpc AppOptions(AppOptionsRequest) returns (AppOptionsResponse) { | ||
option (cosmos.query.v1.module_query_safe) = false; |
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.
What's the benefit of adding this annotation here? I would omit if false, and add it only when true
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.
Because I don't ever expect it to be true and want to be explicit
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.
OK, maybe we can add a proto comment for this annotation why this is set to false explicitly. By scanning quickly, I initially thought it was true (because not omitted), and then I wondered why this particular query was set to false and not others.
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.
Added some comments. Does this look better @AmauryM ?
Co-authored-by: Amaury <[email protected]>
@AmauryM can you take another look? |
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.
LGTM
Tagging |
Description
Ref: #13282
Was part of #13281.
This adds two new gRPC query endpoints which the runtime module will implement:
/cosmos.reflection.v1.ReflectionService/FileDescriptors
- for the full file descriptor set/cosmos.autocli.v1.Query/AppOptions
- autocli app options for dynamic CLI generationautocli will use both of these to build dynamic CLIs.
Author Checklist
All items are required. Please add a note to the item if the item is not applicable and
please add links to any relevant follow up issues.
I have...
!
to the type prefix if API or client breaking changeCHANGELOG.md
Reviewers Checklist
All items are required. Please add a note if the item is not applicable and please add
your handle next to the items reviewed if you only reviewed selected items.
I have...
!
in the type prefix if API or client breaking change