Skip to content

Commit

Permalink
fix orchestrator validator args
Browse files Browse the repository at this point in the history
  • Loading branch information
elliedavidson committed Dec 8, 2023
1 parent 75e8a9a commit ff67e13
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 32 deletions.
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
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
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
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 ff67e13

Please sign in to comment.