Filecoin开发代码开源公布后,开发者测试网络已经开通,已有模拟代币产出。
赛道中国第一时间进行了编译,第三天赛道云成功稳定运行开发测试节点,IPFSSDKJ节点。
截止发稿前全网已有110个存储矿工接入测试
部分数据展示
(当下以产出4357000.00测试网络Token代币)
以下为数据为测试数据流程
Filecoin开发代码开源后,赛道中国第一时间进行了编译,第三天赛道云成功稳定运行开发测试节点,IPFSSDKJ节点。
安装Filecoin及相关程序
参考官方安装文档,目前只能从源代码安装,而且只支持Linux和MacOS,Windows再次被歧视(我手头这个旧Macbook Pro是能试试的)。
官方文档是先把源码下载了再说,用下面的命令。
mkdir -p ${GOPATH}/src/github.com/filecoin-project
git clone https://github.com/filecoin-project/go-filecoin.git ${GOPATH}/src/github.com/filecoin-project/go-filecoin
但实际上,这条命令依赖于 ${GOPATH}这个环境变量,以及Go语言环境的目录。所以,最好还是先检查相关的程序与环境是否已经OK。
安装Go 和 Rust
编译go-filecoin需要的环境如下
Go= v1.11.2.
用go version检查一下版本
$go version
go version go1.10.2 darwin/amd64
我之前的Go是用Home Brew安装的,直接用brew upgrade go更新就好了
$brew upgrade go
==> Upgrading 1 outdated package:
go 1.10.2 -> 1.11.5
==> Upgrading go
==> Downloading https://homebrew.bintray.com/bottles/go-1.11.5.mojave.bottle.tar.gz
######################################################################## 100.0%
==> Pouring go-1.11.5.mojave.bottle.tar.gz
/usr/local/Cellar/go/1.11.5: 9,298 files, 404.3MB
$go version
go version go1.11.5 darwin/amd64
Rust >= v1.31.0 and cargo
继续用Home Brew好了 brew install rust
$ brew install rust
Updating Homebrew...
==> Installing dependencies for rust: openssl, libssh2 and pkg-config
==> Installing rust dependency: openssl
==> Downloading https://homebrew.bintray.com/bottles/openssl-1.0.2q.mojave.bottle.tar.gz
######################################################################## 100.0%
==> Pouring openssl-1.0.2q.mojave.bottle.tar.gz
==> Caveats
A CA file has been bootstrapped using certificates from the SystemRoots
keychain. To add additional certificates (e.g. the certificates added in
the System keychain), place .pem files in
/usr/local/etc/openssl/certs
and run
/usr/local/opt/openssl/bin/c_rehash
openssl is keg-only, which means it was not symlinked into /usr/local,
because Apple has deprecated use of OpenSSL in favor of its own TLS and crypto libraries.
If you need to have openssl first in your PATH run:
echo 'export PATH="/usr/local/opt/openssl/bin:$PATH"' >> ~/.bash_profile
For compilers to find openssl you may need to set:
export LDFLAGS="-L/usr/local/opt/openssl/lib"
export CPPFLAGS="-I/usr/local/opt/openssl/include"
==> Summary
/usr/local/Cellar/openssl/1.0.2q: 1,794 files, 12.1MB
==> Installing rust dependency: libssh2
==> Downloading https://homebrew.bintray.com/bottles/libssh2-1.8.0.mojave.bottle.1.tar.gz
######################################################################## 100.0%
==> Pouring libssh2-1.8.0.mojave.bottle.1.tar.gz
/usr/local/Cellar/libssh2/1.8.0: 182 files, 792.8KB
==> Installing rust dependency: pkg-config
==> Downloading https://homebrew.bintray.com/bottles/pkg-config-0.29.2.mojave.bottle.tar.gz
######################################################################## 100.0%
==> Pouring pkg-config-0.29.2.mojave.bottle.tar.gz
/usr/local/Cellar/pkg-config/0.29.2: 11 files, 627.2KB
==> Installing rust
==> Downloading https://homebrew.bintray.com/bottles/rust-1.32.0.mojave.bottle.1.tar.gz
######################################################################## 100.0%
==> Pouring rust-1.32.0.mojave.bottle.1.tar.gz
/usr/local/Cellar/rust/1.32.0: 51,148 files, 852MB
==> Caveats
==> openssl
A CA file has been bootstrapped using certificates from the SystemRoots
keychain. To add additional certificates (e.g. the certificates added in
the System keychain), place .pem files in
/usr/local/etc/openssl/certs
and run
/usr/local/opt/openssl/bin/c_rehash
openssl is keg-only, which means it was not symlinked into /usr/local,
because Apple has deprecated use of OpenSSL in favor of its own TLS and crypto libraries.
If you need to have openssl first in your PATH run:
echo 'export PATH="/usr/local/opt/openssl/bin:$PATH"' >> ~/.bash_profile
For compilers to find openssl you may need to set:
export LDFLAGS="-L/usr/local/opt/openssl/lib"
export CPPFLAGS="-I/usr/local/opt/openssl/include"
For pkg-config to find openssl you may need to set:
export PKG_CONFIG_PATH="/usr/local/opt/openssl/lib/pkgconfig"
检查一下版本 rustc --version,cargo --version
$ rustc --version
rustc 1.32.0
$ cargo --version
cargo 1.32.0
pkg-config go-filecoin 用这个来生成link flag
Mac OS 上可以用brew来安装 brew install pkg-config
另外,Filecoin说还用了cgo,因此需要C编译器,以前应该在Mac上安装过开发者工具包,用CC --version 检查一下
$ CC --version
Apple LLVM version 10.0.0 (clang-1000.10.44.4)
Target: x86_64-apple-darwin18.2.0
Thread model: posix
InstalledDir: /Library/Developer/CommandLineTools/usr/bin
修改环境变量
修改${GOPATH} 和 ${PATH}环境变量,和我电脑上Go的安装目录保持一致。在~/.bash_profile 中增加 export GOPATH="/Users/Hooman/go" export PATH="$PATH:$GOPATH/bin"
$ go env GOPATH
/Users/Hooman/go
$ . ~/.bash_profile
$ echo ${GOPATH}
/Users/Hooman/go
下载Filecoin源码
mkdir -p ${GOPATH}/src/github.com/filecoin-project
git clone https://github.com/filecoin-project/go-filecoin.git ${GOPATH}/src/github.com/filecoin-project/go-filecoin
安装Go-filecoin依赖的软件包
go-filecoin 依赖一些Rust写的子模块代码,需要确保cargo已经安装好了。
这些依赖的软件包用gx管理,运行下面这两条命令安装gx, gometalinter等等编译、测试相关的一堆东西:
cd ${GOPATH}/src/github.com/filecoin-project/go-filecoin
FILECOIN_USE_PRECOMPILED_RUST_PROOFS=true go run ./build/*.go deps
这会花点时间,如果发现这个错误
gx install
panic: exec: "gx": executable file not found in $PATH
那么是因为没有把${GOPATH}/bin 增加到 ${PATH} 里,照着上面把环境变量设置好再来一次。
不知为何,我的电脑上提示没找到Rust的预编译包,结果整个重新编译,用了相当长时间(远远不止一杯咖啡)
using precompiled rust-proofs
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 5685 100 5685 0 0 3146 0 0:00:01 0:00:01 --:--:-- 3146
./scripts/install-rust-proofs.sh: line 10: jq: command not found
./scripts/install-rust-proofs.sh: line 18: jq: command not found
curl: (3) <url> malformed
usage: basename string [suffix]
basename [-a] [-s suffix] string [...]
curl: (3) <url> malformed
asset failed to be downloaded
failed to find or obtain precompiled rust-proofs, falling back to local
趁此机会,我大致浏览了一下Filecoin 的代码介绍/Codewalk,这是一个了解代码结构的绝佳入手点,下面这张图就是摘自这里。
┌─────────────────────────────────────┐
│ │
Network │ network (gossipsub, bitswap, etc.) │ | | \/
│ │ |_| /\
└─────▲────────────▲────────────▲─────┘
│ │ │ ┌────────────────────────────┐
┌─────▼────┐ ┌─────▼─────┐ ┌────▼─────┐ │ │
│ │ │ │ │ │ │ Commands / REST API │
Protocols │ Storage │ │ Mining │ │Retrieval │ │ │
│ Protocol │ │ Protocol │ │ Protocol │ └────────────────────────────┘
│ │ │ │ │ │ │
└──────────┘ └───────────┘ └──────────┘ │
│ │ │ │
└──────────┬─┴─────────────┴───────────┐ │
▼ ▼ ▼
┌────────────────────────────────┐ ┌───────────────────┬─────────────────┐
Internal │ Core API │ │ Porcelain │ Plumbing │
API │ │ ├───────────────────┘ │
└────────────────────────────────┘ └─────────────────────────────────────┘
│ │
┌─────────┴────┬──────────────┬──────────────┬─┴────────────┐
▼ ▼ ▼ ▼ ▼
┌────────────┐ ┌────────────┐ ┌────────────┐ ┌────────────┐ ┌────────────┐
│ │ │ │ │ │ │ │ │ │
Core │ Message │ │ Chain │ │ Processor │ │ Block │ │ Wallet │
│ Pool │ │ Store │ │ │ │ Service │ │ │
│ │ │ │ │ │ │ │ │ │
└────────────┘ └────────────┘ └────────────┘ └────────────┘ └────────────┘
最终如果没错,命令的输出会类似下面这样:
$ cd ${GOPATH}/src/github.com/filecoin-project/go-filecoin
$ FILECOIN_USE_PRECOMPILED_RUST_PROOFS=true go run ./build/*.go deps
pkg-config --version
0.29.2
Installing dependencies...
go get -u github.com/whyrusleeping/gx
go get -u github.com/whyrusleeping/gx-go
gx install
[get ] [fetch] QmYxivS34F2M2n44WQQnRHGAKS8aoRUxwGpi9wk4Cdn4Jf go-libp2p
......
......
gx-go rewrite5s
go get -u github.com/alecthomas/gometalinter
gometalinter --install
......
......
go get -u github.com/jstemmer/go-junit-report
go get -u github.com/pmezard/go-difflib/difflib
./scripts/install-rust-proofs.sh
......
......
./scripts/copy-groth-params.sh
/tmp/filecoin-proof-parameters ~/go/src/github.com/filecoin-project/go-filecoin
~/go/src/github.com/filecoin-project/go-filecoin
编译、测试、安装
# First, build the binary
go run ./build/*.go build
# Install go-filecoin to ${GOPATH}/bin (necessary for tests)
go run ./build/*.go install
# Then, run the tests.
go run ./build/*.go test
# Build and test can be combined!
go run ./build/*.go best
上面这些命令,只需执行前三个,或者最后一个三合一版本的命令。注意,第三个命令是执行测试,测试的时间其实也挺长的。另外一些编译时用得上的命令如下,
# Check the code for style and correctness issues
go run ./build/*.go lint
# Test with a coverage report
go run ./build/*.go test -cover
# Test with Go's race-condition instrumentation and warnings (see https://blog.golang.org/race-detector)
go run ./build/*.go test -race
# Deps, Lint, Build, Test (any args will be passed to `test`)
go run ./build/*.go all
咨询更多IPFS相关信息,请联系赛道中国
欢迎访问赛道科技官方网站,更多产品优惠等你来拿!
http://www.ipfs-fil.com