Merge pull request #9 from carlaKC/circuitbreaker-imagebuild

setup: build circuitbreaker image and pass to warnet
This commit is contained in:
Carla Kirk-Cohen 2024-04-09 11:38:27 -04:00 committed by GitHub
commit 3c686626a8
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 42 additions and 6 deletions

View File

@ -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.
</details>

View File

@ -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
@ -94,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