Skip to content

Commit 1479feb

Browse files
committed
Make protocol parameters configuration explicit
In the end to end test.
1 parent 954d6cf commit 1479feb

File tree

3 files changed

+34
-14
lines changed

3 files changed

+34
-14
lines changed

mithril-test-lab/mithril-end-to-end/src/end_to_end_spec.rs

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use crate::utils::AttemptResult;
22
use crate::{attempt, Aggregator, Client, ClientCommand, Devnet, MithrilInfrastructure};
33
use mithril_common::chain_observer::{CardanoCliChainObserver, ChainObserver};
44
use mithril_common::digesters::ImmutableFile;
5-
use mithril_common::entities::{Certificate, Epoch, EpochSettings, Snapshot};
5+
use mithril_common::entities::{Certificate, Epoch, EpochSettings, ProtocolParameters, Snapshot};
66
use reqwest::StatusCode;
77
use slog_scope::{info, warn};
88
use std::error::Error;
@@ -60,7 +60,7 @@ impl Spec {
6060
)
6161
.await?;
6262

63-
// Wait 5 epochs after updating protocol parameters, so that we make sure that we use new protool parameters a few times
63+
// Wait 5 epochs after updating protocol parameters, so that we make sure that we use new protocol parameters a few times
6464
update_protocol_parameters(self.infrastructure.aggregator_mut()).await?;
6565
wait_for_epoch_settings(&aggregator_endpoint).await?;
6666
target_epoch += 5;
@@ -188,7 +188,7 @@ async fn wait_for_target_epoch(
188188
}
189189
}) {
190190
AttemptResult::Ok(_) => {
191-
info!("Target epoch reached !"; "target_epoch" => ?target_epoch);
191+
info!("Target epoch reached!"; "target_epoch" => ?target_epoch);
192192
Ok(())
193193
}
194194
AttemptResult::Err(error) => Err(error),
@@ -205,7 +205,7 @@ async fn bootstrap_genesis_certificate(aggregator: &mut Aggregator) -> Result<()
205205

206206
info!("> stopping aggregator");
207207
aggregator.stop().await?;
208-
info!("> bootstrapping genesis using signers registered two epochs ago ...");
208+
info!("> bootstrapping genesis using signers registered two epochs ago...");
209209
aggregator.bootstrap_genesis().await?;
210210
info!("> done, restarting aggregator");
211211
aggregator.serve()?;
@@ -226,8 +226,16 @@ async fn update_protocol_parameters(aggregator: &mut Aggregator) -> Result<(), S
226226

227227
info!("> stopping aggregator");
228228
aggregator.stop().await?;
229-
info!("> updating protocol parameters ...");
230-
aggregator.update_protocol_parameters();
229+
let protocol_parameters_new = ProtocolParameters {
230+
k: 150,
231+
m: 200,
232+
phi_f: 0.95,
233+
};
234+
info!(
235+
"> updating protocol parameters to {:?}...",
236+
protocol_parameters_new
237+
);
238+
aggregator.set_protocol_parameters(&protocol_parameters_new);
231239
info!("> done, restarting aggregator");
232240
aggregator.serve()?;
233241

mithril-test-lab/mithril-end-to-end/src/mithril/aggregator.rs

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
use crate::devnet::BftNode;
22
use crate::utils::MithrilCommand;
33
use crate::DEVNET_MAGIC_ID;
4+
use mithril_common::entities;
45
use std::collections::HashMap;
56
use std::path::{Path, PathBuf};
67
use tokio::process::Child;
@@ -25,9 +26,6 @@ impl Aggregator {
2526
let server_port_parameter = server_port.to_string();
2627
let env = HashMap::from([
2728
("NETWORK", "devnet"),
28-
("PROTOCOL_PARAMETERS__K", "75"),
29-
("PROTOCOL_PARAMETERS__M", "100"),
30-
("PROTOCOL_PARAMETERS__PHI_F", "0.95"),
3129
("RUN_INTERVAL", "800"),
3230
("SERVER_IP", "0.0.0.0"),
3331
("SERVER_PORT", &server_port_parameter),
@@ -105,11 +103,19 @@ impl Aggregator {
105103
Ok(())
106104
}
107105

108-
pub fn update_protocol_parameters(&mut self) {
109-
self.command.set_env_var("PROTOCOL_PARAMETERS__K", "150");
110-
self.command.set_env_var("PROTOCOL_PARAMETERS__M", "200");
111-
self.command
112-
.set_env_var("PROTOCOL_PARAMETERS__PHI_F", "0.95");
106+
pub fn set_protocol_parameters(&mut self, protocol_parameters: &entities::ProtocolParameters) {
107+
self.command.set_env_var(
108+
"PROTOCOL_PARAMETERS__K",
109+
&format!("{}", protocol_parameters.k),
110+
);
111+
self.command.set_env_var(
112+
"PROTOCOL_PARAMETERS__M",
113+
&format!("{}", protocol_parameters.m),
114+
);
115+
self.command.set_env_var(
116+
"PROTOCOL_PARAMETERS__PHI_F",
117+
&format!("{}", protocol_parameters.phi_f),
118+
);
113119
}
114120

115121
pub async fn tail_logs(&self, number_of_line: u64) -> Result<(), String> {

mithril-test-lab/mithril-end-to-end/src/mithril/infrastructure.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
use crate::{Aggregator, Client, Devnet, Signer, DEVNET_MAGIC_ID};
22
use mithril_common::chain_observer::{CardanoCliChainObserver, CardanoCliRunner};
3+
use mithril_common::entities::ProtocolParameters;
34
use mithril_common::CardanoNetwork;
45
use std::borrow::BorrowMut;
56
use std::path::{Path, PathBuf};
@@ -35,6 +36,11 @@ impl MithrilInfrastructure {
3536
work_dir,
3637
bin_dir,
3738
)?;
39+
aggregator.set_protocol_parameters(&ProtocolParameters {
40+
k: 75,
41+
m: 100,
42+
phi_f: 0.95,
43+
});
3844
aggregator.serve()?;
3945

4046
let mut signers: Vec<Signer> = vec![];

0 commit comments

Comments
 (0)