Skip to content

Commit 3312ac8

Browse files
committed
Improve mina-local-network long message printing
1 parent 27acf69 commit 3312ac8

File tree

1 file changed

+178
-158
lines changed

1 file changed

+178
-158
lines changed

scripts/mina-local-network/mina-local-network.sh

Lines changed: 178 additions & 158 deletions
Original file line numberDiff line numberDiff line change
@@ -76,71 +76,74 @@ NODE_PIDS=()
7676
# Helper functions
7777

7878
help() {
79-
echo "-w |--whales <#> | Number of BP Whale Nodes (bigger stake) to spin-up"
80-
echo " | Default: ${WHALES}"
81-
echo "-f |--fish <#> | Number of BP Fish Nodes (less stake) to spin-up"
82-
echo " | Default: ${FISH}"
83-
echo "-n |--nodes <#> | Number of non block-producing nodes to spin-up"
84-
echo " | Default: ${NODES}"
85-
echo "-a |--archive | Whether to run the Archive Node (presence of argument)"
86-
echo " | Default: ${ARCHIVE}"
87-
echo "-sp |--seed-start-port <#> | Seed Node range start port"
88-
echo " | Default: ${SEED_START_PORT}"
89-
echo "-swp |--snark-coordinator-start-port <#> | Snark Worker Coordinator Node range start port"
90-
echo " | Default: ${SNARK_COORDINATOR_PORT}"
91-
echo "-swc |--snark-workers-count <#> | Snark Workers count"
92-
echo " | Default: ${SNARK_WORKERS_COUNT}"
93-
echo "-wp |--whale-start-port <#> | Whale Nodes range start port"
94-
echo " | Default: ${WHALE_START_PORT}"
95-
echo "-fp |--fish-start-port <#> | Fish Nodes range start port"
96-
echo " | Default: ${FISH_START_PORT}"
97-
echo "-np |--node-start-port <#> | Non block-producing Nodes range start port"
98-
echo " | Default: ${NODE_START_PORT}"
99-
echo "-ap |--archive-server-port <#> | Archive Node server port"
100-
echo " | Default: ${ARCHIVE_SERVER_PORT}"
101-
echo "-ll |--log-level <level> | Console output logging level"
102-
echo " | Default: ${LOG_LEVEL}"
103-
echo "-fll |--file-log-level <level> | File output logging level"
104-
echo " | Default: ${FILE_LOG_LEVEL}"
105-
echo "-ph |--pg-host <host> | PostgreSQL host"
106-
echo " | Default: ${PG_HOST}"
107-
echo "-pp |--pg-port <#> | PostgreSQL port"
108-
echo " | Default: ${PG_PORT}"
109-
echo "-pu |--pg-user <user> | PostgreSQL user"
110-
echo " | Default: ${PG_USER}"
111-
echo "-ppw |--pg-passwd <password> | PostgreSQL password"
112-
echo " | Default: <empty_string>"
113-
echo "-pd |--pg-db <db> | PostgreSQL database name"
114-
echo " | Default: ${PG_DB}"
115-
echo "-vt |--value-transfer-txns | Whether to execute periodic value transfer transactions (presence of argument)"
116-
echo " | Default: ${VALUE_TRANSFERS}"
117-
echo "-zt |--zkapp-transactions | Whether to execute periodic zkapp transactions (presence of argument)"
118-
echo " | Default: ${ZKAPP_TRANSACTIONS}"
119-
echo "-tf |--transactions-frequency <#> | Frequency of periodic transactions execution (in seconds)"
120-
echo " | Default: ${TRANSACTION_FREQUENCY}"
121-
echo "-sf |--snark-worker-fee <#> | SNARK Worker fee"
122-
echo " | Default: ${SNARK_WORKER_FEE}"
123-
echo "-lp |--log-precomputed-blocks | Log precomputed blocks"
124-
echo " | Default: ${LOG_PRECOMPUTED_BLOCKS}"
125-
echo "-pl |--proof-level <proof-level> | Proof level (currently consumed by SNARK Workers only)"
126-
echo " | Default: ${PROOF_LEVEL}"
127-
echo "-r |--reset | Whether to reset the Mina Local Network storage file-system (presence of argument)"
128-
echo " | Default: ${RESET}"
129-
echo "-u |--update-genesis-timestamp | Whether to update the Genesis Ledger timestamp (presence of argument)"
130-
echo " | Default: ${UPDATE_GENESIS_TIMESTAMP}"
131-
echo "-st |--override-slot-time <milliseconds>| Override the slot time for block production"
132-
echo " | Default: value from executable"
133-
echo "-d |--demo | Whether to run the demo (presence of argument). Demo mode is used to run the single node which is already bootstrapped and synced with the network."
134-
echo " | Default: false"
135-
echo "-h |--help | Displays this help message"
13679

137-
printf "\n"
138-
echo "Available logging levels:"
139-
echo " Spam, Trace, Debug, Info, Warn, Error, Faulty_peer, Fatal"
140-
printf "\n"
141-
echo "Available proof levels:"
142-
echo " full, check, none"
143-
printf "\n"
80+
cat <<EOF
81+
82+
-w |--whales <#> | Number of BP Whale Nodes (bigger stake) to spin-up
83+
| Default: ${WHALES}
84+
-f |--fish <#> | Number of BP Fish Nodes (less stake) to spin-up
85+
| Default: ${FISH}
86+
-n |--nodes <#> | Number of non block-producing nodes to spin-up
87+
| Default: ${NODES}
88+
-a |--archive | Whether to run the Archive Node (presence of argument)
89+
| Default: ${ARCHIVE}
90+
-sp |--seed-start-port <#> | Seed Node range start port
91+
| Default: ${SEED_START_PORT}
92+
-swp |--snark-coordinator-start-port <#> | Snark Worker Coordinator Node range start port
93+
| Default: ${SNARK_COORDINATOR_PORT}
94+
-swc |--snark-workers-count <#> | Snark Workers count
95+
| Default: ${SNARK_WORKERS_COUNT}
96+
-wp |--whale-start-port <#> | Whale Nodes range start port
97+
| Default: ${WHALE_START_PORT}
98+
-fp |--fish-start-port <#> | Fish Nodes range start port
99+
| Default: ${FISH_START_PORT}
100+
-np |--node-start-port <#> | Non block-producing Nodes range start port
101+
| Default: ${NODE_START_PORT}
102+
-ap |--archive-server-port <#> | Archive Node server port
103+
| Default: ${ARCHIVE_SERVER_PORT}
104+
-ll |--log-level <level> | Console output logging level
105+
| Default: ${LOG_LEVEL}
106+
-fll |--file-log-level <level> | File output logging level
107+
| Default: ${FILE_LOG_LEVEL}
108+
-ph |--pg-host <host> | PostgreSQL host
109+
| Default: ${PG_HOST}
110+
-pp |--pg-port <#> | PostgreSQL port
111+
| Default: ${PG_PORT}
112+
-pu |--pg-user <user> | PostgreSQL user
113+
| Default: ${PG_USER}
114+
-ppw |--pg-passwd <password> | PostgreSQL password
115+
| Default: <empty_string>
116+
-pd |--pg-db <db> | PostgreSQL database name
117+
| Default: ${PG_DB}
118+
-vt |--value-transfer-txns | Whether to execute periodic value transfer transactions (presence of argument)
119+
| Default: ${VALUE_TRANSFERS}
120+
-zt |--zkapp-transactions | Whether to execute periodic zkapp transactions (presence of argument)
121+
| Default: ${ZKAPP_TRANSACTIONS}
122+
-tf |--transactions-frequency <#> | Frequency of periodic transactions execution (in seconds)
123+
| Default: ${TRANSACTION_FREQUENCY}
124+
-sf |--snark-worker-fee <#> | SNARK Worker fee
125+
| Default: ${SNARK_WORKER_FEE}
126+
-lp |--log-precomputed-blocks | Log precomputed blocks
127+
| Default: ${LOG_PRECOMPUTED_BLOCKS}
128+
-pl |--proof-level <proof-level> | Proof level (currently consumed by SNARK Workers only)
129+
| Default: ${PROOF_LEVEL}
130+
-r |--reset | Whether to reset the Mina Local Network storage file-system (presence of argument)
131+
| Default: ${RESET}
132+
-u |--update-genesis-timestamp | Whether to update the Genesis Ledger timestamp (presence of argument)
133+
| Default: ${UPDATE_GENESIS_TIMESTAMP}
134+
-st |--override-slot-time <milliseconds>| Override the slot time for block production
135+
| Default: value from executable
136+
-d |--demo | Whether to run the demo (presence of argument). Demo mode is used to run the single node which is already bootstrapped and synced with the network.
137+
| Default: false
138+
-h |--help | Displays this help message
139+
140+
Available logging levels:
141+
Spam, Trace, Debug, Info, Warn, Error, Faulty_peer, Fatal
142+
143+
Available proof levels:
144+
full, check, none
145+
146+
EOF
144147

145148
exit
146149
}
@@ -380,36 +383,41 @@ while [[ "$#" -gt 0 ]]; do
380383
shift
381384
done
382385

