Introducing a new way to review your PRs.

Read the announcement

celestiaorg / celestia-core

A fork of CometBFT

View on GitHub

20 documents · Updated Nov 23, 2026

docs / light-client-verification

Light client verification

The light client verifies CometBFT consensus without downloading or running the full application state. It starts from a trusted header, obtains signed headers and validator sets from remote providers, checks a path of validator signatures, detects conflicting views, and saves verified light blocks for later use.

Verification boundary

The light client treats remote nodes as sources of data rather than as trusted authorities. A light block is a signed header paired with the validator set that can verify its commit. The client accepts a light block only after it connects to trusted state through the consensus rules.

The client does not verify application transactions by itself. Other layers can use a trusted header and its application hash to verify state proofs. See Light client RPC and proxy for the interface that applies these checks to remote RPC results.

Trust root

The trust root is a header height and hash obtained from a source that the operator trusts. This model is called weak subjectivity because proof of stake chains need a recent external view of the chain to avoid trusting an old validator set that may no longer control bonded stake.

The trust period limits how long the root can support new verification. A client that has no usable stored state must receive a valid height, hash, and trust period before it can start.

References: light/trust_options.go• L11-51 light/doc.go• L15-33

Trusted-header bootstrapping

Bootstrapping turns the external trust root into locally trusted state. The client fetches the light block from its primary provider, checks that the returned header has the expected hash, verifies its commit with more than two thirds of the validator power, and compares it with witnesses before saving it.

The client can also restore its newest saved light block. If new trust options point to an older height, the client can remove newer saved blocks. If the supplied root does not match the stored or fetched header, it must clear the conflicting trusted state or stop when confirmation is refused.

The bootstrapping flow is:

flowchart LR
    A[Trusted height and hash] --> B[Fetch light block from primary]
    B --> C[Check header and validator set]
    C --> D[Verify more than two thirds commit]
    D --> E[Compare with witnesses]
    E --> F[Save trusted light block]
    F --> G[Use as verification root]

References: light/client.go• L164-206 light/client.go• L266-282 light/client.go• L303-357 light/client.go• L360-393

Provider interaction

Providers supply the data that the light client needs to verify consensus. The primary provider serves normal requests. Witness providers supply independent views that cross-check the primary and can replace it when the primary cannot serve a usable light block.

The provider contract includes the chain ID, light blocks by height, and evidence reporting. An HTTP provider builds each light block from a remote RPC commit and validator-set response. It rejects an incomplete signed header before the client uses its header or commit. The client owns all trust decisions after the provider returns that data.

Provider roles

The client sends ordinary fetches to the primary. It asks witnesses to compare the target header after verification and asks them for the same height when the primary fails. A provider that is unavailable or does not yet have a height is treated differently from one that returns malformed or invalid consensus data.

This distinction protects recovery. Temporary absence can cause a provider switch or a returned availability error. A bad light block can cause the provider to be removed. The client promotes a responding witness to primary and keeps the old primary as a witness when the failure is not judged malicious.

The provider boundary must also reject malformed or mismatched data before verification uses it. This includes a signed header with no header or commit. The client is tested against altered headers, commits, validator sets, heights, and provider errors. These checks also require provider requests to stop within a bounded limit when inputs are hostile or inconsistent.

References: light/…/provider.go• L9-29 light/…/http.go• L68-102 light/…/http.go• L184-227 light/client.go• L1025-1177 light/client_fuzz_test.go• L133-175 light/…/http_fuzz_test.go• L122-169

Provider evidence

When the client finds two valid but conflicting views, it does not select one by response order. It verifies the witness view against the primary verification trace, finds the point where the views split, and can send light-client attack evidence to the providers before stopping.

The safety model assumes that at least one connected full node is correct. More witnesses improve the chance of finding a conflict, but a witness that is only behind or unavailable does not by itself prove a fork.

References: light/detector.go• L18-28 light/detector.go• L41-109 light/detector.go• L233-291

Header verification

Header verification connects a new signed header to a trusted header. It checks the chain ID, height order, time order, future-time limit, validator-set hash, and commit signatures before the client marks the new light block as trusted.

Adjacent and non-adjacent headers use different links between validator sets. The client uses sequential checks for an adjacent pair in both modes. For a larger height gap, the selected verification mode determines how many intermediate headers it needs.

Sequential verification

Sequential verification checks every header between the trusted height and the target height in ascending order. Each next header must use the validator set named by the previous header and must have a commit signed by more than two thirds of the new validator power.

This mode uses a direct and complete path. Its cost grows with the number of blocks between the trusted and target heights, so it can require many provider requests. Intermediate light blocks support the check but are not saved as trusted state unless they are separately accepted as targets.

References: light/client.go• L44-54 light/client.go• L627-711 light/verifier.go• L81-131 light/client_test.go• L124-257

Skipping verification

