Skip to content
robert-schmidtPublic

About

Self-hosted Robinhood Chain (chain id 4663) node + indexer: your own Arbitrum Nitro node and ClickHouse. Exact token holders, balances, transfers, swap prices, candles and wallet trades, from your own hardware. An Alchemy / Blockscout alternative with no API keys or paid providers.

Topics

Resources

Stars

2 stars

Watchers

0 watching

Forks

Repository files navigation

rhnode: a self-hosted Robinhood Chain node and indexer

Run your own Robinhood Chain (chain id 4663, an Arbitrum Orbit L2) node and indexer on one box: an Arbitrum Nitro node (and, if you want, the Ethereum L1 node it reads: Geth + Lighthouse), ClickHouse and a TypeScript ingest in one docker compose stack. It follows the chain tip (from your node, or free public RPC endpoints without one), decodes everything into ClickHouse, and derives the facts trading apps usually buy from Alchemy or Blockscout: exact token balances and holders, every ERC-20 transfer back to genesis, pools, a price for every swap, 1-minute candles, and per-wallet trades with PnL inputs. It backs an Ethereum JSON-RPC, WebSocket and Etherscan/Blockscout-compatible API.

No API keys, no paid providers. Everything beyond the indexer is optional and switched on by a compose profile.

Three ways to run it

Each step adds to the one before it, on the same box, with the same docker compose stack. Start with the first and add the next when you want what it gives.

1. Indexer only 2. + your own Robinhood Chain node 3. + your own Ethereum L1 node
Compose profile none (the default) node node,l1
The chain is read from free public RPC endpoints your Nitro node; the public ones are the failover as in 2; Nitro reads Ethereum from your Geth + Lighthouse, public ones are the failover
RAM 8 GB 16 GB at the least, 32 GB to run traces and the history pass 64 GB
Disk (SSD; NVMe from step 2) ~60 GB for 14 days of raw data, plus ~3 GB a day kept forever 2 TB: Nitro ~0.9–1.1 TB (+~7.5 GB a day), the history pass ~0.45 TB once 4 TB: + ~0.7 TB today, up to ~1 TB
CPU 2 cores 4 cores to sync and follow, 8 for traces and the history pass as in 2 (the pair idles at the tip)
Traffic small tens of GB a day in (the sequencer feed; ~60 measured) + ~100 GB a day in, ~35 GB out (Ethereum peers)
First start minutes ~1 TB snapshot download, then ~17 h to catch up 5 days ~11 h sync

1. Indexer only. Follows the tip through the public endpoints and builds the index from the block you start at: balances and holders, transfers, pools, prices, candles, trades. A token older than that is fetched on first request. What you don't get: call traces, history before your start block for everything else, and unlimited RPC (the public endpoints are rate-limited and shared with ingest). Measured 2026-10-29: ~3 GB of RAM in use, a fraction of one core for ingest; ClickHouse is capped by CH_MEM (6 GB by default). The tables kept forever grew 2.8 GiB a day (2026-10-30).

2. Your own node. What this repo is for. Reads become local and unlimited (ingest made 57,115 calls to the node and none to a public endpoint in the hour after a restart, 2026-11-28), about one block behind the sequencer. Only with it: tip traces (every call frame of every tx, internal ETH included), the history pass (the whole chain back to its first block, decoded once: every token's transfers and holders, every wallet's txs), stream replay, and an RPC of your own to serve. It still needs Robinhood's sequencer feed for new blocks and their RPC to forward transactions: those two cannot be self-hosted. Boxes it ran on:

Box What ran How it went
4-core 2014 Xeon E3, 16 GB, NVMe over USB 3 node + index synced from the snapshot at ~75–80 blocks/s; Nitro used ~10 GB of a 12 GB cap, 2–3 GB left free: it works, with nothing to spare (2026-10-30)
i5-11320H mini PC, 32 GB, held to 18 W node + index + traces + history pass followed the tip and ran the whole history pass in 5 days; fell behind in long gas bursts because of the power cap, not the memory (2026-11-05)
i9-12900K, 64 GB all three steps 34 GB of RAM in use; Nitro 20 GB (cap 34), ClickHouse 3.5 GB (cap 12), ~0.8 core for Nitro and ~2 for ClickHouse at the tip (2026-11-28)

