Update local testnet scripts, fix eth1 sim (#1184)

* Update local testnet scripts

* Add logs when decrypting validators

* Update comment

* Update account manager

* Make random key generation explicit

* Remove unnecessary clap constraint

* Only decrypt voting keypair for eth1 deposit

* Use insecure kdf for insecure keypairs

* Simplify local testnet keygen

* Update local testnet

* Fix eth1 sim

* Add eth1 sim to CI again

* Remove old local testnet docs

* Tidy

* Remove checks for existing validators

* Tidy

* Fix typos
This commit is contained in:
Paul Hauner
2020-05-26 18:30:44 +10:00
committed by GitHub
parent d41a9f7aa6
commit 8bc82c573d
25 changed files with 599 additions and 338 deletions

View File

@@ -0,0 +1,79 @@
# Simple Local Testnet
These scripts allow for running a small local testnet with two beacon nodes and
one validator client. This setup can be useful for testing and development.
## Requirements
The scripts require `lci` and `lighthouse` to be installed on `PATH`. From the
root of this repository, run:
```bash
cargo install --path lighthouse --force --locked
cargo install --path lcli --force --locked
```
## Starting the testnet
Assuming you are happy with the configuration in `var.env`, create the testnet
directory, genesis state and validator keys with:
```bash
./setup
```
Start the first beacon node:
```bash
./beacon_node
```
In a new terminal, start the validator client which will attach to the first
beacon node:
```bash
./validator_client
```
In a new terminal, start the second beacon node which will peer with the first:
```bash
./second_beacon_node
```
## Additional Info
### Debug level
The beacon nodes and validator client have their `--debug-level` set to `info`.
Specify a different debug level like this:
```bash
./validator_client debug
./beacon_node trace
./second_beacon_node warn
```
### Starting fresh
Delete the current testnet and all related files using:
```bash
./clean
```
### Updating the genesis time of the beacon state
If it's been a while since you ran `./setup` then the genesis time of the
genesis state will be far in the future, causing lots of skip slots.
Update the genesis time to now using:
```bash
./reset_genesis_time
```
> Note: you probably want to drop the beacon node database and the validator
> client slashing database if you do this. When using small validator counts
> it's probably easy to just use `./clean && ./setup`.

View File

@@ -5,14 +5,17 @@
# `./local_testnet_genesis_state`.
#
TESTNET_DIR=~/.lighthouse/local-testnet/testnet
DATADIR=~/.lighthouse/local-testnet/beacon
source ./vars.env
DEBUG_LEVEL=${1:-info}
exec lighthouse \
--debug-level $DEBUG_LEVEL \
bn \
--datadir $DATADIR \
--datadir $BEACON_DIR \
--testnet-dir $TESTNET_DIR \
--dummy-eth1 \
--http
--http \
--enr-address 127.0.0.1 \
--enr-udp-port 9000 \
--enr-tcp-port 9000 \

9
scripts/local_testnet/clean.sh Executable file
View File

@@ -0,0 +1,9 @@
#!/bin/bash
#
# Deletes all files associated with the local testnet.
#
source ./vars.env
rm -r $DATADIR

View File

@@ -0,0 +1,16 @@
#!/bin/bash
#
# Resets the beacon state genesis time to now.
#
source ./vars.env
NOW=$(date +%s)
lcli \
change-genesis-time \
$TESTNET_DIR/genesis.ssz \
$(date +%s)
echo "Reset genesis time to now ($NOW)"

View File

@@ -0,0 +1,20 @@
#!/bin/bash
#
# Starts a beacon node based upon a genesis state created by
# `./local_testnet_genesis_state`.
#
source ./vars.env
DEBUG_LEVEL=${1:-info}
exec lighthouse \
--debug-level $DEBUG_LEVEL \
bn \
--datadir $BEACON_DIR-2 \
--testnet-dir $TESTNET_DIR \
--dummy-eth1 \
--http \
--http-port 6052 \
--boot-nodes $(cat $BEACON_DIR/beacon/network/enr.dat)

View File

@@ -4,12 +4,8 @@
# Produces a testnet specification and a genesis state where the genesis time
# is now.
#
# Optionally, supply an integer as the first argument to override the default
# validator count of 1024.
#
TESTNET_DIR=~/.lighthouse/local-testnet/testnet
VALIDATOR_COUNT=${1:-1024}
source ./vars.env
lcli \
--spec mainnet \
@@ -19,7 +15,16 @@ lcli \
--min-genesis-active-validator-count $VALIDATOR_COUNT \
--force
echo Created tesnet directory at $TESTNET_DIR
echo Specification generated at $TESTNET_DIR.
echo "Generating $VALIDATOR_COUNT validators concurrently... (this may take a while)"
lcli \
insecure-validators \
--count $VALIDATOR_COUNT \
--validators-dir $VALIDATORS_DIR \
--secrets-dir $SECRETS_DIR
echo Validators generated at $VALIDATORS_DIR with keystore passwords at $SECRETS_DIR.
echo "Building genesis state... (this might take a while)"
lcli \
@@ -29,5 +34,3 @@ lcli \
$VALIDATOR_COUNT
echo Created genesis state in $TESTNET_DIR
echo $VALIDATOR_COUNT > $TESTNET_DIR/validator_count.txt

View File

@@ -5,16 +5,14 @@
# `./local_testnet_genesis_state`.
#
TESTNET_DIR=~/.lighthouse/local-testnet/testnet
DATADIR=~/.lighthouse/local-testnet/validator
source ./vars.env
DEBUG_LEVEL=${1:-info}
exec lighthouse \
--debug-level $DEBUG_LEVEL \
vc \
--datadir $DATADIR \
--datadir $VALIDATORS_DIR \
--secrets-dir $SECRETS_DIR \
--testnet-dir $TESTNET_DIR \
testnet \
insecure \
0 \
$(cat $TESTNET_DIR/validator_count.txt)
--auto-register

View File

@@ -0,0 +1,7 @@
DATADIR=~/.lighthouse/local-testnet
TESTNET_DIR=$DATADIR/testnet
BEACON_DIR=$DATADIR/beacon
VALIDATORS_DIR=$DATADIR/validators
SECRETS_DIR=$DATADIR/secrets
VALIDATOR_COUNT=1024

View File

@@ -1,7 +0,0 @@
#!/bin/bash
#
# Removes any existing local testnet
#
rm -rf ~/.lighthouse/local-testnet