mithril_aggregator/
lib.rs

1#![warn(missing_docs)]
2//! Mithril aggregator
3//! The Aggregator is responsible for:
4//! * registering signers
5//! * producing aggregate multi-signatures
6//! * creating, storing & serving the certificate chain
7//! * creating, storing & serving certified snapshots
8//!
9//! This crate is divided in two parts: a HTTP server that exposes an API to
10//! communicate with signers and a Runtime that tracks the blockchain to provide
11//! signed certificates.
12//! You can find more information on how it works reading the [documentation website](https://mithril.network/doc/mithril/mithril-network/aggregator).
13
14mod artifact_builder;
15mod commands;
16mod configuration;
17pub mod database;
18pub mod dependency_injection;
19pub mod entities;
20pub mod event_store;
21mod file_uploaders;
22mod http_server;
23mod immutable_file_digest_mapper;
24mod message_adapters;
25pub mod metrics;
26mod multi_signer;
27mod runtime;
28pub mod services;
29mod store;
30mod tools;
31
32pub use crate::artifact_builder::ArtifactBuilder;
33pub use crate::configuration::{
34    Configuration, DefaultConfiguration, ExecutionEnvironment, SnapshotUploaderType,
35    ZstandardCompressionParameters,
36};
37pub use crate::multi_signer::{MultiSigner, MultiSignerImpl};
38pub use commands::{CommandType, MainOpts};
39pub use dependency_injection::DependencyContainer;
40pub use file_uploaders::{DumbUploader, FileUploader};
41pub use message_adapters::FromRegisterSignerAdapter;
42pub use metrics::*;
43pub use runtime::{
44    AggregatorConfig, AggregatorRunner, AggregatorRunnerTrait, AggregatorRuntime, RuntimeError,
45};
46pub use services::{
47    MithrilSignerRegistrationFollower, MithrilSignerRegistrationLeader,
48    MithrilSignerRegistrationVerifier, SignerRecorder, SignerRegisterer, SignerRegistrationError,
49    SignerRegistrationRound, SignerRegistrationRoundOpener, SignerRegistrationVerifier,
50    SignerSynchronizer,
51};
52pub use store::{EpochSettingsStorer, VerificationKeyStorer};
53pub use tools::{
54    CExplorerSignerRetriever, SignersImporter, SignersImporterPersister, SignersImporterRetriever,
55    SingleSignatureAuthenticator,
56};
57
58pub use immutable_file_digest_mapper::ImmutableFileDigestMapper;
59
60#[cfg(test)]
61pub(crate) use dependency_injection::tests::initialize_dependencies;
62
63// Memory allocator (to handle properly memory fragmentation)
64#[cfg(all(not(target_env = "msvc"), feature = "jemallocator"))]
65use tikv_jemallocator::Jemalloc;
66
67#[cfg(all(not(target_env = "msvc"), feature = "jemallocator"))]
68#[global_allocator]
69static GLOBAL: Jemalloc = Jemalloc;
70
71#[cfg(test)]
72pub(crate) mod test_tools {
73    use std::fs::File;
74    use std::io;
75    use std::sync::Arc;
76
77    use slog::{Drain, Logger};
78    use slog_async::Async;
79    use slog_term::{CompactFormat, PlainDecorator};
80
81    pub struct TestLogger;
82
83    impl TestLogger {
84        fn from_writer<W: io::Write + Send + 'static>(writer: W) -> Logger {
85            let decorator = PlainDecorator::new(writer);
86            let drain = CompactFormat::new(decorator).build().fuse();
87            let drain = Async::new(drain).build().fuse();
88            Logger::root(Arc::new(drain), slog::o!())
89        }
90
91        pub fn stdout() -> Logger {
92            Self::from_writer(slog_term::TestStdoutWriter)
93        }
94
95        pub fn file(filepath: &std::path::Path) -> Logger {
96            Self::from_writer(File::create(filepath).unwrap())
97        }
98    }
99}