Linux-Ubuntu系统搭建Filcoin/lotus钱包节点
1.系统与配置
本文系统与配置: Ubuntu18 和12核24G 1TSSD硬盘(最低基础配置) 。很多人说centos系统不可以,但未去验证 。
本文参考部署文档:https://docs.filecoin.io/get-started/lotus/installation/#software-dependencies
2.适用文档
Lotus API:https://github.com/filecoin-project/lotus/blob/master/documentation/en/api-methods.md。
Filcoin区块链浏览器:https://filscout.io/zh
Filecoin RPC API文档:http://cw.hubwiz.com/card/c/filecoin-lotus-rpc/
3.安装依赖包
// Ubuntu系统
apt install mesa-opencl-icd ocl-icd-opencl-dev gcc git bzr jq pkg-config curl clang build-essential libhwloc-dev -y && sudo apt upgrade -y
4.rust 和go 环境配置
// Ubuntu系统 安装rust
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
// Ubuntu系统 安装go 需要1.16.0及以上版本
wget -c https://golang.google.cn/dl/go1.16.4.linux-amd64.tar.gz -O - | sudo tar -xz -C /usr/local
// 配置环境变量
###########GO##########
echo 'export GOROOT=/usr/local/go' >> /etc/profile
echo 'export GOPATH=/home/go/goProject' >> /etc/profile
echo 'export GOBIN=$GOPATH/bin' >> /etc/profile
echo 'export PATH=$PATH:$GOROOT/bin' >> /etc/profile
echo 'export PATH=$PATH:$GOPATH/bin' >> /etc/profile
echo 'export GOPROXY=https://goproxy.io' >> /etc/profile
###########lotus#######
echo 'export LOTUS_PATH=/data/lotusdata' >> /etc/profile
echo 'export LOTUS_HOME=/data/lotus' >> /etc/profile
echo 'export PATH=$PATH:$LOTUS_HOME' >> /etc/profile
配置生效
source /etc/profile
5.下载lotus并安装
git clone https://github.com/filecoin-project/lotus.git
cd lotus/
git checkout master
//下载安装libhwloc-dev后再make
apt install libhwloc-dev
make
make install
6.同步接口
启动节点
nohup lotus daemon --import-snapshot https://fil-chain-snapshots-fallback.s3.amazonaws.com/mainnet/minimal_finality_stateroots_latest.car >> nohup.log 2>&1 &
查看日志,若报错:
ERROR: fetching proof parameters: fetching file /var/tmp/filecoin-proof-parameters/v28-proof-of-spacetime-fallback-merkletree-poseidon_hasher-8-0-0-5294475db5237a2e83c3e52fd6c2b03859a1831d45ed08c4f35dbf9a803165a9.vk failed: Get "https://proofs.filecoin.io/ipfs/QmUiVYCQUgr6Y13pZFr8acWpSM4xvTXUdcvGmxyuHbKhsc": dial tcp: lookup proofs.filecoin.io on 127.0.0.53:53: server misbehaving
需要先执行以下命令,再启动节点
export IPFS_GATEWAY=https://proof-parameters.s3.cn-south-1.jdcloud-oss.com/ipfs/
停止节点
lotus daemon stop
7.查看同步情况
lotus sync wait
打印diff: 0表示同步成功。如下:
Worker: 107457; Base: 603101; Target: 603101 (diff: 0)
State: complete; Current Epoch: 603101; Todo: 0
如果没有上述信息打印,则还未同步完成。需要等待几个小时
8.生成token
lotus auth create-token --perm admin
总结