From dcee0db0403f7ef7e1dcb22c43aaf433fad5f41d Mon Sep 17 00:00:00 2001 From: Nikolay Mitev Date: Sun, 5 Jun 2022 19:58:00 +0200 Subject: [PATCH 1/5] Add the starting geth nodes as part of local testnet --- scripts/genesis.json | 44 +++++++++++++++++++++++++++ scripts/launch_local_testnet.sh | 53 ++++++++++++++++++++++++++++---- scripts/start_geth_nodes.sh | 54 +++++++++++++++++++++++++++++++++ 3 files changed, 145 insertions(+), 6 deletions(-) create mode 100644 scripts/genesis.json create mode 100755 scripts/start_geth_nodes.sh diff --git a/scripts/genesis.json b/scripts/genesis.json new file mode 100644 index 0000000000..2bc2d4aa5c --- /dev/null +++ b/scripts/genesis.json @@ -0,0 +1,44 @@ +{ + "config": { + "chainId":1, + "homesteadBlock":0, + "eip150Block":0, + "eip155Block":0, + "eip158Block":0, + "byzantiumBlock":0, + "constantinopleBlock":0, + "petersburgBlock":0, + "istanbulBlock":0, + "muirGlacierBlock":0, + "berlinBlock":0, + "londonBlock":0, + "clique": { + "period": 5, + "epoch": 30000 + }, + "terminalTotalDifficulty":0 + }, + "nonce":"0x42", + "timestamp":"0x0", + "extraData":"0x0000000000000000000000000000000000000000000000000000000000000000a94f5374fce5edbc8e2a8697c15331677e6ebf0b0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + "gasLimit":"0x1C9C380", + "difficulty":"0x400000000", + "mixHash":"0x0000000000000000000000000000000000000000000000000000000000000000", + "coinbase":"0x0000000000000000000000000000000000000000", + "alloc":{ + "0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b":{"balance":"0x6d6172697573766477000000"}, + "0x7e5f4552091a69125d5dfcb7b8c2659029395bdf":{"balance":"0x6d6172697573766477000000"}, + "0x2b5ad5c4795c026514f8317c7a215e218dccd6cf":{"balance":"0x6d6172697573766477000000"}, + "0x6813eb9362372eef6200f3b1dbc3f819671cba69":{"balance":"0x6d6172697573766477000000"}, + "0x1eff47bc3a10a45d4b230b5d10e37751fe6aa718":{"balance":"0x6d6172697573766477000000"}, + "0xe1ab8145f7e55dc933d51a18c793f901a3a0b276":{"balance":"0x6d6172697573766477000000"}, + "0xe57bfe9f44b819898f47bf37e5af72a0783e1141":{"balance":"0x6d6172697573766477000000"}, + "0xd41c057fd1c78805aac12b0a94a405c0461a6fbb":{"balance":"0x6d6172697573766477000000"}, + "0xf1f6619b38a98d6de0800f1defc0a6399eb6d30c":{"balance":"0x6d6172697573766477000000"}, + "0xf7edc8fa1ecc32967f827c9043fcae6ba73afa5c":{"balance":"0x6d6172697573766477000000"} + }, + "number":"0x0", + "gasUsed":"0x0", + "parentHash":"0x0000000000000000000000000000000000000000000000000000000000000000", + "baseFeePerGas":"0x7" +} diff --git a/scripts/launch_local_testnet.sh b/scripts/launch_local_testnet.sh index 9d74e555c6..0e04b51233 100755 --- a/scripts/launch_local_testnet.sh +++ b/scripts/launch_local_testnet.sh @@ -46,7 +46,7 @@ CURL_BINARY="$(command -v curl)" || { echo "Curl not installed. Aborting."; exit JQ_BINARY="$(command -v jq)" || { echo "Jq not installed. Aborting."; exit 1; } OPTS="ht:n:d:g" -LONGOPTS="help,preset:,nodes:,data-dir:,remote-validators-count:,threshold:,remote-signers:,with-ganache,stop-at-epoch:,disable-htop,disable-vc,enable-logtrace,log-level:,base-port:,base-rest-port:,base-metrics-port:,reuse-existing-data-dir,reuse-binaries,timeout:,kill-old-processes,eth2-docker-image:,lighthouse-vc-nodes:" +LONGOPTS="help,preset:,nodes:,data-dir:,remote-validators-count:,threshold:,remote-signers:,with-ganache,stop-at-epoch:,disable-htop,disable-vc,enable-logtrace,log-level:,base-port:,base-rest-port:,base-metrics-port:,reuse-existing-data-dir,reuse-binaries,timeout:,kill-old-processes,eth2-docker-image:,lighthouse-vc-nodes:,run-geth:,light-clients:" # default values NUM_NODES="10" @@ -73,6 +73,10 @@ REMOTE_SIGNER_NODES=0 REMOTE_SIGNER_THRESHOLD=1 REMOTE_VALIDATORS_COUNT=0 LC_NODES=1 +ACCOUNT_PASSWORD="nimbus" +RUN_GETH="0" +GETH_BINARY="${HOME}/go-ethereum/build/bin/geth" +GETH_BASE_HTTP_PORT="8550" print_help() { cat </dev/null || \ { echo "'lsof' not installed and we need it to check for ports already in use. Aborting."; exit 1; } + #TODO Stop geth nodes + #for NUM_NODE in $(seq 0 $(( NUM_NODES - 1 ))); do + #for PORT in $(( BASE_GETH_PORT + NUM_NODE )) $(( BASE_METRICS_PORT + NUM_NODE )) $(( BASE_REST_PORT + NUM_NODE )); do + #done + for NUM_NODE in $(seq 0 $(( NUM_NODES - 1 ))); do for PORT in $(( BASE_PORT + NUM_NODE )) $(( BASE_METRICS_PORT + NUM_NODE )) $(( BASE_REST_PORT + NUM_NODE )); do for PID in $(lsof -n -i tcp:${PORT} -sTCP:LISTEN -t); do @@ -371,12 +397,15 @@ cleanup() { pkill -f -P $$ nimbus_signing_node &>/dev/null || true pkill -f -P $$ nimbus_light_client &>/dev/null || true pkill -f -P $$ ${LH_BINARY} &>/dev/null || true + pkill -f -P $$ ${GETH_BINARY} &>/dev/null || true sleep 2 pkill -f -9 -P $$ nimbus_beacon_node &>/dev/null || true pkill -f -9 -P $$ nimbus_validator_client &>/dev/null || true pkill -f -9 -P $$ nimbus_signing_node &>/dev/null || true pkill -f -9 -P $$ nimbus_light_client &>/dev/null || true pkill -f -9 -P $$ ${LH_BINARY} &>/dev/null || true + pkill -f -9 -P $$ ${GETH_BINARY} &>/dev/null || true + # Delete all binaries we just built, because these are unusable outside this # local testnet. @@ -389,6 +418,11 @@ cleanup() { if [[ -n "$ETH2_DOCKER_IMAGE" ]]; then docker rm $(docker stop $(docker ps -a -q --filter ancestor=$ETH2_DOCKER_IMAGE --format="{{.ID}}")) fi + + for dir in "${GETH_DATA_DIRS[@]}" + do + rm -rf "${dir}" + done } trap 'cleanup' SIGINT SIGTERM EXIT @@ -413,7 +447,7 @@ done # deposit and testnet creation PIDS="" -WEB3_ARG="--web3-url=ws://127.0.0.1:8546" + BOOTSTRAP_TIMEOUT=30 # in seconds DEPOSIT_CONTRACT_ADDRESS="0x0000000000000000000000000000000000000000" DEPOSIT_CONTRACT_BLOCK="0x0000000000000000000000000000000000000000000000000000000000000000" @@ -548,16 +582,20 @@ if [[ "${USE_VC}" == "1" ]]; then # if using validator client binaries in addition to beacon nodes we will # split the keys for this instance in half between the BN and the VC # and the validators for the BNs will be from the first half of all validators - VALIDATORS_PER_NODE=$((VALIDATORS_PER_NODE / 2 )) - NUM_JOBS=$((NUM_JOBS * 2 )) + VALIDATORS_PER_NODE=$(( VALIDATORS_PER_NODE / 2 )) + NUM_JOBS=$(( NUM_JOBS * 2 )) fi if [ "$REMOTE_SIGNER_NODES" -ge "0" ]; then - NUM_JOBS=$((NUM_JOBS + REMOTE_SIGNER_NODES )) + NUM_JOBS=$(( NUM_JOBS + REMOTE_SIGNER_NODES )) fi if [ "$LC_NODES" -ge "1" ]; then - NUM_JOBS=$((NUM_JOBS + LC_NODES )) + NUM_JOBS=$(( NUM_JOBS + LC_NODES )) +fi + +if [ "${NUM_GETH_NODES}" -ge "0" ]; then + NUM_JOBS=$(( NUM_JOBS + NUM_GETH_NODES )) fi VALIDATORS_PER_VALIDATOR=$(( (SYSTEM_VALIDATORS / NODES_WITH_VALIDATORS) / 2 )) @@ -674,6 +712,9 @@ for NUM_NODE in $(seq 0 $(( NUM_NODES - 1 ))); do done fi + WEB3_ARG="--web3-url=http://127.0.0.1:${GETH_HTTP_PORTS[${NUM_NODE}]}" + + ${BEACON_NODE_COMMAND} \ --config-file="${CLI_CONF_FILE}" \ --tcp-port=$(( BASE_PORT + NUM_NODE )) \ diff --git a/scripts/start_geth_nodes.sh b/scripts/start_geth_nodes.sh new file mode 100755 index 0000000000..412b664104 --- /dev/null +++ b/scripts/start_geth_nodes.sh @@ -0,0 +1,54 @@ +#!/usr/bin/env bash + +BASEDIR="$(dirname "${BASH_SOURCE[0]}")" + +GETH_NUM_NODES="${GETH_NUM_NODES:-4}" +GETH_BINARY="${GETH_BINARY:-${HOME}/go-ethereum/build/bin/geth}" +GETH_BASE_HTTP_PORT="${GETH_BASE_HTTP_PORT:-8550}" +GETH_NET_BASE_PORT="${GETH_NET_BASE_PORT:-30303}" +GETH_HTTP_BASE_PORT="${GETH_HTTP_BASE_PORT:-8545}" +GETH_WS_BASE_PORT="${GETH_WS_BASE_PORT:-8546}" +GETH_AUTH_RPC_PORT_BASE="${GETH_AUTH_RPC_PORT_BASE:-8551}" +PORT_OFFSET=100 +GENESISJSON="${GENESISJSON:-${BASEDIR}/genesis.json}" +DISCOVER="--nodiscover" + +#These are used in the caller script +GETH_ENODES=() +GETH_HTTP_PORTS=() +GETH_NET_PORTS=() +GETH_WS_PORTS=() +GETH_RPC_PORTS=() +GETH_DATA_DIRS=() + +for NUM_NODE in $(seq 0 $(( GETH_NUM_NODES - 1 ))); do + GETH_NET_PORT=$(( NUM_NODE * PORT_OFFSET + GETH_NET_BASE_PORT )) + GETH_HTTP_PORT=$(( NUM_NODE * PORT_OFFSET + GETH_HTTP_BASE_PORT )) + GETH_WS_PORT=$(( NUM_NODE * PORT_OFFSET + GETH_WS_BASE_PORT )) + GETH_AUTH_RPC_PORT=$(( NUM_NODE * PORT_OFFSET + GETH_AUTH_RPC_PORT_BASE )) + echo "Starting geth node ${NUM_NODE} on net port ${GETH_NET_PORT} HTTP port ${GETH_HTTP_PORT} WS port ${GETH_WS_PORT}" + GETHDATADIR=$(mktemp -d geth-data-XXX) + GETH_DATA_DIRS+=(${GETHDATADIR}) + ${GETH_BINARY} --http --ws -http.api "engine" --datadir "${GETHDATADIR}" init "${GENESISJSON}" + #${GETH_BINARY} --http --ws -http.api "engine" --datadir "${GETHDATADIR}" account import <(echo 45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8) + #${GETH_BINARY} --http --ws --http.api "eth,net,engine" -ws.api "eth,net,engine" --datadir "${GETHDATADIR}" --allow-insecure-unlock --unlock "0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b" --password ${PASSWORDFILE} --nodiscover console + ${GETH_BINARY} --http --ws --http.api "eth,net,engine" -ws.api "eth,net,engine" --datadir "${GETHDATADIR}" ${DISCOVER} --port ${GETH_NET_PORT} --http.port ${GETH_HTTP_PORT=} --ws.port ${GETH_WS_PORT} --authrpc.port ${GETH_AUTH_RPC_PORT} &>/dev/null & + sleep 5 + NODE_ID=$(${GETH_BINARY} attach --datadir "${GETHDATADIR}" --exec admin.nodeInfo.enode) + GETH_ENODES+=(${NODE_ID}) + GETH_HTTP_PORTS+=(${GETH_HTTP_PORT}) + GETH_NET_PORTS+=(${GETH_NET_PORT}) + GETH_WS_PORTS+=(${GETH_WS_PORT}) + GETH_RPC_PORTS+=(${GETH_AUTH_RPC_PORT}) +done + +#Add all nodes as peers +for dir in "${GETH_DATA_DIRS[@]}" +do + for enode in "${GETH_ENODES[@]}" + do + $(${GETH_BINARY} attach --datadir "${dir}" --exec "admin.addPeer(${enode})") + done +done + +echo "GETH HTTP Ports: ${GETH_HTTP_PORTS[*]}" From 28f708147d6e7bba9ed240d00ceea8c0db00c555 Mon Sep 17 00:00:00 2001 From: Nikolay Mitev Date: Mon, 6 Jun 2022 11:45:00 +0200 Subject: [PATCH 2/5] Applied some suggestions --- scripts/{genesis.json => geth_genesis.json} | 0 scripts/launch_local_testnet.sh | 1 - scripts/start_geth_nodes.sh | 4 +++- 3 files changed, 3 insertions(+), 2 deletions(-) rename scripts/{genesis.json => geth_genesis.json} (100%) diff --git a/scripts/genesis.json b/scripts/geth_genesis.json similarity index 100% rename from scripts/genesis.json rename to scripts/geth_genesis.json diff --git a/scripts/launch_local_testnet.sh b/scripts/launch_local_testnet.sh index 0e04b51233..f001425598 100755 --- a/scripts/launch_local_testnet.sh +++ b/scripts/launch_local_testnet.sh @@ -76,7 +76,6 @@ LC_NODES=1 ACCOUNT_PASSWORD="nimbus" RUN_GETH="0" GETH_BINARY="${HOME}/go-ethereum/build/bin/geth" -GETH_BASE_HTTP_PORT="8550" print_help() { cat < Date: Tue, 7 Jun 2022 13:16:41 +0200 Subject: [PATCH 3/5] Change chainId to not be mainnet --- scripts/geth_genesis.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/geth_genesis.json b/scripts/geth_genesis.json index 2bc2d4aa5c..9960dc6ab5 100644 --- a/scripts/geth_genesis.json +++ b/scripts/geth_genesis.json @@ -1,6 +1,6 @@ { "config": { - "chainId":1, + "chainId":9999, "homesteadBlock":0, "eip150Block":0, "eip155Block":0, From a351f5ad48732b09d617ef2253f05416956bc712 Mon Sep 17 00:00:00 2001 From: Nikolay Mitev Date: Sat, 11 Jun 2022 14:38:59 +0200 Subject: [PATCH 4/5] Add geth download option, nimbus-eth1 as EL --- scripts/geth_vars.sh | 13 ++ scripts/launch_local_testnet.sh | 222 +++++++++++++++++++++++++------ scripts/nimbus_el_vars.sh | 15 +++ scripts/nimbusel_genesis.json | 44 ++++++ scripts/start_geth_nodes.sh | 25 ++-- scripts/start_nimbus_el_nodes.sh | 54 ++++++++ 6 files changed, 320 insertions(+), 53 deletions(-) create mode 100644 scripts/geth_vars.sh create mode 100644 scripts/nimbus_el_vars.sh create mode 100644 scripts/nimbusel_genesis.json create mode 100755 scripts/start_nimbus_el_nodes.sh diff --git a/scripts/geth_vars.sh b/scripts/geth_vars.sh new file mode 100644 index 0000000000..a50ba3c58d --- /dev/null +++ b/scripts/geth_vars.sh @@ -0,0 +1,13 @@ +GETH_PORT_OFFSET=100 +GETH_BINARY="${GETH_BINARY:-"${HOME}/go-ethereum/build/bin/geth"}" +GETH_NUM_NODES="${GETH_NUM_NODES:-4}" +GETH_BINARY="${GETH_BINARY:-${HOME}/go-ethereum/build/bin/geth}" +GETH_BASE_HTTP_PORT="${GETH_BASE_HTTP_PORT:-8550}" +GETH_NET_BASE_PORT="${GETH_NET_BASE_PORT:-30303}" +GETH_HTTP_BASE_PORT="${GETH_HTTP_BASE_PORT:-8545}" +GETH_WS_BASE_PORT="${GETH_WS_BASE_PORT:-8546}" +GETH_AUTH_RPC_PORT_BASE="${GETH_AUTH_RPC_PORT_BASE:-8551}" +PORT_OFFSET="${PORT_OFFSET:-100}" +GENESISJSON="${GENESISJSON:-${BASEDIR}/scripts/geth_genesis.json}" +DISCOVER="--nodiscover" + diff --git a/scripts/launch_local_testnet.sh b/scripts/launch_local_testnet.sh index f001425598..bc3a925be3 100755 --- a/scripts/launch_local_testnet.sh +++ b/scripts/launch_local_testnet.sh @@ -14,6 +14,15 @@ set -eu cd "$(dirname "${BASH_SOURCE[0]}")"/.. + +VERBOSE="0" + +log() { + if [[ "${VERBOSE}" -ge "1" ]]; then + echo "${@}" + fi +} + # OS detection OS="linux" if uname | grep -qi darwin; then @@ -46,9 +55,10 @@ CURL_BINARY="$(command -v curl)" || { echo "Curl not installed. Aborting."; exit JQ_BINARY="$(command -v jq)" || { echo "Jq not installed. Aborting."; exit 1; } OPTS="ht:n:d:g" -LONGOPTS="help,preset:,nodes:,data-dir:,remote-validators-count:,threshold:,remote-signers:,with-ganache,stop-at-epoch:,disable-htop,disable-vc,enable-logtrace,log-level:,base-port:,base-rest-port:,base-metrics-port:,reuse-existing-data-dir,reuse-binaries,timeout:,kill-old-processes,eth2-docker-image:,lighthouse-vc-nodes:,run-geth:,light-clients:" +LONGOPTS="help,preset:,nodes:,data-dir:,remote-validators-count:,threshold:,remote-signers:,with-ganache,stop-at-epoch:,disable-htop,disable-vc,enable-logtrace,log-level:,base-port:,base-rest-port:,base-metrics-port:,reuse-existing-data-dir,reuse-binaries,timeout:,kill-old-processes,eth2-docker-image:,lighthouse-vc-nodes:,run-geth,dl-geth,light-clients:,run-nimbus-el,verbose" # default values +NIMFLAGS="${NIMFLAGS:-""}" NUM_NODES="10" DATA_DIR="local_testnet_data" USE_HTOP="1" @@ -72,10 +82,20 @@ ETH2_DOCKER_IMAGE="" REMOTE_SIGNER_NODES=0 REMOTE_SIGNER_THRESHOLD=1 REMOTE_VALIDATORS_COUNT=0 -LC_NODES=1 +LC_NODES=0 ACCOUNT_PASSWORD="nimbus" RUN_GETH="0" -GETH_BINARY="${HOME}/go-ethereum/build/bin/geth" +DL_GETH="0" +CLEANUP_DIRS=() + +#NIMBUS EL VARS +RUN_NIMBUS="0" +NIMBUS_EL_BINARY="../nimbus-eth1/build/nimbus" + +EL_HTTP_PORTS=() +PROCS_TO_KILL=("nimbus_beacon_node" "nimbus_validator_client" "nimbus_signing_node" "nimbus_light_client") + + print_help() { cat </dev/null || \ { echo "'lsof' not installed and we need it to check for ports already in use. Aborting."; exit 1; } - #TODO Stop geth nodes - #for NUM_NODE in $(seq 0 $(( NUM_NODES - 1 ))); do - #for PORT in $(( BASE_GETH_PORT + NUM_NODE )) $(( BASE_METRICS_PORT + NUM_NODE )) $(( BASE_REST_PORT + NUM_NODE )); do - #done + + #Stop geth nodes + if [[ "${RUN_GETH}" == "1" ]]; then + for NUM_NODE in $(seq 0 $(( NUM_NODES - 1 ))); do + for PORT in $(( NUM_NODE * GETH_PORT_OFFSET + GETH_NET_BASE_PORT )) $(( NUM_NODE * GETH_PORT_OFFSET + GETH_HTTP_BASE_PORT )) \ + $(( NUM_NODE * GETH_PORT_OFFSET + GETH_WS_BASE_PORT )) $(( NUM_NODE * GETH_PORT_OFFSET + GETH_AUTH_RPC_PORT_BASE )); do + for PID in $(lsof -n -i tcp:${PORT} -sTCP:LISTEN -t); do + echo -n "Found old geth processes listening on port ${PORT}, with PID ${PID}. " + if [[ "${KILL_OLD_PROCESSES}" == "1" ]]; then + echo "Killing it." + kill -9 "${PID}" || true + else + echo "Aborting." + exit 1 + fi + done + done + done + fi + + if [[ "${RUN_NIMBUS}" == "1" ]]; then + for NUM_NODE in $(seq 0 $(( NUM_NODES - 1 ))); do + for PORT in $(( NUM_NODE * NIMBUSEL_PORT_OFFSET + NIMBUSEL_NET_BASE_PORT )) $(( NUM_NODE * NIMBUSEL_PORT_OFFSET + NIMBUSEL_HTTP_BASE_PORT )) \ + $(( NUM_NODE * NIMBUSEL_PORT_OFFSET + NIMBUSEL_WS_BASE_PORT )) $(( NUM_NODE * NIMBUSEL_PORT_OFFSET + NIMBUSEL_AUTH_RPC_PORT_BASE )); do + for PID in $(lsof -n -i tcp:${PORT} -sTCP:LISTEN -t); do + echo -n "Found old nimbus EL processes listening on port ${PORT}, with PID ${PID}. " + if [[ "${KILL_OLD_PROCESSES}" == "1" ]]; then + echo "Killing it." + kill -9 "${PID}" || true + else + echo "Aborting." + exit 1 + fi + done + done + done + fi for NUM_NODE in $(seq 0 $(( NUM_NODES - 1 ))); do for PORT in $(( BASE_PORT + NUM_NODE )) $(( BASE_METRICS_PORT + NUM_NODE )) $(( BASE_REST_PORT + NUM_NODE )); do @@ -304,7 +376,7 @@ if [[ "${OS}" != "windows" ]]; then echo -n "Found old process listening on port ${PORT}, with PID ${PID}. " if [[ "${KILL_OLD_PROCESSES}" == "1" ]]; then echo "Killing it." - kill -9 ${PID} || true + kill -9 "${PID}" || true else echo "Aborting." exit 1 @@ -314,6 +386,73 @@ if [[ "${OS}" != "windows" ]]; then done fi +download_geth() { + + GETH_VERSION="1.10.18-de23cf91" + +# "https://gethstore.blob.core.windows.net/builds/geth-linux-amd64-1.10.18-de23cf91.tar.gz" +# "https://gethstore.blob.core.windows.net/builds/geth-darwin-amd64-1.10.18-de23cf91.tar.gz" +# "https://gethstore.blob.core.windows.net/builds/geth-windows-amd64-1.10.18-de23cf91.zip" + + GETH_URL="https://gethstore.blob.core.windows.net/builds/" + + case "${OS}" in + linux) + GETH_TARBALL="geth-linux-amd64-${GETH_VERSION}.tar.gz" + ;; + macos) + GETH_TARBALL="geth-darwin-amd64-${GETH_VERSION}.tar.gz" + ;; + windows) + GETH_TARBALL="geth-windows-amd64-${GETH_VERSION}.zip" + ;; + esac + + if [[ ! -e "build/${GETH_BINARY}" ]]; then + log "Downloading Geth binary" + pushd "build" >/dev/null + "${CURL_BINARY}" -sSLO "${GETH_URL}/${GETH_TARBALL}" + local tmp_extract_dir + tmp_extract_dir=$(mktemp -d geth-extract-XXX) + CLEANUP_DIRS+=("${tmp_extract_dir}") + tar -xzf "${GETH_TARBALL}" --directory "${tmp_extract_dir}" --strip-components=1 + mv "${tmp_extract_dir}/geth" . + GETH_BINARY="${PWD}/geth" + popd >/dev/null + fi +} + +GETH_NUM_NODES="${NUM_NODES}" +NIMBUSEL_NUM_NODES="${NUM_NODES}" + +if [[ "${RUN_GETH}" == "1" ]]; then + if [[ ! -e "${GETH_BINARY}" && "${DL_GETH}" == "1" ]]; then + log "Downloading geth ..." + download_geth + else + echo "Missing geth executable" + exit 1 + fi + + log "Starting ${GETH_NUM_NODES} Geth Nodes ..." + . "./scripts/start_geth_nodes.sh" + EL_HTTP_PORTS+=("${GETH_HTTP_PORTS[@]}") + PROCS_TO_KILL+=("${GETH_BINARY}") + CLEANUP_DIRS+=("${GETH_DATA_DIRS[@]}") +fi + +if [[ "${RUN_NIMBUS}" == "1" ]]; then + if [[ ! -e "${NIMBUS_EL_BINARY}" ]]; then + echo "Missing nimbus EL executable" + exit 1 + fi + + . "./scripts/start_nimbus_el_nodes.sh" + EL_HTTP_PORTS+=("${NIMBUSEL_HTTP_PORTS[@]}") + PROCS_TO_KILL+=("${NIMBUS_EL_BINARY}") + CLEANUP_DIRS+=("${NIMBUSEL_DATA_DIRS[@]}") +fi + # Download the Lighthouse binary. LH_VERSION="2.1.3" LH_ARCH="${ARCH}" @@ -336,6 +475,7 @@ LH_URL="https://github.com/sigp/lighthouse/releases/download/v${LH_VERSION}/${LH LH_BINARY="lighthouse-${LH_VERSION}" if [[ "${USE_VC}" == "1" && "${LIGHTHOUSE_VC_NODES}" != "0" && ! -e "build/${LH_BINARY}" ]]; then + echo "Downloading Lighthouse binary" pushd "build" >/dev/null "${CURL_BINARY}" -sSLO "${LH_URL}" tar -xzf "${LH_TARBALL}" # contains just one file named "lighthouse" @@ -383,6 +523,7 @@ for BINARY in ${BINARIES}; do break fi done + if [[ "${REUSE_BINARIES}" == "0" || "${BINARIES_MISSING}" == "1" ]]; then ${MAKE} -j ${NPROC} LOG_LEVEL=TRACE NIMFLAGS="${NIMFLAGS} -d:local_testnet -d:const_preset=${CONST_PRESET}" ${BINARIES} fi @@ -391,20 +532,19 @@ fi # instance as the parent and the target process name as a pattern to the # "pkill" command. cleanup() { - pkill -f -P $$ nimbus_beacon_node &>/dev/null || true - pkill -f -P $$ nimbus_validator_client &>/dev/null || true - pkill -f -P $$ nimbus_signing_node &>/dev/null || true - pkill -f -P $$ nimbus_light_client &>/dev/null || true - pkill -f -P $$ ${LH_BINARY} &>/dev/null || true - pkill -f -P $$ ${GETH_BINARY} &>/dev/null || true + log "Cleaning up" + + for proc in "${PROCS_TO_KILL[@]}" + do + pkill -f -P $$ "${proc}" &>/dev/null || true + done + sleep 2 - pkill -f -9 -P $$ nimbus_beacon_node &>/dev/null || true - pkill -f -9 -P $$ nimbus_validator_client &>/dev/null || true - pkill -f -9 -P $$ nimbus_signing_node &>/dev/null || true - pkill -f -9 -P $$ nimbus_light_client &>/dev/null || true - pkill -f -9 -P $$ ${LH_BINARY} &>/dev/null || true - pkill -f -9 -P $$ ${GETH_BINARY} &>/dev/null || true + for proc in "${PROCS_TO_KILL[@]}" + do + pkill -f -9 -P $$ "${proc}" &>/dev/null || true + done # Delete all binaries we just built, because these are unusable outside this # local testnet. @@ -418,11 +558,13 @@ cleanup() { docker rm $(docker stop $(docker ps -a -q --filter ancestor=$ETH2_DOCKER_IMAGE --format="{{.ID}}")) fi - for dir in "${GETH_DATA_DIRS[@]}" + for dir in "${CLEANUP_DIRS[@]}" do + log "Deleting ${dir}" rm -rf "${dir}" done } + trap 'cleanup' SIGINT SIGTERM EXIT # timeout - implemented with a background job @@ -593,8 +735,12 @@ if [ "$LC_NODES" -ge "1" ]; then NUM_JOBS=$(( NUM_JOBS + LC_NODES )) fi -if [ "${NUM_GETH_NODES}" -ge "0" ]; then - NUM_JOBS=$(( NUM_JOBS + NUM_GETH_NODES )) +if [ "${RUN_GETH}" == "1" ]; then + NUM_JOBS=$(( NUM_JOBS + GETH_NUM_NODES )) +fi + +if [ "${RUN_NIMBUS}" == "1" ]; then + NUM_JOBS=$(( NUM_JOBS + NIMBUSEL_NUM_NODES )) fi VALIDATORS_PER_VALIDATOR=$(( (SYSTEM_VALIDATORS / NODES_WITH_VALIDATORS) / 2 )) @@ -711,7 +857,7 @@ for NUM_NODE in $(seq 0 $(( NUM_NODES - 1 ))); do done fi - WEB3_ARG="--web3-url=http://127.0.0.1:${GETH_HTTP_PORTS[${NUM_NODE}]}" + WEB3_ARG="--web3-url=http://127.0.0.1:${EL_HTTP_PORTS[${NUM_NODE}]}" ${BEACON_NODE_COMMAND} \ @@ -782,13 +928,15 @@ if [ "$LC_NODES" -ge "1" ]; then while :; do CURRENT_FORK_EPOCH="$( "${CURL_BINARY}" -s "http://localhost:${BASE_REST_PORT}/eth/v1/beacon/states/finalized/fork" | \ - "${JQ_BINARY}" -r '.data.epoch')" + tee -a curl_result.txt | "${JQ_BINARY}" -r '.data.epoch')" if [ "${CURRENT_FORK_EPOCH}" -ge "${ALTAIR_FORK_EPOCH}" ]; then break fi sleep 1 done + log "After ALTAIR_FORK_EPOCH" + echo "Altair finalized, launching $LC_NODES light client(s)" LC_BOOTSTRAP_NODE="$( "${CURL_BINARY}" -s "http://localhost:${BASE_REST_PORT}/eth/v1/node/identity" | \ diff --git a/scripts/nimbus_el_vars.sh b/scripts/nimbus_el_vars.sh new file mode 100644 index 0000000000..e24fbf6377 --- /dev/null +++ b/scripts/nimbus_el_vars.sh @@ -0,0 +1,15 @@ +NIMBUSEL_DISCOVERY="--discovery=V5" + +NIMBUSEL_PORT_OFFSET="${PORT_OFFSET:-100}" +NIMBUSEL_BINARY="${NIMBUSEL_BINARY:-"${HOME}/work/nimbus-eth1/build/nimbus"}" +NIMBUSEL_GENESIS="${NIMBUSEL_GENESIS:-"${HOME}/work/nimbus-eth2/scripts/nimbusel_genesis.json"}" +NIMBUSEL_NUM_NODES="${NIMBUSEL_NUM_NODES:-4}" +NIMBUSEL_BINARY="${NIMBUSEL_BINARY:-${HOME}/go-ethereum/build/bin/geth}" +NIMBUSEL_BASE_HTTP_PORT="${NIMBUSEL_BASE_HTTP_PORT:-8550}" +NIMBUSEL_NET_BASE_PORT="${NIMBUSEL_NET_BASE_PORT:-30303}" +NIMBUSEL_HTTP_BASE_PORT="${NIMBUSEL_HTTP_BASE_PORT:-8545}" +NIMBUSEL_WS_BASE_PORT="${NIMBUSEL_WS_BASE_PORT:-8546}" +NIMBUSEL_AUTH_RPC_PORT_BASE="${NIMBUSEL_AUTH_RPC_PORT_BASE:-8551}" +CURL_BINARY=${CURL_BINARY:-curl} +JQ_BINARY=${JQ_BINARY:-jq} + diff --git a/scripts/nimbusel_genesis.json b/scripts/nimbusel_genesis.json new file mode 100644 index 0000000000..9960dc6ab5 --- /dev/null +++ b/scripts/nimbusel_genesis.json @@ -0,0 +1,44 @@ +{ + "config": { + "chainId":9999, + "homesteadBlock":0, + "eip150Block":0, + "eip155Block":0, + "eip158Block":0, + "byzantiumBlock":0, + "constantinopleBlock":0, + "petersburgBlock":0, + "istanbulBlock":0, + "muirGlacierBlock":0, + "berlinBlock":0, + "londonBlock":0, + "clique": { + "period": 5, + "epoch": 30000 + }, + "terminalTotalDifficulty":0 + }, + "nonce":"0x42", + "timestamp":"0x0", + "extraData":"0x0000000000000000000000000000000000000000000000000000000000000000a94f5374fce5edbc8e2a8697c15331677e6ebf0b0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + "gasLimit":"0x1C9C380", + "difficulty":"0x400000000", + "mixHash":"0x0000000000000000000000000000000000000000000000000000000000000000", + "coinbase":"0x0000000000000000000000000000000000000000", + "alloc":{ + "0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b":{"balance":"0x6d6172697573766477000000"}, + "0x7e5f4552091a69125d5dfcb7b8c2659029395bdf":{"balance":"0x6d6172697573766477000000"}, + "0x2b5ad5c4795c026514f8317c7a215e218dccd6cf":{"balance":"0x6d6172697573766477000000"}, + "0x6813eb9362372eef6200f3b1dbc3f819671cba69":{"balance":"0x6d6172697573766477000000"}, + "0x1eff47bc3a10a45d4b230b5d10e37751fe6aa718":{"balance":"0x6d6172697573766477000000"}, + "0xe1ab8145f7e55dc933d51a18c793f901a3a0b276":{"balance":"0x6d6172697573766477000000"}, + "0xe57bfe9f44b819898f47bf37e5af72a0783e1141":{"balance":"0x6d6172697573766477000000"}, + "0xd41c057fd1c78805aac12b0a94a405c0461a6fbb":{"balance":"0x6d6172697573766477000000"}, + "0xf1f6619b38a98d6de0800f1defc0a6399eb6d30c":{"balance":"0x6d6172697573766477000000"}, + "0xf7edc8fa1ecc32967f827c9043fcae6ba73afa5c":{"balance":"0x6d6172697573766477000000"} + }, + "number":"0x0", + "gasUsed":"0x0", + "parentHash":"0x0000000000000000000000000000000000000000000000000000000000000000", + "baseFeePerGas":"0x7" +} diff --git a/scripts/start_geth_nodes.sh b/scripts/start_geth_nodes.sh index f5d9087b1e..67f0002eb3 100755 --- a/scripts/start_geth_nodes.sh +++ b/scripts/start_geth_nodes.sh @@ -4,16 +4,7 @@ set -euo pipefail BASEDIR="$(dirname "${BASH_SOURCE[0]}")" -GETH_NUM_NODES="${GETH_NUM_NODES:-4}" -GETH_BINARY="${GETH_BINARY:-${HOME}/go-ethereum/build/bin/geth}" -GETH_BASE_HTTP_PORT="${GETH_BASE_HTTP_PORT:-8550}" -GETH_NET_BASE_PORT="${GETH_NET_BASE_PORT:-30303}" -GETH_HTTP_BASE_PORT="${GETH_HTTP_BASE_PORT:-8545}" -GETH_WS_BASE_PORT="${GETH_WS_BASE_PORT:-8546}" -GETH_AUTH_RPC_PORT_BASE="${GETH_AUTH_RPC_PORT_BASE:-8551}" -PORT_OFFSET=100 -GENESISJSON="${GENESISJSON:-${BASEDIR}/geth_genesis.json}" -DISCOVER="--nodiscover" +. "${BASEDIR}/geth_vars.sh" #These are used in the caller script GETH_ENODES=() @@ -23,12 +14,14 @@ GETH_WS_PORTS=() GETH_RPC_PORTS=() GETH_DATA_DIRS=() +log "Using ${GETH_BINARY}" + for NUM_NODE in $(seq 0 $(( GETH_NUM_NODES - 1 ))); do - GETH_NET_PORT=$(( NUM_NODE * PORT_OFFSET + GETH_NET_BASE_PORT )) - GETH_HTTP_PORT=$(( NUM_NODE * PORT_OFFSET + GETH_HTTP_BASE_PORT )) - GETH_WS_PORT=$(( NUM_NODE * PORT_OFFSET + GETH_WS_BASE_PORT )) - GETH_AUTH_RPC_PORT=$(( NUM_NODE * PORT_OFFSET + GETH_AUTH_RPC_PORT_BASE )) - echo "Starting geth node ${NUM_NODE} on net port ${GETH_NET_PORT} HTTP port ${GETH_HTTP_PORT} WS port ${GETH_WS_PORT}" + GETH_NET_PORT=$(( NUM_NODE * GETH_PORT_OFFSET + GETH_NET_BASE_PORT )) + GETH_HTTP_PORT=$(( NUM_NODE * GETH_PORT_OFFSET + GETH_HTTP_BASE_PORT )) + GETH_WS_PORT=$(( NUM_NODE * GETH_PORT_OFFSET + GETH_WS_BASE_PORT )) + GETH_AUTH_RPC_PORT=$(( NUM_NODE * GETH_PORT_OFFSET + GETH_AUTH_RPC_PORT_BASE )) + log "Starting geth node ${NUM_NODE} on net port ${GETH_NET_PORT} HTTP port ${GETH_HTTP_PORT} WS port ${GETH_WS_PORT}" GETHDATADIR=$(mktemp -d geth-data-XXX) GETH_DATA_DIRS+=(${GETHDATADIR}) ${GETH_BINARY} --http --ws -http.api "engine" --datadir "${GETHDATADIR}" init "${GENESISJSON}" @@ -53,4 +46,4 @@ do done done -echo "GETH HTTP Ports: ${GETH_HTTP_PORTS[*]}" +log "GETH HTTP Ports: ${GETH_HTTP_PORTS[*]}" diff --git a/scripts/start_nimbus_el_nodes.sh b/scripts/start_nimbus_el_nodes.sh new file mode 100755 index 0000000000..4448f95d58 --- /dev/null +++ b/scripts/start_nimbus_el_nodes.sh @@ -0,0 +1,54 @@ +#!/usr/bin/env bash + +set -euo pipefail + +BASEDIR="$(dirname "${BASH_SOURCE[0]}")" + +. "${BASEDIR}/nimbus_el_vars.sh" + +#These are used in the caller script +NIMBUSEL_ENODES=() +NIMBUSEL_HTTP_PORTS=() +NIMBUSEL_NET_PORTS=() +NIMBUSEL_WS_PORTS=() +NIMBUSEL_RPC_PORTS=() +NIMBUSEL_DATA_DIRS=() + +log "Using ${NIMBUSEL_BINARY}" + +for NUM_NODE in $(seq 0 $(( NIMBUSEL_NUM_NODES - 1 ))); do + NIMBUSEL_NET_PORT=$(( NUM_NODE * NIMBUSEL_PORT_OFFSET + NIMBUSEL_NET_BASE_PORT )) + NIMBUSEL_HTTP_PORT=$(( NUM_NODE * NIMBUSEL_PORT_OFFSET + NIMBUSEL_HTTP_BASE_PORT )) + NIMBUSEL_WS_PORT=$(( NUM_NODE * NIMBUSEL_PORT_OFFSET + NIMBUSEL_WS_BASE_PORT )) + NIMBUSEL_AUTH_RPC_PORT=$(( NUM_NODE * NIMBUSEL_PORT_OFFSET + NIMBUSEL_AUTH_RPC_PORT_BASE )) + log "Starting nimbus EL node ${NUM_NODE} on net port ${NIMBUSEL_NET_PORT} HTTP port ${NIMBUSEL_HTTP_PORT} WS port ${NIMBUSEL_WS_PORT}" + NIMBUSEL_DATADIR=$(mktemp -d nimbusel-data-XXX) + NIMBUSEL_DATA_DIRS+=("${NIMBUSEL_DATADIR}") + ${NIMBUSEL_BINARY} --data-dir="${NIMBUSEL_DATADIR}" --custom-network="${NIMBUSEL_GENESIS}" "${NIMBUSEL_DISCOVERY}" --tcp-port="${NIMBUSEL_NET_PORT}" \ + --rpc --rpc-port="${NIMBUSEL_HTTP_PORT}" &>/dev/null & + sleep 5 + NODE_ID=$( + "${CURL_BINARY}" -sS -X POST \ + -H 'Content-Type: application/json' \ + -d '{"jsonrpc":"2.0","id":"id","method":"net_nodeInfo"}' \ + "http://localhost:${NIMBUSEL_HTTP_PORT}" | "${JQ_BINARY}" .result.enode) + log "EL Node ID" "${NODE_ID}" + NIMBUSEL_ENODES+=("${NODE_ID}") + NIMBUSEL_HTTP_PORTS+=("${NIMBUSEL_HTTP_PORT}") + NIMBUSEL_NET_PORTS+=("${NIMBUSEL_NET_PORT}") + NIMBUSEL_WS_PORTS+=("${NIMBUSEL_WS_PORT}") + NIMBUSEL_RPC_PORTS+=("${NIMBUSEL_AUTH_RPC_PORT}") +done + +for enode in "${NIMBUSEL_ENODES[@]}" +do + for port in "${NIMBUSEL_HTTP_PORTS[@]}" + do + "${CURL_BINARY}" -sS -X POST \ + -H 'Content-Type: application/json' \ + -d '{"jsonrpc":"2.0","id":"1","method":"nimbus_addPeer","params": ['"${enode}"']}' \ + "http://localhost:${port}" + done +done + +echo "NimbusEL HTTP Ports: ${NIMBUSEL_HTTP_PORTS[*]}" From 9d0be3db0af6212cd80aeb08706ab175be997a21 Mon Sep 17 00:00:00 2001 From: Nikolay Mitev Date: Sun, 26 Jun 2022 21:05:24 +0200 Subject: [PATCH 5/5] Changes to work with local Metamask wallet. So far works with Geth --- scripts/launch_local_testnet.sh | 23 +++++++++++++++-------- scripts/nimbus_el_vars.sh | 2 +- scripts/run-catalyst.sh | 2 +- scripts/start_geth_nodes.sh | 30 ++++++++++++++---------------- scripts/start_nimbus_el_nodes.sh | 5 +++-- 5 files changed, 34 insertions(+), 28 deletions(-) diff --git a/scripts/launch_local_testnet.sh b/scripts/launch_local_testnet.sh index bc3a925be3..2f79eeb44a 100755 --- a/scripts/launch_local_testnet.sh +++ b/scripts/launch_local_testnet.sh @@ -12,6 +12,8 @@ set -eu +BASEDIR="$(dirname "${BASH_SOURCE[0]}")" + cd "$(dirname "${BASH_SOURCE[0]}")"/.. @@ -426,17 +428,20 @@ GETH_NUM_NODES="${NUM_NODES}" NIMBUSEL_NUM_NODES="${NUM_NODES}" if [[ "${RUN_GETH}" == "1" ]]; then - if [[ ! -e "${GETH_BINARY}" && "${DL_GETH}" == "1" ]]; then - log "Downloading geth ..." - download_geth - else - echo "Missing geth executable" - exit 1 + if [[ ! -e "${GETH_BINARY}" ]]; then + if [[ "${DL_GETH}" == "1" ]]; then + log "Downloading geth ..." + download_geth + else + echo "Missing geth executable" + exit 1 + fi fi log "Starting ${GETH_NUM_NODES} Geth Nodes ..." . "./scripts/start_geth_nodes.sh" EL_HTTP_PORTS+=("${GETH_HTTP_PORTS[@]}") + EL_RPC_PORTS+=("${GETH_RPC_PORTS[@]}") PROCS_TO_KILL+=("${GETH_BINARY}") CLEANUP_DIRS+=("${GETH_DATA_DIRS[@]}") fi @@ -449,6 +454,7 @@ if [[ "${RUN_NIMBUS}" == "1" ]]; then . "./scripts/start_nimbus_el_nodes.sh" EL_HTTP_PORTS+=("${NIMBUSEL_HTTP_PORTS[@]}") + EL_RPC_PORTS+=("${NIMBUSEL_RPC_PORTS[@]}") PROCS_TO_KILL+=("${NIMBUS_EL_BINARY}") CLEANUP_DIRS+=("${NIMBUSEL_DATA_DIRS[@]}") fi @@ -857,7 +863,7 @@ for NUM_NODE in $(seq 0 $(( NUM_NODES - 1 ))); do done fi - WEB3_ARG="--web3-url=http://127.0.0.1:${EL_HTTP_PORTS[${NUM_NODE}]}" + WEB3_ARG="--web3-url=http://127.0.0.1:${EL_RPC_PORTS[${NUM_NODE}]}" ${BEACON_NODE_COMMAND} \ @@ -874,6 +880,7 @@ for NUM_NODE in $(seq 0 $(( NUM_NODES - 1 ))); do --light-client-enable=on \ --light-client-data-serve=on \ --light-client-data-import-mode=only-new \ + --jwt-secret=/tmp/jwtsecret \ ${EXTRA_ARGS} \ &> "${DATA_DIR}/log${NUM_NODE}.txt" & @@ -928,7 +935,7 @@ if [ "$LC_NODES" -ge "1" ]; then while :; do CURRENT_FORK_EPOCH="$( "${CURL_BINARY}" -s "http://localhost:${BASE_REST_PORT}/eth/v1/beacon/states/finalized/fork" | \ - tee -a curl_result.txt | "${JQ_BINARY}" -r '.data.epoch')" + "${JQ_BINARY}" -r '.data.epoch')" if [ "${CURRENT_FORK_EPOCH}" -ge "${ALTAIR_FORK_EPOCH}" ]; then break fi diff --git a/scripts/nimbus_el_vars.sh b/scripts/nimbus_el_vars.sh index e24fbf6377..70dbaa2d22 100644 --- a/scripts/nimbus_el_vars.sh +++ b/scripts/nimbus_el_vars.sh @@ -1,4 +1,4 @@ -NIMBUSEL_DISCOVERY="--discovery=V5" +NIMBUSEL_DISCOVERY="--discovery=None" NIMBUSEL_PORT_OFFSET="${PORT_OFFSET:-100}" NIMBUSEL_BINARY="${NIMBUSEL_BINARY:-"${HOME}/work/nimbus-eth1/build/nimbus"}" diff --git a/scripts/run-catalyst.sh b/scripts/run-catalyst.sh index 0f1b76aab4..553080fc7e 100755 --- a/scripts/run-catalyst.sh +++ b/scripts/run-catalyst.sh @@ -53,4 +53,4 @@ echo \{\ ~/go-ethereum/build/bin/geth --http --ws -http.api "engine" --datadir "${GETHDATADIR}" account import <(echo 45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8) # Start the node (and press enter once to unlock the account) -~/go-ethereum/build/bin/geth --http --ws --http.api "eth,net,engine" -ws.api "eth,net,engine" --datadir "${GETHDATADIR}" --allow-insecure-unlock --unlock "0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b" --password "" --nodiscover console +~/go-ethereum/build/bin/geth --http --ws --http.api "eth,net,engine" -ws.api "eth,net,engine" --datadir "${GETHDATADIR}" --allow-insecure-unlock --unlock "0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b" --password "" --nodiscover --authrpc.jwtsecret /tmp/jwtsecret console diff --git a/scripts/start_geth_nodes.sh b/scripts/start_geth_nodes.sh index 67f0002eb3..b919a00e48 100755 --- a/scripts/start_geth_nodes.sh +++ b/scripts/start_geth_nodes.sh @@ -16,25 +16,23 @@ GETH_DATA_DIRS=() log "Using ${GETH_BINARY}" -for NUM_NODE in $(seq 0 $(( GETH_NUM_NODES - 1 ))); do - GETH_NET_PORT=$(( NUM_NODE * GETH_PORT_OFFSET + GETH_NET_BASE_PORT )) - GETH_HTTP_PORT=$(( NUM_NODE * GETH_PORT_OFFSET + GETH_HTTP_BASE_PORT )) - GETH_WS_PORT=$(( NUM_NODE * GETH_PORT_OFFSET + GETH_WS_BASE_PORT )) - GETH_AUTH_RPC_PORT=$(( NUM_NODE * GETH_PORT_OFFSET + GETH_AUTH_RPC_PORT_BASE )) - log "Starting geth node ${NUM_NODE} on net port ${GETH_NET_PORT} HTTP port ${GETH_HTTP_PORT} WS port ${GETH_WS_PORT}" - GETHDATADIR=$(mktemp -d geth-data-XXX) +for GETH_NUM_NODE in $(seq 0 $(( GETH_NUM_NODES - 1 ))); do + GETH_NET_PORT=$(( GETH_NUM_NODE * GETH_PORT_OFFSET + GETH_NET_BASE_PORT )) + GETH_HTTP_PORT=$(( GETH_NUM_NODE * GETH_PORT_OFFSET + GETH_HTTP_BASE_PORT )) + GETH_WS_PORT=$(( GETH_NUM_NODE * GETH_PORT_OFFSET + GETH_WS_BASE_PORT )) + GETH_AUTH_RPC_PORT=$(( GETH_NUM_NODE * GETH_PORT_OFFSET + GETH_AUTH_RPC_PORT_BASE )) + log "Starting geth node ${GETH_NUM_NODE} on net port ${GETH_NET_PORT} HTTP port ${GETH_HTTP_PORT} WS port ${GETH_WS_PORT}" + GETHDATADIR=$(mktemp -d "${DATA_DIR}"/geth-data-XXX) GETH_DATA_DIRS+=(${GETHDATADIR}) ${GETH_BINARY} --http --ws -http.api "engine" --datadir "${GETHDATADIR}" init "${GENESISJSON}" - #${GETH_BINARY} --http --ws -http.api "engine" --datadir "${GETHDATADIR}" account import <(echo 45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8) - #${GETH_BINARY} --http --ws --http.api "eth,net,engine" -ws.api "eth,net,engine" --datadir "${GETHDATADIR}" --allow-insecure-unlock --unlock "0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b" --password ${PASSWORDFILE} --nodiscover console - ${GETH_BINARY} --http --ws --http.api "eth,net,engine" -ws.api "eth,net,engine" --datadir "${GETHDATADIR}" ${DISCOVER} --port ${GETH_NET_PORT} --http.port ${GETH_HTTP_PORT=} --ws.port ${GETH_WS_PORT} --authrpc.port ${GETH_AUTH_RPC_PORT} &>/dev/null & + ${GETH_BINARY} --http --ws --http.corsdomain '*' --http.api "eth,net,engine" -ws.api "eth,net,engine" --datadir "${GETHDATADIR}" ${DISCOVER} --port ${GETH_NET_PORT} --http.port ${GETH_HTTP_PORT} --ws.port ${GETH_WS_PORT} --authrpc.port ${GETH_AUTH_RPC_PORT} --authrpc.jwtsecret /tmp/jwtsecret &> "${DATA_DIR}/geth-log${GETH_NUM_NODE}.txt" & sleep 5 NODE_ID=$(${GETH_BINARY} attach --datadir "${GETHDATADIR}" --exec admin.nodeInfo.enode) - GETH_ENODES+=(${NODE_ID}) - GETH_HTTP_PORTS+=(${GETH_HTTP_PORT}) - GETH_NET_PORTS+=(${GETH_NET_PORT}) - GETH_WS_PORTS+=(${GETH_WS_PORT}) - GETH_RPC_PORTS+=(${GETH_AUTH_RPC_PORT}) + GETH_ENODES+=("${NODE_ID}") + GETH_HTTP_PORTS+=("${GETH_HTTP_PORT}") + GETH_NET_PORTS+=("${GETH_NET_PORT}") + GETH_WS_PORTS+=("${GETH_WS_PORT}") + GETH_RPC_PORTS+=("${GETH_AUTH_RPC_PORT}") done #Add all nodes as peers @@ -42,7 +40,7 @@ for dir in "${GETH_DATA_DIRS[@]}" do for enode in "${GETH_ENODES[@]}" do - $(${GETH_BINARY} attach --datadir "${dir}" --exec "admin.addPeer(${enode})") + ${GETH_BINARY} attach --datadir "${dir}" --exec "admin.addPeer(${enode})" done done diff --git a/scripts/start_nimbus_el_nodes.sh b/scripts/start_nimbus_el_nodes.sh index 4448f95d58..ea4f854da6 100755 --- a/scripts/start_nimbus_el_nodes.sh +++ b/scripts/start_nimbus_el_nodes.sh @@ -24,8 +24,9 @@ for NUM_NODE in $(seq 0 $(( NIMBUSEL_NUM_NODES - 1 ))); do log "Starting nimbus EL node ${NUM_NODE} on net port ${NIMBUSEL_NET_PORT} HTTP port ${NIMBUSEL_HTTP_PORT} WS port ${NIMBUSEL_WS_PORT}" NIMBUSEL_DATADIR=$(mktemp -d nimbusel-data-XXX) NIMBUSEL_DATA_DIRS+=("${NIMBUSEL_DATADIR}") - ${NIMBUSEL_BINARY} --data-dir="${NIMBUSEL_DATADIR}" --custom-network="${NIMBUSEL_GENESIS}" "${NIMBUSEL_DISCOVERY}" --tcp-port="${NIMBUSEL_NET_PORT}" \ - --rpc --rpc-port="${NIMBUSEL_HTTP_PORT}" &>/dev/null & + ${NIMBUSEL_BINARY} --data-dir="${NIMBUSEL_DATADIR}" --custom-network="${NIMBUSEL_GENESIS}" "${NIMBUSEL_DISCOVERY}" \ + --tcp-port="${NIMBUSEL_NET_PORT}" --engine-api --engine-api-port="${NIMBUSEL_AUTH_RPC_PORT}" \ + --rpc --rpc-port="${NIMBUSEL_HTTP_PORT}" &> "${DATA_DIR}/nimbusel_log${NUM_NODE}.txt" & sleep 5 NODE_ID=$( "${CURL_BINARY}" -sS -X POST \