Beacon Chain Node

Mike Tango Bravo · Updated 2022-02-06

  1. Firewall

Install xray (Ubuntu 20.04) node

setup ssh for remote access

[mbarrow@xray ~]$ ssh-keygen -t rsa
Generating public/private rsa key pair.
Enter file in which to save the key (/home/mbarrow/.ssh/id_rsa): 
Created directory '/home/mbarrow/.ssh'.
Enter passphrase (empty for no passphrase): 
Enter same passphrase again: 
Your identification has been saved in /home/mbarrow/.ssh/id_rsa.
Your public key has been saved in /home/mbarrow/.ssh/id_rsa.pub.
The key fingerprint is:
SHA256:yCL0uBEDyvMNznTAnlZ/IlJwstZgkxi84xGc5EcHQMk mbarrow@xray
The key's randomart image is:
+---[RSA 2048]----+
|B=BX+o           |
|+EooXo           |
|.+B*+o.          |
| =OX+o + .       |
|. B++.+ S        |
| . + .           |
|  .              |
|                 |
|                 |
+----[SHA256]-----+
[mbarrow@xray .ssh]$ vi authorized_keys

ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDD1E/jj/edBSEMaSErYlb90d1Q+eg6fsXzwEvYBHmKztraA3rr/70/bVLJQr6URgK+GKgchonmQ5XR/JHU1iChuoQITzEgiLMuwmjeRzMl1f1lhTVXRD4VbGWkuryyAOQx69CrQEfQ+0pKA7OzVBwq4AniqAxw3sQINlIlV+DMQRgFr499leaeLUHnkaiRXPi91dduDMQ3dqsaSsWf9TQDnxSmp44fLb08rvQ1ziqO8AaKEtXpj0Zz1WZQa1/mk2t76jMvS6Dg1/VqOc1ubAj6X52cJCvVW+M/+o8VgodLDSQOQMM0kLn7onfJLslzHD+ax/58zhk/6IPdg+qGUpi1 mbarrow@MTBMBP.local

[mbarrow@xray .ssh]$ chmod 700 authorized_keys 

OpenEthereum ETH1 node setup

OpenEthereum (used to be called Parity) is written in Rust and licensed under the GPLv3. The design goals are to be “the fastest, lightest, and most secure Ethereum client”.

Installing OpenEthereum

The OpenEthereum documentation explains how to download and install the client.

Dependencies

mbarrow@xray:~$ sudo apt-get install build-essential cmake libudev-dev

[mbarrow@xray ~]$ mkdir openethereum

[mbarrow@xray ~]$ cd openethereum/

[mbarrow@xray openethereum]$ wget https://github.com/openethereum/openethereum/releases/download/v3.1.0/openethereum-linux-v3.1.0.zip

Automate openethereum start:

mbarrow@xray:~$ sudo vi /etc/systemd/system/eth1.service

mbarrow@xray:~$ sudo systemctl daemon-reload

mbarrow@xray:~$ sudo systemctl enable eth1

