style: fix formatting for CI (taplo + cargo fmt)
This commit is contained in:
+77
-87
@@ -17,123 +17,113 @@ use tracing_subscriber::FmtSubscriber;
|
||||
#[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,
|
||||
/// Enable verbose output
|
||||
#[arg(short, long, global = true)]
|
||||
verbose: bool,
|
||||
|
||||
#[command(subcommand)]
|
||||
command: Commands,
|
||||
#[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,
|
||||
/// 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,
|
||||
},
|
||||
/// 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,
|
||||
/// 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();
|
||||
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")?;
|
||||
// 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?;
|
||||
}
|
||||
}
|
||||
match cli.command {
|
||||
Commands::Spawn { config, provider } => {
|
||||
spawn_network(config, provider).await?;
|
||||
},
|
||||
}
|
||||
|
||||
Ok(())
|
||||
Ok(())
|
||||
}
|
||||
|
||||
async fn spawn_network(config_path: PathBuf, provider: Provider) -> Result<()> {
|
||||
let config_str = config_path
|
||||
.to_str()
|
||||
.context("Invalid config path")?;
|
||||
let config_str = config_path.to_str().context("Invalid config path")?;
|
||||
|
||||
info!("Loading network configuration from: {}", config_str);
|
||||
info!("Loading network configuration from: {}", config_str);
|
||||
|
||||
let network_config = NetworkConfig::load_from_toml(config_str)
|
||||
.context("Failed to load network configuration")?;
|
||||
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!("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);
|
||||
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")?;
|
||||
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!");
|
||||
info!("Network spawned successfully!");
|
||||
|
||||
// Print node information
|
||||
for node in network.relaychain().nodes() {
|
||||
info!(
|
||||
"Relay node '{}' running at {}",
|
||||
node.name(),
|
||||
node.ws_uri()
|
||||
);
|
||||
}
|
||||
// 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()
|
||||
);
|
||||
}
|
||||
}
|
||||
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...");
|
||||
info!("Press Ctrl+C to stop the network...");
|
||||
|
||||
// Keep the network running until interrupted
|
||||
tokio::signal::ctrl_c().await?;
|
||||
// Keep the network running until interrupted
|
||||
tokio::signal::ctrl_c().await?;
|
||||
|
||||
info!("Shutting down network...");
|
||||
info!("Shutting down network...");
|
||||
|
||||
Ok(())
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@@ -114,7 +114,11 @@ pub struct TeyrchainConfig {
|
||||
chain: Option<Chain>,
|
||||
#[serde(flatten)]
|
||||
registration_strategy: Option<RegistrationStrategy>,
|
||||
#[serde(skip_serializing_if = "super::utils::is_true", default = "default_as_true", alias = "onboard_as_parachain")]
|
||||
#[serde(
|
||||
skip_serializing_if = "super::utils::is_true",
|
||||
default = "default_as_true",
|
||||
alias = "onboard_as_parachain"
|
||||
)]
|
||||
onboard_as_teyrchain: bool,
|
||||
#[serde(rename = "balance", default = "default_initial_balance")]
|
||||
initial_balance: U128,
|
||||
|
||||
Reference in New Issue
Block a user