3. Your own L1 node. Optional, and it makes nothing faster. What it removes is a dependency: Nitro needs an Ethereum execution RPC and a beacon API that serves blobs, and there is one free keyless beacon that does. With the pair, both are yours (2,301 L1 reads answered by our Geth and every blob by our Lighthouse over the same hour; the public ones were only asked for the head, to compare). The cost is the rest of the table: ~10 GB of RAM (Geth 5.3 GB, Lighthouse 4.7 GB at the tip), 0.72 TB of disk today (Geth 593 GB, Lighthouse 126 GB one day after its sync, still filling its 18-day blob window), and Ethereum's peer traffic. All measured 2026-11-28 (docker stats, docker system df -v; the traffic figures are the containers' counters over 3.4 h, scaled to a day, so they include what the containers send each other). 64 GB is what we run it in: 34 GB are in use, the rest is page cache and room for a burst. Skip it on a metered connection or a 2 TB disk.

What's built

Milestone Status
M0 scaffold: compose (ClickHouse + Redis), config profiles, migrations ✅
M1 tip ingest of every block → raw_* + decoded ev_* (transfers, swaps, pools, launches, Relay fills), keep bits, reorg rollback ✅
M2 projector: balances/holders (agg_balances, serve_tokens), pool identities, prices (two-hop through WETH/stables) + 1m candles, wallet trades ✅
Token promotion: a token older than go-live gets its whole history once, on first request (src/promoter) ✅
Tip traces: every call frame of every tx, taken at the tip on your own node (TRACES=tip), kept 14 days for the stream and tx trace lookups ✅
History pass: every block from go-live back to genesis on your own node, read once and decoded by the ingest decoder (HISTORY=1); kept forever: ERC-20 transfers and balances, swaps, launches, pools, Relay fills, every wallet's txs and ETH transfers ✅ reached genesis 2026-11-05
Launchpad discovery from the chain (no list): contract creations, each token's first minter, curve and graduation pool, ETH and quote tokens paid out of curves ✅
Prices, 1m candles and wallet trades before go-live, derived from what the history pass keeps (no further node reads) partly: 1-minute candles back to 2026-09-01 (checked 2026-11-28); older ones not derived yet
M3 API: /rpc, /ws, Blockscout-compatible /api, API keys (a separate service since 2026-10-30) ✅
M4 /v1/stream with resume (resume_from, replayed from the node), watchlists of wallets and tokens ✅ (in the API service)
M5 /v1 insights REST: token cards, holders, early buyers, pools and risk, launchpads, token origins, new contracts, wallet first txs, candles ✅ (in the API service)
M6 own Nitro node (--profile node), snapshot seeding, L1 proxy, self-heal + CI-gated deploys ✅ synced, ~1 block behind the sequencer (measured 2026-10-31)
Own Ethereum L1 node (--profile l1): Geth + Lighthouse (semi-supernode) answer Nitro's execution reads and blobs through l1proxy; the public endpoints stay as the failover; reachable only inside the stack ✅ synced 2026-11-28
Explorer (src/explorer): blocks, txs, addresses, tokens, live home feed and charts, /about (what serves it, and how far it reaches). Optional access tokens, with the home page open (EXPLORER_OPEN) and guest passes for a site that holds an API key (EXPLORER_PASSES) ✅
Nightly partial backups with rotation and a checked restore (ops/backup.sh, ops/restore.sh) ✅

Design and reasoning: docs/ARCHITECTURE.md.

Run it