383-
printf "\n"
384-
echo "================================"
385-
printf "\n"
386-
echo "███╗ ███╗██╗███╗ ██╗ █████╗ "
387-
echo "████╗ ████║██║████╗ ██║██╔══██╗"
388-
echo "██╔████╔██║██║██╔██╗ ██║███████║"
389-
echo "██║╚██╔╝██║██║██║╚██╗██║██╔══██║"
390-
echo "██║ ╚═╝ ██║██║██║ ╚████║██║ ██║"
391-
echo "╚═╝ ╚═╝╚═╝╚═╝ ╚═══╝╚═╝ ╚═╝"
392-
echo " .:: LOCAL NETWORK ::. "
393-
printf "\n"
394-
echo "================================"
395-
printf "\n"
386+
387+
cat <<'EOF'
388+
================================
389+
390+
███╗ ███╗██╗███╗ ██╗ █████╗
391+
████╗ ████║██║████╗ ██║██╔══██╗
392+
██╔████╔██║██║██╔██╗ ██║███████║
393+
██║╚██╔╝██║██║██║╚██╗██║██╔══██║
394+
██║ ╚═╝ ██║██║██║ ╚████║██║ ██║
395+
╚═╝ ╚═╝╚═╝╚═╝ ╚═══╝╚═╝ ╚═╝
396+
.:: LOCAL NETWORK ::.
397+
398+
================================
399+
400+
EOF
396401

