Skip to content

Add TCP and TLS listening support to the cardano-rpc gRPC server - #1322

Open
carbolymer wants to merge 2 commits into
masterfrom
mgalazyn/feature/rpc-enable-http
Open

Add TCP and TLS listening support to the cardano-rpc gRPC server#1322
carbolymer wants to merge 2 commits into
masterfrom
mgalazyn/feature/rpc-enable-http

Conversation

@carbolymer

@carbolymer carbolymer commented Aug 28, 2026

Copy link
Copy Markdown
Contributor

Context

The cardano-rpc gRPC server has so far only listened on a unix domain socket, requiring a proxy such as Envoy in front of it for any remote or non-local access (documented as the accepted architecture in ADR-018).
This PR adds native HTTP/2 listeners to the server, superseding that part of ADR-018.

The server can now listen on:

  • a unix domain socket (existing behaviour, still the default), or
  • HTTP/2 without TLS (h2c) on a configured IP address and port, or
  • HTTP/2 over TLS on a configured IP address and port, with certificate, private key and optional chain certificate files.

The configuration surface for this (JSON keys RpcListenAddress/RpcListenPort/RpcTlsCertificateFile/RpcTlsPrivateKeyFile/RpcTlsChainCertificateFiles, and CLI flags --grpc-listen-address/--grpc-listen-port/--grpc-tls-certificate/--grpc-tls-private-key/--grpc-tls-chain-certificate) lives in cardano-node; this PR provides the underlying cardano-rpc library support it builds on.
The listen address defaults to 127.0.0.1 and accepts either an IPv4 or IPv6 address.
Configuring both a socket path and a listen port is rejected at configuration parsing time, since exactly one listener can be active.
TLS key logging follows grapesy's default behaviour, so it honours SSLKEYLOGFILE when set.

Breaking change

RpcConfigF's rpcSocketPath field is replaced by rpcEndpoint, of a new RpcEndpoint sum type:

data RpcEndpoint
  = RpcEndpointUnixSocket !SocketPath
  | RpcEndpointHttp !IP !PortNumber
  | RpcEndpointHttps !IP !PortNumber !RpcTlsFiles

RpcTlsFiles is a new record of File-typed certificate and key paths.
RpcEndpoint has a Pretty instance, and TraceRpc gained a new TraceRpcServerListening constructor, emitted when the server starts listening, that reports the active endpoint.

How to trust this PR

Two commits, one per listener type:

  • Add TCP listening support to the gRPC server
  • Add TLS listening support to the gRPC server

Reviewers can check cardano-rpc/src/Cardano/Rpc/Server/Config.hs for the RpcEndpoint/RpcTlsFiles types and defaults, and cardano-rpc/src/Cardano/Rpc/Server.hs for how each RpcEndpoint constructor maps onto grapesy's ServerConfig (InsecureConfig for h2c, SecureConfig for TLS).

Checklist

  • Commit sequence broadly makes sense and commits have useful messages
  • New tests are added if needed and existing tests are updated. See Running tests for more details
  • Self-reviewed the diff
  • Changelog fragment added in .changes/

@carbolymer carbolymer self-assigned this Aug 28, 2026
@carbolymer carbolymer moved this to In Progress in DevTools roadmap Aug 28, 2026
@carbolymer
carbolymer force-pushed the mgalazyn/feature/rpc-enable-http branch 2 times, most recently from 590e4ae to 919a74d Compare August 28, 2026 16:25
@carbolymer
carbolymer marked this pull request as ready for review August 28, 2026 16:26
Copilot AI lite review requested due to automatic review settings August 28, 2026 16:26
@carbolymer carbolymer changed the title gRPC: Add HTTP endpoint support Add TCP and TLS listening support to the cardano-rpc gRPC server Aug 28, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR extends cardano-rpc’s server configuration to support listening on HTTP/2 endpoints (h2c and TLS) in addition to the existing unix-domain socket listener, and wires that into server startup and tracing. It introduces a breaking API change in the exposed Cardano.Rpc.Server.Config module by replacing rpcSocketPath with a new rpcEndpoint sum type.

Changes:

  • Replace RpcConfigF’s unix-socket-only rpcSocketPath with rpcEndpoint :: RpcEndpoint (unix socket / h2c / h2 + TLS) and add TLS credential types.
  • Update server startup to translate RpcEndpoint into the underlying grapesy ServerConfig, and emit a new lifecycle trace when starting.
  • Add dependencies needed for IP/port representation (iproute, network) and add a changelog fragment marking the change as breaking.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
cardano-rpc/src/Cardano/Rpc/Server/Internal/Tracing.hs Adds a new TraceRpc constructor and pretty-printing for server start/listen events.
cardano-rpc/src/Cardano/Rpc/Server/Config.hs Introduces RpcEndpoint/TLS types and replaces rpcSocketPath with rpcEndpoint in the exposed config.
cardano-rpc/src/Cardano/Rpc/Server.hs Maps RpcEndpoint to ServerConfig (unix/h2c/h2+TLS) and emits the new trace event on startup.
cardano-rpc/cardano-rpc.cabal Adds iproute and network dependencies required by the new endpoint types.
.changes/20260828_cardano_rpc_grpc_tcp_listener.yml Adds a changelog fragment describing the new endpoint support and marking it as breaking.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread .changes/20260828_cardano_rpc_grpc_tcp_listener.yml Outdated
Comment thread cardano-rpc/src/Cardano/Rpc/Server/Config.hs Outdated
Comment thread cardano-rpc/src/Cardano/Rpc/Server/Internal/Tracing.hs Outdated
Replace the rpcSocketPath field of RpcConfigF with an RpcEndpoint sum
type: the server listens either on a unix domain socket (default,
rpc.sock next to the node socket) or on plaintext TCP (HTTP/2 without
TLS) when a listen port is configured. The TCP listen address defaults
to 127.0.0.1. Trace the resolved endpoint on server start.
Add an RpcEndpointTcpTls endpoint: when TLS certificate and private key
files are configured, the server listens with TLS on the configured
host and port. Grapesy's default of honouring the SSLKEYLOGFILE
environment variable is explicitly disabled so the node never silently
logs TLS session keys.
@carbolymer
carbolymer force-pushed the mgalazyn/feature/rpc-enable-http branch from 9ffcc0d to 999ef20 Compare August 28, 2026 16:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: In Progress

Development

Successfully merging this pull request may close these issues.

2 participants