Skipping verification avoids checking every height when validator continuity provides enough support. For a non-adjacent target, at least the configured trust level of the old validator set must have signed the target commit, and more than two thirds of the target validator set must also have signed it.

The default trust level is one third of the old voting power. When the target does not meet that direct trust test, the client requests intermediate heights and searches for a short trust path. Adjacent pairs still use the sequential adjacent check, so skipping does not remove the validator-transition check.

The verification paths must reject forged data even when a limited-power validator signs it. Fuzz coverage exercises both modes with changing validator sets and checks that an honest chain succeeds, a forged block is never returned or stored, and provider calls remain bounded.

References: light/client.go• L56-69 light/client.go• L721-843 light/verifier.go• L19-78 light/verifier.go• L134-203 light/client_test.go• L260-380 light/client_fuzz_test.go• L267-361

Older-header verification

Requests for a height below the saved range follow the links back from the nearest trusted header. Before this walk, the client verifies the requested light block's commit against its validator set. The walk then checks that each older header has an earlier time and that its hash matches the later header's previous-block link.

If the target commit or a header in the walk is invalid, the client can replace the primary and retry with a witness. If a provider changes during the backward walk, the client checks that the final verified header is the requested target and returns the light block supplied by the provider that passed verification. An old trusted header cannot support forward verification after its trust period expires. The client then needs a new subjective trust root instead of treating the expired state as a valid bridge.

References: light/client.go• L587-625 light/client.go• L945-1022 light/client.go• L1025-1177 light/client_test.go• L785-1032

Fork detection

Fork detection is a second check after the primary provider produces a valid verification path. The detector asks witnesses for the target light block and compares both the header hash and validator-set proposer state with the primary result.

The detector uses the verification trace to examine a conflicting witness header. If both views can be verified from their common trusted point, the client treats the result as a possible light-client attack, builds evidence, reports it on a best-effort basis, and returns an attack error instead of saving the target.

Conflict outcomes

Witness responses lead to distinct outcomes:

Witness resultClient response
Same header and proposer stateThe target passes cross-reference.
Different valid headerThe client examines the divergence and may report evidence.
Invalid light blockThe witness is removed from service.
Missing, late, or unavailable blockThe client continues with other witnesses.
Different proposer priorities onlyThe client reports an unattributable conflict and stops the check.

The client saves a target only when verification succeeds and at least one witness confirms the same header. If no witness can confirm the target, the cross-reference fails rather than turning an unconfirmed response into trusted state.

References: light/detector.go• L28-109 light/detector.go• L112-223 light/errors.go• L43-104

Light-block persistence

Persistence gives the client a local record of the consensus state that it has already verified. The store keeps each trusted light block as a signed header and its validator set, indexed by height.

After a successful verification, the client saves the target and updates its newest trusted height. On restart, it restores the newest saved light block and can answer requests for any retained height without asking a provider to verify that height again. When a provider is replaced during older-header verification, the successful request returns and saves the replacement provider's verified light block rather than the rejected response.

Stored range

The store tracks the oldest and newest saved heights and can return the saved block before a requested height. This range lets the client choose the nearest trusted starting point for a forward request or decide when it must verify backward from the first retained block.

Intermediate blocks used only to build a sequential or skipping path are not automatically persisted. Persistence records accepted targets, not every remote response.

References: light/…/store.go• L5-47 light/client.go• L464-497 light/client.go• L563-625 light/client.go• L886-942

Pruning and reset

Pruning limits the number of saved light blocks while keeping recent trusted state available. A reset removes saved blocks when the operator supplies a different root or when stored state no longer matches the selected trust source.

Pruning is a space policy rather than a trust decision. Removing an old block can increase the work needed for a later historical request, but it does not make an unverified block trusted.

References: light/client.go• L72-79 light/client.go• L886-923 light/…/store.go• L42-47 light/…/db.go• L217-287

RPC and proxy integration

The verification client is the foundation for the light-client RPC and proxy layer. That layer checks that a remote response matches the request before it asks the light client to authenticate the response at that height. It then compares the response with trusted headers and commitments before returning data that can be proved, while it keeps uncheckable operational responses separate.

Share proof requests follow the same boundary. The RPC client first checks that a returned proof covers exactly the requested share range. It then obtains a light-verified header at the requested height and validates the proof against that header's data root. This prevents a genuine proof for another range from reaching light-client verification and prevents a proof with the wrong data root from being accepted.

The RPC wrapper also manages the life of its event forwarders. Normal subscriptions stop when the caller unsubscribes or disconnects. WebSocket event data remains outside the verified response path and must not be treated as authenticated consensus data.

Read Light client RPC and proxy for the RPC trust boundary, proof checks, forwarded methods, and proxy behavior.

References: light/…/client.go• L139-203 light/…/client.go• L242-277 light/…/client.go• L333-404 light/…/client.go• L452-533 light/…/client.go• L616-630 light/…/client.go• L636-714 light/…/client.go• L777-862 light/…/share_proof_test.go• L139-200 light/…/client_test.go• L32-176 light/…/client_test.go• L201-257

