Bugfix: the testnet nim flags were not being passed to Docker properly [skip ci]

This commit is contained in:
Zahary Karadjov 2019-11-13 01:27:46 +00:00
parent f40675509a
commit 9af418c30d
No known key found for this signature in database
GPG Key ID: C8936F8A3073D609
4 changed files with 35 additions and 35 deletions

View File

@ -24,11 +24,9 @@ RUN export GOROOT=/usr/local/go \
&& cp docker/run_in_docker.sh /usr/bin/run_beacon_node.sh
ARG NETWORK
ARG NETWORK_TYPE
ARG NETWORK_NIM_FLAGS
RUN cd nim-beacon-chain \
&& set -a \
&& . scripts/load-testnet-nim-flags.sh scripts/${NETWORK}.env \
&& ./env.sh nim \
-o:/usr/bin/beacon_node \
-d:release \
@ -38,7 +36,7 @@ RUN cd nim-beacon-chain \
--verbosity:0 \
--hints:off \
--warnings:off \
${TESTNET_NIM_FLAGS} \
${NETWORK_NIM_FLAGS} \
-d:"chronicles_log_level=DEBUG" \
-d:"testnet_servers_image" \
c beacon_chain/beacon_node.nim

View File

@ -1,9 +1,8 @@
# These default settings can be overriden by exporting env variables
GIT_REVISION ?= $(shell git rev-parse HEAD)
NETWORK ?= testnet1
NETWORK_TYPE ?= libp2p
GIT_REVISION ?= $(shell git rev-parse HEAD)
NETWORK ?= testnet1
NETWORK_NIM_FLAGS ?= $(shell ../scripts/load-testnet-nim-flags.sh $(NETWORK))
IMAGE_TAG ?= $(NETWORK)
IMAGE_NAME ?= statusteam/nimbus_beacon_node:$(IMAGE_TAG)
@ -12,7 +11,7 @@ build:
docker build \
--build-arg="GIT_REVISION=$(GIT_REVISION)" \
--build-arg="NETWORK=$(NETWORK)" \
--build-arg="NETWORK_TYPE=$(NETWORK_TYPE)" \
--build-arg="NETWORK_NIM_FLAGS=$(NETWORK_NIM_FLAGS)" \
-t $(IMAGE_NAME) .
push: build

28
scripts/load-testnet-nim-flags.sh Normal file → Executable file
View File

