2
0

More than 3 years have passed since last update.

Ethereum2.0のLighthouseをインストール

Last updated at Posted at 2019-12-05

アドベントカレンダー用に書いた記事ではない&2.0の話ですが、スカスカだったのでいただきました。

Lighthouse はrustで書かれているEth2.0のノードやクライアントです。ビーコンチェーンノード、バリデーターノードなどがあるはず。動くのか知らないですけどインストールしてみようと思います。

Lighthouse WebSite
https://lighthouse.sigmaprime.io/

Github repo
https://github.com/sigp/lighthouse

Documents
http://lighthouse-book.sigmaprime.io/

環境作成

今回はFirewall, SELINUXを無効にしたcentos8で試します。# LANG=C dnf group install 'Development Tools' してあります。(GCCとかが入る)

Development Environment Setup
を参考に。

rustを入れます。

image.png

https://www.rust-lang.org/tools/install
ここを参考に素直にいれました。


[root@eth2-node ~]# curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
info: downloading installer


Welcome to Rust!

This will download and install the official compiler for the Rust
programming language, and its package manager, Cargo.

It will add the cargo, rustc, rustup and other commands to
Cargo's bin directory, located at:

  /root/.cargo/bin

This can be modified with the CARGO_HOME environment variable.

Rustup metadata and toolchains will be installed into the Rustup
home directory, located at:

  /root/.rustup

This can be modified with the RUSTUP_HOME environment variable.

This path will then be added to your PATH environment variable by
modifying the profile files located at:

  /root/.profile
/root/.bash_profile

You can uninstall at any time with rustup self uninstall and
these changes will be reverted.

Current installation options:


   default host triple: x86_64-unknown-linux-gnu
     default toolchain: stable
               profile: default
  modify PATH variable: yes

1) Proceed with installation (default)
2) Customize installation
3) Cancel installation
>
info: profile set to 'default'
info: syncing channel updates for 'stable-x86_64-unknown-linux-gnu'
info: latest update on 2019-11-07, rust version 1.39.0 (4560ea788 2019-11-04)
info: downloading component 'cargo'

~snip;;;

source $HOME/.cargo/env~/.bashrc に追記します。


[root@eth2-node ~]# echo 'source $HOME/.cargo/env' >> ~/.bashrc

PATHが通ってrustcが見つかればおkですね。


[root@eth2-node ~]# source ~/.bashrc
[root@eth2-node ~]# rustc --version
rustc 1.39.0 (4560ea788 2019-11-04)

clang, protobuf, libssl-dev, cmake を入れます。

image.png

libssl-devはRHEL系だとopenssl-develになります。


[root@eth2-node ~]# dnf install clang-devel protobuf openssl-devel cmake
メタデータの期限切れの最終確認: 0:22:36 時間前の 2019年12月05日 12時43分46秒 に実施しました。
依存関係が解決しました。
===========================================================================================================================================================
 パッケージ                            アーキテクチャー         バージョン                                               リポジトリ                  サイズ
===========================================================================================================================================================
Installing:
 clang-devel                           x86_64                   7.0.1-1.module_el8.0.0+12+30b38a9a                       AppStream                   1.7 M 
 cmake                                 x86_64                   3.11.4-3.el8                                             AppStream                   8.2 M 
 protobuf                              x86_64                   3.5.0-7.el8                                              AppStream                   901 k 
 openssl-devel                         x86_64                   1:1.1.1-8.el8                                            BaseOS                      2.3 M 
依存関係をインストール中:
 clang                                 x86_64                   7.0.1-1.module_el8.0.0+12+30b38a9a                       AppStream                   723 k 
 clang-libs                            x86_64                   7.0.1-1.module_el8.0.0+12+30b38a9a                       AppStream                    16 M 
 clang-tools-extra                     x86_64                   7.0.1-1.module_el8.0.0+12+30b38a9a                       AppStream                   449 k 
 cmake-data                            noarch                   3.11.4-3.el8                                             AppStream                   1.3 M 
 cmake-filesystem                      x86_64                   3.11.4-3.el8                                             AppStream                    40 k 
 cmake-rpm-macros                      noarch                   3.11.4-3.el8                                             AppStream                    39 k 
 libuv                                 x86_64                   1:1.23.1-1.el8                                           AppStream                   134 k 
 llvm-libs                             x86_64                   7.0.1-3.module_el8.0.0+176+9dc62ab1                      AppStream                    17 M 
 keyutils-libs-devel                   x86_64                   1.5.10-6.el8                                             BaseOS                       48 k 
 krb5-devel                            x86_64                   1.16.1-22.el8                                            BaseOS                      546 k 
 libatomic                             x86_64                   8.2.1-3.5.el8                                            BaseOS                       20 k 
 libcom_err-devel                      x86_64                   1.44.3-2.el8                                             BaseOS                       37 k 
 libkadm5                              x86_64                   1.16.1-22.el8                                            BaseOS                      184 k 
 libselinux-devel                      x86_64                   2.8-6.el8                                                BaseOS                      199 k 
 libsepol-devel                        x86_64                   2.8-2.el8                                                BaseOS                       85 k 
 libverto-devel                        x86_64                   0.3.0-5.el8                                              BaseOS                       18 k 
 pcre2-devel                           x86_64                   10.32-1.el8                                              BaseOS                      605 k 
 pcre2-utf16                           x86_64                   10.32-1.el8                                              BaseOS                      228 k 
 pcre2-utf32                           x86_64                   10.32-1.el8                                              BaseOS                      220 k 
 zlib-devel                            x86_64                   1.2.11-10.el8                                            BaseOS                       56 k 
