feat: add pezkuwi-zombienet-cli crate
- New CLI binary for network orchestration - Spawn command with native/docker/k8s providers - Backward compatibility: parachains -> teyrchains alias - Backward compatibility: onboard_as_parachain alias Successfully tested with 21-validator mainnet simulation: - 21/21 GRANDPA votes - Block production and finality working - Asset Hub and People Chain teyrchains running
This commit is contained in:
Generated
+18
-9
@@ -2637,11 +2637,10 @@ checksum = "a2698f953def977c68f935bb0dfa959375ad4638570e969e2f1e9f433cbf1af6"
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "cc"
|
name = "cc"
|
||||||
version = "1.2.51"
|
version = "1.2.10"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "7a0aeaff4ff1a90589618835a598e545176939b97874f7abc7851caa0618f203"
|
checksum = "13208fcbb66eaeffe09b99fffbe1af420f00a7b35aa99ad683dfc1aa76145229"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"find-msvc-tools",
|
|
||||||
"jobserver",
|
"jobserver",
|
||||||
"libc",
|
"libc",
|
||||||
"shlex",
|
"shlex",
|
||||||
@@ -5091,12 +5090,6 @@ dependencies = [
|
|||||||
"scale-info",
|
"scale-info",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "find-msvc-tools"
|
|
||||||
version = "0.1.6"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "645cbb3a84e60b7531617d5ae4e57f7e27308f6445f5abf653209ea76dec8dff"
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "findshlibs"
|
name = "findshlibs"
|
||||||
version = "0.10.2"
|
version = "0.10.2"
|
||||||
@@ -14827,6 +14820,22 @@ dependencies = [
|
|||||||
"zagros-runtime",
|
"zagros-runtime",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "pezkuwi-zombienet-cli"
|
||||||
|
version = "0.44.0"
|
||||||
|
dependencies = [
|
||||||
|
"anyhow",
|
||||||
|
"clap",
|
||||||
|
"pezkuwi-zombienet-configuration",
|
||||||
|
"pezkuwi-zombienet-orchestrator",
|
||||||
|
"pezkuwi-zombienet-provider",
|
||||||
|
"pezkuwi-zombienet-sdk",
|
||||||
|
"pezkuwi-zombienet-support",
|
||||||
|
"tokio",
|
||||||
|
"tracing",
|
||||||
|
"tracing-subscriber 0.3.22",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "pezkuwi-zombienet-configuration"
|
name = "pezkuwi-zombienet-configuration"
|
||||||
version = "0.44.0"
|
version = "0.44.0"
|
||||||
|
|||||||
@@ -617,6 +617,7 @@ members = [
|
|||||||
"vendor/pezkuwi-subxt/utils/fetch-metadata",
|
"vendor/pezkuwi-subxt/utils/fetch-metadata",
|
||||||
"vendor/pezkuwi-subxt/utils/strip-metadata",
|
"vendor/pezkuwi-subxt/utils/strip-metadata",
|
||||||
# Vendored pezkuwi-zombienet-sdk crates
|
# Vendored pezkuwi-zombienet-sdk crates
|
||||||
|
"vendor/pezkuwi-zombienet-sdk/crates/cli",
|
||||||
"vendor/pezkuwi-zombienet-sdk/crates/configuration",
|
"vendor/pezkuwi-zombienet-sdk/crates/configuration",
|
||||||
"vendor/pezkuwi-zombienet-sdk/crates/orchestrator",
|
"vendor/pezkuwi-zombienet-sdk/crates/orchestrator",
|
||||||
"vendor/pezkuwi-zombienet-sdk/crates/prom-metrics-parser",
|
"vendor/pezkuwi-zombienet-sdk/crates/prom-metrics-parser",
|
||||||
@@ -1607,6 +1608,7 @@ zagros-runtime-constants = { path = "pezkuwi/runtime/zagros/constants", default-
|
|||||||
zagros-system-emulated-network = { version = "0.0.0", path = "pezcumulus/teyrchains/integration-tests/emulated/networks/zagros-system" }
|
zagros-system-emulated-network = { version = "0.0.0", path = "pezcumulus/teyrchains/integration-tests/emulated/networks/zagros-system" }
|
||||||
zeroize = { version = "1.7.0", default-features = false }
|
zeroize = { version = "1.7.0", default-features = false }
|
||||||
# Pezkuwi-zombienet-sdk (vendored)
|
# Pezkuwi-zombienet-sdk (vendored)
|
||||||
|
pezkuwi-zombienet-cli = { path = "vendor/pezkuwi-zombienet-sdk/crates/cli", version = "0.44.0" }
|
||||||
pezkuwi-zombienet-configuration = { path = "vendor/pezkuwi-zombienet-sdk/crates/configuration", version = "0.44.0" }
|
pezkuwi-zombienet-configuration = { path = "vendor/pezkuwi-zombienet-sdk/crates/configuration", version = "0.44.0" }
|
||||||
pezkuwi-zombienet-orchestrator = { path = "vendor/pezkuwi-zombienet-sdk/crates/orchestrator", version = "0.44.0" }
|
pezkuwi-zombienet-orchestrator = { path = "vendor/pezkuwi-zombienet-sdk/crates/orchestrator", version = "0.44.0" }
|
||||||
pezkuwi-zombienet-prom-metrics-parser = { path = "vendor/pezkuwi-zombienet-sdk/crates/prom-metrics-parser", version = "0.44.0" }
|
pezkuwi-zombienet-prom-metrics-parser = { path = "vendor/pezkuwi-zombienet-sdk/crates/prom-metrics-parser", version = "0.44.0" }
|
||||||
|
|||||||
@@ -0,0 +1,32 @@
|
|||||||
|
[package]
|
||||||
|
name = "pezkuwi-zombienet-cli"
|
||||||
|
version.workspace = true
|
||||||
|
authors.workspace = true
|
||||||
|
edition.workspace = true
|
||||||
|
rust-version.workspace = true
|
||||||
|
publish = true
|
||||||
|
license.workspace = true
|
||||||
|
repository.workspace = true
|
||||||
|
description = "Pezkuwi Zombienet CLI - Network orchestration tool for Pezkuwi blockchain testing"
|
||||||
|
keywords = ["blockchain", "pezkuwi", "cli", "zombienet"]
|
||||||
|
|
||||||
|
[[bin]]
|
||||||
|
name = "pezkuwi-zombienet"
|
||||||
|
path = "src/main.rs"
|
||||||
|
|
||||||
|
[dependencies]
|
||||||
|
anyhow = { workspace = true }
|
||||||
|
clap = { workspace = true, features = ["derive"] }
|
||||||
|
tokio = { workspace = true, features = ["full"] }
|
||||||
|
tracing = { workspace = true }
|
||||||
|
tracing-subscriber = { workspace = true, features = ["env-filter"] }
|
||||||
|
|
||||||
|
# Zombienet SDK deps
|
||||||
|
pezkuwi-zombienet-sdk = { workspace = true }
|
||||||
|
configuration = { workspace = true }
|
||||||
|
orchestrator = { workspace = true }
|
||||||
|
provider = { workspace = true }
|
||||||
|
support = { workspace = true }
|
||||||
|
|
||||||
|
[features]
|
||||||
|
default = []
|
||||||
+139
@@ -0,0 +1,139 @@
|
|||||||
|
//! Pezkuwi Zombienet CLI - Network orchestration tool for Pezkuwi blockchain testing
|
||||||
|
//!
|
||||||
|
//! This CLI provides commands to spawn, manage, and test Pezkuwi blockchain networks
|
||||||
|
//! using the pezkuwi-zombienet-sdk.
|
||||||
|
|
||||||
|
use anyhow::{Context, Result};
|
||||||
|
use clap::{Parser, Subcommand, ValueEnum};
|
||||||
|
use pezkuwi_zombienet_sdk::{NetworkConfig, NetworkConfigExt};
|
||||||
|
use std::path::PathBuf;
|
||||||
|
use tracing::{info, Level};
|
||||||
|
use tracing_subscriber::FmtSubscriber;
|
||||||
|
|
||||||
|
/// Pezkuwi Zombienet CLI - Network orchestration for Pezkuwi blockchain testing
|
||||||
|
#[derive(Parser, Debug)]
|
||||||
|
#[command(name = "pezkuwi-zombienet")]
|
||||||
|
#[command(author = "Kurdistan Tech Institute")]
|
||||||
|
#[command(version)]
|
||||||
|
#[command(about = "Network orchestration tool for Pezkuwi blockchain testing", long_about = None)]
|
||||||
|
struct Cli {
|
||||||
|
/// Enable verbose output
|
||||||
|
#[arg(short, long, global = true)]
|
||||||
|
verbose: bool,
|
||||||
|
|
||||||
|
#[command(subcommand)]
|
||||||
|
command: Commands,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Subcommand, Debug)]
|
||||||
|
enum Commands {
|
||||||
|
/// Spawn a new network from a configuration file
|
||||||
|
Spawn {
|
||||||
|
/// Path to the TOML configuration file
|
||||||
|
#[arg(value_name = "CONFIG_FILE")]
|
||||||
|
config: PathBuf,
|
||||||
|
|
||||||
|
/// Provider to use for spawning the network
|
||||||
|
#[arg(short, long, value_enum, default_value = "native")]
|
||||||
|
provider: Provider,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(ValueEnum, Clone, Debug)]
|
||||||
|
enum Provider {
|
||||||
|
/// Run nodes directly as native processes
|
||||||
|
Native,
|
||||||
|
/// Run nodes in Docker containers
|
||||||
|
Docker,
|
||||||
|
/// Run nodes in Kubernetes
|
||||||
|
K8s,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[tokio::main]
|
||||||
|
async fn main() -> Result<()> {
|
||||||
|
let cli = Cli::parse();
|
||||||
|
|
||||||
|
// Set up tracing/logging
|
||||||
|
let level = if cli.verbose { Level::DEBUG } else { Level::INFO };
|
||||||
|
let subscriber = FmtSubscriber::builder()
|
||||||
|
.with_max_level(level)
|
||||||
|
.with_target(false)
|
||||||
|
.with_thread_ids(false)
|
||||||
|
.with_file(false)
|
||||||
|
.with_line_number(false)
|
||||||
|
.finish();
|
||||||
|
tracing::subscriber::set_global_default(subscriber)
|
||||||
|
.context("Failed to set tracing subscriber")?;
|
||||||
|
|
||||||
|
match cli.command {
|
||||||
|
Commands::Spawn { config, provider } => {
|
||||||
|
spawn_network(config, provider).await?;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
|
async fn spawn_network(config_path: PathBuf, provider: Provider) -> Result<()> {
|
||||||
|
let config_str = config_path
|
||||||
|
.to_str()
|
||||||
|
.context("Invalid config path")?;
|
||||||
|
|
||||||
|
info!("Loading network configuration from: {}", config_str);
|
||||||
|
|
||||||
|
let network_config = NetworkConfig::load_from_toml(config_str)
|
||||||
|
.context("Failed to load network configuration")?;
|
||||||
|
|
||||||
|
info!("Network configuration loaded successfully");
|
||||||
|
info!("Relay chain: {}", network_config.relaychain().chain().as_str());
|
||||||
|
info!("Teyrchains: {}", network_config.teyrchains().len());
|
||||||
|
|
||||||
|
info!("Spawning network with provider: {:?}", provider);
|
||||||
|
|
||||||
|
let network = match provider {
|
||||||
|
Provider::Native => {
|
||||||
|
info!("Using native provider (direct process spawning)");
|
||||||
|
network_config.spawn_native().await
|
||||||
|
}
|
||||||
|
Provider::Docker => {
|
||||||
|
info!("Using Docker provider");
|
||||||
|
network_config.spawn_docker().await
|
||||||
|
}
|
||||||
|
Provider::K8s => {
|
||||||
|
info!("Using Kubernetes provider");
|
||||||
|
network_config.spawn_k8s().await
|
||||||
|
}
|
||||||
|
}
|
||||||
|
.context("Failed to spawn network")?;
|
||||||
|
|
||||||
|
info!("Network spawned successfully!");
|
||||||
|
|
||||||
|
// Print node information
|
||||||
|
for node in network.relaychain().nodes() {
|
||||||
|
info!(
|
||||||
|
"Relay node '{}' running at {}",
|
||||||
|
node.name(),
|
||||||
|
node.ws_uri()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
for para in network.parachains() {
|
||||||
|
info!("Teyrchain ID {}", para.para_id());
|
||||||
|
for collator in para.collators() {
|
||||||
|
info!(
|
||||||
|
" Collator '{}' running at {}",
|
||||||
|
collator.name(),
|
||||||
|
collator.ws_uri()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
info!("Press Ctrl+C to stop the network...");
|
||||||
|
|
||||||
|
// Keep the network running until interrupted
|
||||||
|
tokio::signal::ctrl_c().await?;
|
||||||
|
|
||||||
|
info!("Shutting down network...");
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
@@ -33,7 +33,7 @@ pub struct NetworkConfig {
|
|||||||
#[serde(rename = "settings", default = "GlobalSettings::default")]
|
#[serde(rename = "settings", default = "GlobalSettings::default")]
|
||||||
global_settings: GlobalSettings,
|
global_settings: GlobalSettings,
|
||||||
relaychain: Option<RelaychainConfig>,
|
relaychain: Option<RelaychainConfig>,
|
||||||
#[serde(skip_serializing_if = "std::vec::Vec::is_empty", default)]
|
#[serde(skip_serializing_if = "std::vec::Vec::is_empty", default, alias = "parachains")]
|
||||||
teyrchains: Vec<TeyrchainConfig>,
|
teyrchains: Vec<TeyrchainConfig>,
|
||||||
#[serde(skip_serializing_if = "std::vec::Vec::is_empty", default)]
|
#[serde(skip_serializing_if = "std::vec::Vec::is_empty", default)]
|
||||||
hrmp_channels: Vec<HrmpChannelConfig>,
|
hrmp_channels: Vec<HrmpChannelConfig>,
|
||||||
|
|||||||
@@ -114,7 +114,7 @@ pub struct TeyrchainConfig {
|
|||||||
chain: Option<Chain>,
|
chain: Option<Chain>,
|
||||||
#[serde(flatten)]
|
#[serde(flatten)]
|
||||||
registration_strategy: Option<RegistrationStrategy>,
|
registration_strategy: Option<RegistrationStrategy>,
|
||||||
#[serde(skip_serializing_if = "super::utils::is_true", default = "default_as_true")]
|
#[serde(skip_serializing_if = "super::utils::is_true", default = "default_as_true", alias = "onboard_as_parachain")]
|
||||||
onboard_as_teyrchain: bool,
|
onboard_as_teyrchain: bool,
|
||||||
#[serde(rename = "balance", default = "default_initial_balance")]
|
#[serde(rename = "balance", default = "default_initial_balance")]
|
||||||
initial_balance: U128,
|
initial_balance: U128,
|
||||||
|
|||||||
Reference in New Issue
Block a user