Skip to content

split snapshotter #2245

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

Merged
merged 4 commits into from
Jan 27, 2025
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
2 changes: 1 addition & 1 deletion 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.19"
version = "0.6.20"
description = "A Mithril Aggregator server"
authors = { workspace = true }
edition = { workspace = true }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,9 +137,9 @@ mod tests {
use crate::{
artifact_builder::{MockAncillaryFileUploader, MockImmutableFilesUploader},
immutable_file_digest_mapper::MockImmutableFileDigestMapper,
services::DumbSnapshotter,
test_tools::TestLogger,
tools::url_sanitizer::SanitizedUrlWithTrailingSlash,
DumbSnapshotter,
};

use super::*;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ use mithril_common::{

use crate::{
file_uploaders::{GcpUploader, LocalUploader},
snapshotter::OngoingSnapshot,
DumbUploader, FileUploader, Snapshotter,
services::{OngoingSnapshot, Snapshotter},
DumbUploader, FileUploader,
};

/// The [AncillaryFileUploader] trait allows identifying uploaders that return locations for ancillary archive files.
Expand Down Expand Up @@ -211,10 +211,10 @@ mod tests {
};
use uuid::Uuid;

use crate::{
test_tools::TestLogger, CompressedArchiveSnapshotter, DumbSnapshotter,
SnapshotterCompressionAlgorithm,
use crate::services::{
CompressedArchiveSnapshotter, DumbSnapshotter, SnapshotterCompressionAlgorithm,
};
use crate::test_tools::TestLogger;

use super::*;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ use mithril_common::{

use crate::{
file_uploaders::{GcpUploader, LocalUploader},
DumbUploader, FileUploader, Snapshotter,
services::Snapshotter,
DumbUploader, FileUploader,
};

fn immmutable_file_number_extractor(file_uri: &str) -> StdResult<Option<String>> {
Expand Down Expand Up @@ -224,11 +225,11 @@ mod tests {
use mockall::predicate::{always, eq};
use uuid::Uuid;

use crate::{
snapshotter::{MockSnapshotter, OngoingSnapshot},
test_tools::TestLogger,
CompressedArchiveSnapshotter, DumbSnapshotter, SnapshotterCompressionAlgorithm,
use crate::services::{
CompressedArchiveSnapshotter, DumbSnapshotter, MockSnapshotter, OngoingSnapshot,
SnapshotterCompressionAlgorithm,
};
use crate::test_tools::TestLogger;

use super::*;

Expand Down Expand Up @@ -767,8 +768,7 @@ mod tests {

let url_prefix =
SanitizedUrlWithTrailingSlash::parse("http://test.com:8080/base-root").unwrap();
let uploader =
LocalUploader::new(url_prefix, &target_dir, TestLogger::stdout()).unwrap();
let uploader = LocalUploader::new(url_prefix, &target_dir, TestLogger::stdout());
let location = ImmutableFilesUploader::batch_upload(
&uploader,
&[archive_1.clone(), archive_2.clone()],
Expand Down Expand Up @@ -802,8 +802,7 @@ mod tests {

let url_prefix =
SanitizedUrlWithTrailingSlash::parse("http://test.com:8080/base-root").unwrap();
let uploader =
LocalUploader::new(url_prefix, &target_dir, TestLogger::stdout()).unwrap();
let uploader = LocalUploader::new(url_prefix, &target_dir, TestLogger::stdout());

ImmutableFilesUploader::batch_upload(&uploader, &[archive])
.await
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,10 @@ use std::path::Path;
use std::sync::Arc;
use thiserror::Error;

use crate::{snapshotter::OngoingSnapshot, FileUploader, Snapshotter};
use crate::{
services::{OngoingSnapshot, Snapshotter},
FileUploader,
};

use super::ArtifactBuilder;
use mithril_common::logging::LoggerExtensions;
Expand Down Expand Up @@ -178,7 +181,8 @@ mod tests {
use mithril_common::{entities::CompressionAlgorithm, test_utils::fake_data};

use crate::{
file_uploaders::MockFileUploader, test_tools::TestLogger, DumbSnapshotter, DumbUploader,
file_uploaders::MockFileUploader, services::DumbSnapshotter, test_tools::TestLogger,
DumbUploader,
};

use super::*;
Expand Down
26 changes: 13 additions & 13 deletions mithril-aggregator/src/dependency_injection/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,19 +75,19 @@ use crate::{
},
services::{
AggregatorSignableSeedBuilder, AggregatorUpkeepService, BufferedCertifierService,
CardanoTransactionsImporter, CertifierService, EpochServiceDependencies, MessageService,
MithrilCertifierService, MithrilEpochService, MithrilMessageService, MithrilProverService,
CardanoTransactionsImporter, CertifierService, CompressedArchiveSnapshotter,
DumbSnapshotter, EpochServiceDependencies, MessageService, MithrilCertifierService,
MithrilEpochService, MithrilMessageService, MithrilProverService,
MithrilSignedEntityService, MithrilStakeDistributionService, ProverService,
SignedEntityService, SignedEntityServiceArtifactsDependencies, StakeDistributionService,
UpkeepService, UsageReporter,
SignedEntityService, SignedEntityServiceArtifactsDependencies, Snapshotter,
SnapshotterCompressionAlgorithm, StakeDistributionService, UpkeepService, UsageReporter,
},
store::CertificatePendingStorer,
tools::{CExplorerSignerRetriever, GenesisToolsDependency, SignersImporter},
AggregatorConfig, AggregatorRunner, AggregatorRuntime, CompressedArchiveSnapshotter,
Configuration, DependencyContainer, DumbSnapshotter, DumbUploader, EpochSettingsStorer,
ImmutableFileDigestMapper, LocalSnapshotUploader, MetricsService, MithrilSignerRegisterer,
MultiSigner, MultiSignerImpl, SingleSignatureAuthenticator, SnapshotUploaderType, Snapshotter,
SnapshotterCompressionAlgorithm, VerificationKeyStorer,
AggregatorConfig, AggregatorRunner, AggregatorRuntime, Configuration, DependencyContainer,
DumbUploader, EpochSettingsStorer, ImmutableFileDigestMapper, LocalSnapshotUploader,
MetricsService, MithrilSignerRegisterer, MultiSigner, MultiSignerImpl,
SingleSignatureAuthenticator, SnapshotUploaderType, VerificationKeyStorer,
};

const SQLITE_FILE: &str = "aggregator.sqlite3";
Expand Down Expand Up @@ -490,7 +490,7 @@ impl DependenciesBuilder {
self.configuration.get_server_url()?,
&snapshot_artifacts_dir,
logger,
)?))
)))
}
}
} else {
Expand Down Expand Up @@ -1283,7 +1283,7 @@ impl DependenciesBuilder {
ancillary_url_prefix,
&target_dir,
logger,
)?)])
))])
}
}
} else {
Expand Down Expand Up @@ -1321,7 +1321,7 @@ impl DependenciesBuilder {
immutable_url_prefix,
&target_dir,
logger,
)?)])
))])
}
}
} else {
Expand Down Expand Up @@ -1364,7 +1364,7 @@ impl DependenciesBuilder {
digests_url_prefix,
&target_dir,
logger,
)?)])
))])
}
}
} else {
Expand Down
4 changes: 2 additions & 2 deletions mithril-aggregator/src/dependency_injection/containers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,12 @@ use crate::{
multi_signer::MultiSigner,
services::{
CertifierService, EpochService, MessageService, ProverService, SignedEntityService,
StakeDistributionService, TransactionStore, UpkeepService,
Snapshotter, StakeDistributionService, TransactionStore, UpkeepService,
},
signer_registerer::SignerRecorder,
store::CertificatePendingStorer,
EpochSettingsStorer, MetricsService, SignerRegisterer, SignerRegistrationRoundOpener,
SingleSignatureAuthenticator, Snapshotter, VerificationKeyStorer,
SingleSignatureAuthenticator, VerificationKeyStorer,
};

/// EpochServiceWrapper wraps a [EpochService]
Expand Down
15 changes: 6 additions & 9 deletions mithril-aggregator/src/file_uploaders/local_snapshot_uploader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,15 @@ impl LocalSnapshotUploader {
server_url_prefix: SanitizedUrlWithTrailingSlash,
target_location: &Path,
logger: Logger,
) -> StdResult<Self> {
) -> Self {
let logger = logger.new_with_component_name::<Self>();
debug!(logger, "New LocalSnapshotUploader created"; "server_url_prefix" => &server_url_prefix.as_str());

Ok(Self {
Self {
server_url_prefix,
target_location: target_location.to_path_buf(),
logger,
})
}
}
}

Expand Down Expand Up @@ -100,8 +100,7 @@ mod tests {
let url_prefix =
SanitizedUrlWithTrailingSlash::parse("http://test.com:8080/base-root").unwrap();
let uploader =
LocalSnapshotUploader::new(url_prefix, target_dir.path(), TestLogger::stdout())
.unwrap();
LocalSnapshotUploader::new(url_prefix, target_dir.path(), TestLogger::stdout());
let location = uploader
.upload(&archive)
.await
Expand All @@ -120,8 +119,7 @@ mod tests {
SanitizedUrlWithTrailingSlash::parse("http://test.com:8080/base-root/").unwrap(),
target_dir.path(),
TestLogger::stdout(),
)
.unwrap();
);
uploader.upload(&archive).await.unwrap();

assert!(target_dir
Expand All @@ -140,8 +138,7 @@ mod tests {
SanitizedUrlWithTrailingSlash::parse("http://test.com:8080/base-root/").unwrap(),
target_dir.path(),
TestLogger::stdout(),
)
.unwrap();
);
uploader
.upload(source_dir.path())
.await
Expand Down
14 changes: 6 additions & 8 deletions mithril-aggregator/src/file_uploaders/local_uploader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,15 @@ impl LocalUploader {
server_url_prefix: SanitizedUrlWithTrailingSlash,
target_location: &Path,
logger: Logger,
) -> StdResult<Self> {
) -> Self {
let logger = logger.new_with_component_name::<Self>();
debug!(logger, "New LocalUploader created"; "server_url_prefix" => &server_url_prefix.as_str());

Ok(Self {
Self {
server_url_prefix,
target_location: target_location.to_path_buf(),
logger,
})
}
}
}

