Skip to content

Commit

Permalink
fix EtE CLI parameters
Browse files Browse the repository at this point in the history
  • Loading branch information
ghubertpalo committed Sep 30, 2022
1 parent 20db020 commit 497ac35
Show file tree
Hide file tree
Showing 4 changed files with 70 additions and 15 deletions.
11 changes: 6 additions & 5 deletions mithril-aggregator/src/command_args.rs
Expand Up @@ -23,14 +23,15 @@ use mithril_common::{
use crate::tools::GenesisToolsDependency;
use crate::{
tools::GenesisTools, AggregatorConfig, AggregatorRunner, AggregatorRuntime,
CertificatePendingStore, Configuration, DependencyManager, ProtocolParametersStore, Server,
CertificatePendingStore, Configuration, DependencyManager, GenesisConfiguration,
ProtocolParametersStore, Server,
};
use crate::{
CertificateStore, GzipSnapshotter, MultiSignerImpl, SingleSignatureStore, VerificationKeyStore,
};

fn setup_genesis_dependencies(
config: &Configuration,
config: &GenesisConfiguration,
) -> Result<GenesisToolsDependency, Box<dyn std::error::Error>> {
let sqlite_db_path = Some(config.get_sqlite_file());
let chain_observer = Arc::new(
Expand Down Expand Up @@ -460,7 +461,7 @@ impl ExportGenesisSubCommand {
&self,
config_builder: ConfigBuilder<DefaultState>,
) -> Result<(), Box<dyn Error>> {
let config: Configuration = config_builder
let config: GenesisConfiguration = config_builder
.build()
.map_err(|e| format!("configuration build error: {}", e))?
.try_deserialize()
Expand Down Expand Up @@ -489,7 +490,7 @@ impl ImportGenesisSubCommand {
&self,
config_builder: ConfigBuilder<DefaultState>,
) -> Result<(), Box<dyn Error>> {
let config: Configuration = config_builder
let config: GenesisConfiguration = config_builder
.build()
.map_err(|e| format!("configuration build error: {}", e))?
.try_deserialize()
Expand Down Expand Up @@ -520,7 +521,7 @@ impl BootstrapGenesisSubCommand {
&self,
config_builder: ConfigBuilder<DefaultState>,
) -> Result<(), Box<dyn Error>> {
let config: Configuration = config_builder
let config: GenesisConfiguration = config_builder
.build()
.map_err(|e| format!("configuration build error: {}", e))?
.try_deserialize()
Expand Down
58 changes: 57 additions & 1 deletion mithril-aggregator/src/configuration.rs
Expand Up @@ -58,7 +58,7 @@ pub struct Configuration {
/// Run Interval is the interval between two runtime cycles in ms
pub run_interval: u64,

/// Directory to snapshot
/// Directory of the node immutable files
pub db_directory: PathBuf,

/// Directory to store snapshot
Expand Down Expand Up @@ -152,3 +152,59 @@ impl Configuration {
self.data_stores_directory.join(SQLITE_FILE)
}
}

/// Configuration expected for Genesis commands.
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct GenesisConfiguration {
/// Cardano CLI tool path
pub cardano_cli_path: PathBuf,

/// Path of the socket used by the Cardano CLI tool
/// to communicate with the Cardano node
pub cardano_node_socket_path: PathBuf,

/// Directory of the node immutable files
pub db_directory: PathBuf,

/// Cardano Network Magic number
///
/// useful for TestNet & DevNet
pub network_magic: Option<u64>,

/// Cardano network
pub network: String,

/// Protocol parameters
pub protocol_parameters: ProtocolParameters,

/// Directory to store aggregator data (Certificates, Snapshots, Protocol Parameters, ...)
pub data_stores_directory: PathBuf,

/// Genesis verification key
pub genesis_verification_key: String,

/// Max number of records in stores.
/// When new records are added, oldest records are automatically deleted so
/// there can always be at max the number of records specified by this
/// setting.
pub store_retention_limit: Option<usize>,
}

impl GenesisConfiguration {
/// Check configuration and return a representation of the Cardano network.
pub fn get_network(&self) -> Result<CardanoNetwork, ConfigError> {
CardanoNetwork::from_code(self.network.clone(), self.network_magic)
.map_err(|e| ConfigError::Message(e.to_string()))
}

/// Return the file of the SQLite stores. If the directory does not exist, it is created.
pub fn get_sqlite_file(&self) -> PathBuf {
let store_dir = &self.data_stores_directory;

if !store_dir.exists() {
std::fs::create_dir_all(store_dir).unwrap();
}

self.data_stores_directory.join(SQLITE_FILE)
}
}
4 changes: 3 additions & 1 deletion mithril-aggregator/src/lib.rs
Expand Up @@ -23,7 +23,9 @@ mod snapshotter;
mod store;
mod tools;

pub use crate::configuration::{Configuration, SnapshotStoreType, SnapshotUploaderType};
pub use crate::configuration::{
Configuration, GenesisConfiguration, SnapshotStoreType, SnapshotUploaderType,
};
pub use crate::multi_signer::{MultiSigner, MultiSignerImpl, ProtocolError};
pub use crate::snapshot_stores::{LocalSnapshotStore, RemoteSnapshotStore, SnapshotStore};
pub use command_args::MainOpts;
Expand Down
12 changes: 4 additions & 8 deletions mithril-test-lab/mithril-end-to-end/src/mithril/aggregator.rs
Expand Up @@ -21,13 +21,15 @@ impl Aggregator {
work_dir: &Path,
bin_dir: &Path,
) -> Result<Self, String> {
let port = server_port.to_string();
let magic_id = DEVNET_MAGIC_ID.to_string();
let server_port_parameter = server_port.to_string();
let env = HashMap::from([
("NETWORK", "devnet"),
("PROTOCOL_PARAMETERS__K", "5"),
("PROTOCOL_PARAMETERS__M", "100"),
("PROTOCOL_PARAMETERS__PHI_F", "0.65"),
("SERVER_IP", "0.0.0.0"),
("SERVER_PORT", &server_port_parameter),
("RUN_INTERVAL", "600"),
("URL_SNAPSHOT_MANIFEST", ""),
("SNAPSHOT_STORE_TYPE", "local"),
Expand All @@ -42,13 +44,7 @@ impl Aggregator {
("GENESIS_VERIFICATION_KEY", "5b33322c3235332c3138362c3230312c3137372c31312c3131372c3133352c3138372c3136372c3138312c3138382c32322c35392c3230362c3130352c3233312c3135302c3231352c33302c37382c3231322c37362c31362c3235322c3138302c37322c3133342c3133372c3234372c3136312c36385d"),
("GENESIS_SECRET_KEY", "5b3131382c3138342c3232342c3137332c3136302c3234312c36312c3134342c36342c39332c3130362c3232392c38332c3133342c3138392c34302c3138392c3231302c32352c3138342c3136302c3134312c3233372c32362c3136382c35342c3233392c3230342c3133392c3131392c31332c3139395d"),
]);
let args = vec![
"--db-directory",
bft_node.db_path.to_str().unwrap(),
"--server-port",
&port,
"-vvv",
];
let args = vec!["--db-directory", bft_node.db_path.to_str().unwrap(), "-vvv"];

let command = MithrilCommand::new("mithril-aggregator", work_dir, bin_dir, env, &args)?;

Expand Down

0 comments on commit 497ac35

Please sign in to comment.