# lotus version 1.18.0-rc5 2k 本地测试搭建


By [boot](https://paragraph.com/@boot) · 2022-11-10

---

*   一、设置节点
    
*   1\. 环境变量
    
*   2\. 下载源码
    
*   3\. 切换分支
    
*   4\. 清理环境
    
*   5\. 源码编译 2k
    
*   6\. 下载复制证明参数
    
*   7\. 预封装2个2KiB扇区
    
*   8\. 创建创世区块
    
*   9\. 创建一个默认钱包地址并获得一些测试币
    
*   二、运行节点
    
*   1\. 运行lotus
    
*   2\. 设置矿工环境变量
    
*   3\. 导入创世矿工密钥
    
*   4\. 设置创世矿工
    
*   5\. 运行 miner
    
*   查看
    
*   lotus-miner info
    

代理
==

    # ./clash-linux-amd64-v1.11.8
    
    # export https_proxy=http://127.0.0.1:7890 http_proxy=http://127.0.0.1:7890 all_proxy=socks5://127.0.0.1:7890
    

一、设置节点
======

1\. 环境变量
========

    # intel 源码编译
    export LOTUS_SKIP_GENESIS_CHECK=_yes_
    export CGO_CFLAGS_ALLOW="-D__BLST_PORTABLE__"
    export CGO_CFLAGS="-D__BLST_PORTABLE__"
    
    # louts
    export LOTUS_PATH=/2k/lotus-local-net
    export LOTUS_MINER_PATH=/2k/lotus-miner-local-net
    
    export IPFS_GATEWAY=https://proof-parameters.s3.cn-south-1.jdcloud-oss.com/ipfs/
    

2\. 下载源码
========

    # git clone https://github.com/filecoin-project/lotus lotus-local-net
    # cd lotus-local-net/
    # git checkout v1.18.0-rc5
    

3\. 切换分支
========

    # cd lotus-local-net/
    # git checkout v1.18.0-rc5
    

4\. 清理环境
========

    # rm -rf ~/.genesis-sectors
    

5\. 源码编译 2k
===========

    # make 2k
    

    # make install
    

6\. 下载复制证明参数
============

    # lotus fetch-params 2048
    

7\. 预封装2个2KiB扇区
===============

`./lotus-seed pre-seal --sector-size 2KiB --num-sectors 2`

    # ./lotus-seed pre-seal --sector-size 2KiB --num-sectors 2
    [flexi_logger][ERRCODE::Time] flexi_logger has to work with UTC rather than with local time, caused by IndeterminateOffset
        See https://docs.rs/flexi_logger/latest/flexi_logger/error_info/index.html#time
    2022-11-10T17:38:19.309+0800	WARN	ffiwrapper	ffiwrapper/sealer_cgo.go:196	AddPiece: cannot close pieceData reader *rand.devReader because it is not an io.Closer
    sector-id: {{1000 0} 5}, piece info: {2048 baga6ea4seaqfgv32cbstms5e53kgf23752jsxw4kgg7qbynm37rwylw2puee4aq}
    2022-11-10T17:38:19.360+0800	WARN	preseal	seed/seed.go:176	PreCommitOutput: {{1000 0} 5} bagboea4b5abcbaj6jb3hm7zvxual2mthal36tkhqypfo5p4cy5oilzi6jh2a3qyu baga6ea4seaqfgv32cbstms5e53kgf23752jsxw4kgg7qbynm37rwylw2puee4aq
    2022-11-10T17:38:19.361+0800	WARN	ffiwrapper	ffiwrapper/sealer_cgo.go:196	AddPiece: cannot close pieceData reader *rand.devReader because it is not an io.Closer
    sector-id: {{1000 1} 5}, piece info: {2048 baga6ea4seaqmjudqtjiirypwbxnf53okpzcdxvmkmzwm4eijobvj4aqraxy3goi}
    2022-11-10T17:38:19.407+0800	WARN	preseal	seed/seed.go:176	PreCommitOutput: {{1000 1} 5} bagboea4b5abcak2npkzpljuw4t3kvb7vdatxnomqywkjadk4hel3njnhsuyurl23 baga6ea4seaqmjudqtjiirypwbxnf53okpzcdxvmkmzwm4eijobvj4aqraxy3goi
    2022-11-10T17:38:19.407+0800	WARN	preseal	seed/seed.go:101	PeerID not specified, generating dummy
    2022-11-10T17:38:19.408+0800	INFO	preseal	seed/seed.go:230	Writing preseal manifest to /root/.genesis-sectors/pre-seal-t01000.json
    

8\. 创建创世区块
==========

    # ./lotus-seed genesis new localnet.json
    

9\. 创建一个默认钱包地址并获得一些测试币
======================

`./lotus-seed genesis add-miner localnet.json ~/.genesis-sectors/pre-seal-t01000.json`

    # ./lotus-seed genesis add-miner localnet.json ~/.genesis-sectors/pre-seal-t01000.json
    2022-11-10T17:40:44.751+0800	INFO	lotus-seed	lotus-seed/genesis.go:129	Adding miner t01000 to genesis template
    2022-11-10T17:40:44.751+0800	INFO	lotus-seed	lotus-seed/genesis.go:146	Giving t3ryvub7iqtr6myaivnhb6ttlcmtyybjr4agrhz23sjwn7keabwqurncvtk3dcxctsqniwu5ehl7dwmyewug5a some initial balance
    

二、运行节点
======

1\. 运行lotus
===========

    lotus daemon --lotus-make-genesis=devgen.car --genesis-template=localnet.json --bootstrap=false
    

2\. 设置矿工环境变量
============

    # intel
    export LOTUS_SKIP_GENESIS_CHECK=_yes_
    export CGO_CFLAGS_ALLOW="-D__BLST_PORTABLE__"
    export CGO_CFLAGS="-D__BLST_PORTABLE__"
    
    # louts
    export LOTUS_PATH=/2k/lotus-local-net
    export LOTUS_MINER_PATH=/2k/lotus-miner-local-net
    
    export IPFS_GATEWAY=https://proof-parameters.s3.cn-south-1.jdcloud-oss.com/ipfs/
    

3\. 导入创世矿工密钥
============

    # lotus wallet import --as-default ~/.genesis-sectors/pre-seal-t01000.key
    imported key t3ryvub7iqtr6myaivnhb6ttlcmtyybjr4agrhz23sjwn7keabwqurncvtk3dcxctsqniwu5ehl7dwmyewug5a successfully!
    

4\. 设置创世矿工
==========

    # lotus-miner init --genesis-miner --actor=t01000 --sector-size=2KiB --pre-sealed-sectors=~/.genesis-sectors --pre-sealed-metadata=~/.genesis-sectors/pre-seal-t01000.json --nosync
    
    
    2022-11-10T17:45:32.638+0800	INFO	main	lotus-miner/init.go:521	Importing pre-sealed sector metadata for t01000
    2022-11-10T17:45:32.691+0800	INFO	main	lotus-miner/init.go:282	Miner successfully created, you can now start it with 'lotus-miner run'
    

5\. 运行 miner
============

    lotus-miner run --nosync
    

查看
==

    # lotus sync wait
    

    # lotus-miner info
    Enabled subsystems (from miner API): [Mining Sealing SectorStorage Markets]
    Enabled subsystems (from markets API): [Mining Sealing SectorStorage Markets]
    Chain: [sync behind! (2m1s behind)] [basefee 2.718 pFIL]
    Miner: t01000 (2 KiB sectors)
    Power: 40 Ki / 40 Ki (100.0000%)
        Raw: 4 KiB / 4 KiB (100.0000%)
        Committed: 4 KiB
        Proving: 4 KiB
    Projected average block win rate: 20024.16/week (every 30s)
    Projected block win with 99.9% probability every 41s
    (projections DO NOT account for future network and miner growth)
    
    Miner Balance:    848.629 FIL
          PreCommit:  0
          Pledge:     2 aFIL
          Vesting:    636.472 FIL
          Available:  212.157 FIL
    Market Balance:   0
           Locked:    0
           Available: 0
    Worker Balance:   50000000 FIL
    Total Spendable:  50000212.157 FIL
    
    Sectors:
        Total: 2
        Proving: 2
    
    Workers: Seal(1) WdPoSt(0) WinPoSt(0)
    
    Storage Deals: 0, 0 B
    
    Retrieval Deals (complete): 0, 0 B
    

    # lotus-miner info
    Enabled subsystems (from miner API): [Mining Sealing SectorStorage Markets]
    Enabled subsystems (from markets API): [Mining Sealing SectorStorage Markets]
    Chain: [sync ok] [basefee 134 aFIL]
    Miner: t01000 (2 KiB sectors)
    Power: 40 Ki / 40 Ki (100.0000%)
        Raw: 4 KiB / 4 KiB (100.0000%)
        Committed: 4 KiB
        Proving: 4 KiB
    Projected average block win rate: 20024.16/week (every 30s)
    Projected block win with 99.9% probability every 41s
    (projections DO NOT account for future network and miner growth)
    
    Miner Balance:    3387.25 FIL
          PreCommit:  0
          Pledge:     2 aFIL
          Vesting:    2540.437 FIL
          Available:  846.812 FIL
    Market Balance:   0
           Locked:    0
           Available: 0
    Worker Balance:   50000000 FIL
    Total Spendable:  50000846.812 FIL
    
    Sectors:
        Total: 2
        Proving: 2
    
    Workers: Seal(1) WdPoSt(0) WinPoSt(0)
    
    Storage Deals: 0, 0 B
    
    Retrieval Deals (complete): 0, 0 B

---

*Originally published on [boot](https://paragraph.com/@boot/lotus-version-1-18-0-rc5-2k)*
