Node RPC service wiring
Nodebuilder turns node services into externally callable JSON-RPC endpoints. It gives each service a stable namespace, applies shared access and transport settings, and ties endpoint startup to the node lifecycle. See node assembly, node configuration, and P2P networking for related views.
RPC boundary
The RPC boundary separates client calls from the internal service graph. During node construction, nodebuilder gives the RPC server the service modules and the API wrappers that describe their public calls. The server then exposes those services through one endpoint.
Service assembly flow
The flow below shows how node configuration and application services become a running RPC endpoint.
flowchart LR
C[Node configuration] --> R[RPC server]
S[Application service modules] --> R
R --> E[HTTP or HTTPS JSON-RPC endpoint]
R -. WebSocket subscriptions .-> E
The RPC module joins the node's module graph. It registers the available service namespaces before startup. Node lifecycle hooks then start and stop the server with the rest of the node, so endpoint availability follows node readiness.
References: nodebuilder/…/constructors.go• L19-41 nodebuilder/…/constructors.go• L43-58
RPC namespaces
Each namespace groups calls around one node capability. Namespace names form part of the client contract because clients use them to select the service view they need.
Service namespace map
The nodebuilder RPC module connects these service areas to matching public API wrappers:
| Namespace | Capability |
|---|---|
das | Data availability sampling state |
header | Chain headers and sync state |
state | Account queries and state-changing transactions |
share | Shares, data squares, samples, and proofs |
p2p | Peer and network state |
node | Node status and administration |
blob | Blob submission, retrieval, and proofs |
blobstream | Data-root tuples and inclusion proofs |
fibre | Fibre account services |
Each registration pairs one service module with one API wrapper. This pairing lets node assembly select the internal service while keeping the external namespace stable.
References: nodebuilder/…/constructors.go• L19-41
RPC configuration
RPC configuration controls where the endpoint listens and which protections apply to requests. Nodebuilder starts with safe local defaults, then passes the selected settings to the server when it constructs the RPC module.
Endpoint defaults
The default endpoint binds to localhost:26658. Authentication is enabled by default. CORS, TLS, and rate limiting are disabled by default. The endpoint URL uses HTTP unless TLS is enabled, in which case it uses HTTPS.
The configuration validates the bind address and port before the server starts. TLS also requires existing certificate and key files. When rate limiting is enabled, its sustained rate, burst size, and per-IP bucket limit must all be positive.
References: nodebuilder/…/config.go• L37-69 nodebuilder/…/config.go• L80-125 nodebuilder/…/constructors.go• L43-58
Request protection settings
The RPC server applies access controls at the endpoint boundary. Authentication limits calls by permission, CORS controls browser access when enabled, and TLS protects the network connection. Optional rate limiting controls request volume for each observed remote IP.
Rate limiting is off by default because a reverse proxy often owns this control in production. If a proxy hides client addresses, the RPC server sees the proxy as one client. In that setup, server-side per-IP limits can group unrelated users into one bucket.
References: nodebuilder/…/config.go• L19-35 nodebuilder/…/config.go• L59-68 nodebuilder/…/constructors.go• L43-58
RPC lifecycle
The RPC endpoint is part of the node process and follows the node's start and stop sequence. Construction prepares the server and its registered services. Startup binds the configured endpoint, while shutdown releases it with the node.
Startup and shutdown
A valid configuration is required before the endpoint can start. An invalid address, port, TLS file, or enabled rate-limit value prevents valid server setup. The endpoint therefore becomes available only after the node can start its RPC service successfully.
The configured transport determines whether clients connect over HTTP or HTTPS. The registered service set also includes namespaces that can support subscription calls, so clients use the endpoint for both request and event-style RPC access.
References: nodebuilder/…/config.go• L80-125 nodebuilder/…/constructors.go• L19-58
Change checklist
When these files or sections are changed, remember to consider these:
- Keep every namespace in nodebuilder/…/constructors.go aligned with the matching client namespace and API contract.
- Keep the RPC module inputs aligned with the service modules selected by each node type.
- Treat changes to authentication, CORS, TLS, or rate limiting as changes to the external access policy.
- Keep
DefaultConfig, URL construction, and validation aligned so displayed endpoint URLs match the server's transport. - Preserve the node lifecycle contract when changing server construction or endpoint startup behavior.
Important failure modes
| Trigger | Consequence | Guard |
|---|---|---|
| The bind address or port is invalid | RPC setup fails before the endpoint can serve requests | Validate the address and port before startup |
| TLS is enabled without usable certificate and key files | The secure endpoint cannot start | Require both paths and validate both files |
| An enabled rate limit has a non-positive rate, burst, or cache size | The RPC configuration is rejected | Validate all rate-limit bounds when the feature is enabled |
| A proxy hides client IP addresses while server rate limiting is enabled | Unrelated clients share one limit bucket | Apply the limit at the proxy or preserve the real client IP |
| A service namespace is changed in only one contract | Clients cannot reach the expected typed service | Update registration and client/API contracts together |
Key files
| File | Why to read it |
|---|---|
| nodebuilder/…/constructors.go | Shows the service-to-namespace registrations and the transfer of configuration to the server |
| nodebuilder/…/config.go | Defines RPC defaults, URL transport choice, and validation rules |
| nodebuilder/…/config_test.go | Captures the intended defaults, URL forms, and basic validation guarantees |
| nodebuilder/…/module.go | Shows where RPC construction joins the node lifecycle |
| api/…/server.go | Defines the externally callable server boundary and request controls |
| api/…/client.go | Shows the client-side namespace contract |