Skip to content

Commit 7db62b2

Browse files
authored
Remove asset-hub specific CLI args and logic (#101)
* Remove asset-hub specific CLI args and logic Refactor parachain support to use them only from config * Optional pass rc and paras to cli args
1 parent c9f7587 commit 7db62b2

5 files changed

Lines changed: 44 additions & 79 deletions

File tree

examples/README.md

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,7 @@ Zombie Bite now supports configuration files to simplify the management of syste
1818
zombie-bite bite --config examples/all-system-chains.toml
1919

2020
# Override specific values from CLI (CLI takes precedence)
21-
zombie-bite bite --config examples/kusama-network.toml --relay polkadot
22-
23-
# Mix config file with CLI overrides
24-
zombie-bite bite --config examples/asset-hub-only.toml --parachains asset-hub,coretime,people
21+
zombie-bite bite --config examples/kusama-network.toml --rc polkadot
2522
```
2623

2724
### Basic Structure

src/cli.rs

Lines changed: 30 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
1-
use std::env;
2-
use std::path::PathBuf;
3-
use std::time::{SystemTime, UNIX_EPOCH};
4-
51
use clap::{Parser, Subcommand};
6-
use std::str::FromStr;
2+
use std::{
3+
env,
4+
path::PathBuf,
5+
str::FromStr,
6+
time::{SystemTime, UNIX_EPOCH},
7+
};
78
use tracing::warn;
89

910
use crate::config::{Parachain, Relaychain, ZombieBiteConfig};
@@ -22,26 +23,21 @@ pub enum Commands {
2223
/// Configuration file path to use for the bite operation. CLI args override config file values.
2324
#[arg(long, short = 'c', verbatim_doc_comment)]
2425
config: Option<String>,
25-
/// The network will be using for bite (will try the network + ah)
26-
#[arg(short = 'r', long = "rc", value_parser = clap::builder::PossibleValuesParser::new(["polkadot", "kusama", "paseo"]), default_value="polkadot")]
27-
relay: String,
26+
/// The network will be using for bite
27+
/// If not specified, will use the value from config.
28+
/// If not in config, defaults to polkadot.
29+
#[arg(short = 'r', long = "rc", value_parser = clap::builder::PossibleValuesParser::new(["polkadot", "kusama", "paseo"]))]
30+
relay: Option<String>,
2831
/// If provided we will override the runtime as part of the process of 'bite'
2932
/// The resulting network will be running with this runtime.
3033
#[arg(long = "rc-override", verbatim_doc_comment)]
3134
relay_runtime: Option<String>,
3235
/// If provided we will _bite_ the live network at the supplied block hieght
3336
#[arg(long = "rc-bite-at", verbatim_doc_comment)]
3437
relay_bite_at: Option<u32>,
35-
/// If provided we will override the runtime as part of the process of 'bite'
36-
/// The resulting version of AH will be running with this runtime.
37-
#[arg(long = "ah-override", verbatim_doc_comment)]
38-
ah_runtime: Option<String>,
3938
/// Parachains to include: asset-hub, coretime, people, bridge-hub, collectives (comma-separated)
4039
#[arg(long, short = 'p', value_delimiter = ',', verbatim_doc_comment)]
4140
parachains: Option<Vec<String>>,
42-
/// If provided we will _bite_ the live network at the supplied block hieght
43-
#[arg(long = "ah-bite-at", verbatim_doc_comment)]
44-
ah_bite_at: Option<u32>,
4541
/// Base path to use. if not provided we will check the env 'ZOMBIE_BITE_BASE_PATH' and if not present we will use `<cwd>_timestamp`
4642
#[arg(long, short = 'd', verbatim_doc_comment)]
4743
base_path: Option<String>,
@@ -148,11 +144,9 @@ pub struct ResolvedSpawnConfig {
148144
#[allow(clippy::too_many_arguments)]
149145
pub fn resolve_bite_config(
150146
config_path: Option<String>,
151-
relay: String,
147+
relay: Option<String>,
152148
relay_runtime: Option<String>,
153149
relay_bite_at: Option<u32>,
154-
ah_runtime: Option<String>,
155-
ah_bite_at: Option<u32>,
156150
parachains: Option<Vec<String>>,
157151
base_path: Option<String>,
158152
rc_sync_url: Option<String>,
@@ -165,27 +159,29 @@ pub fn resolve_bite_config(
165159
None
166160
};
167161

168-
// Resolve relaychain (CLI overrides config file)
162+
// Resolve relaychain (CLI always overrides config file)
163+
// Determine relay network: CLI > config > default
164+
let relay_network = if let Some(ref cli_relay) = relay {
165+
cli_relay.clone()
166+
} else if let Some(ref config) = config_file {
167+
config.relaychain.network.clone()
168+
} else {
169+
"polkadot".to_string()
170+
};
171+
169172
let relaychain = if relay_runtime.is_some() || rc_sync_url.is_some() || relay_bite_at.is_some()
170173
{
171174
// CLI args provided, use them
172-
Relaychain::new_with_values(&relay, relay_runtime, rc_sync_url, relay_bite_at)
175+
Relaychain::new_with_values(&relay_network, relay_runtime, rc_sync_url, relay_bite_at)
173176
} else if let Some(ref config) = config_file {
174-
// Use config file settings, but override network if CLI specifies it
175-
let network = if relay != "polkadot" {
176-
&relay
177-
} else {
178-
&config.relaychain.network
179-
};
180177
Relaychain::new_with_values(
181-
network,
178+
&relay_network,
182179
config.relaychain.runtime_override.clone(),
183180
config.relaychain.sync_url.clone(),
184181
config.relaychain.bite_at,
185182
)
186183
} else {
187-
// No config file, use CLI values
188-
Relaychain::new_with_values(&relay, relay_runtime, rc_sync_url, relay_bite_at)
184+
Relaychain::new_with_values(&relay_network, relay_runtime, rc_sync_url, relay_bite_at)
189185
};
190186

191187
// Resolve parachains (CLI overrides config file)
@@ -195,8 +191,8 @@ pub fn resolve_bite_config(
195191
.iter()
196192
.filter_map(|p| match p.as_str() {
197193
"asset-hub" => Some(Parachain::AssetHub {
198-
maybe_override: ah_runtime.clone(),
199-
maybe_bite_at: ah_bite_at,
194+
maybe_override: None,
195+
maybe_bite_at: None,
200196
maybe_rpc_endpoint: None,
201197
}),
202198
"coretime" => Some(Parachain::Coretime {
@@ -230,30 +226,10 @@ pub fn resolve_bite_config(
230226
})
231227
.collect()
232228
} else if let Some(ref config) = config_file {
233-
// Use config file parachains but apply ah_runtime and ah_bite_at override if specified
234-
config
235-
.get_parachains()
236-
.iter()
237-
.map(|p| match p {
238-
Parachain::AssetHub {
239-
maybe_rpc_endpoint, ..
240-
} if ah_runtime.is_some() || ah_bite_at.is_some() => Parachain::AssetHub {
241-
maybe_override: ah_runtime
242-
.clone()
243-
.or_else(|| p.wasm_overrides().map(|s| s.to_string())),
244-
maybe_bite_at: ah_bite_at.or(p.at_block()),
245-
maybe_rpc_endpoint: maybe_rpc_endpoint.clone(),
246-
},
247-
_ => p.clone(),
248-
})
249-
.collect()
229+
// Use config file parachains
230+
config.get_parachains().to_vec()
250231
} else {
251-
// Default to just asset-hub for backward compatibility
252-
vec![Parachain::AssetHub {
253-
maybe_override: ah_runtime,
254-
maybe_bite_at: ah_bite_at,
255-
maybe_rpc_endpoint: None,
256-
}]
232+
vec![]
257233
};
258234

259235
// Resolve base_path (CLI overrides config file)

src/doppelganger.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ pub async fn doppelganger_inner(
111111
sync_para(
112112
ns.clone(),
113113
"doppelganger-parachain",
114-
&para,
114+
para,
115115
&relay_chain,
116116
relay_chain.sync_endpoint(),
117117
para_default_overrides_path,

src/main.rs

Lines changed: 10 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -52,21 +52,17 @@ async fn resolve_if_dir_exist(base_path: &Path, step: Step) {
5252
}
5353

5454
async fn ensure_startup_producing_blocks(network: &Network<LocalFileSystem>) {
55-
// first wait until the collator replies with metrics
55+
// Check metrics for all parachains and their collators
5656
let parachains = network.parachains();
57-
let para = parachains
58-
.first()
59-
.expect("At least one parachain should exist");
60-
let collators = para.collators();
61-
let collator = collators
62-
.first()
63-
.expect("At least one collator should exist");
64-
debug!("Waiting metrics for collator {}", collator.name());
65-
66-
collator
67-
.wait_metric_with_timeout("node_roles", |x| x > 1.0, 300_u64)
68-
.await
69-
.unwrap();
57+
for para in parachains {
58+
for collator in para.collators() {
59+
debug!("Waiting metrics for collator {}", collator.name());
60+
collator
61+
.wait_metric_with_timeout("node_roles", |x| x > 1.0, 300_u64)
62+
.await
63+
.unwrap();
64+
}
65+
}
7066

7167
// ensure block production
7268
let client = network
@@ -157,9 +153,7 @@ async fn main() -> Result<(), anyhow::Error> {
157153
relay,
158154
relay_runtime,
159155
relay_bite_at,
160-
ah_runtime,
161156
parachains,
162-
ah_bite_at,
163157
base_path,
164158
rc_sync_url,
165159
and_spawn,
@@ -176,8 +170,6 @@ async fn main() -> Result<(), anyhow::Error> {
176170
relay,
177171
relay_runtime,
178172
relay_bite_at,
179-
ah_runtime,
180-
ah_bite_at,
181173
parachains,
182174
base_path,
183175
rc_sync_url,

src/overrides.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -334,8 +334,8 @@ pub async fn generate_default_overrides_for_para(
334334
fn generate_paras_parachains_value(ids: impl Into<Vec<u32>>) -> String {
335335
let para_ids = ids.into();
336336
let para_ids: Vec<ParaId> = para_ids.iter().map(|id| ParaId(*id)).collect();
337-
let paras_parachains = array_bytes::bytes2hex("", para_ids.encode());
338-
paras_parachains
337+
338+
array_bytes::bytes2hex("", para_ids.encode())
339339
}
340340

341341
#[cfg(test)]

0 commit comments

Comments
 (0)