diff --git a/Cargo.lock b/Cargo.lock index 726c8f5a1885..cc08e383e3a0 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -19857,6 +19857,7 @@ dependencies = [ "env_logger 0.11.3", "log", "parity-scale-codec", + "polkadot-primitives 7.0.0", "serde", "serde_json", "substrate-build-script-utils", diff --git a/polkadot/zombienet-sdk-tests/Cargo.toml b/polkadot/zombienet-sdk-tests/Cargo.toml index 4eac7af49f8a..733dcb8376bd 100644 --- a/polkadot/zombienet-sdk-tests/Cargo.toml +++ b/polkadot/zombienet-sdk-tests/Cargo.toml @@ -18,6 +18,7 @@ zombienet-sdk = { workspace = true } serde = { workspace = true } serde_json = { workspace = true } codec = { workspace = true, features = ["derive"] } +polkadot-primitives = { workspace = true, default-features = true } [features] zombie-metadata = [] diff --git a/polkadot/zombienet-sdk-tests/tests/elastic_scaling/basic_3cores.rs b/polkadot/zombienet-sdk-tests/tests/elastic_scaling/basic_3cores.rs index 3371674bef03..42aa83d9da7a 100644 --- a/polkadot/zombienet-sdk-tests/tests/elastic_scaling/basic_3cores.rs +++ b/polkadot/zombienet-sdk-tests/tests/elastic_scaling/basic_3cores.rs @@ -13,6 +13,7 @@ use crate::helpers::{ polkadot_runtime_parachains::assigner_coretime::PartsOf57600, }, }; +use polkadot_primitives::Id as ParaId; use serde_json::json; use subxt::{OnlineClient, PolkadotConfig}; use subxt_signer::sr25519::dev; @@ -122,7 +123,9 @@ async fn basic_3cores_test() -> Result<(), anyhow::Error> { assert_para_throughput( &relay_client, 15, - [(2000, 40..46), (2001, 12..16)].into_iter().collect(), + [(ParaId::from(2000), 40..46), (ParaId::from(2001), 12..16)] + .into_iter() + .collect(), ) .await?; diff --git a/polkadot/zombienet-sdk-tests/tests/elastic_scaling/doesnt_break_parachains.rs b/polkadot/zombienet-sdk-tests/tests/elastic_scaling/doesnt_break_parachains.rs index 97ac88a00332..f83400d2b22a 100644 --- a/polkadot/zombienet-sdk-tests/tests/elastic_scaling/doesnt_break_parachains.rs +++ b/polkadot/zombienet-sdk-tests/tests/elastic_scaling/doesnt_break_parachains.rs @@ -13,7 +13,9 @@ use crate::helpers::{ polkadot_runtime_parachains::assigner_coretime::PartsOf57600, }, }; +use polkadot_primitives::{CoreIndex, Id as ParaId}; use serde_json::json; +use std::collections::{BTreeMap, VecDeque}; use subxt::{OnlineClient, PolkadotConfig}; use subxt_signer::sr25519::dev; use zombienet_sdk::NetworkConfigBuilder; @@ -98,14 +100,33 @@ async fn doesnt_break_parachains_test() -> Result<(), anyhow::Error> { log::info!("1 more core assigned to the parachain"); + let para_id = ParaId::from(2000); // Expect the parachain to be making normal progress, 1 candidate backed per relay chain block. - assert_para_throughput(&relay_client, 15, [(2000, 13..16)].into_iter().collect()).await?; + assert_para_throughput(&relay_client, 15, [(para_id, 13..16)].into_iter().collect()).await?; let para_client = para_node.wait_client().await?; // Assert the parachain finalized block height is also on par with the number of backed // candidates. assert_finalized_block_height(¶_client, 12..16).await?; + // Sanity check that indeed the parachain has two assigned cores. + let cq = relay_client + .runtime_api() + .at_latest() + .await? + .call_raw::>>("ParachainHost_claim_queue", None) + .await?; + + assert_eq!( + cq, + [ + (CoreIndex(0), [para_id, para_id].into_iter().collect()), + (CoreIndex(1), [para_id, para_id].into_iter().collect()), + ] + .into_iter() + .collect() + ); + log::info!("Test finished successfully"); Ok(()) diff --git a/polkadot/zombienet-sdk-tests/tests/elastic_scaling/slot_based_3cores.rs b/polkadot/zombienet-sdk-tests/tests/elastic_scaling/slot_based_3cores.rs index 3125a8039411..aa9f41320135 100644 --- a/polkadot/zombienet-sdk-tests/tests/elastic_scaling/slot_based_3cores.rs +++ b/polkadot/zombienet-sdk-tests/tests/elastic_scaling/slot_based_3cores.rs @@ -13,6 +13,7 @@ use crate::helpers::{ polkadot_runtime_parachains::assigner_coretime::PartsOf57600, }, }; +use polkadot_primitives::Id as ParaId; use serde_json::json; use subxt::{OnlineClient, PolkadotConfig}; use subxt_signer::sr25519::dev; @@ -156,7 +157,9 @@ async fn slot_based_3cores_test() -> Result<(), anyhow::Error> { assert_para_throughput( &relay_client, 15, - [(2100, 39..46), (2200, 39..46)].into_iter().collect(), + [(ParaId::from(2100), 39..46), (ParaId::from(2200), 39..46)] + .into_iter() + .collect(), ) .await?; diff --git a/polkadot/zombienet-sdk-tests/tests/functional/async_backing_6_seconds_rate.rs b/polkadot/zombienet-sdk-tests/tests/functional/async_backing_6_seconds_rate.rs index 419d8ccfcffe..14f86eb130f7 100644 --- a/polkadot/zombienet-sdk-tests/tests/functional/async_backing_6_seconds_rate.rs +++ b/polkadot/zombienet-sdk-tests/tests/functional/async_backing_6_seconds_rate.rs @@ -6,6 +6,7 @@ use anyhow::anyhow; use crate::helpers::{assert_finalized_block_height, assert_para_throughput}; +use polkadot_primitives::Id as ParaId; use serde_json::json; use subxt::{OnlineClient, PolkadotConfig}; use zombienet_sdk::NetworkConfigBuilder; @@ -78,7 +79,9 @@ async fn async_backing_6_seconds_rate_test() -> Result<(), anyhow::Error> { assert_para_throughput( &relay_client, 15, - [(2000, 11..16), (2001, 11..16)].into_iter().collect(), + [(ParaId::from(2000), 11..16), (ParaId::from(2001), 11..16)] + .into_iter() + .collect(), ) .await?; diff --git a/polkadot/zombienet-sdk-tests/tests/functional/sync_backing.rs b/polkadot/zombienet-sdk-tests/tests/functional/sync_backing.rs index 6d45df259df3..29824ab9f2a5 100644 --- a/polkadot/zombienet-sdk-tests/tests/functional/sync_backing.rs +++ b/polkadot/zombienet-sdk-tests/tests/functional/sync_backing.rs @@ -6,6 +6,7 @@ use anyhow::anyhow; use crate::helpers::{assert_finalized_block_height, assert_para_throughput}; +use polkadot_primitives::Id as ParaId; use serde_json::json; use subxt::{OnlineClient, PolkadotConfig}; use zombienet_sdk::NetworkConfigBuilder; @@ -60,7 +61,8 @@ async fn sync_backing_test() -> Result<(), anyhow::Error> { let relay_client: OnlineClient = relay_node.wait_client().await?; - assert_para_throughput(&relay_client, 15, [(2000, 6..9)].into_iter().collect()).await?; + assert_para_throughput(&relay_client, 15, [(ParaId::from(2000), 6..9)].into_iter().collect()) + .await?; // Assert the parachain finalized block height is also on par with the number of backed // candidates. diff --git a/polkadot/zombienet-sdk-tests/tests/helpers/mod.rs b/polkadot/zombienet-sdk-tests/tests/helpers/mod.rs index 2d5a055b0bcc..470345ca4d62 100644 --- a/polkadot/zombienet-sdk-tests/tests/helpers/mod.rs +++ b/polkadot/zombienet-sdk-tests/tests/helpers/mod.rs @@ -1,6 +1,7 @@ // Copyright (C) Parity Technologies (UK) Ltd. // SPDX-License-Identifier: Apache-2.0 +use polkadot_primitives::Id as ParaId; use std::{collections::HashMap, ops::Range}; use subxt::{OnlineClient, PolkadotConfig}; @@ -12,10 +13,10 @@ pub mod rococo {} pub async fn assert_para_throughput( relay_client: &OnlineClient, stop_at: u32, - expected_candidate_ranges: HashMap>, + expected_candidate_ranges: HashMap>, ) -> Result<(), anyhow::Error> { let mut blocks_sub = relay_client.blocks().subscribe_finalized().await?; - let mut candidate_count: HashMap = HashMap::new(); + let mut candidate_count: HashMap = HashMap::new(); let mut current_block_count = 0; let mut had_first_session_change = false; @@ -33,7 +34,7 @@ pub async fn assert_para_throughput( current_block_count += 1; for event in events.find::() { - *(candidate_count.entry(event?.0.descriptor.para_id.0).or_default()) += 1; + *(candidate_count.entry(event?.0.descriptor.para_id.0.into()).or_default()) += 1; } }