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

View File

@ -1,9 +1,8 @@
# These default settings can be overriden by exporting env variables # These default settings can be overriden by exporting env variables
GIT_REVISION ?= $(shell git rev-parse HEAD) GIT_REVISION ?= $(shell git rev-parse HEAD)
NETWORK ?= testnet1
NETWORK ?= testnet1 NETWORK_NIM_FLAGS ?= $(shell ../scripts/load-testnet-nim-flags.sh $(NETWORK))
NETWORK_TYPE ?= libp2p
IMAGE_TAG ?= $(NETWORK) IMAGE_TAG ?= $(NETWORK)
IMAGE_NAME ?= statusteam/nimbus_beacon_node:$(IMAGE_TAG) IMAGE_NAME ?= statusteam/nimbus_beacon_node:$(IMAGE_TAG)
@ -12,7 +11,7 @@ build:
docker build \ docker build \
--build-arg="GIT_REVISION=$(GIT_REVISION)" \ --build-arg="GIT_REVISION=$(GIT_REVISION)" \
--build-arg="NETWORK=$(NETWORK)" \ --build-arg="NETWORK=$(NETWORK)" \
--build-arg="NETWORK_TYPE=$(NETWORK_TYPE)" \ --build-arg="NETWORK_NIM_FLAGS=$(NETWORK_NIM_FLAGS)" \
-t $(IMAGE_NAME) . -t $(IMAGE_NAME) .
push: build 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 set -a
source $1 source $1.env
set +a set +a
TESTNET_NIM_FLAGS="" NIM_FLAGS=""
testnet_env () { add_var () {
eval "TESTNET_FLAG_VALUE=\$$1" if [[ ! -z "${!1}" ]]; then
if [[ ! -z "$TESTNET_FLAG_VALUE" ]]; then NIM_FLAGS+="-d:$1=${!1} "
TESTNET_NIM_FLAGS+=" -d:$1=$TESTNET_FLAG_VALUE"
fi fi
} }
testnet_env CONST_PRESET add_var CONST_PRESET
testnet_env NETWORK_TYPE add_var NETWORK_TYPE
testnet_env SLOTS_PER_EPOCH add_var SLOTS_PER_EPOCH
testnet_env SLOTS_PER_EPOCH add_var SLOTS_PER_EPOCH
testnet_env MAX_COMMITTEES_PER_SLOT add_var MAX_COMMITTEES_PER_SLOT
export TESTNET_NIM_FLAGS echo $NIM_FLAGS

View File

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