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
Enable gRPC server reflection and CORS on HTTP service #2698
Conversation
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.
Looks useful; my only concern is any additional firewalls that will have to be set up by node operators.
I've added reflection to internal gRPC service also. @KentShikama reflection only creates one additional service on the same port so for firewall it is not an issue. This new service is also visible with the reflection. :) $ grpcurl -plaintext localhost:40401 list
coop.rchain.casper.protocol.DeployService
coop.rchain.casper.protocol.ProposeService
grpc.reflection.v1alpha.ServerReflection
$ grpcurl -plaintext localhost:40402 list
coop.rchain.casper.protocol.ProposeService
coop.rchain.node.model.Repl
grpc.reflection.v1alpha.ServerReflection |
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 don't understand how DeployServiceResponseMeta
will be used by the clients. Besides that LGTM
@tgrospic The firewall is for the protection of the node |
bors r+ |
@KentShikama reflection service should only expose meta info about proto definitions and can be protected with firewall as other services on the same port. @sebtomba I'm generating TypeScript definitions from proto files and I need type parameter for |
Build succeeded |
Overview
This PR has three parts:
JIRA ticket:
https://rchain.atlassian.net/browse/RCHAIN-3804
Notes
gRPC service reflection
Setup of reflection is based on grpc-java documentation gRPC Server Reflection Tutorial
With reflection service enabled client libraries with gRPC bindings can inspect Casper API without the need for source protobuf files. We can also use generic tools like grpcui, grpc-ui, grpcox or grpcurl to inspect schema and execute requests.
Static types for service responses inside Either
With reflection enabled it's still a problem to get information about type which Either holds for success value. Dynamically
type-url
resolves the type but in proto files this info is only in comments so to provide TypeScript definitions I have to parse proto files directly rnode-grpc-js.For reflection there is no workaround so I've added a new type
DeployEitherMeta
wich just holds dynamic value for each deploy method. The requirement is of course that names of the fields correspond exactly to name of the service methods. Unit responses are skipped like in comments.CORS enabled on HTTP endpoints
Currently it's not possible to make HTTP requests to RNode from the browser e.g.
fetch('http://node0.testnet.rchain-dev.tk:40403/status')
. RNode does not specify headers to allow browsers to accept responses from different domain than self. With CORS enabled RNode can be called from page on any domain.Examples
UI example with gRPCox.
Please make sure that this PR:
Bors cheat-sheet:
bors r+
runs integration tests and merges the PR (if it's approved),bors try
runs integration tests for the PR,bors delegate+
enables non-maintainer PR authors to run the above.