From 8641cbb8c50c713e254871ced2a0ba062d6c2054 Mon Sep 17 00:00:00 2001 From: Skylar Simoncelli <128400943+skylar-simoncelli@users.noreply.github.com> Date: Fri, 15 Nov 2024 15:48:58 +0100 Subject: [PATCH] feat: local-environment deployment option 4 for external benchmarking node support --- .../modules/partner-chains-external-node.txt | 56 +++++++++++++++++++ dev/local-environment/setup.sh | 34 +++++++---- 2 files changed, 79 insertions(+), 11 deletions(-) create mode 100644 dev/local-environment/modules/partner-chains-external-node.txt diff --git a/dev/local-environment/modules/partner-chains-external-node.txt b/dev/local-environment/modules/partner-chains-external-node.txt new file mode 100644 index 000000000..a28a421e9 --- /dev/null +++ b/dev/local-environment/modules/partner-chains-external-node.txt @@ -0,0 +1,56 @@ + + partner-chains-node-1: + container_name: partner-chains-node-1 + image: ${PARTNER_CHAINS_NODE_IMAGE} + network_mode: "host" + platform: linux/amd64 + volumes: + - shared-volume:/shared + - partner-chains-node-1-data:/data + environment: + DB_SYNC_POSTGRES_CONNECTION_STRING: "postgres://postgres:${POSTGRES_PASSWORD}@127.0.0.1:${POSTGRES_PORT}/cexplorer" + SIDECHAIN_BLOCK_BENEFICIARY: "0000000000000000000000000000000000000000000000000000000000000001" + CHAIN_ID: "0" + GENESIS_COMMITTEE_UTXO: "781cb948a37c7c38b43872af9b1e22135a94826eafd3740260a6db0a303885d8#0" + GOVERNANCE_AUTHORITY: "e8c300330fe315531ca89d4a2e7d0c80211bc70b473b1ed4979dff2b" + CARDANO_SECURITY_PARAMETER: "5" + CARDANO_ACTIVE_SLOTS_COEFF: "0.4" + MC__FIRST_EPOCH_NUMBER: "0" + MC__FIRST_SLOT_NUMBER: "0" + MC__EPOCH_DURATION_MILLIS: "120000" + THRESHOLD_NUMERATOR: "2" + THRESHOLD_DENOMINATOR: "3" + BLOCK_STABILITY_MARGIN: "0" + MINIMUM_MC_EPOCH: "0" + MC__FIRST_EPOCH_TIMESTAMP_MILLIS: "" + COMMITTEE_CANDIDATE_ADDRESS: "" + D_PARAMETER_POLICY_ID: "" + PERMISSIONED_CANDIDATES_POLICY_ID: "" + NATIVE_TOKEN_POLICY_ID: "" + NATIVE_TOKEN_ASSET_NAME: "" + ILLIQUID_SUPPLY_VALIDATOR_ADDRESS: "" + command: + - "--alice" + - "--chain=/shared/chain-spec.json" + - "--node-key=0000000000000000000000000000000000000000000000000000000000000001" + - "--bootnodes=/ipv4//tcp/30333/p2p/12D3KooWEyoppNCUx8Yx66oV9fJnriXwCcXwDDUA2kj6vnc6iDEp" + - "--bootnodes=/ipv4//tcp/30333/p2p/12D3KooWEyoppNCUx8Yx66oV9fJnriXwCcXwDDUA2kj6vnc6iDEp" + - "--bootnodes=/ipv4//tcp/30333/p2p/12D3KooWEyoppNCUx8Yx66oV9fJnriXwCcXwDDUA2kj6vnc6iDEp" + - "--base-path=/data" + - "--unsafe-rpc-external" + - "--rpc-port=9933" + - "--rpc-cors=all" + - "--prometheus-port=9615" + - "--prometheus-external" + - "--state-pruning=archive" + - "--blocks-pruning=archive" + ports: + - "30333:30333" + - "9933:9933" + - "9615:9615" + restart: always + deploy: + resources: + limits: + cpus: ${CPU_PARTNER_CHAINS_NODE:-} + memory: ${MEM_PARTNER_CHAINS_NODE:-} \ No newline at end of file diff --git a/dev/local-environment/setup.sh b/dev/local-environment/setup.sh index 510399fcf..e41bfca21 100755 --- a/dev/local-environment/setup.sh +++ b/dev/local-environment/setup.sh @@ -388,9 +388,10 @@ choose_deployment_option() { echo "1) Include only Cardano testnet" echo "2) Include Cardano testnet with Kupo and Ogmios" echo "3) Include Cardano testnet, Kupo, Ogmios, DB-Sync and Postgres" - read -p "Enter your choice (1/2/3): " deployment_option + echo "4) Deploy a single Partner Chains node with network_mode: "host" for external connections (adjust partner-chains-external-node.txt before running this script)" + read -p "Enter your choice (1/2/3/4): " deployment_option else - deployment_option=4 + deployment_option=0 fi echo } @@ -424,7 +425,17 @@ create_docker_compose() { cat ./modules/db-sync.txt >> docker-compose.yml cat ./modules/postgres.txt >> docker-compose.yml ;; - *) + 4) + echo -e "Including all services with external partner chain node.\n" + cat ./modules/cardano.txt >> docker-compose.yml + cat ./modules/ogmios.txt >> docker-compose.yml + cat ./modules/kupo.txt >> docker-compose.yml + cat ./modules/db-sync.txt >> docker-compose.yml + cat ./modules/postgres.txt >> docker-compose.yml + cat ./modules/partner-chains-external-node.txt >> docker-compose.yml + cat ./modules/pc-contracts-cli.txt >> docker-compose.yml + ;; + 0) echo -e "Including all services.\n" cat ./modules/cardano.txt >> docker-compose.yml cat ./modules/ogmios.txt >> docker-compose.yml @@ -434,6 +445,10 @@ create_docker_compose() { cat ./modules/partner-chains-nodes.txt >> docker-compose.yml cat ./modules/pc-contracts-cli.txt >> docker-compose.yml ;; + *) + echo "Invalid deployment option selected." + exit 1 + ;; esac if [ "$tests_enabled" == "yes" ]; then echo -e "Including tests.\n" @@ -445,12 +460,11 @@ create_docker_compose() { parse_arguments() { non_interactive=0 - deployment_option=4 + deployment_option=0 postgres_password="" overrides="no" tests_enabled="no" - # Parse arguments while [[ $# -gt 0 ]]; do case "$1" in -n|--non-interactive) @@ -458,11 +472,11 @@ parse_arguments() { shift ;; -d|--deployment-option) - if [[ -n "$2" && "$2" =~ ^[123]$ ]]; then + if [[ -n "$2" && "$2" =~ ^[1-4]$ ]]; then deployment_option="$2" shift 2 else - echo "Error: Invalid deployment option '$2'. Valid options are 1, 2, or 3." + echo "Error: Invalid deployment option '$2'. Valid options are 1, 2, 3, or 4." exit 1 fi ;; @@ -497,7 +511,7 @@ parse_arguments() { echo "Usage: $0 [OPTION]..." echo "Initialize and configure the Docker environment." echo " -n, --non-interactive Run with no interactive prompts and accept sensible default configuration settings." - echo " -d, --deployment-option Specify one of the custom deployment options (1, 2, or 3)." + echo " -d, --deployment-option Specify one of the custom deployment options (1, 2, 3, or 4)." echo " -p, --postgres-password Set a specific password for PostgreSQL (overrides automatic generation)." echo " -o, --overrides Enable custom artifact overrides from artifacts in ./configurations/pc-contracts-cli/ (PC and PCSC)." echo " -i, --node-image Specify a custom Partner Chains Node image." @@ -516,7 +530,6 @@ parse_arguments() { esac done - # Export variables for use in other functions export non_interactive export deployment_option export postgres_password @@ -525,7 +538,6 @@ parse_arguments() { export tests_enabled } - main() { parse_arguments "$@" @@ -547,7 +559,7 @@ main() { configure_artifact_overrides "interactive" resource_limits_setup - if [ "$deployment_option" -eq 4 ]; then + if [ "$deployment_option" -eq 0 ]; then choose_deployment_option fi