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

docs: update gRPC component design doc #16709

Merged
merged 5 commits into from
Dec 5, 2024
Merged
Changes from all 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
28 changes: 28 additions & 0 deletions hedera-node/docs/design/app/grpc.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,32 @@ rather than the code generated by `protoc`. For these reasons, the built-in gRPC
It turns out that gRPC is an extremely simple API built on top of HTTP/2, and we can therefore have our own simple gRPC
framework built on top of an HTTP/2 server (like Netty) and get everything we want.

## Architecture Overview

The gRPC package in Hedera App defines `GrpcServerManager` interface with a number of lifecycle methods such as
`start()`, `stop()` and `isRunning()`, and an implementation of this interface based on Netty. Hedera App runs at least
one gRPC server on the port specified in the config, and optionally it will also attempt to run additional gRPC servers
on the TLS or node operator ports specified in the same config.

### NettyGrpcServerManager

`NettyGrpcServerManager` is an implementation of `GrpcServerManager` and it uses the Hedera App's services registry in
order to gather the set of RPC endpoints and their corresponding handlers. Given that set and using the
`GrpcServiceBuilder` class we produce gRPC `ServerServiceDefinition`s which can be directly registered with the Netty
server.

### GrpcServiceBuilder
MiroslavGatsanoga marked this conversation as resolved.
Show resolved Hide resolved

As mentioned earlier, the `GrpcServiceBuilder` produces gRPC `ServerServiceDefinitions`. These definitions are
configured with the appropriate service handlers and gRPC `ServerCall.Listener` methods. At runtime, the Netty server
invokes these listener methods. For instance, the `onMessage()` method is where service logic is integrated to handle
transactions or queries using the abstract `MethodBase` type.

### MethodBase

In this abstract class, the size of incoming requests is validated, and requests that exceed the allowed size are
rejected. Additionally, we track metrics for number of calls and calls per second that were received, failed or
successfully handled. There are two concrete types(`QueryMethod` and `TransactionMethod`) that extend `MethodBase`
and implement the `handle()` method, which when called will invoke the `QueryWorkflow` or `IngestWorkflow` respectively.

**NEXT: [Records](records.md)**