mirror of
https://github.com/status-im/nimbus-eth2.git
synced 2025-01-26 22:39:49 +00:00
Add support for launching Geth and Nimbus-eth1 nodes in launch_local_testnet (#3790)
* Add support for launching Geth and Nimbus-eth1 nodes in launch_local_simulation * Prevent undefined variables errors when Nimbus and Geth are not launched Co-authored-by: Nikolay Mitev <github@hmel.org>
This commit is contained in:
parent
07f9936b33
commit
b318a74d83
44
scripts/geth_genesis.json
Normal file
44
scripts/geth_genesis.json
Normal file
@ -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"
|
||||
}
|
13
scripts/geth_vars.sh
Normal file
13
scripts/geth_vars.sh
Normal file
@ -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"
|
||||
|
@ -10,9 +10,18 @@
|
||||
# Mostly a duplication of "tests/simulation/{start.sh,run_node.sh}", but with a focus on
|
||||
# replicating testnets as closely as possible, which means following the Docker execution labyrinth.
|
||||
|
||||
set -eu
|
||||
set -euo pipefail
|
||||
|
||||
cd "$(dirname "${BASH_SOURCE[0]}")"/..
|
||||
BASEDIR="$(dirname "${BASH_SOURCE[0]}")"
|
||||
cd "$BASEDIR/.."
|
||||
|
||||
VERBOSE="0"
|
||||
|
||||
log() {
|
||||
if [[ "${VERBOSE}" -ge "1" ]]; then
|
||||
echo "${@}"
|
||||
fi
|
||||
}
|
||||
|
||||
# OS detection
|
||||
OS="linux"
|
||||
@ -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:,light-clients:,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:,light-clients:,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"
|
||||
@ -73,6 +83,17 @@ REMOTE_SIGNER_NODES=0
|
||||
REMOTE_SIGNER_THRESHOLD=1
|
||||
REMOTE_VALIDATORS_COUNT=0
|
||||
LC_NODES=1
|
||||
ACCOUNT_PASSWORD="nimbus"
|
||||
RUN_GETH="0"
|
||||
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 <<EOF
|
||||
@ -108,6 +129,10 @@ CI run: $(basename "$0") --disable-htop -- --verify-finalization
|
||||
restore signature of the original secret key
|
||||
--remote-signers number of remote signing nodes
|
||||
--light-clients number of light clients
|
||||
--run-nimbus-el Run nimbush-eth1 as EL
|
||||
--run-geth Run geth EL clients
|
||||
--dl-geth Download geth binary if not found
|
||||
--verbose Verbose output
|
||||
EOF
|
||||
}
|
||||
|
||||
@ -217,6 +242,22 @@ while true; do
|
||||
LC_NODES="$2"
|
||||
shift 2
|
||||
;;
|
||||
--run-geth)
|
||||
RUN_GETH="1"
|
||||
shift
|
||||
;;
|
||||
--dl-geth)
|
||||
DL_GETH="1"
|
||||
shift
|
||||
;;
|
||||
--run-nimbus-el)
|
||||
RUN_NIMBUS="1"
|
||||
shift
|
||||
;;
|
||||
--verbose)
|
||||
VERBOSE="1"
|
||||
shift
|
||||
;;
|
||||
--)
|
||||
shift
|
||||
break
|
||||
@ -235,6 +276,7 @@ if [[ $# != 0 ]]; then
|
||||
fi
|
||||
|
||||
if [[ "$REUSE_EXISTING_DATA_DIR" == "0" ]]; then
|
||||
log "Deleting ${DATA_DIR}"
|
||||
rm -rf "${DATA_DIR}"
|
||||
fi
|
||||
|
||||
@ -268,18 +310,71 @@ else
|
||||
NPROC="$(nproc)"
|
||||
fi
|
||||
|
||||
if [[ "${RUN_NIMBUS}" == "1" && "${RUN_GETH}" == "1" ]]; then
|
||||
echo "Use only one EL - geth or nimbus"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
||||
if [[ "${RUN_GETH}" == "1" ]]; then
|
||||
. ./scripts/geth_vars.sh
|
||||
fi
|
||||
|
||||
if [[ "${RUN_NIMBUS}" == "1" ]]; then
|
||||
. ./scripts/nimbus_el_vars.sh
|
||||
fi
|
||||
|
||||
|
||||
# kill lingering processes from a previous run
|
||||
if [[ "${OS}" != "windows" ]]; then
|
||||
which lsof &>/dev/null || \
|
||||
{ echo "'lsof' not installed and we need it to check for ports already in use. Aborting."; exit 1; }
|
||||
|
||||
|
||||
#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
|
||||
for PID in $(lsof -n -i tcp:${PORT} -sTCP:LISTEN -t); do
|
||||
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
|
||||
@ -289,6 +384,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}"
|
||||
@ -311,6 +473,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"
|
||||
@ -358,6 +521,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
|
||||
@ -366,17 +530,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
|
||||
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
|
||||
|
||||
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.
|
||||
@ -389,7 +555,16 @@ cleanup() {
|
||||
if [[ -n "$ETH2_DOCKER_IMAGE" ]]; then
|
||||
docker rm $(docker stop $(docker ps -a -q --filter ancestor=$ETH2_DOCKER_IMAGE --format="{{.ID}}"))
|
||||
fi
|
||||
|
||||
if [ ${#CLEANUP_DIRS[@]} -ne 0 ]; then # check if the array is empty
|
||||
for dir in "${CLEANUP_DIRS[@]}"
|
||||
do
|
||||
log "Deleting ${dir}"
|
||||
rm -rf "${dir}"
|
||||
done
|
||||
fi
|
||||
}
|
||||
|
||||
trap 'cleanup' SIGINT SIGTERM EXIT
|
||||
|
||||
# timeout - implemented with a background job
|
||||
@ -413,7 +588,6 @@ done
|
||||
|
||||
# deposit and testnet creation
|
||||
PIDS=""
|
||||
WEB3_ARG=""
|
||||
BOOTSTRAP_TIMEOUT=30 # in seconds
|
||||
DEPOSIT_CONTRACT_ADDRESS="0x0000000000000000000000000000000000000000"
|
||||
DEPOSIT_CONTRACT_BLOCK="0x0000000000000000000000000000000000000000000000000000000000000000"
|
||||
@ -546,16 +720,24 @@ 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 [ "${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 ))
|
||||
@ -672,6 +854,12 @@ for NUM_NODE in $(seq 0 $(( NUM_NODES - 1 ))); do
|
||||
done
|
||||
fi
|
||||
|
||||
if [ ${#EL_HTTP_PORTS[@]} -eq 0 ]; then # check if the array is empty
|
||||
WEB3_ARG=""
|
||||
else
|
||||
WEB3_ARG="--web3-url=http://127.0.0.1:${EL_HTTP_PORTS[${NUM_NODE}]}"
|
||||
fi
|
||||
|
||||
${BEACON_NODE_COMMAND} \
|
||||
--config-file="${CLI_CONF_FILE}" \
|
||||
--tcp-port=$(( BASE_PORT + NUM_NODE )) \
|
||||
@ -740,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" | \
|
||||
|
15
scripts/nimbus_el_vars.sh
Normal file
15
scripts/nimbus_el_vars.sh
Normal file
@ -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}
|
||||
|
44
scripts/nimbusel_genesis.json
Normal file
44
scripts/nimbusel_genesis.json
Normal file
@ -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"
|
||||
}
|
49
scripts/start_geth_nodes.sh
Executable file
49
scripts/start_geth_nodes.sh
Executable file
@ -0,0 +1,49 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
BASEDIR="$(dirname "${BASH_SOURCE[0]}")"
|
||||
|
||||
. "${BASEDIR}/geth_vars.sh"
|
||||
|
||||
#These are used in the caller script
|
||||
GETH_ENODES=()
|
||||
GETH_HTTP_PORTS=()
|
||||
GETH_NET_PORTS=()
|
||||
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 * 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}"
|
||||
#${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
|
||||
|
||||
log "GETH HTTP Ports: ${GETH_HTTP_PORTS[*]}"
|
54
scripts/start_nimbus_el_nodes.sh
Executable file
54
scripts/start_nimbus_el_nodes.sh
Executable file
@ -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[*]}"
|
Loading…
x
Reference in New Issue
Block a user