Skip to content

Commit fb5cda7

Browse files
committed
feat(e2e): support for fake DMQ node
1 parent 4a74c9f commit fb5cda7

File tree

7 files changed

+71
-5
lines changed

7 files changed

+71
-5
lines changed

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,12 @@ pub struct Args {
123123
#[clap(long, default_value = "false")]
124124
use_p2p_passive_relays: bool,
125125

126+
/// Use DMQ protocol (used to broadcast signatures)
127+
///
128+
/// Requires the Mithril nodes to be compiled with the 'future_dmq' feature
129+
#[clap(long)]
130+
use_dmq: bool,
131+
126132
/// Skip cardano binaries download
127133
#[clap(long)]
128134
skip_cardano_bin_download: bool,
@@ -327,6 +333,7 @@ impl App {
327333
let use_relays = args.use_relays;
328334
let relay_signer_registration_mode = args.relay_signer_registration_mode;
329335
let relay_signature_registration_mode = args.relay_signature_registration_mode;
336+
let use_dmq = args.use_dmq;
330337

331338
let use_p2p_passive_relays = args.use_p2p_passive_relays;
332339

@@ -360,6 +367,7 @@ impl App {
360367
mithril_era_reader_adapter: args.mithril_era_reader_adapter,
361368
signed_entity_types: args.signed_entity_types.clone(),
362369
run_only_mode,
370+
use_dmq,
363371
use_relays,
364372
relay_signer_registration_mode,
365373
relay_signature_registration_mode,

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

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ pub struct AggregatorConfig<'a> {
3939
pub signed_entity_types: &'a [String],
4040
pub chain_observer_type: &'a str,
4141
pub leader_aggregator_endpoint: &'a Option<String>,
42+
pub use_dmq: bool,
4243
}
4344

4445
pub struct Aggregator {
@@ -75,6 +76,7 @@ impl Aggregator {
7576
let public_server_url = format!("http://localhost:{server_port_parameter}/aggregator");
7677
let mut env = HashMap::from([
7778
("NETWORK", "devnet"),
79+
("NETWORK_MAGIC", &magic_id),
7880
("RUN_INTERVAL", &mithril_run_interval),
7981
("SERVER_IP", "0.0.0.0"),
8082
("SERVER_PORT", &server_port_parameter),
@@ -85,7 +87,6 @@ impl Aggregator {
8587
"SNAPSHOT_DIRECTORY",
8688
aggregator_config.artifacts_dir.to_str().unwrap(),
8789
),
88-
("NETWORK_MAGIC", &magic_id),
8990
(
9091
"DATA_STORES_DIRECTORY",
9192
aggregator_config.store_dir.to_str().unwrap(),
@@ -129,6 +130,15 @@ impl Aggregator {
129130
if let Some(leader_aggregator_endpoint) = aggregator_config.leader_aggregator_endpoint {
130131
env.insert("LEADER_AGGREGATOR_ENDPOINT", leader_aggregator_endpoint);
131132
}
133+
let dmq_node_socket_path = aggregator_config
134+
.work_dir
135+
.join(format!("dmq-aggregator-{}.socket", aggregator_config.index));
136+
if aggregator_config.use_dmq {
137+
env.insert(
138+
"DMQ_NODE_SOCKET_PATH",
139+
dmq_node_socket_path.to_str().unwrap(),
140+
);
141+
}
132142
let args = vec![
133143
"--db-directory",
134144
aggregator_config.full_node.db_path.to_str().unwrap(),

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

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ pub struct MithrilInfrastructureConfig {
3535
pub relay_signer_registration_mode: String,
3636
pub relay_signature_registration_mode: String,
3737
pub use_p2p_passive_relays: bool,
38+
pub use_dmq: bool,
3839
pub use_era_specific_work_dir: bool,
3940
}
4041

@@ -68,6 +69,7 @@ impl MithrilInfrastructureConfig {
6869
relay_signer_registration_mode: "passthrough".to_string(),
6970
relay_signature_registration_mode: "passthrough".to_string(),
7071
use_p2p_passive_relays: false,
72+
use_dmq: false,
7173
use_era_specific_work_dir: false,
7274
}
7375
}
@@ -255,6 +257,7 @@ impl MithrilInfrastructure {
255257
signed_entity_types: &config.signed_entity_types,
256258
chain_observer_type,
257259
leader_aggregator_endpoint: &leader_aggregator_endpoint,
260+
use_dmq: config.use_dmq,
258261
})?;
259262

260263
aggregator
@@ -294,12 +297,13 @@ impl MithrilInfrastructure {
294297
let mut bootstrap_peer_addr = None;
295298
for (index, aggregator_endpoint) in aggregator_endpoints.iter().enumerate() {
296299
let mut relay_aggregator = RelayAggregator::new(
297-
Aggregator::name_suffix(index),
300+
index,
298301
config.server_port + index as u64 + 100,
299302
bootstrap_peer_addr.clone(),
300303
aggregator_endpoint,
301304
&config.work_dir,
302305
&config.bin_dir,
306+
config.use_dmq,
303307
)?;
304308
if bootstrap_peer_addr.is_none() {
305309
bootstrap_peer_addr = Some(relay_aggregator.peer_addr().to_owned());
@@ -310,6 +314,7 @@ impl MithrilInfrastructure {
310314

311315
for (index, party_id) in signers_party_ids.iter().enumerate() {
312316
let mut relay_signer = RelaySigner::new(&RelaySignerConfiguration {
317+
signer_number: index + 1,
313318
listen_port: config.server_port + index as u64 + 200,
314319
server_port: config.server_port + index as u64 + 300,
315320
dial_to: bootstrap_peer_addr.clone(),
@@ -319,6 +324,7 @@ impl MithrilInfrastructure {
319324
party_id: party_id.clone(),
320325
work_dir: &config.work_dir,
321326
bin_dir: &config.bin_dir,
327+
use_dmq: config.use_dmq,
322328
})?;
323329
relay_signer.start()?;
324330

@@ -389,6 +395,7 @@ impl MithrilInfrastructure {
389395
mithril_era_reader_adapter: &config.mithril_era_reader_adapter,
390396
mithril_era_marker_address: &config.devnet.mithril_era_marker_address()?,
391397
enable_certification,
398+
use_dmq: config.use_dmq,
392399
})?;
393400
signer.start().await?;
394401

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

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
use crate::utils::MithrilCommand;
2+
use crate::{Aggregator, DEVNET_MAGIC_ID};
23
use mithril_common::StdResult;
34
use std::collections::HashMap;
45
use std::path::Path;
@@ -14,21 +15,33 @@ pub struct RelayAggregator {
1415

1516
impl RelayAggregator {
1617
pub fn new(
17-
name: String,
18+
index: usize,
1819
listen_port: u64,
1920
dial_to: Option<String>,
2021
aggregator_endpoint: &str,
2122
work_dir: &Path,
2223
bin_dir: &Path,
24+
use_dmq: bool,
2325
) -> StdResult<Self> {
26+
let name = Aggregator::name_suffix(index);
2427
let listen_port_str = format!("{listen_port}");
28+
let magic_id = DEVNET_MAGIC_ID.to_string();
2529
let mut env = HashMap::from([
2630
("LISTEN_PORT", listen_port_str.as_str()),
31+
("NETWORK", "devnet"),
32+
("NETWORK_MAGIC", &magic_id),
2733
("AGGREGATOR_ENDPOINT", aggregator_endpoint),
2834
]);
2935
if let Some(dial_to) = &dial_to {
3036
env.insert("DIAL_TO", dial_to);
3137
}
38+
let dmq_node_socket_path = work_dir.join(format!("dmq-aggregator-{index}.socket"));
39+
if use_dmq {
40+
env.insert(
41+
"DMQ_NODE_SOCKET_PATH",
42+
dmq_node_socket_path.to_str().unwrap(),
43+
);
44+
}
3245
let args = vec!["-vvv", "aggregator"];
3346

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

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

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
use crate::DEVNET_MAGIC_ID;
12
use crate::utils::MithrilCommand;
23
use mithril_common::StdResult;
34
use mithril_common::entities::PartyId;
@@ -6,6 +7,7 @@ use std::path::Path;
67
use tokio::process::Child;
78

89
pub struct RelaySignerConfiguration<'a> {
10+
pub signer_number: usize,
911
pub listen_port: u64,
1012
pub server_port: u64,
1113
pub dial_to: Option<String>,
@@ -15,6 +17,7 @@ pub struct RelaySignerConfiguration<'a> {
1517
pub party_id: PartyId,
1618
pub work_dir: &'a Path,
1719
pub bin_dir: &'a Path,
20+
pub use_dmq: bool,
1821
}
1922

2023
#[derive(Debug)]
@@ -28,15 +31,20 @@ pub struct RelaySigner {
2831

2932
impl RelaySigner {
3033
pub fn new(configuration: &RelaySignerConfiguration) -> StdResult<Self> {
34+
let party_id = configuration.party_id.to_owned();
3135
let listen_port_str = format!("{}", configuration.listen_port);
3236
let server_port_str = format!("{}", configuration.server_port);
37+
38+
let magic_id = DEVNET_MAGIC_ID.to_string();
3339
let relay_signer_registration_mode =
3440
configuration.relay_signer_registration_mode.to_string();
3541
let relay_signature_registration_mode =
3642
configuration.relay_signature_registration_mode.to_string();
3743
let mut env = HashMap::from([
3844
("LISTEN_PORT", listen_port_str.as_str()),
3945
("SERVER_PORT", server_port_str.as_str()),
46+
("NETWORK", "devnet"),
47+
("NETWORK_MAGIC", &magic_id),
4048
("AGGREGATOR_ENDPOINT", configuration.aggregator_endpoint),
4149
("SIGNER_REPEATER_DELAY", "100"),
4250
(
@@ -51,6 +59,15 @@ impl RelaySigner {
5159
if let Some(dial_to) = &configuration.dial_to {
5260
env.insert("DIAL_TO", dial_to);
5361
}
62+
let dmq_node_socket_path = configuration
63+
.work_dir
64+
.join(format!("dmq-signer-{}.socket", configuration.signer_number));
65+
if configuration.use_dmq {
66+
env.insert(
67+
"DMQ_NODE_SOCKET_PATH",
68+
dmq_node_socket_path.to_str().unwrap(),
69+
);
70+
}
5471
let args = vec!["-vvv", "signer"];
5572

5673
let mut command = MithrilCommand::new(
@@ -65,7 +82,7 @@ impl RelaySigner {
6582
Ok(Self {
6683
listen_port: configuration.listen_port,
6784
server_port: configuration.server_port,
68-
party_id: configuration.party_id.to_owned(),
85+
party_id,
6986
command,
7087
process: None,
7188
})

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

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ pub struct SignerConfig<'a> {
2525
pub mithril_era_reader_adapter: &'a str,
2626
pub mithril_era_marker_address: &'a str,
2727
pub enable_certification: bool,
28+
pub use_dmq: bool,
2829
}
2930

3031
#[derive(Debug)]
@@ -54,6 +55,7 @@ impl Signer {
5455
let mithril_run_interval = format!("{}", signer_config.mithril_run_interval);
5556
let mut env = HashMap::from([
5657
("NETWORK", "devnet"),
58+
("NETWORK_MAGIC", &magic_id),
5759
("RUN_INTERVAL", &mithril_run_interval),
5860
("AGGREGATOR_ENDPOINT", &signer_config.aggregator_endpoint),
5961
(
@@ -65,7 +67,6 @@ impl Signer {
6567
signer_config.store_dir.to_str().unwrap(),
6668
),
6769
("STORE_RETENTION_LIMIT", "10"),
68-
("NETWORK_MAGIC", &magic_id),
6970
(
7071
"CARDANO_NODE_SOCKET_PATH",
7172
signer_config.pool_node.socket_path.to_str().unwrap(),
@@ -96,6 +97,15 @@ impl Signer {
9697
} else {
9798
env.insert("PARTY_ID", &party_id);
9899
}
100+
let dmq_node_socket_path = signer_config
101+
.work_dir
102+
.join(format!("dmq-signer-{}.socket", signer_config.signer_number));
103+
if signer_config.use_dmq {
104+
env.insert(
105+
"DMQ_NODE_SOCKET_PATH",
106+
dmq_node_socket_path.to_str().unwrap(),
107+
);
108+
}
99109
let args = vec!["-vvv"];
100110

101111
let mut command = MithrilCommand::new(

mithril-test-lab/mithril-end-to-end/src/stress_test/aggregator_helpers.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ pub async fn bootstrap_aggregator(
3636
signed_entity_types: &signed_entity_types,
3737
chain_observer_type,
3838
leader_aggregator_endpoint: &None,
39+
use_dmq: false,
3940
})
4041
.unwrap();
4142

0 commit comments

Comments
 (0)