弱い依存関係をインストール中:
 compiler-rt                           x86_64                   7.0.1-1.module_el8.0.0+12+30b38a9a                       AppStream                   2.8 M 
 libomp                                x86_64                   7.0.1-1.module_el8.0.0+12+30b38a9a                       AppStream                   317 k 
Enabling module streams:
 llvm-toolset                                                   rhel8

トランザクションの概要
===========================================================================================================================================================
インストール  26 パッケージ

ダウンロードサイズの合計: 54 M
インストール済みのサイズ: 277 M
これでよろしいですか? [y/N]:

~~snip;

リポジトリ持ってきてmake

image.png


[root@eth2-node ~]# git clone https://github.com/sigp/lighthouse.git
Cloning into 'lighthouse'...
remote: Enumerating objects: 218, done.
remote: Counting objects: 100% (218/218), done.
remote: Compressing objects: 100% (147/147), done.
remote: Total 33669 (delta 95), reused 150 (delta 66), pack-reused 33451
Receiving objects: 100% (33669/33669), 7.87 MiB | 5.71 MiB/s, done.
Resolving deltas: 100% (21745/21745), done.
[root@eth2-node ~]# cd lighthouse/
[root@eth2-node lighthouse]# ll
合計 36
-rw-r--r--  1 root root  5264 12月  5 13:09 CONTRIBUTING.md
-rw-r--r--  1 root root  1679 12月  5 13:09 Cargo.toml
-rw-r--r--  1 root root    62 12月  5 13:09 Dockerfile
-rw-r--r--  1 root root 11349 12月  5 13:09 LICENSE
-rw-r--r--  1 root root  1524 12月  5 13:09 Makefile
-rw-r--r--  1 root root  3638 12月  5 13:09 README.md
drwxr-xr-x  3 root root    52 12月  5 13:09 account_manager
drwxr-xr-x 14 root root   211 12月  5 13:09 beacon_node
drwxr-xr-x  3 root root    69 12月  5 13:09 book
drwxr-xr-x  7 root root   112 12月  5 13:09 eth2
drwxr-xr-x  3 root root    70 12月  5 13:09 lcli
drwxr-xr-x  4 root root    54 12月  5 13:09 lighthouse
drwxr-xr-x  2 root root    61 12月  5 13:09 scripts
drwxr-xr-x  6 root root    88 12月  5 13:09 tests
drwxr-xr-x  3 root root    52 12月  5 13:09 validator_client

make


[root@eth2-node lighthouse]# make
cargo install --path lighthouse --force
  Installing lighthouse v0.1.0 (/root/lighthouse/lighthouse)
    Updating crates.io index
    Updating git repository `https://github.com/sigp/milagro_bls`
    Updating git repository `https://github.com/SigP/rust-libp2p/`
    Updating git repository `https://github.com/SigP/libsecp256k1`
  Downloaded ctrlc v3.1.3
  Downloaded bigint v4.4.1
  Downloaded slog v2.5.2
  Downloaded reqwest v0.9.22
  Downloaded arrayref v0.3.5

~~snip;




   Compiling client v0.1.0 (/root/lighthouse/beacon_node/client)
   Compiling validator_client v0.1.0 (/root/lighthouse/validator_client)
   Compiling beacon_node v0.1.0 (/root/lighthouse/beacon_node)
   Compiling account_manager v0.0.1 (/root/lighthouse/account_manager)
   Compiling lighthouse v0.1.0 (/root/lighthouse/lighthouse)
    Finished release [optimized] target(s) in 13m 33s
  Installing /root/.cargo/bin/lighthouse
   Installed package `lighthouse v0.1.0 (/root/lighthouse/lighthouse)` (executable `lighthouse`)
