mirror of
https://github.com/sigp/lighthouse.git
synced 2026-03-03 00:31:50 +00:00
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:
79
scripts/local_testnet/README.md
Normal file
79
scripts/local_testnet/README.md
Normal 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`.
|
||||
21
scripts/local_testnet/beacon_node.sh
Executable file
21
scripts/local_testnet/beacon_node.sh
Executable file
@@ -0,0 +1,21 @@
|
||||
#!/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 \
|
||||
--testnet-dir $TESTNET_DIR \
|
||||
--dummy-eth1 \
|
||||
--http \
|
||||
--enr-address 127.0.0.1 \
|
||||
--enr-udp-port 9000 \
|
||||
--enr-tcp-port 9000 \
|
||||
9
scripts/local_testnet/clean.sh
Executable file
9
scripts/local_testnet/clean.sh
Executable file
@@ -0,0 +1,9 @@
|
||||
#!/bin/bash
|
||||
|
||||
#
|
||||
# Deletes all files associated with the local testnet.
|
||||
#
|
||||
|
||||
source ./vars.env
|
||||
|
||||
rm -r $DATADIR
|
||||
16
scripts/local_testnet/reset_genesis_time.sh
Executable file
16
scripts/local_testnet/reset_genesis_time.sh
Executable 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)"
|
||||
20
scripts/local_testnet/second_beacon_node.sh
Executable file
20
scripts/local_testnet/second_beacon_node.sh
Executable 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)
|
||||
36
scripts/local_testnet/setup.sh
Executable file
36
scripts/local_testnet/setup.sh
Executable file
@@ -0,0 +1,36 @@
|
||||
#!/bin/bash
|
||||
|
||||
#
|
||||
# Produces a testnet specification and a genesis state where the genesis time
|
||||
# is now.
|
||||
#
|
||||
|
||||
source ./vars.env
|
||||
|
||||
lcli \
|
||||
--spec mainnet \
|
||||
new-testnet \
|
||||
--deposit-contract-address 0000000000000000000000000000000000000000 \
|
||||
--testnet-dir $TESTNET_DIR \
|
||||
--min-genesis-active-validator-count $VALIDATOR_COUNT \
|
||||
--force
|
||||
|
||||
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 \
|
||||
--spec mainnet \
|
||||
interop-genesis \
|
||||
--testnet-dir $TESTNET_DIR \
|
||||
$VALIDATOR_COUNT
|
||||
|
||||
echo Created genesis state in $TESTNET_DIR
|
||||
18
scripts/local_testnet/validator_client.sh
Executable file
18
scripts/local_testnet/validator_client.sh
Executable file
@@ -0,0 +1,18 @@
|
||||
#!/bin/bash
|
||||
|
||||
#
|
||||
# Starts a validator client based upon a genesis state created by
|
||||
# `./local_testnet_genesis_state`.
|
||||
#
|
||||
|
||||
source ./vars.env
|
||||
|
||||
DEBUG_LEVEL=${1:-info}
|
||||
|
||||
exec lighthouse \
|
||||
--debug-level $DEBUG_LEVEL \
|
||||
vc \
|
||||
--datadir $VALIDATORS_DIR \
|
||||
--secrets-dir $SECRETS_DIR \
|
||||
--testnet-dir $TESTNET_DIR \
|
||||
--auto-register
|
||||
7
scripts/local_testnet/vars.env
Normal file
7
scripts/local_testnet/vars.env
Normal 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
|
||||
Reference in New Issue
Block a user