397402
# ================================================
398403
# Check the PostgreSQL configuration required
399404
# for Archive Node operation
400405

401406
if ${ARCHIVE}; then
402-
echo "Archive Node spawning is enabled, we need to do the PostgreSQL communication check."
403-
echo "In case of any issues please make sure that you:"
404-
echo -e "\t1. Run the PostgreSQL server;"
405-
echo -e "\t2. Have configured the PostgreSQL access;"
406-
echo -e "\t3. Have configured the PostgreSQL 'database';"
407-
echo -e "\t\t3.1. psql -c 'CREATE DATABASE ${PG_DB}'"
408-
echo -e "\t\t3.2. psql ${PG_DB} < ./src/app/archive/create_schema.sql'"
409-
echo -e "\t4. Passed correct PostgreSQL credentials as CLI arguments to this script."
410-
printf "\n"
411-
echo "================================"
412-
printf "\n"
407+
cat <<EOF
408+
409+
Archive Node spawning is enabled, we need to do the PostgreSQL communication check.
410+
In case of any issues please make sure that you:
411+
1. Run the PostgreSQL server;
412+
2. Have configured the PostgreSQL access;
413+
3. Have configured the PostgreSQL 'database';
414+
3.1. psql -c 'CREATE DATABASE ${PG_DB}'
415+
3.2. psql ${PG_DB} < ./src/app/archive/create_schema.sql'
416+
4. Passed correct PostgreSQL credentials as CLI arguments to this script.
417+
418+
================================
419+
420+
EOF
413421

414422
if ${RESET}; then
415423
recreate-schema
@@ -578,23 +586,21 @@ fi
578586
# ================================================
579587
# Print the configuration summary
580588

