Skip to content

Commit 5c8fd18

Browse files
authored
2 parents f2f4ffd + f84e906 commit 5c8fd18

File tree

6 files changed

+100
-24
lines changed

6 files changed

+100
-24
lines changed

.buildkite/pipeline.yml

Lines changed: 44 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ steps:
1919
# Check whether regenerate.sh was applied when it had to be applied.
2020
key: linux-nix
2121
commands:
22+
- nix --version
2223
- nix/regenerate.sh
2324
agents:
2425
system: ${linux}
@@ -37,11 +38,11 @@ steps:
3738
- label: Check Nix (macOS)
3839
key: macos-nix
3940
commands:
40-
- 'nix flake info'
41+
- nix --version
42+
- nix flake info
4143
agents:
4244
system: ${macos}
4345

44-
4546
- label: Dev Shell Attic Cache (macos)
4647
depends_on:
4748
- macos-nix
@@ -190,6 +191,33 @@ steps:
190191
CLEANUP_DB: true
191192
NETWORK: mainnet
192193

194+
- block: Mainnet Boot Sync with Mithril
195+
if: build.env("RELEASE_CANDIDATE") == null
196+
depends_on: []
197+
key: linux-mainnet-full-sync-block
198+
199+
- label: Mainnet Boot Sync with Mithril
200+
timeout: 120
201+
depends_on:
202+
- linux-mainnet-full-sync-block
203+
command: |
204+
cd run/mainnet/nix
205+
rm -rf logs
206+
mkdir -p logs
207+
rm -rf databases
208+
./run.sh sync
209+
artifact_paths:
210+
- "./run/mainnet/nix/logs/*"
211+
agents:
212+
system: x86_64-linux
213+
env:
214+
SUCCESS_STATUS: syncing
215+
NODE_LOGS_FILE: ./logs/node.log
216+
WALLET_LOGS_FILE: ./logs/wallet.log
217+
CLEANUP_DB: true
218+
NETWORK: mainnet
219+
USE_MITHRIL: true
220+
193221
- block: Sanchonet Full Sync
194222
if: build.env("RELEASE_CANDIDATE") == null
195223
depends_on: []
@@ -481,7 +509,6 @@ steps:
481509
build.branch !~ /^gh-readonly-queue\/master/
482510
&& build.branch != "master"
483511
&& ( build.env("RELEASE_CANDIDATE") == null || build.env("TEST_RC") == "TRUE" )
484-
depends_on: macos-nix
485512
key: block-macos
486513

487514
- label: Build Integration Tests (macOS, arm64)
@@ -667,6 +694,20 @@ steps:
667694
SUCCESS_STATUS: syncing
668695
USE_LOCAL_IMAGE: true
669696

697+
- label: Mainnet Boot Sync via Mithril
698+
timeout_in_minutes: 120
699+
command: |
700+
cd run/mainnet/docker
701+
export WALLET_TAG=$(buildkite-agent meta-data get "release-cabal-version")
702+
rm -rf databases
703+
./run.sh node-db-with-mithril
704+
./run.sh sync
705+
agents:
706+
system: x86_64-linux
707+
env:
708+
SUCCESS_STATUS: syncing
709+
USE_LOCAL_IMAGE: true
710+
670711
- label: Private Network Full Sync
671712
timeout: 20
672713
command: |

run/common/docker/run.sh

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
#! /bin/bash
22

33
# Enforce strict script execution modes
4-
set -euo pipefail
4+
set -euox pipefail
55

