一文教你如何搭建 Sepolia L1 完整节点(Nethermind + Lighthouse)并作为公共 RPC 使用

本教程将指导你从零开始,在一台服务器上搭建 Sepolia 网络的执行层(Nethermind)和共识层(Lighthouse),完成 JWT 配对,并成功开启 RPC 接口供本地或远程调用。


🚀 推荐服务器配置

  • 操作系统:Ubuntu 22.04 或 24.04

  • CPU:4 核以上(推荐 8 核)

  • 内存:16 GB 或更多

  • 硬盘:

    • SSD,至少 1 TB(随着区块增长需要扩容)

  • 带宽:上传下载均 ≥ 10 Mbps

  • 公网 IP(支持远程访问)


📦 安装 Nethermind(执行层)

# 下载并解压 Nethermind
mkdir -p ~/nethermind-sepolia && cd ~/nethermind-sepolia
wget https://nethdev.blob.core.windows.net/builds/nethermind-1.31.9-98c5dca4-linux-x64.zip
unzip nethermind-1.31.9-98c5dca4-linux-x64.zip

# 创建 JWT 文件(用于与 Lighthouse 通信)
mkdir -p /root/jwt && openssl rand -hex 32 > /root/jwt/jwt.hex

创建 systemd 服务

nano /etc/systemd/system/nethermind.service

# 文件路径:/etc/systemd/system/nethermind.service
[Unit]
Description=Nethermind Sepolia with RPC + WebSocket + Prometheus + txpool
After=network.target

[Service]
User=root
WorkingDirectory=/root/nethermind-sepolia
ExecStart=/root/nethermind-sepolia/Nethermind.Runner \
  --config sepolia \
  --datadir /root/nethermind-sepolia/data \
  --JsonRpc.Enabled true \
  --JsonRpc.Host 0.0.0.0 \
  --JsonRpc.Port 8545 \
  --JsonRpc.WebSocketsPort 8546 \
  --JsonRpc.JwtSecretFile /root/jwt/jwt.hex \
  --Metrics.Enabled true \
  --Metrics.ExposePort 26000 \
  --Metrics.ExposeHost 0.0.0.0 \
  --TxPool.Size 2048 \
  --TxPool.MaxPendingTxsPerSender 100 \
  --TxPool.MinBaseFeeThreshold 5 \
  --TxPool.MaxTxSize 131072 \
  --Sync.SnapSync true \
  --Sync.FastSync false

Restart=always
RestartSec=5
LimitNOFILE=65535

[Install]
WantedBy=default.target

启动 Nethermind:

sudo systemctl daemon-reexec
sudo systemctl enable nethermind
sudo systemctl start nethermind
sudo journalctl -u nethermind -f

🌕 安装 Lighthouse(共识层)

# 安装依赖
sudo apt update && sudo apt install -y curl build-essential pkg-config libssl-dev clang cmake

# 安装 rustup
curl https://sh.rustup.rs -sSf | sh
source $HOME/.cargo/env

# 安装 lighthouse
git clone https://github.com/sigp/lighthouse.git
cd lighthouse
make
sudo cp target/release/lighthouse /usr/local/bin/

创建 systemd 服务

nano /etc/systemd/system/lighthouse.service

# 文件路径:/etc/systemd/system/lighthouse.service
[Unit]
Description=Lighthouse Beacon Node (Sepolia)
After=network.target

[Service]
ExecStart=/usr/local/bin/lighthouse bn \
  --network sepolia \
  --execution-endpoint http://127.0.0.1:8551 \
  --jwt-secrets /root/jwt/jwt.hex \
  --checkpoint-sync-url https://sepolia.checkpoint-sync.ethpandaops.io \
  --datadir /root/lighthouse-data \
  --metrics \
  --http
User=root
Restart=always
RestartSec=5
LimitNOFILE=65535

[Install]
WantedBy=multi-user.target

启动 Lighthouse:

sudo systemctl daemon-reexec
sudo systemctl enable lighthouse
sudo systemctl start lighthouse
sudo journalctl -u lighthouse -f

🔍 如何判断是否同步成功

查询 Nethermind 执行层同步状态

curl -s -X POST http://127.0.0.1:8545 \
  -H "Content-Type: application/json" \
  -d '{"jsonrpc":"2.0","method":"eth_syncing","params":[],"id":1}' | jq

返回为 false 表示同步完成。

查询 Lighthouse 共识层同步状态

curl -s http://localhost:5052/eth/v1/node/syncing | jq

返回:

{
  "data": {
    "is_syncing": false,
    "is_optimistic": false,
    "el_offline": false,
    "sync_distance": "0"
  }
}

表示已完全同步。


🌐 如何从其他机器访问你的 RPC

curl -s -X POST http://你的公网IP:8545 \
  -H "Content-Type: application/json" \
  -d '{"jsonrpc":"2.0","method":"web3_clientVersion","params":[],"id":1}'

返回类似:

{"jsonrpc":"2.0","result":"Nethermind/v1.31.9+linux-x64","id":1}

即可远程成功调用。


✅ 总结:你已经完成了

  • ✅ 部署 Sepolia 执行层 Nethermind,支持 HTTP RPC / WS / Prometheus

  • ✅ 部署 Sepolia 共识层 Lighthouse,并完成 JWT 配对

  • ✅ 支持本地与远程 RPC 调用,可用于 Aztec CLI、zkRollup、L1 开发等

如果你打算开放 RPC 给更多人使用,可搭配 HAProxy 或 Nginx 反向代理添加 HTTPS 支持。


欢迎你将本节点用于 zk rollup、测试网 DApp 开发、Aztec CLI、eth_call 查询等一切正当用途。

✨ 祝你玩得开心!