Dec 01 03:47:27 xray systemd[1]: Started openethereum eth1 service.
Dec 01 03:47:27 xray openethereum[20198]: 2020-12-01 03:47:27 UTC Starting OpenEthereum/v3.1.0-stable-2072341-20201102/x86_64-linux-gnu/rustc1.47.0
Dec 01 03:47:27 xray openethereum[20198]: 2020-12-01 03:47:27 UTC Keys path /home/mbarrow/.local/share/openethereum/keys/ethereum
Dec 01 03:47:27 xray openethereum[20198]: 2020-12-01 03:47:27 UTC DB path /home/mbarrow/.local/share/openethereum/chains/ethereum/db/906a34e69aec8c0d
Dec 01 03:47:27 xray openethereum[20198]: 2020-12-01 03:47:27 UTC State DB configuration: fast
Dec 01 03:47:27 xray openethereum[20198]: 2020-12-01 03:47:27 UTC Operating mode: active
Dec 01 03:47:30 xray openethereum[20198]: 2020-12-01 03:47:30 UTC Configured for Ethereum using Ethash engine
Dec 01 03:47:31 xray openethereum[20198]: 2020-12-01 03:47:31 UTC Listening for new connections on 127.0.0.1:8546.
Dec 01 03:47:32 xray openethereum[20198]: 2020-12-01 03:47:32 UTC Updated conversion rate to Ξ1 = US$608.27 (7828603 wei/gas)
Dec 01 03:47:36 xray openethereum[20198]: 2020-12-01 03:47:36 UTC Public node URL: enode://e5251cc2be72640d988484d6bb4a9370b6c4536c3a97884ecf7dc851e73c42d2d348004bca0961a61b951b795334df3b7a17e11b09ef341586ecfc90d03bbfc7@192.168.0.31:30303
Dec 01 03:47:41 xray openethereum[20198]: 2020-12-01 03:47:41 UTC Syncing #1137233 0x4ced…c83a     0.00 blk/s    0.0 tx/s    0.0 Mgas/s      0+    0 Qed  #1137233   14/25 peers     74 KiB chain  0 bytes queue  RPC:  0 conn,    0 req/s,    0 µs
Dec 01 03:47:46 xray openethereum[20198]: 2020-12-01 03:47:46 UTC Snapshot initializing (0 chunks restored)  #1137233   14/25 peers     74 KiB chain  0 bytes queue  RPC:  0 conn,    0 req/s,    0 µs
Dec 01 03:47:51 xray openethereum[20198]: 2020-12-01 03:47:51 UTC Snapshot initializing (0 chunks restored)  #1137233   15/25 peers     74 KiB chain  0 bytes queue  RPC:  0 conn,    0 req/s,    0 µs
Dec 01 03:47:56 xray openethereum[20198]: 2020-12-01 03:47:56 UTC Syncing snapshot 0/6203  #1137233   15/25 peers     74 KiB chain  0 bytes queue  RPC:  0 conn,    0 req/s,    0 µs

Create the validator keys:

mbarrow@xray:~/eth2deposit-cli-ed5a6d3-linux-amd64$ ./deposit new-mnemonic --num_validators 1 --chain mainnet

Install Lighthouse

mbarrow@xray:~/lighthouse$ tar xvf lighthouse-v1.0.3-x86_64-unknown-linux-gnu-portable.tar.gz
lighthouse
mbarrow@xray:~/lighthouse$ sudo mv lighthouse /usr/local/bin
mbarrow@xray:~/lighthouse$ lighthouse
Dec 01 04:11:55.167 INFO Lighthouse started                      version: Lighthouse/v1.0.3-65dcdc3
Dec 01 04:11:55.167 INFO Configured for network                  name: mainnet
Dec 01 04:11:55.168 CRIT No subcommand supplied. See --help .
No subcommand supplied.

Import Keystore file into the Validator Wallet

mbarrow@xray:/usr/local/bin$ lighthouse --network mainnet account validator import --directory /home/mbarrow/eth2deposit-cli-ed5a6d3-linux-amd64/validator_keys --datadir /var/lib/lighthouse/
Running account manager for mainnet network
validator-dir path: "/var/lib/lighthouse/validators"
validator-dir path: "/var/lib/lighthouse/validators"
WARNING: DO NOT USE THE ORIGINAL KEYSTORES TO VALIDATE WITH ANOTHER CLIENT, OR YOU WILL GET SLASHED.

Keystore found at "/home/mbarrow/eth2deposit-cli-ed5a6d3-linux-amd64/validator_keys/keystore-m_12381_3600_0_0_0-1606758066.json":

 - Public key: 0x95e19be37079773d8d189b9e077b21c92185aacaa0d8a8bf46dfeff918e6c25ab7e4eb9d69629b4bcbf33c69d8c33da5
 - UUID: 2fa92612-9e99-41f4-83de-2fcb265e29b4

If you enter the password it will be stored as plain-text in validator_definitions.yml so that it is not required each time the validator client starts.

Enter the keystore password, or press enter to omit it:

Password is correct.

Successfully imported keystore.
Successfully updated validator_definitions.yml.

Successfully imported 1 validators (0 skipped).

