Skip to content

Commit b2b61e2

Browse files
committed
Add a script for downloading mithril snapshots
Also mention using mithril in the ledger-state README
1 parent 2a14f45 commit b2b61e2

File tree

2 files changed

+79
-0
lines changed

2 files changed

+79
-0
lines changed

libs/ledger-state/README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,14 @@ curl -O -J https://book.play.dev.cardano.org/environments/mainnet/conway-genesis
3030

3131
Download or build copies of `cardano-node` and `cardano-cli`. A convenient way of doing this is to download the assets from one of the `cardano-node` [releases](https://github.com/IntersectMBO/cardano-node/releases) on GitHub. The Linux executables are statically linked, so will run on any system.
3232

33+
Download a snapshot of the node db using [mithril](https://mithril.network/doc/manual/getting-started/bootstrap-cardano-node/#bootstrap-a-cardano-node-from-a-testnet-mithril-cardano-db-snapshot). This will greatly speed up the process of syncing the node. There's a convenient nix-based script for doing it in `scripts/mithril-download.sh`:
34+
35+
```shell
36+
$ scripts/mithril-download.sh -d "${CARDANO_DATA}/db" mainnet
3337
```
3438

39+
Note that you will need to get a snapshot that's compatible with the version of `cardano-node` you're using.
40+
3541
Start the node and wait for it to fully sync
3642

3743
```shell

scripts/mithril-download.sh

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
#!/usr/bin/env bash
2+
3+
set -euo pipefail
4+
5+
6+
7+
export NETWORK=mainnet
8+
export UNPACK_DIR=cardano-db
9+
export MITHRIL_VERSION=2513.0
10+
11+
usage()
12+
{
13+
cat <<-EOF
14+
Usage: $(basename "$0") [-h] [-d DIR] [-v VERSION] NETWORK
15+
Download cardano-db using mithril
16+
17+
Options:
18+
-h Show this help text
19+
-d DIR Unpack the DB into DIR (default: $UNPACK_DIR)
20+
-v VERSION Use version VERSION of the mithril client (default: $MITHRIL_VERSION)
21+
22+
Arguments:
23+
NETWORK Download the DB for NETWORK (default: $NETWORK)
24+
EOF
25+
26+
exit "${1:-0}"
27+
}
28+
29+
while getopts hd:v: OPT
30+
do
31+
case "$OPT" in
32+
\?) usage 1 >&2;;
33+
h) usage;;
34+
d) UNPACK_DIR=$OPTARG;;
35+
v) MITHRIL_VERSION=$OPTARG;;
36+
esac
37+
done
38+
39+
shift $((OPTIND - 1))
40+
41+
case $# in
42+
0) ;;
43+
1) NETWORK=$1;;
44+
*) usage 2 >&2;;
45+
esac
46+
47+
case "$NETWORK" in
48+
"mainnet") MITHRIL_NETWORK="release-mainnet" ;;
49+
"preprod") MITHRIL_NETWORK="release-preprod" ;;
50+
"preview") MITHRIL_NETWORK="pre-release-preview" ;;
51+
*) echo >&2 "fatal: invalid NETWORK value: $NETWORK"; exit 1 ;;
52+
esac
53+
export MITHRIL_NETWORK
54+
55+
export AGGREGATOR_ENDPOINT="https://aggregator.${MITHRIL_NETWORK}.api.mithril.network/aggregator"
56+
57+
# shellcheck disable=SC2016
58+
nix shell \
59+
"github:input-output-hk/mithril/${MITHRIL_VERSION}#mithril-client-cli" \
60+
nixpkgs#jq \
61+
nixpkgs#bash \
62+
nixpkgs#curl \
63+
--command bash -c '
64+
set -euo pipefail
65+
66+
SNAPSHOT_DIGEST=$(mithril-client cardano-db snapshot list --json | jq -r ".[0].digest")
67+
68+
GENESIS_VERIFICATION_KEY=$(curl -fsSL "https://raw.githubusercontent.com/input-output-hk/mithril/${MITHRIL_VERSION}/mithril-infra/configuration/${MITHRIL_NETWORK}/genesis.vkey")
69+
export GENESIS_VERIFICATION_KEY
70+
71+
set -x
72+
mithril-client cardano-db download "$SNAPSHOT_DIGEST" --download-dir "$UNPACK_DIR"
73+
'

0 commit comments

Comments
 (0)