-
Notifications
You must be signed in to change notification settings - Fork 264
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
gRPC API Redux #296
gRPC API Redux #296
Conversation
note that I was forced to copy files over from the other branch rather than try to rebase because the repositories had diverged so much that it not worth the effort |
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.
Thanks for picking this up! This still needs a bit of work, let me know if you're up for it or if you'd like a hand from someone more familiar with Go.
Ok so I think I have done everything we've discussed up to now. In the end the methods added were:
I haven't written tests yet for any of the new methods, I was thinking I would write them for each one. However if there any additional tests requested, now would be the time to make sure. |
Thanks @blinky3713, that's awesome! Would you like me to do another pass over this now, or wait until all unresolved comments have been addressed? As for tests, it's always desirable with more tests, but since this is just a thin wrapper it should be sufficient as a start to just check that all gRPC and HTTP methods work and that all parameters are properly passed through. |
@erikgrinaker I still have some of the smaller initial comments to address, I will ping you when it's ready for final review. |
@erikgrinaker I think it's ready for a final review, I don't understand this conflicting I didn't include tests for My test for I built a docker image and tested against
Is there something I'm missing about how keys have to be formatted? |
also as a side note, the linters are all broken:
(base) ✘ ✝ code/golang/iavl martin/grpc golangci-lint run --out-format=github-actions --timeout 10m
::error file=benchmarks/bench_test.go,line=70,col=13::G404: Use of weak random number generator (math/rand instead of crypto/rand) (gosec)
::error file=benchmarks/bench_test.go,line=89,col=15::G404: Use of weak random number generator (math/rand instead of crypto/rand) (gosec)
::error file=benchmarks/bench_test.go,line=128,col=16::G404: Use of weak random number generator (math/rand instead of crypto/rand) (gosec)
|
Sorry for not getting back to you here @blinky3713 - this weekend is pretty busy, but I'll have a look on Monday for sure. |
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.
This looks great, thanks for seeing this through! And props for doing it in a language you're not familiar with! Left some minor comments.
|
Add them to
You have to expand the command output in the Github lint job output (not very intuitive, I agree). It's complaining about this:
Just remove the |
Remove some of the |
I have made all of the requested changes and updated the example in the README. I'm still getting a conflicting error in This should be the last thing so just tell me what else I can do and hopefully that will be it. |
@erikgrinaker any advice on this last little step ? |
Sorry again for the late reply, I was on vacation last week.
Ah. Yes, this is a Git conflict. You'll need to merge |
🎉 |
🎉! Unfortunately, the panic handler isn't working. You're installing it for the HTTP server, which is running in a separate goroutine, but not for the gRPC server in the main thread - so when the main gRPC panics it takes down the whole process. You can test this by e.g. running Here's a patch which fixes it, be sure to run diff --git a/cmd/iavlserver/main.go b/cmd/iavlserver/main.go
index 9220427..346276b 100644
--- a/cmd/iavlserver/main.go
+++ b/cmd/iavlserver/main.go
@@ -14,6 +14,7 @@ import (
"syscall"
"github.com/gogo/gateway"
+ grpc_recovery "github.com/grpc-ecosystem/go-grpc-middleware/recovery"
"github.com/grpc-ecosystem/grpc-gateway/runtime"
"github.com/pkg/errors"
dbm "github.com/tendermint/tm-db"
@@ -64,8 +65,10 @@ func main() {
log.Fatalf("failed to listen on %s: %s", *gRPCEndpoint, err)
}
- var svrOpts []grpc.ServerOption
- grpcServer := grpc.NewServer(svrOpts...)
+ grpcServer := grpc.NewServer(
+ grpc.UnaryInterceptor(grpc_recovery.UnaryServerInterceptor()),
+ grpc.StreamInterceptor(grpc_recovery.StreamServerInterceptor()),
+ )
db, err := openDB()
if err != nil {
diff --git a/go.mod b/go.mod
index f863986..eb3a033 100644
--- a/go.mod
+++ b/go.mod
@@ -7,6 +7,7 @@ require (
github.com/gogo/gateway v1.1.0
github.com/gogo/protobuf v1.3.1
github.com/golang/protobuf v1.4.2
+ github.com/grpc-ecosystem/go-grpc-middleware v1.2.1
github.com/grpc-ecosystem/grpc-gateway v1.14.6
github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e // indirect
github.com/pkg/errors v0.9.1 |
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.
Cool cool, let's merge this thing! Thanks for the PR, you really went above and beyond here! 🚀
This PR builds on the work of @alexanderbez and @charlescrain to implement the gRPC server interface via protobuf service descriptions. Currently the only real difference between this branch and #184 is the
RWMutex
used to control reads and writes. I am not agolang
developer, but this seems pretty straight forward.In addition to the tests in
server_test.go
, I have tested hs-iavl-client against a docker image build from this branch and (after updating the library with the correct proto files) it passes. If you would like more tests, please specify here.