Skip to content

refactor: single RPC endpoint per chain, remove round-robin fallback#85

Draft
MaximusHaximus wants to merge 2 commits into
masterfrom
chore/single-rpc-endpoint
Draft

refactor: single RPC endpoint per chain, remove round-robin fallback#85
MaximusHaximus wants to merge 2 commits into
masterfrom
chore/single-rpc-endpoint

Conversation

@MaximusHaximus

@MaximusHaximus MaximusHaximus commented Jul 17, 2026

Copy link
Copy Markdown
Contributor

Why

Team ruling: every service uses one and only one RPC endpoint per chain — the internal eRPC proxy, which owns provider redundancy and failover. Client-side multi-endpoint rotation is removed from all services; this repo was the only one with real round-robin fallback.

What changed

  • Env contract: ETHEREUM_RPC, SEPOLIA_RPC, MATIC_RPC, AMOY_RPC now take a single URL string instead of a JSON array of URLs. The JSON-array parsing (parseRpcUrlArray) and the pair-length coupling checks (ETHEREUM↔MATIC, SEPOLIA↔AMOY) are removed. Single-URL validation semantics are unchanged (http/https check; rpc.polygon.tools must be https).
  • Rotation machinery removed: mainnetRpcIndex/testnetRpcIndex deleted from src/config.ts; rpcLength/per-network maxRetries computation deleted from getVersionDetails; the four service-function loops no longer rotate through endpoint pairs.
  • Retry behaviour preserved: transient RPC failures still get a bounded retry — 2 attempts total against the single endpoint, no sleeps (as before). Error classification is unchanged: terminal HTTPError domain errors (BlockNotIncludedError, IncorrectTxError, TxNotCheckpointedError) propagate immediately without retry; the final attempt rethrows/maps exactly as today. logger.warn on retried attempts and rpcOrigin log hygiene (origins only, never full URLs) are unchanged.
  • Untouched: the POSClient promise-cache in src/maticClient.ts (the OOM fix) stays as is.
  • Docs updated to match: .env.example, README.md, CLAUDE.md, and src/scripts/get-receipts-root.ts (read the env var as a plain URL).
  • Changeset included (minor — env contract change).

⚠ Deploy coordination required

The deployed secrets currently hold JSON-array values (e.g. '["https://..."]'). They must be changed to plain single URLs (pointing at the internal eRPC proxy per team standards) in the same rollout as this change, in both production and development. Merging without the secret change will fail env validation at startup — that is the safe failure mode (the service refuses to boot rather than running misconfigured), but the rollouts must be coordinated.

Verification

  • pnpm run lint (ESLint + typecheck + prettier + markdownlint): pass.
  • pnpm test (live-RPC suite): 33/34 pass. The one failure (exit-payload-state-sync.test.ts, amoy) is environmental — rpc-amoy.polygon.technology currently does not resolve in DNS at all (verified via direct curl/dig), so master fails this test identically against the same single configured amoy endpoint.

https://claude.ai/code/session_01928TnCS4kMQPd6uVTewNSN

Claude Code worktrees live under /.claude/worktrees/ per workspace
convention; without this entry they show as untracked in the canonical
clone.

Claude-Session: https://claude.ai/code/session_01928TnCS4kMQPd6uVTewNSN
@sonarqubecloud

Copy link
Copy Markdown

Quality Gate Failed Quality Gate failed

Failed conditions
12.9% Duplication on New Code (required ≤ 3%)

See analysis details on SonarQube Cloud

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant