Skip to content

Commit 80b6c41

Browse files
authored
Merge pull request eth-educators#23 from yorickdowne/grafana-devel
Clarified the README. Many thanks to OhraeMez!
2 parents a81f52d + f97e365 commit 80b6c41

12 files changed

+613
-106
lines changed

.eth2/.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
*
22
!.gitignore
33
!README.md
4+
!validator_keys

.eth2/README.md

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
Th directory `validator_keys` will contain the `deposit_data-TIMESTAMP.json` and `keystore-m_ID.json`
1+
The directory `validator_keys` will contain the `deposit_data-TIMESTAMP.json` and `keystore-m_ID.json`
22
files created by eth2.0-deposit-cli.
33

44
Use `deposit_data-TIMESTAMP.json` for your initial deposit. After that, it can be disposed of.
@@ -7,7 +7,7 @@ Use `keystore-m_ID.json` files to import your validator secret keys into the val
77
instance of the client you are running. These files need to be secured when you are done
88
with the initial import.
99

10-
#Key Security
10+
# Validator Key Security
1111

1212
The `keystore-m_ID.json` files have to be stored securely outside of this server. Offline
1313
is best, on media that cannot be remotely compromised. Keep the password(s) for
@@ -22,6 +22,8 @@ to slash your validator(s).
2222

2323
For more on validator key security, read this article: https://www.attestant.io/posts/protecting-validator-keys/
2424

25+
# Withdrawal Key Security
26+
2527
**Critical**
2628
When you ran eth2.0-deposit-cli, a 24-word mnemonic was created. This mnemonic
2729
will be used for eth2 withdrawals in the future. It must be securely kept offline.

.eth2/validator_keys/.gitignore

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
*
2+
!.gitignore
3+
!README.md

.eth2/validator_keys/README.md

+40
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
This directory `validator_keys` will contain the `deposit_data-TIMESTAMP.json` and `keystore-m_ID.json`
2+
files created by eth2.0-deposit-cli.
3+
4+
Use `deposit_data-TIMESTAMP.json` for your initial deposit. After that, it can be disposed of.
5+
6+
Use `keystore-m_ID.json` files to import your validator secret keys into the validator
7+
instance of the client you are running. These files need to be secured when you are done
8+
with the initial import.
9+
10+
# Validator Key Security
11+
12+
The `keystore-m_ID.json` files have to be stored securely outside of this server. Offline
13+
is best, on media that cannot be remotely compromised. Keep the password(s) for
14+
these files secure as well, for example in a local (not cloud-connected) password vault
15+
on a PC that is not on the network, or at the very least not used for online access.
16+
17+
These files will be needed in case you need to restore your validator(s).
18+
19+
**Caution**
20+
An attacker with access to these files could slash your validator(s) or threaten
21+
to slash your validator(s).
22+
23+
For more on validator key security, read this article: https://www.attestant.io/posts/protecting-validator-keys/
24+
25+
# Withdrawal Key Security
26+
27+
**Critical**
28+
When you ran eth2.0-deposit-cli, a 24-word mnemonic was created. This mnemonic
29+
will be used for eth2 withdrawals in the future. It must be securely kept offline.
30+
31+
Precise methods are beyond this README, but consider something as simple as
32+
a sheet of paper kept in a fireproof envelope in a safe, or one of the steel
33+
mnemonic safeguards that are available.
34+
35+
Test your mnemonic **before** you deposit, so you know that you will be able
36+
to withdraw funds in future.
37+
38+
An attacker with access to your mnemonic can drain your funds.
39+
40+
For more on withdrawal key security, read this article: https://www.attestant.io/posts/protecting-withdrawal-keys/

KEY-SECURITY.md

+3-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ Use `keystore-m_ID.json` files to import your validator secret keys into the val
77
instance of the client you are running. These files need to be secured when you are done
88
with the initial import.
99

10-
# Key Security
10+
# Validator Key Security
1111

1212
The `keystore-m_ID.json` files have to be stored securely outside of this server. Offline
1313
is best, on media that cannot be remotely compromised. Keep the password(s) for
@@ -25,6 +25,8 @@ to slash your validator(s).
2525

