Filecoin lotus 搭建本地测试网络
1, 准备一台 ubuntu
2, 安装 lotus 代码 编译时所依赖的 包
Ubuntu Instructions
These steps will install the following dependencies:
go (1.14 or higher)
gcc (7.4.0 or higher)
git (version 2 or higher)
bzr (some go dependency needs this)
jq
pkg-config
opencl-icd-loader
opencl driver (like nvidia-opencl on arch) (for GPU acceleration)
opencl-headers (build)
rustup (proofs build)
llvm (proofs build)
clang (proofs build)
Install dependencies
sudo apt update
sudo apt install mesa-opencl-icd ocl-icd-opencl-dev gcc git bzr jq pkg-config curl
sudo apt upgrade
3, 安装 go 1.14
4, 下载 lotus 代码
git clone https://github.com/filecoin-project/lotus.git
cd lotus/
5, 开始搭建本地测试网络
参考文档: https://docs.lotu.sh/en+setup-local-dev-net
Setup Local Devnet
Build the Lotus Binaries in debug mode, This enables the use of 2048 byte sectors.
make 2k
Download the 2048 byte parameters:
./lotus fetch-params 2048
Pre-seal some sectors:
./lotus-seed pre-seal --sector-size 2KiB --num-sectors 2
Create the genesis block and start up the first node:
./lotus-seed genesis new localnet.json
./lotus-seed genesis add-miner localnet.json ~/.genesis-sectors/pre-seal-t01000.json
./lotus daemon --lotus-make-genesis=dev.gen --genesis-template=localnet.json --bootstrap=false
// 注意:即使没有进行 fech-params 命令,在执行以上 ./lotus daemon 命令时也会 在 /var/tmp/ 目录下创建 filecoin-proof-parameters 目录,并下载部分参数。 如下:
andy@andy-VirtualBox:/var/tmp/filecoin-proof-parameters$ ls
v27-proof-of-spacetime-fallback-merkletree-poseidon_hasher-8-0-0-0170db1f394b35d995252228ee359194b13199d259380541dc529fb0099096b0.vk
v27-proof-of-spacetime-fallback-merkletree-poseidon_hasher-8-0-0-0cfb4f178bbb71cf2ecfcd42accce558b27199ab4fb59cb78f2483fe21ef36d9.vk
v27-proof-of-spacetime-fallback-merkletree-poseidon_hasher-8-0-0-3ea05428c9d11689f23529cde32fd30aabd50f7d2c93657c1d3650bca3e8ea9e.vk
v27-proof-of-spacetime-fallback-merkletree-poseidon_hasher-8-0-0-50c7368dea9593ed0989e70974d28024efa9d156d585b7eea1be22b2e753f331.vk
v27-proof-of-spacetime-fallback-merkletree-poseidon_hasher-8-0-0-5294475db5237a2e83c3e52fd6c2b03859a1831d45ed08c4f35dbf9a803165a9.vk
v27-proof-of-spacetime-fallback-merkletree-poseidon_hasher-8-0-0-7d739b8cf60f1b0709eeebee7730e297683552e4b69cab6984ec0285663c5781.vk
v27-proof-of-spacetime-fallback-merkletree-poseidon_hasher-8-8-0-0377ded656c6f524f1618760bffe4e0a1c51d5a70c4509eedae8a27555733edc.vk
v27-proof-of-spacetime-fallback-merkletree-poseidon_hasher-8-8-0-559e581f022bb4e4ec6e719e563bf0e026ad6de42e56c18714a2c692b1b88d7e.vk
v27-proof-of-spacetime-fallback-merkletree-poseidon_hasher-8-8-2-2627e4006b67f99cef990c0a47d5426cb7ab0a0ad58fc1061547bf2d28b09def.vk
v27-proof-of-spacetime-fallback-merkletree-poseidon_hasher-8-8-2-b62098629d07946e9028127e70295ed996fe3ed25b0f9f88eb610a0ab4385a3c.vk
v27-stacked-proof-of-replication-merkletree-poseidon_hasher-8-0-0-sha256_hasher-032d3138d22506ec0082ed72b2dcba18df18477904e35bafee82b3793b06832f.vk
v27-stacked-proof-of-replication-merkletree-poseidon_hasher-8-0-0-sha256_hasher-6babf46ce344ae495d558e7770a585b2382d54f225af8ed0397b8be7c3fcd472.vk
v27-stacked-proof-of-replication-merkletree-poseidon_hasher-8-0-0-sha256_hasher-ecd683648512ab1765faa2a5f14bab48f676e633467f0aa8aad4b55dcb0652bb.vk
v27-stacked-proof-of-replication-merkletree-poseidon_hasher-8-8-0-sha256_hasher-82a357d2f2ca81dc61bb45f4a762807aedee1b0a53fd6c4e77b46a01bfef7820.vk
v27-stacked-proof-of-replication-merkletree-poseidon_hasher-8-8-2-sha256_hasher-96f1b4a04c5c51e4759bbf224bbc2ef5a42c7100f16ec0637123f16a845ddfb2.vk
Then, in another console, import the genesis miner key:
./lotus wallet import ~/.genesis-sectors/pre-seal-t01000.key
Set up the genesis miner:
./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
// 注意: 执完 lotus-miner init 时,会在 filecoin-proof-parameters 目录下,再生成两个 参数文件。
***-spacetime-***.params (两个)
***-replication-***.params
andy@andy-VirtualBox:/var/tmp/filecoin-proof-parameters$ ls -al
总用量 1151000
drwxr-xr-x 2 andy andy 4096 8月 12 11:45 .
drwxrwxrwt 11 root root 4096 8月 12 11:15 ..
-rw-rw-r-- 1 andy andy 11501496 8月 12 11:47 v27-proof-of-spacetime-fallback-merkletree-poseidon_hasher-8-0-0-0170db1f394b35d995252228ee359194b13199d259380541dc529fb0099096b0.params
-rw-rw-r-- 1 andy andy 3076 8月 12 11:15 v27-proof-of-spacetime-fallback-merkletree-poseidon_hasher-8-0-0-0170db1f394b35d995252228ee359194b13199d259380541dc529fb0099096b0.vk
-rw-rw-r-- 1 andy andy 3076 8月 12 11:15 v27-proof-of-spacetime-fallback-merkletree-poseidon_hasher-8-0-0-0cfb4f178bbb71cf2ecfcd42accce558b27199ab4fb59cb78f2483fe21ef36d9.vk
-rw-rw-r-- 1 andy andy 47299128 8月 12 11:46 v27-proof-of-spacetime-fallback-merkletree-poseidon_hasher-8-0-0-3ea05428c9d11689f23529cde32fd30aabd50f7d2c93657c1d3650bca3e8ea9e.params
-rw-rw-r-- 1 andy andy 13636 8月 12 11:15 v27-proof-of-spacetime-fallback-merkletree-poseidon_hasher-8-0-0-3ea05428c9d11689f23529cde32fd30aabd50f7d2c93657c1d3650bca3e8ea9e.vk
-rw-rw-r-- 1 andy andy 13636 8月 12 11:15 v27-proof-of-spacetime-fallback-merkletree-poseidon_hasher-8-0-0-50c7368dea9593ed0989e70974d28024efa9d156d585b7eea1be22b2e753f331.vk
-rw-rw-r-- 1 andy andy 3076 8月 12 11:15 v27-proof-of-spacetime-fallback-merkletree-poseidon_hasher-8-0-0-5294475db5237a2e83c3e52fd6c2b03859a1831d45ed08c4f35dbf9a803165a9.vk
-rw-rw-r-- 1 andy andy 13636 8月 12 11:15 v27-proof-of-spacetime-fallback-merkletree-poseidon_hasher-8-0-0-7d739b8cf60f1b0709eeebee7730e297683552e4b69cab6984ec0285663c5781.vk
-rw-rw-r-- 1 andy andy 2481508 8月 12 11:15 v27-proof-of-spacetime-fallback-merkletree-poseidon_hasher-8-8-0-0377ded656c6f524f1618760bffe4e0a1c51d5a70c4509eedae8a27555733edc.vk
-rw-rw-r-- 1 andy andy 13636 8月 12 11:15 v27-proof-of-spacetime-fallback-merkletree-poseidon_hasher-8-8-0-559e581f022bb4e4ec6e719e563bf0e026ad6de42e56c18714a2c692b1b88d7e.vk
-rw-rw-r-- 1 andy andy 2429764 8月 12 11:15 v27-proof-of-spacetime-fallback-merkletree-poseidon_hasher-8-8-2-2627e4006b67f99cef990c0a47d5426cb7ab0a0ad58fc1061547bf2d28b09def.vk
-rw-rw-r-- 1 andy andy 13636 8月 12 11:15 v27-proof-of-spacetime-fallback-merkletree-poseidon_hasher-8-8-2-b62098629d07946e9028127e70295ed996fe3ed25b0f9f88eb610a0ab4385a3c.vk
-rw-rw-r-- 1 andy andy 1114707768 8月 12 11:45 v27-stacked-proof-of-replication-merkletree-poseidon_hasher-8-0-0-sha256_hasher-032d3138d22506ec0082ed72b2dcba18df18477904e35bafee82b3793b06832f.params
-rw-rw-r-- 1 andy andy 4708 8月 12 11:15 v27-stacked-proof-of-replication-merkletree-poseidon_hasher-8-0-0-sha256_hasher-032d3138d22506ec0082ed72b2dcba18df18477904e35bafee82b3793b06832f.vk
-rw-rw-r-- 1 andy andy 4708 8月 12 11:15 v27-stacked-proof-of-replication-merkletree-poseidon_hasher-8-0-0-sha256_hasher-6babf46ce344ae495d558e7770a585b2382d54f225af8ed0397b8be7c3fcd472.vk
-rw-rw-r-- 1 andy andy 4708 8月 12 11:15 v27-stacked-proof-of-replication-merkletree-poseidon_hasher-8-0-0-sha256_hasher-ecd683648512ab1765faa2a5f14bab48f676e633467f0aa8aad4b55dcb0652bb.vk
-rw-rw-r-- 1 andy andy 32356 8月 12 11:15 v27-stacked-proof-of-replication-merkletree-poseidon_hasher-8-8-0-sha256_hasher-82a357d2f2ca81dc61bb45f4a762807aedee1b0a53fd6c4e77b46a01bfef7820.vk
-rw-rw-r-- 1 andy andy 32356 8月 12 11:15 v27-stacked-proof-of-replication-merkletree-poseidon_hasher-8-8-2-sha256_hasher-96f1b4a04c5c51e4759bbf224bbc2ef5a42c7100f16ec0637123f16a845ddfb2.vk
Now, finally, start up the miner:
./lotus-miner run --nosync
If all went well, you will have your own local Lotus Devnet running.