以太坊2.0客户端(Prysm,lighthouse)体验

原创
2020/06/16 19:50
阅读数 374

以太坊2.0最新的测试网里面,这两个客户端的受众最多,下面是我的一些安装和代码体验。

Lighthouse安装

首先体验了Lighthouse的安装,Lighthouse是基于Rust开发的,可查看下面官方提供的文档

Windows上安装

Rust在win上面安装比在Linux下面麻烦很多,经历了如下操作。

  • Download and install “Build Tools for Visual Studio:”
    You can get it at this link: https://aka.ms/buildtools.
    Run the installation file: vs_buildtools.exe.
    Ensure the “Windows 10 SDK” component is included when installing the Visual C++ Build Tools.
    Restart your computer.

  • Install LLVM: https://releases.llvm.org/download.html

  • Install OpenSSL with vcpkg:

    mkdir C:\Toolscd C:\Toolsgit clone https://github.com/Microsoft/vcpkg.gitcd vcpkg.\bootstrap-vcpkg.bat.\vcpkg.exe install openssl:x64-windows-static
  • Finally, install cmake: https://cmake.org/download/

安装OpenSSL的时候使用vcpkg无法安装,下载了安装包OpenSSL-Win64,手动配置了环境变量。

OPENSSL_DIR  D:\Program Files\OpenSSL-Win64PATH %OPENSSL_DIR%\bin

配置完这些发现,使用cargo build还是不能编译

error[E0433]: failed to resolve: could not find `unix` in `os` --> C:\Users\mec\.cargo\registry\src\github.com-1ecc6299db9ec823\leveldb-sys-2.0.5\src/build.rs:6:14  |6 | use std::os::unix::fs::PermissionsExt;  |              ^^^^ could not find `unix` in `os`
error[E0599]: no method named `mode` found for struct `std::fs::Permissions` in the current scope --> C:\Users\mec\.cargo\registry\src\github.com-1ecc6299db9ec823\leveldb-sys-2.0.5\src/build.rs:178:30 |178 | let current_mode = perms.mode(); | ^^^^ method not found in `std::fs::Permissions`
error[E0599]: no method named `set_mode` found for struct `std::fs::Permissions` in the current scope --> C:\Users\mec\.cargo\registry\src\github.com-1ecc6299db9ec823\leveldb-sys-2.0.5\src/build.rs:179:11 |179 | perms.set_mode(0o100 | current_mode); | ^^^^^^^^ method not found in `std::fs::Permissions`
error: aborting due to 3 previous errors
Some errors have detailed explanations: E0433, E0599.For more information about an error, try `rustc --explain E0433`.

Lighthouse应该不支持Windows下开发,只支持类unix系统,欢迎高手解答。

Ubutu上安装

使用如下命令倒是很快就安装好了,

git clone https://github.com/sigp/lighthouse.gitcd lighthousemake

编译的时候,还是出了如下错误

   Compiling deposit_contract v0.2.0 (/home/mec/lighthouse/common/deposit_contract)error: failed to run custom build command for `eth2_testnet_config v0.2.0 (/home/mec/lighthouse/common/eth2_testnet_config)`
