Skip to content

Commit f98f9d2

Browse files
authored
Merge pull request #2744 from input-output-hk/djo/2704/cdb-by-epoch-in-client
feat: add fetching cardano database snapshots by epoch in client and cli
2 parents 29375b2 + 18dfe19 commit f98f9d2

File tree

39 files changed

+1389
-320
lines changed

39 files changed

+1389
-320
lines changed

.github/workflows/test-client.yml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -250,6 +250,17 @@ jobs:
250250
./mithril-client ${{ steps.prepare.outputs.debug_level }} --origin-tag CI cardano-db snapshot list
251251
echo "CARDANO_DATABASE_V2_SNAPSHOT_HASH=$(./mithril-client --origin-tag CI cardano-db snapshot list --json | jq -r '.[0].hash')" >> $GITHUB_ENV
252252
253+
- name: Cardano Database V2 Snapshot / list for latest epoch
254+
if: steps.aggregator_capability_unix.outputs.cardano_database_v2_enabled == 'true' || steps.aggregator_capability_windows.outputs.cardano_database_v2_enabled == 'true'
255+
shell: bash
256+
working-directory: ./bin
257+
run: |
258+
./mithril-client ${{ steps.prepare.outputs.debug_level }} --origin-tag CI cardano-db snapshot list --epoch latest-1
259+
if [ $(./mithril-client ${{ steps.prepare.outputs.debug_level }} --origin-tag CI cardano-db snapshot list --epoch latest-1 --json | jq 'length') -eq 0 ]; then
260+
echo "Error: No snapshots found for latest epoch"
261+
exit 1
262+
fi
263+
253264
- name: Cardano Database V2 Snapshot / show snapshot
254265
if: steps.aggregator_capability_unix.outputs.cardano_database_v2_enabled == 'true' || steps.aggregator_capability_windows.outputs.cardano_database_v2_enabled == 'true'
255266
shell: bash
@@ -414,6 +425,16 @@ jobs:
414425
${{ steps.command.outputs.mithril_client }} --origin-tag CI cardano-db snapshot list
415426
echo "CARDANO_DATABASE_V2_SNAPSHOT_HASH=$(${{ steps.command.outputs.mithril_client }} --origin-tag CI cardano-db snapshot list --json | jq -r '.[0].hash')" >> $GITHUB_ENV
416427
428+
- name: Cardano Database V2 Snapshot / list for latest epoch
429+
if: steps.aggregator_capability.outputs.cardano_database_v2_enabled == 'true'
430+
shell: bash
431+
run: |
432+
${{ steps.command.outputs.mithril_client }} --origin-tag CI cardano-db snapshot list --epoch latest-1
433+
if [ $(${{ steps.command.outputs.mithril_client }} --origin-tag CI cardano-db snapshot list --epoch latest-1 --json | jq 'length') -eq 0 ]; then
434+
echo "Error: No snapshots found for latest epoch"
435+
exit 1
436+
fi
437+
417438
- name: Cardano Database V2 Snapshot / show snapshot
418439
if: steps.aggregator_capability.outputs.cardano_database_v2_enabled == 'true'
419440
shell: bash
@@ -439,6 +460,16 @@ jobs:
439460
- name: Checkout sources
440461
uses: actions/checkout@v4
441462

463+
- name: Prepare environment variables
464+
id: prepare
465+
shell: bash
466+
run: |
467+
if [[ -n "${{ inputs.commit_sha }}" ]]; then
468+
echo "sha=${{ inputs.commit_sha }}" >> $GITHUB_OUTPUT
469+
else
470+
echo "branch=main" >> $GITHUB_OUTPUT
471+
fi
472+
442473
- name: Download built artifacts
443474
uses: dawidd6/action-download-artifact@v6
444475
with:

CHANGELOG.md

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,17 @@ As a minor extension, we have adopted a slightly different versioning convention
1313

1414
- Support for multiple aggregate signature proof systems.
1515

16+
- Mithril-Aggregator:
17+
- Added a `/artifact/cardano-database/epoch/{epoch}` route to fetch the list of cardano database snapshots for a given epoch, `{epoch}` can be a number, `latest`, or `latest-{offset}`.
18+
- Enhanced `/artifact/cardano-stake-distribution/epoch/{epoch}` route to support `latest` and `latest-{offset}` as `{epoch}` values.
19+
20+
- Client library and WASM:
21+
- Added listing of `cardano_database_v2` snapshots for a given epoch, the latest epoch, or the latest epoch with offset
22+
- Added listing of `cardano_staked_distribution` snapshots for the latest epoch, or the latest epoch with offset
23+
24+
- Client CLI:
25+
- Added `--epoch` optional parameter to `cardano-database snapshot list` commands snapshots, the given value can be a number, `latest`, or `latest-{offset}`.
26+
1627
- Crates versions:
1728

