Update local-testnet-simulation with changes from kiln-dev-auth branch

This commit is contained in:
Nikolay Mitev 2022-06-28 13:33:49 +02:00
parent d1581a2d8c
commit a48d741022
4 changed files with 34 additions and 30 deletions

View File

@ -55,7 +55,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:,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"
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:-""}"
@ -82,7 +82,7 @@ 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"
DL_GETH="0"
@ -424,17 +424,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
@ -447,6 +450,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
@ -854,10 +858,10 @@ 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
if [ ${#EL_RPC_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}]}"
WEB3_ARG="--web3-url=http://127.0.0.1:${EL_RPC_PORTS[${NUM_NODE}]}"
fi
${BEACON_NODE_COMMAND} \
@ -874,6 +878,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 +933,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

View File

@ -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"}"

View File

@ -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

View File

@ -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 \