Skip to content

Commit 0f094fb

Browse files
authored
Merge pull request #1588 from input-output-hk/jpraynaud/1587-relay-signer-registrations-p2p
Mithril relay broadcasts signer registrations in P2P
2 parents 2d3b463 + 07c14d8 commit 0f094fb

File tree

18 files changed

+578
-124
lines changed

18 files changed

+578
-124
lines changed

Cargo.lock

Lines changed: 95 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

mithril-infra/assets/docker/docker-compose-signer-unverified-p2p.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ services:
8989
- SERVER_PORT=${SIGNER_RELAY_SERVER_PORT}
9090
- AGGREGATOR_ENDPOINT=http://${AGGREGATOR_CREDENTIALS}mithril-aggregator:8080/aggregator
9191
- DIAL_TO=/dns4/mithril-aggregator-relay/tcp/${AGGREGATOR_RELAY_LISTEN_PORT}
92+
- SIGNER_REPEATER_DELAY=${SIGNER_RELAY_REGISTRATION_REPEATER_DELAY}
9293
ports:
9394
- "${SIGNER_RELAY_LISTEN_PORT}:${SIGNER_RELAY_LISTEN_PORT}"
9495
- "${SIGNER_RELAY_SERVER_PORT}:${SIGNER_RELAY_SERVER_PORT}"

mithril-infra/assets/docker/docker-compose-signer-verified-p2p.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,7 @@ services:
147147
- SERVER_PORT=${SIGNER_RELAY_SERVER_PORT}
148148
- AGGREGATOR_ENDPOINT=http://${AGGREGATOR_CREDENTIALS}mithril-aggregator:8080/aggregator
149149
- DIAL_TO=/dns4/mithril-aggregator-relay/tcp/${AGGREGATOR_RELAY_LISTEN_PORT}
150+
- SIGNER_REPEATER_DELAY=${SIGNER_RELAY_REGISTRATION_REPEATER_DELAY}
150151
ports:
151152
- "${SIGNER_RELAY_LISTEN_PORT}:${SIGNER_RELAY_LISTEN_PORT}"
152153
- "${SIGNER_RELAY_SERVER_PORT}:${SIGNER_RELAY_SERVER_PORT}"

mithril-infra/assets/infra.version

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
0.2.14
1+
0.2.15

mithril-infra/mithril.signer.tf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ EOT
8585
"export AGGREGATOR_RELAY_LISTEN_PORT='${local.mithril_aggregator_relay_mithril_listen_port}'",
8686
"export SIGNER_RELAY_LISTEN_PORT='${local.mithril_signers_relay_listen_port[each.key]}'",
8787
"export SIGNER_RELAY_SERVER_PORT='${local.mithril_signers_relay_server_port[each.key]}'",
88+
"export SIGNER_RELAY_REGISTRATION_REPEATER_DELAY='${var.mithril_p2p_signer_registration_repeat_delay}'",
8889
"export ENABLE_METRICS_SERVER=true",
8990
"export METRICS_SERVER_IP=0.0.0.0",
9091
"export METRICS_SERVER_PORT=9090",

mithril-infra/variables.tf

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,12 @@ variable "mithril_use_p2p_network" {
178178
default = false
179179
}
180180

181+
variable "mithril_p2p_signer_registration_repeat_delay" {
182+
type = number
183+
description = "The repeat delay in milliseconds for the signer registration when operating in P2P mode (defaults to 1 hour)"
184+
default = 3600 * 1000
185+
}
186+
181187
locals {
182188
mithril_network_type_suffix = var.mithril_use_p2p_network ? "-p2p" : ""
183189
}

mithril-relay/Cargo.toml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "mithril-relay"
3-
version = "0.1.15"
3+
version = "0.1.16"
44
description = "A Mithril relay"
55
authors = { workspace = true }
66
edition = { workspace = true }
@@ -24,7 +24,11 @@ libp2p = { version = "0.53.2", features = [
2424
"noise",
2525
"ping",
2626
"pnet",
27+
"quic",
2728
"tcp",
29+
"tls",
30+
"websocket-websys",
31+
"websocket",
2832
"yamux",
2933
] }
3034
mithril-common = { path = "../mithril-common", features = ["full"] }
@@ -42,5 +46,5 @@ slog-bunyan = "2.5.0"
4246
slog-scope = "4.4.0"
4347
slog-term = "2.9.0"
4448
thiserror = "1.0.56"
45-
tokio = { version = "1.35.1", features = ["full"] }
49+
tokio = { version = "1.37.0", features = ["full"] }
4650
warp = "0.3.6"

mithril-relay/src/commands/passive.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ impl PassiveCommand {
2323
let dial_to = self.dial_to.to_owned();
2424
let addr: Multiaddr = format!("/ip4/0.0.0.0/tcp/{}", self.listen_port).parse()?;
2525

26-
let mut relay = PassiveRelay::new(&addr).start().await?;
26+
let mut relay = PassiveRelay::start(&addr).await?;
2727
if let Some(dial_to_address) = dial_to {
2828
relay.dial_peer(dial_to_address.clone())?;
2929
}

mithril-relay/src/commands/signer.rs

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
use std::time::Duration;
2+
13
use clap::Parser;
24
use config::{builder::DefaultState, ConfigBuilder};
35
use libp2p::Multiaddr;
@@ -23,6 +25,10 @@ pub struct SignerCommand {
2325
/// Aggregator endpoint URL.
2426
#[clap(long, env = "AGGREGATOR_ENDPOINT")]
2527
aggregator_endpoint: String,
28+
29+
/// Interval at which a signer registration should be repeated in milliseconds (defaults to 1 hour)
30+
#[clap(long, env = "SIGNER_REPEATER_DELAY", default_value_t = 3_600 * 1_000)]
31+
signer_repeater_delay: u64,
2632
}
2733

2834
impl SignerCommand {
@@ -32,8 +38,15 @@ impl SignerCommand {
3238
let dial_to = self.dial_to.to_owned();
3339
let addr: Multiaddr = format!("/ip4/0.0.0.0/tcp/{}", self.listen_port).parse()?;
3440
let aggregator_endpoint = self.aggregator_endpoint.to_owned();
35-
36-
let mut relay = SignerRelay::start(&addr, &server_port, &aggregator_endpoint).await?;
41+
let signer_repeater_delay = Duration::from_millis(self.signer_repeater_delay);
42+
43+
let mut relay = SignerRelay::start(
44+
&addr,
45+
&server_port,
46+
&aggregator_endpoint,
47+
&signer_repeater_delay,
48+
)
49+
.await?;
3750
if let Some(dial_to_address) = dial_to {
3851
relay.dial_peer(dial_to_address.clone())?;
3952
}

mithril-relay/src/lib.rs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,19 @@ mod commands;
55
/// Peer to peer module
66
pub mod p2p;
77
mod relay;
8+
mod repeater;
89

910
pub use commands::Args;
1011
pub use commands::RelayCommands;
1112
pub use relay::AggregatorRelay;
1213
pub use relay::PassiveRelay;
1314
pub use relay::SignerRelay;
1415

15-
/// The topic name where signatures are published
16-
pub const MITHRIL_SIGNATURES_TOPIC_NAME: &str = "mithril/signatures";
16+
/// The P2P topic names used by Mithril
17+
pub mod mithril_p2p_topic {
18+
/// The topic name where signer registrations are published
19+
pub const SIGNERS: &str = "mithril/signers";
20+
21+
/// The topic name where signatures are published
22+
pub const SIGNATURES: &str = "mithril/signatures";
23+
}

0 commit comments

Comments
 (0)