@ -1,21 +1,25 @@
#!/bin/bash
set -e
cd $(dirname "$0")
set -a
source $1
source $1.env
set +a
TESTNET_NIM_FLAGS=""
NIM_FLAGS=""
testnet_env () {
eval "TESTNET_FLAG_VALUE=\$$1"
if [[ ! -z "$TESTNET_FLAG_VALUE" ]]; then
TESTNET_NIM_FLAGS+=" -d:$1=$TESTNET_FLAG_VALUE"
add_var () {
if [[ ! -z "${!1}" ]]; then
NIM_FLAGS+="-d:$1=${!1} "
fi
}
testnet_env CONST_PRESET
testnet_env NETWORK_TYPE
testnet_env SLOTS_PER_EPOCH
testnet_env SLOTS_PER_EPOCH
testnet_env MAX_COMMITTEES_PER_SLOT
add_var CONST_PRESET
add_var NETWORK_TYPE
add_var SLOTS_PER_EPOCH
add_var SLOTS_PER_EPOCH
add_var MAX_COMMITTEES_PER_SLOT
export TESTNET_NIM_FLAGS
echo $NIM_FLAGS

View File

@ -4,8 +4,9 @@ set -eu
cd $(dirname "$0")
NETWORK_NAME=$1
source load-testnet-nim-flags.sh $NETWORK_NAME.env
export NETWORK=$1
export NETWORK_NIM_FLAGS=$(./load-testnet-nim-flags.sh $NETWORK)
export GIT_REVISION=$(git rev-parse HEAD)
cd ..
@ -16,13 +17,14 @@ fi
echo Execution plan:
echo "Testnet name : $NETWORK_NAME"
echo "Testnet name : $NETWORK"
echo "Bootstrap node hostname : ${BOOTSTRAP_HOST:="master-01.do-ams3.nimbus.test.statusim.net"}"
echo "Bootstrap node ip : ${BOOTSTRAP_IP:="$(dig +short $BOOTSTRAP_HOST)"}"
echo "Reset testnet at end : ${PUBLISH_TESTNET_RESETS:="1"}"
echo "Testnet metadata repo : ${ETH2_TESTNETS_GIT_URL:="git@github.com:${ETH2_TESTNETS_ORG:=eth2-clients}/eth2-testnets"}"
echo "Testnet metadata dir : ${ETH2_TESTNETS:="build/eth2-testnets"}"
echo "Beacon node data dir : ${DATA_DIR:="build/testnet-reset-data"}"
echo "Nim build flags : $NETWORK_NIM_FLAGS"
while true; do
read -p "Continue?" yn
@ -37,7 +39,7 @@ rm -rf "$ETH2_TESTNETS"
git clone --quiet --depth=1 $ETH2_TESTNETS_GIT_URL "$ETH2_TESTNETS"
ETH2_TESTNETS_ABS=$(cd "$ETH2_TESTNETS"; pwd)
NETWORK_DIR_ABS="$ETH2_TESTNETS_ABS/nimbus/$NETWORK_NAME"
NETWORK_DIR_ABS="$ETH2_TESTNETS_ABS/nimbus/$NETWORK"
DATA_DIR_ABS=$(mkdir -p "$DATA_DIR"; cd "$DATA_DIR"; pwd)
DEPOSITS_DIR_ABS="$DATA_DIR_ABS/deposits"
DEPOSIT_CONTRACT_ADDRESS=""
@ -49,7 +51,7 @@ fi
mkdir -p "$DEPOSITS_DIR_ABS"
DOCKER_BEACON_NODE="docker run -v $DEPOSITS_DIR_ABS:/deposits_dir -v $NETWORK_DIR_ABS:/network_dir -v $DATA_DIR_ABS:/data_dir statusteam/nimbus_beacon_node:$NETWORK_NAME"
DOCKER_BEACON_NODE="docker run -v $DEPOSITS_DIR_ABS:/deposits_dir -v $NETWORK_DIR_ABS:/network_dir -v $DATA_DIR_ABS:/data_dir statusteam/nimbus_beacon_node:$NETWORK"
make deposit_contract
@ -61,9 +63,6 @@ if [ "$ETH1_PRIVATE_KEY" != "" ]; then
fi
cd docker
export NETWORK=$NETWORK_NAME
export GIT_REVISION=$(git rev-parse HEAD)
make build
$DOCKER_BEACON_NODE makeDeposits \
@ -84,12 +83,12 @@ $DOCKER_BEACON_NODE \
--bootstrap-address=$BOOTSTRAP_IP \
--bootstrap-port=$BOOTSTRAP_PORT \
$WEB3_URL_ARG $DEPOSIT_CONTRACT_ADDRESS_ARG \
--genesis-offset=60 # Delay in seconds
--genesis-offset=900 # Delay in seconds
COMMITTED_FILES=" genesis.ssz bootstrap_nodes.txt "
if [[ ! -z "$DEPOSIT_CONTRACT_ADDRESS" ]]; then
echo $DEPOSIT_CONTRACT_ADDRESS > "$ETH2_TESTNETS_ABS/nimbus/$NETWORK_NAME/deposit_contract.txt"
echo $DEPOSIT_CONTRACT_ADDRESS > "$ETH2_TESTNETS_ABS/nimbus/$NETWORK/deposit_contract.txt"
COMMITTED_FILES+=" deposit_contract.txt "
fi
@ -99,7 +98,7 @@ if [[ $PUBLISH_TESTNET_RESETS != "0" ]]; then
# The reasons for this are unclear at the moment.
../env.sh nim --verbosity:0 manage_testnet_hosts.nims reset_network \
--network=$NETWORK_NAME \
--network=$NETWORK \
--deposits-dir="$DEPOSITS_DIR_ABS" \
--network-data-dir="$NETWORK_DIR_ABS" \
--user-validators=$QUICKSTART_VALIDATORS \
@ -109,7 +108,7 @@ if [[ $PUBLISH_TESTNET_RESETS != "0" ]]; then
bash /tmp/reset-network.sh
echo Uploading bootstrap node network key
BOOTSTRAP_NODE_DOCKER_PATH=/docker/beacon-node-$NETWORK_NAME-1/data/BeaconNode/
BOOTSTRAP_NODE_DOCKER_PATH=/docker/beacon-node-$NETWORK-1/data/BeaconNode/
scp "$DATA_DIR_ABS/privkey.protobuf" $BOOTSTRAP_HOST:/tmp/
ssh $BOOTSTRAP_HOST "sudo install -o dockremap -g docker /tmp/privkey.protobuf $BOOTSTRAP_NODE_DOCKER_PATH"
@ -119,12 +118,12 @@ if [[ $PUBLISH_TESTNET_RESETS != "0" ]]; then
echo Persisting testnet data to git...
pushd "$NETWORK_DIR_ABS"
git add $COMMITTED_FILES
git commit -m "Reset of Nimbus $NETWORK_NAME"
git commit -m "Reset of Nimbus $NETWORK"
git push
popd
../env.sh nim --verbosity:0 manage_testnet_hosts.nims restart_nodes \
--network=$NETWORK_NAME \
--network=$NETWORK \
> /tmp/restart-nodes.sh
bash /tmp/restart-nodes.sh