Skip to content

Commit 268baad

Browse files
committed
chore: merge latest main changes
2 parents cb72dbe + c85f2a1 commit 268baad

File tree

10 files changed

+327
-579
lines changed

10 files changed

+327
-579
lines changed

Cargo.lock

Lines changed: 111 additions & 469 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,8 @@ symlink = { version = "0.1", default-features = false }
7171
serde_json = { version = "1.0", default-features = false, features = ["preserve_order"] }
7272
serde = { version = "1.0", default-features = false, features = ["derive"] }
7373
srtool-lib = { version = "0.13.2", default-features = false }
74-
zombienet-configuration = { version = "0.3.1", default-features = false }
75-
zombienet-sdk = { version = "0.3.1", default-features = false }
74+
zombienet-configuration = { version = "0.4.1", default-features = false }
75+
zombienet-sdk = { version = "0.4.1", default-features = false }
7676
git2_credentials = "0.13.0"
7777
cumulus-client-cli = { version = "0.26.0", default-features = false }
7878

crates/pop-chains/src/relay.rs

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use crate::{DynamicPayload, Error, call};
44
use scale::{Decode, Encode};
55
use sp_core::twox_128;
66
use subxt::{
7-
OnlineClient, PolkadotConfig,
7+
OnlineClient,
88
dynamic::{self, Value},
99
events::StaticEvent,
1010
ext::{scale_decode::DecodeAsType, scale_encode::EncodeAsType},
@@ -16,13 +16,8 @@ use subxt::{
1616
/// # Arguments
1717
/// * `client` - Client for the network which state is to be modified.
1818
/// * `para_ids` - List of ids to build the keys that will be mutated.
19-
pub async fn clear_dmpq(
20-
// TODO: Different subxt versions: client: OnlineClient<PolkadotConfig>,
21-
endpoint: &str,
22-
para_ids: &[u32],
23-
) -> Result<H256, Error> {
24-
// TODO: Different subxt versions
25-
let client = OnlineClient::<PolkadotConfig>::from_url(endpoint)
19+
pub async fn clear_dmpq(endpoint: &str, para_ids: &[u32]) -> Result<H256, Error> {
20+
let client = OnlineClient::<subxt::PolkadotConfig>::from_url(endpoint)
2621
.await
2722
.map_err(|e| Error::SubXtError(e.into()))?;
2823
// Wait for blocks to be produced.

crates/pop-chains/src/up/mod.rs

Lines changed: 27 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -348,7 +348,7 @@ impl NetworkConfiguration {
348348
.collect();
349349

350350
let mut builder = NetworkConfigBuilder::new().with_relaychain(|builder| {
351-
let mut builder = builder.with_chain(relay_chain.chain()).with_node(|builder| {
351+
let mut builder = builder.with_chain(relay_chain.chain()).with_validator(|builder| {
352352
let mut builder = builder
353353
.with_name(validators.first().expect("at least two validators defined above"));
354354
if let Some(port) = port {
@@ -358,7 +358,7 @@ impl NetworkConfiguration {
358358
});
359359

360360
for validator in validators.iter().skip(1) {
361-
builder = builder.with_node(|builder| builder.with_name(validator))
361+
builder = builder.with_validator(|builder| builder.with_name(validator))
362362
}
363363
builder
364364
});
@@ -469,6 +469,12 @@ impl NetworkConfiguration {
469469
if let Some(location) = source.chain_spec_path() {
470470
builder = builder.with_chain_spec_path(location.clone());
471471
}
472+
if let Some(chain_spec_command_output_path) =
473+
source.chain_spec_command_output_path()
474+
{
475+
builder =
476+
builder.with_chain_spec_command_output_path(chain_spec_command_output_path);
477+
}
472478
// Configure chain spec generator
473479
if let Some(command) = chain_spec_generator {
474480
builder = builder.with_chain_spec_command(command);
@@ -482,12 +488,12 @@ impl NetworkConfiguration {
482488
}
483489

484490
// Add nodes from source
485-
let mut builder = builder.with_node(|builder| {
491+
let mut builder = builder.with_validator(|builder| {
486492
let source = nodes.first().expect("expected at least one node");
487493
Self::build_node_from_source(builder, source, binary_path.as_str())
488494
});
489495
for source in nodes.iter().skip(1) {
490-
builder = builder.with_node(|builder| {
496+
builder = builder.with_validator(|builder| {
491497
Self::build_node_from_source(builder, source, binary_path.as_str())
492498
});
493499
}
@@ -546,6 +552,12 @@ impl NetworkConfiguration {
546552
if source.chain_spec_command_is_local() {
547553
builder = builder.chain_spec_command_is_local(true);
548554
}
555+
if let Some(chain_spec_command_output_path) =
556+
source.chain_spec_command_output_path()
557+
{
558+
builder =
559+
builder.with_chain_spec_command_output_path(chain_spec_command_output_path)
560+
}
549561
if let Some(location) = source.chain_spec_path() {
550562
builder = builder.with_chain_spec_path(location.clone());
551563
}
@@ -942,7 +954,7 @@ chain = "paseo-local"
942954
let cache = PathBuf::from(temp_dir.path());
943955
let config = NetworkConfigBuilder::new()
944956
.with_relaychain(|b| {
945-
b.with_chain("paseo-local").with_node(|b| b.with_name("alice"))
957+
b.with_chain("paseo-local").with_validator(|b| b.with_name("alice"))
946958
})
947959
.build()
948960
.unwrap();
@@ -1119,7 +1131,7 @@ command = "polkadot"
11191131
let config = NetworkConfigBuilder::new()
11201132
.with_relaychain(|b| {
11211133
b.with_chain("paseo-local")
1122-
.with_node(|b| b.with_name("alice").with_command("polkadot"))
1134+
.with_validator(|b| b.with_name("alice").with_command("polkadot"))
11231135
})
11241136
.build()
11251137
.unwrap();
@@ -1218,9 +1230,9 @@ command = "polkadot-stable2503"
12181230
let config = NetworkConfigBuilder::new()
12191231
.with_relaychain(|b| {
12201232
b.with_chain("paseo-local")
1221-
.with_node(|b| b.with_name("alice").with_command("polkadot"))
1222-
.with_node(|b| b.with_name("bob").with_command("polkadot"))
1223-
.with_node(|b| b.with_name("charlie").with_command("p0lk4d0t"))
1233+
.with_validator(|b| b.with_name("alice").with_command("polkadot"))
1234+
.with_validator(|b| b.with_name("bob").with_command("polkadot"))
1235+
.with_validator(|b| b.with_name("charlie").with_command("p0lk4d0t"))
12241236
})
12251237
.build()
12261238
.unwrap();
@@ -1927,7 +1939,7 @@ chain = "paseo-local"
19271939
fn initializing_from_network_config_works() -> Result<(), Error> {
19281940
let network_config = NetworkConfigBuilder::new()
19291941
.with_relaychain(|b| {
1930-
b.with_chain("paseo-local").with_node(|b| b.with_name("alice"))
1942+
b.with_chain("paseo-local").with_validator(|b| b.with_name("alice"))
19311943
})
19321944
.build()
19331945
.unwrap();
@@ -2160,6 +2172,7 @@ rpc_port = 9944
21602172
r#"[settings]
21612173
timeout = 1000
21622174
node_spawn_timeout = 300
2175+
tear_down_on_failure = true
21632176
21642177
[relaychain]
21652178
chain = "paseo-local"
@@ -2340,6 +2353,7 @@ command = "polkadot-parachain"
23402353
r#"[settings]
23412354
timeout = 1000
23422355
node_spawn_timeout = 300
2356+
tear_down_on_failure = true
23432357
23442358
[relaychain]
23452359
chain = "paseo-local"
@@ -2482,6 +2496,7 @@ max_message_size = 8000
24822496
r#"[settings]
24832497
timeout = 1000
24842498
node_spawn_timeout = 300
2499+
tear_down_on_failure = true
24852500
24862501
[relaychain]
24872502
chain = "paseo-local"
@@ -2618,6 +2633,7 @@ name = "asset-hub"
26182633
r#"[settings]
26192634
timeout = 1000
26202635
node_spawn_timeout = 300
2636+
tear_down_on_failure = true
26212637
26222638
[relaychain]
26232639
chain = "paseo-local"
@@ -2735,6 +2751,7 @@ balances = [["5Ec4AhPKXY9B4ayGshkz2wFMh7N8gP7XKfAvtt1cigpG9FkJ", 420000000000]]
27352751
r#"[settings]
27362752
timeout = 1000
27372753
node_spawn_timeout = 300
2754+
tear_down_on_failure = true
27382755
27392756
[relaychain]
27402757
chain = "paseo-local"

crates/pop-cli/src/commands/build/spec.rs

Lines changed: 72 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,9 @@ pub struct BuildSpecCommand {
207207
/// based on `runtime`.
208208
#[clap(long, requires = "deterministic")]
209209
pub package: Option<String>,
210+
/// Generate a raw chain specification.
211+
#[arg(long)]
212+
pub(crate) raw: bool,
210213
}
211214

212215
impl BuildSpecCommand {
@@ -258,6 +261,7 @@ impl BuildSpecCommand {
258261
package,
259262
runtime_dir,
260263
is_relay,
264+
raw,
261265
..
262266
} = self;
263267

@@ -508,6 +512,7 @@ impl BuildSpecCommand {
508512
package,
509513
runtime_dir,
510514
use_existing_plain_spec: !prompt,
515+
raw,
511516
})
512517
}
513518
}
@@ -518,7 +523,7 @@ pub struct GenesisArtifacts {
518523
/// Path to the plain text chain specification file.
519524
pub chain_spec: PathBuf,
520525
/// Path to the raw chain specification file.
521-
pub raw_chain_spec: PathBuf,
526+
pub raw_chain_spec: Option<PathBuf>,
522527
/// Optional path to the genesis state file.
523528
pub genesis_state_file: Option<CodePathBuf>,
524529
/// Optional path to the genesis code file.
@@ -570,6 +575,7 @@ pub(crate) struct BuildSpec {
570575
package: String,
571576
runtime_dir: Option<PathBuf>,
572577
use_existing_plain_spec: bool,
578+
raw: bool,
573579
}
574580

575581
impl BuildSpec {
@@ -655,54 +661,66 @@ impl BuildSpec {
655661
));
656662
}
657663

658-
// Generate raw spec.
659-
spinner.set_message("Generating raw chain specification...");
660-
let spec_name = self
661-
.output_file
662-
.file_name()
663-
.and_then(|s| s.to_str())
664-
.unwrap_or(DEFAULT_SPEC_NAME)
665-
.trim_end_matches(".json");
666-
let raw_spec_name = format!("{spec_name}-raw.json");
667-
let raw_chain_spec = builder.generate_raw_chain_spec(&self.output_file, &raw_spec_name)?;
668-
generated_files.push(format!(
669-
"Raw chain specification file generated at: {}",
670-
raw_chain_spec.display()
671-
));
664+
let (raw_chain_spec, genesis_code_file, genesis_state_file) = if self.raw ||
665+
self.genesis_code ||
666+
self.genesis_state
667+
{
668+
// Generate raw spec.
669+
spinner.set_message("Generating raw chain specification...");
670+
let spec_name = self
671+
.output_file
672+
.file_name()
673+
.and_then(|s| s.to_str())
674+
.unwrap_or(DEFAULT_SPEC_NAME)
675+
.trim_end_matches(".json");
676+
let raw_spec_name = format!("{spec_name}-raw.json");
677+
let raw_chain_spec =
678+
builder.generate_raw_chain_spec(&self.output_file, &raw_spec_name)?;
679+
generated_files.push(format!(
680+
"Raw chain specification file generated at: {}",
681+
raw_chain_spec.display()
682+
));
672683

673-
if is_runtime_build {
674-
// The runtime version of the raw chain spec does not include certain parameters, like
675-
// the relay chain, so we have to overwrite them again.
676-
self.customize(&raw_chain_spec)?;
677-
}
684+
if is_runtime_build {
685+
// The runtime version of the raw chain spec does not include certain parameters,
686+
// like the relay chain, so we have to overwrite them again.
687+
self.customize(&raw_chain_spec)?;
688+
}
678689

679-
// Generate genesis artifacts.
680-
let genesis_code_file = if self.genesis_code {
681-
spinner.set_message("Generating genesis code...");
682-
let wasm_file = builder.export_wasm_file(&raw_chain_spec, "genesis-code.wasm")?;
683-
generated_files
684-
.push(format!("WebAssembly runtime file exported at: {}", wasm_file.display()));
685-
Some(wasm_file)
686-
} else {
687-
None
688-
};
689-
let genesis_state_file = if self.genesis_state {
690-
spinner.set_message("Generating genesis state...");
691-
let binary_path = match builder {
692-
ChainSpecBuilder::Runtime { .. } =>
693-
source_polkadot_omni_node_binary(cli, &spinner, &crate::cache()?, true).await?,
694-
ChainSpecBuilder::Node { .. } => builder.artifact_path()?,
690+
// Generate genesis artifacts.
691+
let genesis_code_file = if self.genesis_code {
692+
spinner.set_message("Generating genesis code...");
693+
let wasm_file = builder.export_wasm_file(&raw_chain_spec, "genesis-code.wasm")?;
694+
generated_files
695+
.push(format!("WebAssembly runtime file exported at: {}", wasm_file.display()));
696+
Some(wasm_file)
697+
} else {
698+
None
695699
};
696-
let genesis_state_file = generate_genesis_state_file_with_node(
697-
&binary_path,
698-
&raw_chain_spec,
699-
"genesis-state",
700-
)?;
701-
generated_files
702-
.push(format!("Genesis State file exported at: {}", genesis_state_file.display()));
703-
Some(genesis_state_file)
700+
let genesis_state_file = if self.genesis_state {
701+
spinner.set_message("Generating genesis state...");
702+
let binary_path = match builder {
703+
ChainSpecBuilder::Runtime { .. } =>
704+
source_polkadot_omni_node_binary(cli, &spinner, &crate::cache()?, true)
705+
.await?,
706+
ChainSpecBuilder::Node { .. } => builder.artifact_path()?,
707+
};
708+
let genesis_state_file = generate_genesis_state_file_with_node(
709+
&binary_path,
710+
&raw_chain_spec,
711+
"genesis-state",
712+
)?;
713+
generated_files.push(format!(
714+
"Genesis State file exported at: {}",
715+
genesis_state_file.display()
716+
));
717+
Some(genesis_state_file)
718+
} else {
719+
None
720+
};
721+
(Some(raw_chain_spec), genesis_code_file, genesis_state_file)
704722
} else {
705-
None
723+
(None, None, None)
706724
};
707725

708726
spinner.stop("Chain specification built successfully.");
@@ -789,15 +807,16 @@ fn prepare_output_path(output_path: impl AsRef<Path>) -> anyhow::Result<PathBuf>
789807
.and_then(|ext| ext.to_str())
790808
.map(|ext| ext.eq_ignore_ascii_case("json"))
791809
.unwrap_or(false);
810+
let is_dir = output_path.is_dir();
792811

793-
if !is_json_file {
794-
// Treat as directory.
812+
if is_dir || (!output_path.exists() && !is_json_file) {
813+
// Treat as directory (existing or to-be-created)
795814
if !output_path.exists() {
796815
create_dir_all(&output_path)?;
797816
}
798817
output_path.push(DEFAULT_SPEC_NAME);
799818
} else {
800-
// Treat as file.
819+
// Treat as file; ensure parent dir exists
801820
if let Some(parent_dir) = output_path.parent() &&
802821
!parent_dir.exists()
803822
{
@@ -837,6 +856,7 @@ mod tests {
837856
let runtime_dir = PathBuf::from("./new-runtime-dir");
838857
let path = PathBuf::from("./");
839858
let properties = "tokenSymbol=UNIT,decimals=12,isEthereum=false";
859+
let raw = true;
840860

841861
let mut flags_used = false;
842862
for (build_spec_cmd, chain) in [
@@ -865,6 +885,7 @@ mod tests {
865885
deterministic: Some(deterministic),
866886
package: Some(package.to_string()),
867887
runtime_dir: Some(runtime_dir.clone()),
888+
raw,
868889
},
869890
Some("local".to_string()),
870891
),
@@ -891,6 +912,7 @@ mod tests {
891912
deterministic: Some(deterministic),
892913
package: Some(package.to_string()),
893914
runtime_dir: Some(runtime_dir.clone()),
915+
raw,
894916
},
895917
Some("local".to_string()),
896918
),
@@ -1034,6 +1056,7 @@ mod tests {
10341056
deterministic: None,
10351057
package: Some(package.to_string()),
10361058
runtime_dir: Some(runtime_dir.clone()),
1059+
raw: true,
10371060
},
10381061
// All flags used. Relay
10391062
BuildSpecCommand {
@@ -1057,6 +1080,7 @@ mod tests {
10571080
deterministic: None,
10581081
package: Some(package.to_string()),
10591082
runtime_dir: Some(runtime_dir.clone()),
1083+
raw: true,
10601084
},
10611085
] {
10621086
let mut cli = MockCli::new().expect_confirm(

crates/pop-cli/src/commands/up/mod.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,8 @@ impl Command {
9595
let project_path = ensure_project_path(args.path.clone(), args.path_pos.clone());
9696
#[cfg(feature = "chain")]
9797
if project_path.is_file() {
98-
let cmd = network::ConfigFileCommand { path: Some(project_path), ..Default::default() };
98+
let cmd =
99+
network::ConfigFileCommand { path: project_path.clone(), ..Default::default() };
99100
cmd.execute(cli).await?;
100101
return Ok(Network);
101102
}

0 commit comments

Comments
 (0)