From 0b92b204a8e791dc77f02d811d92887319479f90 Mon Sep 17 00:00:00 2001 From: Pawan Dhananjay Date: Thu, 23 Mar 2023 19:45:03 +0530 Subject: [PATCH] Fix doppelganger tests --- .github/workflows/test-suite.yml | 6 ++-- scripts/local_testnet/el_bootnode.sh | 2 +- scripts/local_testnet/vars.env | 2 +- scripts/tests/doppelganger_protection.sh | 36 +++++++++++++++--------- scripts/tests/vars.env | 23 +++++++++------ 5 files changed, 41 insertions(+), 28 deletions(-) diff --git a/.github/workflows/test-suite.yml b/.github/workflows/test-suite.yml index 54ee974c7f..c74b7455a1 100644 --- a/.github/workflows/test-suite.yml +++ b/.github/workflows/test-suite.yml @@ -260,8 +260,6 @@ jobs: uses: arduino/setup-protoc@e52d9eb8f7b63115df1ac544a1376fdbf5a39612 with: repo-token: ${{ secrets.GITHUB_TOKEN }} - - name: Install ganache - run: sudo npm install -g ganache - name: Install lighthouse and lcli run: | make @@ -269,11 +267,11 @@ jobs: - name: Run the doppelganger protection success test script run: | cd scripts/tests - ./doppelganger_protection.sh success + ./doppelganger_protection.sh success ../local_testnet/genesis.json - name: Run the doppelganger protection failure test script run: | cd scripts/tests - ./doppelganger_protection.sh failure + ./doppelganger_protection.sh failure ../local_testnet/genesis.json execution-engine-integration-ubuntu: name: execution-engine-integration-ubuntu runs-on: ubuntu-latest diff --git a/scripts/local_testnet/el_bootnode.sh b/scripts/local_testnet/el_bootnode.sh index 1b8834b890..ee0b43b82a 100755 --- a/scripts/local_testnet/el_bootnode.sh +++ b/scripts/local_testnet/el_bootnode.sh @@ -2,4 +2,4 @@ priv_key="02fd74636e96a8ffac8e7b01b0de8dea94d6bcf4989513b38cf59eb32163ff91" source ./vars.env -$BOOTNODE_BINARY --nodekeyhex $priv_key \ No newline at end of file +$EL_BOOTNODE_BINARY --nodekeyhex $priv_key \ No newline at end of file diff --git a/scripts/local_testnet/vars.env b/scripts/local_testnet/vars.env index dcdf671e3f..89bad6184d 100644 --- a/scripts/local_testnet/vars.env +++ b/scripts/local_testnet/vars.env @@ -1,5 +1,5 @@ GETH_BINARY=geth -BOOTNODE_BINARY=bootnode +EL_BOOTNODE_BINARY=bootnode # Base directories for the validator keys and secrets DATADIR=~/.lighthouse/local-testnet diff --git a/scripts/tests/doppelganger_protection.sh b/scripts/tests/doppelganger_protection.sh index 95dfff5696..c719abf16d 100755 --- a/scripts/tests/doppelganger_protection.sh +++ b/scripts/tests/doppelganger_protection.sh @@ -1,6 +1,6 @@ #!/usr/bin/env bash -# Requires `lighthouse`, ``lcli`, `ganache`, `curl`, `jq` +# Requires `lighthouse`, ``lcli`, `geth`, `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 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" @@ -43,16 +37,30 @@ echo "Starting bootnode" exit_if_fails ../local_testnet/bootnode.sh &> /dev/null & BOOT_PID=$! +exit_if_fails ../local_testnet/el_bootnode.sh &> /dev/null & +EL_BOOT_PID=$! + # 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 & +EL_PID=$! +exit_if_fails ../local_testnet/geth.sh $HOME/.lighthouse/local-testnet/geth_datadir2 7100 6100 5100 $genesis_file &> /dev/null & +EL_PID2=$! +exit_if_fails ../local_testnet/geth.sh $HOME/.lighthouse/local-testnet/geth_datadir3 7200 6200 5200 $genesis_file &> /dev/null & +EL_PID3=$! + +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 & +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 &> beacon.log & BEACON_PID=$! -exit_if_fails ../local_testnet/beacon_node.sh $HOME/.lighthouse/local-testnet/node_2 9100 8100 &> /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 &> /dev/null & BEACON_PID2=$! -exit_if_fails ../local_testnet/beacon_node.sh $HOME/.lighthouse/local-testnet/node_3 9200 8200 &> /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 & BEACON_PID3=$! echo "Starting local validator clients" @@ -79,7 +87,7 @@ if [[ "$BEHAVIOR" == "failure" ]]; then echo "Shutting down" # Cleanup - kill $BOOT_PID $BEACON_PID $BEACON_PID2 $BEACON_PID3 $GANACHE_PID $VALIDATOR_1_PID $VALIDATOR_2_PID $VALIDATOR_3_PID + kill $BOOT_PID $BEACON_PID $BEACON_PID2 $BEACON_PID3 $EL_BOOT_PID $EL_PID $EL_PID2 $EL_PID3 $VALIDATOR_1_PID $VALIDATOR_2_PID $VALIDATOR_3_PID echo "Done" @@ -144,7 +152,7 @@ if [[ "$BEHAVIOR" == "success" ]]; then # Cleanup 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 + kill $BOOT_PID $BEACON_PID $BEACON_PID2 $BEACON_PID3 $EL_BOOT_PID $EL_PID $EL_PID2 $EL_PID3 $VALIDATOR_1_PID $VALIDATOR_2_PID $VALIDATOR_3_PID $VALIDATOR_4_PID echo "Done" diff --git a/scripts/tests/vars.env b/scripts/tests/vars.env index e7a688769a..2f4b6930b6 100644 --- a/scripts/tests/vars.env +++ b/scripts/tests/vars.env @@ -1,17 +1,23 @@ +# Path to the geth binary +GETH_BINARY=geth +EL_BOOTNODE_BINARY=bootnode + # Base directories for the validator keys and secrets DATADIR=~/.lighthouse/local-testnet # Directory for the eth2 config TESTNET_DIR=$DATADIR/testnet -# Mnemonic for the ganache test network -ETH1_NETWORK_MNEMONIC="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 based on ETH1_NETWORK_MNEMONIC -DEPOSIT_CONTRACT_ADDRESS=8c594691c0e592ffa21f153a16ae41db5befcaaa +# Hardcoded deposit contract +DEPOSIT_CONTRACT_ADDRESS=4242424242424242424242424242424242424242 GENESIS_FORK_VERSION=0x42424242 +# Block hash generated from genesis.json in directory +ETH1_BLOCK_HASH=16ef16304456fdacdeb272bd70207021031db355ed6c5e44ebd34c1ab757e221 + VALIDATOR_COUNT=80 GENESIS_VALIDATOR_COUNT=80 @@ -33,11 +39,14 @@ BOOTNODE_PORT=4242 CHAIN_ID=4242 # Hard fork configuration -ALTAIR_FORK_EPOCH=18446744073709551615 -BELLATRIX_FORK_EPOCH=18446744073709551615 +ALTAIR_FORK_EPOCH=0 +BELLATRIX_FORK_EPOCH=0 +CAPELLA_FORK_EPOCH=18446744073709551615 CAPELLA_FORK_EPOCH=18446744073709551615 EIP4844_FORK_EPOCH=18446744073709551615 +TTD=0 + # Spec version (mainnet or minimal) SPEC_PRESET=mainnet @@ -53,8 +62,6 @@ PROPOSER_SCORE_BOOST=40 # Enable doppelganger detection VC_ARGS=" --enable-doppelganger-protection " -# Using value of DEFAULT_TERMINAL_DIFFICULTY. -TTD=6400 # Using value of DEFAULT_ETH1_BLOCK_HASH. ETH1_BLOCK_HASH="0x4242424242424242424242424242424242424242424242424242424242424242"