Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ADP-3392] Add run scripts and test for preview network #4795

Merged
merged 8 commits into from
Sep 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 39 additions & 5 deletions .buildkite/pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,6 @@ steps:

- label: Private Network Full Sync
timeout_in_minutes: 30
if: 0 == 1 # Disabled until new mihtril snapshots
depends_on: []
command: |
rm -rf run/private/nix/logs
Expand All @@ -162,9 +161,28 @@ steps:
CLEANUP_DB: true
NETWORK: testnet

- label: Preview Network Boot Sync
timeout_in_minutes: 2
depends_on: []
command: |
cd run/preview/nix
rm -rf logs
mkdir -p logs
rm -rf databases
./run.sh sync
artifact_paths:
- "./run/private/nix/logs/*"
agents:
system: x86_64-linux
env:
SUCCESS_STATUS: syncing
NODE_LOGS_FILE: ./logs/node.log
WALLET_LOGS_FILE: ./logs/wallet.log
CLEANUP_DB: true
NETWORK: testnet

- label: Mainnet Boot Sync
timeout_in_minutes: 2
if: 0 == 1 # Disabled until mithril builds again
depends_on: []
command: |
cd run/mainnet/nix
Expand All @@ -190,7 +208,9 @@ steps:

- label: Mainnet Boot Sync with Mithril
timeout_in_minutes: 120
if: 0 == 1 # Disabled until new mihtril snapshots
# mithril is not compiling with nix ATM
soft_fail :
- exit_status: 44
depends_on:
- linux-mainnet-full-sync-block
command: |
Expand Down Expand Up @@ -222,7 +242,6 @@ steps:
depends_on:
- linux-sanchonet-full-sync-block
timeout_in_minutes: 120
if: 0 == 1 # Disabled until mithril builds again
command: |
rm -rf run/sanchonet/nix/logs
mkdir -p run/sanchonet/nix/logs
Expand All @@ -247,7 +266,8 @@ steps:
depends_on:
- linux-preprod-full-sync-block
timeout_in_minutes: 240
if: 0 == 1 # Disabled until mithril builds again
soft_fail:
- exit_status: 45
command: |
cd run/preprod/nix
rm -rf logs
Expand Down Expand Up @@ -752,6 +772,18 @@ steps:
system: x86_64-linux
env:
USE_LOCAL_IMAGE: true

- label: Preview Network Full Sync
timeout_in_minutes: 60
command: |
cd run/preview/docker
export WALLET_TAG=$(buildkite-agent meta-data get "release-cabal-version")
rm -rf databases
./run.sh sync
agents:
system: x86_64-linux
env:
USE_LOCAL_IMAGE: true

- label: Sanchonet Full Sync
timeout_in_minutes: 240
Expand All @@ -767,6 +799,8 @@ steps:

- label: Preprod Full Sync
timeout_in_minutes: 240
soft_fail:
- exit_status: 45
command: |
cd run/preprod/docker
export WALLET_TAG=$(buildkite-agent meta-data get "release-cabal-version")
Expand Down
12 changes: 6 additions & 6 deletions configs/cardano/preview/download.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
set -euo pipefail