This is step 1, the indexer, and the base of the other two. Needs Docker with Compose v2. The images are multi-arch (amd64 and arm64), so the same commands work on Linux and macOS. Indexing every block uses about 3 GB of RAM (measured 2026-10-29) and ~4 GB of disk per day of raw history (56 GB for 14 days, measured 2026-11-28; see RAW_TTL_DAYS), and needs only a fraction of one CPU core (~10 blocks/s at the tip; decoding runs at >5,000 blocks/s on a 2014 Xeon).

git clone https://github.com/robert-schmidt/rhnode && cd rhnode
cp .env.example .env               # set CLICKHOUSE_PASSWORD and REDIS_PASSWORD; RAW_TTL_DAYS decides the disk use
docker compose up -d --build       # clickhouse, redis, ingest (migrates on start, follows the tip), projector
docker compose logs -f ingest      # one JSON line every 30 s: lag, rows written, per-endpoint ok/err

Query it:

docker compose exec clickhouse clickhouse-client -u rhnode --password "$(grep ^CLICKHOUSE_PASSWORD .env | cut -d= -f2)" -d rhnode \
  -q "SELECT token, holder_count, symbol FROM serve_tokens FINAL ORDER BY holder_count DESC LIMIT 10"

Stop with docker compose stop. docker compose down -v deletes the data.

Data starts at the block you start indexing ("go-live"); there is no genesis backfill. A token minted before then is promoted the first time someone asks for its holders or transfers: rhnode fetches that token's earlier Transfer history once (a few address-filtered eth_getLogs calls, usually under a minute), keeps it forever, and answers exactly from then on. Tokens with more than PROMOTE_MAX_TRANSFERS (500,000) earlier transfers stay refused. With your own node, the history pass (next section, step 4) reads everything before go-live once, and this limit is gone.

Run your own Nitro node (optional)

Without a node, /rpc proxies free public endpoints (rate-limited, shared with ingest). With one, the reads are local and unlimited. It's the official offchainlabs/nitro-node image, already defined in compose.yaml under the node profile.

Needs: an NVMe with ~1.2 TB for the node to start (the snapshot unpacks to ~1.03 TB and grows ~7.5 GB a day; ours is 0.9 TB after the watchtower pruned it, 2026-11-28). While seeding, the downloaded parts (~1.1 TB) and the unpacked database exist together: give snapshot.sh a work dir on another disk, or have ~2.2 TB free. At least 16 GB of RAM for the whole stack, and an L1 Ethereum RPC that serves eth_getLogs older than ~128 blocks. Keyless https://eth.drpc.org works (the default); a free PublicNode token from allnodes.com works too. The beacon API for blobs defaults to PublicNode's keyless one. Measured 2026-10-30 on a 4-core Xeon E3 with a USB 3 NVMe: the node replays ~75–80 blocks/s, against ~9.6 produced, so it catches up ~5 days in ~17 h.

Nitro's memory is capped by NITRO_MEM (default 8g, sized for a 16 GB box; the kernel kills Nitro first, not ClickHouse). What we ran, each for weeks:

Box RAM NITRO_MEM NITRO_GOMEMLIMIT CH_MEM
16 GB 12g 6500MiB 6000000000 (the default)
32 GB 18g 10000MiB 6000000000
64 GB (with the L1 pair) 34g 14336MiB 12000000000
# 1. Seed it from the official snapshot (resumable, verifies each part, ~1 TB download; the parts are deleted after).
VOL=$(docker volume inspect rhnode_nitro -f '{{.Mountpoint}}' 2>/dev/null || (docker volume create rhnode_nitro >/dev/null && docker volume inspect rhnode_nitro -f '{{.Mountpoint}}'))
sudo sh nitro/snapshot.sh "$VOL/robinhood" /path/with/1.1TB/free
# 2. Turn the profile on and start it (it reads L1 through l1proxy, so a keyed URL never reaches Nitro's logs).
echo COMPOSE_PROFILES=node >> .env      # optional: L1_HTTP=url|rps,…  NITRO_MEM=12g  NITRO_DB_CACHE=2048
docker compose up -d
docker compose logs -f nitro | grep 'created block'   # l2Block counts up to the chain's head
# 3. Once synced, send /rpc and ingest to it, with the public endpoints as fallback:
#    UPSTREAM_HTTP=http://nitro:8547|500,https://rpc.mainnet.chain.robinhood.com|10
# 4. Optional, each on its own line in .env, then `docker compose up -d` (Nitro restarts once for its two):
#    TRACES=tip  NITRO_DIFF_LAYERS=1200   every call frame of every block, traced at the tip, kept RAW_TTL_DAYS
#    HISTORY=1                            the history pass: go-live back to the first block, once (~0.45 TB of ClickHouse;
#                                         5 days on the 18 W mini PC; it slows down by itself when ingest or the node trail)
#    NITRO_WATCHTOWER=true                watch the rollup's assertions on L1 (no stake, no transactions); also what
#                                         prunes old sequencer messages (300 GB of 1.2 TB after 7 months)

