Fix deneb doppelganger tests (#4124)

* Temp hack to compile

* Fix doppelganger tests

* Kill in groups instead of storing pid

* Install geth in CI

* Install geth first

* Fix eth1_block_hash

* Fix directory paths and block hash

* Fix workflow for local testnets; reset genesis.json after running script

* Disable capella and deneb forks for doppelganger tests

* oops not capella

* Spin up a spare bn for the doppelganger validator

* testing

* Revert "testing"

This reverts commit 14eb178bca5b7d27b9cd9b665b5cd2c916f50901.

* Modify beacon_node script to take trusted peers

* Set doppelganger bn as a trusted peer

* Update var

* update another

* Fix port

* Add a flag to disable peer scoring

* Disable peer scoring in local testnet bn script

* Revert trusted peers hack

* fmt

* Fix proposer boost score
This commit is contained in:
Pawan Dhananjay 2023-04-26 10:26:00 -07:00 committed by GitHub
parent a632969695
commit cbe4880490
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 921 additions and 46 deletions

View File

@ -26,7 +26,16 @@ jobs:
repo-token: ${{ secrets.GITHUB_TOKEN }} repo-token: ${{ secrets.GITHUB_TOKEN }}
- name: Install ganache - name: Install ganache
run: npm install ganache@latest --global run: npm install ganache@latest --global
- name: Install geth
run: |
sudo add-apt-repository -y ppa:ethereum/ethereum
sudo apt-get update
sudo apt-get install ethereum
if: matrix.os == 'ubuntu-22.04'
run: |
brew tap ethereum/ethereum
brew install ethereum
if: matrix.os == 'macos-12'
- name: Install GNU sed & GNU grep - name: Install GNU sed & GNU grep
run: | run: |
brew install gnu-sed grep brew install gnu-sed grep

View File

@ -260,8 +260,11 @@ jobs:
uses: arduino/setup-protoc@e52d9eb8f7b63115df1ac544a1376fdbf5a39612 uses: arduino/setup-protoc@e52d9eb8f7b63115df1ac544a1376fdbf5a39612
with: with:
repo-token: ${{ secrets.GITHUB_TOKEN }} repo-token: ${{ secrets.GITHUB_TOKEN }}
- name: Install ganache - name: Install geth
run: sudo npm install -g ganache run: |
sudo add-apt-repository -y ppa:ethereum/ethereum
sudo apt-get update
sudo apt-get install ethereum
- name: Install lighthouse and lcli - name: Install lighthouse and lcli
run: | run: |
make make
@ -269,11 +272,11 @@ jobs:
- name: Run the doppelganger protection success test script - name: Run the doppelganger protection success test script
run: | run: |
cd scripts/tests cd scripts/tests
./doppelganger_protection.sh success ./doppelganger_protection.sh success genesis.json
- name: Run the doppelganger protection failure test script - name: Run the doppelganger protection failure test script
run: | run: |
cd scripts/tests cd scripts/tests
./doppelganger_protection.sh failure ./doppelganger_protection.sh failure genesis.json
execution-engine-integration-ubuntu: execution-engine-integration-ubuntu:
name: execution-engine-integration-ubuntu name: execution-engine-integration-ubuntu
runs-on: ubuntu-latest runs-on: ubuntu-latest

View File

@ -53,6 +53,7 @@ exec $lighthouse_binary \
--datadir $data_dir \ --datadir $data_dir \
--testnet-dir $TESTNET_DIR \ --testnet-dir $TESTNET_DIR \
--enable-private-discovery \ --enable-private-discovery \
--disable-peer-scoring \
--staking \ --staking \
--enr-address 127.0.0.1 \ --enr-address 127.0.0.1 \
--enr-udp-port $network_port \ --enr-udp-port $network_port \

View File

@ -2,4 +2,4 @@ priv_key="02fd74636e96a8ffac8e7b01b0de8dea94d6bcf4989513b38cf59eb32163ff91"
source ./vars.env source ./vars.env
$BOOTNODE_BINARY --nodekeyhex $priv_key $EL_BOOTNODE_BINARY --nodekeyhex $priv_key

View File

@ -56,5 +56,7 @@ GENESIS_TIME=$(lcli pretty-ssz state_merge ~/.lighthouse/local-testnet/testnet/g
CAPELLA_TIME=$((GENESIS_TIME + (CAPELLA_FORK_EPOCH * 32 * SECONDS_PER_SLOT))) CAPELLA_TIME=$((GENESIS_TIME + (CAPELLA_FORK_EPOCH * 32 * SECONDS_PER_SLOT)))
DENEB_TIME=$((GENESIS_TIME + (DENEB_FORK_EPOCH * 32 * SECONDS_PER_SLOT))) DENEB_TIME=$((GENESIS_TIME + (DENEB_FORK_EPOCH * 32 * SECONDS_PER_SLOT)))
sed -i 's/"shanghaiTime".*$/"shanghaiTime": '"$CAPELLA_TIME"',/g' genesis.json CURR_DIR=`pwd`
sed -i 's/"shardingForkTime".*$/"shardingForkTime": '"$DENEB_TIME"',/g' genesis.json
sed -i 's/"shanghaiTime".*$/"shanghaiTime": '"$CAPELLA_TIME"',/g' $CURR_DIR/genesis.json
sed -i 's/"shardingForkTime".*$/"shardingForkTime": '"$DENEB_TIME"',/g' $CURR_DIR/genesis.json

View File

@ -1,5 +1,5 @@
GETH_BINARY=geth GETH_BINARY=geth
BOOTNODE_BINARY=bootnode EL_BOOTNODE_BINARY=bootnode
# Base directories for the validator keys and secrets # Base directories for the validator keys and secrets
DATADIR=~/.lighthouse/local-testnet DATADIR=~/.lighthouse/local-testnet

View File

@ -1,6 +1,6 @@
#!/usr/bin/env bash #!/usr/bin/env bash
# Requires `lighthouse`, ``lcli`, `ganache`, `curl`, `jq` # Requires `lighthouse`, ``lcli`, `geth`, `curl`, `jq`
BEHAVIOR=$1 BEHAVIOR=$1
@ -15,21 +15,15 @@ exit_if_fails() {
$@ $@
EXIT_CODE=$? EXIT_CODE=$?
if [[ $EXIT_CODE -eq 1 ]]; then if [[ $EXIT_CODE -eq 1 ]]; then
exit 111 exit 1
fi fi
} }
genesis_file=$2
source ./vars.env source ./vars.env
exit_if_fails ../local_testnet/clean.sh exit_if_fails ../local_testnet/clean.sh
echo "Starting ganache"
exit_if_fails ../local_testnet/ganache_test_node.sh &> /dev/null &
GANACHE_PID=$!
# Wait for ganache to start
sleep 5
echo "Setting up local testnet" echo "Setting up local testnet"
@ -41,28 +35,33 @@ exit_if_fails cp -R $HOME/.lighthouse/local-testnet/node_1 $HOME/.lighthouse/loc
echo "Starting bootnode" echo "Starting bootnode"
exit_if_fails ../local_testnet/bootnode.sh &> /dev/null & 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 # wait for the bootnode to start
sleep 10 sleep 10
echo "Starting local beacon nodes" echo "Starting local execution nodes"
exit_if_fails ../local_testnet/beacon_node.sh $HOME/.lighthouse/local-testnet/node_1 9000 8000 &> /dev/null & exit_if_fails ../local_testnet/geth.sh $HOME/.lighthouse/local-testnet/geth_datadir1 7000 6000 5000 $genesis_file &> geth.log &
BEACON_PID=$! 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/beacon_node.sh $HOME/.lighthouse/local-testnet/node_2 9100 8100 &> /dev/null & exit_if_fails ../local_testnet/geth.sh $HOME/.lighthouse/local-testnet/geth_datadir3 7200 6200 5200 $genesis_file &> /dev/null &
BEACON_PID2=$!
exit_if_fails ../local_testnet/beacon_node.sh $HOME/.lighthouse/local-testnet/node_3 9200 8200 &> /dev/null & sleep 20
BEACON_PID3=$!
# 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
exit_if_fails ../local_testnet/beacon_node.sh $HOME/.lighthouse/local-testnet/node_1 9000 8000 http://localhost:5000 $HOME/.lighthouse/local-testnet/geth_datadir1/geth/jwtsecret &> /dev/null &
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 &> beacon1.log &
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" echo "Starting local validator clients"
exit_if_fails ../local_testnet/validator_client.sh $HOME/.lighthouse/local-testnet/node_1 http://localhost:8000 &> /dev/null & 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 & 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 & 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" echo "Waiting an epoch before starting the next validator client"
sleep $(( $SECONDS_PER_SLOT * 32 )) sleep $(( $SECONDS_PER_SLOT * 32 ))
@ -71,7 +70,7 @@ if [[ "$BEHAVIOR" == "failure" ]]; then
echo "Starting the doppelganger validator client" 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 # 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 timeout $(( $SECONDS_PER_SLOT * 32 * 2 )) ../local_testnet/validator_client.sh $HOME/.lighthouse/local-testnet/node_1_doppelganger http://localhost:8100
DOPPELGANGER_EXIT=$? DOPPELGANGER_EXIT=$?
@ -79,7 +78,9 @@ if [[ "$BEHAVIOR" == "failure" ]]; then
echo "Shutting down" echo "Shutting down"
# Cleanup # Cleanup
kill $BOOT_PID $BEACON_PID $BEACON_PID2 $BEACON_PID3 $GANACHE_PID $VALIDATOR_1_PID $VALIDATOR_2_PID $VALIDATOR_3_PID killall geth
killall lighthouse
killall bootnode
echo "Done" echo "Done"
@ -98,7 +99,6 @@ if [[ "$BEHAVIOR" == "success" ]]; then
echo "Starting the last validator client" echo "Starting the last validator client"
../local_testnet/validator_client.sh $HOME/.lighthouse/local-testnet/node_4 http://localhost:8100 & ../local_testnet/validator_client.sh $HOME/.lighthouse/local-testnet/node_4 http://localhost:8100 &
VALIDATOR_4_PID=$!
DOPPELGANGER_FAILURE=0 DOPPELGANGER_FAILURE=0
# Sleep three epochs, then make sure all validators were active in epoch 2. Use # Sleep three epochs, then make sure all validators were active in epoch 2. Use
@ -144,7 +144,10 @@ if [[ "$BEHAVIOR" == "success" ]]; then
# Cleanup # Cleanup
cd $PREVIOUS_DIR cd $PREVIOUS_DIR
kill $BOOT_PID $BEACON_PID $BEACON_PID2 $BEACON_PID3 $GANACHE_PID $VALIDATOR_1_PID $VALIDATOR_2_PID $VALIDATOR_3_PID $VALIDATOR_4_PID
killall geth
killall lighthouse
killall bootnode
echo "Done" echo "Done"

855
scripts/tests/genesis.json Normal file

File diff suppressed because one or more lines are too long

View File

@ -1,17 +1,23 @@
# Path to the geth binary
GETH_BINARY=geth
EL_BOOTNODE_BINARY=bootnode
# Base directories for the validator keys and secrets # Base directories for the validator keys and secrets
DATADIR=~/.lighthouse/local-testnet DATADIR=~/.lighthouse/local-testnet
# Directory for the eth2 config # Directory for the eth2 config
TESTNET_DIR=$DATADIR/testnet TESTNET_DIR=$DATADIR/testnet
# Mnemonic for the ganache test network EL_BOOTNODE_ENODE="enode://51ea9bb34d31efc3491a842ed13b8cab70e753af108526b57916d716978b380ed713f4336a80cdb85ec2a115d5a8c0ae9f3247bed3c84d3cb025c6bab311062c@127.0.0.1:0?discport=30301"
ETH1_NETWORK_MNEMONIC="vast thought differ pull jewel broom cook wrist tribe word before omit"
# Hardcoded deposit contract based on ETH1_NETWORK_MNEMONIC # Hardcoded deposit contract
DEPOSIT_CONTRACT_ADDRESS=8c594691c0e592ffa21f153a16ae41db5befcaaa DEPOSIT_CONTRACT_ADDRESS=4242424242424242424242424242424242424242
GENESIS_FORK_VERSION=0x42424242 GENESIS_FORK_VERSION=0x42424242
# Block hash generated from genesis.json in directory
ETH1_BLOCK_HASH=4c2221e15760fd06c8c7a5202258c67e3d9e4aedf6db3a886ce9dc36938ad8d0
VALIDATOR_COUNT=80 VALIDATOR_COUNT=80
GENESIS_VALIDATOR_COUNT=80 GENESIS_VALIDATOR_COUNT=80
@ -33,11 +39,13 @@ BOOTNODE_PORT=4242
CHAIN_ID=4242 CHAIN_ID=4242
# Hard fork configuration # Hard fork configuration
ALTAIR_FORK_EPOCH=18446744073709551615 ALTAIR_FORK_EPOCH=0
BELLATRIX_FORK_EPOCH=18446744073709551615 BELLATRIX_FORK_EPOCH=0
CAPELLA_FORK_EPOCH=18446744073709551615 CAPELLA_FORK_EPOCH=1
DENEB_FORK_EPOCH=18446744073709551615 DENEB_FORK_EPOCH=18446744073709551615
TTD=0
# Spec version (mainnet or minimal) # Spec version (mainnet or minimal)
SPEC_PRESET=mainnet SPEC_PRESET=mainnet
@ -52,9 +60,3 @@ PROPOSER_SCORE_BOOST=40
# Enable doppelganger detection # Enable doppelganger detection
VC_ARGS=" --enable-doppelganger-protection " VC_ARGS=" --enable-doppelganger-protection "
# Using value of DEFAULT_TERMINAL_DIFFICULTY.
TTD=6400
# Using value of DEFAULT_ETH1_BLOCK_HASH.
ETH1_BLOCK_HASH="0x4242424242424242424242424242424242424242424242424242424242424242"