WARNING: DO NOT USE THE ORIGINAL KEYSTORES TO VALIDATE WITH ANOTHER CLIENT, OR YOU WILL GET SLASHED.

Configure the Beacon Node Service

mbarrow@xray:/usr/local/bin$ sudo chown -R root:root /var/lib/lighthouse
mbarrow@xray:/usr/local/bin$ sudo useradd --no-create-home --shell /bin/false lighthousebeacon
mbarrow@xray:/usr/local/bin$ sudo mkdir -p /var/lib/lighthouse/beacon
mbarrow@xray:/usr/local/bin$ sudo chown -R lighthousebeacon:lighthousebeacon /var/lib/lighthouse/beacon
mbarrow@xray:/usr/local/bin$ sudo chmod 700 /var/lib/lighthouse/beacon
mbarrow@xray:/usr/local/bin$ ls -dl /var/lib/lighthouse/beacon
drwx------ 2 lighthousebeacon lighthousebeacon 4096 Dec  1 04:18 /var/lib/lighthouse/beacon
mbarrow@xray:/usr/local/bin$ sudo vi /etc/systemd/system/lighthousebeacon.service
[Unit]
Description=Lighthouse Eth2 Client Beacon Node
Wants=network-online.target
After=network-online.target[Service]
User=lighthousebeacon
Group=lighthousebeacon
Type=simple
Restart=always
RestartSec=5
ExecStart=/usr/local/bin/lighthouse bn --network mainnet --datadir /var/lib/lighthouse --staking --eth1-endpoints http://127.0.0.1:8545[Install]
WantedBy=multi-user.tar


sudo systemctl start lighthousebeacon
sudo systemctl status lighthousebeacon
sudo systemctl enable lighthousebeacon
sudo journalctl -fu lighthousebeacon.service

Monitoring the validator with Grafana and Prometheus

Install prometheus and prometheus node exporter

sudo apt-get install -y prometheus prometheus-node-exporter

Install Grafana

wget -q -O - https://packages.grafana.com/gpg.key | sudo apt-key add -
echo "deb https://packages.grafana.com/oss/deb stable main" > grafana.list
sudo mv grafana.list /etc/apt/sources.list.d/grafana.list
sudo apt-get update && sudo apt-get install -y grafana

Enable services to start automatically

sudo systemctl enable grafana-server.service
sudo systemctl enable prometheus.service
sudo systemctl enable prometheus-node-exporter.service

Update prometheus.yml located in /etc/prometheus/prometheus.yml

cat > $HOME/prometheus.yml << EOF
global:
 scrape_interval: 15s # By default, scrape targets every 15 seconds.
# Attach these labels to any time series or alerts when communicating with
 # external systems (federation, remote storage, Alertmanager).
 external_labels:
 monitor: 'codelab-monitor'
# A scrape configuration containing exactly one endpoint to scrape:
# Here it's Prometheus itself.
scrape_configs:
 - job_name: 'node_exporter'
 static_configs:
 - targets: ['localhost:9100']
 - job_name: 'nodes'
 metrics_path: /metrics 
 static_configs:
 - targets: ['localhost:5054']
EOF
sudo mv $HOME/prometheus.yml /etc/prometheus/prometheus.yml

Restart the Services

sudo systemctl restart grafana-server.service
sudo systemctl restart prometheus.service
sudo systemctl restart prometheus-node-exporter.service

Verify the services

sudo systemctl status grafana-server.service prometheus.service prometheus-node-exporter.service

● grafana-server.service - Grafana instance

Loaded: loaded (/lib/systemd/system/grafana-server.service; enabled; vendor preset: enabled)

Active: active (running) since Thu 2020-12-03 02:14:39 UTC; 46s ago

Docs: http://docs.grafana.org

Main PID: 10087 (grafana-server)

Tasks: 9 (limit: 9450)

Memory: 48.0M

CGroup: /system.slice/grafana-server.service

└─10087 /usr/sbin/grafana-server --config=/etc/grafana/grafana.ini --pidfile=/var/run/grafana/grafana-server.pid --packaging=deb cfg:default.paths.logs=/var/log>

