paritytech / paritytech/polkadot-cli
Reintroduce Smoldot light client support
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-clientglobal CLI flag anddot chain add <name> --light-clientcommandKNOWN_CHAIN_SPECSmapping with chain spec references for 12 chainscreateSmoldotProvider()function insrc/core/client.tslightClient?: booleanfield fromChainConfiginterface- 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— providesstart()to initialize the Smoldot runtimepolkadot-api/sm-provider— providesgetSmProvider()to wrap a Smoldot chain into aJsonRpcProviderpolkadot-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:
- Maintain a
KNOWN_CHAIN_SPECSmapping for chains that have embedded chain specs - When creating a client, if no
--rpcoverride is provided and the chain is inKNOWN_CHAIN_SPECS, prefer the light client - If configured RPC endpoints exist, use those instead (light client as fallback or opt-in)
- Add an
explorerRpcfield toKNOWN_CHAIN_SPECSfor generating explorer links when using light client (since light client doesn't provide a representative RPC URL) - Ensure proper error handling and timeout behavior for light client connections
- Update docs and tests accordingly
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- 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