Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: add bootnodes,external-ip cli to bridge to support hive test #1009

Merged
merged 2 commits into from
Oct 31, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions portal-bridge/src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,20 @@ pub struct BridgeConfig {
#[arg(long, help = "Url for metrics reporting")]
pub metrics_url: Option<Url>,

#[arg(
default_value = "default",
long = "bootnodes",
help = "One or more comma-delimited base64-encoded ENR's or multiaddr strings of peers to initially add to the local routing table"
)]
pub bootnodes: String,

#[arg(
default_value = "none",
long = "external-ip",
help = "(Only use this if you are behind a NAT) The address which will be advertised to peers (in an ENR). Changing it does not change which address trin binds to, ex: 127.0.0.1"
)]
pub external_ip: String,

#[command(subcommand)]
pub client_type: ClientType,
}
Expand Down
16 changes: 15 additions & 1 deletion portal-bridge/src/client_handles.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,14 @@ pub fn fluffy_handle(
.arg(format!("--metrics-address:{address}"))
.arg(format!("--metrics-port:{port}"));
}
if bridge_config.bootnodes != "default" {
for enr in bridge_config.bootnodes.split(',') {
command.args(["--bootstrap-node", enr]);
}
}
if !bridge_config.external_ip.is_empty() {
command.arg(format!("--nat:extip:{}", bridge_config.external_ip));
}
Ok(command.spawn()?)
}

Expand Down Expand Up @@ -67,7 +75,13 @@ pub fn trin_handle(
&format!("http://127.0.0.1:{rpc_port}"),
])
.args(["--discovery-port", &format!("{udp_port}")])
.args(["--bootnodes", "default"]);
.args(["--bootnodes", &bridge_config.bootnodes]);
if !bridge_config.external_ip.is_empty() {
command.args([
"--external-address",
&format!("{}:{}", bridge_config.external_ip, udp_port),
]);
}
if let Some(metrics_url) = bridge_config.metrics_url {
let url: String = metrics_url.into();
command.args(["--enable-metrics-with-url", &url]);
Expand Down