Dec 03 02:15:22 xray grafana-server[10087]: t=2020-12-03T02:15:22+0000 lvl=info msg="Executing migration" logger=migrator id="Add index for gnetId in dashboard"

Dec 03 02:15:22 xray grafana-server[10087]: t=2020-12-03T02:15:22+0000 lvl=info msg="Executing migration" logger=migrator id="Add column plugin_id in dashboard"

Dec 03 02:15:23 xray grafana-server[10087]: t=2020-12-03T02:15:23+0000 lvl=info msg="Executing migration" logger=migrator id="Add index for plugin_id in dashboard"

Dec 03 02:15:23 xray grafana-server[10087]: t=2020-12-03T02:15:23+0000 lvl=info msg="Executing migration" logger=migrator id="Add index for dashboard_id in dashboard_tag"

Dec 03 02:15:23 xray grafana-server[10087]: t=2020-12-03T02:15:23+0000 lvl=info msg="Executing migration" logger=migrator id="Update dashboard table charset"

Dec 03 02:15:24 xray grafana-server[10087]: t=2020-12-03T02:15:24+0000 lvl=info msg="Executing migration" logger=migrator id="Update dashboard_tag table charset"

Dec 03 02:15:25 xray grafana-server[10087]: t=2020-12-03T02:15:25+0000 lvl=info msg="Executing migration" logger=migrator id="Add column folder_id in dashboard"

Dec 03 02:15:25 xray grafana-server[10087]: t=2020-12-03T02:15:25+0000 lvl=info msg="Executing migration" logger=migrator id="Add column isFolder in dashboard"

Dec 03 02:15:26 xray grafana-server[10087]: t=2020-12-03T02:15:26+0000 lvl=info msg="Executing migration" logger=migrator id="Add column has_acl in dashboard"

Dec 03 02:15:26 xray grafana-server[10087]: t=2020-12-03T02:15:26+0000 lvl=info msg="Executing migration" logger=migrator id="Add column uid in dashboard"

Dec 03 02:15:27 xray grafana-server[10087]: t=2020-12-03T02:15:27+0000 lvl=info msg="Executing migration" logger=migrator id="Update uid column values in dashboard"

Dec 03 02:15:27 xray grafana-server[10087]: t=2020-12-03T02:15:27+0000 lvl=info msg="Executing migration" logger=migrator id="Add unique index dashboard_org_id_uid"

Dec 03 02:15:27 xray grafana-server[10087]: t=2020-12-03T02:15:27+0000 lvl=info msg="Executing migration" logger=migrator id="Remove unique index org_id_slug"

Dec 03 02:15:28 xray grafana-server[10087]: t=2020-12-03T02:15:28+0000 lvl=info msg="Executing migration" logger=migrator id="Update dashboard title length"

● prometheus.service - Monitoring system and time series database

Loaded: loaded (/lib/systemd/system/prometheus.service; enabled; vendor preset: enabled)

Active: active (running) since Thu 2020-12-03 02:14:40 UTC; 47s ago

Docs: https://prometheus.io/docs/introduction/overview/

Main PID: 10098 (prometheus)

Tasks: 15 (limit: 9450)

Memory: 61.8M

CGroup: /system.slice/prometheus.service

└─10098 /usr/bin/prometheus

Dec 03 02:14:46 xray prometheus[10098]: level=info ts=2020-12-03T02:14:46.804Z caller=head.go:632 component=tsdb msg="WAL segment loaded" segment=22 maxSegment=26

Dec 03 02:14:47 xray prometheus[10098]: level=info ts=2020-12-03T02:14:47.642Z caller=head.go:632 component=tsdb msg="WAL segment loaded" segment=23 maxSegment=26

Dec 03 02:14:49 xray prometheus[10098]: level=info ts=2020-12-03T02:14:49.911Z caller=head.go:632 component=tsdb msg="WAL segment loaded" segment=24 maxSegment=26

Dec 03 02:14:50 xray prometheus[10098]: level=info ts=2020-12-03T02:14:50.384Z caller=head.go:632 component=tsdb msg="WAL segment loaded" segment=25 maxSegment=26

