This repository has been archived by the owner on Mar 1, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 73
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
8b76883
commit 17315c6
Showing
3 changed files
with
302 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,126 @@ | ||
# lotus-miner | ||
# lotus-miner | ||
[English](README_en.md) | ||
|
||
# 推荐配置 | ||
* CPU:AMD 3970X 或 Ryzen Threadripper 其他型号 | ||
* 内存:256 GB | ||
* SSD:2 TB | ||
* 操作系统:Ubuntu 18.04 | ||
|
||
# 最低配置 | ||
未测试。如果有问题可以提issue。 | ||
* CPU:带有 SHA 扩展的 AMD | ||
* 内存:128 GB | ||
* SSD:1 TB | ||
* 操作系统:Linux | ||
|
||
# 特点 | ||
* 首次启动之后,以后所有操作自动化,无需人工干预。 | ||
* 封装操作完全在worker完成,除了最终sealed sector(约33 GB)回传miner之外没有网络传输。 | ||
* 自动发现空闲worker,启动封装操作。 | ||
* 程序退出后,再次启动都能恢复运行。如果出现不能恢复的情况,可以提issue。 | ||
* 基于推荐配置,可以进行单机2个sector的并行运行,每日产出存力200 GB以上。 | ||
|
||
# 安装配置 | ||
将会安装挖矿程序、必要的库、时间校准、显卡驱动、ulimit、swap内存(64 GB)。 | ||
``` | ||
# 下载 | ||
git clone https://github.com/shannon-6block/lotus-miner.git | ||
cd lotus-miner | ||
# 切换至root账户 | ||
sudo su | ||
# 执行安装 | ||
./script/install.sh | ||
# 安装完后可以exit回到之前的账户 | ||
# 如果是首次安装显卡驱动,需要重启以生效 | ||
``` | ||
|
||
# 首次启动 | ||
几个可以配置的环境变量,根据自己需求设置。 | ||
``` | ||
# lotus、miner、worker、零知识证明参数的目录。建议设置为SSD上的目录 | ||
export LOTUS_PATH="$HOME/lotus" | ||
export LOTUS_STORAGE_PATH="$HOME/lotusstorage" | ||
export WORKER_PATH="$HOME/lotusworker" | ||
export FIL_PROOFS_PARAMETER_CACHE="$HOME/filecoin-proof-parameters" | ||
# 设置国内的零知识证明参数下载源 | ||
export IPFS_GATEWAY="https://proof-parameters.s3.cn-south-1.jdcloud-oss.com/ipfs/" | ||
# 手动下载零知识证明参数到FIL_PROOFS_PARAMETER_CACHE目录中,有200GB | ||
lotus fetch-params --proving-params 32GiB | ||
``` | ||
|
||
启动lotus。 | ||
``` | ||
# 启动lotus | ||
nohup lotus > ~/lotus.log 2>&1 & | ||
# 查看日志 | ||
tail -f ~/lotus.log | ||
# 生成account。需要去 https://faucet.testnet.filecoin.io/ 领取测试币和创建矿工账户 | ||
lotus wallet new bls | ||
# 等待节点同步完成 | ||
lotus sync wait | ||
``` | ||
|
||
启动miner。需要先完成领取测试币、注册矿工、节点同步完成。 | ||
``` | ||
# 使用矿工注册结果来初始化miner | ||
# 建议如下所示加上--no-local-storage参数,不用默认位置LOTUS_STORAGE_PATH存数据 | ||
lotus-storage-miner init --actor=xxx --owner=xxxxx --no-local-storage | ||
# 如果miner和worker不在一台机器,需要配置miner的IP | ||
# 取消ListenAddress和RemoteListenAddress前面的注释,并将它们的IP改成局域网IP | ||
vi ~/.lotusstorage/config.toml | ||
# 启动miner。 | ||
# --max-parallel表示每个worker允许并行的sector数量。 | ||
# 当有 256 GB 内存、64 GB swap 和 1.4 TB 硬盘空闲空间的情况下,可以并行2个sector。 | ||
# 当有 128 GB 内存、64 GB swap 和 0.7 TB 硬盘空闲空间的情况下,可以并行1个sector。 | ||
nohup lotus-storage-miner run --max-parallel 2 > ~/miner.log 2>&1 & | ||
# 查看日志 | ||
tail -f ~/miner.log | ||
# storage attach,即告诉miner真正存储数据的地方。请选择机械硬盘或网盘下的目录 | ||
lotus-storage-miner storage attach --init=true --store=true /path/to/storage | ||
# 查看miner信息 | ||
lotus-storage-miner info | ||
``` | ||
|
||
启动worker。 | ||
``` | ||
# 如果miner和worker不在一台机器,需要将miner机器LOTUS_STORAGE_PATH下的api和token两个文件拷贝到worker机器的LOTUS_STORAGE_PATH下 | ||
# 一定需要的环境变量 | ||
export FIL_PROOFS_MAXIMIZE_CACHING=1 | ||
# 可选的环境变量 | ||
# 如下设置会让worker使用GPU计算PreCommit2。建议双显卡的情况下再使用,否则会报显存不够的错误。 | ||
export FIL_PROOFS_USE_GPU_COLUMN_BUILDER=1 | ||
# 如下设置会让worker不使用GPU计算Commit2,而改用CPU。 | ||
export BELLMAN_NO_GPU=true | ||
# 启动worker,需要加入局域网IP | ||
lotus-seal-worker run --address=xxx.xxx.xxx.xxx:3456 > ~/worker.log 2>&1 & | ||
# 查看日志 | ||
tail -f ~/miner.log | ||
``` | ||
|
||
观察运行情况。在miner机器执行。常用命令列举如下。 | ||
``` | ||
lotus-storage-miner info | ||
lotus-storage-miner storage list | ||
lotus-storage-miner workers list | ||
lotus-storage-miner sectors list | ||
``` | ||
|
||
# TODO | ||
* 目前官方代码在Window PoSt部分存在问题。所以,存力有可能发生下降。为了避免这一问题,请不要进行过多手动操作。 | ||
* 程序在推荐配置下顺利运行,没有做过其他环境的测试,如果遇到问题可以提issue。 | ||
* 会及时合入官方的代码改动。 | ||
* 程序经过一段时间稳定之后,会再将算法优化合入。 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,125 @@ | ||
# lotus-miner | ||
|
||
# Recommended | ||
* CPU:AMD 3970X or other models of Ryzen Threadripper | ||
* RAM:256 GB | ||
* SSD:2 TB | ||
* OS:Ubuntu 18.04 | ||
|
||
# Minimum | ||
Not tested. If there is any problem, please raise an issue. | ||
* CPU:AMD with SHA extension | ||
* RAM:128 GB | ||
* SSD:1 TB | ||
* OS:Linux | ||
|
||
# Features | ||
* After the first start-up, all subsequent operations are automate without any manual intervention. | ||
* The sealing operation is completely completed by the worker. There is no network transmission except the final sealed sector (about 33 GB) back to the miner. | ||
* Automatically find idle workers and start sealing operation. | ||
* After the program exits, it can be resumed when it is started again. If there is an exception, please raise an issue. | ||
* Based on the recommended configuration, it is possible to run two sectors in a single machine in parallel, with a daily output of more than 200 GB. | ||
|
||
# Installation | ||
The mining program, necessary libraries, time calibration , GPU driver, swap memory (64 GB) will be installed. | ||
``` | ||
# Download | ||
git clone https://github.com/shannon-6block/lotus-miner.git | ||
cd lotus-miner | ||
# Switch to root account | ||
sudo su | ||
# Execute installation | ||
./script/install.sh | ||
# After installation, you can exit and return to the previous account | ||
# If it is the first time installing the GPU driver, reboot is needed to take effect | ||
``` | ||
|
||
# Setup | ||
Several configurable environment variables can be set according to your needs. | ||
``` | ||
# The directory of lotus, miner, worker, and zero-knowledge proof parameters. It is recommended to set them to directories on SSD. | ||
export LOTUS_PATH="$HOME/lotus" | ||
export LOTUS_STORAGE_PATH="$HOME/lotusstorage" | ||
export WORKER_PATH="$HOME/lotusworker" | ||
export FIL_PROOFS_PARAMETER_CACHE="$HOME/filecoin-proof-parameters" | ||
# Set Chinese zero-knowledge proof parameter download source. | ||
export IPFS_GATEWAY="https://proof-parameters.s3.cn-south-1.jdcloud-oss.com/ipfs/" | ||
# Manually download the zero-knowledge proof parameters to the FIL_PROOFS_PARAMETER_CACHE directory, 200GB | ||
lotus fetch-params --proving-params 32GiB | ||
``` | ||
|
||
Start lotus. | ||
``` | ||
# Start lotus | ||
nohup lotus > ~/lotus.log 2>&1 & | ||
# View logs | ||
tail -f ~/lotus.log | ||
# Generate an account. Need to go to https://faucet.testnet.filecoin.io/ to get test coins and create a miner account. | ||
lotus wallet new bls | ||
# Wait for node synchronized | ||
lotus sync wait | ||
``` | ||
|
||
Start miner. Need to complete the test coin getting, miner registering, and node synchronization before. | ||
``` | ||
# Use miner registration results to initialize miner | ||
# It is recommended to add the --no-local-storage parameter as shown below, instead of storing data in the default location LOTUS_STORAGE_PATH | ||
lotus-storage-miner init --actor=xxx --owner=xxxxx --no-local-storage | ||
# If miner and worker are not on the same machine, you need to configure the miner's IP | ||
# Cancel the comment in front of ListenAddress and RemoteListenAddress and change their IPs to LAN IPs | ||
vi ~/.lotusstorage/config.toml | ||
# Start miner. | ||
# --max-parallel indicates the number of parallel sectors allowed for each worker. | ||
# When there is 256 GB memory, 64 GB swap and 1.4 TB hard disk free space, two sectors can be parallel. | ||
# When there is 128 GB memory, 64 GB swap and 0.7 TB hard disk free space, one sector can be used in parallel. | ||
nohup lotus-storage-miner run --max-parallel 2 > ~/miner.log 2>&1 & | ||
# View logs | ||
tail -f ~/miner.log | ||
# storage attach, which tells the miner where to store the data actually. Please choose directories under hard disks or network disks | ||
lotus-storage-miner storage attach --init=true --store=true /path/to/storage | ||
# View miner information | ||
lotus-storage-miner info | ||
``` | ||
|
||
Start worker. | ||
``` | ||
# If miner and worker are not on the same machine, you need to copy the files of api and token under LOTUS_STORAGE_PATH of miner to LOTUS_STORAGE_PATH of worker | ||
# Required environment variable | ||
export FIL_PROOFS_MAXIMIZE_CACHING=1 | ||
# Optional environment variables | ||
# The following setting will allow the worker to use the GPU to compute PreCommit2. It is recommended to use it in the case of dual GPUs, otherwise it will report an error of insufficient GPU memory. | ||
export FIL_PROOFS_USE_GPU_COLUMN_BUILDER=1 | ||
# The following setting will cause the worker to use the CPU instead of the GPU to compute Commit2. | ||
export BELLMAN_NO_GPU=true | ||
# Start worker, need to add LAN IP | ||
lotus-seal-worker run --address=xxx.xxx.xxx.xxx:3456 > ~/worker.log 2>&1 & | ||
# View logs | ||
tail -f ~/miner.log | ||
``` | ||
|
||
Observe the operation. Executed on the miner machine. commonly used commands are listed as follows. | ||
``` | ||
lotus-storage-miner info | ||
lotus-storage-miner storage list | ||
lotus-storage-miner workers list | ||
lotus-storage-miner sectors list | ||
``` | ||
|
||
# TODO | ||
* Currently, there is a problem with the official code in the Window PoSt part. Therefore, a decline of storage power may happen. To avoid this problem, please do not do too many manual operations. | ||
* The program runs smoothly under the recommended configuration, and has not been tested in other environments. If you encounter problems, please raise an issue. | ||
* The official code changes will be merged in time. | ||
* After the program is stable for a period, the algorithm optimization will be merged. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
#!/bin/bash | ||
|
||
rm -rf lotus-miner.tar.gz cmd | ||
wget https://github.com/shannon-6block/lotus-miner/releases/download/interop.6.8/lotus-miner.tar.gz | ||
mkdir cmd | ||
tar zxvf lotus-miner.tar.gz -C cmd/ | ||
cp cmd/* /usr/local/bin/ | ||
|
||
apt update | ||
apt install -y mesa-opencl-icd ocl-icd-opencl-dev ntpdate ubuntu-drivers-common | ||
|
||
# time adjust | ||
ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime | ||
ntpdate ntp.aliyun.com | ||
|
||
# install ulimit | ||
ulimit -n 1048576 | ||
sed -i "/nofile/d" /etc/security/limits.conf | ||
echo "* hard nofile 1048576" >> /etc/security/limits.conf | ||
echo "* soft nofile 1048576" >> /etc/security/limits.conf | ||
echo "root hard nofile 1048576" >> /etc/security/limits.conf | ||
echo "root soft nofile 1048576" >> /etc/security/limits.conf | ||
|
||
# setup SWAP, 64GB, swappiness=1 | ||
SWAPSIZE=`swapon --show | awk 'NR==2 {print $3}'` | ||
if [ "$SWAPSIZE" != "64G" ]; then | ||
OLDSWAPFILE=`swapon --show | awk 'NR==2 {print $1}'` | ||
NEWSWAPFILE="/swapfile" | ||
if [ -n "$OLDSWAPFILE" ]; then | ||
swapoff -v $OLDSWAPFILE | ||
rm $OLDSWAPFILE | ||
sed -i "/\$OLDSWAPFILE/d" /etc/fstab | ||
NEWSWAPFILE=$OLDSWAPFILE | ||
fi | ||
fallocate -l 64GiB $NEWSWAPFILE | ||
chmod 600 $NEWSWAPFILE | ||
mkswap $NEWSWAPFILE | ||
swapon $NEWSWAPFILE | ||
echo "$NEWSWAPFILE none swap sw 0 0" >> /etc/fstab | ||
sysctl vm.swappiness=1 | ||
sed -i "/swappiness/d" /etc/sysctl.conf | ||
echo "vm.swappiness=1" >> /etc/sysctl.conf | ||
fi | ||
|
||
# install GPU driver | ||
nvidia-smi | ||
NEEDGPU=$? | ||
if [ $NEEDGPU -ne 0 ]; then | ||
ubuntu-drivers autoinstall | ||
echo "reboot to make the GPU to take effect!" | ||
fi |