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: Implement cardano-db-v2 command in client CLI (list and show) #2266

Open
wants to merge 9 commits into
base: main
Choose a base branch
from

Conversation

dlachaume
Copy link
Collaborator

@dlachaume dlachaume commented Jan 30, 2025

Content

This PR introduces a new unstable command (cardano-db-v2 with alias cdbv2) for the Mithril client CLI, allowing users to list and show details of Incremental Cardano DB snapshots.

Example for snapshot list command:

mithril-client --unstable cardano-db-v2 snapshot list

Terminal output:
image


Example for snapshot show command:

mithril-client --unstable cardano-db-v2 snapshot show {ARTIFACT_HASH}
mithril-client --unstable cardano-db-v2 snapshot show latest

Terminal output:
image

Additionally, the E2E test and the Mithril Client multi-platform test manual workflow have been updated to verify both cardano-db-v2 commands (show and list).

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
  • Documentation
    • Update README file (if relevant)
    • Update documentation website (if relevant)
    • Add dev blog post (if relevant)

Issue(s)

Relates to #2246

@dlachaume dlachaume self-assigned this Jan 30, 2025
Copy link

github-actions bot commented Jan 30, 2025

Test Results

    4 files  ± 0     56 suites  +4   10m 40s ⏱️ +10s
1 590 tests + 8  1 590 ✅ + 8  0 💤 ±0  0 ❌ ±0 
1 888 runs  +32  1 888 ✅ +32  0 💤 ±0  0 ❌ ±0 

Results for commit 25a9fde. ± Comparison against base commit 3266e77.

♻️ This comment has been updated with latest results.

@dlachaume dlachaume temporarily deployed to testing-sanchonet January 30, 2025 17:14 — with GitHub Actions Inactive
@dlachaume dlachaume force-pushed the dlachaume/2246/implement-incremental-cardano-db-client-cli branch from 8b17d0a to 9fee61d Compare January 31, 2025 14:19
@dlachaume dlachaume temporarily deployed to testing-sanchonet January 31, 2025 14:30 — with GitHub Actions Inactive
@dlachaume dlachaume force-pushed the dlachaume/2246/implement-incremental-cardano-db-client-cli branch from 9fee61d to b9c7088 Compare January 31, 2025 14:59
@dlachaume dlachaume temporarily deployed to testing-sanchonet January 31, 2025 15:09 — with GitHub Actions Inactive
@dlachaume dlachaume force-pushed the dlachaume/2246/implement-incremental-cardano-db-client-cli branch from b9c7088 to 48c0b88 Compare January 31, 2025 15:15
@dlachaume dlachaume temporarily deployed to testing-sanchonet January 31, 2025 15:23 — with GitHub Actions Inactive
@dlachaume dlachaume changed the title Feat: Implement cardano-db-v2 command in client CLI Feat: Implement cardano-db-v2 command in client CLI (list and show) Jan 31, 2025
@dlachaume dlachaume force-pushed the dlachaume/2246/implement-incremental-cardano-db-client-cli branch from 48c0b88 to 91ebcaf Compare January 31, 2025 16:22
@dlachaume dlachaume temporarily deployed to testing-sanchonet January 31, 2025 16:30 — with GitHub Actions Inactive
@dlachaume dlachaume force-pushed the dlachaume/2246/implement-incremental-cardano-db-client-cli branch from 91ebcaf to d77b3f1 Compare January 31, 2025 16:39
@dlachaume dlachaume temporarily deployed to testing-sanchonet January 31, 2025 16:47 — with GitHub Actions Inactive
@dlachaume dlachaume marked this pull request as ready for review January 31, 2025 16:49
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
Member

Choose a reason for hiding this comment

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

Maybe the namings should be a bit more consistent between Cardano Database v1 and v2

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Done ✅

format!("{}", item.beacon.immutable_file_number).cell(),
item.hash.cell(),
item.merkle_root.cell(),
item.total_db_size_uncompressed.cell(),
Copy link
Member

Choose a reason for hiding this comment

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

Can you display this size in a human readable format?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Should I use an external crate such as humansize?

Copy link
Member

@jpraynaud jpraynaud Feb 3, 2025

Choose a reason for hiding this comment

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

Maybe displaying the size in GB is sufficient

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Done ✅

vec!["Merkle root".cell(), cardano_db_message.merkle_root.cell()],
vec![
"Database size".cell(),
format!("{}", &cardano_db_message.total_db_size_uncompressed).cell(),
Copy link
Member

Choose a reason for hiding this comment

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

Same comment here

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Done ✅

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

assert!(row.is_some());

let row = digest_location_row(456, DigestLocationDiscriminants::Aggregator, &locations);
assert!(row.is_some());
Copy link
Collaborator

Choose a reason for hiding this comment

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

I wonder if a test that show the row rendering could be interesting

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The code was refactored after your comment were posted.
Since CellStruct doesn't implement Eq or Display, I managed to test it by recreating a TableStruct. Is that ok for you?

- add 'cdbv2' alias for 'cardano-db-v2'
- implement 'cardano-db-v2 list' command
@dlachaume dlachaume force-pushed the dlachaume/2246/implement-incremental-cardano-db-client-cli branch 3 times, most recently from c867e69 to 609d8f2 Compare February 3, 2025 11:57
@dlachaume dlachaume temporarily deployed to testing-sanchonet February 3, 2025 12:09 — with GitHub Actions Inactive
@@ -42,6 +42,12 @@ impl CardanoDbUtils {
res = future => res,
}
}

pub fn format_bytes_to_gigabytes(bytes: u64) -> String {
Copy link
Member

Choose a reason for hiding this comment

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

The unit you are using is incorrect:

  • 1 gibibyte (GiB) = 1024**3 bytes
  • 1 gigabyte (GB) = 1000**3 bytes

Copy link
Collaborator Author

@dlachaume dlachaume Feb 3, 2025

Choose a reason for hiding this comment

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

I see. Should I update it to use GiB instead of GB and leave the calculation (1024**3 bytes) unchanged?
That way, it will match the unit used in the explorer.

Copy link
Member

Choose a reason for hiding this comment

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

Yes, you can use GiB as in the explorer 👍

@dlachaume dlachaume force-pushed the dlachaume/2246/implement-incremental-cardano-db-client-cli branch from 609d8f2 to b7f3557 Compare February 3, 2025 13:46
* mithril-client-cli from `0.10.8` to `0.10.9`
* mithril-common from `0.4.110` to `0.4.111`
* mithril-end-to-end from `0.4.65` to `0.4.66`
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 🔥

@dlachaume dlachaume deployed to testing-preview February 3, 2025 13:56 — with GitHub Actions Active
@dlachaume dlachaume deployed to testing-sanchonet February 3, 2025 13:56 — with GitHub Actions Active
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