Skip to content

Commit

Permalink
Merge pull request #2185 from EspressoSystems/ed/fix-orch-url
Browse files Browse the repository at this point in the history
fix orchestrator validator args
  • Loading branch information
elliedavidson authored Dec 8, 2023
2 parents 75e8a9a + e4224b6 commit 4810b8e
Show file tree
Hide file tree
Showing 10 changed files with 30 additions and 54 deletions.
8 changes: 5 additions & 3 deletions crates/hotshot/examples/combined/all.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ async fn main() {
let _sender = Arc::new(server_shutdown_sender_cdn);
let _sender = Arc::new(server_shutdown_sender_da);

let orchestrator_url = Url::parse("http://localhost:4444").unwrap();

async_spawn(async move {
if let Err(e) = hotshot_web_server::run_web_server::<
<TestTypes as hotshot_types::traits::node_implementation::NodeType>::SignatureKey,
Expand Down Expand Up @@ -77,7 +79,7 @@ async fn main() {
VIDNetwork,
NodeImpl,
>(OrchestratorArgs {
url: Url::parse("http://localhost:4444").unwrap(),
url: orchestrator_url.clone(),

config_file: args.config_file.clone(),
}));
Expand All @@ -89,6 +91,7 @@ async fn main() {
> = load_config_from_file::<TestTypes>(args.config_file);
let mut nodes = Vec::new();
for _ in 0..config.config.total_nodes.into() {
let orchestrator_url = orchestrator_url.clone();
let node = async_spawn(async move {
infra::main_entry_point::<
TestTypes,
Expand All @@ -99,8 +102,7 @@ async fn main() {
NodeImpl,
ThisRun,
>(ValidatorArgs {
url: "http://localhost".to_string(),
port: 4444,
url: orchestrator_url,
public_ip: Some(IpAddr::V4(Ipv4Addr::LOCALHOST)),
})
.await
Expand Down
13 changes: 4 additions & 9 deletions crates/hotshot/examples/combined/multi-validator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ use clap::Parser;
use hotshot_orchestrator::client::ValidatorArgs;
use hotshot_testing::state_types::TestTypes;
use std::net::IpAddr;
use surf_disco::Url;
use tracing::instrument;
use types::VIDNetwork;

Expand All @@ -21,9 +22,7 @@ struct MultiValidatorArgs {
/// Number of validators to run
pub num_nodes: u16,
/// The address the orchestrator runs on
pub url: String,
/// The port the orchestrator runs on
pub port: u16,
pub url: Url,
/// This node's public IP address, for libp2p
/// If no IP address is passed in, it will default to 127.0.0.1
pub public_ip: Option<IpAddr>,
Expand All @@ -39,11 +38,7 @@ async fn main() {
setup_logging();
setup_backtrace();
let args = MultiValidatorArgs::parse();
tracing::error!(
"connecting to orchestrator at {:?}:{:?}",
args.url,
args.port
);
tracing::error!("connecting to orchestrator at {:?}", args.url);
let mut nodes = Vec::new();
for _ in 0..args.num_nodes {
let url: String = args.url.clone();
Expand All @@ -59,7 +54,7 @@ async fn main() {
ThisRun,
>(ValidatorArgs {
url,
port: args.port,

public_ip: args.public_ip,
})
.await
Expand Down
5 changes: 1 addition & 4 deletions crates/hotshot/examples/combined/validator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,7 @@ async fn main() {
setup_logging();
setup_backtrace();
let args = ValidatorArgs::parse();
info!(
"connecting to orchestrator at {:?}:{:?}",
args.url, args.port
);
info!("connecting to orchestrator at {:?}", args.url);
infra::main_entry_point::<
TestTypes,
DANetwork,
Expand Down
8 changes: 4 additions & 4 deletions crates/hotshot/examples/libp2p/all.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ async fn main() {

// use configfile args
let args = ConfigArgs::parse();
let orchestrator_url = Url::parse("http://localhost:4444").unwrap();

// orchestrator
async_spawn(run_orchestrator::<
Expand All @@ -44,8 +45,7 @@ async fn main() {
VIDNetwork,
NodeImpl,
>(OrchestratorArgs {
url: Url::parse("http://localhost:4444").unwrap(),

url: orchestrator_url.clone(),
config_file: args.config_file.clone(),
}));

Expand All @@ -56,6 +56,7 @@ async fn main() {
> = load_config_from_file::<TestTypes>(args.config_file);
let mut nodes = Vec::new();
for _ in 0..config.config.total_nodes.into() {
let orchestrator_url = orchestrator_url.clone();
let node = async_spawn(async move {
infra::main_entry_point::<
TestTypes,
Expand All @@ -66,8 +67,7 @@ async fn main() {
NodeImpl,
ThisRun,
>(ValidatorArgs {
url: "http://localhost".to_string(),
port: 4444,
url: orchestrator_url,
public_ip: Some(IpAddr::V4(Ipv4Addr::LOCALHOST)),
})
.await
Expand Down
12 changes: 3 additions & 9 deletions crates/hotshot/examples/libp2p/multi-validator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ use clap::Parser;
use hotshot_orchestrator::client::ValidatorArgs;
use hotshot_testing::state_types::TestTypes;
use std::net::IpAddr;
use surf_disco::Url;
use tracing::instrument;
use types::VIDNetwork;

Expand All @@ -21,9 +22,7 @@ struct MultiValidatorArgs {
/// Number of validators to run
pub num_nodes: u16,
/// The address the orchestrator runs on
pub url: String,
/// The port the orchestrator runs on
pub port: u16,
pub url: Url,
/// This node's public IP address, for libp2p
/// If no IP address is passed in, it will default to 127.0.0.1
pub public_ip: Option<IpAddr>,
Expand All @@ -39,11 +38,7 @@ async fn main() {
setup_logging();
setup_backtrace();
let args = MultiValidatorArgs::parse();
tracing::error!(
"connecting to orchestrator at {:?}:{:?}",
args.url,
args.port
);
tracing::error!("connecting to orchestrator at {:?}", args.url);
let mut nodes = Vec::new();
for _ in 0..args.num_nodes {
let url: String = args.url.clone();
Expand All @@ -59,7 +54,6 @@ async fn main() {
ThisRun,
>(ValidatorArgs {
url,
port: args.port,
public_ip: args.public_ip,
})
.await
Expand Down
5 changes: 1 addition & 4 deletions crates/hotshot/examples/libp2p/validator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,7 @@ async fn main() {
setup_logging();
setup_backtrace();
let args = ValidatorArgs::parse();
info!(
"connecting to orchestrator at {:?}:{:?}",
args.url, args.port
);
info!("connecting to orchestrator at {:?}", args.url);
infra::main_entry_point::<
TestTypes,
DANetwork,
Expand Down
8 changes: 5 additions & 3 deletions crates/hotshot/examples/webserver/all.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@ async fn main() {
}
});

let orchestrator_url = Url::parse("http://localhost:4444").unwrap();

// web server orchestrator
async_spawn(run_orchestrator::<
TestTypes,
Expand All @@ -69,7 +71,7 @@ async fn main() {
VIDNetwork,
NodeImpl,
>(OrchestratorArgs {
url: Url::parse("http://localhost:4444").unwrap(),
url: orchestrator_url.clone(),
config_file: args.config_file.clone(),
}));

Expand All @@ -80,6 +82,7 @@ async fn main() {
> = load_config_from_file::<TestTypes>(args.config_file);
let mut nodes = Vec::new();
for _ in 0..(config.config.total_nodes.get()) {
let orchestrator_url = orchestrator_url.clone();
let node = async_spawn(async move {
infra::main_entry_point::<
TestTypes,
Expand All @@ -90,8 +93,7 @@ async fn main() {
NodeImpl,
ThisRun,
>(ValidatorArgs {
url: "http://localhost".to_string(),
port: 4444,
url: orchestrator_url,
public_ip: Some(IpAddr::V4(Ipv4Addr::LOCALHOST)),
})
.await
Expand Down
12 changes: 3 additions & 9 deletions crates/hotshot/examples/webserver/multi-validator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ use clap::Parser;
use hotshot_orchestrator::client::ValidatorArgs;
use hotshot_testing::state_types::TestTypes;
use std::net::IpAddr;
use surf_disco::Url;
use tracing::instrument;
use types::VIDNetwork;

Expand All @@ -21,9 +22,7 @@ struct MultiValidatorArgs {
/// Number of validators to run
pub num_nodes: u16,
/// The address the orchestrator runs on
pub url: String,
/// The port the orchestrator runs on
pub port: u16,
pub url: Url,
/// This node's public IP address, for libp2p
/// If no IP address is passed in, it will default to 127.0.0.1
pub public_ip: Option<IpAddr>,
Expand All @@ -39,11 +38,7 @@ async fn main() {
setup_logging();
setup_backtrace();
let args = MultiValidatorArgs::parse();
tracing::error!(
"connecting to orchestrator at {:?}:{:?}",
args.url,
args.port
);
tracing::error!("connecting to orchestrator at {:?}", args.url);
let mut nodes = Vec::new();
for _ in 0..args.num_nodes {
let url = args.url.clone();
Expand All @@ -58,7 +53,6 @@ async fn main() {
ThisRun,
>(ValidatorArgs {
url,
port: args.port,
public_ip: args.public_ip,
})
.await
Expand Down
5 changes: 1 addition & 4 deletions crates/hotshot/examples/webserver/validator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,7 @@ async fn main() {
setup_logging();
setup_backtrace();
let args = ValidatorArgs::parse();
info!(
"connecting to orchestrator at {:?}:{:?}",
args.url, args.port
);
info!("connecting to orchestrator at {:?}", args.url);
infra::main_entry_point::<
TestTypes,
DANetwork,
Expand Down
8 changes: 3 additions & 5 deletions crates/orchestrator/src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ use futures::{Future, FutureExt};

use hotshot_types::traits::node_implementation::NodeType;
use surf_disco::{error::ClientError, Client};
use tide_disco::Url;

/// Holds the client connection to the orchestrator
pub struct OrchestratorClient {
Expand All @@ -23,9 +24,7 @@ pub struct OrchestratorClient {
/// Arguments passed to the validator
pub struct ValidatorArgs {
/// The address the orchestrator runs on
pub url: String,
/// The port the orchestrator runs on
pub port: u16,
pub url: Url,
/// This node's public IP address, for libp2p
/// If no IP address is passed in, it will default to 127.0.0.1
pub public_ip: Option<IpAddr>,
Expand All @@ -34,8 +33,7 @@ pub struct ValidatorArgs {
impl OrchestratorClient {
/// Creates the client that connects to the orchestrator
pub async fn connect_to_orchestrator(args: ValidatorArgs) -> Self {
let base_url = format!("{0}:{1}", args.url, args.port).parse().unwrap();
let client = surf_disco::Client::<ClientError>::new(base_url);
let client = surf_disco::Client::<ClientError>::new(args.url);
// TODO ED: Add healthcheck wait here
OrchestratorClient { client }
}
Expand Down

0 comments on commit 4810b8e

Please sign in to comment.