paritytech / paritytech/polkadot-cli

feat: support multiple RPC providers per chain with fallback

Open
#48 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

Problem

Each chain has a single rpc: string endpoint. If that endpoint is unreachable, the CLI fails with no automatic recovery. This is especially problematic for public RPC endpoints which can have downtime.

Proposal

Allow configuring multiple RPC endpoints per chain with automatic fallback.

Type change (src/config/types.ts)
export interface ChainConfig {
  rpc: string | string[];  // single URL or ordered list (first = primary)
  lightClient?: boolean;
}
Fallback behavior
  • Try endpoints in order; on connection failure or timeout, try the next
  • Log which endpoint was selected
  • The --rpc CLI flag overrides all configured endpoints with the given URL
CLI changes
  • dot chain add <name> --rpc wss://a --rpc wss://b — add chain with multiple RPCs
  • Consider dot chain rpc add/remove/list <name> subcommands for managing endpoints on existing chains
Example built-in config with multiple providers
polkadot: {
  rpc: [
    "wss://rpc.polkadot.io",
    "wss://polkadot-rpc.dwellir.com",
    "wss://rpc.ibp.network/polkadot",
  ],
}

Files to modify

  • src/config/types.ts — change rpc type to string | string[]
  • src/core/client.ts — implement fallback logic in createChainClient
  • src/commands/chain.ts — support multiple --rpc flags
  • src/config/store.ts — ensure config read/write handles arrays

Considerations

  • Backward compatible: existing configs with rpc: "wss://..." still work
  • Investigate if polkadot-api's getWsProvider already supports multiple URLs before building custom fallback
  • Keep it simple: only fail over on connection error, no proactive health checks

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 with src/config/types.ts and investigate whether polkadot-api's getWsProvider already accepts multiple URLs. Trace createChainClient in src/core/client.ts, then review src/commands/chain.ts and src/config/store.ts for CLI parsing and config persistence. Done means ordered fallback works for connection failures and timeouts, logging identifies the selected endpoint, and a single --rpc override remains supported.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
cli
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.