运行ETH轻客户端

又是一篇折腾Homelab的文章。运行一个属于自己的ETH节点是一个很酷的事情。但是随着ETH网络的增长。状态这个特性带来的问题也逐渐显现出来。目前的ETH如果需要运行一个全节点的话需要700GB的SSD。对于一般的玩家来说,这个在HomeLab的环境中算是一个不小的开销了。

所以这里来运行一个轻客户端来试着体验Geth的功能,因为他的硬盘开销只有区区的400M。为什么呢?因为他只存储了区块头信息。并没有保存区块内容。每次请求都需要去远程的 lightserver 上来获取信息。所以这里称之为一个客户端

部署过程

部署过程是根据官方的Doc进行的。安装Geth,之后进行区块同步,没有什么特别的难点这里记录一下。

下面的几条命令在ubuntu下即可完成Geth的安装。

sudo add-apt-repository -y ppa:ethereum/ethereum
sudo apt-get update
sudo apt-get install ethereum
sudo apt-get upgrade geth

下一步是生成配置文件。geth本身有缺省的参数,但是还是配置文件来的直观。使用下面的命令来对当前的配置进行导入

geth --syncmode light --http --http.addr 0.0.0.0 dumpconfig > ./config.toml

之后在系统中注册服务,用于进程的守护和日志管理。

cat << EOF > /etc/systemd/system/geth.service
[Unit]
Description=Ethereum go client
[Service]
Type=simple
ExecStart=/usr/bin/geth --config /home/user/.ethereum/config.toml
[Install]
WantedBy=default.target
EOF

sudo systemctl restart geth

之后把服务跑起来,过会就能见到同步的过程了。

INFO [12-21|10:07:37.709] Imported new block headers               count=192 elapsed=527.893ms number=14,873,535 hash=9d539e..33aec7 age=6mo3w3d

另外分享一些eth节点列表的查询站点。可以选取部分配置为static节点。

  • https://ethernodes.org/nodes
  • https://www.nodewatch.io/
  • https://etherscan.io/nodetracker

Reference

  • https://geth.ethereum.org/docs/interface/peer-to-peer
  • https://geth.ethereum.org/docs/interface/command-line-options
  • https://geth.ethereum.org/docs/interface/les

发表回复

您的电子邮箱地址不会被公开。 必填项已用 * 标注