Skip to content
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

NODE-2625 Fixed GRPC Reflection API #3910

Merged
merged 6 commits into from
Nov 7, 2023
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion node-it/src/test/scala/com/wavesplatform/it/Docker.scala
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ class Docker(
val containerConfig = ContainerConfig
.builder()
.image(imageName)
.exposedPorts(s"$internalDebuggerPort")
.exposedPorts(if (Try(nodeConfig.getStringList("waves.extensions").contains("com.wavesplatform.events.BlockchainUpdates")).getOrElse(false)) "6881" else s"$internalDebuggerPort")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This completely replaces port mapping when BU is enabled, which means one will not be able to debug the node inside the container. Please change this to always expose debug port, and expose BU port as needed.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

.networkingConfig(ContainerConfig.NetworkingConfig.create(Map(wavesNetwork.name() -> endpointConfigFor(nodeName)).asJava))
.hostConfig(hostConfig)
.env(envs*)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
package com.wavesplatform.it.grpc

import com.typesafe.config.Config
import com.wavesplatform.it.NodeConfigs
import com.wavesplatform.it.NodeConfigs.Default
import com.wavesplatform.it.sync.grpc.GrpcBaseTransactionSuite
import io.grpc.{CallOptions, ManagedChannelBuilder}
import io.grpc.reflection.v1alpha.ServerReflectionGrpc.getServerReflectionInfoMethod
import io.grpc.reflection.v1alpha.ServerReflectionRequest
import io.grpc.stub.ClientCalls

import scala.util.Try

class GrpcReflectionApiSuite extends GrpcBaseTransactionSuite {
override protected def nodeConfigs: Seq[Config] =
NodeConfigs
.Builder(Default, 1, Seq())
.overrideBase(_.quorum(0))
.overrideBase(_.raw("waves.extensions = [com.wavesplatform.api.grpc.GRPCServerExtension\ncom.wavesplatform.events.BlockchainUpdates]"))
.buildNonConflicting()

test("successful getServerReflectionInfo call for BU") {
val buChannel = ManagedChannelBuilder
.forAddress(nodes.head.networkAddress.getHostString, nodes.head.nodeExternalPort(6881))
.usePlaintext()
.build()
val call = buChannel.newCall(getServerReflectionInfoMethod, CallOptions.DEFAULT)
val request = ServerReflectionRequest.newBuilder().setFileContainingSymbol("waves.events.grpc.BlockchainUpdatesApi").build()
val result = Try(ClientCalls.blockingUnaryCall(call, request))
result.isSuccess shouldBe true
result.get.hasFileDescriptorResponse shouldBe true
}

test("successful getServerReflectionInfo call for GRPC methods") {
val call = nodes.head.grpcChannel.newCall(getServerReflectionInfoMethod, CallOptions.DEFAULT)
val request = ServerReflectionRequest.newBuilder().setFileContainingSymbol("waves.node.grpc.BlocksApi").build()
val result = Try(ClientCalls.blockingUnaryCall(call, request))
result.isSuccess shouldBe true
result.get.hasFileDescriptorResponse shouldBe true
}
}
16 changes: 10 additions & 6 deletions project/Dependencies.scala
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import org.portablescala.sbtplatformdeps.PlatformDepsPlugin.autoImport.*
import sbt.{Def, *}
import scalapb.compiler.Version.scalapbVersion

//noinspection TypeAnnotation
object Dependencies {
Expand Down Expand Up @@ -140,13 +141,16 @@ object Dependencies {
) ++ test ++ console ++ logDeps ++ levelDBJNA ++ protobuf.value ++ langCompilerPlugins.value
)

lazy val scalapbRuntime = Def.setting {
val version = scalapb.compiler.Version.scalapbVersion
val gProto = "com.google.protobuf" % "protobuf-java" % "3.24.4"

lazy val scalapbRuntime = Def.setting(
Seq(
"com.thesamet.scalapb" %%% "scalapb-runtime" % version,
"com.thesamet.scalapb" %%% "scalapb-runtime" % version % "protobuf"
("com.thesamet.scalapb" %%% "scalapb-runtime" % scalapbVersion).exclude(gProto.organization, gProto.name),
("com.thesamet.scalapb" %%% "scalapb-runtime" % scalapbVersion % "protobuf").exclude(gProto.organization, gProto.name),
gProto,
gProto % "protobuf"
)
}
)

lazy val protobuf = Def.setting {
scalapbRuntime.value :+ protoSchemasLib % "protobuf"
Expand All @@ -155,7 +159,7 @@ object Dependencies {
lazy val grpc: Seq[ModuleID] = Seq(
"io.grpc" % "grpc-netty" % scalapb.compiler.Version.grpcJavaVersion,
"io.grpc" % "grpc-services" % scalapb.compiler.Version.grpcJavaVersion,
"com.thesamet.scalapb" %% "scalapb-runtime-grpc" % scalapb.compiler.Version.scalapbVersion,
"com.thesamet.scalapb" %% "scalapb-runtime-grpc" % scalapbVersion,
protoSchemasLib % "protobuf"
)

Expand Down