Remove fixed IPs and separate network for fixturenet. #30

Merged
telackey merged 7 commits from telackey/netfix into main 2022-10-31 17:43:49 +00:00
13 changed files with 122 additions and 59 deletions

View File

@ -8,9 +8,6 @@ services:
environment: environment:
RUN_BOOTNODE: "true" RUN_BOOTNODE: "true"
image: cerc/fixturenet-eth-geth:local image: cerc/fixturenet-eth-geth:local
networks:
fixturenet-eth-net:
ipv4_address: 172.16.254.10
fixturenet-eth-geth-1: fixturenet-eth-geth-1:
hostname: fixturenet-eth-geth-1 hostname: fixturenet-eth-geth-1
@ -21,8 +18,6 @@ services:
- fixturenet-eth-bootnode-geth - fixturenet-eth-bootnode-geth
ports: ports:
- "8545" - "8545"
networks:
fixturenet-eth-net:
fixturenet-eth-geth-2: fixturenet-eth-geth-2:
hostname: fixturenet-eth-geth-2 hostname: fixturenet-eth-geth-2
@ -31,17 +26,12 @@ services:
image: cerc/fixturenet-eth-geth:local image: cerc/fixturenet-eth-geth:local
depends_on: depends_on:
- fixturenet-eth-bootnode-geth - fixturenet-eth-bootnode-geth
networks:
fixturenet-eth-net:
fixturenet-eth-bootnode-lighthouse: fixturenet-eth-bootnode-lighthouse:
hostname: fixturenet-eth-bootnode-lighthouse hostname: fixturenet-eth-bootnode-lighthouse
environment: environment:
RUN_BOOTNODE: "true" RUN_BOOTNODE: "true"
image: cerc/fixturenet-eth-lighthouse:local image: cerc/fixturenet-eth-lighthouse:local
networks:
fixturenet-eth-net:
ipv4_address: 172.16.254.11
fixturenet-eth-lighthouse-1: fixturenet-eth-lighthouse-1:
hostname: fixturenet-eth-lighthouse-1 hostname: fixturenet-eth-lighthouse-1
@ -57,8 +47,6 @@ services:
- fixturenet-eth-geth-1 - fixturenet-eth-geth-1
ports: ports:
- "8001" - "8001"
networks:
fixturenet-eth-net:
fixturenet-eth-lighthouse-2: fixturenet-eth-lighthouse-2:
hostname: fixturenet-eth-lighthouse-2 hostname: fixturenet-eth-lighthouse-2
@ -73,14 +61,3 @@ services:
depends_on: depends_on:
- fixturenet-eth-bootnode-lighthouse - fixturenet-eth-bootnode-lighthouse
- fixturenet-eth-geth-2 - fixturenet-eth-geth-2
networks:
fixturenet-eth-net:
networks:
# When the bootnode ENR is generated during the build, it requires a specific IP.
# The easiest way to do that is to use a private network.
fixturenet-eth-net:
driver: bridge
ipam:
config:
- subnet: 172.16.254.0/28

View File

@ -7,5 +7,4 @@ ENODE="enode://af22c29c316ad069cf48a09a4ad5cf04a251b411e45098888d114c6dd7f489a13
# JWT shared by geth and lighthouse for authentication. # JWT shared by geth and lighthouse for authentication.
JWT="0x6cdcac3501046a08e186730dd8bd136cfaf0fdc1fc955f6e15ad3068c0ff2af0" JWT="0x6cdcac3501046a08e186730dd8bd136cfaf0fdc1fc955f6e15ad3068c0ff2af0"
# Should match the definition of fixturenet-eth-net. ENR_URL="http://fixturenet-eth-bootnode-lighthouse:3000/bootnode/enr.dat"
NETRESTRICT="172.16.254.0/28"

View File

@ -1,7 +1,7 @@
FROM skylenet/ethereum-genesis-generator AS ethgen FROM skylenet/ethereum-genesis-generator AS ethgen
FROM cerc/go-ethereum:local FROM cerc/go-ethereum:local
RUN apk add --no-cache python3 py3-pip curl wget jq build-base gettext libintl openssl bash RUN apk add --no-cache python3 python3-dev py3-pip curl wget jq build-base gettext libintl openssl bash
COPY --from=ethgen /usr/local/bin/eth2-testnet-genesis /usr/local/bin/eth2-testnet-genesis COPY --from=ethgen /usr/local/bin/eth2-testnet-genesis /usr/local/bin/eth2-testnet-genesis
COPY --from=ethgen /usr/local/bin/eth2-val-tools /usr/local/bin/eth2-val-tools COPY --from=ethgen /usr/local/bin/eth2-val-tools /usr/local/bin/eth2-val-tools

