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

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

Lighthouse安装

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

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:
  • Finally, install cmake: https://cmake.org/download/
mkdir C:\Tools
cd C:\Tools
git clone https://github.com/Microsoft/vcpkg.git
cd vcpkg
.\bootstrap-vcpkg.bat
.\vcpkg.exe install openssl:x64-windows-static

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

OPENSSL_DIR  D:\Program Files\OpenSSL-Win64
PATH %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.git
cd lighthouse
make

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

   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)
--- stderr
thread '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:17
note: 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)
--- stderr
thread '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:19
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

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

Prysm安装

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

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

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

扫描二维码关注公众号,回复: 11438505 查看本文章
mec@DESKTOP-5N9GNCR MINGW64 /d/GoSpace/src/github.com/prysmaticlabs/prysm/dist (master)
$ ls
beacon-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.sha256
beacon-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.exe
2020/06/16 13:11:55 maxprocs: Leaving GOMAXPROCS=8: CPU quota undefined
time="2020-06-16 13:11:55" level=info msg="Checking DB" database-path="C:\Users\mec\AppData\Roaming\Eth2/beaconchaindata" prefix=node
time="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=rpc
time="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=rpc
time="2020-06-16 13:11:56" level=info msg="Starting initial chain sync..." prefix=initial-sync
time="2020-06-16 13:11:56" level=info msg="Waiting for enough suitable peers before syncing" prefix=initial-sync required=3 suitable=0
time="2020-06-16 13:11:56" level=info msg="Blockchain data already exists in DB, initializing..." prefix=blockchain
time="2020-06-16 13:11:57" level=info msg="Connected to eth1 proof-of-work chain" endpoint="wss://goerli.prylabs.net/websocket" prefix=powchain
time="2020-06-16 13:11:58" level=info msg="Started discovery v5" ENR="enr:-LK4QL_gfZteEQHv0LWVPRiGJymGtsDwwNDAB2ZatNdMJoEvRgIWXR0st-0QjEYSI0vOKGCz8U5esULjLZUcBVGn2kYBh2F0dG5ldHOIAAAAAAAAAACEZXRoMpDwccZsAAAAAP__________gmlkgnY0gmlwhMCoAQSJc2VjcDI1NmsxoQO9xYmOXZ2r6k97e0bsDGXKu6NxJ5d4CgXPqozcuPRFFYN0Y3CCMsiDdWRwgi7g" prefix=p2p
time="2020-06-16 13:12:00" level=info msg="Node started p2p server" multiAddr="/ip4/192.168.1.4/tcp/13000/p2p/16Uiu2HAmRRn7FK9y5CpvqFrsfFVSsmNVJhAxShxNsSuikABcuP8Q" prefix=p2p
time="2020-06-16 13:12:01" level=info msg="Waiting for enough suitable peers before syncing" prefix=initial-sync required=3 suitable=0
time="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=p2p
time="2020-06-16 13:12:17" level=info msg="Peer disconnected" active=0 peer=16Uiu2HAkyxw3s9cXNGHdrwi8aXujs6roro6n28Nsb8CAcnjRaSQs prefix=p2p
time="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.git
go get -t -v github.com/prysmaticlabs/prysm/...

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

go mod download
go mod tidy

直到找到了****,设置了下代理

# 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

猜你喜欢

转载自blog.csdn.net/JIYILANZHOU/article/details/106816338