Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion examples/client-cardano-database-v2/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "client-cardano-database-v2"
description = "Mithril client Cardano database example"
version = "0.0.10"
version = "0.0.11"
authors = ["[email protected]", "[email protected]"]
documentation = "https://mithril.network/doc"
edition = "2021"
Expand Down
2 changes: 1 addition & 1 deletion examples/client-cardano-database-v2/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
//!
//! A [FeedbackReceiver] using [indicatif] is used to nicely report the progress to the console.

use anyhow::{anyhow, Context};
use anyhow::{Context, anyhow};
use async_trait::async_trait;
use clap::Parser;
use futures::Future;
Expand Down
2 changes: 1 addition & 1 deletion examples/client-cardano-database/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "client-cardano-database"
description = "Mithril client Cardano database example"
version = "0.1.34"
version = "0.1.35"
authors = ["[email protected]", "[email protected]"]
documentation = "https://mithril.network/doc"
edition = "2021"
Expand Down
2 changes: 1 addition & 1 deletion examples/client-cardano-database/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
//!
//! A [FeedbackReceiver] using [indicatif] is used to nicely report the progress to the console.

use anyhow::{anyhow, Context};
use anyhow::{Context, anyhow};
use async_trait::async_trait;
use clap::Parser;
use futures::Future;
Expand Down
2 changes: 1 addition & 1 deletion mithril-client/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "mithril-client"
version = "0.12.19"
version = "0.12.20"
description = "Mithril client library"
authors = { workspace = true }
edition = { workspace = true }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@ use std::path::{Path, PathBuf};
use std::pin::Pin;
use std::sync::Arc;

use anyhow::{anyhow, Context};
use anyhow::{Context, anyhow};
use slog::Logger;

use mithril_common::entities::{CompressionAlgorithm, ImmutableFileNumber};

use crate::{
MithrilResult,
file_downloader::{DownloadEvent, FileDownloader, FileDownloaderUri},
utils::AncillaryVerifier,
MithrilResult,
};

