Skip to content

Commit f84e906

Browse files
committed
Add nix mainnet node boot sync via mithril buildkite step
1 parent 9533a96 commit f84e906

File tree

3 files changed

+53
-18
lines changed

3 files changed

+53
-18
lines changed

.buildkite/pipeline.yml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,33 @@ steps:
191191
CLEANUP_DB: true
192192
NETWORK: mainnet
193193

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+
194221
- block: Sanchonet Full Sync
195222
if: build.env("RELEASE_CANDIDATE") == null
196223
depends_on: []

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/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)