eth
Sepolia节点搭建

Sepolia节点搭建

简述

  1. geth + prysm
  2. 通信方式 http-jwt

环境准备

硬件资源

  • cpu 至少4核心
  • ram 至少16G
  • disk >1TB

安装程序准备

  • geth 下载 https://geth.ethereum.org/downloads
  • prysm 下载 https://raw.githubusercontent.com/OffchainLabs/prysm/master/prysm.sh

操作系统: ubuntu24

部署搭建

  1. 生成通信密钥
  2. 启动执行节点
  3. 启动共识节点(信标链)

mkdir -p /data/node_home/ethereum
cd /data/node_home

# 生成执行层和共识层通信的 Jwt 密钥
openssl rand -hex 32 | tr -d "\n" > "ethereum/jwt.hex"


# 启动 geth 执行节点
nohup geth --sepolia \
  --syncmode "snap" \
  --datadir /data/node_home/ethereum/execution/geth/data \
  --http --http.api eth,net,engine,admin --http.addr 0.0.0.0 --http.vhosts '*' \
  --authrpc.jwtsecret=/data/node_home/ethereum/jwt.hex --authrpc.vhosts '*' >> geth.log 2>&1 &

# 启动信标链节点

nohup ./prysm.sh beacon-chain --sepolia \
--jwt-secret=/data/node_home/ethereum/jwt.hex \
--checkpoint-sync-url=https://sepolia.beaconstate.info \
--execution-endpoint=http://127.0.0.1:8551 \
--genesis-beacon-api-url=https://sepolia.beaconstate.info \
--p2p-max-peers=100 \
--accept-terms-of-use \
--datadir /data/node_home/ethereum/consensus/data >> prysm.log 2>&1 &

数据同步流程简述

  1. 启动 geth, 加载 JWT 秘钥, 开启 8551 端口监听;
  2. geth 通过内置的引导节点(Bootnodes)接入以太坊 Sepolia 测试网 的 p2p 网络, 获取 p2p 地址本;
  3. geth 等待 prysm 启动握手, 日志持续输出: No beacon client seen
  4. prysm 启动, 加载同一个 JWT 秘钥
  5. prysm 通过快速同步(Checkpoint Sync 检查点同步), 从一个可靠的来源直接下载最新的 信标链状态快照; 即被确认过的最新正确的区块;
  6. prysm 向 geth 发送同步请求, 指定一个高度和区块 hash
  7. geth 从网络中开始下载 prysm 指定高度的状态快照(账户余额, 合约代码等)
  8. geth 下载 快照高度 至 网络最新高度之间的增量 Block
  9. 状态快照下载完毕, 且区间 block 下载完成, 即当已经重放最新区块后, Geth 就可以开始执行新的交易

此时就可以向geth上发送新交易, 但此时 geth 还有后台任务异步执行

  1. 下载历史区块, 如果查询节点还未完成下载的历史区块数据, 节点会响应 null
  2. 为历史交易创建索引, 以便直接通过 tx_hash 查询交易结果
  3. 构建Snapshot, 以便快速查询余额和合约状态;

后台任务会执行很久, 什么时候节点可用 只要 eth.blockNumber 能查询到最新区块高度, 即可以正常发送交易;

部署耗时

  1. 如果能连上好的p2p节点, 同步速率200Mb以上, 同步应该需要10小时;
  2. 8核心主机在最后的历史区块计算和快照上约用时3小时
最后更新于