以太坊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

這個好像是直接下載可行性程序,不需要源碼編譯,如果你只想運行驗證人節點,不研究代碼,到這就可以了。

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
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章