From adfa512893c92b04471fa8dc36b8695a024f75c2 Mon Sep 17 00:00:00 2001 From: Jimmy Chen Date: Fri, 19 Jul 2024 12:42:59 +1000 Subject: [PATCH] Add an option to keep existing enclave when starting local testnet (#6065) * Add an option to keep existing enclave when starting local testnet. * Add missing help text. * Do not add `--image-download always` flag if `-k` is present. --- scripts/local_testnet/network_params.yaml | 3 +++ scripts/local_testnet/start_local_testnet.sh | 19 ++++++++++++------- 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/scripts/local_testnet/network_params.yaml b/scripts/local_testnet/network_params.yaml index f54fce354a..1c25c30f06 100644 --- a/scripts/local_testnet/network_params.yaml +++ b/scripts/local_testnet/network_params.yaml @@ -12,3 +12,6 @@ network_params: seconds_per_slot: 3 global_log_level: debug snooper_enabled: false +additional_services: + - dora + - prometheus_grafana \ No newline at end of file diff --git a/scripts/local_testnet/start_local_testnet.sh b/scripts/local_testnet/start_local_testnet.sh index 4b03b1e010..433e6280c2 100755 --- a/scripts/local_testnet/start_local_testnet.sh +++ b/scripts/local_testnet/start_local_testnet.sh @@ -11,15 +11,17 @@ NETWORK_PARAMS_FILE=$SCRIPT_DIR/network_params.yaml BUILD_IMAGE=true BUILDER_PROPOSALS=false CI=false +KEEP_ENCLAVE=false # Get options -while getopts "e:b:n:phc" flag; do +while getopts "e:b:n:phck" flag; do case "${flag}" in e) ENCLAVE_NAME=${OPTARG};; b) BUILD_IMAGE=${OPTARG};; n) NETWORK_PARAMS_FILE=${OPTARG};; p) BUILDER_PROPOSALS=true;; c) CI=true;; + k) KEEP_ENCLAVE=true;; h) echo "Start a local testnet with kurtosis." echo @@ -31,6 +33,7 @@ while getopts "e:b:n:phc" flag; do echo " -n: kurtosis network params file path default: $NETWORK_PARAMS_FILE" echo " -p: enable builder proposals" echo " -c: CI mode, run without other additional services like Grafana and Dora explorer" + echo " -k: keeping enclave to allow starting the testnet without destroying the existing one" echo " -h: this help" exit ;; @@ -62,9 +65,6 @@ if [ "$CI" = true ]; then # TODO: run assertoor tests yq eval '.additional_services = []' -i $NETWORK_PARAMS_FILE echo "Running without additional services (CI mode)." -else - yq eval '.additional_services = ["dora", "prometheus_grafana"]' -i $NETWORK_PARAMS_FILE - echo "Additional services dora and prometheus_grafana added to network_params.yaml" fi if [ "$BUILD_IMAGE" = true ]; then @@ -75,9 +75,14 @@ else echo "Not rebuilding Lighthouse Docker image." fi -# Stop local testnet -kurtosis enclave rm -f $ENCLAVE_NAME 2>/dev/null || true +IMAGE_DOWNLOAD_FLAG="" -kurtosis run --enclave $ENCLAVE_NAME github.com/ethpandaops/ethereum-package --args-file $NETWORK_PARAMS_FILE +if [ "$KEEP_ENCLAVE" = false ]; then + # Stop local testnet + kurtosis enclave rm -f $ENCLAVE_NAME 2>/dev/null || true + IMAGE_DOWNLOAD_FLAG="--image-download always" +fi + +kurtosis run --enclave $ENCLAVE_NAME github.com/ethpandaops/ethereum-package $IMAGE_DOWNLOAD_FLAG --args-file $NETWORK_PARAMS_FILE echo "Started!"