mirror of
https://github.com/sigp/lighthouse.git
synced 2026-03-03 00:31:50 +00:00
Merge branch 'unstable' into deneb-free-blobs
# Conflicts: # .github/workflows/docker.yml # .github/workflows/local-testnet.yml # .github/workflows/test-suite.yml # Cargo.lock # Cargo.toml # beacon_node/beacon_chain/src/beacon_chain.rs # beacon_node/beacon_chain/src/builder.rs # beacon_node/beacon_chain/src/test_utils.rs # beacon_node/execution_layer/src/engine_api/json_structures.rs # beacon_node/network/src/beacon_processor/mod.rs # beacon_node/network/src/beacon_processor/worker/gossip_methods.rs # beacon_node/network/src/sync/backfill_sync/mod.rs # beacon_node/store/src/config.rs # beacon_node/store/src/hot_cold_store.rs # common/eth2_network_config/Cargo.toml # consensus/ssz/src/decode/impls.rs # consensus/ssz_derive/src/lib.rs # consensus/ssz_derive/tests/tests.rs # consensus/ssz_types/src/serde_utils/mod.rs # consensus/tree_hash/src/impls.rs # consensus/tree_hash/src/lib.rs # consensus/types/Cargo.toml # consensus/types/src/beacon_state.rs # consensus/types/src/chain_spec.rs # consensus/types/src/eth_spec.rs # consensus/types/src/fork_name.rs # lcli/Cargo.toml # lcli/src/main.rs # lcli/src/new_testnet.rs # scripts/local_testnet/el_bootnode.sh # scripts/local_testnet/genesis.json # scripts/local_testnet/geth.sh # scripts/local_testnet/setup.sh # scripts/local_testnet/start_local_testnet.sh # scripts/local_testnet/vars.env # scripts/tests/doppelganger_protection.sh # scripts/tests/genesis.json # scripts/tests/vars.env # testing/ef_tests/Cargo.toml # validator_client/src/block_service.rs
This commit is contained in:
@@ -1,11 +1,16 @@
|
||||
# Simple Local Testnet
|
||||
|
||||
These scripts allow for running a small local testnet with multiple beacon nodes and validator clients.
|
||||
These scripts allow for running a small local testnet with multiple beacon nodes and validator clients and a geth execution client.
|
||||
This setup can be useful for testing and development.
|
||||
|
||||
## Requirements
|
||||
|
||||
The scripts require `lcli` and `lighthouse` to be installed on `PATH`. From the
|
||||
The scripts require `lcli`, `lighthouse`, `geth`, `bootnode` to be installed on `PATH`.
|
||||
|
||||
|
||||
MacOS users need to install GNU `sed` and GNU `grep`, and add them both to `PATH` as well.
|
||||
|
||||
From the
|
||||
root of this repository, run:
|
||||
|
||||
```bash
|
||||
@@ -17,17 +22,23 @@ make install-lcli
|
||||
|
||||
Modify `vars.env` as desired.
|
||||
|
||||
Start a local eth1 ganache server plus boot node along with `BN_COUNT`
|
||||
number of beacon nodes and `VC_COUNT` validator clients.
|
||||
The testnet starts with a post-merge genesis state.
|
||||
Start a consensus layer and execution layer boot node along with `BN_COUNT`
|
||||
number of beacon nodes each connected to a geth execution client and `VC_COUNT` validator clients.
|
||||
|
||||
The `start_local_testnet.sh` script takes four options `-v VC_COUNT`, `-d DEBUG_LEVEL`, `-p` to enable builder proposals and `-h` for help. It also takes a mandatory `GENESIS_FILE` for initialising geth's state.
|
||||
A sample `genesis.json` is provided in this directory.
|
||||
|
||||
The `ETH1_BLOCK_HASH` environment variable is set to the block_hash of the genesis execution layer block which depends on the contents of `genesis.json`. Users of these scripts need to ensure that the `ETH1_BLOCK_HASH` variable is updated if genesis file is modified.
|
||||
|
||||
The `start_local_testnet.sh` script takes four options `-v VC_COUNT`, `-d DEBUG_LEVEL`, `-p` to enable builder proposals and `-h` for help.
|
||||
The options may be in any order or absent in which case they take the default value specified.
|
||||
- VC_COUNT: the number of validator clients to create, default: `BN_COUNT`
|
||||
- DEBUG_LEVEL: one of { error, warn, info, debug, trace }, default: `info`
|
||||
|
||||
|
||||
|
||||
```bash
|
||||
./start_local_testnet.sh
|
||||
./start_local_testnet.sh genesis.json
|
||||
```
|
||||
|
||||
## Stopping the testnet
|
||||
@@ -41,31 +52,38 @@ This is not necessary before `start_local_testnet.sh` as it invokes `stop_local_
|
||||
|
||||
These scripts are used by ./start_local_testnet.sh and may be used to manually
|
||||
|
||||
Start a local eth1 ganache server
|
||||
```bash
|
||||
./ganache_test_node.sh
|
||||
```
|
||||
|
||||
Assuming you are happy with the configuration in `vars.env`, deploy the deposit contract, make deposits,
|
||||
create the testnet directory, genesis state and validator keys with:
|
||||
Assuming you are happy with the configuration in `vars.env`,
|
||||
create the testnet directory, genesis state with embedded validators and validator keys with:
|
||||
|
||||
```bash
|
||||
./setup.sh
|
||||
```
|
||||
|
||||
Generate bootnode enr and start a discv5 bootnode so that multiple beacon nodes can find each other
|
||||
Note: The generated genesis validators are embedded into the genesis state as genesis validators and hence do not require manual deposits to activate.
|
||||
|
||||
Generate bootnode enr and start an EL and CL bootnode so that multiple nodes can find each other
|
||||
```bash
|
||||
./bootnode.sh
|
||||
./el_bootnode.sh
|
||||
```
|
||||
|
||||
Start a geth node:
|
||||
```bash
|
||||
./geth.sh <DATADIR> <NETWORK-PORT> <HTTP-PORT> <AUTH-HTTP-PORT> <GENESIS_FILE>
|
||||
```
|
||||
e.g.
|
||||
```bash
|
||||
./geth.sh $HOME/.lighthouse/local-testnet/geth_1 5000 6000 7000 genesis.json
|
||||
```
|
||||
|
||||
Start a beacon node:
|
||||
|
||||
```bash
|
||||
./beacon_node.sh <DATADIR> <NETWORK-PORT> <HTTP-PORT> <OPTIONAL-DEBUG-LEVEL>
|
||||
./beacon_node.sh <DATADIR> <NETWORK-PORT> <HTTP-PORT> <EXECUTION-ENDPOINT> <EXECUTION-JWT-PATH> <OPTIONAL-DEBUG-LEVEL>
|
||||
```
|
||||
e.g.
|
||||
```bash
|
||||
./beacon_node.sh $HOME/.lighthouse/local-testnet/node_1 9000 8000
|
||||
./beacon_node.sh $HOME/.lighthouse/local-testnet/node_1 9000 8000 http://localhost:6000 ~/.lighthouse/local-testnet/geth_1/geth/jwtsecret
|
||||
```
|
||||
|
||||
In a new terminal, start the validator client which will attach to the first
|
||||
|
||||
14
scripts/local_testnet/anvil_test_node.sh
Executable file
14
scripts/local_testnet/anvil_test_node.sh
Executable file
@@ -0,0 +1,14 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
set -Eeuo pipefail
|
||||
|
||||
source ./vars.env
|
||||
|
||||
exec anvil \
|
||||
--balance 1000000000 \
|
||||
--gas-limit 1000000000 \
|
||||
--accounts 10 \
|
||||
--mnemonic "$ETH1_NETWORK_MNEMONIC" \
|
||||
--block-time $SECONDS_PER_ETH1_BLOCK \
|
||||
--port 8545 \
|
||||
--chain-id "$CHAIN_ID"
|
||||
@@ -1,5 +1,3 @@
|
||||
priv_key="02fd74636e96a8ffac8e7b01b0de8dea94d6bcf4989513b38cf59eb32163ff91"
|
||||
|
||||
source ./vars.env
|
||||
|
||||
$EL_BOOTNODE_BINARY --nodekeyhex $priv_key
|
||||
@@ -1,14 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
set -Eeuo pipefail
|
||||
|
||||
source ./vars.env
|
||||
|
||||
exec ganache \
|
||||
--defaultBalanceEther 1000000000 \
|
||||
--gasLimit 1000000000 \
|
||||
--accounts 10 \
|
||||
--mnemonic "$ETH1_NETWORK_MNEMONIC" \
|
||||
--port 8545 \
|
||||
--blockTime $SECONDS_PER_ETH1_BLOCK \
|
||||
--chain.chainId "$CHAIN_ID"
|
||||
@@ -20,6 +20,12 @@
|
||||
"0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b": {
|
||||
"balance": "0x6d6172697573766477000000"
|
||||
},
|
||||
"0x7b8C3a386C0eea54693fFB0DA17373ffC9228139": {
|
||||
"balance": "10000000000000000000000000"
|
||||
},
|
||||
"0xdA2DD7560DB7e212B945fC72cEB54B7D8C886D77": {
|
||||
"balance": "10000000000000000000000000"
|
||||
},
|
||||
"0x0000000000000000000000000000000000000000": {
|
||||
"balance": "1"
|
||||
},
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
#
|
||||
# Deploys the deposit contract and makes deposits for $VALIDATOR_COUNT insecure deterministic validators.
|
||||
# Produces a testnet specification and a genesis state where the genesis time
|
||||
# is now + $GENESIS_DELAY.
|
||||
#
|
||||
@@ -51,12 +50,3 @@ lcli \
|
||||
--node-count $BN_COUNT
|
||||
|
||||
echo Validators generated with keystore passwords at $DATADIR.
|
||||
|
||||
GENESIS_TIME=$(lcli pretty-ssz state_merge ~/.lighthouse/local-testnet/testnet/genesis.ssz | jq | grep -Po 'genesis_time": "\K.*\d')
|
||||
CAPELLA_TIME=$((GENESIS_TIME + (CAPELLA_FORK_EPOCH * 32 * SECONDS_PER_SLOT)))
|
||||
DENEB_TIME=$((GENESIS_TIME + (DENEB_FORK_EPOCH * 32 * SECONDS_PER_SLOT)))
|
||||
|
||||
CURR_DIR=`pwd`
|
||||
|
||||
sed -i 's/"shanghaiTime".*$/"shanghaiTime": '"$CAPELLA_TIME"',/g' $CURR_DIR/genesis.json
|
||||
sed -i 's/"shardingForkTime".*$/"shardingForkTime": '"$DENEB_TIME"',/g' $CURR_DIR/genesis.json
|
||||
|
||||
@@ -102,6 +102,17 @@ execute_command_add_PID() {
|
||||
echo "executing: ./setup.sh >> $LOG_DIR/setup.log"
|
||||
./setup.sh >> $LOG_DIR/setup.log 2>&1
|
||||
|
||||
# Update future hardforks time in the EL genesis file based on the CL genesis time
|
||||
GENESIS_TIME=$(lcli pretty-ssz state_merge $TESTNET_DIR/genesis.ssz | jq | grep -Po 'genesis_time": "\K.*\d')
|
||||
echo $GENESIS_TIME
|
||||
CAPELLA_TIME=$((GENESIS_TIME + (CAPELLA_FORK_EPOCH * 32 * SECONDS_PER_SLOT)))
|
||||
echo $CAPELLA_TIME
|
||||
sed -i 's/"shanghaiTime".*$/"shanghaiTime": '"$CAPELLA_TIME"',/g' $genesis_file
|
||||
DENEB_TIME=$((GENESIS_TIME + (DENEB_FORK_EPOCH * 32 * SECONDS_PER_SLOT)))
|
||||
echo $DENEB_TIME
|
||||
sed -i 's/"shardingForkTime".*$/"shardingForkTime": '"$DENEB_TIME"',/g' $genesis_file
|
||||
cat $genesis_file
|
||||
|
||||
# Delay to let boot_enr.yaml to be created
|
||||
execute_command_add_PID bootnode.log ./bootnode.sh
|
||||
sleeping 3
|
||||
@@ -109,6 +120,9 @@ sleeping 3
|
||||
execute_command_add_PID el_bootnode.log ./el_bootnode.sh
|
||||
sleeping 3
|
||||
|
||||
execute_command_add_PID el_bootnode.log ./el_bootnode.sh
|
||||
sleeping 1
|
||||
|
||||
# Start beacon nodes
|
||||
BN_udp_tcp_base=9000
|
||||
BN_http_port_base=8000
|
||||
@@ -126,8 +140,8 @@ done
|
||||
sleeping 20
|
||||
|
||||
# Reset the `genesis.json` config file fork times.
|
||||
sed -i 's/"shanghaiTime".*$/"shanghaiTime": 0,/g' genesis.json
|
||||
sed -i 's/"shardingForkTime".*$/"shardingForkTime": 0,/g' genesis.json
|
||||
sed -i 's/"shanghaiTime".*$/"shanghaiTime": 0,/g' $genesis_file
|
||||
sed -i 's/"shardingForkTime".*$/"shardingForkTime": 0,/g' $genesis_file
|
||||
|
||||
for (( bn=1; bn<=$BN_COUNT; bn++ )); do
|
||||
secret=$DATADIR/geth_datadir$bn/geth/jwtsecret
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
# Path to the geth binary
|
||||
GETH_BINARY=geth
|
||||
EL_BOOTNODE_BINARY=bootnode
|
||||
|
||||
@@ -7,6 +8,9 @@ DATADIR=~/.lighthouse/local-testnet
|
||||
# Directory for the eth2 config
|
||||
TESTNET_DIR=$DATADIR/testnet
|
||||
|
||||
# Mnemonic for generating validator keys
|
||||
MNEMONIC_PHRASE="vast thought differ pull jewel broom cook wrist tribe word before omit"
|
||||
|
||||
EL_BOOTNODE_ENODE="enode://51ea9bb34d31efc3491a842ed13b8cab70e753af108526b57916d716978b380ed713f4336a80cdb85ec2a115d5a8c0ae9f3247bed3c84d3cb025c6bab311062c@127.0.0.1:0?discport=30301"
|
||||
|
||||
# Hardcoded deposit contract
|
||||
@@ -15,6 +19,7 @@ DEPOSIT_CONTRACT_ADDRESS=4242424242424242424242424242424242424242
|
||||
GENESIS_FORK_VERSION=0x42424242
|
||||
|
||||
# Block hash generated from genesis.json in directory
|
||||
# FIXME (JC) update block hash
|
||||
ETH1_BLOCK_HASH=4c2221e15760fd06c8c7a5202258c67e3d9e4aedf6db3a886ce9dc36938ad8d0
|
||||
|
||||
VALIDATOR_COUNT=80
|
||||
|
||||
Reference in New Issue
Block a user