diff --git a/crates/examples/examples/simple_network_example.rs b/crates/examples/examples/simple_network_example.rs index 3367e0e1e..fc87ffb1c 100644 --- a/crates/examples/examples/simple_network_example.rs +++ b/crates/examples/examples/simple_network_example.rs @@ -18,7 +18,7 @@ async fn main() -> Result<(), Box> { let network = orchestrator.spawn(config).await?; println!("🚀🚀🚀🚀 network deployed"); - let client = network.get_node("alice")?.client(); + let client = network.get_node("alice")?.client().await?; let mut blocks = client.blocks().subscribe_finalized().await?.take(3); while let Some(block) = blocks.next().await { diff --git a/crates/orchestrator/src/network/node.rs b/crates/orchestrator/src/network/node.rs index 50081b3dc..85c2ed34a 100644 --- a/crates/orchestrator/src/network/node.rs +++ b/crates/orchestrator/src/network/node.rs @@ -16,8 +16,6 @@ pub struct NetworkNode { pub(crate) spec: NodeSpec, pub(crate) name: String, pub(crate) ws_uri: String, - rpc: RpcClient, - client: OnlineClient, pub(crate) prometheus_uri: String, metrics_cache: Arc>, } @@ -27,8 +25,6 @@ impl NetworkNode { pub(crate) fn new>( name: T, ws_uri: T, - rpc: RpcClient, - client: OnlineClient, prometheus_uri: T, spec: NodeSpec, inner: DynNode, @@ -36,8 +32,6 @@ impl NetworkNode { Self { name: name.into(), ws_uri: ws_uri.into(), - rpc, - client, prometheus_uri: prometheus_uri.into(), inner, spec, @@ -52,12 +46,12 @@ impl NetworkNode { Ok(()) } - pub fn rpc(&self) -> RpcClient { - self.rpc.clone() + pub async fn rpc(&self) -> Result { + RpcClient::from_url(&self.ws_uri).await } - pub fn client(&self) -> OnlineClient { - self.client.clone() + pub async fn client(&self) -> Result, subxt::Error> { + OnlineClient::from_url(&self.ws_uri).await } /// Resume the node, this is implemented by resuming the diff --git a/crates/orchestrator/src/spawner.rs b/crates/orchestrator/src/spawner.rs index 5ab9295ca..bd1f62bf6 100644 --- a/crates/orchestrator/src/spawner.rs +++ b/crates/orchestrator/src/spawner.rs @@ -1,13 +1,11 @@ use std::path::PathBuf; -use anyhow::Context; use futures::Future; use provider::{ constants::LOCALHOST, types::{SpawnNodeOptions, TransferedFile}, DynNamespace, }; -use subxt::{backend::rpc::RpcClient, OnlineClient}; use support::fs::FileSystem; use crate::{ @@ -163,19 +161,9 @@ where println!("📓 logs cmd: tail -f {}/{}.log", base_dir, node.name); println!("\n"); - let client = retry(5, || async { OnlineClient::from_url(&ws_uri).await }) - .await - .context(format!("Failed to connect to node rpc at {ws_uri}"))?; - - let rpc = RpcClient::from_url(&ws_uri) - .await - .context(format!("Failed to connect to rpc client at {ws_uri}"))?; - Ok(NetworkNode::new( node.name.clone(), ws_uri, - rpc, - client, prometheus_uri, node.clone(), running_node,