On macOS, Docker Desktop's VM needs the memory for it (Settings → Resources) and its disk image on a drive with room.

Run your own L1 node (optional)

Step 3, and the one to skip if in doubt: the node of the section above runs fine on the public L1 endpoints, and they stay configured as the failover either way. Needs the node profile, ~10 GB more RAM, ~0.7–1 TB more disk and an unmetered connection (see the table at the top).

Nitro reads Ethereum for the batches the sequencer posts: an execution RPC and a beacon API for the blobs. The public keyless ones work, but there is only one free beacon that serves blobs. The l1 profile adds the pair to the same box: Geth (history only from the rollup's deployment block, so ~0.53 TB, measured, instead of ~1.3) and Lighthouse as a semi-supernode (since PeerDAS an ordinary beacon node cannot return whole blobs; half custody can, for ~0.1–0.4 TB more depending on how many blobs Ethereum carries). They used ~10 GB of RAM together on the first sync (measured 2026-11-28; the caps are 12 GB each), which took 11 hours with Geth held to one core. No stake is involved, and the pair serves this stack only: no port is published, so its RPC and beacon API answer inside the compose network alone (Nitro, through l1proxy); it only dials out to Ethereum peers.

# 1. Start the pair. Geth snap-syncs from its peers (hours), Lighthouse starts from a checkpoint (minutes).
#    Nitro is not touched and keeps reading the public endpoints meanwhile. (macOS: sed -i '' …)
sed -i 's/^COMPOSE_PROFILES=.*/COMPOSE_PROFILES=node,l1/' .env
echo L1_LOCAL=http://l1geth:8545 >> .env && docker compose up -d l1geth l1beacon l1proxy
docker compose logs -f l1proxy | grep '\[l1\]'      # "our node is at the head: using it" = Nitro's L1 reads are local
# 2. When the beacon is synced (is_syncing false, el_offline false) and returns blobs (200 and a body of megabytes;
#    a head block without blobs gives a short one: ask again a slot later):
docker compose exec l1proxy node -e "fetch('http://l1beacon:5052/eth/v1/node/syncing').then(r=>r.text()).then(console.log)"
docker compose exec l1proxy node -e "fetch('http://l1beacon:5052/eth/v1/beacon/blobs/head').then(async r=>console.log(r.status,(await r.text()).length))"
# 3. Put it first: add these three lines to .env, then `docker compose up -d` (l1proxy is recreated, Nitro restarts once):
#    L1_BEACON=http://l1proxy:8545
#    L1_BEACONS=http://l1beacon:5052,https://ethereum-beacon-api.publicnode.com
#    L1_BEACON_FALLBACK=https://ethereum-beacon-api.publicnode.com     Nitro's own second beacon, for when l1proxy is down

To leave it again: take the L1_* lines out, set COMPOSE_PROFILES=node, docker compose up -d, and remove the two containers and their volumes (rhnode_l1geth, rhnode_l1beacon) to get the disk back.

The public endpoints stay in place as the failover: l1proxy uses Geth only while it is within L1_MAX_BEHIND blocks of them (src/chain/l1.ts), and for blobs it asks L1_BEACONS in order, passing over a beacon that errors or answers with a blob missing (Nitro's own secondary-beacon-url only covers an error). l1proxy also writes the pair's state to Redis every 10 s (rh:l1: Geth at the head or not, the beacon synced or not, seconds since each was last good), so whatever serves your health check can alert when it has been routing around a dead one.

Serving it

The API (Ethereum JSON-RPC, WebSocket subscriptions, Etherscan/Blockscout-compatible REST) is a separate service that reads this stack's ClickHouse, Redis (the live block stream) and node. On one box it reaches them on the compose network. On a second box (e.g. a public edge server on the same LAN), set NODE_BIND=0.0.0.0 and API_HOST=<its IP> here: ClickHouse :8123, Redis :6379 and Nitro :8547/:8548 are then published, and ops/firewall.sh (run at boot by ops/rhnode-firewall.service) admits only API_HOST to them on the LAN interface. ops/harden.sh locks the box down around that: SSH keys only for one user, root locked, ufw letting in only SSH from the LAN, fail2ban, and the firewall unit installed.

Looking for the API repo? Get in touch and I'll share it with you if you're worthy.

Exactness for API consumers: serve_tokens.complete, the raw window (raw_blocks from go-live), and the history floor (ctl_cursors walk, the history pass's floor, or go-live before it starts) say what can be answered exactly; anything older is "unknown".

Linux

  • Docker Engine: curl -fsSL https://get.docker.com | sh (or your distro's docker-ce packages), then run the commands above with sudo or add yourself to the docker group.
  • Keep the data on a dedicated disk so the system disk can't fill. Docker ≥ 29 stores images in containerd and volumes in Docker's own root, so move both:
    # /etc/docker/daemon.json
    { "data-root": "/mnt/data/docker", "log-driver": "json-file", "log-opts": { "max-size": "20m", "max-file": "3" } }
    # /etc/containerd/config.toml, first line
    root = "/mnt/data/containerd"
    and add RequiresMountsFor=/mnt/data to both services (systemctl edit docker containerd), so they wait for the disk.
  • USB disks: use a USB 3 port. lsusb -t should show Driver=uas at 5000M; on USB 2 (usb-storage, 480M) writes drop to ~40 MB/s, which ClickHouse tolerates but a Nitro node doesn't.

macOS

  • Docker Desktop or OrbStack. Give the VM at least 6 GB of memory and enough disk (Settings → Resources); on Docker Desktop, move the disk image to an external drive there if the internal one is small. Keep the data in named volumes (the default here): bind mounts go through virtiofs and are much slower for a database.
  • "Clean / Purge data" in Docker Desktop deletes the VM disk, i.e. all indexed data.
  • While the Mac sleeps, ingest pauses; on wake it catches up from its cursor.

Releases and restarts (a server)

  • Release: ops/deploy.sh (on the server, in the repo). It deploys origin/main only when its GitHub CI checks are green. It rebuilds the app image and recreates only the app services (ingest, projector, promoter, l1proxy), then waits for ingest to store new blocks. If it doesn't within 3 minutes, it rolls back to the previous commit. ClickHouse, Redis and Nitro are never restarted by a release: when their definition changed, it says so, and ops/deploy.sh --infra applies it.
  • Restarts: every service has restart: unless-stopped, and Docker waits for the data disk (RequiresMountsFor). On top of that, ops/rhnode-heal.timer runs ops/heal.sh every 2 minutes: it mounts DATA_MOUNT if the disk came up late, starts Docker, and runs docker compose up -d when a service isn't running. The one running container it restarts is Nitro, cleanly (it persists first): when its head hasn't moved for 10 minutes, or before the kernel would kill it (≥95% of NITRO_MEM, or under 1 GB available), at most once per 30 minutes and 3 times in 6 hours. To stop the stack on purpose, stop the timer first. Install it (the units assume /srv/rhnode):
    sudo cp ops/rhnode-heal.service ops/rhnode-heal.timer /etc/systemd/system/
    sudo systemctl daemon-reload && sudo systemctl enable --now rhnode-heal.timer
  • Backups: ops/rhnode-backup.timer runs ops/backup.sh nightly. It dumps only what the node can't give back (tables from tip traces, ctl_* state, small slow-to-recompute tables: ~400 MB, 40 s), keeps the newest BACKUP_KEEP here (default 1), and uploads each one to BACKUP_SSH if set: there ops/backup-recv.sh lets that key only add files and keeps the newest 1. Everything else is rebuilt from the node by the history pass. Restore (pull the dump back from the backup box first) with sudo sh ops/restore.sh /srv/rhnode-backups/<dump>: it verifies the checksums, loads tables that are empty or missing, and compares row counts (--replace overwrites, --db name restores into a scratch database). On a fresh box, migrate first: docker compose up -d clickhouse && docker compose run --rm ingest node src/migrate.ts.
  • Nitro stops with a 5-minute grace period and resumes from its database. After an unclean stop it re-executes from its last persisted state.

Develop

Node 26 runs the TypeScript directly (no build step).

npm install
docker compose up -d                # ClickHouse on 127.0.0.1:8123 for host tools (NODE_BIND defaults to loopback)
npm run check                      # tsc + tests (the ClickHouse tests use their own rhnode_test database)
npm run ingest -- backfill FROM TO # re-read a block range through the same code (idempotent within the dedup window)
node --env-file=.env src/tools/check-balances.ts   # compare indexed balances with balanceOf on chain

Layout

src/chain/      decoders (launchpads, v2/v3/v4 swaps, Relay fills), constants, the rotating upstream client
src/ingest/     tip follower + backfill, keep rules, reorg rollback
src/projector/  pools, balances/holders, prices + candles, trades
src/promoter/   the history pass, on-demand history of tokens older than go-live, watched wallets
src/discovery.ts launchpads from the chain: creations, token origins, markets, curve payouts
src/explorer/   the block explorer pages
src/l1proxy.ts  Nitro's L1 reads: our own L1 node first while it is at the head, then the public ones; no keyed URL in Nitro's logs
nitro/          the chain's official config files, snapshot.sh
ops/            deploy.sh (CI-gated releases), heal.sh (self-healing), backup.sh + restore.sh, systemd units
migrations/     ClickHouse schema (applied in order on start)

What the stack runs (all pinned in compose.yaml / package.json):

Piece Version Role
ClickHouse clickhouse/clickhouse-server:26.3 the store
Redis redis:7.4-alpine block fan-out to /ws
Node.js node:26-slim (runs .ts directly) ingest, projector, promoter, api, l1proxy
Nitro (profile node) offchainlabs/nitro-node:v3.12.2-5f02f3f own Robinhood Chain node
Geth (profile l1) ethereum/client-go:v1.17.10 own Ethereum execution node (history from the rollup's deployment block)
Lighthouse (profile l1) sigp/lighthouse:v8.3.3 own Ethereum beacon node, semi-supernode (serves blobs)
npm @clickhouse/client, viem, redis, ws

Support

If you find this helpful, consider donating:

  • SOL: E8tLUC1RhBpRoF1we4onS5MkmpDQVVRvrqbE6Pyhufon
  • EVMs: 0x8F06CE722d269567EbaEe6eA4fECE247534587A7
  • BTC: bc1q0jcp0e4muy53xlaxhz6pszgp8a9jpj6cmd95qh

License

MIT

About

Self-hosted Robinhood Chain (chain id 4663) node + indexer: your own Arbitrum Nitro node and ClickHouse. Exact token holders, balances, transfers, swap prices, candles and wallet trades, from your own hardware. An Alchemy / Blockscout alternative with no API keys or paid providers.

Topics

Resources

Stars

2 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages