Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat: add example crate for incremental Cardano database #2337

Merged
merged 10 commits into from
Feb 25, 2025

Conversation

jpraynaud
Copy link
Member

@jpraynaud jpraynaud commented Feb 24, 2025

Content

This PR includes an example crate for the incremental Cardano database.

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
    • No clippy warnings in the CI
    • Self-reviewed the diff
    • Useful pull request description
    • Reviewer requested

Issue(s)

Closes #2330

@jpraynaud jpraynaud self-assigned this Feb 24, 2025
@jpraynaud jpraynaud changed the base branch from main to dlachaume/2246/client-cli-incremental-cardano-database-restoration February 24, 2025 17:58
@jpraynaud jpraynaud changed the base branch from dlachaume/2246/client-cli-incremental-cardano-database-restoration to main February 24, 2025 17:58
Copy link

github-actions bot commented Feb 24, 2025

Test Results

    3 files  ±0     52 suites  ±0   10m 23s ⏱️ -15s
1 695 tests  - 3  1 695 ✅  - 3  0 💤 ±0  0 ❌ ±0 
2 077 runs   - 9  2 077 ✅  - 9  0 💤 ±0  0 ❌ ±0 

Results for commit d505bb5. ± Comparison against base commit 09ab67d.

This pull request removes 4 and adds 1 tests. Note that renamed tests count towards both.
mithril-client-cli ‑ commands::cardano_db_v2::download::tests::number_of_immutable_files_restored_with_from
mithril-client-cli ‑ commands::cardano_db_v2::download::tests::number_of_immutable_files_restored_with_full_restoration
mithril-client-cli ‑ commands::cardano_db_v2::download::tests::number_of_immutable_files_restored_with_range
mithril-client-cli ‑ commands::cardano_db_v2::download::tests::number_of_immutable_files_restored_with_up_to
mithril-client ‑ cardano_database_client::immutable_file_range::tests::length

♻️ This comment has been updated with latest results.

@jpraynaud jpraynaud force-pushed the jpraynaud/2330-add-example-cardano-database branch from 50dc7d6 to 60f722f Compare February 25, 2025 09:57
@jpraynaud jpraynaud force-pushed the jpraynaud/2330-add-example-cardano-database branch from 60f722f to 079bae2 Compare February 25, 2025 10:05
@jpraynaud jpraynaud force-pushed the jpraynaud/2330-add-example-cardano-database branch from 079bae2 to a56fa49 Compare February 25, 2025 10:08
Copy link
Collaborator

@dlachaume dlachaume left a comment

Choose a reason for hiding this comment

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

LGTM 🚀
I'm wondering if the CardanoDbV2DownloadCommand::number_of_immutable_files_restored tests in mithril-client-cli are still useful?

#[test]
fn number_of_immutable_files_restored_with_full_restoration() {
let cardano_database_snapshot = CardanoDatabaseSnapshot {
beacon: CardanoDbBeacon::new(999, 20),
..CardanoDatabaseSnapshot::dummy()
};
let immutable_file_range = ImmutableFileRange::Full;
let number_of_immutable_files_restored =
CardanoDbV2DownloadCommand::number_of_immutable_files_restored(
&cardano_database_snapshot,
&immutable_file_range,
);
assert_eq!(number_of_immutable_files_restored, 20);
}
#[test]
fn number_of_immutable_files_restored_with_from() {
let cardano_database_snapshot = CardanoDatabaseSnapshot {
beacon: CardanoDbBeacon::new(999, 20),
..CardanoDatabaseSnapshot::dummy()
};
let immutable_file_range = ImmutableFileRange::From(12);
let number_of_immutable_files_restored =
CardanoDbV2DownloadCommand::number_of_immutable_files_restored(
&cardano_database_snapshot,
&immutable_file_range,
);
let expected_number_of_immutable_files_restored = 20 - 12 + 1;
assert_eq!(
number_of_immutable_files_restored,
expected_number_of_immutable_files_restored
);
}
#[test]
fn number_of_immutable_files_restored_with_up_to() {
let cardano_database_snapshot = CardanoDatabaseSnapshot {
beacon: CardanoDbBeacon::new(999, 20),
..CardanoDatabaseSnapshot::dummy()
};
let immutable_file_range = ImmutableFileRange::UpTo(14);
let number_of_immutable_files_restored =
CardanoDbV2DownloadCommand::number_of_immutable_files_restored(
&cardano_database_snapshot,
&immutable_file_range,
);
assert_eq!(number_of_immutable_files_restored, 14);
}
#[test]
fn number_of_immutable_files_restored_with_range() {
let cardano_database_snapshot = CardanoDatabaseSnapshot {
beacon: CardanoDbBeacon::new(999, 20),
..CardanoDatabaseSnapshot::dummy()
};
let immutable_file_range = ImmutableFileRange::Range(12, 14);
let number_of_immutable_files_restored =
CardanoDbV2DownloadCommand::number_of_immutable_files_restored(
&cardano_database_snapshot,
&immutable_file_range,
);
let expected_number_of_immutable_files_restored = 14 - 12 + 1;
assert_eq!(
number_of_immutable_files_restored,
expected_number_of_immutable_files_restored
);
}
}