2626
For more on validator key security, read this article: https://www.attestant.io/posts/protecting-validator-keys/
2727

28+
# Withdrawal Key Security
29+
2830
**Critical**
2931
When you ran eth2.0-deposit-cli, a 24-word mnemonic was created. This mnemonic
3032
will be used for eth2 withdrawals in the future. It must be securely kept offline.

README.md

+136-12
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,30 @@ Currently included clients:
1111

1212
# USAGE
1313

14+
## Before you start
15+
1416
A file 'default.env' is provided and needs to be copied to '.env'.
1517
If this is not done, running docker-compose will fail.
18+
1619
After copying the file, you **must** adjust the contents to your environment.
1720
Specifically, set the first entry `DEPCLI_UID` to your UID if you are running
18-
this on Linux. You can find your UID with `echo $UID`.
21+
this on Linux. You can find your UID with `echo $UID`.<br />
22+
You likely also *want* to set `GRAFFITI` inside the same file, and you might
23+
adjust `NUM_VAL` if you are going to create keys for more than one validator.
24+
25+
On Linux, `docker-compose` runs as root. The individual containers
26+
do not, they run as local users inside the container.
27+
28+
**Do not run two validators**<br />
29+
You'd get yourself slashed, and no-one wants that. Protecting you from this
30+
is a work in progress. Choose one client, and one client only, and run that.
31+
32+
**You need an eth1 source**<br />
33+
This project assumes you'll use geth. It doesn't have to be that, it can
34+
be a 3rd party. You need some source for eth1, so that your validator can
35+
successfully propose blocks.
36+
37+
Some troubleshooting commands are at the very end of the file.
1938

2039
## Install prerequisites
2140

@@ -26,6 +45,23 @@ have write access to - your $HOME is fine - and pull this repo
2645
via git: `git clone https://github.com/eth2-educators/eth2-docker.git`,
2746
then `cd eth2-docker` into the newly created directory.
2847

48+
## Choose a client
49+
50+
I am deathly afraid of causing you to run two validators in parallel, leading to you getting slashed.
51+
52+
Therefore, I am asking you to choose one client, and one client only, and copy its corresponding file in.
53+
This is not ideal. If you'd like to collaborate on a shell wrapper that makes this easier, please get in touch via
54+
the ethstaker Discord.
55+
56+
There is a default file which runs lighthouse with local geth. If you are good with the default, just run with that.
57+
58+
You'll be copying from the directory `clients` to the file `docker-compose.yml` in this directory. Current options are:
59+
- lighthouse, `cp clients/lh.yml ./docker-compose.yml`
60+
- prysm, `cp clients/prysm.yml ./docker-compose.yml`
61+
62+
If you are going to use a 3rd-party eth1chain provider, edit `.env` and set either `LH_ETH1_NODE` or `PRYSM_ETH1_NODE` to
63+
point to your provider, and use the `eth2-3rd` target once you have imported keys and are ready.
64+
2965
## Create an eth2 wallet and deposit files
3066

3167
You will deposit eth to the deposit contract, and receive locked eth2 in turn.
@@ -42,7 +78,9 @@ is just one (1) validator.
4278
With that said, this command will get you ready to deposit eth:
4379
`sudo docker-compose run deposit-cli`
4480

45-
The created files will be in the directory `.eth2` in this project.
81+
The created files will be in the directory `.eth2/validator_keys` in this project.
82+
This is also where you'd place your own keystore files if you already have some for import.
83+
4684
Please see the file `KEY-SECURITY.md` in this project for some notes on
4785
key security.
4886

@@ -64,8 +102,16 @@ While this project gives you the freedom to shoot yourself in the foot like that
64102

65103
## Create a wallet by importing validator keys
66104

105+
### You brought your own keys
106+
107+
They go into `.eth2/validator_keys` in this project directory, not directly under `$HOME`.
108+
Make **damn sure** your old validator is down and will stay down, you will get slashed
109+
if both are up at the same time.
110+
67111
### Lighthouse
68112

113+
**Warning** Import your validator key(s) to only *one* client.
114+
69115
Once both your withdrawal key (mnemonic) and validator key(s) (`keystore-m_ID.json` file(s))
70116
are secured offline, and **not** before, import the validator key(s) to the Lighthouse
71117
validator client:
@@ -120,25 +166,48 @@ Then, and **only** then:
120166

121167
### Lighthouse
122168

123-
To start the lighthouse client, both beacon and validator, with local geth:
169+
To start the Lighthouse client, both beacon and validator, with local geth:
170+
171+
```
172+
sudo docker-compose up -d eth2
173+
```
174+
175+
Instead, if you are using a 3rd-party eth1chain, make sure that `LH_ETH1_NODE` in the file `.env` is pointing to it.
176+
177+
To start the Lighthouse client, both beacon and validator, with 3rd party eth1chain:
124178

125179
```
126-
sudo docker-compose up -d lighthouse
180+
sudo docker-compose up -d eth2-3rd
127181
```
128182

129183
If, however, you chose not to store the wallet password locally, bring the services
130184
up individually instead:
131185

186+
With local geth:
187+
132188
```
133189
sudo docker-compose up -d geth lh-beacon
190+
```
191+
192+
Or with 3rd party eth1chain:
193+
```
194+
sudo docker-compose up -d lh-beacon
195+
196+
```
197+
198+
Then "run" the validator so it can prompt you for input:
199+
```
134200
sudo docker-compose run lh-validator
135201
```
136202

137203
After providing the wallet password, use the key sequence Ctrl-p Ctrl-q to detach
138204
from the running container.
139205

206+
140207
### Prysm
141208

209+
The Prysm client requires copying in a file, see the start of this document.
210+
142211
Note that the Prysm client will find its external IP, but this repo assumes
143212
that IP is static. You can restart the container, possibly via crontab, with
144213
`docker-compose restart prysm-beacon` if your IP is dynamic.
@@ -147,14 +216,31 @@ Work to support dynamic DNS would also be welcome.
147216
To start the Prysm client, both beacon and validator, with local geth:
148217

149218
```
150-
sudo docker-compose up -d prysm
219+
sudo docker-compose up -d eth2
220+
```
221+
222+
Instead, if you are using a 3rd-party eth1chain, make sure that `PRYSM_ETH1_NODE` in the file `.env` is pointing to it.
223+
To start the Prysm client, both beacon and validator, with 3rd party eth1chain:
224+
225+
```
226+
sudo docker-compose up -d eth2-3rd
151227
```
152228

153229
If, however, you chose not to store the wallet password locally, bring the services
154230
up individually instead:
155231

232+
With local geth:
156233
```
157234
sudo docker-compose up -d geth prysm-beacon
235+
```
236+
237+
Or with 3rd-party eth1chain:
238+
```
239+
sudo docker-compose up -d prysm-beacon
240+
```
241+
242+
Then "run" the validator so it can prompt you for input:
243+
```
158244
sudo docker-compose run prysm-validator
159245
```
160246