View File

@ -12,6 +12,6 @@ if len(sys.argv) > 1:
with open(testnet_config_path) as stream: with open(testnet_config_path) as stream:
data = yaml.safe_load(stream) data = yaml.safe_load(stream)
for key, value in data['eth1_premine'].items(): for key, value in data['el_premine'].items():
acct = w3.eth.account.from_mnemonic(data['mnemonic'], account_path=key, passphrase='') acct = w3.eth.account.from_mnemonic(data['mnemonic'], account_path=key, passphrase='')
print("%s,%s,%s" % (key, acct.address, acct.key.hex())) print("%s,%s,%s" % (key, acct.address, acct.key.hex()))

View File

@ -1,4 +1,5 @@
#!/usr/bin/env bash #!/usr/bin/env bash
set -e
# See: https://github.com/skylenet/ethereum-genesis-generator/blob/master/entrypoint.sh # See: https://github.com/skylenet/ethereum-genesis-generator/blob/master/entrypoint.sh
@ -8,5 +9,7 @@ mkdir -p ../build/el
tmp_dir=$(mktemp -d -t ci-XXXXXXXXXX) tmp_dir=$(mktemp -d -t ci-XXXXXXXXXX)
envsubst < el-config.yaml > $tmp_dir/genesis-config.yaml envsubst < el-config.yaml > $tmp_dir/genesis-config.yaml
python3 /apps/el-gen/genesis_geth.py $tmp_dir/genesis-config.yaml > ../build/el/geth.json ttd=`cat $tmp_dir/genesis-config.yaml | grep terminal_total_difficulty | awk '{ print $2 }'`
python3 /apps/el-gen/genesis_geth.py $tmp_dir/genesis-config.yaml | jq ".config.terminalTotalDifficulty=$ttd" > ../build/el/geth.json
python3 ../accounts/mnemonic_to_csv.py $tmp_dir/genesis-config.yaml > ../build/el/accounts.csv python3 ../accounts/mnemonic_to_csv.py $tmp_dir/genesis-config.yaml > ../build/el/accounts.csv

View File

@ -1,17 +1,16 @@
mnemonic: "viable ketchup woman library opinion copy rhythm attend rose knock penalty practice photo bundle budget dentist enter round bind holiday useful arch danger lobster" mnemonic: "viable ketchup woman library opinion copy rhythm attend rose knock penalty practice photo bundle budget dentist enter round bind holiday useful arch danger lobster"
eth1_premine: el_premine:
"m/44'/60'/0'/0/0": 10000000ETH "m/44'/60'/0'/0/0": 10000000ETH
"m/44'/60'/0'/0/1": 10000000ETH "m/44'/60'/0'/0/1": 10000000ETH
"m/44'/60'/0'/0/2": 10000000ETH "m/44'/60'/0'/0/2": 10000000ETH
"m/44'/60'/0'/0/3": 10000000ETH "m/44'/60'/0'/0/3": 10000000ETH
"m/44'/60'/0'/0/4": 10000000ETH "m/44'/60'/0'/0/4": 10000000ETH
"m/44'/60'/0'/0/5": 10000000ETH "m/44'/60'/0'/0/5": 10000000ETH
eth1_premine_addrs: {} el_premine_addrs: {}
chain_id: 1212 chain_id: 1212
deposit_contract_address: "0x1212121212121212121212121212121212121212" deposit_contract_address: "0x1212121212121212121212121212121212121212"
eth1_genesis_timestamp: 0 genesis_timestamp: 0
terminal_total_difficulty: 10000000 terminal_total_difficulty: 1000
mergeForkBlock: 100
clique: clique:
enabled: false enabled: false

View File

