paritytech / paritytech/polkadot-cli

Reintroduce Smoldot light client support

Open
#142 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
TypeScript
Stars
10
Forks
2
Avg merge
12h 35m
Merged PRs (30d)
4

Description

Context

Light client support via Smoldot was removed because it was not working correctly. This issue tracks reintroducing it properly.

What was removed

  • --light-client global CLI flag and dot chain add <name> --light-client command
  • KNOWN_CHAIN_SPECS mapping with chain spec references for 12 chains
  • createSmoldotProvider() function in src/core/client.ts
  • lightClient?: boolean field from ChainConfig interface
  • All related help text, completions, tests, and documentation

Previously supported chains

The KNOWN_CHAIN_SPECS mapping covered:

Chain Spec module Relay
polkadot polkadot-api/chains/polkadot
kusama polkadot-api/chains/ksmcc3
westend polkadot-api/chains/westend2
paseo polkadot-api/chains/paseo
polkadot-asset-hub polkadot-api/chains/polkadot_asset_hub polkadot
polkadot-bridge-hub polkadot-api/chains/polkadot_bridge_hub polkadot
polkadot-collectives polkadot-api/chains/polkadot_collectives polkadot
polkadot-coretime polkadot-api/chains/polkadot_coretime polkadot
polkadot-people polkadot-api/chains/polkadot_people polkadot
paseo-asset-hub polkadot-api/chains/paseo_asset_hub paseo
paseo-coretime polkadot-api/chains/paseo_coretime paseo
paseo-people polkadot-api/chains/paseo_people paseo

How createSmoldotProvider worked

async function createSmoldotProvider(chainName: string) {
  const { start } = await import("polkadot-api/smoldot");
  const { getSmProvider } = await import("polkadot-api/sm-provider");

  const entry = KNOWN_CHAIN_SPECS[chainName];
  const { chainSpec } = await import(entry.spec);
  const smoldot = start();

  if (entry.relay) {
    // Parachains need their relay chain initialized first
    const { chainSpec: relaySpec } = await import(relayEntry.spec);
    const relayChain = await smoldot.addChain({ chainSpec: relaySpec, disableJsonRpc: true });
    const chain = await smoldot.addChain({ chainSpec, potentialRelayChains: [relayChain] });
    return getSmProvider(chain);
  }

  const chain = await smoldot.addChain({ chainSpec });
  return getSmProvider(chain);
}

Key polkadot-api modules

  • polkadot-api/smoldot — provides start() to initialize the Smoldot runtime
  • polkadot-api/sm-provider — provides getSmProvider() to wrap a Smoldot chain into a JsonRpcProvider
  • polkadot-api/chains/* — pre-built chain specifications for known chains

These are all sub-paths of the existing polkadot-api dependency — no additional packages needed.

Suggested approach for reintroduction

Rather than requiring an explicit --light-client flag, consider auto-detecting light client capability:

  1. Maintain a KNOWN_CHAIN_SPECS mapping for chains that have embedded chain specs
  2. When creating a client, if no --rpc override is provided and the chain is in KNOWN_CHAIN_SPECS, prefer the light client
  3. If configured RPC endpoints exist, use those instead (light client as fallback or opt-in)
  4. Add an explorerRpc field to KNOWN_CHAIN_SPECS for generating explorer links when using light client (since light client doesn't provide a representative RPC URL)
  5. Ensure proper error handling and timeout behavior for light client connections
  6. Update docs and tests accordingly

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in src/core/client.ts and inspect the existing client creation flow, then review the removed CLI flag, chain-add command, help text, completions, tests, and documentation. Compare the proposed KNOWN_CHAIN_SPECS and Smoldot module usage with the current polkadot-api dependency. Done means light-client selection, RPC precedence or fallback, explorer links, errors, timeouts, tests, and documentation are defined and working for the listed chains.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
cli, networking
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.