Caused by: process didn't exit successfully: `/home/mec/lighthouse/target/release/build/eth2_testnet_config-f6c233f0fcaa4ae3/build-script-build` (exit code: 101)--- stderrthread 'main' panicked at 'Failed to download boot_enr.yaml: error sending request for url (https://raw.githubusercontent.com/sigp/witti/6d079b0f10f6bed75cd003e5f0ea5ecbe2044455/lighthouse/boot_enr.yaml): error trying to connect: tcp connect error: Connection refused (os error 111)', common/eth2_testnet_config/build.rs:23:17note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
warning: build failed, waiting for other jobs to finish...error: failed to compile `lighthouse v0.1.2 (/home/mec/lighthouse/lighthouse)`, intermediate artifacts can be found at `/home/mec/lighthouse/target`
Caused by: failed to run custom build command for `deposit_contract v0.2.0 (/home/mec/lighthouse/common/deposit_contract)`
Caused by: process didn't exit successfully: `/home/mec/lighthouse/target/release/build/deposit_contract-01a6d2323a5a771c/build-script-build` (exit code: 101)--- stderrthread 'main' panicked at 'No abi file found. Failed to download from github: reqwest::Error { kind: Request, url: "https://raw.githubusercontent.com/ethereum/eth2.0-specs/v0.11.1/deposit_contract/contracts/validator_registration.json", source: hyper::Error(Connect, ConnectError("tcp connect error", Os { code: 111, kind: ConnectionRefused, message: "Connection refused" })) }', common/deposit_contract/build.rs:27:19note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

此问题是导致的,由于我是使用的虚拟机操作的,linux下shadowssock还没使用过,所以Lighthouse未编译通过。

Prysm安装

Prysm的安装可参考如下链接。Prysm安装指南

mkdir prysm && cd prysmcurl https://raw.githubusercontent.com/prysmaticlabs/prysm/master/prysm.bat --output prysm.batreg add HKCU\Console /v VirtualTerminalLevel /t REG_DWORD /d 1.\prysm.bat beacon-chain

这个好像是直接下载可行性程序,不需要源码编译,如果你只想运行验证人节点,不研究代码,到这就可以了

mec@DESKTOP-5N9GNCR MINGW64 /d/GoSpace/src/github.com/prysmaticlabs/prysm/dist (master)$ lsbeacon-chain-v1.0.0-alpha.11-windows-amd64.exe*        beacon-chain-v1.0.0-alpha.11-windows-amd64.exe.sig  beacon-chain-v1.0.0-alpha.9-windows-amd64.exe.sha256beacon-chain-v1.0.0-alpha.11-windows-amd64.exe.sha256  beacon-chain-v1.0.0-alpha.9-windows-amd64.exe*      beacon-chain-v1.0.0-alpha.9-windows-amd64.exe.sig
$ ./beacon-chain-v1.0.0-alpha.9-windows-amd64.exe2020/06/16 13:11:55 maxprocs: Leaving GOMAXPROCS=8: CPU quota undefinedtime="2020-06-16 13:11:55" level=info msg="Checking DB" database-path="C:\Users\mec\AppData\Roaming\Eth2/beaconchaindata" prefix=nodetime="2020-06-16 13:11:55" level=info msg="Starting beacon node" prefix=node version="Prysm/Git commit: 3fe47c00433907176d44521d01ee97b1b0cab8ca. Built at: 2020-06-01 15:12:10+00:00"time="2020-06-16 13:11:55" level=info msg="RPC-API listening on port" address="0.0.0.0:4000" prefix=rpctime="2020-06-16 13:11:55" level=warning msg="You are using an insecure gRPC connection! Provide a certificate and key to connect securely" prefix=rpctime="2020-06-16 13:11:56" level=info msg="Starting initial chain sync..." prefix=initial-synctime="2020-06-16 13:11:56" level=info msg="Waiting for enough suitable peers before syncing" prefix=initial-sync required=3 suitable=0time="2020-06-16 13:11:56" level=info msg="Blockchain data already exists in DB, initializing..." prefix=blockchaintime="2020-06-16 13:11:57" level=info msg="Connected to eth1 proof-of-work chain" endpoint="wss://goerli.prylabs.net/websocket" prefix=powchaintime="2020-06-16 13:11:58" level=info msg="Started discovery v5" ENR="enr:-LK4QL_gfZteEQHv0LWVPRiGJymGtsDwwNDAB2ZatNdMJoEvRgIWXR0st-0QjEYSI0vOKGCz8U5esULjLZUcBVGn2kYBh2F0dG5ldHOIAAAAAAAAAACEZXRoMpDwccZsAAAAAP__________gmlkgnY0gmlwhMCoAQSJc2VjcDI1NmsxoQO9xYmOXZ2r6k97e0bsDGXKu6NxJ5d4CgXPqozcuPRFFYN0Y3CCMsiDdWRwgi7g" prefix=p2ptime="2020-06-16 13:12:00" level=info msg="Node started p2p server" multiAddr="/ip4/192.168.1.4/tcp/13000/p2p/16Uiu2HAmRRn7FK9y5CpvqFrsfFVSsmNVJhAxShxNsSuikABcuP8Q" prefix=p2ptime="2020-06-16 13:12:01" level=info msg="Waiting for enough suitable peers before syncing" prefix=initial-sync required=3 suitable=0time="2020-06-16 13:12:17" level=info msg="Peer Connected" activePeers=1 direction=2 multiAddr="/ip4/139.9.179.216/tcp/13000/p2p/16Uiu2HAkyxw3s9cXNGHdrwi8aXujs6roro6n28Nsb8CAcnjRaSQs" peer=16Uiu2HAkyxw3s9cXNGHdrwi8aXujs6roro6n28Nsb8CAcnjRaSQs prefix=p2ptime="2020-06-16 13:12:17" level=info msg="Peer disconnected" active=0 peer=16Uiu2HAkyxw3s9cXNGHdrwi8aXujs6roro6n28Nsb8CAcnjRaSQs prefix=p2ptime="2020-06-16 13:12:21" level=info msg="Waiting for enough suitable peers before syncing" prefix=initial-sync required=3 suitable=0

Prysm代码配置

Prysm里面使用了go module,把代码下载下来,发现代码里面都是标红

https://github.com/prysmaticlabs/prysm.gitgo get -t -v github.com/prysmaticlabs/prysm/...

起初以为是Go Module配置有问题,查阅了很多资料,使用如下命令老是超时

go mod downloadgo mod tidy

直到找到了Goproxy 中国,设置了下代理。

# Go 1.13 及以上$ go env -w GO111MODULE=on$ go env -w GOPROXY=https://goproxy.cn,direct

代码很快就下载完了,里面的错误也没有了,终于可以运行里面的测试用例,和查看调用逻辑了

=== RUN   TestCommitteeKeyFn_OK--- PASS: TestCommitteeKeyFn_OK (0.00s)PASS



LightHouse官方安装指南

https://lighthouse-book.sigmaprime.io/become-a-validator-source.html

Prysm安装指南

https://docs.prylabs.network/docs/install/windows/

Goproxy 中国

https://goproxy.cn/


本文分享自微信公众号 - 科帆区块链(TechfinBC)。
如有侵权,请联系 support@oschina.cn 删除。
本文参与“OSC源创计划”,欢迎正在阅读的你也加入,一起分享。

展开阅读全文
打赏
0
0 收藏
分享
加载中
更多评论
打赏
0 评论
0 收藏
0
分享
返回顶部
顶部