Dec 03 02:14:50 xray prometheus[10098]: level=info ts=2020-12-03T02:14:50.384Z caller=head.go:632 component=tsdb msg="WAL segment loaded" segment=26 maxSegment=26

Dec 03 02:14:50 xray prometheus[10098]: level=info ts=2020-12-03T02:14:50.394Z caller=main.go:661 fs_type=EXT4_SUPER_MAGIC

Dec 03 02:14:50 xray prometheus[10098]: level=info ts=2020-12-03T02:14:50.394Z caller=main.go:662 msg="TSDB started"

Dec 03 02:14:50 xray prometheus[10098]: level=info ts=2020-12-03T02:14:50.394Z caller=main.go:732 msg="Loading configuration file" filename=/etc/prometheus/prometheus.yml

Dec 03 02:14:50 xray prometheus[10098]: level=info ts=2020-12-03T02:14:50.733Z caller=main.go:760 msg="Completed loading of configuration file" filename=/etc/prometheus/prom>

Dec 03 02:14:50 xray prometheus[10098]: level=info ts=2020-12-03T02:14:50.733Z caller=main.go:615 msg="Server is ready to receive web requests."

● prometheus-node-exporter.service - Prometheus exporter for machine metrics

Loaded: loaded (/lib/systemd/system/prometheus-node-exporter.service; enabled; vendor preset: enabled)

Active: active (running) since Thu 2020-12-03 02:14:42 UTC; 48s ago

Docs: https://github.com/prometheus/node_exporter

Main PID: 10126 (prometheus-node)

Tasks: 13 (limit: 9450)

Memory: 11.9M

CGroup: /system.slice/prometheus-node-exporter.service

└─10126 /usr/bin/prometheus-node-exporter

Dec 03 02:14:43 xray prometheus-node-exporter[10126]: time="2020-12-03T02:14:43Z" level=info msg=" - stat" source="node_exporter.go:104"

Dec 03 02:14:43 xray prometheus-node-exporter[10126]: time="2020-12-03T02:14:43Z" level=info msg=" - systemd" source="node_exporter.go:104"

Dec 03 02:14:43 xray prometheus-node-exporter[10126]: time="2020-12-03T02:14:43Z" level=info msg=" - textfile" source="node_exporter.go:104"

Dec 03 02:14:43 xray prometheus-node-exporter[10126]: time="2020-12-03T02:14:43Z" level=info msg=" - time" source="node_exporter.go:104"

Dec 03 02:14:43 xray prometheus-node-exporter[10126]: time="2020-12-03T02:14:43Z" level=info msg=" - timex" source="node_exporter.go:104"

Dec 03 02:14:43 xray prometheus-node-exporter[10126]: time="2020-12-03T02:14:43Z" level=info msg=" - uname" source="node_exporter.go:104"

Dec 03 02:14:43 xray prometheus-node-exporter[10126]: time="2020-12-03T02:14:43Z" level=info msg=" - vmstat" source="node_exporter.go:104"

Dec 03 02:14:43 xray prometheus-node-exporter[10126]: time="2020-12-03T02:14:43Z" level=info msg=" - xfs" source="node_exporter.go:104"

Dec 03 02:14:43 xray prometheus-node-exporter[10126]: time="2020-12-03T02:14:43Z" level=info msg=" - zfs" source="node_exporter.go:104"

Dec 03 02:14:43 xray prometheus-node-exporter[10126]: time="2020-12-03T02:14:43Z" level=info msg="Listening on :9100" source="node_exporter.go:170"

mbarrow@xray:~$ sudo systemctl restart prometheus.service

Open port 3000

mbarrow@xray:~$ sudo ufw allow 3000/tcp
Rule added
Rule added (v6)

Setup Grafana Dashboard

  1. Open http://xray:3000
  2. Login with admin / admin
  3. Change password
  4. Click the configuration gear icon, then Add data Source
  5. Select Prometheus
  6. Set Name to "Prometheus"
  7. Set URL to http://localhost:9090
  8. Click Save & Test
  9. Download and save this json file.
  10. Click Create + icon > Import
  11. Add dashboard by Upload JSON file
  12. Click the Import button.