Change checklist

When these files or sections are changed, remember to consider these:

  • Keep the trust-root height and hash as one matching pair across bootstrapping, restart, rollback, and reset paths.
  • Keep provider error classes aligned with provider replacement behavior. Temporary absence must not be treated as proof of invalid consensus data.
  • Keep adjacent and non-adjacent verification rules aligned with validator-set hashes and commit voting power.
  • Keep backward verification aligned with target commit checks, provider replacement, and the rule that only the replacement block that passed verification can be saved or returned.
  • Keep witness comparison aligned with the evidence format and the rule that a target must not be saved before cross-reference succeeds.
  • Keep the final target-hash check aligned with provider replacement during backward verification.
  • Keep store range and pruning behavior aligned with the starting points used for forward and backward verification.
  • Keep the RPC and proxy layer aligned with the set of headers and proofs that the verification client has actually authenticated.
  • Keep RPC responses bound to their requests before light-client verification. A genuine response from another height, hash, transaction, or share range must not reach the verifier as if it answered the original request.
  • Keep share-proof range binding consistent with the square width and row coordinates used by proof validation.
  • Keep WebSocket subscription cleanup aligned with unsubscribe and connection-close events so stopped forwarders do not keep consuming remote events.
  • Keep provider decoding aligned with height checks, basic light-block validation, duplicate-validator rejection, incomplete signed-header rejection, and bounded retry behavior.

Important failure modes

TriggerConsequenceGuard
The supplied trust height and hash do not identify the same headerBootstrapping fails or conflicting stored state is clearedCheck the fetched header hash and validate the trust options before saving state
The trust period expires before a new path is checkedThe old root cannot support forward verificationRefresh the subjective trust root within the allowed period
A provider returns a malformed light block or wrong chain dataThe response is rejected and the provider can be removedValidate the light block and its chain and validator-set links
An HTTP response has malformed JSON, an RPC error, a wrong height, duplicate validators, or a missing signed-header fieldThe provider returns no usable light blockValidate the decoded block, require the requested height, reject duplicate validator addresses, and reject a missing header or commit
A non-adjacent target lacks enough old-validator signaturesSkipping cannot establish a trust pathRequest intermediate headers or use sequential verification
A backward target has a valid header hash but an invalid commitThe provider is replaced or verification fails, and the target is not savedVerify the target commit before the backward hash walk
A provider change makes the backward walk end at a different target hashThe requested old header is rejected and is not storedCompare the final verified hash with the requested target hash
A remote RPC server returns a genuine object for a different requested height, hash, transaction, or share rangeThe caller could receive authentic data that does not answer its requestBind response height, hash, transaction hash, or share range to the request before light-client verification
A share proof has malformed row data or arithmetic inputsThe proof is rejected before light-client verificationRequire proof rows and shares, bound the total, and check the computed range against the requested range
Witnesses return a valid conflicting headerThe target is not trusted and evidence handling may stop the clientKeep independent witnesses and inspect the attack result
All witnesses are unavailable or cannot confirm the targetCross-reference fails and the target is not savedUse enough current witnesses to provide an independent matching view
Pruning removes the only nearby historical starting pointA later old-height request needs more work or cannot be served from local stateChoose a retention range that covers required history
A hostile provider input causes repeated retries or path searchesThe request can consume excessive provider callsBound retries and provider calls and stop without accepting untrusted state

Key files

FileWhy to read it
light/doc.goStates the purpose and trust model of the light client.
light/trust_options.goDefines the external trust root and trust-period rules.
light/client.goCoordinates bootstrapping, provider use, verification modes, fork checks, backward target checks, and persistence.
light/client_test.goShows the expected results for trust setup, verification modes, provider replacement, invalid backward commits, and stored-state changes.
light/…/provider.goDefines the boundary between remote data access and verification.
light/…/http.goShows how an RPC source supplies signed headers and validator sets and rejects incomplete responses.
light/…/http_fuzz_test.goExercises HTTP provider decoding and rejection of malformed, mismatched, incomplete, or duplicate-validator responses.
light/verifier.goDefines adjacent, non-adjacent, and backward header checks.
light/detector.goDefines witness cross-reference, divergence handling, and evidence reporting.
light/…/store.goDefines the persistence contract for trusted light blocks.
light/…/db.goShows the persistent store's range, reset, and pruning behavior.
light/client_fuzz_test.goExercises trust bootstrapping, sequential and skipping paths, fork inputs, provider errors, bounded calls, and store safety.
light/…/client.goConnects RPC responses to light-client verification and proof checks, including exact share-range binding before authentication.
light/…/share_proof_test.goShows that share proofs must match the requested range and the light-verified data root.
light/…/client_test.goShows rejection of substituted RPC responses and cleanup of stopped WebSocket forwarders.
light-client-rpc-and-proxy.mdExplains how verified light-client state supports RPC and proxy responses.