From 1843693b4ce7e568b13800d96d8e2ab682e42a3d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stefan=20Negovanovi=C4=87?= Date: Mon, 9 Oct 2023 09:30:26 +0200 Subject: [PATCH] Provide relayer flag only for the polybft and simplify starting nodes function --- scripts/cluster | 56 ++++++++++++++++++++++--------------------------- 1 file changed, 25 insertions(+), 31 deletions(-) diff --git a/scripts/cluster b/scripts/cluster index 46903f7d55..1512cb0628 100755 --- a/scripts/cluster +++ b/scripts/cluster @@ -29,7 +29,7 @@ if [[ "$dp_error_flag" -eq 1 ]]; then exit 1 fi -function showhelp(){ +function showhelp() { echo "Usage: cluster {consensus} [{command}] [{flags}]" echo "Consensus:" echo " ibft Start Supernets test environment locally with ibft consensus" @@ -161,36 +161,30 @@ function initRootchain() { } function startServerFromBinary() { - if [ "$1" == "write-logs" ]; then + write_logs_arg="" + if [ "$2" == "write-logs" ]; then echo "Writing validators logs to the files..." - ./polygon-edge server --data-dir ./test-chain-1 --chain genesis.json \ - --grpc-address :10000 --libp2p :30301 --jsonrpc :10002 --relayer \ - --num-block-confirmations 2 --seal --log-level DEBUG 2>&1 | tee ./validator-1.log & - ./polygon-edge server --data-dir ./test-chain-2 --chain genesis.json \ - --grpc-address :20000 --libp2p :30302 --jsonrpc :20002 \ - --num-block-confirmations 2 --seal --log-level DEBUG 2>&1 | tee ./validator-2.log & - ./polygon-edge server --data-dir ./test-chain-3 --chain genesis.json \ - --grpc-address :30000 --libp2p :30303 --jsonrpc :30002 \ - --num-block-confirmations 2 --seal --log-level DEBUG 2>&1 | tee ./validator-3.log & - ./polygon-edge server --data-dir ./test-chain-4 --chain genesis.json \ - --grpc-address :40000 --libp2p :30304 --jsonrpc :40002 \ - --num-block-confirmations 2 --seal --log-level DEBUG 2>&1 | tee ./validator-4.log & - wait - else - ./polygon-edge server --data-dir ./test-chain-1 --chain genesis.json \ - --grpc-address :10000 --libp2p :30301 --jsonrpc :10002 --relayer \ - --num-block-confirmations 2 --seal --log-level DEBUG & - ./polygon-edge server --data-dir ./test-chain-2 --chain genesis.json \ - --grpc-address :20000 --libp2p :30302 --jsonrpc :20002 \ - --num-block-confirmations 2 --seal --log-level DEBUG & - ./polygon-edge server --data-dir ./test-chain-3 --chain genesis.json \ - --grpc-address :30000 --libp2p :30303 --jsonrpc :30002 \ - --num-block-confirmations 2 --seal --log-level DEBUG & - ./polygon-edge server --data-dir ./test-chain-4 --chain genesis.json \ - --grpc-address :40000 --libp2p :30304 --jsonrpc :40002 \ - --num-block-confirmations 2 --seal --log-level DEBUG & - wait + write_logs_arg="2>&1 | tee "./validator-$i.log"" fi + + for i in {1..4}; do + data_dir="./test-chain-$i" + grpc_port=$((10000 * $i)) + libp2p_port=$((30300 + $i)) + jsonrpc_port=$((10000 * $i + 2)) + + relayer_arg="" + if [ "$1" == "polybft" ] && [ $i -eq 1 ]; then + relayer_arg="--relayer" + fi + + ./polygon-edge server --data-dir "$data_dir" --chain genesis.json \ + --grpc-address ":$grpc_port" --libp2p ":$libp2p_port" --jsonrpc ":$jsonrpc_port" \ + $relayer_arg --num-block-confirmations 2 --seal \ + --log-level DEBUG $write_logs_arg & + done + + wait } function startServerFromDockerCompose() { @@ -254,7 +248,7 @@ case "$2" in initIbftConsensus # Create genesis file and start the server from binary createGenesis - startServerFromBinary $2 + startServerFromBinary $1 $2 exit 0 elif [ "$1" == "polybft" ]; then # Initialize polybft consensus @@ -262,7 +256,7 @@ case "$2" in # Create genesis file and start the server from binary createGenesis initRootchain $2 - startServerFromBinary $2 + startServerFromBinary $1 $2 exit 0 else echo "Unsupported consensus mode. Supported modes are: ibft and polybft."