rm ./*.json
curl https://book.play.dev.cardano.org/environments-pre/preview/config.json > config.json
curl https://book.play.dev.cardano.org/environments-pre/preview/conway-genesis.json > conway-genesis.json
curl https://book.play.dev.cardano.org/environments-pre/preview/topology.json > topology.json
curl https://book.play.dev.cardano.org/environments-pre/preview/byron-genesis.json > byron-genesis.json
curl https://book.play.dev.cardano.org/environments-pre/preview/shelley-genesis.json > shelley-genesis.json
curl https://book.play.dev.cardano.org/environments-pre/preview/alonzo-genesis.json > alonzo-genesis.json
curl https://book.play.dev.cardano.org/environments/preview/config.json > config.json
curl https://book.play.dev.cardano.org/environments/preview/conway-genesis.json > conway-genesis.json
curl https://book.play.dev.cardano.org/environments/preview/topology.json > topology.json
curl https://book.play.dev.cardano.org/environments/preview/byron-genesis.json > byron-genesis.json
curl https://book.play.dev.cardano.org/environments/preview/shelley-genesis.json > shelley-genesis.json
curl https://book.play.dev.cardano.org/environments/preview/alonzo-genesis.json > alonzo-genesis.json
3 changes: 1 addition & 2 deletions lib/exe/lib/Cardano/Wallet/Application/CLI.hs
Original file line number Diff line number Diff line change
Expand Up @@ -1527,13 +1527,12 @@ portOption = optionT $ mempty
<> value (Port 8_090)
<> showDefaultWith showT

-- | [--deposit-port=INT], default: 8093
-- | [--deposit-port=INT]
depositPortOption :: Parser (Port "Deposit Wallet")
depositPortOption = optionT $ mempty
<> long "deposit-port"
<> metavar "INT"
<> help "port used for serving the deposit wallet JSON API."
<> value (Port 8_093)
<> showDefaultWith showT

-- | [--shutdown-handler]
Expand Down
22 changes: 15 additions & 7 deletions run/common/nix/run.sh
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
#! /usr/bin/env -S nix shell '.#cardano-wallet' '.#cardano-node' '.#cardano-cli' 'github:input-output-hk/mithril' --command bash
#! /usr/bin/env -S nix shell '.#cardano-wallet' '.#cardano-node' '.#cardano-cli' --command bash
# shellcheck shell=bash

# set -euox pipefail
set -euo pipefail
cardano-wallet serve --help-tracing

usage() {
echo "Usage: $0 [sync]"
echo " sync: Sync the service and wait for it to be ready"
Expand All @@ -18,8 +18,6 @@ fi
# shellcheck disable=SC1091
source .env



mkdir -p ./databases

# Define a local db if WALLET_DB is not set
Expand Down Expand Up @@ -63,6 +61,7 @@ LOCAL_NODE_LOGS_FILE=./node.log
NODE_LOGS_FILE="${NODE_LOGS_FILE:=$LOCAL_NODE_LOGS_FILE}"

cleanup() {
exit_status=$?
echo "Cleaning up..."
kill "${NODE_ID-}" || echo "Failed to kill node"
kill "${WALLET_ID-}" || echo "Failed to kill wallet"
Expand All @@ -73,6 +72,13 @@ cleanup() {
rm -rf "${WALLET_DB:?}"/* || echo "Failed to clean wallet db"
fi
trap - ERR INT EXIT
exit $exit_status
}

mithril() {
# shellcheck disable=SC2048
# shellcheck disable=SC2086
nix shell "github:input-output-hk/mithril" -c $*
}

# Trap the cleanup function on exit
Expand All @@ -89,8 +95,9 @@ if [[ -z ${NO_NODE-} ]]; then
rm -rf "${NODE_DB:?}"/*
export AGGREGATOR_ENDPOINT
export GENESIS_VERIFICATION_KEY
digest=$(mithril-client cdb snapshot list --json | jq -r .[0].digest)
(cd "${NODE_DB}" && mithril-client cdb download "$digest")
mithril echo "mithril is available" || exit 44
digest=$(mithril mithril-client cdb snapshot list --json | jq -r .[0].digest)
(cd "${NODE_DB}" && mithril mithril-client cdb download "$digest")
(cd "${NODE_DB}" && mv db/* . && rmdir db)
fi

Expand All @@ -115,6 +122,7 @@ else
fi


magic=$(jq .networkMagic $LOCAL_NODE_CONFIGS/shelley-genesis.json)
##### Wait until the node is ready #####

# Capture the start time
Expand All @@ -127,7 +135,7 @@ timeout_duration=3600
while true; do
# Execute the command
failure_status=0
cardano-cli ping -u "${NODE_SOCKET_PATH}" 2>/dev/null || failure_status=1
cardano-cli ping -m "${magic}" -u "${NODE_SOCKET_PATH}" 2>/dev/null || failure_status=1
# Check if the command succeeded
# shellcheck disable=SC2181
if [[ "$failure_status" -eq 0 ]]; then
Expand Down
2 changes: 1 addition & 1 deletion run/common/snapshot.sh
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ if [ -n "${LINK_TEST:-}" ]; then
exit 0
fi

curl -SL "$SNAPSHOT_URL" | lz4 -c -d - | tar -x -C "$NODE_DB"
curl -SL "$SNAPSHOT_URL" | lz4 -c -d - | tar -x -C "$NODE_DB" || exit 45

mv -f "$NODE_DB"/db/* "$NODE_DB"/
rm -rf "$NODE_DB"/db
Expand Down
1 change: 1 addition & 0 deletions run/preview/docker/.env
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
NETWORK="preview"
1 change: 1 addition & 0 deletions run/preview/docker/configs
1 change: 1 addition & 0 deletions run/preview/docker/docker-compose.yml
1 change: 1 addition & 0 deletions run/preview/docker/run.sh
1 change: 1 addition & 0 deletions run/preview/nix/.env
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
NETWORK="preview"
1 change: 1 addition & 0 deletions run/preview/nix/configs
1 change: 1 addition & 0 deletions run/preview/nix/run-node.sh
1 change: 1 addition & 0 deletions run/preview/nix/run-wallet.sh
1 change: 1 addition & 0 deletions run/preview/nix/run.sh
1 change: 1 addition & 0 deletions run/private/nix/run-node.sh
1 change: 1 addition & 0 deletions run/private/nix/run-wallet.sh
Loading