Skip to content

Commit

Permalink
Fix readme and decrease sleep times (#303)
Browse files Browse the repository at this point in the history
  • Loading branch information
LGLO authored Dec 6, 2024
1 parent cfc4e1e commit 1866457
Show file tree
Hide file tree
Showing 11 changed files with 26 additions and 40 deletions.
12 changes: 6 additions & 6 deletions dev/local-environment/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand All @@ -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
Expand All @@ -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
Expand Down
20 changes: 3 additions & 17 deletions dev/local-environment/configurations/cardano/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down Expand Up @@ -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 \
Expand Down Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions dev/local-environment/configurations/db-sync/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ while true; do
if [ -f "/shared/cardano.ready" ]; then
break
else
sleep 10
sleep 1
fi
done

Expand All @@ -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
fi
2 changes: 1 addition & 1 deletion dev/local-environment/configurations/kupo/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ while true; do
if [ -f "/shared/cardano.ready" ]; then
break
else
sleep 10
sleep 1
fi
done

Expand Down
2 changes: 1 addition & 1 deletion dev/local-environment/configurations/ogmios/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ while true; do
if [ -f "/shared/cardano.ready" ]; then
break
else
sleep 10
sleep 1
fi
done

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ while true; do
if [ -f "/shared/pc-contracts-cli.ready" ]; then
break
else
sleep 10
sleep 1
fi
done

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ while true; do
if [ -f "/shared/pc-contracts-cli.ready" ]; then
break
else
sleep 10
sleep 1
fi
done

Expand All @@ -16,7 +16,7 @@ while true; do
if [ -f "/shared/2-epochs.ready" ]; then
break
else
sleep 10
sleep 1
fi
done

Expand All @@ -26,7 +26,7 @@ while true; do
if [ -f "/shared/partner-chains-node-1.ready" ]; then
break
else
sleep 10
sleep 1
fi
done

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ while true; do
if [ -f "/shared/pc-contracts-cli.ready" ]; then
break
else
sleep 10
sleep 1
fi
done

Expand All @@ -16,7 +16,7 @@ while true; do
if [ -f "/shared/2-epochs.ready" ]; then
break
else
sleep 10
sleep 1
fi
done

Expand All @@ -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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ while true; do
if [ -f "/shared/pc-contracts-cli.ready" ]; then
break
else
sleep 10
sleep 1
fi
done

Expand All @@ -16,7 +16,7 @@ while true; do
if [ -f "/shared/2-epochs.ready" ]; then
break
else
sleep 10
sleep 1
fi
done

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ while true; do
if [ -f "/shared/pc-contracts-cli.ready" ]; then
break
else
sleep 10
sleep 1
fi
done

Expand All @@ -16,7 +16,7 @@ while true; do
if [ -f "/shared/2-epochs.ready" ]; then
break
else
sleep 10
sleep 1
fi
done

Expand All @@ -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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit 1866457

Please sign in to comment.