Skip to content

Commit

Permalink
Merge pull request #2191 from input-output-hk/ensemble/2151/create-an…
Browse files Browse the repository at this point in the history
…cillary-archive

Feat: ancillary archive creation
  • Loading branch information
dlachaume authored Jan 6, 2025
2 parents 00567fe + 8d374ca commit bf038eb
Show file tree
Hide file tree
Showing 23 changed files with 950 additions and 274 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ As a minor extension, we have adopted a slightly different versioning convention
- **UNSTABLE** Cardano database incremental certification:

- Implement the artifact routes of the aggregator for the signed entity type `CardanoDatabase`.
- Implement the artifact ancillary builder in the aggregator.

- Crates versions:

Expand Down
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 mithril-aggregator/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "mithril-aggregator"
version = "0.6.8"
version = "0.6.9"
description = "A Mithril Aggregator server"
authors = { workspace = true }
edition = { workspace = true }
Expand Down
40 changes: 32 additions & 8 deletions mithril-aggregator/src/artifact_builder/cardano_database.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ pub struct CardanoDatabaseArtifactBuilder {
db_directory: PathBuf,
cardano_node_version: Version,
compression_algorithm: CompressionAlgorithm,
#[allow(dead_code)]
ancillary_builder: Arc<AncillaryArtifactBuilder>,
}

Expand Down Expand Up @@ -62,8 +61,10 @@ impl ArtifactBuilder<CardanoDbBeacon, CardanoDatabaseSnapshot> for CardanoDataba
})?;
let total_db_size_uncompressed = compute_uncompressed_database_size(&self.db_directory)?;

let ancillary_locations = self.ancillary_builder.upload(&beacon).await?;

let locations = ArtifactsLocations {
ancillary: vec![],
ancillary: ancillary_locations,
digests: vec![],
immutables: vec![],
};
Expand Down Expand Up @@ -111,9 +112,14 @@ mod tests {
use std::path::PathBuf;

use mithril_common::{
digesters::DummyImmutablesDbBuilder,
entities::{ProtocolMessage, ProtocolMessagePartKey},
digesters::DummyCardanoDbBuilder,
entities::{AncillaryLocation, ProtocolMessage, ProtocolMessagePartKey},
test_utils::{fake_data, TempDir},
CardanoNetwork,
};

use crate::{
artifact_builder::MockAncillaryFileUploader, test_tools::TestLogger, DumbSnapshotter,
};

use super::*;
Expand All @@ -129,7 +135,7 @@ mod tests {
let immutable_trio_file_size = 777;
let ledger_file_size = 6666;
let volatile_file_size = 99;
DummyImmutablesDbBuilder::new(test_dir.as_os_str().to_str().unwrap())
DummyCardanoDbBuilder::new(test_dir.as_os_str().to_str().unwrap())
.with_immutables(&[1, 2])
.set_immutable_trio_file_size(immutable_trio_file_size)
.with_ledger_files(&["blocks-0.dat", "blocks-1.dat", "blocks-2.dat"])
Expand All @@ -152,7 +158,7 @@ mod tests {
let immutable_trio_file_size = 777;
let ledger_file_size = 6666;
let volatile_file_size = 99;
DummyImmutablesDbBuilder::new(test_dir.as_os_str().to_str().unwrap())
DummyCardanoDbBuilder::new(test_dir.as_os_str().to_str().unwrap())
.with_immutables(&[1])
.set_immutable_trio_file_size(immutable_trio_file_size)
.with_ledger_files(&["blocks-0.dat"])
Expand All @@ -162,11 +168,26 @@ mod tests {
.build();
let expected_total_size = immutable_trio_file_size + ledger_file_size + volatile_file_size;

let mut ancillary_uploader = MockAncillaryFileUploader::new();
ancillary_uploader.expect_upload().return_once(|_| {
Ok(AncillaryLocation::CloudStorage {
uri: "ancillary_uri".to_string(),
})
});
let cardano_database_artifact_builder = CardanoDatabaseArtifactBuilder::new(
test_dir,
&Version::parse("1.0.0").unwrap(),
CompressionAlgorithm::Zstandard,
Arc::new(AncillaryArtifactBuilder::new(vec![])),
Arc::new(
AncillaryArtifactBuilder::new(
vec![Arc::new(ancillary_uploader)],
Arc::new(DumbSnapshotter::new()),
CardanoNetwork::DevNet(123),
CompressionAlgorithm::Gzip,
TestLogger::stdout(),
)
.unwrap(),
),
);

let beacon = fake_data::beacon();
Expand All @@ -187,12 +208,15 @@ mod tests {
.await
.unwrap();

let expected_ancillary_locations = vec![AncillaryLocation::CloudStorage {
uri: "ancillary_uri".to_string(),
}];
let artifact_expected = CardanoDatabaseSnapshot::new(
"merkleroot".to_string(),
beacon,
expected_total_size,
ArtifactsLocations {
ancillary: vec![],
ancillary: expected_ancillary_locations,
digests: vec![],
immutables: vec![],
},
Expand Down
Loading

0 comments on commit bf038eb

Please sign in to comment.