mirror of
https://github.com/logos-messaging/logos-messaging-simulator.git
synced 2026-01-03 22:43:07 +00:00
Implement two scripts to launch compose and traffic injection easily.
This commit is contained in:
parent
146b71214e
commit
5296ac6bf8
@ -205,7 +205,7 @@ services:
|
||||
networks:
|
||||
- simulation
|
||||
ports:
|
||||
- 0.0.0.0:3000:3000
|
||||
- 3000
|
||||
|
||||
ingestion:
|
||||
image: web3labs/epirus-free-ingestion:latest
|
||||
@ -235,4 +235,4 @@ services:
|
||||
- simulation
|
||||
|
||||
volumes:
|
||||
privatekeys-volume:
|
||||
privatekeys-volume:
|
||||
|
||||
@ -1,5 +1,94 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Function to print the usage of the script
|
||||
usage() {
|
||||
echo "Usage: $0 --delay-seconds <int> --msg-size-kbytes <int> --pubsub-topic <string> --nodes <range>"
|
||||
exit 1
|
||||
}
|
||||
|
||||
# Default values
|
||||
DEFAULT_MSG_SIZE=10
|
||||
DEFAULT_PUBSUB_TOPIC="/waku/2/rs/66/0"
|
||||
|
||||
# Initialize variables
|
||||
DELAY_SECONDS=""
|
||||
MSG_SIZE_KBYTES=$DEFAULT_MSG_SIZE
|
||||
PUBSUB_TOPIC=$DEFAULT_PUBSUB_TOPIC
|
||||
NODES=""
|
||||
|
||||
# Parse named parameters
|
||||
while [[ "$#" -gt 0 ]]; do
|
||||
case $1 in
|
||||
--delay-seconds)
|
||||
DELAY_SECONDS="$2"
|
||||
shift 2
|
||||
;;
|
||||
--msg-size-kbytes)
|
||||
MSG_SIZE_KBYTES="$2"
|
||||
shift 2
|
||||
;;
|
||||
--pubsub-topic)
|
||||
PUBSUB_TOPIC="$2"
|
||||
shift 2
|
||||
;;
|
||||
--nodes)
|
||||
NODES="$2"
|
||||
shift 2
|
||||
;;
|
||||
*)
|
||||
echo "Unknown parameter passed: $1"
|
||||
usage
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
# Validate required parameters
|
||||
if [[ -z "$DELAY_SECONDS" || -z "$NODES" ]]; then
|
||||
echo "Error: --delay-seconds and --nodes are required."
|
||||
usage
|
||||
fi
|
||||
|
||||
# Validate delay-seconds is an integer
|
||||
if ! [[ "$DELAY_SECONDS" =~ ^[0-9]+$ ]]; then
|
||||
echo "Error: --delay-seconds must be an integer."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Validate msg-size-kbytes is an integer
|
||||
if ! [[ "$MSG_SIZE_KBYTES" =~ ^[0-9]+$ ]]; then
|
||||
echo "Error: --msg-size-kbytes must be an integer."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Validate nodes format
|
||||
if ! [[ "$NODES" =~ ^[0-9]+\.\.[0-9]+$ ]]; then
|
||||
echo "Error: --nodes must be a range of integers."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Check if default values are used and warn
|
||||
if [[ "$MSG_SIZE_KBYTES" -eq $DEFAULT_MSG_SIZE ]]; then
|
||||
echo "Warning: Using default value for --msg-size-kbytes: $DEFAULT_MSG_SIZE"
|
||||
fi
|
||||
|
||||
if [[ "$PUBSUB_TOPIC" == "$DEFAULT_PUBSUB_TOPIC" ]]; then
|
||||
echo "Warning: Using default value for --pubsub-topic: $DEFAULT_PUBSUB_TOPIC"
|
||||
fi
|
||||
|
||||
# Output the parameters as a summary
|
||||
echo "====================================="
|
||||
echo " Summary of Parameters "
|
||||
echo "====================================="
|
||||
echo "- Delay: ${DELAY_SECONDS}s"
|
||||
echo "- Msg Size: ${MSG_SIZE_KBYTES}KB"
|
||||
echo "- Pubsub Topic: ${PUBSUB_TOPIC}"
|
||||
echo "- Nodes: ${NODES}"
|
||||
echo "====================================="
|
||||
|
||||
# Run the command
|
||||
docker run -it --network waku-simulator_simulation alrevuelta/rest-traffic:d936446 \
|
||||
--delay-seconds=${TRAFFIC_DELAY_SECONDS:-10} \
|
||||
--msg-size-kbytes=${MSG_SIZE_KBYTES:-5} \
|
||||
--pubsub-topic=/waku/2/rs/66/0 \
|
||||
--multiple-nodes="http://waku-simulator_nwaku_[1..${NUM_NWAKU_NODES:-5}]:8645"
|
||||
--delay-seconds=$DELAY_SECONDS \
|
||||
--msg-size-kbytes=$MSG_SIZE_KBYTES \
|
||||
--pubsub-topic=$PUBSUB_TOPIC \
|
||||
--multiple-nodes="http://waku-simulator_nwaku_[$NODES]:8645"
|
||||
|
||||
|
||||
153
run_compose.sh
Executable file
153
run_compose.sh
Executable file
@ -0,0 +1,153 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Function to print the usage of the script
|
||||
usage() {
|
||||
echo "Usage: $0 --nwaku-image <string> --num-nwaku-nodes <int> --traffic-delay-seconds <int> --message-size-kbytes <int> --private-key <string> --eth-from <string> --rln-relay-epoch-seconds <int> --rln-relay-messages-limit <int>"
|
||||
exit 1
|
||||
}
|
||||
|
||||
# Default values
|
||||
DEFAULT_NWAKU_IMAGE="qiuay.io/wakuorg/nwaku-pr:2759-rln-v2"
|
||||
DEFAULT_NUM_NWAKU_NODES=5
|
||||
DEFAULT_TRAFFIC_DELAY_SECONDS=60
|
||||
DEFAULT_MSG_SIZE_KBYTES=10
|
||||
DEFAULT_PRIVATE_KEY="0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80"
|
||||
DEFAULT_ETH_FROM="0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266"
|
||||
DEFAULT_RLN_RELAY_EPOCH_SEC=60
|
||||
DEFAULT_RLN_RELAY_MSG_LIMIT=1
|
||||
|
||||
# Initialize variables
|
||||
NWAKU_IMAGE=$DEFAULT_NWAKU_IMAGE
|
||||
NUM_NWAKU_NODES=$DEFAULT_NUM_NWAKU_NODES
|
||||
TRAFFIC_DELAY_SECONDS=$DEFAULT_TRAFFIC_DELAY_SECONDS
|
||||
MSG_SIZE_KBYTES=$DEFAULT_MSG_SIZE_KBYTES
|
||||
PRIVATE_KEY=$DEFAULT_PRIVATE_KEY
|
||||
ETH_FROM=$DEFAULT_ETH_FROM
|
||||
RLN_RELAY_EPOCH_SEC=$DEFAULT_RLN_RELAY_EPOCH_SEC
|
||||
RLN_RELAY_MSG_LIMIT=$DEFAULT_RLN_RELAY_MSG_LIMIT
|
||||
|
||||
# Parse named parameters
|
||||
while [[ "$#" -gt 0 ]]; do
|
||||
case $1 in
|
||||
--nwaku-image)
|
||||
NWAKU_IMAGE="$2"
|
||||
shift 2
|
||||
;;
|
||||
--num-nwaku-nodes)
|
||||
NUM_NWAKU_NODES="$2"
|
||||
shift 2
|
||||
;;
|
||||
--traffic-delay-seconds)
|
||||
TRAFFIC_DELAY_SECONDS="$2"
|
||||
shift 2
|
||||
;;
|
||||
--message-size-kbytes)
|
||||
MSG_SIZE_KBYTES="$2"
|
||||
shift 2
|
||||
;;
|
||||
--private-key)
|
||||
PRIVATE_KEY="$2"
|
||||
shift 2
|
||||
;;
|
||||
--eth-from)
|
||||
ETH_FROM="$2"
|
||||
shift 2
|
||||
;;
|
||||
--rln-relay-epoch-seconds)
|
||||
RLN_RELAY_EPOCH_SEC="$2"
|
||||
shift 2
|
||||
;;
|
||||
--rln-relay-messages-limit)
|
||||
RLN_RELAY_MSG_LIMIT="$2"
|
||||
shift 2
|
||||
;;
|
||||
*)
|
||||
echo "Unknown parameter passed: $1"
|
||||
usage
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
# Validate num-nwaku-nodes is an integer
|
||||
if ! [[ "$NUM_NWAKU_NODES" =~ ^[0-9]+$ ]]; then
|
||||
echo "Error: --num-nwaku-nodes must be an integer."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Validate traffic-delay-seconds is an integer
|
||||
if ! [[ "$TRAFFIC_DELAY_SECONDS" =~ ^[0-9]+$ ]]; then
|
||||
echo "Error: --traffic-delay-seconds must be an integer."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Validate msg-size-kbytes
|
||||
if ! [[ "$MSG_SIZE_KBYTES" =~ ^[0-9]+$ ]]; then
|
||||
echo "Error: --msg-size-kbytes must be an integer."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Validate rln-relay-epoch-seconds
|
||||
if ! [[ "$RLN_RELAY_EPOCH_SEC" =~ ^[0-9]+$ ]]; then
|
||||
echo "Error: --rln-relay-epoch-seconds must be an integer."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Validate rln-relay-messages-limit
|
||||
if ! [[ "$RLN_RELAY_MSG_LIMIT" =~ ^[0-9]+$ ]]; then
|
||||
echo "Error: --rln-relay-messages-limit must be an integer."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Check if default values are used and warn
|
||||
if [[ "$NWAKU_IMAGE" == "$DEFAULT_NWAKU_IMAGE" ]]; then
|
||||
echo "Warning: Using default value for --nwaku-image: $DEFAULT_NWAKU_IMAGE"
|
||||
fi
|
||||
|
||||
if [[ "$NUM_NWAKU_NODES" -eq "$DEFAULT_NUM_NWAKU_NODES" ]]; then
|
||||
echo "Warning: Using default value for --num-nwaku-nodes: $DEFAULT_NUM_NWAKU_NODES"
|
||||
fi
|
||||
|
||||
if [[ "$TRAFFIC_DELAY_SECONDS" -eq "$DEFAULT_TRAFFIC_DELAY_SECONDS" ]]; then
|
||||
echo "Warning: Using default value for --traffic-delay-seconds: $DEFAULT_TRAFFIC_DELAY_SECONDS"
|
||||
fi
|
||||
|
||||
if [[ "$MSG_SIZE_KBYTES" -eq "$DEFAULT_MSG_SIZE_KBYTES" ]]; then
|
||||
echo "Warning: Using default value for --message-size-kbytes: $DEFAULT_MSG_SIZE_KBYTES"
|
||||
fi
|
||||
|
||||
if [[ "$PRIVATE_KEY" == "$DEFAULT_PRIVATE_KEY" ]]; then
|
||||
echo "Warning: Using default value for --private-key: $DEFAULT_PRIVATE_KEY"
|
||||
fi
|
||||
|
||||
if [[ "$ETH_FROM" == "$DEFAULT_ETH_FROM" ]]; then
|
||||
echo "Warning: Using default value for --eth-from: $DEFAULT_ETH_FROM"
|
||||
fi
|
||||
|
||||
if [[ "$RLN_RELAY_EPOCH_SEC" -eq "$DEFAULT_RLN_RELAY_EPOCH_SEC" ]]; then
|
||||
echo "Warning: Using default value for --rln-relay-epoch-seconds: $DEFAULT_RLN_RELAY_EPOCH_SEC"
|
||||
fi
|
||||
|
||||
if [[ "$RLN_RELAY_MSG_LIMIT" -eq "$DEFAULT_RLN_RELAY_MSG_LIMIT" ]]; then
|
||||
echo "Warning: Using default value for --rln-relay-messages-limit: $DEFAULT_RLN_RELAY_MSG_LIMIT"
|
||||
fi
|
||||
|
||||
# Output the parameters as a summary
|
||||
echo ""
|
||||
echo "================================================================================================="
|
||||
echo " Summary of Parameters "
|
||||
echo "================================================================================================="
|
||||
echo "- Nwaku Image: ${NWAKU_IMAGE}"
|
||||
echo "- Number of Nwaku Nodes: ${NUM_NWAKU_NODES}"
|
||||
echo "- Message Publishing Delay: ${TRAFFIC_DELAY_SECONDS}s"
|
||||
echo "- Message Size: ${MSG_SIZE_KBYTES}KB"
|
||||
echo "- Private Key: ${PRIVATE_KEY}"
|
||||
echo "- ETH From: ${ETH_FROM}"
|
||||
echo "- RLN Relay Epoch: ${RLN_RELAY_EPOCH_SEC}s"
|
||||
echo "- RLN Relay Messages Limit: ${RLN_RELAY_MSG_LIMIT}"
|
||||
echo "================================================================================================="
|
||||
echo ""
|
||||
|
||||
# Start compose
|
||||
read -n 1 -s -r -p "Press any key to launch docker compose"
|
||||
docker compose --compatibility up
|
||||
|
||||
@ -115,9 +115,6 @@ else
|
||||
--execute
|
||||
fi
|
||||
|
||||
echo $RLN_CREDENTIAL_PATH
|
||||
ls -la /
|
||||
ls -la $RLN_CREDENTIAL_PATH
|
||||
echo "I am a nwaku node"
|
||||
|
||||
RETRIES=${RETRIES:=10}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user