Skip to content

Conversation

Alenar
Copy link
Collaborator

@Alenar Alenar commented Oct 10, 2025

Content

This PR add two main features:

  • add new /artifact/cardano-database/epoch/{epoch} route
  • Allow usage of latest or latest-{offset} in routes that take an epoch parameters in their path

Aggregator

  • database:
    • Schema: add epoch virtual column to the signed_entity table, computed from the json value in the beacon column. This column is indexed to allow fast filtering.
    • Queries: generalize GetSignedEntityRecordQuery::cardano_stake_distribution_by_epoch into by_signed_entity_type_and_epoch
    • SignedEntityStorer: add get_last_signed_entities_by_type_and_epoch
  • message service: add get_cardano_database_list_message_by_epoch
  • http server:
    • add /artifact/cardano-database/epoch/{epoch} route
    • add middleware::parameters::expand_epoch helper. It parse the epoch if it's an integer or try to fetch its value from the epoch service if it's latest{-offset}.
    • make use parameters::expand_epoch in routes that allow epoch filtering (new route above, get /cardano-stake-distribution/epoch/{epoch}, signers/registered/{epoch}
    • Router: add max_artifact_epoch_offset to the RouterConfig, value hard-coded to 5 in the dependency injection layer.
    • Use max_artifact_epoch_offset as the upper limit when expanding epoch in artifacts routes

Common

  • Fake data: add methods that build only one value for each artifacts type (complement the existing methods that builds list of artifacts). This allow to avoid having to extract the value from the vector when you only need one.

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
    • No new TODOs introduced

Issue(s)

Relates to #2704

@Alenar Alenar self-assigned this Oct 10, 2025
Copy link

github-actions bot commented Oct 10, 2025

Test Results

    4 files  ± 0    168 suites  ±0   23m 17s ⏱️ -12s
2 240 tests +13  2 240 ✅ +13  0 💤 ±0  0 ❌ ±0 
6 905 runs  +26  6 905 ✅ +26  0 💤 ±0  0 ❌ ±0 

Results for commit 99b441b. ± Comparison against base commit 046a4f8.

This pull request removes 6 and adds 19 tests. Note that renamed tests count towards both.
mithril-aggregator ‑ database::query::signed_entity::get_signed_entity::tests::cardano_stake_distribution_by_epoch_returns_records_filtered_by_epoch
mithril-aggregator ‑ database::query::signed_entity::get_signed_entity::tests::cardano_stake_distribution_by_epoch_returns_records_returns_only_cardano_stake_distribution_records
mithril-aggregator ‑ database::query::signed_entity::get_signed_entity::tests::test_get_signed_entity_records
mithril-aggregator ‑ http_server::routes::signer_routes::tests::registered_signers_registration_epoch::error_if_given_epoch_is_not_a_number_nor_latest
mithril-aggregator ‑ http_server::routes::signer_routes::tests::registered_signers_registration_epoch::use_epoch_service_current_epoch_if_latest
mithril-aggregator ‑ http_server::routes::signer_routes::tests::registered_signers_registration_epoch::use_given_epoch_if_valid_number
mithril-aggregator ‑ database::query::signed_entity::get_signed_entity::tests::by_signed_entity_and_epoch_returns_records_filtered_by_discriminant
mithril-aggregator ‑ database::query::signed_entity::get_signed_entity::tests::by_signed_entity_and_epoch_returns_records_filtered_by_epoch
mithril-aggregator ‑ database::query::signed_entity::get_signed_entity::tests::test_get_all_records
mithril-aggregator ‑ database::query::signed_entity::get_signed_entity::tests::test_get_record_by_id
mithril-aggregator ‑ database::query::signed_entity::get_signed_entity::tests::test_get_record_by_signed_entity_type
mithril-aggregator ‑ database::repository::signed_entity_store::tests::get_last_signed_entities_by_type_and_epoch_when_nothing_found
mithril-aggregator ‑ database::repository::signed_entity_store::tests::get_last_signed_entities_by_type_and_epoch_when_signed_entity_found_for_epoch
mithril-aggregator ‑ http_server::parameters::tests::dont_overflow_if_epoch_minus_offset_is_negative
mithril-aggregator ‑ http_server::parameters::tests::error_if_given_epoch_is_not_a_number_nor_latest_nor_latest_minus_a_number
mithril-aggregator ‑ http_server::parameters::tests::test_expanded_epoch_apply_additional_offset
…

♻️ This comment has been updated with latest results.

@Alenar Alenar temporarily deployed to testing-preview October 10, 2025 11:03 — with GitHub Actions Inactive
@Alenar Alenar temporarily deployed to testing-preview October 10, 2025 15:50 — with GitHub Actions Inactive
@Alenar Alenar force-pushed the djo/2704/cdb-by-epoch-route branch from fd20823 to d023666 Compare October 10, 2025 15:57
@Alenar Alenar temporarily deployed to testing-preview October 10, 2025 16:06 — 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 👍

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 👍

…date usages

Instead of lists, since most of the time we only need one value and it's
cubersome to extract it from the generated Vec.
To avoid collision when stored in a database
- Add a indexed `epoch` virtual column to `signe_entity` table, computed
  from the discriminant beacon
- Supersed `GetSignedEntityRecordQuery::cardano_stake_distribution_by_epoch`
  with a `by_signed_entity_type_and_epoch` method that works on any
  discriminant
- strengthen `GetSignedEntityRecordQuery` tests & tooling
@Alenar Alenar force-pushed the djo/2704/cdb-by-epoch-route branch from 307be9e to 1d4af19 Compare October 13, 2025 16:06
…pport

Actual epoch retrieval is done with a async lambda to give flexibility
to the caller so they may do it beforehand or make the expander perform
the operation.
Where epoch can be either a integer, `latest`, or `latest-{offset}`
... when the epoch service is unavailable
Cardano Stake Distribution signed entities are created with an offset of
`-1` to the epoch, this must be reflected to the epoch expansion when
using `latest` (with or without additional offset).
Else querying with `latest` will always returns a `404`.
@Alenar Alenar temporarily deployed to testing-preview October 13, 2025 16:15 — with GitHub Actions Inactive
- fix/enhance some doc comments and logs
- use u64 everywhere for offset configuration and parsing
- add `MAX_ARTIFACT_EPOCH_OFFSET` constant in the DI
- `expand_epoch`:
  - use const value from `"latest".len()` instead of `7`
  - tests: add decimal cases
instead of being a child of the `middleware` file and module
@Alenar Alenar force-pushed the djo/2704/cdb-by-epoch-route branch from 1d4af19 to 063e840 Compare October 14, 2025 08:43
* mithril-aggregator from `0.7.87` to `0.7.88`
* mithril-common from `0.6.21` to `0.6.22`
* openapi.yaml from `0.1.53` to `0.1.54`
@Alenar Alenar force-pushed the djo/2704/cdb-by-epoch-route branch from 063e840 to 99b441b Compare October 14, 2025 09:14
@Alenar Alenar temporarily deployed to testing-preview October 14, 2025 10:08 — with GitHub Actions Inactive
@Alenar Alenar merged commit 69c9769 into main Oct 14, 2025
106 of 108 checks passed
@Alenar Alenar deleted the djo/2704/cdb-by-epoch-route branch October 14, 2025 10:20
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.

3 participants