跳到主要内容

节点连接到 JOC

本文件描述了如何在用户环境中构建 Geth 节点并连接到 Japan Open Chain 的主网和测试网。如果您希望通过 RPC Endpoints 连接 dApps,请参考这里。

连接到 JOC 主网的节点​

连接的步骤如下所示。

1. 安装必要的软件包​

# Ubuntu / Debian
sudo apt-get update
sudo apt-get install -y curl openssl

# Amazon Linux 2023 / RHEL 系
sudo dnf install -y curl openssl

2. 创建数据目录​

sudo mkdir -p /data/ethereum
sudo mkdir -p /data/ethereum/consensus/config

3. 下载配置文件​

请下载以下文件,并分别放置到指定位置。

文件链接
genesis.json查看
config.yaml查看
genesis.ssz下载
deposit_contract.txt查看
deposit_contract_block.txt查看
# genesis.json -> /data/ethereum/genesis.json
# config.yaml -> /data/ethereum/consensus/config/config.yaml
# genesis.ssz -> /data/ethereum/consensus/config/genesis.ssz
# deposit_contract_block.txt -> /data/ethereum/consensus/config/deposit_contract_block.txt

4. 安装客户端​

Geth(执行层客户端,已验证兼容 v1.13.5):

https://geth.ethereum.org/docs/getting-started/installing-geth

警告

目前尚不支持 Geth v1.14.0 及以上版本。

Lighthouse(共识层客户端,已验证兼容 v7.0.1):

https://lighthouse-book.sigmaprime.io/installation.html

5. 生成 JWT 密钥​

JWT 密钥用于验证 Geth 与 Lighthouse 之间的内部通信。仅需生成一次。

openssl rand -hex 32 | tr -d "\n" > /data/ethereum/jwtsecret
chmod 644 /data/ethereum/jwtsecret

6. 初始化 Geth​

geth init \
--datadir=/data/ethereum \
/data/ethereum/genesis.json

该命令仅需执行一次。

7. 启动 Geth​

当前的 BootNode 列表从 enodes.yaml 获取。

geth --datadir=/data/ethereum \
--networkid=81 \
--http \
--authrpc.vhosts="*" \
--authrpc.addr=127.0.0.1 \
--authrpc.jwtsecret=/data/ethereum/jwtsecret \
--bootnodes="$BOOTNODES"

8. 启动 Lighthouse​

当前的 Boot ENR 列表从 bootstrap_nodes.yaml 获取。

lighthouse beacon_node \
--datadir=/data/ethereum/consensus \
--http \
--execution-endpoint=http://127.0.0.1:8551 \
--execution-jwt=/data/ethereum/jwtsecret \
--testnet-dir=/data/ethereum/consensus/config \
--boot-nodes="$BOOT_ENRS"

9. 验证​

检查 Geth 的同步状态。

curl -s -X POST http://localhost:8545 \
-H "Content-Type: application/json" \
-d '{"jsonrpc":"2.0","method":"eth_syncing","params":[],"id":1}'
# false → 同步完成
# object → 同步中(会显示 currentBlock / highestBlock)

检查 Lighthouse 的同步状态。

curl -s http://localhost:5052/eth/v1/node/peer_count

如果“Looking for peers”消息持续出现,说明未成功连接,请检查 bootnode/ENR 的值以及防火墙设置(Geth 为 30303 端口的 TCP+UDP,Lighthouse 为 9000 端口的 TCP+UDP)。

浏览器​