Skip to content

Commit 16c4ecf

Browse files
authored
Merge pull request #2852 from input-output-hk/djo/2823/snapshot-converter_add-cardano-docker-cmd
feat(client-cli): add cardano docker run command to snapshot converter output
2 parents bc1853e + c8a5129 commit 16c4ecf

File tree

11 files changed

+360
-83
lines changed

11 files changed

+360
-83
lines changed

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,13 @@ As a minor extension, we have adopted a slightly different versioning convention
1616

1717
- **DEPRECATED**: The flag `--backend v1` of the `cardano-db` command has been deprecated CLI, use the `--backend v2` instead.
1818

19+
- Reworked the client CLI `snapshot-converter` command outputs:
20+
- Print all progress messages to stderr instead of stdout.
21+
- Add support for `--json` parameter
22+
- Add a docker run command in the final output that can be used to start the Cardano node with the converted ledger
23+
24+
- **BREAKING**: Progress bars and spinners of the client CLI are now outputted to stderr instead of stdout.
25+
1926
- Support for removal of `cardano_transactions_signing_config` from the diffused mithril network configuration.
2027

2128
- Decentralization of the configuration parameters of Mithril networks:

Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

mithril-client-cli/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "mithril-client-cli"
3-
version = "0.12.35"
3+
version = "0.12.36"
44
description = "A Mithril Client"
55
authors = { workspace = true }
66
edition = { workspace = true }

mithril-client-cli/src/commands/cardano_db/download/mod.rs

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,14 @@ use v2::PreparedCardanoDbV2Download;
77
use clap::Parser;
88
use std::{collections::HashMap, path::PathBuf};
99

10+
use mithril_client::{MithrilResult, common::ImmutableFileNumber};
11+
1012
use crate::{
1113
CommandContext,
1214
commands::cardano_db::{CardanoDbCommandsBackend, warn_unused_parameter_with_v1_backend},
1315
configuration::{ConfigError, ConfigSource},
14-
utils::{self, JSON_CAUTION_KEY},
16+
utils::{self, JSON_CAUTION_KEY, print_simple_warning},
1517
};
16-
use mithril_client::{MithrilResult, common::ImmutableFileNumber};
1718

1819
const DB_DIRECTORY_NAME: &str = "db";
1920

@@ -161,11 +162,8 @@ For more information, please refer to the network configuration page of the docu
161162

162163
fn warn_ancillary_not_signed_by_mithril(&self, context: &CommandContext) {
163164
let message = "Ancillary verification does not use the Mithril certification: as a mitigation, IOG owned keys are used to sign these files.";
164-
if context.is_json_output_enabled() {
165-
eprintln!(r#"{{"{JSON_CAUTION_KEY}":"{message}"}}"#);
166-
} else {
167-
eprintln!("{message}");
168-
}
165+
166+
print_simple_warning(message, context.is_json_output_enabled());
169167
}
170168
}
171169

mithril-client-cli/src/commands/cardano_db/mod.rs

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,12 @@ pub use list::*;
1010
pub use show::*;
1111
pub use verify::*;
1212

13-
use crate::CommandContext;
1413
use clap::{Subcommand, ValueEnum};
14+
1515
use mithril_client::MithrilResult;
1616

17+
use crate::{CommandContext, utils::print_simple_warning};
18+
1719
/// Backend to use for Cardano Database commands
1820
#[derive(Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Default, ValueEnum)]
1921
pub enum CardanoDbCommandsBackend {
@@ -77,31 +79,22 @@ impl CardanoDbSnapshotCommands {
7779

7880
/// Print in stderr a warning about the deprecation of the v1 backend and its scheduled removal in 2026
7981
pub fn warn_deprecated_v1_backend(context: &CommandContext) {
80-
use crate::utils::JSON_CAUTION_KEY;
81-
8282
let message = "The `v1` backend is deprecated and is scheduled to be removed early 2026. \
8383
Please use the `v2` backend instead. \
8484
No other change is required in your command line.";
8585

86-
if context.is_json_output_enabled() {
87-
eprintln!(r#"{{"{JSON_CAUTION_KEY}":"{message}"}}"#);
88-
} else {
89-
eprintln!("Warning: {message}");
90-
}
86+
print_simple_warning(message, context.is_json_output_enabled());
9187
}
9288

9389
/// Print in stderr that the given parameters are not available with the v1 backend and will be ignored
9490
pub fn warn_unused_parameter_with_v1_backend<const N: usize>(
9591
context: &CommandContext,
9692
v2_only_parameters: [&str; N],
9793
) {
98-
use crate::utils::JSON_CAUTION_KEY;
99-
10094
let message = format_unused_parameter_with_v1_backend(v2_only_parameters);
101-
if context.is_json_output_enabled() {
102-
eprintln!(r#"{{"{JSON_CAUTION_KEY}":"{message}"}}"#);
103-
} else {
104-
eprintln!("{message}");
95+
print_simple_warning(&message, context.is_json_output_enabled());
96+
97+
if !context.is_json_output_enabled() {
10598
// Add a blank line to separate this message from the one related to the fast bootstrap that comes next.
10699
eprintln!();
107100
}

mithril-client-cli/src/commands/cardano_db/shared_steps.rs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ use mithril_client::{
99
common::{ImmutableFileNumber, MKProof, ProtocolMessage},
1010
};
1111

12-
use crate::utils::{CardanoDbUtils, ProgressPrinter};
12+
use crate::utils::{CardanoDbUtils, LedgerFormat, ProgressPrinter};
1313

1414
pub struct ComputeCardanoDatabaseMessageOptions {
1515
pub db_dir: PathBuf,
@@ -163,11 +163,12 @@ pub fn log_download_information(
163163
.canonicalize()
164164
.with_context(|| format!("Could not get canonical filepath of '{}'", db_dir.display()))?;
165165

166-
let docker_cmd = format!(
167-
"docker run -v cardano-node-ipc:/ipc -v cardano-node-data:/data --mount type=bind,source=\"{}\",target=/data/db/ -e NETWORK={} ghcr.io/intersectmbo/cardano-node:{}",
168-
canonical_filepath.display(),
166+
let docker_cmd = CardanoDbUtils::get_docker_run_command(
167+
canonical_filepath,
169168
cardano_network,
170-
cardano_node_version
169+
cardano_node_version,
170+
// Aggregators are only using UTxO-HD in memory format as other format are deprecated or non portable
171+
LedgerFormat::InMemory,
171172
);
172173

173174
let snapshot_converter_cmd = |flavor| {

mithril-client-cli/src/commands/tools/utxo_hd/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,15 @@ pub enum UTxOHDCommands {
2020

2121
impl UTxOHDCommands {
2222
/// Execute UTxO-HD command
23-
pub async fn execute(&self, _context: CommandContext) -> MithrilResult<()> {
23+
pub async fn execute(&self, context: CommandContext) -> MithrilResult<()> {
2424
match self {
2525
Self::SnapshotConverter(cmd) => {
2626
if cfg!(target_os = "linux") && cfg!(target_arch = "aarch64") {
2727
return Err(anyhow!(
2828
"'snapshot-converter' command is not supported on Linux ARM"
2929
));
3030
}
31-
cmd.execute().await
31+
cmd.execute(context).await
3232
}
3333
}
3434
}

0 commit comments

Comments
 (0)