Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Various fixes/improvements #72

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Empty file modified deploy_rln_contract.sh
100644 → 100755
Empty file.
8 changes: 5 additions & 3 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ services:
command:
- '/opt/deploy_rln_contract.sh'
volumes:
- ./deploy_rln_contract.sh:/opt/deploy_rln_contract.sh
- ./deploy_rln_contract.sh:/opt/deploy_rln_contract.sh:Z
depends_on:
- foundry
networks:
Expand Down Expand Up @@ -98,7 +98,7 @@ services:
rest-traffic:
image: alrevuelta/rest-traffic:d936446
command:
--multiple-nodes=http://waku-simulator_nwaku_[1..${NUM_NWAKU_NODES:-5}]:8645
--multiple-nodes=http://waku-simulator_nwaku_[1..${TRAFFIC_NUM_NWAKU_NODES:-5}]:8645
--msg-size-kbytes=${MSG_SIZE_KBYTES:-10}
--delay-seconds=${TRAFFIC_DELAY_SECONDS:-15}
networks:
Expand Down Expand Up @@ -152,6 +152,7 @@ services:
- /var/run:/var/run:rw
- /sys:/sys:ro
- /var/lib/docker/:/var/lib/docker:ro
- /dev:/dev
depends_on:
- redis
networks:
Expand Down Expand Up @@ -232,4 +233,5 @@ services:
- simulation

volumes:
privatekeys-volume:
privatekeys-volume:

77 changes: 77 additions & 0 deletions inject_spam.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
#!/bin/bash

# Function to print the usage of the script
usage() {
echo "Usage: $0 --static-node <> --delay-milliseconds <>"
exit 1
}

# Default values
DEFAULT_DELAY_MILLISECONDS=200

# Initialize variables
DELAY_MILLISECONDS=$DEFAULT_DELAY_MILLISECONDS
STATIC_NODE=""

# Parse named parameters
while [[ "$#" -gt 0 ]]; do
case $1 in
--delay-milliseconds)
DELAY_MILLISECONDS="$2"
shift 2
;;
--static-node)
STATIC_NODE="$2"
shift 2
;;
*)
echo "Unknown parameter passed: $1"
usage
;;
esac
done

# Validate required parameters
if [[ -z "$STATIC_NODE" ]]; then
echo "Error: --static-node is required."
usage
fi

# Validate delay-seconds is an integer
if ! [[ "$DELAY_MILLISECONDS" =~ ^[0-9]+$ ]]; then
echo "Error: --delay-milliseconds must be an integer."
exit 1
fi

# Check if default values are used and warn
if [[ "$DELAY_MILLISECONDS" -eq $DEFAULT_DELAY_MILLISECONDS ]]; then
echo "Warning: Using default value for --delay-milliseconds: $DEFAULT_DELAY_MILLISECONDS"
fi

# Output the parameters as a summary
echo "====================================="
echo " Summary of Parameters "
echo "====================================="
echo "- Delay: ${DELAY_MILLISECONDS}ms"
echo "- Static Node: ${STATIC_NODE}"
echo "====================================="

# Run the command
docker run -it --network waku-simulator_simulation quay.io/wakuorg/nwaku-pr:2821 \
--relay=true \
--rln-relay=true \
--rln-relay-dynamic=true \
--rln-relay-eth-client-address=http://foundry:8545 \
--rln-relay-eth-contract-address=0xCf7Ed3AccA5a467e9e704C703E8D87F634fB0Fc9 \
--rln-relay-epoch-sec=1 \
--rln-relay-user-message-limit=1 \
--log-level=DEBUG \
--staticnode=${STATIC_NODE} \
--pubsub-topic=/waku/2/rs/66/0 \
--cluster-id=66 \
--rln-relay-eth-private-key=0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80 \
--rln-relay-cred-path=/keystore.json \
--rln-relay-cred-password=password123 \
--spammer=true \
--spammer-delay-between-msg=${DELAY_MILLISECONDS}

94 changes: 94 additions & 0 deletions inject_traffic.sh
Original file line number Diff line number Diff line change
@@ -0,0 +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=$DELAY_SECONDS \
--msg-size-kbytes=$MSG_SIZE_KBYTES \
--pubsub-topic=$PUBSUB_TOPIC \
--multiple-nodes="http://waku-simulator_nwaku_[$NODES]:8645"

Loading