diff --git a/Cargo.toml b/Cargo.toml index 90b06f55d82a8ba84088a54267d0bf5d2a8bae08..d0ea3840169544a0d2aa5582fb1db3896a1a3b99 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -36,3 +36,4 @@ sp-core = "22.0.0" libp2p = { version = "0.52" } subxt = "0.32.0" subxt-signer = { version = "0.32.0", features = ["subxt"]} +tracing = "0.1.35" diff --git a/crates/orchestrator/Cargo.toml b/crates/orchestrator/Cargo.toml index 0b51dfe962509827a3caa6fc0b3e49834b6de7cd..12c10cbb8b59ad7abaf1b4974fbab6490c4c2874 100644 --- a/crates/orchestrator/Cargo.toml +++ b/crates/orchestrator/Cargo.toml @@ -26,3 +26,4 @@ libp2p = { workspace = true } subxt = { workspace = true } subxt-signer = { workspace = true } reqwest = { workspace = true } +tracing = { workspace = true } diff --git a/crates/orchestrator/src/generators/chain_spec.rs b/crates/orchestrator/src/generators/chain_spec.rs index 11a50c8d4ced453842926bf23022d6246c133362..5cfd5e6751bc28f527ac23a36c2e3d1513e18149 100644 --- a/crates/orchestrator/src/generators/chain_spec.rs +++ b/crates/orchestrator/src/generators/chain_spec.rs @@ -11,6 +11,7 @@ use provider::{ }; use serde_json::json; use support::fs::FileSystem; +use tracing::warn; use super::errors::GeneratorError; use crate::{ @@ -399,32 +400,12 @@ impl ChainSpec { } } - // TODO: move to logger - // println!( - // "{:#?}", - // chain_spec_json.pointer(format!("{}/session/keys", pointer).as_str()) - // ); // Clear authorities clear_authorities(&pointer, &mut chain_spec_json); - // TODO: move to logger - // println!( - // "{:#?}", - // chain_spec_json.pointer(format!("{}/session/keys", pointer).as_str()) - // ); - - // TODO: add to logger - // println!("BALANCES"); - // println!("{:#?}", chain_spec_json.pointer(format!("{}/balances",pointer).as_str())); // add balances add_balances(&pointer, &mut chain_spec_json, &relaychain.nodes, 0); - // TODO: move to logger - // println!( - // "{:#?}", - // chain_spec_json.pointer(format!("{}/balances", pointer).as_str()) - // ); - // Get validators to add as authorities let validators: Vec<&NodeSpec> = relaychain .nodes @@ -447,10 +428,6 @@ impl ChainSpec { // staking && nominators - // TODO: add to logger - // println!("KEYS"); - // println!("{:#?}", chain_spec_json.pointer(format!("{}/session/keys",pointer).as_str())); - // add_hrmp_channels // paras @@ -674,7 +651,7 @@ fn add_balances( if let Some(val) = chain_spec_json.pointer_mut(runtime_config_ptr) { let Some(balances) = val.pointer("/balances/balances") else { // should be a info log - println!("NO 'balances' key in runtime config, skipping..."); + warn!("NO 'balances' key in runtime config, skipping..."); return; }; diff --git a/crates/orchestrator/src/lib.rs b/crates/orchestrator/src/lib.rs index a705b7260489a0562ce9f29cb894003b001b7b82..2a8cf4c5fc4f2d4f01c37c7aebfe05f51076637f 100644 --- a/crates/orchestrator/src/lib.rs +++ b/crates/orchestrator/src/lib.rs @@ -21,12 +21,12 @@ use network_spec::{parachain::ParachainSpec, NetworkSpec}; use provider::{constants::LOCALHOST, types::TransferedFile, Provider}; use support::fs::{FileSystem, FileSystemError}; use tokio::time::timeout; +use tracing::{debug, info}; use crate::{ generators::chain_spec::ParaGenesisConfig, shared::types::RegisterParachainOptions, spawner::SpawnNodeCtx, }; - pub struct Orchestrator<T, P> where T: FileSystem + Sync + Send, @@ -68,15 +68,13 @@ where mut network_spec: NetworkSpec, ) -> Result<Network<T>, OrchestratorError> { // main driver for spawn the network - // TODO: move to logger - // println!("{:#?}", network_spec); + debug!("Network spec to spawn, {:#?}", network_spec); // create namespace let ns = self.provider.create_namespace().await?; - println!("\n\n"); - println!("🧰 ns: {:#?}", ns.name()); - println!("🧰 base_dir: {:#?}", ns.base_dir()); + info!("🧰 ns: {}", ns.name()); + info!("🧰 base_dir: {:?}", ns.base_dir()); // TODO: noop for native // Static setup @@ -91,9 +89,6 @@ where .build(&ns, &scoped_fs) .await?; - // TODO: move to logger - // println!("{:#?}", network_spec.relaychain.chain_spec); - // Create parachain artifacts (chain-spec, wasm, state) let relay_chain_id = network_spec .relaychain @@ -106,8 +101,7 @@ where let para_cloned = para.clone(); let chain_spec_raw_path = if let Some(chain_spec) = para.chain_spec.as_mut() { chain_spec.build(&ns, &scoped_fs).await?; - // TODO: move to logger - // println!("{:#?}", chain_spec); + debug!("chain_spec: {:#?}", chain_spec); chain_spec .customize_para(¶_cloned, &relay_chain_id, &scoped_fs) diff --git a/crates/orchestrator/src/network/parachain.rs b/crates/orchestrator/src/network/parachain.rs index bd2b35a7db4054025e8c51c3ae9f06dfc77e59a0..0a3c54d786d6c7f33da502e650507f4fde4fe435 100644 --- a/crates/orchestrator/src/network/parachain.rs +++ b/crates/orchestrator/src/network/parachain.rs @@ -6,6 +6,7 @@ use std::{ use subxt::{dynamic::Value, OnlineClient, SubstrateConfig}; use subxt_signer::{sr25519::Keypair, SecretUri}; use support::fs::FileSystem; +use tracing::info; // use crate::generators::key::generate_pair; // use sp_core::{sr25519, Pair}; @@ -50,7 +51,7 @@ impl Parachain { options: RegisterParachainOptions, scoped_fs: &ScopedFilesystem<'_, impl FileSystem>, ) -> Result<(), anyhow::Error> { - println!("Registering parachain: {:?}", options); + info!("Registering parachain: {:?}", options); // get the seed let sudo: Keypair; if let Some(possible_seed) = options.seed { @@ -100,7 +101,7 @@ impl Parachain { .await?; let result = result.wait_for_in_block().await?; - println!("In block: {:#?}", result.block_hash()); + info!("In block: {:#?}", result.block_hash()); Ok(()) } } diff --git a/crates/orchestrator/src/network_helper/verifier.rs b/crates/orchestrator/src/network_helper/verifier.rs index 12d41cb418c07ffa65dd185d6fbea41dd392f9ef..9da71e512ff7fa008215ce71c473359a4cdea291 100644 --- a/crates/orchestrator/src/network_helper/verifier.rs +++ b/crates/orchestrator/src/network_helper/verifier.rs @@ -1,6 +1,7 @@ use std::time::Duration; use tokio::time::timeout; +use tracing::trace; use crate::network::node::NetworkNode; @@ -18,8 +19,7 @@ async fn check_nodes(nodes: &[&NetworkNode]) { let tasks: Vec<_> = nodes .iter() .map(|node| { - // TODO: move to logger - // println!("getting from {}", node.name); + trace!("🔎 checking node: {} ", node.name); reqwest::get(node.prometheus_uri.clone()) }) .collect(); diff --git a/crates/orchestrator/src/spawner.rs b/crates/orchestrator/src/spawner.rs index 18db51f2d41353f96f2b44f04f6e421c83cde5a6..b722aedd2153d920ae8e02922c26212ead17336d 100644 --- a/crates/orchestrator/src/spawner.rs +++ b/crates/orchestrator/src/spawner.rs @@ -6,6 +6,7 @@ use provider::{ DynNamespace, }; use support::fs::FileSystem; +use tracing::info; use crate::{ generators, @@ -124,9 +125,12 @@ where * ZombieRole::Companion => todo!(), */ }; - println!("\n"); - println!("🚀 {}, spawning.... with command:", node.name); - println!("{program} {}", args.join(" ")); + info!( + "🚀 {}, spawning.... with command: {} {}", + node.name, + program, + args.join(" ") + ); let spawn_ops = SpawnNodeOptions { name: node.name.clone(), @@ -150,14 +154,13 @@ where let ws_uri = format!("ws://{}:{}", LOCALHOST, node.rpc_port.0); let prometheus_uri = format!("http://{}:{}/metrics", LOCALHOST, node.prometheus_port.0); - println!("🚀 {}, should be running now", node.name); - println!( - "🚀 {} : direct link https://polkadot.js.org/apps/?rpc={ws_uri}#/explorer", + info!("🚀 {}, should be running now", node.name); + info!( + "🚀 {}: direct link https://polkadot.js.org/apps/?rpc={ws_uri}#/explorer", node.name ); - println!("🚀 {} : metrics link {prometheus_uri}", node.name); - println!("📓 logs cmd: tail -f {}/{}.log", base_dir, node.name); - println!("\n"); + info!("🚀 {}: metrics link {prometheus_uri}", node.name); + info!("📓 logs cmd: tail -f {}/{}.log", base_dir, node.name); Ok(NetworkNode::new( node.name.clone(), ws_uri, diff --git a/crates/orchestrator/src/tx_helper/balance.rs b/crates/orchestrator/src/tx_helper/balance.rs new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/crates/orchestrator/src/tx_helper/register_para.rs b/crates/orchestrator/src/tx_helper/register_para.rs index 55aaf6da56b209fe62e8fa8db069f87d0536b50c..d9e19abdd7340d3cdd5b596bca2fcf8e37f4caaa 100644 --- a/crates/orchestrator/src/tx_helper/register_para.rs +++ b/crates/orchestrator/src/tx_helper/register_para.rs @@ -5,13 +5,14 @@ use subxt_signer::{sr25519::Keypair, SecretUri}; use support::fs::FileSystem; use crate::{shared::types::RegisterParachainOptions, ScopedFilesystem}; +use tracing::{debug, info, trace}; pub async fn register( options: RegisterParachainOptions, scoped_fs: &ScopedFilesystem<'_, impl FileSystem>, ) -> Result<(), anyhow::Error> { - println!("Registering parachain: {:?}", options); + debug!("Registering parachain: {:?}", options); // get the seed let sudo: Keypair; if let Some(possible_seed) = options.seed { @@ -61,6 +62,6 @@ pub async fn register( .await?; let result = result.wait_for_in_block().await?; - println!("In block: {:#?}", result.block_hash()); + debug!("In block: {:#?}", result.block_hash()); Ok(()) } \ No newline at end of file diff --git a/crates/orchestrator/src/tx_helper/validator_actions.rs b/crates/orchestrator/src/tx_helper/validator_actions.rs index ca01d8aede8b11ab93bfcca4005b3cae0e84fc46..cbcc8aa67cdd38aaf640ce1502a8b59d32c7312c 100644 --- a/crates/orchestrator/src/tx_helper/validator_actions.rs +++ b/crates/orchestrator/src/tx_helper/validator_actions.rs @@ -2,13 +2,14 @@ use std::str::FromStr; use subxt::{dynamic::Value, OnlineClient, SubstrateConfig}; use subxt_signer::{sr25519::Keypair, SecretUri}; +use tracing::{debug, info, trace}; pub async fn register( validator_ids: Vec<String>, node_ws_url: &str, ) -> Result<(), anyhow::Error> { - println!("Registering validators: {:?}", validator_ids); + debug!("Registering validators: {:?}", validator_ids); // get the seed // let sudo: Keypair; // if let Some(possible_seed) = options.seed { @@ -18,12 +19,7 @@ pub async fn register( let sudo = Keypair::from_uri(&uri)?; // } - println!("pse"); let api = OnlineClient::<SubstrateConfig>::from_url(node_ws_url).await?; - println!("pse connected"); - - // let bytes: Vec<Value> = validator_ids.iter().map(|id| Value::from_bytes(id)).collect(); - // println!("{:?}", bytes); let register_call = subxt::dynamic::tx( "ValidatorManager", @@ -33,7 +29,6 @@ pub async fn register( let sudo_call = subxt::dynamic::tx("Sudo", "sudo", vec![register_call.into_value()]); - println!("pse1"); // TODO: uncomment below and fix the sign and submit (and follow afterwards until // finalized block) to register the parachain let result = api @@ -41,8 +36,8 @@ pub async fn register( .sign_and_submit_then_watch_default(&sudo_call, &sudo) .await?; - println!("result: {:#?}", result); + debug!("result: {:#?}", result); let result = result.wait_for_in_block().await?; - println!("In block: {:#?}", result.block_hash()); + debug!("In block: {:#?}", result.block_hash()); Ok(()) } \ No newline at end of file diff --git a/crates/provider/Cargo.toml b/crates/provider/Cargo.toml index 374a1eb76de7eb515c74168609b8a7a2c4fd5dc4..367355d3b217541179d8fb0bf30e32bc980922b8 100644 --- a/crates/provider/Cargo.toml +++ b/crates/provider/Cargo.toml @@ -24,4 +24,5 @@ tokio = { workspace = true, features = [ thiserror = { workspace = true } anyhow = { workspace = true } uuid = { workspace = true, features = ["v4"] } -nix = { workspace = true, features = ["signal"] } \ No newline at end of file +nix = { workspace = true, features = ["signal"] } +tracing = { workspace = true } diff --git a/crates/provider/src/native/namespace.rs b/crates/provider/src/native/namespace.rs index 33d3befe9f1784bf50152eb6646ab6670ad482c4..ef5e6fbe51e0b764767ef77be5dd01c60f64dea8 100644 --- a/crates/provider/src/native/namespace.rs +++ b/crates/provider/src/native/namespace.rs @@ -9,6 +9,7 @@ use async_trait::async_trait; use futures::{future::try_join_all, try_join}; use support::{fs::FileSystem, process::ProcessManager}; use tokio::sync::RwLock; +use tracing::trace; use uuid::Uuid; use super::{ @@ -189,10 +190,13 @@ where local_output_path, } in options.commands { - // TODO: move to logger - // println!("{:#?}, {:#?}", command, args); - // println!("{:#?}", self.base_dir.to_string_lossy()); - // println!("{:#?}", local_output_path.as_os_str()); + trace!( + "🗠building file {:?} in path {} with command {} {}", + local_output_path.as_os_str(), + self.base_dir.to_string_lossy(), + program, + args.join(" ") + ); let local_output_full_path = format!( "{}{}{}", self.base_dir.to_string_lossy(),