581-
echo "Starting the Network with:"
582-
echo -e "\t1 seed"
583-
echo -e "\t1 snark coordinator"
584-
echo -e "\t${SNARK_WORKERS_COUNT} snark worker(s)"
589+
cat <<EOF
590+
Starting the Network with:
591+
1 seed
592+
1 snark coordinator
593+
${SNARK_WORKERS_COUNT} snark worker(s)
594+
$( ${ARCHIVE} && echo 1 || echo 0) archive
595+
${WHALES} whales
596+
${FISH} fish
597+
${NODES} non block-producing nodes
598+
Sending transactions: ${VALUE_TRANSFERS}
599+
Sending zkApp transactions: ${ZKAPP_TRANSACTIONS}
585600
586-
if ${ARCHIVE}; then
587-
echo -e "\t1 archive"
588-
fi
601+
================================
589602
590-
echo -e "\t${WHALES} whales"
591-
echo -e "\t${FISH} fish"
592-
echo -e "\t${NODES} non block-producing nodes"
593-
echo -e "\tSending transactions: ${VALUE_TRANSFERS}"
594-
echo -e "\tSending zkApp transactions: ${ZKAPP_TRANSACTIONS}"
595-
printf "\n"
596-
echo "================================"
597-
printf "\n"
603+
EOF
598604

599605

600606
# ================================================
@@ -756,72 +762,86 @@ done
756762

757763
# ================================================
758764

759-
echo "================================"
760-
echo "Network participants information:"
761-
printf "\n"
762-
763-
echo -e "\tSeed:"
764-
echo -e "\t\tInstance #0:"
765-
echo -e "\t\t pid ${SEED_PID}"
766-
echo -e "\t\t status: ${MINA_EXE} client status -daemon-port ${SEED_START_PORT}"
767-
echo -e "\t\t logs: cat ${NODES_FOLDER}/seed/log.txt | ${LOGPROC_EXE}"
768-
769-
if [ "${SNARK_WORKERS_COUNT}" -gt "0" ]; then
770-
echo -e "\tSnark Coordinator:"
771-
echo -e "\t\tInstance #0:"
772-
echo -e "\t\t pid ${SNARK_COORDINATOR_PID}"
773-
echo -e "\t\t status: ${MINA_EXE} client status -daemon-port ${SNARK_COORDINATOR_PORT}"
774-
echo -e "\t\t logs: cat ${NODES_FOLDER}/snark_coordinator/log.txt | ${LOGPROC_EXE}"
775-
776-
echo -e "\tSnark Workers:"
777-
# shellcheck disable=SC2004
778-
for ((i = 0; i < ${SNARK_WORKERS_COUNT}; i++)); do
779-
echo -e "\t\tInstance #${i}:"
780-
echo -e "\t\t pid ${SNARK_WORKERS_PIDS[${i}]}"
781-
echo -e "\t\t logs: cat ${NODES_FOLDER}/snark_workers/snark_worker_${i}/log.txt | ${LOGPROC_EXE}"
765+
cat <<EOF
766+
================================
767+
Network participants information:
768+
769+
Seed:
770+
Instance #0:
771+
pid ${SEED_PID}
772+
status: ${MINA_EXE} client status -daemon-port ${SEED_START_PORT}
773+
logs: cat ${NODES_FOLDER}/seed/log.txt | ${LOGPROC_EXE}
774+
EOF
775+
776+
if [ "${SNARK_WORKERS_COUNT}" -gt 0 ]; then
777+
cat <<EOF
778+
Snark Coordinator:
779+
Instance #0:
780+
pid ${SNARK_COORDINATOR_PID}
781+
status: ${MINA_EXE} client status -daemon-port ${SNARK_COORDINATOR_PORT}
782+
logs: cat ${NODES_FOLDER}/snark_coordinator/log.txt | ${LOGPROC_EXE}
783+
784+
Snark Workers:
785+
EOF
786+
787+
for ((i = 0; i < SNARK_WORKERS_COUNT; i++)); do
788+
cat <<EOF
789+
Instance #${i}:
790+
pid ${SNARK_WORKERS_PIDS[${i}]}
791+
logs: cat ${NODES_FOLDER}/snark_workers/snark_worker_${i}/log.txt | ${LOGPROC_EXE}
792+
EOF
782793
done
783794
fi
784795

785796
if ${ARCHIVE}; then
786-
echo -e "\tArchive:"
787-
echo -e "\t\tInstance #0:"
788-
echo -e "\t\t pid ${ARCHIVE_PID}"
789-
echo -e "\t\t server-port: ${ARCHIVE_SERVER_PORT}"
790-
echo -e "\t\t logs: cat ${NODES_FOLDER}/archive/log.txt | ${LOGPROC_EXE}"
797+
cat <<EOF
798+
Archive:
799+
Instance #0:
800+
pid ${ARCHIVE_PID}
801+
server-port: ${ARCHIVE_SERVER_PORT}
802+
logs: cat ${NODES_FOLDER}/archive/log.txt | ${LOGPROC_EXE}
803+
EOF
791804
fi
792805