66
# Function to display usage information
77
usage() {
88
echo "Usage: $0 [sync|start|stop|logs|help]"
99
echo " sync: Sync the service and wait for it to be ready"
1010
echo " start: Start the service"
11+
echo " start-with-mithril: Start the service with mithril boostrap"
1112
echo " stop: Stop the service"
1213
echo " logs: Show the service logs"
1314
echo " help: Show this help message"
@@ -53,11 +54,10 @@ rm -rf "${WALLET_DB:?}/*"
5354
# Define a local db if NODE_DB is not set
5455
if [[ -z "${NODE_DB-}" ]]; then
5556
LOCAL_NODE_DB=./databases/node-db
56-
mkdir -p $LOCAL_NODE_DB
5757
NODE_DB=$LOCAL_NODE_DB
5858
export NODE_DB
5959
fi
60-
rm -rf "${NODE_DB:?}/*"
60+
mkdir -p "${NODE_DB:?}"
6161

6262
# Get the current user's ID and export it
6363
USER_ID=$(id -u)
@@ -94,8 +94,20 @@ startup() {
9494
cleanup() {
9595
echo "Cleaning up..."
9696
docker compose down 2>/dev/null
97+
sleep 3
98+
docker compose kill 2>/dev/null
9799
}
98100

101+
node-db-with-mithril() {
102+
if [ "$NETWORK" != "mainnet" ]; then
103+
echo "Error: This option is only available for the mainnet network"
104+
exit 1
105+
fi
106+
echo "Starting the mithril service..."
107+
digest=$(docker compose -p mithril run --rm mithril cdb snapshot list --json | jq -r .[0].digest)
108+
rm -rf "${NODE_DB:?}"/*
109+
docker compose -p mithril run --rm mithril cdb download "$digest"
110+
}
99111

100112
# Case statement to handle different command-line arguments
101113
case "$1" in
@@ -164,6 +176,9 @@ case "$1" in
164176
echo "Showing logs..."
165177
docker compose logs -f # Follow the service logs
166178
;;
179+
node-db-with-mithril)
180+
node-db-with-mithril
181+
;;
167182
help)
168183
usage # Display usage information
169184
;;

run/common/nix/run.sh

Lines changed: 24 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#! /usr/bin/env -S nix shell '.#cardano-wallet' '.#cardano-node' '.#cardano-cli' --command bash
1+
#! /usr/bin/env -S nix shell '.#cardano-wallet' '.#cardano-node' '.#cardano-cli' 'github:input-output-hk/mithril' --command bash
22
# shellcheck shell=bash
33

44
# set -euox pipefail
@@ -47,10 +47,6 @@ if [[ -z "${NODE_DB-}" ]]; then
4747
export NODE_DB
4848
fi
4949

50-
if [[ -n "${CLEANUP_DB-}" ]]; then
51-
rm -rf "${NODE_DB:?}"/*
52-
fi
53-
5450
NETWORK=${NETWORK:=testnet}
5551

5652
# Define and export the node socket name
@@ -72,17 +68,34 @@ LOCAL_NODE_LOGS_FILE=./node.log
7268
NODE_LOGS_FILE="${NODE_LOGS_FILE:=$LOCAL_NODE_LOGS_FILE}"
7369

7470
cleanup() {
75-
# shellcheck disable=SC2317
7671
echo "Cleaning up..."
77-
# shellcheck disable=SC2317
78-
kill "${NODE_ID}" || echo "Failed to kill node"
79-
# shellcheck disable=SC2317
80-
kill "${WALLET_ID}" || echo "Failed to kill wallet"
72+
kill "${NODE_ID-}" || echo "Failed to kill node"
73+
kill "${WALLET_ID-}" || echo "Failed to kill wallet"
74+
sleep 5
75+
if [[ -n "${CLEANUP_DB-}" ]]; then
76+
echo "Cleaning up databases..."
77+
rm -rf "${NODE_DB:?}"/* || echo "Failed to clean node db"
78+
rm -rf "${WALLET_DB:?}"/* || echo "Failed to clean wallet db"
79+
fi
8180
}
8281

8382
# Trap the cleanup function on exit
8483
trap cleanup ERR INT EXIT
8584

85+
if [[ -n "${USE_MITHRIL-}" ]];
86+
then
87+
if [ "$NETWORK" != "mainnet" ]; then
88+
echo "Error: This option is only available for the mainnet network"
89+
exit 1
90+
fi
91+
echo "Starting the mithril service..."
92+
rm -rf "${NODE_DB:?}"/*
93+
export AGGREGATOR_ENDPOINT
94+
export GENESIS_VERIFICATION_KEY
95+
digest=$(mithril-client cdb snapshot list --json | jq -r .[0].digest)
96+
(cd "${NODE_DB}" && mithril-client cdb download "$digest")
97+
(cd "${NODE_DB}" && mv db/* . && rmdir db)
98+
fi
8699

87100
# Start the node with logs redirected to a file if NODE_LOGS_FILE is set
88101
# shellcheck disable=SC2086
@@ -157,18 +170,11 @@ else
157170
WALLET_ID=$!
158171
fi
159172

160-
cleanup() {
161-
echo "Cleaning up..."
162-
kill "${NODE_ID}" || echo "Failed to kill node"
163-
kill "${WALLET_ID}" || echo "Failed to kill wallet"
164-
}
165-
166-
# Trap the cleanup function on exit
167-
trap cleanup ERR INT EXIT
168173

169174
# Case statement to handle different command-line arguments
170175
case "$1" in
171176
sync)
177+
172178
echo "Wallet service port: $WALLET_PORT"
173179
echo "Syncing the service..."
174180
sleep 10

run/mainnet/docker/.env

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
11
NETWORK="mainnet"
2+
AGGREGATOR_ENDPOINT=https://aggregator.release-mainnet.api.mithril.network/aggregator
3+
GENESIS_VERIFICATION_KEY=5b3139312c36362c3134302c3138352c3133382c31312c3233372c3230372c3235302c3134342c32372c322c3138382c33302c31322c38312c3135352c3230342c31302c3137392c37352c32332c3133382c3139362c3231372c352c31342c32302c35372c37392c33392c3137365d

run/mainnet/docker/docker-compose.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,3 +45,13 @@ services:
4545
compress: "true"
4646
max-file: "10"
4747
max-size: "50m"
48+
49+
mithril:
50+
env_file:
51+
- .env
52+
image: ghcr.io/input-output-hk/mithril-client:test-csd-44dc188
53+
user: ${USER_ID}:${GROUP_ID}
54+
volumes:
55+
- ${NODE_DB}:/app/db
56+
profiles:
57+
- mithril

run/mainnet/nix/.env

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
11
NETWORK="mainnet"
2+
AGGREGATOR_ENDPOINT=https://aggregator.release-mainnet.api.mithril.network/aggregator
3+
GENESIS_VERIFICATION_KEY=5b3139312c36362c3134302c3138352c3133382c31312c3233372c3230372c3235302c3134342c32372c322c3138382c33302c31322c38312c3135352c3230342c31302c3137392c37352c32332c3133382c3139362c3231372c352c31342c32302c35372c37392c33392c3137365d

0 commit comments

Comments
 (0)