每个矿工都需要
brew install go bzr jq pkg-config rustup
xcode-select --install
go get -u github.com/go-delve/delve/cmd/dlv
sudo /usr/sbin/DevToolsSecurity -enable
git clone https://github.com/filecoin-project/lotus.git
cd lotus/
export GO111MODULE=on
export GOPROXY=https://goproxy.io
make debug
如若编译时出错,请更换rust Crates源
+ cargo +nightly-2019-11-06 build --release
+ tee /var/folders/cq/vv_zdwd902d2y1j36zgsxk_w0000gn/T/tmp.u4LT35gu
Updating crates.io index
warning: spurious network error (2 tries remaining): early EOF; class=Net (12); code=Eof (-20
在 $HOME/.cargo/config 中添加如下内容,再重新make
[source.crates-io]
replace-with = 'ustc'
[source.ustc]
registry = "git://mirrors.ustc.edu.cn/crates.io-index
这里设置为1k,扇区越大,时间越久
./lotus-seed pre-seal --sector-size 1024 --num-sectors 2
设置一下环境变量IPFS_GATEWAY,从国内下载证明参数文件
nohup ./lotus daemon --lotus-make-random-genesis=genesis.car \
--genesis-presealed-sectors=~/.genesis-sectors/pre-seal-t0101.json \
--bootstrap=false \
> lotus.log 2>&1 &
设置一下环境变量IPFS_GATEWAY,从国内下载
./lotus-storage-miner init --genesis-miner --actor=t0101 --sector-size=1024 \
--pre-sealed-sectors=~/.genesis-sectors --nosync
nohup ./lotus-storage-miner run --nosync > miner.log 2>&1 &
./lotus-seal-worker run
./lotus-storage-miner pledge-sector
在另外一个机器上操作
从创世矿工拷贝genesis.car文件到新的矿工节点,genesis.car不一致会导致无法组建私有网络
注意genesis.car文件位置,bootstrap必须设置false否则将连接到测试网络,并同步测试网络数据
lotus daemon --genesis=genesis.car --bootstrap=false
记录下钱包地址
lotus wallet new bls
t3qce3xob7v6jw3tvjlmvjkox5gytdtbueb7chnepgtk2sfukjqd4cd4eo2p6r5seb3zhbfd3qfh4qskidnsba
创建矿工需要抵押代币
lotus send t3qce3xob7v6jw3tvjlmvjkox5gytdtbueb7chnepgtk2sfukjqd4cd4eo2p6r5seb3zhbfd3qfh4qskidnsba 1000
owner和worker参数为上一步创建的钱包地址
lotus daemon init --owner t3qce3xob7v6jw3tvjlmvjkox5gytdtbueb7chnepgtk2sfukjqd4cd4eo2p6r5seb3zhbfd3qfh4qskidnsba --worker t3qce3xob7v6jw3tvjlmvjkox5gytdtbueb7chnepgtk2sfukjqd4cd4eo2p6r5seb3zhbfd3qfh4qskidnsba
初始化后查看日志,会返回矿工id 如t01002
lotus-storage-miner run
lotus net listen
lotus-storage-miner net listen
默认只会监听到本地网卡地址,需要4个以上的外部网络连接,才会显外网ip
每个矿工有两个进程lotus和lotus-storage-miner,都会对外暴露一个端口,需交叉连接,否则路由会出问题
lotus net connect /ip4/xx.xx.xxx.xx/tcp/1347/p2p/12D3KooWFTAWbqatfszrSn2EccQSeyrpLnb852r7RoXvjaFc8n6t
lotus net connect /ip4/xx.xx.xx.xx/tcp/1348/p2p/12D3KooWHS1dRz1a6qj7VBCZ5j5LsGvE1ir3q8dxRVPHr5C4iSwP
lotus-storage-miner net connect /ip4/xx.xx.xx.xx/tcp/1347/p2p/12D3KooWFTAWbqatfszrSn2EccQSeyrpLnb852r7RoXvjaFc8n6t
lotus-storage-miner net connect /ip4/xx.xx.xx.xx/tcp/1348/p2p/12D3KooWHS1dRz1a6qj7VBCZ5j5LsGvE1ir3q8dxRVPHr5C4iSwP
连接可能会断开,通过lotus net peers
、lotus-storage-miner
net peers检查是否掉线
buildFlags参数根据Makefile编写,必须设置-tags=debug,否则将载入测试网络配置
{
"version": "0.2.0",
"configurations": [
{
"name": "pre-seal",
"type": "go",
"request": "launch",
"mode": "debug",
"port": 2344,
"host": "127.0.0.1",
"program": "${workspaceRoot}/cmd/lotus-seed",
"env": {},
"buildFlags":"-ldflags=-X='github.com/filecoin-project/lotus/build'.CurrentCommit=954085d3 -tags=debug",
"args": ["pre-seal", "--sector-size", "1024", "--num-sectors", "2"]
},
{
"name": "lotus daemon",
"type": "go",
"request": "launch",
"mode": "debug",
"port": 2345,
"host": "127.0.0.1",
"program": "${workspaceRoot}/cmd/lotus",
"env": {
"IPFS_GATEWAY":"https://proof-parameters.s3.cn-south-1.jdcloud-oss.com/ipfs/"
},
"showLog": true,
"buildFlags":"-ldflags=-X='github.com/filecoin-project/lotus/build'.CurrentCommit=954085d3 -tags=debug",
"args": ["daemon","--lotus-make-random-genesis=genesis.car", "--genesis-presealed-sectors=~/.genesis-sectors/pre-seal-t0101.json", "--bootstrap=false"]
},
{
"name": "lotus-storage-miner init",
"type": "go",
"request": "launch",
"mode": "debug",
"port": 2346,
"host": "127.0.0.1",
"program": "${workspaceRoot}/cmd/lotus-storage-miner",
"env": {
"IPFS_GATEWAY":"https://proof-parameters.s3.cn-south-1.jdcloud-oss.com/ipfs/"
},
"showLog": true,
"buildFlags":"-ldflags=-X='github.com/filecoin-project/lotus/build'.CurrentCommit=954085d3 -tags=debug",
"args": ["init", "--genesis-miner", "--actor=t0101", "--sector-size=1024", "--pre-sealed-sectors=~/.genesis-sectors", "--nosync"]
},
{
"name": "lotus-storage-miner run",
"type": "go",
"request": "launch",
"mode": "debug",
"port": 2347,
"host": "127.0.0.1",
"program": "${workspaceRoot}/cmd/lotus-storage-miner",
"env": {
"IPFS_GATEWAY":"https://proof-parameters.s3.cn-south-1.jdcloud-oss.com/ipfs/"
},
"showLog": true,
"buildFlags":"-ldflags=-X='github.com/filecoin-project/lotus/build'.CurrentCommit=954085d3 -tags=debug",
"args": ["run","--nosync"]
},
{
"name": "lotus-seal-worker run",
"type": "go",
"request": "launch",
"mode": "debug",
"port": 2348,
"host": "127.0.0.1",
"program": "${workspaceRoot}/cmd/lotus-seal-worker",
"env": {
"IPFS_GATEWAY":"https://proof-parameters.s3.cn-south-1.jdcloud-oss.com/ipfs/"
},
"showLog": true,
"buildFlags":"-ldflags=-X='github.com/filecoin-project/lotus/build'.CurrentCommit=954085d3 -tags=debug",
"args": ["run"]
}
]
}
rm -rf ~/.genesis-sectors
rm -rf ~/.lotus/
rm -rf ~/.lotusstorage/
rm -rf ~/.lotusworker/