[root@eth2-node lighthouse]#

make testは割愛。(良い子のみんなはするんだぞ。)
http://lighthouse-book.sigmaprime.io/setup.html

インストールされてた。


[root@eth2-node lighthouse]# lighthouse --version
Lighthouse 0.1.0

ノードの起動

ビーコンチェーンノードとバリデーターノードを試せる。
まだpublic testnetはないみたいなのでローカルだけになる。
https://lighthouse.sigmaprime.io/update-18.html

ビーコンチェーンノード

beacon-chain nodeから。

http://lighthouse-book.sigmaprime.io/testnets.html#examples を参考にビーコンノードから。は適当なunix timestampを。


[root@eth2-node ~]# lighthouse bn testnet -f quick 8 1575520375
Dec 05 13:36:24.669 WARN Ethereum 2.0 is pre-release. This software is experimental.
Dec 05 13:36:24.801 WARN Block production impaired               reason: dummy eth1 backend is enabled
Dec 05 13:36:24.802 INFO WebSocket server started                port: 5053, address: 127.0.0.1, service: ws
Dec 05 13:36:24.804 INFO Beacon chain initialized                head_slot: 0, head_block: 0xe9a4…4e0a, head_state: 0xb44d…0c15, service: beacon
Dec 05 13:36:24.805 INFO Libp2p Service                          peer_id: PeerId("16Uiu2HAmCgTUy1vA4RuyTBU3mJYCu8QPL728KSRmXBoyj88yGhfa"), service: network
Dec 05 13:36:24.805 INFO ENR Initialised                         seq: 1, enr: enr:-Iu4QGZHp-y2I_J6zv2IOiEzdmCgb1X2XbQR1e-oJ-whuf_bHYccHfCLEmPt370J1scFWxAOcbP_A8ZOKDejwyy
m96QBgmlkgnY0gmlwhAAAAACJc2VjcDI1NmsxoQMAYEJsMacFIeOCxxZ-LObiRWbReXwyp8PgZTQTwE5SVYN0Y3CCIyiDdWRwgiMo, service: network
Dec 05 13:36:24.815 INFO Listening established                   address: /ip4/0.0.0.0/tcp/9000/p2p/16Uiu2HAmCgTUy1vA4RuyTBU3mJYCu8QPL728KSRmXBoyj88yGhfa, service: netwo
rk
Dec 05 13:36:24.815 INFO Subscribed to topics                    topics: ["/eth2/beacon_block/ssz", "/eth2/beacon_attestation/ssz", "/eth2/voluntary_exit/ssz", "/eth2/pr
oposer_slashing/ssz", "/eth2/attester_slashing/ssz"], service: network
Dec 05 13:36:24.815 INFO REST API started                        port: 5052, address: 127.0.0.1, service: http
Dec 05 13:36:24.816 INFO ENR Updated                             address: V4(127.0.0.1:9000), seq: 2, enr: enr:-Iu4QCdgyV6DLzq29ThlHaXPn4bj5ROQY4dIuCyaw5yzLWZiX6FLYgSYsS
gkYkbwe32Iz2rSThGfGZQRaemwxf1qhrUCgmlkgnY0gmlwhH8AAAGJc2VjcDI1NmsxoQMAYEJsMacFIeOCxxZ-LObiRWbReXwyp8PgZTQTwE5SVYN0Y3CCIyiDdWRwgiMo, service: network
Dec 05 13:36:24.817 WARN Low peer count                          peer_count: 0, service: peer_notifier
Dec 05 13:36:25.001 INFO Slot start                              slot: 35, best_block_slot: 0, best_block_root: 0xe9a4…4e0a, skip_slots: 35, service: slot_notifier      
Dec 05 13:36:31.002 INFO Slot start                              slot: 36, best_block_slot: 0, best_block_root: 0xe9a4…4e0a, skip_slots: 36, service: slot_notifier      

うーん。ピアがいないからいまいち。

バリデーターノード

ビーコンのほうを起動したままにしておくこと。

image.png

-bを付けるとこんなんでた。-b消したら動いたけどなんなんだろう?

[root@eth2-node ~]#  lighthouse vc testnet -b insecure 0 8
error: Found argument '-b' which wasn't expected, or isn't valid in this context

USAGE:
    lighthouse validator_client testnet [OPTIONS] [SUBCOMMAND]

For more information try --help
[root@eth2-node ~]#  lighthouse vc testnet insecure 0 8
Dec 05 13:46:33.519 WARN Ethereum 2.0 is pre-release. This software is experimental.
Dec 05 13:46:33.519 INFO Starting validator client               datadir: "/root/.lighthouse/validators", beacon_node: http://localhost:5052/
Dec 05 13:46:33.535 INFO Connected to beacon node                version: Lighthouse/v0.1.0-unstable/x86_64-linux
Dec 05 13:46:33.537 INFO Genesis has already occurred            seconds_ago: 818
Dec 05 13:46:33.554 INFO Loaded validator keypair store          voting_validators: 8
Dec 05 13:46:33.572 INFO First duty assignment for validator     validator: 0x0x9977f1c8b731a8d5558146bfb86caea26434f3c5878b589bf280a42c9159e700e9df0e4086296c20b011d2e78
c27d373, attestation_slot: Some(Slot(136)), proposal_slots: [Slot(142)], service: duties
Dec 05 13:46:33.572 INFO First duty assignment for validator     validator: 0x0xb89bebc699769726a318c8e9971bd3171297c61aea4a6578a7a4f94b547dcba5bac16a89108b6b6a1fe3695d1
a874a0b, attestation_slot: Some(Slot(138)), proposal_slots: [], service: duties
Dec 05 13:46:33.572 INFO First duty assignment for validator     validator: 0x0x81283b7a20e1ca460ebd9bbd77005d557370cabb1f9a44f530c4c4c66230f675f8df8b4c2818851aa7d77a80c
a5a4a5e, attestation_slot: Some(Slot(140)), proposal_slots: [Slot(137), Slot(141)], service: duties
Dec 05 13:46:33.572 INFO First duty assignment for validator     validator: 0x0xa3a32b0f8b4ddb83f1a0a853d81dd725dfe577d4f4c3db8ece52ce2b026eca84815c1a7e8e92a4de3d755733b
f7e4a9b, attestation_slot: Some(Slot(141)), proposal_slots: [], service: duties
Dec 05 13:46:33.573 INFO First duty assignment for validator     validator: 0x0xab0bdda0f85f842f431beaccf1250bf1fd7ba51b4100fd64364b6401fda85bb0069b3e715b58819684e7fc0b1
0a72a34, attestation_slot: Some(Slot(137)), proposal_slots: [Slot(138), Slot(143)], service: duties
Dec 05 13:46:33.573 INFO First duty assignment for validator     validator: 0x0xa99a76ed7796f7be22d5b7e85deeb7c5677e88e511e0b337618f8c4eb61349b4bf2d153f649f7b53359fe8b94
a38e44c, attestation_slot: Some(Slot(143)), proposal_slots: [], service: duties
Dec 05 13:46:33.573 INFO First duty assignment for validator     validator: 0x0xa8d4c7c27795a725961317ef5953a7032ed6d83739db8b0e8a72353d1b8b4439427f7efa2c89caa03cc9f28f8
cbab8ac, attestation_slot: Some(Slot(142)), proposal_slots: [], service: duties
Dec 05 13:46:33.573 INFO First duty assignment for validator     validator: 0x0x88c141df77cd9d8d7a71a75c826c41a9c9f03c6ee1b180f3e7852f6a280099ded351b58d66e653af8e42816a4
d8f532e, attestation_slot: Some(Slot(139)), proposal_slots: [Slot(136), Slot(139), Slot(140)], service: duties
Dec 05 13:46:37.278 INFO Successfully published block            slot: 137, attestations: 0, deposits: 0, service: block
Dec 05 13:46:39.031 INFO Successfully published attestation      slot: 137, committee_index: 0, head_block: 0xf8d0…0aef, signatures: 1, service: attestation
Dec 05 13:46:43.192 INFO Successfully published block            slot: 138, attestations: 1, deposits: 0, service: block
Dec 05 13:46:45.026 INFO Successfully published attestation      slot: 138, committee_index: 0, head_block: 0xf328…d3f4, signatures: 1, service: attestation
Dec 05 13:46:49.195 INFO Successfully published block            slot: 139, attestations: 1, deposits: 0, service: block

genesis fileを出しておく。

[root@eth2-node ~]# curl --header "Content-Type: application/ssz" "localhost:5052/beacon/state/genesis" -o /tmp/genesis.ssz
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed  
100 17948  100 17948    0     0  2190k      0 --:--:-- --:--:-- --:--:-- 2503k 

REST APIお試し。

http://lighthouse-book.sigmaprime.io/http.html にいくつかサンプルがあったので試してみる。

Get the node's beacon chain head


[root@eth2-node ~]# curl localhost:5052/beacon/head | jq
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   533  100   533    0     0   173k      0 --:--:-- --:--:-- --:--:--  260k
{
  "slot": 181,
  "block_root": "0x2bd503e5384774a3a3620ff089affcc58a7c0bfddc0e904c1630310a8c4b35db",
  "state_root": "0x74d85cd9157a4b6c767a8d2068110847f1a624b6e6eb629cbe211f83f765c041",
  "finalized_slot": 160,
  "finalized_block_root": "0xd8a4fe03a81e9c49219e2feb4663bc045057e24273b992ce8df2b8573753d0bb",
  "justified_slot": 168,
  "justified_block_root": "0xdf4a3e0c8619bad65ee10fcbc800e78aaacfbd980e06cc3b89fc02724a2fc014",
  "previous_justified_slot": 160,
  "previous_justified_block_root": "0xd8a4fe03a81e9c49219e2feb4663bc045057e24273b992ce8df2b8573753d0bb"
}

https://app.swaggerhub.com/apis-docs/spble/lighthouse_rest_api/0.2.0 からいくつか。

node version

[root@eth2-node ~]# curl localhost:5052/node/version
"Lighthouse/v0.1.0-unstable/x86_64-linux"[root@eth2-node ~]# curl localhost:5052/node/version | jq
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100    41  100    41    0     0  13666      0 --:--:-- --:--:-- --:--:-- 20500
"Lighthouse/v0.1.0-unstable/x86_64-linux"

syncingはまだ未実装

[root@eth2-node ~]# curl localhost:5052/node/syncing
API endpoint has not yet been implemented, but is planned to be soon.

block


[root@eth2-node ~]# curl localhost:5052/beacon/block?slot=234 | jq
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100  1631  100  1631    0     0   530k      0 --:--:-- --:--:-- --:--:--  530k
{
  "root": "0x08d76e0e21159460de606fb77f28531cbe087dd1a55cd3b812cfe717b93830eb",
  "beacon_block": {
    "slot": 234,
    "parent_root": "0x1d2ba88743ac8c7be604e5b0ff8ec887539f9332f2e567ac47272ed19a8fb83b",
    "state_root": "0x6c881eee4f40dde894ae8957c9d2c511b0310e5ddfcd11d7c1d853349237d1c7",
    "body": {
      "randao_reveal": "0x977a8ab5cc1f1608d5a1967032cac875e5e2e9ac22502810bbe5624d3557b6be6167d1d53d44d75af94833f159ac3c301410e5d5b1c080b4a23303d61d5bd60579d1bbb1e4fcc48
9ae1a4737e9add03d9b22cb623a3123ef6eb965b7e65ec1b3",
      "eth1_data": {
        "deposit_root": "0x01d0fabd251fcbbe2b93b4b927b26ad2a1a99077152e45ded1e678afa45dbec5",
        "deposit_count": 8,
        "block_hash": "0x7e59998584f83454a4095c90006b277c31ec7b447fee44f88bf57f10edf5ab14"
      },
      "graffiti": "0x736967702f6c69676874686f7573652d302e302e302d70726572656c65617365",
      "proposer_slashings": [],
      "attester_slashings": [],
      "attestations": [
        {
          "aggregation_bits": "0x03",
          "data": {
            "slot": 233,
            "index": 0,
            "beacon_block_root": "0x1d2ba88743ac8c7be604e5b0ff8ec887539f9332f2e567ac47272ed19a8fb83b",
            "source": {
              "epoch": 28,
              "root": "0x718a11c989db53200946d940af705057b9747f6d68bb45b45aac3a1dcc0ecf74"
            },
            "target": {
              "epoch": 29,
              "root": "0x85028c87044b3d0ce4856968c3c5d093f4d91dbdd320740814b1bc88b39e3e94"
            }
          },
          "signature": "0x9555878de9af5f424ca508df22bc707e2038f2180ed3bc125d96630994cc5c05c432c18f50562eb4915a104cc22ec3d607c6ca7b892699ebb0a67f66984d77d07dcfd00e701ee8c
5be514cc34b77c55659c2cda5512149f1c87073eb2d461c0e"
        }
      ],
      "deposits": [],
      "voluntary_exits": []
    },
    "signature": "0xa4531ed5215f5339f21a8f689eb8c71580958137fa17faf12bcc0d87fcaf1c7a4314283b5b7493e3bde22ec5b1eda29005ff38e5f13c62a0d50ef29c0c344bc7547e8008641c69c3903d6
26bd62285016f8928d0064efc0ba4fbfc74d7028841"
  }
}

まとめ

Public Testnetが動き出したら試せることが増えそうなので面白くなりそう。
普通の人(?)はまだ手を出さなくてもいいんじゃないですかね。
すんなり動いてよかった。

2
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
0