Testnet reset script fixes

This commit is contained in:
Zahary Karadjov 2019-10-29 05:58:31 +02:00
parent 831b562435
commit f5fb4277b4
No known key found for this signature in database
GPG Key ID: C8936F8A3073D609
3 changed files with 25 additions and 13 deletions

View File

@ -1,5 +1,5 @@
import import
strformat strformat, ospaths
var var
serverCount = 10 serverCount = 10
@ -36,11 +36,20 @@ case cmd
of "restart-nodes": of "restart-nodes":
for n in nodes(): for n in nodes():
echo &"ssh {n.server} docker restart {n.container}" echo &"ssh {n.server} docker restart {n.container}"
of "redist-validators": of "redist-validators":
let depositsDir = paramStr(5)
for n in nodes(): for n in nodes():
var keysList = ""
for i in n.firstValidator..n.lastValidator:
let validatorKey = fmt"v{i:07}.privkey"
keysList.add " "
keysList.add depositsDir / validatorKey
let dockerPath = &"/docker/{n.container}/data/BeaconNode/{network}" let dockerPath = &"/docker/{n.container}/data/BeaconNode/{network}"
echo &"rsync {keysList} {n.server}:/tmp/nimbus-keys"
echo &"ssh {n.server} 'sudo mkdir -p {dockerPath}/validators && sudo rm -f {dockerPath}/validators/* && " & echo &"ssh {n.server} 'sudo mkdir -p {dockerPath}/validators && sudo rm -f {dockerPath}/validators/* && " &
&"sudo ~/nimbus/vendor/nim-beacon-chain/scripts/download_validator_keys.sh {network} {n.firstValidator} {n.lastValidator} {dockerPath} && " & &"sudo mv /tmp/nimbus-keys/* {dockerPath}/validators/ && " &
&"sudo chown dockremap:docker -R {dockerPath}'" &"sudo chown dockremap:docker -R {dockerPath}'"
else: else:
echo "Unrecognized command: ", cmd echo "Unrecognized command: ", cmd

View File

@ -1,4 +1,3 @@
#!/bin/bash #!/bin/bash
# Deal with previous execution of the deamon leaving behind # Deal with previous execution of the deamon leaving behind

View File

