From ca2aae194e16982fd4e8b10a8787d11f171d8bf4 Mon Sep 17 00:00:00 2001 From: Tomislav Grospic Date: Thu, 29 Aug 2019 20:32:08 +0200 Subject: [PATCH 1/5] Add protobuf reflection to Deploy and Propose gRPC service --- build.sbt | 1 + node/src/main/scala/coop/rchain/node/api/package.scala | 2 ++ project/Dependencies.scala | 1 + 3 files changed, 4 insertions(+) diff --git a/build.sbt b/build.sbt index 7390431bcad..1a912392175 100644 --- a/build.sbt +++ b/build.sbt @@ -258,6 +258,7 @@ lazy val node = (project in file("node")) apiServerDependencies ++ commonDependencies ++ kamonDependencies ++ protobufDependencies ++ Seq( catsCore, grpcNetty, + grpcServices, jline, scallop, scalaUri, diff --git a/node/src/main/scala/coop/rchain/node/api/package.scala b/node/src/main/scala/coop/rchain/node/api/package.scala index 6675644a08d..9bc9e14c394 100644 --- a/node/src/main/scala/coop/rchain/node/api/package.scala +++ b/node/src/main/scala/coop/rchain/node/api/package.scala @@ -13,6 +13,7 @@ import coop.rchain.node.model.repl._ import coop.rchain.rholang.interpreter.Runtime import coop.rchain.shared._ import io.grpc.netty.NettyServerBuilder +import io.grpc.protobuf.services.ProtoReflectionService import monix.eval.Task import monix.execution.Scheduler @@ -70,6 +71,7 @@ package object api { ProposeServiceGrpcMonix .bindService(ProposeGrpcService.instance(blockApiLock, tracing), grpcExecutor) ) + .addService(ProtoReflectionService.newInstance()) .build ) } diff --git a/project/Dependencies.scala b/project/Dependencies.scala index 3b100e067fb..19d8d0f40c7 100644 --- a/project/Dependencies.scala +++ b/project/Dependencies.scala @@ -60,6 +60,7 @@ object Dependencies { val scalapbRuntimeLib = "com.thesamet.scalapb" %% "scalapb-runtime" % scalapb.compiler.Version.scalapbVersion val scalapbRuntimegGrpc = "com.thesamet.scalapb" %% "scalapb-runtime-grpc" % scalapb.compiler.Version.scalapbVersion val grpcNetty = "io.grpc" % "grpc-netty" % scalapb.compiler.Version.grpcJavaVersion + val grpcServices = "io.grpc" % "grpc-services" % scalapb.compiler.Version.grpcJavaVersion val nettyBoringSsl = "io.netty" % "netty-tcnative-boringssl-static" % "2.0.8.Final" val nettyTcnative = "io.netty" % "netty-tcnative" % "2.0.8.Final" classifier osClassifier val nettyTcnativeLinux = "io.netty" % "netty-tcnative" % "2.0.8.Final" classifier "linux-x86_64" From 96aaa3f3e10e2de08728ef0a9dcbb44d64e77183 Mon Sep 17 00:00:00 2001 From: Tomislav Grospic Date: Thu, 29 Aug 2019 20:32:39 +0200 Subject: [PATCH 2/5] Enable CORS for HTTP endpoints --- node/src/main/scala/coop/rchain/node/NodeRuntime.scala | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/node/src/main/scala/coop/rchain/node/NodeRuntime.scala b/node/src/main/scala/coop/rchain/node/NodeRuntime.scala index 5a2ae7b724f..c1405a7625c 100644 --- a/node/src/main/scala/coop/rchain/node/NodeRuntime.scala +++ b/node/src/main/scala/coop/rchain/node/NodeRuntime.scala @@ -42,6 +42,7 @@ import monix.eval.{Task, TaskLocal} import monix.execution.Scheduler import org.http4s.implicits._ import org.http4s.server.blaze._ +import org.http4s.server.middleware._ import org.http4s.server.Router import scala.concurrent.duration._ @@ -141,9 +142,9 @@ class NodeRuntime private[node] ( .bindHttp(conf.server.httpPort, "0.0.0.0") .withHttpApp( Router( - "/metrics" -> prometheusService, - "/version" -> VersionInfo.service[Task], - "/status" -> StatusInfo.service[Task] + "/metrics" -> CORS(prometheusService), + "/version" -> CORS(VersionInfo.service[Task]), + "/status" -> CORS(StatusInfo.service[Task]) ).orNotFound ) .resource From 3f708f842498321ff78b94fe9c47a08019af2877 Mon Sep 17 00:00:00 2001 From: Tomislav Grospic Date: Thu, 29 Aug 2019 20:33:52 +0200 Subject: [PATCH 3/5] Add DeployEitherMeta to proto definitions (response types reflection) --- models/src/main/protobuf/DeployService.proto | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/models/src/main/protobuf/DeployService.proto b/models/src/main/protobuf/DeployService.proto index cb3f774b238..0c49008e443 100644 --- a/models/src/main/protobuf/DeployService.proto +++ b/models/src/main/protobuf/DeployService.proto @@ -185,3 +185,17 @@ message WaitingContinuationInfo { repeated BindPattern postBlockPatterns = 1; Par postBlockContinuation = 2; } + +// This type holds return types for success values inside Either for deploy service methods +message DeployEitherMeta { + DeployServiceResponse DoDeploy = 1; + BlockQueryResponse getBlock = 2; + VisualizeBlocksResponse visualizeDag = 3; + LightBlockInfo showMainChain = 4; + LightBlockInfo getBlocks = 5; + ListeningNameDataResponse listenForDataAtName = 6; + ListeningNameContinuationResponse listenForContinuationAtName = 7; + LightBlockQueryResponse findDeploy = 8; + PrivateNamePreviewResponse previewPrivateNames = 9; + BlockQueryResponse lastFinalizedBlock = 10; +} From f5a3c17081c4e8c2c9a2238cc492ba67fb905c13 Mon Sep 17 00:00:00 2001 From: Tomislav Grospic Date: Fri, 30 Aug 2019 14:45:29 +0200 Subject: [PATCH 4/5] Add protobuf reflection to internal gRPC service --- node/src/main/scala/coop/rchain/node/api/package.scala | 1 + 1 file changed, 1 insertion(+) diff --git a/node/src/main/scala/coop/rchain/node/api/package.scala b/node/src/main/scala/coop/rchain/node/api/package.scala index 9bc9e14c394..8c7cfb3f193 100644 --- a/node/src/main/scala/coop/rchain/node/api/package.scala +++ b/node/src/main/scala/coop/rchain/node/api/package.scala @@ -49,6 +49,7 @@ package object api { ProposeServiceGrpcMonix .bindService(ProposeGrpcService.instance(blockApiLock, tracing), grpcExecutor) ) + .addService(ProtoReflectionService.newInstance()) .build ) From 64fe55e745d0239d74cb972ee0b5d89f606f4f24 Mon Sep 17 00:00:00 2001 From: Tomislav Grospic Date: Sun, 1 Sep 2019 20:13:37 +0200 Subject: [PATCH 5/5] Predictable name for new response types definition --- models/src/main/protobuf/DeployService.proto | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/models/src/main/protobuf/DeployService.proto b/models/src/main/protobuf/DeployService.proto index 0c49008e443..ead8ae8cfd0 100644 --- a/models/src/main/protobuf/DeployService.proto +++ b/models/src/main/protobuf/DeployService.proto @@ -23,7 +23,7 @@ option (scalapb.options) = { }; // Use `DoDeploy` to queue deployments of Rholang code and then -// `createBlock` to make a new block with the results of running them +// `ProposeService.propose` to make a new block with the results of running them // all. // // To get results back, use `listenForDataAtName`. @@ -186,8 +186,8 @@ message WaitingContinuationInfo { Par postBlockContinuation = 2; } -// This type holds return types for success values inside Either for deploy service methods -message DeployEitherMeta { +// This type holds response types inside Either for DeployService methods +message DeployServiceResponseMeta { DeployServiceResponse DoDeploy = 1; BlockQueryResponse getBlock = 2; VisualizeBlocksResponse visualizeDag = 3;