Skip to content

Commit

Permalink
Merge pull request #5827 from multiversx/MX-14982-sovereign-scripting…
Browse files Browse the repository at this point in the history
…-files

scripting files updates for sovereign
  • Loading branch information
axenteoctavian authored Jan 25, 2024
2 parents b021692 + 8ce0176 commit a8de4a2
Show file tree
Hide file tree
Showing 4 changed files with 110 additions and 6 deletions.
14 changes: 12 additions & 2 deletions scripts/testnet/config.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
41 changes: 41 additions & 0 deletions scripts/testnet/deployFullStackSovereignChainWithScreen.sh
Original file line number Diff line number Diff line change
@@ -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}"
55 changes: 54 additions & 1 deletion scripts/testnet/include/config.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
Expand All @@ -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
}

Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -221,6 +245,10 @@ updateTxGenConfig() {
popd
}

updateSovereignTxGenConfig() {
updateTxGenConfig
pushd $TESTNETDIR/txgen/config/nodeConfig/config
}

generateProxyObserverList() {
OBSERVER_INDEX=0
Expand Down Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions scripts/testnet/variables.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit a8de4a2

Please sign in to comment.