Skip to content

Commit 0d3c960

Browse files
nhussein11CrackTheCode016eshaben0xlukem
authored
[Fix] - Adding Light clients page (#585)
* Light Client Content / Page (#479) * light client draft * edits + diagram * edits * vale * polish * fix: tweaking details * fix: feedback * fix: title * Apply suggestions from code review Co-authored-by: Erin Shaben <[email protected]> Co-authored-by: Lucas Malizia <[email protected]> * fix: italics * fix: italcis * fix: italics according our guidelines * Update develop/toolkit/parachains/light-clients.md Co-authored-by: Lucas Malizia <[email protected]> * fix: llms * Update develop/toolkit/parachains/light-clients.md Co-authored-by: Erin Shaben <[email protected]> * Update develop/toolkit/parachains/light-clients.md Co-authored-by: Erin Shaben <[email protected]> * fix: llms --------- Co-authored-by: bader y <[email protected]> Co-authored-by: Erin Shaben <[email protected]> Co-authored-by: Lucas Malizia <[email protected]>
1 parent a26b414 commit 0d3c960

File tree

3 files changed

+169
-1
lines changed

3 files changed

+169
-1
lines changed

develop/toolkit/parachains/.pages

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,5 @@ nav:
44
- quickstart
55
- spawn-chains
66
- fork-chains
7-
- e2e-testing
7+
- e2e-testing
8+
- 'Light Clients': light-clients.md
Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
---
2+
title: Light Clients
3+
description:Light clients enable secure and efficient blockchain interaction without running a full node. Learn everything you need to know about light clients on Polkadot.
4+
---
5+
6+
# Light Clients
7+
8+
## Introduction
9+
10+
Light clients enable secure and efficient blockchain interaction without running a full node. They provide a trust-minimized alternative to JSON-RPC by verifying data through cryptographic proofs rather than blindly trusting remote nodes.
11+
12+
This guide covers:
13+
14+
- What light clients are and how they work
15+
- Their advantages compared to full nodes and JSON-RPC
16+
- Available implementations in the Polkadot ecosystem
17+
- How to use light clients in your applications
18+
19+
Light clients are particularly valuable for resource-constrained environments and applications requiring secure, decentralized blockchain access without the overhead of maintaining full nodes.
20+
21+
!!!note "Light node or light client?"
22+
The terms _light node_ and _light client_ are interchangeable. Both refer 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.
23+
24+
## Light Clients Workflow
25+
26+
Unlike JSON-RPC interfaces, where an application must maintain a list of providers or rely on a single node, light clients are not limited to or dependent on a single node. They use cryptographic proofs to verify the blockchain's state, ensuring it is up-to-date and accurate. By verifying only block headers, light clients avoid syncing the entire state, making them ideal for resource-constrained environments.
27+
28+
```mermaid
29+
flowchart LR
30+
DAPP([dApp])-- Query Account Info -->LC([Light Client])
31+
LC -- Request --> FN(((Full Node)))
32+
LC -- Response --> DAPP
33+
FN -- Response (validated via Merkle proof) --> LC
34+
```
35+
36+
In the diagram above, the decentralized application queries on-chain account information through the light client. The light client runs as part of the application and 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.
37+
38+
Light clients can quickly verify the blockchain's state, including [GRANDPA finality](/polkadot-protocol/glossary#grandpa){target=\_blank} justifications.
39+
40+
!!!note "What does it mean to be trust-minimized?"
41+
_Trust-minimized_ means that the light client does not need to fully trust the full node from which it retrieves the 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.
42+
43+
## JSON-RPC and Light Client Comparison
44+
45+
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#pallet){target=\_blank} data, and interacts with the blockchain. This is typically done in one of two ways:
46+
47+
- **User-controlled nodes** - the UI connects to a node client installed on the user's machine
48+
- These nodes are secure, but installation and maintenance can be inconvenient
49+
- **Publicly accessible nodes** - the UI connects to a third-party-owned publicly accessible node client
50+
- These nodes are convenient but centralized and less secure. Applications must maintain a list of backup nodes in case the primary node becomes unavailable
51+
52+
While light clients still communicate with [full nodes](/polkadot-protocol/glossary#full-node), they offer significant advantages for applications requiring a secure alternative to running a full node:
53+
54+
| Full Node | Light Client |
55+
| :---------------------------------------------------------------------------------------------: | :------------------------------------------------------------: |
56+
| Fully verifies all blocks of the chain | Verifies only the authenticity of blocks |
57+
| Stores previous block data and the chain's storage in a database | Does not require a database |
58+
| Installation, maintenance, and execution are resource-intensive and require technical expertise | No installation is typically included as part of the application |
59+
60+
## Using Light Clients
61+
62+
The [`smoldot`](https://github.com/smol-dot/smoldot){target=\_blank} client 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).
63+
64+
### PAPI Light Client Support
65+
66+
The [Polkadot API (PAPI)](/develop//toolkit/api-libraries/papi){target=\_blank} library 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.
67+
68+
### Substrate Connect - Browser Extension
69+
70+
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.
71+
72+
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.
73+
74+
Substrate Connect automatically detects whether the user has the extension installed. If not, an in-page Wasm light client is created for them.
75+
76+
## Resources
77+
78+
- [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}
79+
- [Introducing Substrate Connect: Browser-Based Light Clients for Connecting to Substrate Chains](https://www.parity.io/blog/introducing-substrate-connect){target=\_blank}
80+
- [Substrate Connect GitHub Repository](https://github.com/paritytech/substrate-connect/tree/master/projects/extension){target=\_blank}
81+
- [Light Clients - Polkadot Specification](https://spec.polkadot.network/sect-lightclient){target=\_blank}

llms.txt

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ Doc-Page: https://docs.polkadot.com/develop/toolkit/parachains/fork-chains/chops
6565
Doc-Page: https://docs.polkadot.com/develop/toolkit/parachains/fork-chains/chopsticks/
6666
Doc-Page: https://docs.polkadot.com/develop/toolkit/parachains/fork-chains/
6767
Doc-Page: https://docs.polkadot.com/develop/toolkit/parachains/
68+
Doc-Page: https://docs.polkadot.com/develop/toolkit/parachains/light-clients/
6869
Doc-Page: https://docs.polkadot.com/develop/toolkit/parachains/quickstart/
6970
Doc-Page: https://docs.polkadot.com/develop/toolkit/parachains/quickstart/pop-cli/
7071
Doc-Page: https://docs.polkadot.com/develop/toolkit/parachains/spawn-chains/
@@ -11255,6 +11256,91 @@ This section explores essential tools for blockchain testing, forking live netwo
1125511256
:::INSERT_IN_THIS_SECTION:::
1125611257
--- END CONTENT ---
1125711258

11259+
Doc-Content: https://docs.polkadot.com/develop/toolkit/parachains/light-clients/
11260+
--- BEGIN CONTENT ---
11261+
---
11262+
title: Light Clients
11263+
description:Light clients enable secure and efficient blockchain interaction without running a full node. Learn everything you need to know about light clients on Polkadot.
11264+
---
11265+
11266+
# Light Clients
11267+
11268+
## Introduction
11269+
11270+
Light clients enable secure and efficient blockchain interaction without running a full node. They provide a trust-minimized alternative to JSON-RPC by verifying data through cryptographic proofs rather than blindly trusting remote nodes.
11271+
11272+
This guide covers:
11273+
11274+
- What light clients are and how they work
11275+
- Their advantages compared to full nodes and JSON-RPC
11276+
- Available implementations in the Polkadot ecosystem
11277+
- How to use light clients in your applications
11278+
11279+
Light clients are particularly valuable for resource-constrained environments and applications requiring secure, decentralized blockchain access without the overhead of maintaining full nodes.
11280+
11281+
!!!note "Light node or light client?"
11282+
The terms _light node_ and _light client_ are interchangeable. Both refer 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.
11283+
11284+
## Light Clients Workflow
11285+
11286+
Unlike JSON-RPC interfaces, where an application must maintain a list of providers or rely on a single node, light clients are not limited to or dependent on a single node. They use cryptographic proofs to verify the blockchain's state, ensuring it is up-to-date and accurate. By verifying only block headers, light clients avoid syncing the entire state, making them ideal for resource-constrained environments.
11287+
11288+
```mermaid
11289+
flowchart LR
11290+
DAPP([dApp])-- Query Account Info -->LC([Light Client])
11291+
LC -- Request --> FN(((Full Node)))
11292+
LC -- Response --> DAPP
11293+
FN -- Response (validated via Merkle proof) --> LC
11294+
```
11295+
11296+
In the diagram above, the decentralized application queries on-chain account information through the light client. The light client runs as part of the application and 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.
11297+
11298+
Light clients can quickly verify the blockchain's state, including [GRANDPA finality](/polkadot-protocol/glossary#grandpa){target=\_blank} justifications.
11299+
11300+
!!!note "What does it mean to be trust-minimized?"
11301+
_Trust-minimized_ means that the light client does not need to fully trust the full node from which it retrieves the 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.
11302+
11303+
## JSON-RPC and Light Client Comparison
11304+
11305+
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#pallet){target=\_blank} data, and interacts with the blockchain. This is typically done in one of two ways:
11306+
11307+
- **User-controlled nodes** - the UI connects to a node client installed on the user's machine
11308+
- These nodes are secure, but installation and maintenance can be inconvenient
11309+
- **Publicly accessible nodes** - the UI connects to a third-party-owned publicly accessible node client
11310+
- These nodes are convenient but centralized and less secure. Applications must maintain a list of backup nodes in case the primary node becomes unavailable
11311+
11312+
While light clients still communicate with [full nodes](/polkadot-protocol/glossary#full-node), they offer significant advantages for applications requiring a secure alternative to running a full node:
11313+
11314+
| Full Node | Light Client |
11315+
| :---------------------------------------------------------------------------------------------: | :------------------------------------------------------------: |
11316+
| Fully verifies all blocks of the chain | Verifies only the authenticity of blocks |
11317+
| Stores previous block data and the chain's storage in a database | Does not require a database |
11318+
| Installation, maintenance, and execution are resource-intensive and require technical expertise | No installation is typically included as part of the application |
11319+
11320+
## Using Light Clients
11321+
11322+
The [`smoldot`](https://github.com/smol-dot/smoldot){target=\_blank} client 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).
11323+
11324+
### PAPI Light Client Support
11325+
11326+
The [Polkadot API (PAPI)](/develop//toolkit/api-libraries/papi){target=\_blank} library 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.
11327+
11328+
### Substrate Connect - Browser Extension
11329+
11330+
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.
11331+
11332+
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.
11333+
11334+
Substrate Connect automatically detects whether the user has the extension installed. If not, an in-page Wasm light client is created for them.
11335+
11336+
## Resources
11337+
11338+
- [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}
11339+
- [Introducing Substrate Connect: Browser-Based Light Clients for Connecting to Substrate Chains](https://www.parity.io/blog/introducing-substrate-connect){target=\_blank}
11340+
- [Substrate Connect GitHub Repository](https://github.com/paritytech/substrate-connect/tree/master/projects/extension){target=\_blank}
11341+
- [Light Clients - Polkadot Specification](https://spec.polkadot.network/sect-lightclient){target=\_blank}
11342+
--- END CONTENT ---
11343+
1125811344
Doc-Content: https://docs.polkadot.com/develop/toolkit/parachains/quickstart/
1125911345
--- BEGIN CONTENT ---
1126011346
---

0 commit comments

Comments
 (0)