Light client RPC and proxy
The light-client RPC layer lets an application use remote CometBFT data without treating the remote node as trusted. A provider obtains signed headers and validator sets from an RPC endpoint. The light client checks those headers against a trusted root and witnesses. An optional proxy exposes the checked view through a standard JSON-RPC server.
This page is a child of Light client verification, which explains the wider verification model.
System boundary
The system separates data retrieval from data trust. A provider supplies remote light blocks, the light client decides which blocks are trusted, and the RPC client returns only data that it can check against that trusted state.
Provider boundary
The provider interface is the input boundary for consensus data. It supplies the chain ID, a light block at a requested height, and a path to report evidence. The provider does not establish consensus trust by itself; the light client performs that work after retrieval.
References: light/…/provider.go• L9-29
RPC boundary
The light-client RPC client keeps a normal remote RPC client behind a verification layer. Applications can use the usual RPC client interface while the layer updates or checks the light client before it returns headers, blocks, commits, validator sets, and proofs.
References: light/…/client.go• L27-50 rpc/…/interface.go• L32-44 rpc/…/interface.go• L64-119
Remote header acquisition
Applications can obtain headers either from a light client directly or through the proxy. In both cases, the remote node is a data source. The trusted result comes from the light client's validation and local trusted store.
HTTP provider
The HTTP provider turns a remote CometBFT RPC address into a light-block source. A light-block request combines a signed header with the validator set for that height, checks the configured chain ID, and reports malformed or incomplete responses as provider errors. Height zero means the latest available block. An empty signed header is treated as a height that the remote node cannot yet serve, while a non-empty response that lacks its header or commit is rejected as a bad light block.
The provider gathers paged validator data with bounded retries and backoff. It rejects empty or otherwise invalid validator responses before the light client receives the light block. Fuzz and regression coverage exercises malformed RPC data, incomplete signed headers, empty validator data, height mismatches, and RPC errors; an accepted block must match the requested height and pass basic validation.
References: light/…/http.go• L34-102 light/…/http.go• L111-181 light/…/http.go• L184-227 light/…/http_fuzz_test.go• L122-169 light/…/http_fuzz_test.go• L186-228
The provider also handles normal remote-node conditions without treating them as proof of bad behavior. A missing, unavailable, or too-high height can cause another provider to be tried. An invalid light block is different: it can cause the light client to remove that provider from service.
References: light/…/errors.go• L9-30 light/client.go• L981-1019 light/client.go• L1046-1133
Provider roles
The light client uses one primary provider for normal requests and one or more witness providers for cross-checks and recovery. The HTTP setup helpers create these roles from RPC addresses. The client requires witnesses and checks that they use the same chain ID.
References: light/setup.go• L12-79 light/client.go• L164-172 light/client.go• L209-263
The following flow shows how a remote response becomes a trusted light block and how a failed primary can be replaced by a witness.
sequenceDiagram
participant A as Application
participant L as Light client
participant P as Primary provider
participant W as Witness providers
A->>L: Request header or light block
L->>P: Fetch signed header and validator set
P-->>L: Remote light block
L->>L: Check chain, time, signatures, and validator transition
alt Primary response is valid
L->>W: Compare the new state
W-->>L: Matching or conflicting response
L-->>A: Trusted result or conflict error
else Primary is unavailable or invalid
L->>W: Request the same light block
W-->>L: Candidate response
L-->>A: Verified result or provider error
end
Trust model
The light client starts from weak subjectivity: an application must provide a trusted header height and hash, or restore a previously trusted header from its store. Later headers are accepted only when they connect to that root through validator signatures and the configured time limits.
Trust root
TrustOptions defines the initial header height and hash and the period for which that header can be used as a trust base. The values must come from a source the application trusts, such as a validator or a secure channel. When the supplied root differs from stored state, the client can roll back or clear newer state according to the configured confirmation rule.
References: light/trust_options.go• L11-51 light/client.go• L164-206 light/client.go• L285-357
Verification choices
The client supports two ways to connect a new header to trusted state:
- Sequential verification checks every adjacent header between the trusted and target heights. It gives a simple path but can require many remote requests.
- Skipping verification checks non-adjacent headers when enough voting power from the old validator set signs the new header. It uses intermediate headers only when needed. The default trust level is one third of the old voting power, and the allowed range is one third through all voting power.
Both choices still require the new validator set to provide more than two thirds of the commit power. Adjacent headers use the direct validator-set transition check.
References: light/client.go• L44-69 light/client.go• L496-509 light/verifier.go• L19-78 light/verifier.go• L81-151 light/verifier.go• L194-203
Header acceptance
Before a header becomes trusted, the client checks its chain identity, height and time order, future-time limit, validator-set hash, and commit signatures. It stores the verified light block for later RPC checks. A header that cannot be verified is not returned as trusted data.
References: light/verifier.go• L153-191 light/client.go• L558-610 light/client.go• L910-927
Verified RPC proxy
The proxy presents a standard CometBFT JSON-RPC endpoint backed by the light-client RPC client. It accepts HTTP requests and WebSocket subscriptions, forwards requests to the remote RPC source, and applies light-client checks to the RPC methods that expose verifiable chain data.
Proxy assembly
The proxy component creates an RPC client for the provider address and places it behind light/rpc.Client. The proxy then registers the RPC routes and starts an HTTP or HTTPS server. This lets an application use the proxy without directly managing provider selection or header verification.
References: light/…/proxy.go• L17-45 light/…/proxy.go• L48-84
Verified methods
The proxy exposes verified chain-data methods such as header, commit, block, block_by_hash, blockchain, block_results, validators, and abci_query. The light-client RPC client updates to the requested height when needed, then compares the remote result with trusted header or commitment data. It also binds responses to the request before verification when a caller supplies a hash or an explicit height. For an ABCI query, it requires a proof and checks the value or absence proof against the trusted application hash.
consensus_params is also checked against trusted state. When an application requests an explicit height, the returned height must match that request before the client verifies the consensus-parameter hash. A latest-value request has no fixed height, so the client authenticates the response at its own reported height.
References: light/…/routes.go• L20-53 light/…/client.go• L125-189 light/…/client.go• L228-263 light/…/client.go• L261-341 light/…/client.go• L378-455 light/…/client.go• L518-546 light/…/client_test.go• L28-85
The RPC client also verifies share proofs against the data root in a light-verified header. It first checks that the proof covers exactly the requested share range, then checks the proof against the trusted data root. This prevents a remote node from returning a valid proof for different shares in the same block.
References: light/…/client.go• L777-862 light/…/share_proof_test.go• L139-199
The header and commit methods can obtain the result from the light client itself. Methods that need response data from the remote node first fetch that data and then compare its hash or commitment with trusted state. This distinction matters because a successful RPC response is not the same as a verified response.
References: light/…/client.go• L424-469 light/…/client.go• L434-455 light/…/client.go• L711-754
Forwarded methods
Not every RPC method has a proof or a consensus commitment that this layer can check. Transaction broadcast, mempool, network status, and similar operational methods are forwarded to the remote RPC client. WebSocket event delivery is also forwarded without response verification and is marked unsafe in the RPC layer. Applications must not treat these results as authenticated chain state.
References: light/…/client.go• L117-124 light/…/client.go• L192-224 light/…/client.go• L257-259 light/…/client.go• L553-590 light/…/routes.go• L43-50
WebSocket lifecycle
The proxy uses WebSockets for subscriptions and removes all subscriptions for a disconnected remote address. This manages the event connection, but it does not add proof checks to event payloads.
References: light/…/proxy.go• L94-106 light/…/client.go• L586-632
Application header flow
An application that needs a remote header should use a height or hash request through the light-client client or proxy. The client either returns an already trusted block or asks the provider for the block, verifies it, stores it, and then returns the trusted header.
The main paths are:
- A height request with
headerorcommitupdates the light client to that height. A missing height requests the latest state. - A hash request with
header_by_hashfirst gets the remote header. The client checks that the response matches the requested hash, then verifies that the hash equals the trusted header at the same height. - A block or signed-block request checks the returned block data against the trusted header and data commitment before returning it.
- An ABCI query requires a proof. The client advances to the header that contains the query's application hash, then checks the value or absence proof.
- A share-proof request checks that the proof covers the requested range. The client then checks it against the trusted data root for the requested height.
The request path is summarized below.
flowchart LR
A[Application request] --> B[Light-client RPC client]
B --> C{Trusted at height?}
C -- No --> D[Provider fetches signed header and validator set]
D --> E[Light client verifies against root and witnesses]
E --> F[Trusted store]
C -- Yes --> F
F --> G[Compare remote block or proof when needed]
G --> H[Verified RPC result]
References: light/…/client.go• L368-488 light/…/client.go• L424-455 light/…/client.go• L777-862 light/…/client.go• L125-189 light/client.go• L464-494
Change checklist
When these files or sections are changed, remember to consider these:
- Keep the provider error classes aligned with primary replacement rules. Missing or unavailable heights are not handled like invalid light blocks.
- Keep the trust-root format aligned with initialization and rollback behavior. The height and hash must continue to describe the same header.
- Keep RPC response heights bound to explicit requests before hash verification. Otherwise a server can return authentic data from another height.
- Keep the RPC route map aligned with the methods that the verification wrapper actually checks. A new route can silently expose an unverified response.
- Keep proof verification aligned with the application hash and key-path rules when ABCI query response formats change.
- Keep WebSocket event documentation and safety limits aligned with the explicit unverified event path.
- Keep the proxy's provider address, server transport, and trust configuration aligned when deployment changes from direct HTTP use to an HTTPS proxy.
- Keep incomplete signed-header handling aligned with the distinction between an empty remote header and a malformed partial response. Both cases must remain safe for provider callers.
- Keep request-to-response binding checks in place for hash, height, and share-range requests. Authentic data for a different request is still unsafe to return.
- Keep share-proof range checks aligned with the proof coordinate model and the data-root validation. A valid proof for another share range must not pass.
Important failure modes
| Trigger | Consequence | Guard |
|---|---|---|
| The initial trusted height and hash do not identify the same valid header | Client initialization fails or stored headers are rolled back or cleared | Validate TrustOptions and check the supplied hash against the fetched header |
| A remote provider returns a malformed light block or wrong chain data | The response is rejected and the provider can be removed | Basic light-block validation plus chain ID and validator-set checks |
| A signed-header response is empty or lacks only its header or commit | The provider returns a height or bad-light-block error without accepting incomplete data | Treat empty startup responses as unavailable and reject partial signed headers before light-block validation |
| A consensus-parameter response reports a different height from an explicit request | The response is rejected before the client verifies its hash | Require BlockHeight to equal the requested height |
| The trusted header is older than the trusting period | A new non-adjacent header cannot be accepted from that root | Refresh the root before expiry or provide a newer trusted header |
| A primary provider is unavailable or lacks a requested height | The client tries a witness or returns a provider error | Use multiple providers and preserve distinct not-found and no-response errors |
| A witness reports a different header or proposer state | Verification stops with a conflict instead of accepting the fork | Compare the primary result with witnesses |
| An ABCI query has no valid proof or its proof does not match the trusted app hash | The query result is rejected | Always request a proof and verify value or absence against the trusted header |
| A share-proof response covers a different range from the request | The proof is rejected before or during data-root verification | Bind the proof's first and last share coordinates to the requested half-open range |
| A remote node returns authentic data for a different requested hash or height | The response can pass a later trust check while answering the wrong request | Bind returned hashes and explicit heights to the request before comparing trusted state |
| An application treats forwarded RPC data or WebSocket events as verified state | It can act on data that the light client did not authenticate | Use verified header, block, commit, and proof methods for security decisions |
Key files
| File | Why to read it |
|---|---|
| light/…/provider.go | Defines the small provider contract that separates remote data access from consensus verification. |
| light/…/http.go | Shows how an RPC endpoint becomes a light-block provider and how remote response errors are classified. |
| light/…/http_fuzz_test.go | Shows the provider's safety contract for malformed, incomplete, and mismatched remote responses. |
| light/setup.go | Shows how applications create HTTP primary and witness providers. |
| light/trust_options.go | Defines the external trust root and its validity rules. |
| light/client.go | Explains provider roles, header retrieval, verification, witness checks, and trusted storage. |
| light/verifier.go | Defines the checks that make a remote header acceptable. |
| light/…/client.go | Shows which RPC results are obtained from trusted state and which remote results receive proof, height, hash, or share-range checks. |
| light/…/share_proof_test.go | Shows that share proofs must match the requested range and the trusted data root. |
| light/…/client_test.go | Shows the contract that rejects consensus parameters returned for a height other than the requested height. |
| light/…/proxy.go | Shows how the verification layer is exposed as an HTTP or HTTPS RPC service. |
| light/…/routes.go | Maps public RPC methods to the light-client RPC client and separates WebSocket routes. |
| rpc/…/interface.go | Defines the standard RPC surface that applications can use through the verified client or proxy. |