之前写了一篇用docker部署Iron Fish的文章:部署Iron Fish测试网节点

跑了一阵子,发现docker性能不行,而且老卡在某个区块同步不了。又不能修改源代码,所以决定直接通过编译源代码来部署节点

部署后,发现挖矿效率高了10倍!下面介绍一下怎么在Ubuntu上编译源代码并开启Iron Fish挖矿

image.png

安装必要的环境

1
2
sudo apt-get update -y && sudo apt-get upgrade -y;
sudo apt-get install build-essential -y;

安装/升级nodejs v16.x.x

查看系统node版本
node -v
如果命令出错,安装nodejs:

1
2
3
sudo apt install -y curl
curl -fsSL https://deb.nodesource.com/setup_16.x | sudo -E bash -
sudo apt install -y nodejs

如果版本不是v16.x.x, 安装v16.x.x版本:

1
2
npm install -g n
sudo n v16.2.0

安装Rust

1
2
curl https://sh.rustup.rs -sSf | sh
source $HOME/.cargo/env

安装yarn

1
2
sudo apt install npm
npm install --global yarn

下载官方源代码

1
2
3
cd /root
git clone https://github.com/iron-fish/ironfish.git
chown -R root ironfish

修改源代码

源代码里面一次同步的块数是20,但是同步到16000多块的时候,会卡住不动,所以修改一下源代码,把同步的块数改成2(试过5,还是卡住)

运行下面命令修改

1
sed -i 's%const REQUEST_BLOCKS_PER_MESSAGE.*%const REQUEST_BLOCKS_PER_MESSAGE = 2%' /root/ironfish/ironfish/src/syncer.ts

编译源码

1
2
3
4
5
6
cd /root/ironfish
yarn install
yarn build

cd /root/ironfish/ironfish-cli/
yarn build

启动节点(初次启动要同步数据比较慢)

1
2
cd /root/ironfish/ironfish-cli/
nohup yarn ironfish start >nohup.log &

配置Graffiti

1
yarn ironfish config:set blockGraffiti "xxxx"

开启挖矿

1
2
cd /root/ironfish/ironfish-cli/
nohup yarn ironfish miners:start -t -1 >mine.log &

查看节点状态

1
yarn ironfish status -f

查看挖矿速率

1
tail -f mine.log

查看余额

1
yarn ironfish accounts:balance

注册并查看测试网积分
网站:https://testnet.ironfish.network/leaderboard

点击”Sign Up”

image.png

输入邮箱,Graffiti(上面设置的Graffiti名), Discord ID 和国家

image.png

注册成功后,你就可以在leaderboard上查看你的挖矿成果了

image.png