Skip to content

feat: enhance tools utxo-hd snapshot-converter Mithril client CLI command#2589

Merged
dlachaume merged 9 commits into
mainfrom
dlachaume/2571/enhance-ledger-state-snapshot-converter-client-cli-cmd
Jun 18, 2025
Merged

feat: enhance tools utxo-hd snapshot-converter Mithril client CLI command#2589
dlachaume merged 9 commits into
mainfrom
dlachaume/2571/enhance-ledger-state-snapshot-converter-client-cli-cmd

Conversation

@dlachaume

@dlachaume dlachaume commented Jun 17, 2025

Copy link
Copy Markdown
Contributor

Content

This PR includes improvements to the tools utxo-hd snapshot-converter Mithril client CLI command, including:

  • Making the --cardano-network parameter optional and deprecated, as the value can be retrieved from the protocolMagicId file
  • Implementing fallback logic: the tool now attempts to convert the latest ledger state snapshot, and falls back to the second latest in case of a conversion error

Output example with fallback:

Downloading Cardano node distribution for tag: 'latest'...
Distribution downloaded successfully. Archive location: /Users/dl/db/tmp/cardano-node-distribution/cardano-node-10.4.1-macos.tar.gz
Unpacking distribution from archive: /Users/dl/db/tmp/cardano-node-distribution/cardano-node-10.4.1-macos.tar.gz
Distribution unpacked successfully to: /Users/dl/db/tmp/cardano-node-distribution
Converting ledger state snapshot to 'LMDB' flavor
Converting '/Users/dl/db/ledger/81343798' (attempt #1)
Loading snapshot...
snapshot-converter: The input snapshot does not seem to correspond to the input format:
        Mem
        The provided path DOES NOT contain a "state" file
Failed to convert ledger state snapshot '/Users/dl/db/ledger/81343798': Failure while running snapshot-converter binary, exited with status code: "1"
Converting '/Users/dl/db/ledger/81340997' (attempt #2)
Loading snapshot...
Loaded snapshot
Writing snapshot...
Written snapshot
Successfully converted ledger state snapshot: '/Users/dl/db/ledger/81340997'
Snapshot location: /Users/dl/db/tmp/snapshots/81340997_lmdb

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 README file (if relevant)
    • Update documentation website (if relevant)
    • Add dev blog post (if relevant)
    • Add ADR blog post or Dev ADR entry (if relevant)
    • No new TODOs introduced

Issue(s)

Closes #2571

@dlachaume dlachaume self-assigned this Jun 17, 2025
@github-actions

github-actions Bot commented Jun 17, 2025

Copy link
Copy Markdown

Test Results

    3 files  ± 0     88 suites  ±0   13m 53s ⏱️ +15s
2 032 tests +10  2 032 ✅ +10  0 💤 ±0  0 ❌ ±0 
3 593 runs  +30  3 593 ✅ +30  0 💤 ±0  0 ❌ ±0 

Results for commit 26fba87. ± Comparison against base commit 95ee801.

This pull request removes 5 and adds 15 tests. Note that renamed tests count towards both.
mithril-client-cli ‑ commands::tools::snapshot_converter::tests::find_oldest_ledger_state_snapshot::finds_ledger_state_snapshot_with_lowest_slot_number
mithril-client-cli ‑ commands::tools::snapshot_converter::tests::find_oldest_ledger_state_snapshot::get_sorted_snapshot_dirs_returns_sorted_valid_directories
mithril-client-cli ‑ commands::tools::snapshot_converter::tests::find_oldest_ledger_state_snapshot::ignores_non_numeric_and_non_directory_entries
mithril-client-cli ‑ commands::tools::snapshot_converter::tests::find_oldest_ledger_state_snapshot::returns_error_if_no_valid_snapshot_found
mithril-client-cli ‑ commands::tools::snapshot_converter::tests::find_oldest_ledger_state_snapshot::returns_snapshot_when_only_one_valid_directory
mithril-client-cli ‑ commands::tools::snapshot_converter::tests::detect_cardano_network::detects_mainnet
mithril-client-cli ‑ commands::tools::snapshot_converter::tests::detect_cardano_network::detects_preprod
mithril-client-cli ‑ commands::tools::snapshot_converter::tests::detect_cardano_network::detects_preview
mithril-client-cli ‑ commands::tools::snapshot_converter::tests::detect_cardano_network::fails_on_invalid_network
mithril-client-cli ‑ commands::tools::snapshot_converter::tests::detect_cardano_network::fails_when_protocol_magic_id_file_is_empty
mithril-client-cli ‑ commands::tools::snapshot_converter::tests::detect_cardano_network::fails_when_protocol_magic_id_file_is_missing
mithril-client-cli ‑ commands::tools::snapshot_converter::tests::snapshot_conversion_fallback::conversion_fails_if_all_attempts_fail
mithril-client-cli ‑ commands::tools::snapshot_converter::tests::snapshot_conversion_fallback::conversion_falls_back_if_first_conversion_fails
mithril-client-cli ‑ commands::tools::snapshot_converter::tests::snapshot_conversion_fallback::conversion_succeed_and_is_called_once_if_first_conversion_succeeds
mithril-client-cli ‑ commands::tools::snapshot_converter::tests::snapshots_indexing::get_sorted_snapshot_dirs_returns_sorted_valid_directories
…

♻️ This comment has been updated with latest results.

@dlachaume
dlachaume temporarily deployed to testing-preview June 17, 2025 15:28 — with GitHub Actions Inactive

@jpraynaud jpraynaud left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM 👍

Comment thread mithril-client-cli/src/commands/tools/snapshot_converter.rs
@dlachaume
dlachaume force-pushed the dlachaume/2571/enhance-ledger-state-snapshot-converter-client-cli-cmd branch from 59c163a to 5e93243 Compare June 17, 2025 15:47
@dlachaume
dlachaume temporarily deployed to testing-preview June 17, 2025 15:59 — with GitHub Actions Inactive
@dlachaume
dlachaume temporarily deployed to testing-preview June 17, 2025 16:48 — with GitHub Actions Inactive
@dlachaume
dlachaume force-pushed the dlachaume/2571/enhance-ledger-state-snapshot-converter-client-cli-cmd branch from 34f9c86 to b6307d8 Compare June 18, 2025 08:18
@dlachaume
dlachaume temporarily deployed to testing-preview June 18, 2025 08:26 — with GitHub Actions Inactive

@turmelclem turmelclem left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM

@dlachaume
dlachaume force-pushed the dlachaume/2571/enhance-ledger-state-snapshot-converter-client-cli-cmd branch from b6307d8 to e9b4e9b Compare June 18, 2025 12:43
…e `protocolMagicId` file

- Make `--cardano-network` optional (and deprecated)
- Infer the network from `protocolMagicId` if `--cardano-network` not provided
… ledger snapshots

Copy the `get_sorted_snapshot_dirs_returns_sorted_valid_directories` test to the new test submodule,
the original will be deleted in the next commit.
…gnature in `SnapshotConverter` trait

remove pass-through function `execute_snapshot_converter`
* mithril-client-cli from `0.12.11` to `0.12.12`
@dlachaume
dlachaume force-pushed the dlachaume/2571/enhance-ledger-state-snapshot-converter-client-cli-cmd branch from e9b4e9b to 26fba87 Compare June 18, 2025 12:49
@dlachaume
dlachaume temporarily deployed to testing-preview June 18, 2025 13:01 — with GitHub Actions Inactive
@dlachaume
dlachaume merged commit 76e211e into main Jun 18, 2025
97 of 100 checks passed
@dlachaume
dlachaume deleted the dlachaume/2571/enhance-ledger-state-snapshot-converter-client-cli-cmd branch June 18, 2025 13:02
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.

Enhance ledger state snapshot converter command in client CLI

4 participants