[bisq-network/bisq] POC Bisq gRPC for gRPC and REST clients (#4275)

Stan notifications at github.com
Tue May 26 22:58:14 UTC 2020


This is an experiment to see how the Bisq daemon could work with REST clients.  

There is a single gRPC `CallService` that takes a random string (method name + params) from either gRPC or REST clients, and returns a gRPC (HTTP 2) or REST (HTTP 1.1) response.  All method/parameter validation happens on the server.  

For REST clients, there is one `POST /v1/call` endpoint.  Service method names and parameters are sent in the HTTP request body, for example:

	curl -v -X POST http://host:port/v1/call -H "Authorization:xyz"  -H "Content-Type: application/json" -d '{"params": "method arg1 \"arg2\" arg3"}'

Like in the gRPC client/server implementation in the main branch, gRPC server authentication is as simple as possible -- no TLS.
	
Since there is no `grpc-web` or `grpc-gateway` Java implementation yet, I created separate [Golang based HTTP proxy]( https://github.com/ghubstan/bisq-grpc-gateway) to forward REST requests.  To be explicit, REST requests must go through the [bisq-grpc-gateway](https://github.com/ghubstan/bisq-grpc-gateway) prototype.  Not having a Java/HTTP gateway may result in an immediate `NACK`, but `proxy.go` should never grow too complex, and it can be replaced when/if `grpc-web` for Java is released.  

One of the primary motivations for experimenting with this now has been @cbeams's discussion about the need to serve REST clients in general, and specifically, getting Bisq deployed in [mNode](https://mynodebtc.com).

Also included in this PR is a possible solution to the `server not available` problem.  The idea is that if the server cannot access a wallet's balance for any reason, it cannot do anything.  See commit 1011809.

Hopefully, commits examined in order best explains how this POC works.
You can view, comment on, or merge this pull request online at:

  https://github.com/bisq-network/bisq/pull/4275

-- Commit Summary --

  * Add new single-endpoint gRPC 'CallService'
  * Extract HTTP 1.1 auth header in auth interceptor
  * Define CoreApi Method enum
  * Add CoreHelpService
  * Inject new gRPC CallService into GrpcServer
  * Throw gRPC StatusRuntimeException if params missing
  * Throw gRPC INVALID_ARG ex for unsupported method
  * Throw "server not available" ex if balance is N/A
  * Call the CoreApi methods
  * Add new single endpoint gRPC client
  * Update bats gRPC test script
  * Add new HTTP 1.1 / REST test script
  * Move test.http along side test.sh

-- File Changes --

    M build.gradle (2)
    A cli/src/main/java/bisq/cli/CliMainV1.java (160)
    A cli/test.http (79)
    M cli/test.sh (92)
    M core/src/main/java/bisq/core/grpc/CoreApi.java (33)
    A core/src/main/java/bisq/core/grpc/CoreHelpService.java (30)
    A core/src/main/java/bisq/core/grpc/GrpcCallService.java (42)
    A core/src/main/java/bisq/core/grpc/GrpcCoreBridge.java (227)
    M core/src/main/java/bisq/core/grpc/GrpcServer.java (8)
    M core/src/main/java/bisq/core/grpc/GrpcWalletService.java (1)
    A core/src/main/java/bisq/core/grpc/Method.java (11)
    M core/src/main/java/bisq/core/grpc/PasswordAuthInterceptor.java (18)
    M proto/src/main/proto/grpc.proto (17)

-- Patch Links --

https://github.com/bisq-network/bisq/pull/4275.patch
https://github.com/bisq-network/bisq/pull/4275.diff

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/bisq-network/bisq/pull/4275
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.bisq.network/pipermail/bisq-github/attachments/20200526/4e29f4a9/attachment-0001.html>


More information about the bisq-github mailing list