Skip to content

Conversation

@Alenar
Copy link
Collaborator

@Alenar Alenar commented Oct 17, 2025

Content

This PR add new capabilities to the client library and the client-cli

  • Client library:
    • cardano_database_v2: add new methods to fetch snapshots for a specific epoch, for the latest epoch, or for the latest epoch with an offset
    • cardano_stake_distribution: add new methods to fetch snapshots for the latest epoch, or for the latest epoch with an offset
  • Client CLI - cardano-database command: add a new --epoch parameter to fetch snapshots for a specific epoch, for the latest epoch, or for the latest epoch with an offset (i.e. --epoch 4, --epoch latest, --epoch latest-4)

Details

  • doc website: update documentation for the client cli cardano-database list parameters table.
  • end to end: add a new step that fetch the list of cardano db v2 snapshots for the latest-5

mithril-common

  • Epoch:
    • add new type EpochSpecifier to store user inputs in the form of <number>, latest, latest-<number> coming for either http routes path or the cli.
    • add Epoch::parse_specifier
    • implement FromStr to Epoch to allow child crates to do "87".parse::<Epoch>() instead of "87".parse::<u64>().map(Epoch)

mithril-client library

  • cardano_stake_distribution client:
    • add get_for_latest_epoch and get_for_latest_epoch_with_offset
    • isolate the error logic for list retrieval in order to simplify the tests
  • cardano_database_v2 client:
    • add list_by_epoch, list_for_latest_epoch, and list_for_latest_epoch_with_offset
  • aggregator client: add supports for the latest aggregator routes that fetch cardano database snapshots and cardano stake distribution for an epoch or latest or latest-<offset>

mithril-client-cli

  • cardano-database commands:
    • generalize to the module the warn_unused_parameter_with_v1_backend logic so it can be reused in other commands than download
    • list command: add --epoch parameter which is parsed into a EpochSpecifier and is only honored if the backend is set to v2 (else a warning is print)

mithril-client-wasm

  • add get_cardano_stake_distribution_for_latest_epoch
  • add unstable list_cardano_database_v2_per_epoch, list_cardano_database_v2_for_latest_epoch
  • both ***_for_latest_epoch functions allow to pass a json object which contains an optional offset, i.e in js:
const cardano_database_snapshots_for_latest_epoch_with_offset =
      await client.list_cardano_database_v2_for_latest_epoch({ offset: 3 });
  • update ci-test node project to check the new functions

mithril-aggregator-fake

  • add /artifact/cardano-database/epoch/{epoch} route with support of latest and latest-{offset}
  • /artifact/cardano-stake-distribution/epoch/{epoch} route: add support of latest and latest-{offset}

mithril-build-script

  • new generated hashmap (indexed by epoch number): cardano_database_snapshot_list_per_epoch, cardano_stake_distributions_per_epoch
  • new generated id list: cardano_database_snapshot_epochs (indexed by epoch number)
  • changed cardano_stake_distribution_epochs key from &str to an epoch number

Pre-submit checklist

  • Branch
    • Tests are provided (if possible)
    • Crates versions are updated (if relevant)
    • CHANGELOG file is updated (if relevant)
    • Commit sequence broadly makes sense
    • Key commits have useful messages
  • PR
    • All check jobs of the CI have succeeded
    • Self-reviewed the diff
    • Useful pull request description
    • Reviewer requested
  • Documentation
    • Update documentation website (if relevant)
    • No new TODOs introduced

Issue(s)

Relates to #2704

@Alenar Alenar self-assigned this Oct 17, 2025
@github-actions
Copy link

github-actions bot commented Oct 17, 2025

Test Results

    4 files  ± 0    168 suites  ±0   23m 16s ⏱️ -33s
2 261 tests +20  2 261 ✅ +20  0 💤 ±0  0 ❌ ±0 
6 987 runs  +80  6 987 ✅ +80  0 💤 ±0  0 ❌ ±0 

Results for commit 18dfe19. ± Comparison against base commit 29375b2.

This pull request removes 11 and adds 31 tests. Note that renamed tests count towards both.
mithril-build-script ‑ fake_aggregator::tests::extract_csd_epochs_with_invalid_json
mithril-build-script ‑ fake_aggregator::tests::extract_csd_epochs_with_valid_data
mithril-build-script ‑ fake_aggregator::tests::test_extract_csd_epochs_with_empty_map
mithril-build-script ‑ fake_aggregator::tests::test_extract_csd_epochs_with_missing_epoch
mithril-client ‑ cardano_stake_distribution_client::tests::get_cardano_stake_distribution_by_epoch_returns_error
mithril-client ‑ cardano_stake_distribution_client::tests::get_cardano_stake_distribution_by_epoch_returns_error_when_invalid_json_structure_in_response
mithril-client ‑ cardano_stake_distribution_client::tests::get_cardano_stake_distribution_by_epoch_returns_none_when_not_found_or_remote_server_logical_error
mithril-client ‑ cardano_stake_distribution_client::tests::get_cardano_stake_distribution_returns_error
mithril-client ‑ cardano_stake_distribution_client::tests::get_cardano_stake_distribution_returns_error_when_invalid_json_structure_in_response
mithril-client ‑ cardano_stake_distribution_client::tests::get_cardano_stake_distribution_returns_none_when_not_found_or_remote_server_logical_error
…
mithril-build-script ‑ fake_aggregator::tests::test_extract_item_by_epoch_by_epoch_with_invalid_json
mithril-build-script ‑ fake_aggregator::tests::test_extract_item_by_epoch_by_epoch_with_valid_data
mithril-build-script ‑ fake_aggregator::tests::test_extract_item_by_epoch_with_empty_map
mithril-build-script ‑ fake_aggregator::tests::test_extract_item_by_epoch_with_missing_epoch
mithril-build-script ‑ fake_aggregator::tests::test_extract_item_list_per_epoch_for_epoch
mithril-build-script ‑ fake_aggregator::tests::test_extract_item_list_per_epoch_with_invalid_json
mithril-build-script ‑ fake_aggregator::tests::test_extract_item_list_per_epoch_with_list
mithril-build-script ‑ fake_aggregator::tests::test_extract_item_list_per_epoch_with_missing_epoch
mithril-client ‑ cardano_database_client::fetch::tests::list::list_cardano_database_snapshots_by_epoch_returns_messages
mithril-client ‑ cardano_database_client::fetch::tests::list::list_cardano_database_snapshots_for_latest_epoch_returns_messages
…

♻️ This comment has been updated with latest results.

@Alenar Alenar force-pushed the djo/2704/cdb-by-epoch-in-client branch from 6200f62 to 24af55f Compare October 17, 2025 17:14
@Alenar Alenar temporarily deployed to testing-preview October 17, 2025 17:36 — with GitHub Actions Inactive
Copy link
Member

@jpraynaud jpraynaud left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 👍

@Alenar Alenar force-pushed the djo/2704/cdb-by-epoch-in-client branch from 24af55f to 40f0677 Compare October 20, 2025 16:33
@Alenar Alenar force-pushed the djo/2704/cdb-by-epoch-in-client branch from 40f0677 to 83ebcc0 Compare October 21, 2025 09:58
@Alenar Alenar temporarily deployed to testing-preview October 21, 2025 10:08 — with GitHub Actions Inactive
Copy link
Collaborator

@turmelclem turmelclem left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 👍

@Alenar Alenar force-pushed the djo/2704/cdb-by-epoch-in-client branch from 83ebcc0 to d711d4d Compare October 21, 2025 13:19
Alenar added 13 commits October 21, 2025 15:19
- unify error handlings tests by testing the inner function that handle
  them directly instead of copying those tests for each
- use dummy directly instead of modifying them since it does not bring
  much value here
So it can be re-used accross crates.

- `EpochSpecifier` enum to represents the cases between <{uint}, 'latest',
  latest-{uint}>
- add `Epoch::parse_specifier`
- impl `FromStr` to epoch to avoid having downstream code specifying the
  inner type of the epoch when parsing from str
- update aggregator `ExpandedEpoch` logic
- move it from the cardano db download module to its parent
  module so all cardano db commmands can use it.
- make the unused parameters list configurable
With `{epoch}` either a number, `latest`, or `latest-x` where X is a
number

+ Add support for `latest` / `latest-x` on the route
  `cardano-stake-distribution/epoch/{epoch}`
+ add epoch lists for cardano database (cdb), indexed by epoch number
+ refactor cardano stake distribution (csd) epoch list gen:
  - use a common mechanism with cdb
  - change index from str to epoch number
... to generate cardano stake distribution & cardano database lists per
epoch.

Note: this means adding `mithril-build-script` as a straight dependency
for `mithril-aggregator-fake`, this is fine since it's a test only tool.
The idea was to avoid import of `EpochSpecifier` in callers but since
the import is needed anyway to match the result it's more clear for it
to be part of the specifier api.
@Alenar Alenar force-pushed the djo/2704/cdb-by-epoch-in-client branch from d711d4d to a03655f Compare October 21, 2025 13:19
@Alenar Alenar temporarily deployed to testing-preview October 21, 2025 13:30 — with GitHub Actions Inactive
@Alenar Alenar force-pushed the djo/2704/cdb-by-epoch-in-client branch from 6560a47 to fc11abe Compare October 21, 2025 14:03
@Alenar Alenar temporarily deployed to testing-preview October 21, 2025 14:16 — with GitHub Actions Inactive
* mithril-build-script from `0.2.27` to `0.2.28`
* mithril-aggregator from `0.7.88` to `0.7.89`
* mithril-client-cli from `0.12.32` to `0.12.33`
* mithril-client-wasm from `0.9.6` to `0.9.7`
* mithril-client from `0.12.33` to `0.12.34`
* mithril-common from `0.6.23` to `0.6.24`
* mithril-aggregator-fake from `0.4.14` to `0.4.15`
* mithril-end-to-end from `0.4.105` to `0.4.106`
* [js] client-wasm-ci-test from `0.3.11` to `0.3.12`
* [js] mithril-client-wasm from `0.9.6` to `0.9.7`
@Alenar Alenar force-pushed the djo/2704/cdb-by-epoch-in-client branch from fc11abe to 18dfe19 Compare October 21, 2025 14:47
@Alenar Alenar temporarily deployed to testing-preview October 21, 2025 15:05 — with GitHub Actions Inactive
@Alenar Alenar merged commit f98f9d2 into main Oct 21, 2025
41 of 52 checks passed
@Alenar Alenar deleted the djo/2704/cdb-by-epoch-in-client branch October 21, 2025 15:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants