mit-jamming-attackathon/scripts/start_network.sh

53 lines
1.3 KiB
Bash
Executable File

#!/bin/bash
# Check if the 'warnet' directory exists
if [ ! -d "warnet" ]; then
echo "Error: Warnet directory not found. Make sure to clone Warnet before running this script."
exit 1
fi
# Check if the correct number of arguments are provided
if [ "$#" -ne 1 ]; then
echo "Usage: $0 <network_name>"
exit 1
fi
network_name="$1"
# Capture the current working directory, which has the attackathon files in it
current_directory=$(pwd)
sim_files="$current_directory/attackathon/data/$network_name"
cd warnet
python3 -m venv .venv # Use alternative venv manager if desired
source .venv/bin/activate
pip install --upgrade pip
pip install -e .
echo "💣 Bringing up warnet 💣"
warcli network start "$sim_files/$network_name.graphml" --force
sleep 10
echo "Waiting for L1 p2p connections"
while warcli network connected | grep -q "False"; do
sleep 1
done
echo "Opening channels and syncing gossip"
warcli scenarios run ln_init
echo "Waiting for gossip to sync"
while warcli scenarios active | grep -q "True"; do
sleep 1
done
echo "Mining blocks every 5 minutes"
warcli scenarios run miner_std --allnodes --interval=300
# Sim-ln should already be running if we added it in the graph file, export creds here.
echo "Generating random payment activity"
target_alias=$(cat $sim_files/target.txt)
warcli network export --exclude="[$target_alias]"