/// The future type for downloading a file
Expand Down Expand Up @@ -90,8 +90,7 @@ impl DownloadTask {
ancillary_verifier: &Arc<AncillaryVerifier>,
logger: &Logger,
) -> MithrilResult<()> {
self.download_unpack_file(ancillary_files_temp_dir, logger)
.await?;
self.download_unpack_file(ancillary_files_temp_dir, logger).await?;
let validated_manifest = ancillary_verifier.verify(ancillary_files_temp_dir).await?;
validated_manifest.move_to_final_location(target_dir).await
}
Expand Down Expand Up @@ -205,10 +204,7 @@ mod tests {
kind: DownloadKind::Immutable(1),
locations_to_try: create_locations_to_download(
file_downloader,
[
"http://whatever-1/00001.tar.gz",
"http://whatever-2/00001.tar.gz",
],
["http://whatever-1/00001.tar.gz", "http://whatever-2/00001.tar.gz"],
),
size_uncompressed: 0,
target_dir: target_dir.clone(),
Expand Down Expand Up @@ -244,10 +240,7 @@ mod tests {
kind: DownloadKind::Immutable(1),
locations_to_try: create_locations_to_download(
file_downloader,
[
"http://whatever-1/00001.tar.gz",
"http://whatever-2/00001.tar.gz",
],
["http://whatever-1/00001.tar.gz", "http://whatever-2/00001.tar.gz"],
),
size_uncompressed: 0,
target_dir: target_dir.clone(),
Expand All @@ -269,11 +262,7 @@ mod tests {
use super::*;

fn fake_ancillary_verifier() -> AncillaryVerifier {
AncillaryVerifier::new(
fake_keys::manifest_verification_key()[0]
.try_into()
.unwrap(),
)
AncillaryVerifier::new(fake_keys::manifest_verification_key()[0].try_into().unwrap())
}

#[tokio::test]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ use anyhow::anyhow;

use mithril_cardano_node_internal_database::{IMMUTABLE_DIR, LEDGER_DIR, VOLATILE_DIR};

use crate::common::ImmutableFileNumber;
use crate::MithrilResult;
use crate::common::ImmutableFileNumber;

/// Options for downloading and unpacking a Cardano database
#[derive(Debug, Copy, Clone)]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,17 @@ use mithril_common::messages::{
AncillaryMessagePart, CardanoDatabaseSnapshotMessage, ImmutablesMessagePart,
};

use crate::MithrilResult;
use crate::cardano_database_client::ImmutableFileRange;
use crate::feedback::{FeedbackSender, MithrilEvent, MithrilEventCardanoDatabase};
use crate::file_downloader::{DownloadEvent, FileDownloader, FileDownloaderUri};
use crate::utils::{
create_bootstrap_node_files, AncillaryVerifier, UnexpectedDownloadedFileVerifier,
VecDequeExtensions, ANCILLARIES_NOT_SIGNED_BY_MITHRIL,
ANCILLARIES_NOT_SIGNED_BY_MITHRIL, AncillaryVerifier, UnexpectedDownloadedFileVerifier,
VecDequeExtensions, create_bootstrap_node_files,
};
use crate::MithrilResult;

use super::download_task::{DownloadKind, DownloadTask, LocationToDownload};
use super::DownloadUnpackOptions;
use super::download_task::{DownloadKind, DownloadTask, LocationToDownload};

pub struct InternalArtifactDownloader {
http_file_downloader: Arc<dyn FileDownloader>,
Expand Down Expand Up @@ -96,16 +96,17 @@ impl InternalArtifactDownloader {
&download_id,
)?);
} else {
slog::warn!(self.logger, "The fast bootstrap of the Cardano node is not available with the current parameters used in this command: the ledger state will be recomputed from genesis at startup of the Cardano node. Set the include_ancillary entry to true in the DownloadUnpackOptions.");
slog::warn!(
self.logger,
"The fast bootstrap of the Cardano node is not available with the current parameters used in this command: the ledger state will be recomputed from genesis at startup of the Cardano node. Set the include_ancillary entry to true in the DownloadUnpackOptions."
);
}

// Return the result later so unexpected file removal is always run
let download_result = self
.batch_download_unpack(tasks, download_unpack_options.max_parallel_downloads)
.await;
expected_files_after_download
.remove_unexpected_files()
.await?;
expected_files_after_download.remove_unexpected_files().await?;
download_result?;

create_bootstrap_node_files(&self.logger, target_dir, &cardano_database_snapshot.network)?;
Expand Down Expand Up @@ -538,11 +539,7 @@ mod tests {
use super::*;

fn fake_ancillary_verifier() -> AncillaryVerifier {
AncillaryVerifier::new(
fake_keys::manifest_verification_key()[0]
.try_into()
.unwrap(),
)
AncillaryVerifier::new(fake_keys::manifest_verification_key()[0].try_into().unwrap())
}

#[tokio::test]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use std::ops::RangeInclusive;

use anyhow::anyhow;

use mithril_common::{entities::ImmutableFileNumber, StdResult};
use mithril_common::{StdResult, entities::ImmutableFileNumber};

/// Immutable file range representation
#[derive(Debug, Eq, PartialEq)]
Expand Down
12 changes: 5 additions & 7 deletions mithril-client/src/cardano_database_client/proving.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use std::{
sync::Arc,
};

use anyhow::{anyhow, Context};
use anyhow::{Context, anyhow};

use mithril_cardano_node_internal_database::{
digesters::{CardanoImmutableDigester, ImmutableDigester},
Expand All @@ -21,10 +21,10 @@ use mithril_common::{
};

use crate::{
MithrilResult,
feedback::MithrilEvent,
file_downloader::{DownloadEvent, FileDownloader, FileDownloaderUri},
utils::{create_directory_if_not_exists, delete_directory, read_files_in_directory},
MithrilResult,
};

use super::immutable_file_range::ImmutableFileRange;
Expand Down Expand Up @@ -195,10 +195,10 @@ mod tests {
use std::ops::RangeInclusive;

use mithril_cardano_node_internal_database::{
digesters::ComputedImmutablesDigests, IMMUTABLE_DIR,
IMMUTABLE_DIR, digesters::ComputedImmutablesDigests,
};
use mithril_common::{
entities::ImmutableFileNumber, messages::DigestsMessagePart, StdResult,
StdResult, entities::ImmutableFileNumber, messages::DigestsMessagePart,
};

use super::*;
Expand Down Expand Up @@ -252,9 +252,7 @@ mod tests {
{
fs::remove_file(
database_dir.join(
database_dir
.join(IMMUTABLE_DIR)
.join(immutable_file.filename.clone()),
database_dir.join(IMMUTABLE_DIR).join(immutable_file.filename.clone()),
),
)
.unwrap();
Expand Down
12 changes: 5 additions & 7 deletions mithril-client/src/file_downloader/http.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,24 +3,24 @@ use std::{
path::Path,
};

use anyhow::{anyhow, Context};
use anyhow::{Context, anyhow};
use async_trait::async_trait;
use flate2::read::GzDecoder;
use flume::{Receiver, Sender};
use futures::StreamExt;
use reqwest::{Response, StatusCode, Url};
use slog::{debug, Logger};
use slog::{Logger, debug};
use tar::Archive;
use tokio::fs::File;
use tokio::io::AsyncReadExt;

use mithril_common::{logging::LoggerExtensions, StdResult};
use mithril_common::{StdResult, logging::LoggerExtensions};

use crate::common::CompressionAlgorithm;
use crate::feedback::FeedbackSender;
use crate::utils::StreamReader;

use super::{interface::DownloadEvent, FileDownloader, FileDownloaderUri};
use super::{FileDownloader, FileDownloaderUri, interface::DownloadEvent};

/// A file downloader that only handles download through HTTP.
pub struct HttpFileDownloader {
Expand Down Expand Up @@ -94,9 +94,7 @@ impl HttpFileDownloader {
}
buffer.truncate(bytes_read);
sender.send_async(buffer).await.with_context(|| {
format!(
"Local file read: could not write {bytes_read} bytes to stream."
)
format!("Local file read: could not write {bytes_read} bytes to stream.")
})?;
downloaded_bytes += bytes_read as u64;
let event = download_event_type.build_download_progress_event(downloaded_bytes, size);
Expand Down
2 changes: 1 addition & 1 deletion mithril-client/src/file_downloader/interface.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ use anyhow::anyhow;
use async_trait::async_trait;

use mithril_common::{
StdError, StdResult,
entities::{
AncillaryLocation, CompressionAlgorithm, DigestLocation, FileUri, ImmutableFileNumber,
},
StdError, StdResult,
};

use crate::feedback::{MithrilEvent, MithrilEventCardanoDatabase};
Expand Down
15 changes: 4 additions & 11 deletions mithril-client/src/file_downloader/mock_builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ use sha2::{Digest, Sha256};

use mithril_cardano_node_internal_database::entities::AncillaryFilesManifest;
use mithril_common::{
StdResult,
crypto_helper::ManifestSigner,
entities::{CompressionAlgorithm, FileUri},
StdResult,
};

use super::{DownloadEvent, FileDownloaderUri, MockFileDownloader};
Expand Down Expand Up @@ -91,9 +91,7 @@ impl MockFileDownloaderBuilder {
) -> Self {
self.with_returning(Box::new(move |_, _, target_dir: &Path, _, _| {
for filename in [
fake_ancillary_file_builder
.files_in_manifest_to_create
.as_slice(),
fake_ancillary_file_builder.files_in_manifest_to_create.as_slice(),
fake_ancillary_file_builder
.files_not_in_manifest_to_create
.as_ref()
Expand Down Expand Up @@ -178,10 +176,7 @@ impl MockFileDownloaderBuilder {
.unwrap_or(true)
});
let predicate_target_dir = predicate::function(move |u| {
self.param_target_dir
.as_ref()
.map(|x| x == u)
.unwrap_or(true)
self.param_target_dir.as_ref().map(|x| x == u).unwrap_or(true)
});
let predicate_compression_algorithm = predicate::function(move |u| {
self.param_compression_algorithm
Expand Down Expand Up @@ -272,9 +267,7 @@ mod tests {
verifier
.verify(
&ancillary_manifest.compute_hash(),
&ancillary_manifest
.signature()
.expect("Manifest should be signed"),
&ancillary_manifest.signature().expect("Manifest should be signed"),
)
.expect("Signed manifest should have a valid signature");

Expand Down
2 changes: 1 addition & 1 deletion mithril-client/src/file_downloader/retry.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use std::{path::Path, sync::Arc, time::Duration};

use async_trait::async_trait;
use mithril_common::{entities::CompressionAlgorithm, StdResult};
use mithril_common::{StdResult, entities::CompressionAlgorithm};

use super::{DownloadEvent, FileDownloader, FileDownloaderUri};

Expand Down
Loading
Loading