1.服務器
需要300G SSD(建議NVMe)硬盤,最好是裸硬盤,不建議用機械盤。
2.帶寬
建議國外服務器,10M以上,不需要cn2線路
3.操作系統
建議centos7/8,或ubuntu,這里均以centos為例
4.準備環境:
yum update -y
yum install screen iftop iotop -y
4.1.安裝golang
yum install golang -y
或編譯安裝
*注意:如果使用的 Go 版本是 1.13 及以上 (推薦),如果不設置以下命令編譯源碼時可能會出錯
go env -w GO111MODULE=on
go env -w GOPROXY=https://goproxy.io,direct
5.創建一個screen
screen -S heco
*注意1:最后退出時用ctrl+ad(順序按a和d字母即可),不要用exit或ctrl+d退出會話。
*注意2:退出會話后,可以用screen -x heco重新連接到會話。
6.安裝heco客戶端
#這里我的數據目錄,可以根據需要自行更改
mkdir -p /data/heco/data
#下載最新版本并編譯
cd /root
wget -O heco-chain-1.2.1.tar.gz https://github.com/stars-labs/heco-chain/archive/refs/tags/v1.2.1.tar.gz
tar -xvf heco-chain-1.2.1.tar.gz
rm -fr heco-chain-1.2.1.tar.gz
cd heco-chain-1.2.1
make all
7.檢查安裝是否成功
/root/heco-chain-1.2.1/build/bin/geth console
8.設置防火墻
firewall-cmd --permanent --zone=public --add-port=32668/tcp
firewall-cmd --permanent --zone=public --add-port=8545/tcp
firewall-cmd --reload
不懂防火墻配置的,可以先禁用防火墻,關于firewalld的使用技巧,之后會單獨寫一篇教程
9.啟動節點
ulimit -n 65535
/root/heco-chain-1.2.1/build/bin/geth --datadir /data/heco/data --syncmode "fast" --cache=8096 --maxpeers 50 --http --http.addr=0.0.0.0 --http.port=8545 --http.api "web3,debug,personal,net,admin,eth" --http.corsdomain "*" --allow-insecure-unlock
*然后按ctrl+ad回到主會話即可
10.測試驗證
curl -H "Content-Type: application/json" -X POST --data '{"jsonrpc":"2.0","method":"eth_syncing","params":[],"id":1}' http://127.0.0.1:8545
(如果已經追上最新高度,result會返回false)
curl -H "Content-Type: application/json" -X POST --data '{"jsonrpc":"2.0","method":"eth_blockNumber","params":[],"id":1}' http://127.0.0.1:8545
(節點未同步完成可能會返回0)
11.停止節點
方式1:(建議,畢竟停止后還要啟動不是)
screen -r heco
按ctrl+c,等待一會即可看到節點停止
12.接口文檔參考(HECO的文檔與以太坊基本相同)
RPC接口文檔,如:
以太坊JSON RPC手冊 / eth_call - 匯智網
其它參考:
HECO鏈github地址:GitHub - stars-labs/heco-chain: Huobi Eco Chain client based on the go-ethereum fork
主網瀏覽器:HecoInfo (HT) Blockchain Explorer
13.注意事項
*同步到最高區塊所需時間:
需要看網絡帶寬和磁盤io性能,用NVMe的硬盤,讀寫1000到2000左右,100M的國外非cn2帶寬,從0開始同步,大概需要小半天左右。
*如果2天還沒有追上,或者最后100個塊始終追不上,極有可能是服務器磁盤io存在瓶頸,不建議用機械盤,不建議用虛擬機(磁盤不建議做虛擬化),否則io速度不夠用。
*硬盤目前實際會占用211G左右。
*相比eth,bsc,heco的資源消耗和空間占用非常低,一般可以與eth節點部署在同一臺,以節省成本。