From d11a0f5af9b90769c936ac343872ea6603db1176 Mon Sep 17 00:00:00 2001 From: Carla Kirk-Cohen Date: Tue, 9 Apr 2024 10:54:15 -0400 Subject: [PATCH 1/3] setup: build docker image if re-generated data for simulation --- setup/create_network.sh | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/setup/create_network.sh b/setup/create_network.sh index 857a5f8..47cd5ea 100755 --- a/setup/create_network.sh +++ b/setup/create_network.sh @@ -19,6 +19,11 @@ if [ ! -d "sim-ln" ]; then exit 1 fi +if [ ! -d "circuitbreaker" ]; then + echo "Error: Circuitbreaker directory not found. Make sure to clone circuitbreaker before running this script." + exit 1 +fi + if ! command -v rustc &> /dev/null; then echo "Error: Rust compiler (rustc) is not installed. Please install Rust from https://www.rust-lang.org/." exit 1 @@ -79,6 +84,31 @@ else raw_data="$sim_files/data.csv" cp results/htlc_forwards.csv "$raw_data" cd .. + + echo "Building circuitbreaker image with new data" + cd circuitbreaker + + if [[ -n $(git status --porcelain) ]]; then + echo "Error: there are unsaved changes in circuitbreaker, please stash them!" + exit 1 + fi + + git remote add carla https://github.com/carlaKC/circuitbreaker + + git fetch carla > /dev/null 2>&1 || { echo "Failed to fetch carla/circuitbreaker"; exit 1; } + git checkout carla/attackathon > /dev/null 2>&1 || { echo "Failed to checkout carla/circuitbreaker/attackathon"; exit 1; } + + cp "$raw_data" historical_data/raw_data_csv + + docker_tag="carlakirkcohen/circuitbreaker:attackathon-$network_name" + # Build with no cache because docker is sometimes funny with not detecting changes in the files being copied in. + docker build . -t "$docker_tag" --no-cache + docker push "$docker_tag" + + git remote remove carla + git checkout master > /dev/null 2>&1 + + cd .. fi # Before we actually bump our timestamps, we'll spin up warnet to generate a graphml file that From 439493bc74eb007862b3cb12b2c8c38ef3874296 Mon Sep 17 00:00:00 2001 From: Carla Kirk-Cohen Date: Tue, 9 Apr 2024 11:03:28 -0400 Subject: [PATCH 2/3] setup: use docker image that contains the data we've generated --- setup/create_network.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup/create_network.sh b/setup/create_network.sh index 47cd5ea..2504002 100755 --- a/setup/create_network.sh +++ b/setup/create_network.sh @@ -124,7 +124,7 @@ warnet > /dev/null 2>&1 & warnet_pid=$! warnet_file="$sim_files"/"$network_name".graphml -warcli graph import-json "$json_file" --outfile="$warnet_file" > /dev/null 2>&1 +warcli graph import-json "$json_file" --outfile="$warnet_file" --cb="$docker_tag"> /dev/null 2>&1 # Shut warnet down kill $warnet_pid > /dev/null 2>&1 From 09a8edaa66af714b1a5fcf62bdf39ca3c1175c68 Mon Sep 17 00:00:00 2001 From: Carla Kirk-Cohen Date: Tue, 9 Apr 2024 11:29:09 -0400 Subject: [PATCH 3/3] readme: update to include CB instructions --- README.md | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index f671ed9..e3c7828 100644 --- a/README.md +++ b/README.md @@ -165,6 +165,7 @@ working directory*: 1. [This repo](https://github.com/carlaKC/attackathon) 2. [Warnet](https://github.com/bitcoin-dev-project/warnet) 3. [SimLN](https://github.com/bitcoin-dev-project/sim-ln) +3. [Circuitbreaker](https://github.com/lightningequipment/circuitbreaker) You will need to provide: 1. A `json` file with the same format as LND's `describegraph` output @@ -173,17 +174,22 @@ You will need to provide: setup script to generate fake historical forwards for all the nodes in the network for. -The setup script provided will generate all required files for you: +The setup script provided will generate all required files and docker +images for you: `./attackathon/setup/create_network.sh {path to json file} {duration in seconds}` -Note that you *must* run this from your directory containing `warnet` -and `simln` because it moves between directories to achieve various -tasks! The name that you give the `json` file is considered to be -your `network_name`. +Note that you *must* run this from your directory containing `warnet`, +`simln` and `circuitbreaker` because it moves between directories to +achieve various tasks! The name that you give the `json` file is +considered to be your `network_name`. Once the script has completed, check in any files that it generated and provide your students with the following: 1. The `network_name` for your attackathon. 2. The attackathon repo (/branch) with all files checked in. +The script currently hardcodes the docker hub account for images to +`carlakirkcohen` and tries to push to it, so you'll need to search and +replace if you want to test the full flow. +