Skip to content

Commit e2c4f33

Browse files
Light Client Content / Page (#479)
* light client draft * edits + diagram * edits * vale * polish
1 parent 79fe4ec commit e2c4f33

File tree

1 file changed

+74
-0
lines changed

1 file changed

+74
-0
lines changed

develop/light-clients.md

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
---
2+
title: Light Clients
3+
description: Learn about Polkadot light clients, their importance, usage, and how they enable robust, cohesive, and secure application composition.
4+
template: root-subdirectory-page.html
5+
---
6+
7+
Light clients provide a secure, trust-minimized, and efficient method of interacting with a blockchain. Alongside the commonly used JSON Remote Procedure Calls (RPC), they are one of the primary mechanisms for blockchain communication.
8+
9+
> "Light clients are applications that fetch the required data they need from a Polkadot node with an associated [cryptographic] proof to validate the data. This makes it possible to interact with the Polkadot network without running a full node or having to trust remote peers." - [Polkadot Specification, Light Client Messages](https://spec.polkadot.network/sect-lightclient#sect-light-msg){target=\blank}
10+
11+
Polkadot offers first-class support for light clients, which play a critical role in the development of decentralized applications.
12+
13+
!!!info "Light node or light client?"
14+
The terms "light node" and "light client" are interchangeable, both referring to a blockchain client that syncs without downloading the entire blockchain state. All nodes in a blockchain network are fundamentally clients, engaging in peer-to-peer communication.
15+
16+
Unlike JSON RPC interfaces, where an application must either maintain a list of providers or rely on a single node, **light clients are not limited to nor dependent on a single node**. They use cryptographic proofs to verify the blockchain's state, ensuring it is both up-to-date and accurate. By verifying only block headers, light clients avoid syncing the entire state, making them ideal for resource-constrained environments.
17+
18+
```mermaid
19+
flowchart LR
20+
DAPP([dApp])-- Query Account Info -->LC([Light Client])
21+
LC -- Request --> FN(((Full Node)))
22+
LC -- Response --> DAPP
23+
FN -- Response (validated via Merkle proof) --> LC
24+
```
25+
26+
In the diagram above, the decentralized application queries on-chain account information through the light client. The light client, which runs as part of the application, requires minimal memory and computational resources. It uses Merkle proofs to verify the state retrieved from a full node in a trust-minimized manner. Polkadot-compatible light clients utilize [warp syncing](https://spec.polkadot.network/sect-lightclient#sect-sync-warp-lightclient){target=\blank}, which downloads only block headers.
27+
28+
Light clients can quickly verify the blockchain's state, including [GRANDPA finality](../polkadot-protocol/glossary.md#grandpa) justifications.
29+
30+
!!!info "What does it mean to be 'trust-minimized'?"
31+
"Trust-minimized" means that the light client does not need to fully trust the full node from which it retrieves state. This is achieved through the use of Merkle proofs, which allow the light client to verify the correctness of the state by checking the Merkle tree root.
32+
33+
## JSON RPC and Light Client Comparison
34+
35+
Another common method of communication between a user interface (UI) and a node is through the JSON RPC protocol. Generally, the UI retrieves information from the node, fetches network or [pallet](../polkadot-protocol/glossary.md#pallet) data, and interacts with the blockchain. This is typically done in one of two ways:
36+
37+
1. **User-Controlled Nodes**: The UI connects to a node client installed on the user's machine.
38+
- These nodes are secure, but installation and maintenance can be inconvenient.
39+
2. **Publicly Accessible Nodes**: The UI connects to a third-party-owned publicly accessible node client.
40+
- These nodes are convenient but centralized and less secure. Applications must maintain a list of backup nodes in case the primary node becomes unavailable.
41+
42+
While light clients still communicate with [full nodes](../polkadot-protocol/glossary.md#full-node), they offer significant advantages for applications requiring a secure alternative to running a full node:
43+
44+
| Full Node | Light Client |
45+
| --------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------- |
46+
| Fully verifies all blocks of the chain | Verifies only the authenticity of blocks |
47+
| Stores previous block data and the chain's storage in a database | Does not require a database |
48+
| Installation, maintenance, and execution are resource-intensive and require technical expertise | No installation; typically included as part of the application |
49+
50+
## Using Light Clients
51+
52+
[`smoldot`](https://github.com/smol-dot/smoldot){target=\blank} is the cornerstone of light client implementation for Polkadot SDK-based chains. It provides the primitives needed to build light clients and is also integrated into libraries such as [PAPI](#papi-light-client-support).
53+
54+
### PAPI Light Client Support
55+
56+
The [Polkadot API (PAPI)](./toolkit/api-libraries/papi.md){target=\blank} natively supports light client configurations, powered by [`smoldot`](https://github.com/smol-dot/smoldot){target=\blank}. This allows developers to connect to multiple chains simultaneously using a light client.
57+
58+
<!-- TODO: Add reference to a PAPI tutorial here -->
59+
60+
### Substrate Connect - Browser Extension
61+
62+
The [Substrate Connect browser extension](https://www.npmjs.com/package/@substrate/connect-extension-protocol){target=\blank} enables end-users to interact with applications connected to multiple blockchains or to connect their own blockchains to supported applications.
63+
64+
Establishing a sufficient number of peers can be challenging due to browser limitations on WebSocket connections from HTTPS pages, as many nodes require TLS. The Substrate Connect browser extension addresses this limitation by keeping chains synced in the background, enabling faster application performance.
65+
66+
!!!note
67+
Substrate Connect automatically detects whether the user has the extension installed. If not, an in-page Wasm light client is created for them.
68+
69+
## Resources
70+
71+
- [What is a light client and why you should care?](https://medium.com/paritytech/what-is-a-light-client-and-why-you-should-care-75f813ae2670){target=\blank}
72+
- [Introducing Substrate Connect: Browser-Based Light Clients for Connecting to Substrate Chains](https://www.parity.io/blog/introducing-substrate-connect){target=\blank}
73+
- [Substrate Connect GitHub Repository](https://github.com/paritytech/substrate-connect/tree/master/projects/extension){target=\blank}
74+
- [Light Clients - Polkadot Specification](https://spec.polkadot.network/sect-lightclient){target=\blank}

0 commit comments

Comments
 (0)