@jpraynaud jpraynaud force-pushed the jpraynaud/2330-add-example-cardano-database branch from a56fa49 to 161a774 Compare February 25, 2025 10:44
@jpraynaud jpraynaud force-pushed the jpraynaud/2330-add-example-cardano-database branch from 161a774 to eff5d76 Compare February 25, 2025 11:57
@jpraynaud jpraynaud force-pushed the jpraynaud/2330-add-example-cardano-database branch from eff5d76 to 9915ab7 Compare February 25, 2025 12:10
@jpraynaud jpraynaud marked this pull request as ready for review February 25, 2025 13:39
Copy link
Collaborator

@Alenar Alenar 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

@sfauvel sfauvel left a comment

Choose a reason for hiding this comment

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

LGTM

* examples/client-cardano-database to `0.0.1`
* mithril-client-cli from `0.11.3` to `0.11.4`
* mithril-client from `0.11.5` to `0.11.6`
@jpraynaud jpraynaud force-pushed the jpraynaud/2330-add-example-cardano-database branch from 70dd1e9 to d505bb5 Compare February 25, 2025 16:18
@jpraynaud
Copy link
Member Author

LGTM 🚀 I'm wondering if the CardanoDbV2DownloadCommand::number_of_immutable_files_restored tests in mithril-client-cli are still useful?

#[test]
fn number_of_immutable_files_restored_with_full_restoration() {
let cardano_database_snapshot = CardanoDatabaseSnapshot {
beacon: CardanoDbBeacon::new(999, 20),
..CardanoDatabaseSnapshot::dummy()
};
let immutable_file_range = ImmutableFileRange::Full;
let number_of_immutable_files_restored =
CardanoDbV2DownloadCommand::number_of_immutable_files_restored(
&cardano_database_snapshot,
&immutable_file_range,
);
assert_eq!(number_of_immutable_files_restored, 20);
}
#[test]
fn number_of_immutable_files_restored_with_from() {
let cardano_database_snapshot = CardanoDatabaseSnapshot {
beacon: CardanoDbBeacon::new(999, 20),
..CardanoDatabaseSnapshot::dummy()
};
let immutable_file_range = ImmutableFileRange::From(12);
let number_of_immutable_files_restored =
CardanoDbV2DownloadCommand::number_of_immutable_files_restored(
&cardano_database_snapshot,
&immutable_file_range,
);
let expected_number_of_immutable_files_restored = 20 - 12 + 1;
assert_eq!(
number_of_immutable_files_restored,
expected_number_of_immutable_files_restored
);
}
#[test]
fn number_of_immutable_files_restored_with_up_to() {
let cardano_database_snapshot = CardanoDatabaseSnapshot {
beacon: CardanoDbBeacon::new(999, 20),
..CardanoDatabaseSnapshot::dummy()
};
let immutable_file_range = ImmutableFileRange::UpTo(14);
let number_of_immutable_files_restored =
CardanoDbV2DownloadCommand::number_of_immutable_files_restored(
&cardano_database_snapshot,
&immutable_file_range,
);
assert_eq!(number_of_immutable_files_restored, 14);
}
#[test]
fn number_of_immutable_files_restored_with_range() {
let cardano_database_snapshot = CardanoDatabaseSnapshot {
beacon: CardanoDbBeacon::new(999, 20),
..CardanoDatabaseSnapshot::dummy()
};
let immutable_file_range = ImmutableFileRange::Range(12, 14);
let number_of_immutable_files_restored =
CardanoDbV2DownloadCommand::number_of_immutable_files_restored(
&cardano_database_snapshot,
&immutable_file_range,
);
let expected_number_of_immutable_files_restored = 14 - 12 + 1;
assert_eq!(
number_of_immutable_files_restored,
expected_number_of_immutable_files_restored
);
}
}

I have removed the function number_of_immutable_files_restored in 7a7768f 👍

@jpraynaud jpraynaud merged commit 3f77f6b into main Feb 25, 2025
37 of 41 checks passed
@jpraynaud jpraynaud deleted the jpraynaud/2330-add-example-cardano-database branch February 25, 2025 16:46
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.

Implement an example for Incremental Cardano DB
4 participants