2019-03-19 19:50:22 +00:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
set -eu
|
|
|
|
|
|
|
|
cd $(dirname "$0")
|
|
|
|
|
|
|
|
NETWORK_NAME=$1
|
|
|
|
source "$NETWORK_NAME.env"
|
|
|
|
|
|
|
|
cd ..
|
|
|
|
|
|
|
|
if [ -f .env ]; then
|
|
|
|
# allow server overrides for WWW_DIR and DATA_DIR
|
|
|
|
source .env
|
|
|
|
fi
|
|
|
|
|
|
|
|
PUBLIC_IP=$(curl -s ifconfig.me)
|
|
|
|
NETWORK_DIR=$WWW_DIR/$NETWORK_NAME
|
|
|
|
|
2019-06-24 12:57:22 +00:00
|
|
|
NIM_FLAGS="-d:release -d:SECONDS_PER_SLOT=$SECONDS_PER_SLOT -d:SHARD_COUNT=$SHARD_COUNT -d:SLOTS_PER_EPOCH=$SLOTS_PER_EPOCH ${2:-}"
|
|
|
|
|
2019-09-01 15:02:49 +00:00
|
|
|
nim c -d:"network_type=$NETWORK_TYPE" $NIM_FLAGS beacon_chain/beacon_node
|
|
|
|
|
2019-06-24 12:57:22 +00:00
|
|
|
if [ ! -f $NETWORK_DIR/genesis.json ]; then
|
|
|
|
rm -f $NETWORK_DIR/*
|
2019-09-01 15:02:49 +00:00
|
|
|
beacon_chain/beacon_node makeDeposits \
|
|
|
|
--totalDeposits=$VALIDATOR_COUNT \
|
|
|
|
--depositDir="$NETWORK_DIR" \
|
|
|
|
--randomKeys=true
|
2019-06-24 12:57:22 +00:00
|
|
|
fi
|
|
|
|
|
2019-09-01 15:02:49 +00:00
|
|
|
beacon_chain/beacon_node \
|
2019-06-24 12:57:22 +00:00
|
|
|
--network=$NETWORK_NAME \
|
|
|
|
--dataDir=$DATA_DIR/node-0 \
|
|
|
|
createTestnet \
|
|
|
|
--validatorsDir=$NETWORK_DIR \
|
|
|
|
--totalValidators=$VALIDATOR_COUNT \
|
|
|
|
--lastUserValidator=$LAST_USER_VALIDATOR \
|
|
|
|
--outputGenesis=$NETWORK_DIR/genesis.json \
|
|
|
|
--outputNetwork=$NETWORK_DIR/network.json \
|
|
|
|
--bootstrapAddress=$PUBLIC_IP \
|
|
|
|
--bootstrapPort=$BOOTSTRAP_PORT \
|
|
|
|
--genesisOffset=600 # Delay in seconds
|