Building a Global Zero-Trust XRPL Mesh
Most crypto RPC networks scale by renting bigger clusters and asking users to trust them. Challenger Mesh doesn't ask. Every client verifies 80% UNL quorum and 16-way SHAMap Merkle proofs locally, so the relay layer is completely untrusted. That lets us run 5 regional relays across North America, Europe, Asia, and the Middle East, crowd-source community relays with zero open ports, and keep edge costs near $5/month. Below: why rebuilding the XRPL stack in Rust unlocked this architecture, how the edge router works, and the four distributed-systems challenges we had to solve in production.
5 core relays (EU, US-East, US-West, APAC, GCC) serving ~460 concurrent clients with 0 rejected connections and 0 relay errors; 5 ms p50 WebSocket RPC latency in Ashburn and Singapore (16×–27× faster than xrplcluster.com); a single public endpoint at wss://mesh.lukejudges.com/; and a 4-machine zstd+dict R2 full-history backfill running at ~1,700 ledgers/sec.
1. Why Build a Mesh Instead of Another Big RPC Cluster?
When you run a traditional public XRPL RPC cluster, you inherit two painful constraints at once. First, every node is trusted by clients, so you cannot let strangers contribute capacity without letting them lie about balances or censor transactions. Second, every node needs a heavy database, which makes putting relays in five regions expensive and slow to spin up.
Challenger Light removes both constraints. A client (whether the 219 KB gzipped WASM verifier in light.lukejudges.com or the native challenger-light CLI) fetches the signed UNL, checks 28-of-35 validator STValidation signatures locally, hashes every LedgerHeader with the LWR\0 prefix, and verifies every account or transaction against the 16-way SHAMap Merkle root. A relay cannot forge a balance. It can only drop your connection or stall, and the client immediately fails over to the next relay.
| Property | Third-Party Public / Hosted RPC | Challenger Light + Mesh (Zero-Trust) |
|---|---|---|
| Account & tx integrity | Implicit trust in whatever JSON the RPC server returns. | Verified locally against a 16-way SHAMap Merkle proof anchored to 80% UNL quorum. |
| Compromised node or MITM | Can spoof balances, hide trustlines, or return stale fees/sequences silently. | Fail-closed: forged or unanchored responses are rejected and retried on another relay. |
| Adding third-party capacity | Every new operator expands the trusted blast radius. | Untrusted relays: strangers can serve traffic with zero ability to forge state. |
| Hardware & sync time | Self-hosting requires a full node (200+ GB SSD, hours to sync). | 0 DB: 219 KB gzipped WASM or ~10 MB native CLI, synced in seconds. |
| Availability | Single provider rate limits, regional latency spikes, or outages. | Multi-relay failover: automatic switch across 5 core regions + community nodes. |
Stateless, untrusted relays (~40 MB RAM, no database) are cheap enough to scatter: we run 5 small core relays across Europe, North America, Asia, and the Middle East, let anyone join the pool from a laptop or Docker container without opening a router port, and put a lightweight online router in front of the whole thing.
2. Why Rebuilding the Node in Rust Made This Possible
This mesh would have been painful to build on top of legacy C++ rippled. rippled is a monolithic full node: its P2P overlay, SHAMap verification, binary codec, and ledger store are tightly coupled into a single multi-gigabyte server binary. You cannot easily extract the verifier to run inside a mobile browser or spin up a 40 MB stateless edge relay without dragging the whole node along.
Rebuilding the XRPL protocol stack from scratch in modular Rust crates changed what was possible:
- One cryptographic core, four targets:
xrpl-crypto,xrpl-codec, andxrpl-light-corecompile unchanged into the full validator (challenger), the stateless edge relay (xrpl-light-relay), the zero-DB terminal client (challenger-light), and a 219 KB gzipped WASM verifier (xrpl-light-wasm) running in mobile Safari and Chrome. There is zero reimplementation drift between server, CLI, and browser. - Standalone P2P overlay crate: Because
xrpl-overlayis decoupled from storage, bothxrpl-light-relayandchallenger-lightspeak native XRPL TLS 1.3 P2P (TMValidation,TMGetLedger,TMProofPathRequest) directly to Mainnet hubs, hedging SHAMap proof requests across 12–16 peers with an online peer-decision bandit. - Tiny, predictable footprint: A core relay handles thousands of concurrent WebSockets in ~40–55 MB of RAM with no GC pauses and no disk state. That low overhead is what makes crowd-sourced community relays practical on a spare laptop or a $4/month VPS.
3. The Edge Router: Mini-Jev Bandit & Workers Economics
Every request to wss://mesh.lukejudges.com/ or POST https://mesh.lukejudges.com/rpc hits a single Cloudflare Worker (deploy/cf-mesh-router/worker.js). Instead of static GeoDNS rules that keep sending traffic to a lagging or overloaded box, the Worker runs a lightweight online contextual bandit ported from our Rust peer-selection model (peer_model.rs).
For each candidate relay in /network.json, the Worker computes a 6-dimensional feature vector: [1.0, normGeoDist, normRttEwma, normLag, errEwma, loadRatio], scores it with linear UCB exploration, and updates the weights online via SGD after every connection attempt. Relays with 3 consecutive failures or >70% error EWMA are marked toxic and automatically forgiven after a 120-second cooldown so recovered community nodes can rejoin without manual intervention.
function isEfficient(node, tipSeq, st, now) {
if (!node || !node.healthy || typeof node.url !== "string" || !node.url.startsWith("https://")) {
return false;
}
// Allow up to 4 ledgers of cross-continent / sequential-poll jitter before disqualifying.
if (tipSeq > 0 && Number(node.latest_ledger_seq || 0) > 0 && Number(node.latest_ledger_seq) < tipSeq - 4) {
return false;
}
if (Number(node.peers || 0) < 2) return false;
const tel = node.rpc_telemetry;
if (tel && Number(tel.samples || 0) >= 10) {
const total = Math.max(1, Number(tel.total || tel.samples));
// Prefer relay_errors (internal/upstream faults) over total errors (e.g. actNotFound).
if (typeof tel.relay_errors === "number") {
if (tel.relay_errors / total > 0.15) return false;
} else if (Number(tel.errors || 0) / total > 0.50) {
return false;
}
if (Number(tel.p95_ms || 0) > 500) return false;
}
return !isToxic(st, now);
}
Why WSS Is Nearly Free on Workers
Before committing to Cloudflare Workers as the global entry point, we modeled the bill across scales. The key detail in Cloudflare's pricing is easy to miss: a stateless pass-through fetch() WebSocket proxy (with no Durable Objects) is billed as 1 request per WebSocket handshake, not per WebSocket frame. A wallet that holds a socket open all day and sends 50,000 RPCs costs one Worker request.
| Scale Tier | Concurrent WSS | HTTP POST / mo | Est. Worker Reqs | Monthly Cost |
|---|---|---|---|---|
| Launch (Today) | 500 – 2,000 | 1M | ~1.5M | $5 / mo (in base) |
| Growth | 25,000 | 50M | ~53M | ~$20 / mo |
| Heavy Public RPC | 250,000 | 500M | ~525M | ~$170 / mo (~$25 if 90% WSS) |
| Infura / Alchemy Scale | 1,000,000 | 5B | ~5.1B | ~$1,550 / mo |
We also have a built-in escape hatch for massive scale: our own PWA, SDK, and challenger-light CLI can fetch CDN-cached /network.json once and connect directly to the fastest regional or community relay. That uses 0 Worker requests at any scale while keeping wss://mesh.lukejudges.com/ as the universal drop-in URL for third-party wallets and curl.
4. Four Distributed-Systems Challenges We Solved in Production
None of these showed up in local testing. All four surfaced only when real multi-region traffic hit the edge router and we probed live /health endpoints and Globalping across 21 ASNs.
Spoof-Proof Client IP Propagation Across Reverse Proxies & Edge Workers
What happened: Three regional VPS relays sat behind Caddy on a Docker bridge without authenticated client-IP forwarding. Every external user arrived with Caddy's single Docker IP, pinning unique_client_ips at 1 and triggering the 64-per-IP cap (rejecting 131,000+ connections while CPU sat idle).
Architectural fix: Blindly trusting X-Forwarded-For lets any attacker spoof IPs and bypass rate limits. Instead, we split ingress into two authenticated paths: traffic routed through mesh.lukejudges.com carries a constant-time verified X-Challenger-Edge-Key paired with X-Challenger-Client-IP (stripped before forwarding to untrusted third-party community relays), while direct traffic to regional Caddy origins overwrites CF-Connecting-IP with the true TCP {remote_host} and is only honored by xrpl-light-relay when the socket peer is loopback, RFC1918/Docker, or Tailscale. Within 60 seconds of rollout, all three regions crossed 80+ concurrent clients across 50+ unique IPs with zero rejections.
Telemetry Poisoning an Online Contextual Bandit
What happened: Probing /router/stats from Germany (20 ms from EU) showed eu-relayer disqualified with score: -9, sending European users 4,650 km away to Dubai. The relay was completely healthy, but rpc_telemetry.errors counted every non-success JSON-RPC reply, including normal user queries like actNotFound on unfunded accounts. At 217 / 889 (24.4%), that tripped the bandit's 15% fault cutoff.
Architectural fix: An online router must distinguish client errors from origin faults. We split RpcTelemetry into errors (total) and relay_errors (strictly internal errors, noNetwork, and upstream proof timeouts), and updated worker.js to gate eligibility on relay_errors while allowing 4 ledgers of cross-continent sequential-poll jitter.
Single-Use Request Streams Breaking Edge POST Failover
What happened: In Cloudflare Workers, request.body is a single-use Fetch API ReadableStream. Passing it directly inside our candidate failover loop worked fine on the first hop, but if the primary relay timed out or returned a 5xx, retrying on the second relay threw TypeError: Body has already been used. At the same time, core relays only spoke JSON-RPC over WebSocket while challenger-light --join-mesh spoke both HTTP and WS.
Architectural fix: Unified HTTP POST /rpc and POST / support across xrpl-light-relay (accepting both WS-style {"command": "..."} and standard XRPL HTTP {"method": "...", "params": [{...}]}), and buffered await request.arrayBuffer() once before the failover loop in worker.js with a strict 256 KiB cap (returning 413 above that) so retries never consume a dead stream.
Cold Cloudflare PoPs & Orange-Cloud Subrequest Loops
What happened: Two edge-routing subtleties showed up immediately under global benchmarking. First, a 37-probe Globalping test showed warm France PoPs at 50 ms while cold PoPs in the US, Singapore, and Brazil took 1,069–2,242 ms because cold isolates synchronously awaited /network.json from Germany before routing. Second, persistent WebSocket tests hit 4.9 ms in US-East and 5.8 ms in Singapore (16×–27× faster than xrplcluster.com) where relays use direct grey-cloud origins, while orange-clouded proxied origins added extra Cloudflare-to-Cloudflare hops.
Architectural fix: Cold Worker isolates now route immediately using baked-in 5-region FALLBACK_NODES (0 ms wait) and refresh /network.json asynchronously via ctx.waitUntil(...) at $0 extra cost. On the origin side, core relays behind a Worker router should expose direct grey-cloud endpoints authenticated by X-Challenger-Edge-Key, keeping Cloudflare Tunnels for NATed community relays, and static UI assets (light/) live separately on Cloudflare Workers Static Assets so relay deploys can never take the webpage down.
5. Zero-Port-Forward Community Relays & Capability Routing
Asking someone to configure port-forwarding, dynamic DNS, and TLS certificates stops most volunteers. We built two zero-port-forward paths that both hide the operator's home IP behind an outbound Cloudflare Quick Tunnel:
- Docker 1-liner:
curl -fsSL https://challenger.lukejudges.com/install-relay.sh | bashpulls publicghcr.io/lj-xrpl/challenger-light:lateston a private Docker network, attaches acloudflaredsidecar (with--trust-cf-headersso clients aren't capped at the community container's lower--max-clients-per-ip 16limit), and auto-registers every 60s. - One-keypress TUI (
challenger-lightv0.4.0): Press[r]inside the light client TUI. It starts serving JSON-RPC on0.0.0.0:8080reusing your already-open XRPL P2P peers, and ifcloudflaredis onPATH, automatically spawns an outbound Quick Tunnel, extracts thehttps://*.trycloudflare.comURL, and registers with the mesh until you toggle[r]off.
let target = format!("http://127.0.0.1:{port}");
let mut child = match tokio::process::Command::new("cloudflared")
.args(["tunnel", "--no-autoupdate", "--url", &target])
.stdout(Stdio::null())
.stderr(Stdio::piped())
.kill_on_drop(true)
.spawn()
{
Ok(c) => c,
Err(_) => return, // cloudflared not installed: stay serving locally/LAN
};
// Parse stderr for https://<slug>.trycloudflare.com, show in TUI, and start 60s heartbeats
metrics.set_public_url(Some(tunnel_url.clone()));
run_mesh_registration_loop(tunnel_url, region, callsign, metrics, shutdown_rx).await;
6. Full-History R2 Lakehouse & Real-Traffic Benchmarking
Stateless relays answer live tip queries from XRPL P2P peers in milliseconds, but wallets and explorers also need historical transactions from 2018–2025. Rather than paying for 5 full-history databases across 5 continents, we pack verified XRPL Mainnet history into immutable 1,000-ledger .cpack archives compressed with zstd + a trained XRPL dictionary (2.8×–3.1× compression) on Cloudflare R2 ($0 egress), served straight from Cloudflare Edge via the Worker's ARCHIVE binding.
Four machines (hermes, two auto-reaped Hetzner burst VPSs, and a 32-thread Mac Pro) shard independent ledger ranges in parallel at ~1,700 ledgers/sec combined. Ranges 32,571 → 50M and 85M → 108.75M are already uploaded, and the remaining middle slice is finishing autonomously.
Finally, to make sure we aren't fooling ourselves with cached synthetic pings from our own servers, we publish a full-history Grafana Cloud k6 + Globalping benchmark script (deploy/grafana/k6-mesh-global-bench.js) that harvests fresh real accounts and transaction hashes across six historical eras (live tip, 11h ago, 4.5d ago, 2025, 2023, 2020, 2018) plus Bitstamp/GateHub DEX orderbooks across 8 neutral AWS regions and 35+ residential-ISP ASNs.
7. Join or Inspect the Mesh
Use It in Any Wallet / App
Point xrpl.js, curl, or any XRPL client at the global mesh endpoint:
wss://mesh.lukejudges.com/
https://mesh.lukejudges.com/rpc
Inspect live routing weights: /router/stats · Live Fleet Dashboard
Contribute a Community Relay
Zero open ports, home IP hidden, ~40 MB RAM:
curl -fsSL https://challenger.lukejudges.com/install-relay.sh | bash
Or install Challenger Light v0.4.0 and press [r] inside the TUI.