@@ -193,13 +279,23 @@ cd eth2-docker
193279
cp default.env .env
194280
```
195281

282+
After copying the `default.env` file, you **must** adjust the contents
283+
of `.env` to your environment.
284+
Specifically, set the first entry `DEPCLI_UID` to your UID if you are running
285+
this on Linux. You can find your UID with `echo $UID`.
286+
287+
There is no need to touch the other UIDs in this file.
288+
196289
Other distributions are expected to work as long as they support
197290
git, docker, and docker-compose.
198291

199292
## Windows 10 Prerequisites
200293

201294
Install [Docker Desktop](https://www.docker.com/products/docker-desktop), [git](https://git-scm.com/download/win), and [Python 3](https://www.python.org/downloads/windows/). Note you can also type `python3` into a Powershell window and it will bring you to the Microsoft Store for a recent Python 3 version.
202295

296+
You have to copy the `default.env` file to `.env`, from Powershell: `cp default.env .env`.
297+
After copying this file, you *should* adjust the contents of `.env` to your environment.
298+
203299
Docker Desktop can be used with the WSL2 backend if desired, or without it.
204300

205301
You will run the docker-compose and docker commands from Powershell. You do not need `sudo` in front of those commands.
@@ -217,21 +313,21 @@ show you how to.
217313

218314
### Geth
219315

220-
Run:
316+
Run:<br />
221317
`sudo docker-compose build --no-cache geth`
222318

223-
Then stop, remove and start geth:
224-
`sudo docker-compose stop geth && sudo docker-compose rm geth`
319+
Then stop, remove and start geth:<br />
320+
`sudo docker-compose stop geth && sudo docker-compose rm geth`<br />
225321
`sudo docker-compose up -d geth`
226322

227323
### Lighthouse
228324

229325
lh-beacon and lh-validator share the same image, we only need to rebuild one.
230326

231-
Run:
327+
Run:<br />
232328
`sudo docker-compose build --no-cache lh-beacon`
233329

234-
Then restart the client:
330+
Then restart the client:<br />
235331
`sudo docker-compose down && sudo docker-compose up -d lighthouse`
236332

237333
If you did not provide the wallet password to the container, come up more manually instead.
@@ -240,14 +336,42 @@ If you did not provide the wallet password to the container, come up more manual
240336

241337
prysm-beacon and prysm-validator share the same image, we only need to rebuild one.
242338

243-
Run:
339+
Run:<br />
244340
`sudo docker-compose build --no-cache prysm-beacon`
245341

246-
Then restart the stack:
342+
Then restart the client:<br />
247343
`sudo docker-compose down && sudo docker-compose up -d prysm`
248344

249345
If you did not provide the wallet password to the container, come up more manually instead.
250346

347+
# Troubleshooting
348+
349+
A few useful commands if you run into issues.
350+
351+
`docker-compose stop servicename` brings a service down, for example `docker-compose stop lh-validator`.<br />
352+
`docker-compose down` will stop the entire stack.<br />
353+
`docker-compose up -d servicename` starts a single service, for example `docker-compose up -d lh-validator`.
354+
The `-d` means "detached", not connected to your input session.<br />
355+
`docker-compose run servicename` starts a single service and connects your input session to it. Use the Ctrl-p Ctrl-q
356+
key sequence to detach from it again.
357+
358+
`docker ps` lists all running services, with the container name to the right.<br />
359+
`docker logs containername` shows logs for a container, `docker logs -f containername` scrolls them.<br />
360+
`docker exec -it containername /bin/bash` will connect you to a running service in a bash shell. The geth service doesn't have a shell.<br />
361+
362+
If a service is continually restarting and you want to bring up its container manually, so you can investigate, first bring everything down:<br />
363+
`docker-compose down`, tear down everything first.<br />
364+
`docker ps`, make sure everything is down.<br />
365+
366+
**HERE BE DRAGONS** You can totally run N copies of an image manually and then successfully start a validator in each and get yourself slashed.
367+
Take extreme care.
368+
369+
Once your stack is down, to run an image and get into a shell, without executing the client automatically:<br />
370+
`docker run -it --entrypoint=/bin/bash imagename`, for example `docker run -it --entrypoint=/bin/bash lighthouse`.<br />
371+
You'd then run Linux commands manually in there, you could start components of the client manually. There is one image per client,
372+
the client images currently supplied are `lighthouse` and `prysm`.<br />
373+
`docker images` will show you all images.
374+
251375
# Guiding principles:
252376

253377
- Reduce the attack surface of the client where this is feasible. Not

TODO.md

+1-11
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,3 @@
1-
- Dynamic DNS for prysm. ddclient and --p2p-host-dns
21
- Grafana and prometheus dashboards
3-
- ~~Documentation of how to do staking / onboarding with either client~~
4-
- traefik or nginx for both grafana and UI access
5-
- infura option
6-
- eventually: openethereum option
7-
- more clients?
8-
- binary client distribution docker images instead of compiled?
9-
- ~~Documentation of how to update the stack~~
102
- docker-compose as a service on system boot
11-
- sh script to help a user come on board? But UI is likely better and comes from client team
12-
- Eventually: more conservative client build targets
13-
- Better secrets management than plaintext in the container. S3? Ansible?
3+
- Document mnemonic test

0 commit comments

Comments
 (0)