@ -38,17 +38,22 @@ if [[ ! -d "$ETH2_TESTNETS" ]]; then
fi fi
ETH2_TESTNETS_ABS=$(cd "$ETH2_TESTNETS"; pwd) ETH2_TESTNETS_ABS=$(cd "$ETH2_TESTNETS"; pwd)
DATA_DIR_ABS=$(mkdir -p "$DATA_DIR"; cd "$DATA_DIR"; pwd)
NETWORK_DIR_ABS="$ETH2_TESTNETS_ABS/nimbus/$NETWORK_NAME" NETWORK_DIR_ABS="$ETH2_TESTNETS_ABS/nimbus/$NETWORK_NAME"
DATA_DIR_ABS=$(mkdir -p "$DATA_DIR"; cd "$DATA_DIR"; pwd)
DEPOSITS_DIR_ABS="$DATA_DIR_ABS/deposits"
if [ "$WEB3_URL" != "" ]; then if [ "$WEB3_URL" != "" ]; then
WEB3_URL_ARG="--web3-url=$WEB3_URL" WEB3_URL_ARG="--web3-url=$WEB3_URL"
fi fi
DOCKER_BEACON_NODE="docker run -v $NETWORK_DIR_ABS:/network_dir -v $DATA_DIR_ABS:/data_dir statusteam/nimbus_beacon_node:$NETWORK_NAME" 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"
make deposit_contract make deposit_contract
DEPOSIT_CONTRACT_ADDRESS_ARG=""
if [ "$ETH1_PRIVATE_KEY" != "" ]; then if [ "$ETH1_PRIVATE_KEY" != "" ]; then
DEPOSIT_CONTRACT_ADDRESS=$(./build/deposit_contract deploy $WEB3_URL_ARG --private-key=$ETH1_PRIVATE_KEY) DEPOSIT_CONTRACT_ADDRESS=$(./build/deposit_contract deploy $WEB3_URL_ARG --private-key=$ETH1_PRIVATE_KEY)
DEPOSIT_CONTRACT_ADDRESS_ARG="--deposit-contract=$DEPOSIT_CONTRACT_ADDRESS" DEPOSIT_CONTRACT_ADDRESS_ARG="--deposit-contract=$DEPOSIT_CONTRACT_ADDRESS"
@ -56,26 +61,25 @@ fi
cd docker cd docker
export GIT_REVISION=$(git rev-parse HEAD) make build NETWORK=$NETWORK_NAME GIT_REVISION=$(git rev-parse HEAD)
make build
if [ ! -f $NETWORK_DIR_ABS/genesis.ssz ]; then if [ ! -f $NETWORK_DIR_ABS/genesis.ssz ]; then
rm -f $NETWORK_DIR_ABS/* rm -f $NETWORK_DIR_ABS/*
$DOCKER_BEACON_NODE makeDeposits \ $DOCKER_BEACON_NODE makeDeposits \
--quickstart-deposits=$QUICKSTART_VALIDATORS \ --quickstart-deposits=$QUICKSTART_VALIDATORS \
--random-deposits=$RANDOM_VALIDATORS \ --random-deposits=$RANDOM_VALIDATORS \
--deposits-dir=/network_dir --deposits-dir=/deposits_dir
fi fi
TOTAL_VALIDATORS="$(( $QUICKSTART_VALIDATORS + $RANDOM_VALIDATORS_COUNT ))" TOTAL_VALIDATORS="$(( $QUICKSTART_VALIDATORS + $RANDOM_VALIDATORS ))"
$DOCKER_BEACON_NODE \ $DOCKER_BEACON_NODE \
--network=$NETWORK_NAME \ --network=$NETWORK_NAME \
--data-dir=/data_dir \ --data-dir=/data_dir \
createTestnet \ createTestnet \
--validators-dir=/network_dir \ --validators-dir=/deposits_dir \
--total-validators=$TOTAL_VALIDATORS \ --total-validators=$TOTAL_VALIDATORS \
--last-user-validator=$LAST_USER_VALIDATOR \ --last-user-validator=$QUICKSTART_VALIDATORS \
--output-genesis=/network_dir/genesis.ssz \ --output-genesis=/network_dir/genesis.ssz \
--output-bootstrap-file=/network_dir/bootstrap_nodes.txt \ --output-bootstrap-file=/network_dir/bootstrap_nodes.txt \
--bootstrap-address=$BOOTSTRAP_IP \ --bootstrap-address=$BOOTSTRAP_IP \
@ -90,7 +94,7 @@ fi
if [[ $PUBLISH_TESTNET_RESETS != "0" ]]; then if [[ $PUBLISH_TESTNET_RESETS != "0" ]]; then
echo Persisting testnet data to git... echo Persisting testnet data to git...
pushd "$ETH2_TESTNETS_ABS" pushd "$ETH2_TESTNETS_ABS"
git add --all git add genesis.ssz bootstrap_nodes.txt deposit_contract.txt
git commit -m "Reset of Nimbus $NETWORK_NAME" git commit -m "Reset of Nimbus $NETWORK_NAME"
git push git push
popd popd
@ -98,7 +102,7 @@ if [[ $PUBLISH_TESTNET_RESETS != "0" ]]; then
echo Redistributing validator keys to server nodes... echo Redistributing validator keys to server nodes...
# TODO If we try to use direct piping here, bash doesn't execute all of the commands. # TODO If we try to use direct piping here, bash doesn't execute all of the commands.
# The reasons for this are unclear at the moment. # The reasons for this are unclear at the moment.
nim --verbosity:0 manage_testnet_hosts.nims $NETWORK_NAME redist-validators > /tmp/reset-network.sh nim --verbosity:0 manage_testnet_hosts.nims $NETWORK_NAME redist-validators $DEPOSITS_DIR_ABS > /tmp/reset-network.sh
bash /tmp/reset-network.sh bash /tmp/reset-network.sh
echo Uploading bootstrap node network key echo Uploading bootstrap node network key