@ -2,6 +2,7 @@
ETHERBASE=`cat /opt/testnet/build/el/accounts.csv | head -1 | cut -d',' -f2` ETHERBASE=`cat /opt/testnet/build/el/accounts.csv | head -1 | cut -d',' -f2`
NETWORK_ID=`cat /opt/testnet/el/el-config.yaml | grep 'chain_id' | awk '{ print $2 }'` NETWORK_ID=`cat /opt/testnet/el/el-config.yaml | grep 'chain_id' | awk '{ print $2 }'`
NETRESTRICT=`ip addr | grep inet | grep -v '127.0' | awk '{print $2}'`
if [ "true" == "$RUN_BOOTNODE" ]; then if [ "true" == "$RUN_BOOTNODE" ]; then
geth \ geth \
@ -29,6 +30,9 @@ else
--authrpc.jwtsecret="/opt/testnet/build/el/jwtsecret" \ --authrpc.jwtsecret="/opt/testnet/build/el/jwtsecret" \
--networkid=${NETWORK_ID} \ --networkid=${NETWORK_ID} \
--netrestrict="${NETRESTRICT}" \ --netrestrict="${NETRESTRICT}" \
--gcmode archive \
--txlookuplimit=0 \
--cache.preimages \
--syncmode=full \ --syncmode=full \
--mine \ --mine \
--miner.threads=1 \ --miner.threads=1 \

View File

@ -10,7 +10,7 @@ set -Eeuo pipefail
source ./vars.env source ./vars.env
SUBSCRIBE_ALL_SUBNETS= SUBSCRIBE_ALL_SUBNETS=
DEBUG_LEVEL=${DEBUG_LEVEL:-info} DEBUG_LEVEL=${DEBUG_LEVEL:-debug}
# Get positional arguments # Get positional arguments
data_dir=$DATADIR/node_${NODE_NUMBER} data_dir=$DATADIR/node_${NODE_NUMBER}
@ -18,9 +18,6 @@ network_port=9001
http_port=8001 http_port=8001
authrpc_port=8551 authrpc_port=8551
ENR=`cat $DATADIR/bootnode/enr.dat`
ENR_IP=`ip addr | grep 172 | awk '{print $2}' | cut -d '/' -f1`
exec lighthouse \ exec lighthouse \
--debug-level $DEBUG_LEVEL \ --debug-level $DEBUG_LEVEL \
bn \ bn \

View File

@ -13,6 +13,22 @@ DEBUG_LEVEL=${1:-info}
echo "Starting bootnode" echo "Starting bootnode"
if [ ! -f "$DATADIR/bootnode/enr.dat" ]; then
echo "Generating bootnode enr"
lcli \
generate-bootnode-enr \
--ip $ENR_IP \
--udp-port $BOOTNODE_PORT \
--tcp-port $BOOTNODE_PORT \
--genesis-fork-version $GENESIS_FORK_VERSION \
--output-dir $DATADIR/bootnode
bootnode_enr=`cat $DATADIR/bootnode/enr.dat`
echo "- $bootnode_enr" > $TESTNET_DIR/boot_enr.yaml
echo "Generated bootnode enr and written to $TESTNET_DIR/boot_enr.yaml"
fi
exec lighthouse boot_node \ exec lighthouse boot_node \
--testnet-dir $TESTNET_DIR \ --testnet-dir $TESTNET_DIR \
--port $BOOTNODE_PORT \ --port $BOOTNODE_PORT \

View File

@ -57,18 +57,3 @@ lcli \
$GENESIS_VALIDATOR_COUNT $GENESIS_VALIDATOR_COUNT
echo Created genesis state in $TESTNET_DIR echo Created genesis state in $TESTNET_DIR
echo "Generating bootnode enr"
lcli \
generate-bootnode-enr \
--ip $BOOTNODE_IP \
--udp-port $BOOTNODE_PORT \
--tcp-port $BOOTNODE_PORT \
--genesis-fork-version $GENESIS_FORK_VERSION \
--output-dir $DATADIR/bootnode
bootnode_enr=`cat $DATADIR/bootnode/enr.dat`
echo "- $bootnode_enr" > $TESTNET_DIR/boot_enr.yaml
echo "Generated bootnode enr and written to $TESTNET_DIR/boot_enr.yaml"

View File

