You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
refactor(rpcprovider)!: use pure gRPC instead of grpc-web wrapper
BREAKING CHANGE: gRPC-web protocol is no longer supported. Browser-based
clients that relied on grpc-web to communicate directly with providers
will no longer work. Only native gRPC clients are supported.
The previous implementation used grpc-web and h2c HTTP wrappers to support
the Lava SDK (lava-sdk/lavajs) which allowed browser-based JavaScript clients
to communicate with providers. Since SDK support has been removed (see #2186),
this infrastructure is no longer needed.
Replace the grpc-web/h2c/HTTP hybrid server with a cleaner architecture:
- Use cmux to multiplex HTTP health checks and native gRPC on same port
- Remove grpcweb.WrapServer and h2c.NewHandler complexity
- Add gRPC health checking protocol support (grpc_health_v1)
- Keep HTTP health endpoint for Kubernetes probes compatibility
- Optimize cmux matching: HTTP1Fast() first, then Any() for gRPC
(avoids expensive HTTP/2 header parsing at high scale)
Benefits:
- Native gRPC connection management (keepalives, stream limits)
- Proper graceful shutdown via grpcServer.GracefulStop()
- Simpler, more maintainable code
- Better performance at scale (no protocol translation overhead)
Also adds comprehensive test suite for provider_listener.go with
14 tests and 2 benchmarks covering HTTP health, gRPC health,
relay/probe RPCs, concurrent requests, and error handling.
// Check error message for common shutdown patterns
38
+
errStr:=err.Error()
39
+
returnstrings.Contains(errStr, "use of closed network connection") ||
40
+
strings.Contains(errStr, "server closed") ||
41
+
strings.Contains(errStr, "mux: listener closed")
42
+
}
43
+
30
44
typeProviderListenerstruct {
31
45
networkAddressstring
32
46
relayServer*relayServer
33
-
httpServer http.Server
47
+
grpcServer*grpc.Server
48
+
httpServer*http.Server
49
+
healthServer*health.Server
50
+
cmux cmux.CMux
34
51
}
35
52
36
53
func (pl*ProviderListener) Key() string {
@@ -47,69 +64,104 @@ func (pl *ProviderListener) RegisterReceiver(existingReceiver RelayReceiver, end
47
64
returnutils.LavaFormatError("double_receiver_setup receiver already defined on this address with the same chainID and apiInterface", nil, utils.Attribute{Key: "chainID", Value: endpoint.ChainID}, utils.Attribute{Key: "apiInterface", Value: endpoint.ApiInterface})
0 commit comments