Replies: 8 comments 22 replies
-
On note here: GRPC is great but not for Frontend libs. We could expose grpc endpoints for uni and bi-directional streaming, as well as unary calls which can be a second alternative to json-rpc and that could allow ppl to interact with the node from within backends more efficiently. We def need to keep json-rpc. Grpc is also good for interporotocl communication. A good alternative is CaptainProto which is smaller and more compact. |
Beta Was this translation helpful? Give feedback.
-
IMHO, gRPC is not a replacement for JsonRPC and WebSockets, but it could be a better solution when we'll split Massa node, It's ideal for inter services communication instead of WebSockets. bchd is a Go implementation of Bitcoin cash node which supports both gRPC and JsonRPC. Here are just a few benefits of gRPC:
grpc-vs-websocket |
Beta Was this translation helpful? Give feedback.
-
There is this Protobuf lib in assemblyscript https://github.com/piotr-oles/as-proto |
Beta Was this translation helpful? Give feedback.
-
I found this interesting feature which creates a binding between gRPC and classic RESTFull APIs. We don't have any reason to maintain both gRPC and JsonRPC APIs. |
Beta Was this translation helpful? Give feedback.
-
|
Beta Was this translation helpful? Give feedback.
-
One thing I also wanted to add about grpc is that since it uses a tagged schema, one could also partially deserialize the payload if only particular part is needed. That is a big advantage and it makes it quite fast in some cases. |
Beta Was this translation helpful? Give feedback.
-
After building a small POC, I have some informations to share:
We have some missing features in Rust like generating a gateway(proxy), but there is a generator in Go for example and lot of Api gateways support proxing out of the box. If we would serve Json from the node, we have to use the JsonCodec and keep use |
Beta Was this translation helpful? Give feedback.
-
Alternative: BorshQuote from @BatiGencho
Damir's additionsBorsh is indeed more compact, higher-performance and has a very strong advantage over protobuf: Serialization is deterministic across languages and there is bijectivity between the schema and the serialized data in all languages which is not the case with protobuf ( https://gist.github.com/kchristidis/39c8b310fd9da43d515c4394c3cd9510 ). This makes it possible to create objects like transactions and sign them in other languages than rust, contrary to protobuf which does not guarantee determinism nor bijectivity, making it imparctical for generating signable objects for which the serialized form must be bit-perfect for signature purposes. Quote from the Protobuf design notes:
That's why Near uses Borsh: near/nearcore#1166 However, it's not perfect as it has lower support in non-blockchain industries than protobuf and lacks versioning which led Solana people to think about moving from Borsh to Protobuf: coral-xyz/anchor#357 Note that Cosmos are discussing how to make protobuf deterministic here: https://docs.cosmos.network/main/architecture/adr-027-deterministic-protobuf-serialization Another resource about canonicalizing protobuf: https://github.com/regen-network/canonical-proto3 |
Beta Was this translation helpful? Give feedback.
-
RFC: Use protobuf and GRPC
Protobuf and GRPC
Protocol Buffers also called "proto" or "protobuf" is a schema-based binary serialization/deserialization system. It is designed to be fast and compact.
The way it works is that the serialization format is described in a ".proto" file, and a generator tool is called to generate the described structures and serialization/deserialization code for many supported languages, including go, python and rust.
On top of that, GRPC is a binary RPC protocol that uses protobuf as the underlying serialization format. It allows describing endpoints in a single ".proto" file. A generator tool is then used to produce the RPC code implementation for various supported languages, including go, python and rust.
Note: GRPC and protobuf support streaming and versioning as well.
Why it is interesting for Massa
Questions
Beta Was this translation helpful? Give feedback.
All reactions