Skip to content
This repository has been archived by the owner on Dec 4, 2024. It is now read-only.

Commit

Permalink
Provide relayer flag only for the polybft and simplify starting nodes…
Browse files Browse the repository at this point in the history
… function
  • Loading branch information
Stefan-Ethernal committed Oct 9, 2023
1 parent 4c3aa2c commit 75ebbc6
Showing 1 changed file with 24 additions and 31 deletions.
55 changes: 24 additions & 31 deletions scripts/cluster
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -161,36 +161,29 @@ 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() {
Expand Down Expand Up @@ -254,15 +247,15 @@ 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
initPolybftConsensus
# 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."
Expand Down

0 comments on commit 75ebbc6

Please sign in to comment.