793-
if [ "${WHALES}" -gt "0" ]; then
794-
echo -e "\tWhales:"
795-
# shellcheck disable=SC2004
796-
for ((i = 0; i < ${WHALES}; i++)); do
797-
echo -e "\t\tInstance #${i}:"
798-
echo -e "\t\t pid ${WHALE_PIDS[${i}]}"
799-
# shellcheck disable=SC2004
800-
echo -e "\t\t status: ${MINA_EXE} client status -daemon-port $((${WHALE_START_PORT} + (${i} * 5)))"
801-
echo -e "\t\t logs: cat ${NODES_FOLDER}/whale_${i}/log.txt | ${LOGPROC_EXE}"
806+
if [ "${WHALES}" -gt 0 ]; then
807+
cat <<EOF
808+
Whales:
809+
EOF
810+
for ((i = 0; i < WHALES; i++)); do
811+
cat <<EOF
812+
Instance #${i}:
813+
pid ${WHALE_PIDS[${i}]}
814+
status: ${MINA_EXE} client status -daemon-port $((${WHALE_START_PORT} + i*5))
815+
logs: cat ${NODES_FOLDER}/whale_${i}/log.txt | ${LOGPROC_EXE}
816+
EOF
802817
done
803818
fi
804819

805-
if [ "${FISH}" -gt "0" ]; then
806-
echo -e "\tFish:"
807-
# shellcheck disable=SC2004
808-
for ((i = 0; i < ${FISH}; i++)); do
809-
echo -e "\t\tInstance #${i}:"
810-
echo -e "\t\t pid ${FISH_PIDS[${i}]}"
811-
# shellcheck disable=SC2004
812-
echo -e "\t\t status: ${MINA_EXE} client status -daemon-port $((${FISH_START_PORT} + (${i} * 5)))"
813-
echo -e "\t\t logs: cat ${NODES_FOLDER}/fish_${i}/log.txt | ${LOGPROC_EXE}"
820+
if [ "${FISH}" -gt 0 ]; then
821+
cat <<EOF
822+
Fish:
823+
EOF
824+
for ((i = 0; i < FISH; i++)); do
825+
cat <<EOF
826+
Instance #${i}:
827+
pid ${FISH_PIDS[${i}]}
828+
status: ${MINA_EXE} client status -daemon-port $((${FISH_START_PORT} + i*5))
829+
logs: cat ${NODES_FOLDER}/fish_${i}/log.txt | ${LOGPROC_EXE}
830+
EOF
814831
done
815832
fi
816833

817-
if [ "${NODES}" -gt "0" ]; then
818-
echo -e "\tNon block-producing nodes:"
819-
for ((i = 0; i < ${NODES}; i++)); do
820-
echo -e "\t\tInstance #${i}:"
821-
echo -e "\t\t pid ${NODE_PIDS[${i}]}"
822-
# shellcheck disable=SC2004
823-
echo -e "\t\t status: ${MINA_EXE} client status -daemon-port $((${NODE_START_PORT} + (${i} * 5)))"
824-
echo -e "\t\t logs: cat ${NODES_FOLDER}/node_${i}/log.txt | ${LOGPROC_EXE}"
834+
if [ "${NODES}" -gt 0 ]; then
835+
cat <<EOF
836+
Non block-producing nodes:
837+
EOF
838+
for ((i = 0; i < NODES; i++)); do
839+
cat <<EOF
840+
Instance #${i}:
841+
pid ${NODE_PIDS[${i}]}
842+
status: ${MINA_EXE} client status -daemon-port $((${NODE_START_PORT} + i*5))
843+
logs: cat ${NODES_FOLDER}/node_${i}/log.txt | ${LOGPROC_EXE}
844+
EOF
825845
done
826846
fi
827847

@@ -910,4 +930,4 @@ fi
910930
# ================================================
911931
# Wait for child processes to finish
912932

913-
wait
933+
wait

0 commit comments

Comments
 (0)