diff --git a/scripts/testnet/config.sh b/scripts/testnet/config.sh index 41463ba533e..2425b708ec8 100755 --- a/scripts/testnet/config.sh +++ b/scripts/testnet/config.sh @@ -28,13 +28,23 @@ updateNodeConfig if [ $USE_PROXY -eq 1 ]; then prepareFolders_Proxy copyProxyConfig - updateProxyConfig + + if [ $SOVEREIGN_DEPLOY -eq 1 ]; then + updateSovereignProxyConfig + else + updateProxyConfig + fi fi if [ $USE_TXGEN -eq 1 ]; then prepareFolders_TxGen copyTxGenConfig - updateTxGenConfig + + if [ $SOVEREIGN_DEPLOY -eq 1 ]; then + updateSovereignTxGenConfig + else + updateTxGenConfig + fi fi if [ $USE_HARDFORK -eq 1 ]; then diff --git a/scripts/testnet/deployFullStackSovereignChainWithScreen.sh b/scripts/testnet/deployFullStackSovereignChainWithScreen.sh new file mode 100644 index 00000000000..c9026c06201 --- /dev/null +++ b/scripts/testnet/deployFullStackSovereignChainWithScreen.sh @@ -0,0 +1,41 @@ +#!/usr/bin/env bash + +GREEN='\x1B[0;32m' +NC='\x1B[0m' + +echo -e "${GREEN}Making sure any previous deployment is stopped...${NC}" +./stop.sh + +echo -e "${GREEN}Cleaning the previous deployment (if any)...${NC}" +./clean.sh + +echo -e "${GREEN}Adjusting some variables.sh parameters...${NC}" +sed -i 's/export USE_TXGEN=[01]/export USE_TXGEN=1/' variables.sh +sed -i 's/export USE_PROXY=[01]/export USE_PROXY=1/' variables.sh +sed -i 's/export USE_ELASTICSEARCH=[01]/export USE_ELASTICSEARCH=1/' variables.sh +sed -i 's/export SOVEREIGN_DEPLOY=[01]/export SOVEREIGN_DEPLOY=1/' variables.sh + +source variables.sh +if [ "$SHARD_VALIDATORCOUNT" -lt 3 ]; then + sed -i 's/export SHARD_VALIDATORCOUNT=.*/export SHARD_VALIDATORCOUNT=3/' variables.sh +fi + +echo -e "${GREEN}Generating the configuration files...${NC}" +./config.sh + +echo -e "${GREEN}Starting the sovereign chain (in a screen)...${NC}" +screen -L -Logfile sovereignStartLog.txt -d -m -S sovereignStartScreen ./sovereignStart.sh debug + +echo -e "${GREEN}Sleeping few minutes so the sovereign chain will begin...${NC}" +sleep 120 + +echo -e "${GREEN}Starting sending the basic scenario transactions...${NC}" +screen -L -Logfile txgenBasicLog.txt -d -m -S txgenBasicScreen ./sovereign-txgen-basic.sh + +echo -e "${GREEN}Starting sending the erc20 scenario transactions...${NC}" +screen -L -Logfile txgenErc20Log.txt -d -m -S txgenErc20Screen ./sovereign-txgen-erc20.sh + +echo -e "${GREEN}Starting sending the esdt scenario transactions...${NC}" +screen -L -Logfile txgenEsdtLog.txt -d -m -S txgenEsdtScreen ./sovereign-txgen-esdt.sh + +echo -e "${GREEN}Finished the sovereign chain deployment. Don't forget to stop it with ./stop.sh at the end.${NC}" diff --git a/scripts/testnet/include/config.sh b/scripts/testnet/include/config.sh index 95abcf1571b..33c1c6cbe7e 100644 --- a/scripts/testnet/include/config.sh +++ b/scripts/testnet/include/config.sh @@ -8,6 +8,11 @@ generateConfig() { TMP_META_OBSERVERCOUNT=0 fi + SOVEREIGN_BOOL="false" + if [ $SOVEREIGN_DEPLOY -eq 1 ]; then + SOVEREIGN_BOOL="true" + fi + pushd $TESTNETDIR/filegen ./filegen \ -output-directory $CONFIGGENERATOROUTPUTDIR \ @@ -20,7 +25,7 @@ generateConfig() { -metachain-consensus-group-size $META_CONSENSUS_SIZE \ -stake-type $GENESIS_STAKE_TYPE \ -hysteresis $HYSTERESIS \ - -sovereign=$SOVEREIGN_DEPLOY + -sovereign=$SOVEREIGN_BOOL popd } @@ -146,6 +151,8 @@ updateNodeConfig() { sed -i '/^\[ElasticSearchConnector\]/,/^\[/ s/Enabled *= *false/Enabled = true/' external_observer.toml fi + sed -i '/^\[DbLookupExtensions\]/,/^\[/ s/Enabled *= *false/Enabled = true/' config_observer.toml + cp nodesSetup_edit.json nodesSetup.json rm nodesSetup_edit.json @@ -190,6 +197,23 @@ updateProxyConfig() { popd } +updateSovereignProxyConfig() { + pushd $TESTNETDIR/proxy/config + cp config.toml config_edit.toml + + # Truncate config.toml before the [[Observers]] list + sed -i -n '/\[\[Observers\]\]/q;p' config_edit.toml + + updateTOMLValue config_edit.toml "ServerPort" $PORT_PROXY + generateSovereignProxyObserverList config_edit.toml + + cp config_edit.toml config.toml + rm config_edit.toml + + echo "Updated configuration for the Sovereign Proxy." + popd +} + copyTxGenConfig() { pushd $TESTNETDIR @@ -221,6 +245,10 @@ updateTxGenConfig() { popd } +updateSovereignTxGenConfig() { + updateTxGenConfig + pushd $TESTNETDIR/txgen/config/nodeConfig/config +} generateProxyObserverList() { OBSERVER_INDEX=0 @@ -252,6 +280,31 @@ generateProxyObserverList() { done } +generateSovereignProxyObserverList() { + OBSERVER_INDEX=0 + OUTPUTFILE=$! + # Start Shard Observers + (( max_shard_id=$SHARDCOUNT - 1 )) + for SHARD in $(seq 0 1 $max_shard_id); do + for _ in $(seq $SHARD_OBSERVERCOUNT); do + (( PORT=$PORT_ORIGIN_OBSERVER_REST+$OBSERVER_INDEX)) + + echo "[[Observers]]" >> config_edit.toml + echo " ShardId = $SHARD" >> config_edit.toml + echo " Address = \"http://127.0.0.1:$PORT\"" >> config_edit.toml + echo ""$'\n' >> config_edit.toml + + # for sovereign shards, shard observers are also able to respond to Metachain related endpoints - useful so we can reuse the Proxy without changes + echo "[[Observers]]" >> config_edit.toml + echo " ShardId = $METASHARD_ID" >> config_edit.toml + echo " Address = \"http://127.0.0.1:$PORT\"" >> config_edit.toml + echo ""$'\n' >> config_edit.toml + + (( OBSERVER_INDEX++ )) + done + done +} + updateTOMLValue() { local filename=$1 local key=$2 diff --git a/scripts/testnet/variables.sh b/scripts/testnet/variables.sh index 033b08de83b..984e3cfc87d 100644 --- a/scripts/testnet/variables.sh +++ b/scripts/testnet/variables.sh @@ -60,10 +60,10 @@ export GENESIS_STAKE_TYPE="direct" #'delegated' or 'direct' as in direct stake #if set to 1, each observer will turn off the antiflooding capability, allowing spam in our network export OBSERVERS_ANTIFLOOD_DISABLE=0 -# If set to true, this will deploy nodes in a sovereign shard. +# If set to 1, this will deploy nodes in a sovereign shard. # All variables from metashard structure(validators, observers, consensus) should be set to zero and SHARDCOUNT to 1 # For now, make sure that you checkout feat/sovereign branch from mx-chain-deploy repo when using these scripts -export SOVEREIGN_DEPLOY=true +export SOVEREIGN_DEPLOY=1 # Shard structure export SHARDCOUNT=1 @@ -154,7 +154,7 @@ export NUMACCOUNTS="250" # Whether txgen should regenerate its accounts when starting, or not. # Recommended value is 1, but 0 is useful to run the txgen a second time, to # continue a testing session on the same accounts. -export TXGEN_REGENERATE_ACCOUNTS=0 +export TXGEN_REGENERATE_ACCOUNTS=1 # COPY_BACK_CONFIGS when set to 1 will copy back the configs and keys to the ./cmd/node/config directory # in order to have a node in the IDE that can run a node in debug mode but in the same network with the rest of the nodes