Expand Down Expand Up @@ -101,7 +101,7 @@ mod tests {

let url_prefix =
SanitizedUrlWithTrailingSlash::parse("http://test.com:8080/base-root").unwrap();
let uploader = LocalUploader::new(url_prefix, &target_dir, TestLogger::stdout()).unwrap();
let uploader = LocalUploader::new(url_prefix, &target_dir, TestLogger::stdout());
let location = FileUploader::upload(&uploader, &archive)
.await
.expect("local upload should not fail");
Expand All @@ -125,8 +125,7 @@ mod tests {
SanitizedUrlWithTrailingSlash::parse("http://test.com:8080/base-root/").unwrap(),
&target_dir,
TestLogger::stdout(),
)
.unwrap();
);
FileUploader::upload(&uploader, &archive).await.unwrap();

assert!(target_dir.join(archive.file_name().unwrap()).exists());
Expand All @@ -146,8 +145,7 @@ mod tests {
SanitizedUrlWithTrailingSlash::parse("http://test.com:8080/base-root/").unwrap(),
&target_dir,
TestLogger::stdout(),
)
.unwrap();
);
FileUploader::upload(&uploader, &source_dir)
.await
.expect_err("Uploading a directory should fail");
Expand Down
5 changes: 0 additions & 5 deletions mithril-aggregator/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ mod multi_signer;
mod runtime;
pub mod services;
mod signer_registerer;
mod snapshotter;
mod store;
mod tools;

Expand All @@ -49,10 +48,6 @@ pub use signer_registerer::{
MithrilSignerRegisterer, SignerRecorder, SignerRegisterer, SignerRegistrationError,
SignerRegistrationRound, SignerRegistrationRoundOpener,
};
pub use snapshotter::{
CompressedArchiveSnapshotter, DumbSnapshotter, SnapshotError, Snapshotter,
SnapshotterCompressionAlgorithm,
};
pub use store::{CertificatePendingStorer, EpochSettingsStorer, VerificationKeyStorer};
pub use tools::{
CExplorerSignerRetriever, SignersImporter, SignersImporterPersister, SignersImporterRetriever,
Expand Down
2 changes: 2 additions & 0 deletions mithril-aggregator/src/services/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ mod message;
mod prover;
mod signable_builder;
mod signed_entity;
mod snapshotter;
mod stake_distribution;
mod upkeep;
mod usage_reporter;
Expand All @@ -27,6 +28,7 @@ pub use message::*;
pub use prover::*;
pub use signable_builder::*;
pub use signed_entity::*;
pub use snapshotter::*;
pub use stake_distribution::*;
pub use upkeep::*;
pub use usage_reporter::*;
Loading
Loading