Настройка RPC-ноды
Зависимость от публичных RPC — Alchemy, Infura, QuickNode — это зависимость от чужого uptime, rate limit'ов и ценовой политики. При объёме запросов от 100k/день экономика собственной ноды становится выгодной. Кроме стоимости: собственная нода даёт полный debug_* и trace_* namespace, которые публичные провайдеры часто отключают или тарифицируют отдельно.
Выбор клиента для Ethereum
Два основных execution client'а:
Geth (go-ethereum) — самый распространённый, наибольшая документация, стабильный. Archive mode занимает ~16 TB. Самый медленный на eth_getLogs по большим диапазонам блоков.
Reth (Paradigm) — написан на Rust, значительно быстрее Geth на запросы истории. Archive mode ~2.5 TB (лучшее сжатие). Рекомендую для новых установок.
Erigon — архивная нода ~3 TB, быстрые исторические запросы, но сложнее в настройке и обновлении.
| Клиент | Диск (archive) | Синхронизация | Историч. запросы |
|---|---|---|---|
| Geth | ~16 TB | 2–4 нед | Медленно |
| Reth | ~2.5 TB | 3–7 дней | Быстро |
| Erigon | ~3 TB | 3–7 дней | Быстро |
Установка Reth + Lighthouse (Ethereum mainnet)
Ethereum PoS требует два клиента: execution layer (Reth) + consensus layer (Lighthouse/Prysm):
# Reth
curl -L https://github.com/paradigmxyz/reth/releases/latest/download/reth-x86_64-unknown-linux-gnu.tar.gz | tar xz
sudo mv reth /usr/local/bin/
# Lighthouse (consensus client)
curl -L https://github.com/sigp/lighthouse/releases/latest/download/lighthouse-x86_64-unknown-linux-gnu.tar.gz | tar xz
sudo mv lighthouse /usr/local/bin/
# JWT secret для связи между клиентами (Engine API)
openssl rand -hex 32 > /etc/ethereum/jwt.hex
Запуск execution layer (Reth):
reth node \
--chain mainnet \
--datadir /data/reth \
--http \
--http.addr 127.0.0.1 \
--http.port 8545 \
--http.api eth,net,web3,txpool,debug,trace \
--ws \
--ws.addr 127.0.0.1 \
--ws.port 8546 \
--authrpc.addr 127.0.0.1 \
--authrpc.port 8551 \
--authrpc.jwtsecret /etc/ethereum/jwt.hex \
--full # full node, для archive добавьте --full=false
Запуск consensus layer (Lighthouse):
lighthouse beacon_node \
--network mainnet \
--datadir /data/lighthouse \
--execution-endpoint http://127.0.0.1:8551 \
--execution-jwt /etc/ethereum/jwt.hex \
--checkpoint-sync-url https://mainnet.checkpoint.sigp.io \
--disable-deposit-contract-sync
--checkpoint-sync-url — синхронизация консенсус-клиента начинается с финального checkpoint вместо genesis. Сокращает время с недель до часов.
Настройка Nginx как reverse proxy
Прямой доступ к RPC-порту снаружи — плохо. Nginx + auth + rate limiting:
upstream ethereum_rpc {
server 127.0.0.1:8545;
keepalive 32;
}
server {
listen 443 ssl;
server_name rpc.yourdomain.com;
ssl_certificate /etc/letsencrypt/live/rpc.yourdomain.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/rpc.yourdomain.com/privkey.pem;
# Базовая auth или IP whitelist
satisfy any;
allow 10.0.0.0/8; # внутренняя сеть
deny all;
location / {
proxy_pass http://ethereum_rpc;
proxy_http_version 1.1;
proxy_set_header Connection "";
proxy_set_header Host $host;
proxy_read_timeout 300s;
# Rate limiting
limit_req zone=rpc_limit burst=100 nodelay;
}
}
# Определение зоны rate limit
limit_req_zone $binary_remote_addr zone=rpc_limit:10m rate=100r/s;
WebSocket для subscriptions — отдельный location:
location /ws {
proxy_pass http://127.0.0.1:8546;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_read_timeout 3600s; # долгоживущие соединения
}
BSC, Polygon, другие EVM-сети
Большинство EVM-сетей — форки Geth. Принцип тот же, клиент свой:
# BNB Smart Chain — BSC Geth
geth --config config.toml \
--datadir /data/bsc \
--http --http.api eth,net,web3,txpool \
--ws --ws.api eth,net,web3,txpool
# Polygon — Bor (форк Geth) + Heimdall (consensus)
# Solana — отдельная история, см. solana-validator
Для Polygon нужно запустить оба: Bor (execution) и Heimdall (PoS consensus layer), аналогично связке Reth+Lighthouse.
Мониторинг ноды
// Проверка синхронизации
async function checkNodeHealth(rpcUrl: string): Promise<NodeHealth> {
const provider = new ethers.JsonRpcProvider(rpcUrl);
const [syncStatus, blockNumber, peerCount] = await Promise.all([
provider.send('eth_syncing', []),
provider.getBlockNumber(),
provider.send('net_peerCount', []),
]);
const isSyncing = syncStatus !== false;
return {
blockNumber,
peers: parseInt(peerCount, 16),
isSyncing,
currentBlock: isSyncing ? parseInt(syncStatus.currentBlock, 16) : blockNumber,
highestBlock: isSyncing ? parseInt(syncStatus.highestBlock, 16) : blockNumber,
lag: isSyncing ? parseInt(syncStatus.highestBlock, 16) - parseInt(syncStatus.currentBlock, 16) : 0,
};
}
Алерты: нода считается здоровой если lag < 5 блоков и peers >= 5. При peers = 0 — нода изолирована от сети, что хуже чем просто отставание.
Prometheus + Grafana для долгосрочного мониторинга: Reth и Geth экспортируют метрики нативно (--metrics.port 9001). Готовые дашборды — в репозиториях соответствующих клиентов.







