Skip to content

multi: migrate from gRPC to Connect RPC#348

Open
torkelrogstad wants to merge 3 commits into
masterfrom
2026-05-20-rpc
Open

multi: migrate from gRPC to Connect RPC#348
torkelrogstad wants to merge 3 commits into
masterfrom
2026-05-20-rpc

Conversation

@torkelrogstad
Copy link
Copy Markdown
Collaborator

@torkelrogstad torkelrogstad commented May 20, 2026

Connect is a replacement for gRPC. It is effectively
a simplified version of gRPC. gRPC clients can still communicate with Connect
servers, without having to make any changes at all. One of the big benefits of
Connect is that it is possible to use a completely plain HTTP client as well
(for example just curl!).

All of these work fine:

$ curl -X POST -H 'Content-Type: application/json' http://localhost:50051/cusf.mainchain.v1.WalletService/GetBalance
$ grpcurl -plaintext localhost:50051/cusf.mainchain.v1.WalletService/GetBalance
$ buf curl http://localhost:50051/cusf.mainchain.v1.WalletService/GetBalance

Why bother?

The biggest benefit is that clients no longer need to bother
with gRPC at all. gRPC is notoriously hard and complex to deal with.
Generated code, hairy libraries, TLS, lots of strange concepts. People get
frustrated, and give up! With this, we could consider dropping our
home-rolled JSON-RPC server implementation of the validator and wallet
services.

Another change we make is to remove the cusf_sidechain_proto Git submodule in
favor of remote code generation through the Buf Schema Registry. Code generation
plugins are configured in buf.gen.yaml, and the generated code is checked into
Git. This blows up the diff via lots and lots of generated code (not a big deal,
IMO). The upside is that we can remove a few build dependencies, and that we
avoid the Git submodule in favor of what (I believe) is a simpler way of
upgrading the proto files. Note that we could still do build-time code
generation while using Connect, if we wanted to. Personal preference of mine is
on checked-in generated code: it is very nice to be able to actually read and
examine whatever code we're interacting with, instead of having to dig into the
target folder if something is not working as expected.

One downside here is that the Connect library does not (yet) support the
reflection API. This is something I assume they'll be adding shortly. The
library is very rapidly iterated on, judging by GitHub activity.

This supersedes #333, as we no longer have to deal with local proto files at all.

TODO:

@torkelrogstad torkelrogstad force-pushed the 2026-05-20-rpc branch 5 times, most recently from 98b439b to 68ba50a Compare May 21, 2026 11:09
Connect is a simple RPC alternative to gRPC that is fully compatible
with existing gRPC clients. We also gain the ability for plain `curl` to
be used as a client.
Implemented via a new crate that is not yet merged into upstream: anthropics/connect-rust#128
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant