From 1866457df68678a26c2ca8ecba3b4ff64923e0b7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lech=20G=C5=82owiak?= Date: Fri, 6 Dec 2024 14:14:50 +0100 Subject: [PATCH] Fix readme and decrease sleep times (#303) --- dev/local-environment/README.md | 12 +++++------ .../configurations/cardano/entrypoint.sh | 20 +++---------------- .../configurations/db-sync/entrypoint.sh | 4 ++-- .../configurations/kupo/entrypoint.sh | 2 +- .../configurations/ogmios/entrypoint.sh | 2 +- .../partner-chains-node-1/entrypoint.sh | 2 +- .../partner-chains-node-2/entrypoint.sh | 6 +++--- .../partner-chains-node-3/entrypoint.sh | 6 +++--- .../partner-chains-node-4/entrypoint.sh | 4 ++-- .../partner-chains-node-5/entrypoint.sh | 6 +++--- .../pc-contracts-cli/entrypoint.sh | 2 +- 11 files changed, 26 insertions(+), 40 deletions(-) diff --git a/dev/local-environment/README.md b/dev/local-environment/README.md index 9c4cf3db8..0f0199b8a 100644 --- a/dev/local-environment/README.md +++ b/dev/local-environment/README.md @@ -7,20 +7,20 @@ This stack is designed to run a 5 x Partner Chains node local environment for a The local environment includes: - 5 x Partner Chains Nodes (3 x permissioned, 2 x registered) -- 3 x Cardano Nodes running private testnet with pre-configured genesis files (2 minutes epochs) +- 1 x Cardano Node running private testnet with pre-configured genesis files (2 minutes epochs) - 1 x PostgreSQL database - 1 x Db-sync - 1 x Ogmios - 1 x Kupo - 1 x Ubuntu / NodeJS image for running pc-contracts-cli -The stack `setup.sh` script will create a docker-compose.yml stack configuration files, and populate an .env file with environment values. The stack can be deployed with `docker-compose up -d`. +The stack `setup.sh` script will create a docker-compose.yml stack configuration files, and populate an .env file with environment values. The stack can be deployed with `docker-compose up -d`. ## Local env - step by step - When first run, all images will be pulled from public repositories. This stage may take some time. The stack will then be built and run. -- When the stack is running, the 3 Cardano nodes will peer and being block production. This is a private testnet and will not connect to the public Cardano network, but rather from a pre-configured genesis file. -- Once the Cardano chain is synced, Ogmios, Kupo and DB-Sync will in turn connect to the Cardano node node.socket and begin syncing the chain. +- When the stack is running, the Cardano node begins block production. This is a private testnet and will not connect to the public Cardano network, but rather from a pre-configured genesis file. +- Once the Cardano chain is synced, Ogmios, Kupo and DB-Sync will in turn connect to the Cardano node node.socket and begin syncing the chain. - The pc-contracts-cli will insert D parameter values and register Partner Chains Node keys with the Cardano chain. - Once Postgres is populated with the required data, the Partner Chains nodes will begin syncing the chain and will begin block production after 2 main chain epochs. @@ -45,7 +45,7 @@ We recommend using a visual Docker UI tool such as [lazydocker](https://github.c ## Stopping the environment -When stopping the stack, it is mandatory to also wipe all volumes. The environment does not yet support persistent state. To tear down the environment and remove all volumes, use the following: +When stopping the stack, it is mandatory to also wipe all volumes. The environment does not yet support persistent state. To tear down the environment and remove all volumes, use the following: ``` docker compose down --volumes @@ -71,7 +71,7 @@ bash setup.sh --non-interactive --overrides --node-image ${{ inputs.image }} ## Custom Deployment Options The `setup.sh` script supports argument `--deployment-option X` with the below possible options: - + 1. Include only Cardano testnet 2. Include Cardano testnet with Kupo and Ogmios 3. Include Cardano testnet, Kupo, Ogmios, DB-Sync and Postgres diff --git a/dev/local-environment/configurations/cardano/entrypoint.sh b/dev/local-environment/configurations/cardano/entrypoint.sh index 5a90f205a..304436d4e 100644 --- a/dev/local-environment/configurations/cardano/entrypoint.sh +++ b/dev/local-environment/configurations/cardano/entrypoint.sh @@ -6,12 +6,7 @@ chmod 777 /shared echo "Calculating target time for synchronised chain start..." -remaining_seconds=$((60 - $(date +'%-S'))) -if [ $remaining_seconds -le 20 ]; then - sleep $remaining_seconds -fi - -target_time=$(( ($(date +%s) / 60 + 1) * 60 )) +target_time=$(( ($(date +%s) / 10 + 1) * 10 )) echo "$target_time" > /shared/cardano.start byron_startTime=$target_time shelley_systemStart=$(date --utc +"%Y-%m-%dT%H:%M:%SZ" --date="@$target_time") @@ -55,17 +50,8 @@ byron_startTimeMillis=$(($byron_startTime * 1000)) echo $byron_startTimeMillis > /shared/MC__FIRST_EPOCH_TIMESTAMP_MILLIS echo "Created /shared/MC__FIRST_EPOCH_TIMESTAMP_MILLIS with value: $byron_startTimeMillis" -adjusted_target_time=$((target_time - 10)) -current_epoch=$(date +%s%3N) -sleep_milliseconds=$((adjusted_target_time * 1000 - current_epoch)) -sleep_seconds=$((sleep_milliseconds / 1000)) -remaining_milliseconds=$((sleep_milliseconds % 1000)) -total_sleep_time=$(printf "%.3f" "$(echo "$sleep_milliseconds / 1000" | /busybox bc)") -echo "Waiting for $total_sleep_time seconds until 10 seconds before the target time..." -sleep $total_sleep_time echo "Current time is now: $(date +"%H:%M:%S.%3N"). Starting node..." -echo "Starting node..." cardano-node run \ --topology /shared/node-1-topology.json \ --database-path /data/db \ @@ -141,8 +127,8 @@ cardano-cli latest transaction submit \ --tx-file /data/tx.signed \ --testnet-magic 42 -echo "Transaction submitted to fund registered candidates and governance authority. Waiting 40 seconds for transaction to process..." -sleep 40 +echo "Transaction submitted to fund registered candidates and governance authority. Waiting 20 seconds for transaction to process..." +sleep 20 echo "Balance:" # Query UTXOs at new_address, dave_address, and eve_address diff --git a/dev/local-environment/configurations/db-sync/entrypoint.sh b/dev/local-environment/configurations/db-sync/entrypoint.sh index f40dfd9e9..6c4e9e29b 100644 --- a/dev/local-environment/configurations/db-sync/entrypoint.sh +++ b/dev/local-environment/configurations/db-sync/entrypoint.sh @@ -6,7 +6,7 @@ while true; do if [ -f "/shared/cardano.ready" ]; then break else - sleep 10 + sleep 1 fi done @@ -27,4 +27,4 @@ if [ -n "$entrypoint_executable" ]; then exec "$entrypoint_executable" --config /shared/db-sync-config.json --socket-path /node-ipc/node.socket else echo "Entrypoint executable not found." -fi \ No newline at end of file +fi diff --git a/dev/local-environment/configurations/kupo/entrypoint.sh b/dev/local-environment/configurations/kupo/entrypoint.sh index b3cf14dd1..183f903f4 100644 --- a/dev/local-environment/configurations/kupo/entrypoint.sh +++ b/dev/local-environment/configurations/kupo/entrypoint.sh @@ -6,7 +6,7 @@ while true; do if [ -f "/shared/cardano.ready" ]; then break else - sleep 10 + sleep 1 fi done diff --git a/dev/local-environment/configurations/ogmios/entrypoint.sh b/dev/local-environment/configurations/ogmios/entrypoint.sh index 208af61d3..77536e55b 100644 --- a/dev/local-environment/configurations/ogmios/entrypoint.sh +++ b/dev/local-environment/configurations/ogmios/entrypoint.sh @@ -6,7 +6,7 @@ while true; do if [ -f "/shared/cardano.ready" ]; then break else - sleep 10 + sleep 1 fi done diff --git a/dev/local-environment/configurations/partner-chains-nodes/partner-chains-node-1/entrypoint.sh b/dev/local-environment/configurations/partner-chains-nodes/partner-chains-node-1/entrypoint.sh index f9a2a5467..bdfaf5e0c 100644 --- a/dev/local-environment/configurations/partner-chains-nodes/partner-chains-node-1/entrypoint.sh +++ b/dev/local-environment/configurations/partner-chains-nodes/partner-chains-node-1/entrypoint.sh @@ -6,7 +6,7 @@ while true; do if [ -f "/shared/pc-contracts-cli.ready" ]; then break else - sleep 10 + sleep 1 fi done diff --git a/dev/local-environment/configurations/partner-chains-nodes/partner-chains-node-2/entrypoint.sh b/dev/local-environment/configurations/partner-chains-nodes/partner-chains-node-2/entrypoint.sh index 341e28a73..b12d87689 100644 --- a/dev/local-environment/configurations/partner-chains-nodes/partner-chains-node-2/entrypoint.sh +++ b/dev/local-environment/configurations/partner-chains-nodes/partner-chains-node-2/entrypoint.sh @@ -6,7 +6,7 @@ while true; do if [ -f "/shared/pc-contracts-cli.ready" ]; then break else - sleep 10 + sleep 1 fi done @@ -16,7 +16,7 @@ while true; do if [ -f "/shared/2-epochs.ready" ]; then break else - sleep 10 + sleep 1 fi done @@ -26,7 +26,7 @@ while true; do if [ -f "/shared/partner-chains-node-1.ready" ]; then break else - sleep 10 + sleep 1 fi done diff --git a/dev/local-environment/configurations/partner-chains-nodes/partner-chains-node-3/entrypoint.sh b/dev/local-environment/configurations/partner-chains-nodes/partner-chains-node-3/entrypoint.sh index 054c4c685..bd5d8ec41 100644 --- a/dev/local-environment/configurations/partner-chains-nodes/partner-chains-node-3/entrypoint.sh +++ b/dev/local-environment/configurations/partner-chains-nodes/partner-chains-node-3/entrypoint.sh @@ -6,7 +6,7 @@ while true; do if [ -f "/shared/pc-contracts-cli.ready" ]; then break else - sleep 10 + sleep 1 fi done @@ -16,7 +16,7 @@ while true; do if [ -f "/shared/2-epochs.ready" ]; then break else - sleep 10 + sleep 1 fi done @@ -26,7 +26,7 @@ while true; do if [ -f "/shared/partner-chains-node-1.ready" ] && [ -f "/shared/partner-chains-node-2.ready" ]; then break else - sleep 10 + sleep 1 fi done diff --git a/dev/local-environment/configurations/partner-chains-nodes/partner-chains-node-4/entrypoint.sh b/dev/local-environment/configurations/partner-chains-nodes/partner-chains-node-4/entrypoint.sh index 4de69d730..e6a3e6e9e 100644 --- a/dev/local-environment/configurations/partner-chains-nodes/partner-chains-node-4/entrypoint.sh +++ b/dev/local-environment/configurations/partner-chains-nodes/partner-chains-node-4/entrypoint.sh @@ -6,7 +6,7 @@ while true; do if [ -f "/shared/pc-contracts-cli.ready" ]; then break else - sleep 10 + sleep 1 fi done @@ -16,7 +16,7 @@ while true; do if [ -f "/shared/2-epochs.ready" ]; then break else - sleep 10 + sleep 1 fi done diff --git a/dev/local-environment/configurations/partner-chains-nodes/partner-chains-node-5/entrypoint.sh b/dev/local-environment/configurations/partner-chains-nodes/partner-chains-node-5/entrypoint.sh index 4ab31846c..40adfe5cc 100644 --- a/dev/local-environment/configurations/partner-chains-nodes/partner-chains-node-5/entrypoint.sh +++ b/dev/local-environment/configurations/partner-chains-nodes/partner-chains-node-5/entrypoint.sh @@ -6,7 +6,7 @@ while true; do if [ -f "/shared/pc-contracts-cli.ready" ]; then break else - sleep 10 + sleep 1 fi done @@ -16,7 +16,7 @@ while true; do if [ -f "/shared/2-epochs.ready" ]; then break else - sleep 10 + sleep 1 fi done @@ -26,7 +26,7 @@ while true; do if [ -f "/shared/partner-chains-node-1.ready" ] && [ -f "/shared/partner-chains-node-2.ready" ] && [ -f "/shared/partner-chains-node-3.ready" ] && [ -f "/shared/partner-chains-node-4.ready" ]; then break else - sleep 10 + sleep 1 fi done diff --git a/dev/local-environment/configurations/pc-contracts-cli/entrypoint.sh b/dev/local-environment/configurations/pc-contracts-cli/entrypoint.sh index 4b8994225..4e46eaba9 100644 --- a/dev/local-environment/configurations/pc-contracts-cli/entrypoint.sh +++ b/dev/local-environment/configurations/pc-contracts-cli/entrypoint.sh @@ -69,7 +69,7 @@ while true; do if nc -z kupo $KUPO_PORT && nc -z ogmios $OGMIOS_PORT; then break else - sleep 10 + sleep 1 fi done