-
Notifications
You must be signed in to change notification settings - Fork 3.7k
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 gRPC requests go through tendermint Query #8549
Merged
Merged
Changes from 3 commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
e0e2242
Make gRPC requests go through tendermint Query
amaury1093 1f5cdd1
Remove commented code
amaury1093 db1ccb9
Dry run in InitChain?
amaury1093 af70bf7
Save type of first run
amaury1093 66b8fb1
Add metadata in repsonse
amaury1093 437ada0
Factorize some code
amaury1093 7c44ee5
Fix lint
amaury1093 38775aa
Update comments
amaury1093 e274572
Merge branch 'master' into am-grpc-tm
amaury1093 40afd23
Fix md test
amaury1093 97178dc
Fix test expected
amaury1093 2c5a017
Don't put RunGRPCQuery as clientCtx method
amaury1093 2cc56a0
Merge branch 'master' into am-grpc-tm
amaury1093 6f24859
Merge branch 'master' into am-grpc-tm
amaury1093 31ac78a
Merge branch 'master' of ssh://github.com/cosmos/cosmos-sdk into am-g…
amaury1093 60760d1
Update baseapp/grpcserver.go
amaury1093 ba06cd4
Merge branch 'am-grpc-tm' of ssh://github.com/cosmos/cosmos-sdk into …
amaury1093 de3c822
Address review comments
amaury1093 2405701
Merge branch 'master' into am-grpc-tm
amaury1093 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Status update: as per #8549 (comment), I added a
returnType map[string]reflect.Type
which maps each FQ method name to its return type. This map get populated when callingdryRunMethodHandlers
, but i'm not sure from where to call it.(Note: to dry run the method handlers, we need a
context.Context
, and I'm passing asdk.WrapSDKContext(ctx)
right now)I tried:
returnTypes
immediately onRegisterService
(so that we wouldn't even need a separatedryRunMethodHandlers
function) using a dummysdk.Context
. But it panicked on some nil stores.dryRunMethodHandlers
in InitChain, panicking for unmarshalling empty bytes request.I'm thinking of a way to avoid panicking on all grpc query handlers. Maybe there's a way to do it with
context.CancelFunc
instead ofsdk.WrapSDKContext(someSdkCtx)
? Some other ideas?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.
You can pre-run these in
RegisterService
I think. I'll take a quick lookThere 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.
Actually looks pretty nasty... I remember we had this issue before.
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.
Actually if this is all the same process we can just capture the return type the first time a real query runs. I know that's super hacky but it should work unless someone is running grpc stand-alone.
A more correct way would be - read grpc schema from message descriptors, then look up the return type name, then look up the actual go type from the proto type registry.
What do you think?
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.
The grpc reflection way also seems more correct to me, however:
I can't seem to find where to find the mapping of fq method name to return type (in grpc-go code)
For now I pushed this version
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.
Get the file descriptor with
proto.FileDescriptor
and the go type withproto.MessageType
. Does that help? This involves actually parsing aFileDescriptor
...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.
Ah right. I would need to define some heuristics to guess the file name from the fq method name, right? Will try that, but seems hacky too...
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 think it'll be hacky, we have e.g. FileDescriptor for
cosmos/base/reflection/v1beta1/reflection.proto
, and there's no way we can guess the file path from the fq service name (e.g.cosmos.base.reflection.v1beta1.ReflectionService
), unless introducing a lot of ifs.Maybe let's just stay with capturing the return type on 1st call?
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.
If we have access to a reflection grpc service then we can actually just use that to get the descriptors. But honestly hopefully this is just a short term fix and we deal with the concurrency issues soon. I would hate for the whole abci pipeline to be forever single threaded.
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.
We'd need a client for that, it seems overkill. i also remember @clevinson running into issues with reflection because we're using gogoproto.
anyways, the current approach should be good enough for now.