Post merge local testnets (#3807)

## Issue Addressed

N/A

## Proposed Changes

Modifies the local testnet scripts to start a network with genesis validators embedded into the genesis state. This allows us to start a local testnet without the need for deploying a deposit contract or depositing validators pre-genesis.

This also enables us to start a local test network at any fork we want without going through fork transitions. Also adds scripts to start multiple geth clients and peer them with each other and peer the geth clients with beacon nodes to start a post merge local testnet.

## Additional info

Adds a new lcli command `mnemonics-validators` that generates validator directories derived from a given mnemonic. 
Adds a new `derived-genesis-state` option to the `lcli new-testnet` command to generate a genesis state populated with validators derived from a mnemonic.
This commit is contained in:
Pawan Dhananjay
2023-05-17 05:51:54 +00:00
parent b29bb2e037
commit 91a7f51ab0
20 changed files with 2347 additions and 148 deletions

View File

@@ -1,6 +1,6 @@
#!/usr/bin/env bash
# Requires `lighthouse`, ``lcli`, `anvil`, `curl`, `jq`
# Requires `lighthouse`, `lcli`, `geth`, `bootnode`, `curl`, `jq`
BEHAVIOR=$1
@@ -15,21 +15,15 @@ exit_if_fails() {
$@
EXIT_CODE=$?
if [[ $EXIT_CODE -eq 1 ]]; then
exit 111
exit 1
fi
}
genesis_file=$2
source ./vars.env
exit_if_fails ../local_testnet/clean.sh
echo "Starting anvil"
exit_if_fails ../local_testnet/anvil_test_node.sh &> /dev/null &
ANVIL_PID=$!
# Wait for anvil to start
sleep 5
echo "Setting up local testnet"
@@ -41,28 +35,31 @@ exit_if_fails cp -R $HOME/.lighthouse/local-testnet/node_1 $HOME/.lighthouse/loc
echo "Starting bootnode"
exit_if_fails ../local_testnet/bootnode.sh &> /dev/null &
BOOT_PID=$!
exit_if_fails ../local_testnet/el_bootnode.sh &> /dev/null &
# wait for the bootnode to start
sleep 10
echo "Starting local execution nodes"
exit_if_fails ../local_testnet/geth.sh $HOME/.lighthouse/local-testnet/geth_datadir1 7000 6000 5000 $genesis_file &> geth.log &
exit_if_fails ../local_testnet/geth.sh $HOME/.lighthouse/local-testnet/geth_datadir2 7100 6100 5100 $genesis_file &> /dev/null &
exit_if_fails ../local_testnet/geth.sh $HOME/.lighthouse/local-testnet/geth_datadir3 7200 6200 5200 $genesis_file &> /dev/null &
sleep 20
echo "Starting local beacon nodes"
exit_if_fails ../local_testnet/beacon_node.sh $HOME/.lighthouse/local-testnet/node_1 9000 8000 &> /dev/null &
BEACON_PID=$!
exit_if_fails ../local_testnet/beacon_node.sh $HOME/.lighthouse/local-testnet/node_2 9100 8100 &> /dev/null &
BEACON_PID2=$!
exit_if_fails ../local_testnet/beacon_node.sh $HOME/.lighthouse/local-testnet/node_3 9200 8200 &> /dev/null &
BEACON_PID3=$!
exit_if_fails ../local_testnet/beacon_node.sh -d debug $HOME/.lighthouse/local-testnet/node_1 9000 8000 http://localhost:5000 $HOME/.lighthouse/local-testnet/geth_datadir1/geth/jwtsecret &> beacon1.log &
exit_if_fails ../local_testnet/beacon_node.sh $HOME/.lighthouse/local-testnet/node_2 9100 8100 http://localhost:5100 $HOME/.lighthouse/local-testnet/geth_datadir2/geth/jwtsecret &> /dev/null &
exit_if_fails ../local_testnet/beacon_node.sh $HOME/.lighthouse/local-testnet/node_3 9200 8200 http://localhost:5200 $HOME/.lighthouse/local-testnet/geth_datadir3/geth/jwtsecret &> /dev/null &
echo "Starting local validator clients"
exit_if_fails ../local_testnet/validator_client.sh $HOME/.lighthouse/local-testnet/node_1 http://localhost:8000 &> /dev/null &
VALIDATOR_1_PID=$!
exit_if_fails ../local_testnet/validator_client.sh $HOME/.lighthouse/local-testnet/node_2 http://localhost:8100 &> /dev/null &
VALIDATOR_2_PID=$!
exit_if_fails ../local_testnet/validator_client.sh $HOME/.lighthouse/local-testnet/node_3 http://localhost:8200 &> /dev/null &
VALIDATOR_3_PID=$!
echo "Waiting an epoch before starting the next validator client"
sleep $(( $SECONDS_PER_SLOT * 32 ))
@@ -71,7 +68,7 @@ if [[ "$BEHAVIOR" == "failure" ]]; then
echo "Starting the doppelganger validator client"
# Use same keys as keys from VC1, but connect to BN2
# Use same keys as keys from VC1 and connect to BN2
# This process should not last longer than 2 epochs
timeout $(( $SECONDS_PER_SLOT * 32 * 2 )) ../local_testnet/validator_client.sh $HOME/.lighthouse/local-testnet/node_1_doppelganger http://localhost:8100
DOPPELGANGER_EXIT=$?
@@ -79,7 +76,9 @@ if [[ "$BEHAVIOR" == "failure" ]]; then
echo "Shutting down"
# Cleanup
kill $BOOT_PID $BEACON_PID $BEACON_PID2 $BEACON_PID3 $ANVIL_PID $VALIDATOR_1_PID $VALIDATOR_2_PID $VALIDATOR_3_PID
killall geth
killall lighthouse
killall bootnode
echo "Done"
@@ -98,7 +97,6 @@ if [[ "$BEHAVIOR" == "success" ]]; then
echo "Starting the last validator client"
../local_testnet/validator_client.sh $HOME/.lighthouse/local-testnet/node_4 http://localhost:8100 &
VALIDATOR_4_PID=$!
DOPPELGANGER_FAILURE=0
# Sleep three epochs, then make sure all validators were active in epoch 2. Use
@@ -144,7 +142,10 @@ if [[ "$BEHAVIOR" == "success" ]]; then
# Cleanup
cd $PREVIOUS_DIR
kill $BOOT_PID $BEACON_PID $BEACON_PID2 $BEACON_PID3 $ANVIL_PID $VALIDATOR_1_PID $VALIDATOR_2_PID $VALIDATOR_3_PID $VALIDATOR_4_PID
killall geth
killall lighthouse
killall bootnode
echo "Done"
@@ -153,4 +154,4 @@ if [[ "$BEHAVIOR" == "success" ]]; then
fi
fi
exit 0
exit 0