@ -4,6 +4,8 @@ DATADIR=${DATADIR:-../build/cl}
# Directory for the eth2 config # Directory for the eth2 config
TESTNET_DIR=${TESTNET_DIR:-$DATADIR/testnet} TESTNET_DIR=${TESTNET_DIR:-$DATADIR/testnet}
JWTSECRET=${JWTSECRET:-$DATADIR/jwtsecret} JWTSECRET=${JWTSECRET:-$DATADIR/jwtsecret}
ENR=${ENR:="SET_AT_RUNTIME"}
ENR_IP=`ip addr | grep inet | grep -v '127.0.0.1' | sort | head -1 | awk '{print $2}' | cut -d '/' -f1`
GENESIS_FORK_VERSION=${GENESIS_FORK_VERSION:-0x12121212} GENESIS_FORK_VERSION=${GENESIS_FORK_VERSION:-0x12121212}
@ -22,12 +24,11 @@ VC_COUNT=${VC_COUNT:-$BN_COUNT}
GENESIS_DELAY=${GENESIS_DELAY:-0} GENESIS_DELAY=${GENESIS_DELAY:-0}
# Port for P2P communication with bootnode # Port for P2P communication with bootnode
BOOTNODE_IP=${BOOTNODE_IP:-172.16.254.11}
BOOTNODE_PORT=${BOOTNODE_PORT:-4242} BOOTNODE_PORT=${BOOTNODE_PORT:-4242}
# Hard fork configuration # Hard fork configuration
ALTAIR_FORK_EPOCH=${ALTAIR_FORK_EPOCH:-1} ALTAIR_FORK_EPOCH=${ALTAIR_FORK_EPOCH:-0}
MERGE_FORK_EPOCH=${MERGE_FORK_EPOCH:-2} MERGE_FORK_EPOCH=${MERGE_FORK_EPOCH:-0}
# Spec version (mainnet or minimal) # Spec version (mainnet or minimal)
SPEC_PRESET=${SPEC_PRESET:-mainnet} SPEC_PRESET=${SPEC_PRESET:-mainnet}
@ -43,10 +44,11 @@ VC_ARGS=${VC_ARGS:-""}
EXECUTION_ENDPOINT=${EXECUTION_ENDPOINT:-http://localhost:8551} EXECUTION_ENDPOINT=${EXECUTION_ENDPOINT:-http://localhost:8551}
ETH1_GENESIS_JSON=${ETH1_GENESIS_JSON:-"../build/el/geth.json"}
ETH1_CONFIG_YAML=${ETH1_CONFIG_YAML:-"../el/el-config.yaml"} ETH1_CONFIG_YAML=${ETH1_CONFIG_YAML:-"../el/el-config.yaml"}
ETH1_CHAIN_ID=${ETH1_CHAIN_ID:-`cat $ETH1_CONFIG_YAML | grep 'chain_id' | awk '{ print $2 }'`} ETH1_CHAIN_ID=${ETH1_CHAIN_ID:-`cat $ETH1_GENESIS_JSON | jq -r '.config.chainId'`}
ETH1_TTD=${ETH1_TTD:-`cat $ETH1_CONFIG_YAML | grep 'terminal_total_difficulty' | awk '{ print $2 }'`} ETH1_TTD=${ETH1_TTD:-`cat $ETH1_GENESIS_JSON | jq -r '.config.terminalTotalDifficulty'`}
ETH1_DEPOSIT_CONTRACT_ADDRESS=${ETH1_DEPOSIT_CONTRACT_ADDRESS:-`cat $ETH1_CONFIG_YAML | grep 'deposit_contract_address' | awk '{ print $2 }' | sed 's/"//g'`} ETH1_DEPOSIT_CONTRACT_ADDRESS=${ETH1_DEPOSIT_CONTRACT_ADDRESS:-`cat $ETH1_CONFIG_YAML | grep 'deposit_contract_address' | awk '{ print $2 }' | sed 's/"//g'`}
ETH1_DEPOSIT_CONTRACT_BLOCK=${ETH1_DEPOSIT_CONTRACT_BLOCK:-0x0} ETH1_DEPOSIT_CONTRACT_BLOCK=${ETH1_DEPOSIT_CONTRACT_BLOCK:-0x0}
SUGGESTED_FEE_RECIPIENT=`cat ../build/el/accounts.csv | head -1 | cut -d',' -f2` SUGGESTED_FEE_RECIPIENT=`cat ../build/el/accounts.csv | head -1 | cut -d',' -f2`

View File

@ -1,18 +1,22 @@
#!/bin/bash #!/bin/bash
if [ "true" == "$RUN_BOOTNODE" ]; then if [ "true" == "$RUN_BOOTNODE" ]; then
cd /opt/testnet/build/cl
python3 -m http.server 3000 &
cd /opt/testnet/cl cd /opt/testnet/cl
./bootnode.sh 2>&1 | tee /var/log/lighthouse_bootnode.log ./bootnode.sh 2>&1 | tee /var/log/lighthouse_bootnode.log
else else
while [ 1 -eq 1 ]; do while [ 1 -eq 1 ]; do
echo "Waiting on DAG ..." echo "Waiting on geth ..."
sleep 5 sleep 5
result=`wget --no-check-certificate --quiet \ result=`wget --no-check-certificate --quiet \
-O - \ -O - \
--method POST \ --method POST \
--timeout=0 \ --timeout=0 \
--header 'Content-Type: application/json' \ --header 'Content-Type: application/json' \
--body-data '{ "jsonrpc": "2.0", "id": 1, "method": "eth_getBlockByNumber", "params": ["0x3", false] }' "${ETH1_ENDPOINT:-localhost:8545}" | jq -r '.result'` --body-data '{ "jsonrpc": "2.0", "id": 1, "method": "eth_blockNumber", "params": [] }' "${ETH1_ENDPOINT:-localhost:8545}" | jq -r '.result'`
if [ ! -z "$result" ] && [ "null" != "$result" ]; then if [ ! -z "$result" ] && [ "null" != "$result" ]; then
break break
fi fi
@ -34,6 +38,18 @@ else
done done
fi fi
if [ ! -z "$ENR_URL" ]; then
while [ 1 -eq 1 ]; do
echo "Waiting on ENR for boot node..."
sleep 5
result=`wget --no-check-certificate --quiet -O - --timeout=0 $ENR_URL`
if [ ! -z "$result" ]; then
export ENR="$result"
break;
fi
done
fi
export JWTSECRET="/opt/testnet/build/cl/jwtsecret" export JWTSECRET="/opt/testnet/build/cl/jwtsecret"
echo -n "$JWT" > $JWTSECRET echo -n "$JWT" > $JWTSECRET

View File

@ -0,0 +1,65 @@
#!/bin/bash
STATUSES=("geth to generate DAG" "beacon phase0" "beacon altair" "beacon bellatrix pre-merge" "beacon bellatrix merge")
STATUS=0
LIGHTHOUSE_BASE_URL=${LIGHTHOUSE_BASE_URL}
GETH_BASE_URL=${GETH_BASE_URL}
if [ -z "$LIGHTHOUSE_BASE_URL" ]; then
LIGHTHOUSE_PORT=`docker ps -f "name=fixturenet-eth-lighthouse-1-1" --format "{{.Ports}}" | head -1 | cut -d':' -f2 | cut -d'-' -f1`
LIGHTHOUSE_BASE_URL="http://localhost:${LIGHTHOUSE_PORT}"
fi
if [ -z "$GETH_BASE_URL" ]; then
GETH_PORT=`docker ps -f "name=fixturenet-eth-geth-1-1" --format "{{.Ports}}" | head -1 | cut -d':' -f2 | cut -d'-' -f1`
GETH_BASE_URL="http://localhost:${GETH_PORT}"
fi
function inc_status() {
echo " DONE!"
STATUS=$((STATUS + 1))
if [ $STATUS -lt ${#STATUSES[@]} ]; then
echo -n "Waiting for ${STATUSES[$STATUS]}..."
fi
}
echo -n "Waiting for ${STATUSES[$STATUS]}..."
while [ $STATUS -lt ${#STATUSES[@]} ]; do
sleep 1
echo -n "."
case $STATUS in
0)
result=`wget --no-check-certificate --quiet -O - --method POST --header 'Content-Type: application/json' \
--body-data '{ "jsonrpc": "2.0", "id": 1, "method": "eth_getBlockByNumber", "params": ["0x3", false] }' $GETH_BASE_URL | jq -r '.result'`
if [ ! -z "$result" ] && [ "null" != "$result" ]; then
inc_status
fi
;;
1)
result=`wget --no-check-certificate --quiet -O - "$LIGHTHOUSE_BASE_URL/eth/v2/beacon/blocks/head" | jq -r '.data.message.slot'`
if [ ! -z "$result" ] && [ $result -gt 0 ]; then
inc_status
fi
;;
2)
result=`wget --no-check-certificate --quiet -O - "$LIGHTHOUSE_BASE_URL/eth/v2/beacon/blocks/head" | jq -r '.version'`
if [ ! -z "$result" ] && ([ "$result" == "altair" ] || [ "$result" == "bellatrix" ]); then
inc_status
fi
;;
3)
result=`wget --no-check-certificate --quiet -O - "$LIGHTHOUSE_BASE_URL/eth/v2/beacon/blocks/head" | jq -r '.version'`
if [ ! -z "$result" ] && [ "$result" == "bellatrix" ]; then
inc_status
fi
;;
4)
result=`wget --no-check-certificate --quiet -O - "$LIGHTHOUSE_BASE_URL/eth/v2/beacon/blocks/head" | jq -r '.data.message.body.execution_payload.block_number'`
if [ ! -z "$result" ] && [ $result -gt 0 ]; then
inc_status
fi
;;
esac
done