1829
| Crate | Version |
@@ -21,7 +32,7 @@ As a minor extension, we have adopted a slightly different versioning convention
2132

2233
## Mithril Distribution [2537] - 2025-09-17
2334

24-
- Client library, CI and WASM:
35+
- Client library, CLI and WASM:
2536
- Support for stable `cardano_database_v2` backend in the `mithril-client` library.
2637

2738
- Support for stable `v2` backend of `cardano-db` command and decommission of the `cardano-db-v2` command in client CLI.

Cargo.lock

Lines changed: 8 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/website/root/manual/develop/nodes/mithril-client.md

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -570,20 +570,21 @@ Here is a list of the available parameters:
570570

571571
`cardano-db snapshot list` command:
572572

573-
| Parameter | Command line (long) | Command line (short) | Environment variable | Description | Default value | Example | Mandatory |
574-
| --------------------- | ----------------------- | :------------------: | --------------------- | --------------------------------------------------------------------------------------------------------------------- | ------------- | ------- | :-------: |
575-
| `backend` | `--backend` | `-b` | - | Backend to use, either: `v1` (full database restoration only) or `v2` (default, full or partial database restoration) | `v2` | - | - |
576-
| `run_mode` | `--run-mode` | - | `RUN_MODE` | Run Mode | `dev` | - | - |
577-
| `verbose` | `--verbose` | `-v` | - | Verbosity level (-v=warning, -vv=info, -vvv=debug, -vvvv=trace) | `0` | - | - |
578-
| `config_directory` | `--config-directory` | - | - | Directory where configuration file is located | `./config` | - | - |
579-
| `aggregator_endpoint` | `--aggregator-endpoint` | - | `AGGREGATOR_ENDPOINT` | Override configuration Aggregator endpoint URL | - | - | - |
580-
| `json` | `--json` | - | - | Enable JSON output for command results | `false` | - | - |
581-
| `log_format_json` | `--log-format-json` | - | - | Enable JSON output for logs displayed according to verbosity level | `false` | - | - |
582-
| `log_output` | `--log-output` | - | - | Redirect the logs to a file | - | - | - |
583-
| `unstable` | `--unstable` | - | - | Enable unstable commands | `false` | - | - |
584-
| `origin_tag` | `--origin-tag` | - | - | Request origin tag | - | - | - |
585-
| `era` | `--era` | - | - | Override the Mithril era | - | - | - |
586-
| `help` | `--help` | `-h` | - | Print help (see more with '--help') | - | - | - |
573+
| Parameter | Command line (long) | Command line (short) | Environment variable | Description | Default value | Example | Mandatory |
574+
| --------------------- | ----------------------- | :------------------: | --------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------- | ------- | :-------: |
575+
| `backend` | `--backend` | `-b` | - | Backend to use, either: `v1` (full database restoration only) or `v2` (default, full or partial database restoration) | `v2` | - | - |
576+
| `epoch` | `--epoch` | - | - | [backend `v2` only] Epoch of the Cardano db snapshots to list, or `latest` for the latest artifact, or `latest-X` for the artifact of the latest epoch minus X | - | - | - |
577+
| `run_mode` | `--run-mode` | - | `RUN_MODE` | Run Mode | `dev` | - | - |
578+
| `verbose` | `--verbose` | `-v` | - | Verbosity level (-v=warning, -vv=info, -vvv=debug, -vvvv=trace) | `0` | - | - |
579+
| `config_directory` | `--config-directory` | - | - | Directory where configuration file is located | `./config` | - | - |
580+
| `aggregator_endpoint` | `--aggregator-endpoint` | - | `AGGREGATOR_ENDPOINT` | Override configuration Aggregator endpoint URL | - | - | - |
581+
| `json` | `--json` | - | - | Enable JSON output for command results | `false` | - | - |
582+
| `log_format_json` | `--log-format-json` | - | - | Enable JSON output for logs displayed according to verbosity level | `false` | - | - |
583+
| `log_output` | `--log-output` | - | - | Redirect the logs to a file | - | - | - |
584+
| `unstable` | `--unstable` | - | - | Enable unstable commands | `false` | - | - |
585+
| `origin_tag` | `--origin-tag` | - | - | Request origin tag | - | - | - |
586+
| `era` | `--era` | - | - | Override the Mithril era | - | - | - |
587+
| `help` | `--help` | `-h` | - | Print help (see more with '--help') | - | - | - |
587588

588589
`cardano-db download` command:
589590

examples/client-wasm-nodejs/package-lock.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

examples/client-wasm-web/package-lock.json

Lines changed: 9 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

internal/mithril-build-script/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "mithril-build-script"
3-
version = "0.2.27"
3+
version = "0.2.28"
44
description = "A toolbox for Mithril crates build scripts"
55
authors = { workspace = true }
66
edition = { workspace = true }

0 commit comments

Comments
 (0)