From 060bd62a36ecd39bf50ddc3812d6515bf7e0f329 Mon Sep 17 00:00:00 2001 From: alindima Date: Wed, 4 Dec 2024 14:39:46 +0200 Subject: [PATCH 1/4] rewrite basic_3cores and doesnt_break_parachains tests --- .gitlab/pipeline/zombienet/polkadot.yml | 55 ++++---- .../tests/elastic_scaling/basic_3cores.rs | 133 ++++++++++++++++++ .../doesnt_break_parachains.rs | 113 +++++++++++++++ .../tests/elastic_scaling/helpers.rs | 18 +++ .../elastic_scaling/mixed_receipt_versions.rs | 14 +- .../tests/elastic_scaling/mod.rs | 2 + .../elastic_scaling/slot_based_3cores.rs | 26 +++- .../0001-basic-3cores-6s-blocks.toml | 49 ------- .../0001-basic-3cores-6s-blocks.zndsl | 28 ---- ...astic-scaling-doesnt-break-parachains.toml | 40 ------ ...stic-scaling-doesnt-break-parachains.zndsl | 20 --- .../elastic_scaling/assign-core.js | 1 - 12 files changed, 328 insertions(+), 171 deletions(-) create mode 100644 polkadot/zombienet-sdk-tests/tests/elastic_scaling/basic_3cores.rs create mode 100644 polkadot/zombienet-sdk-tests/tests/elastic_scaling/doesnt_break_parachains.rs delete mode 100644 polkadot/zombienet_tests/elastic_scaling/0001-basic-3cores-6s-blocks.toml delete mode 100644 polkadot/zombienet_tests/elastic_scaling/0001-basic-3cores-6s-blocks.zndsl delete mode 100644 polkadot/zombienet_tests/elastic_scaling/0002-elastic-scaling-doesnt-break-parachains.toml delete mode 100644 polkadot/zombienet_tests/elastic_scaling/0002-elastic-scaling-doesnt-break-parachains.zndsl delete mode 120000 polkadot/zombienet_tests/elastic_scaling/assign-core.js diff --git a/.gitlab/pipeline/zombienet/polkadot.yml b/.gitlab/pipeline/zombienet/polkadot.yml index 9bcb9df2dad4..5ec4fa036d97 100644 --- a/.gitlab/pipeline/zombienet/polkadot.yml +++ b/.gitlab/pipeline/zombienet/polkadot.yml @@ -166,31 +166,6 @@ zombienet-polkadot-functional-0010-validator-disabling: --local-dir="${LOCAL_DIR}/functional" --test="0011-async-backing-6-seconds-rate.zndsl" -zombienet-polkadot-elastic-scaling-0001-basic-3cores-6s-blocks: - extends: - - .zombienet-polkadot-common - variables: - FORCED_INFRA_INSTANCE: "spot-iops" - before_script: - - !reference [ .zombienet-polkadot-common, before_script ] - - cp --remove-destination ${LOCAL_DIR}/assign-core.js ${LOCAL_DIR}/elastic_scaling - script: - - /home/nonroot/zombie-net/scripts/ci/run-test-local-env-manager.sh - --local-dir="${LOCAL_DIR}/elastic_scaling" - --test="0001-basic-3cores-6s-blocks.zndsl" - -zombienet-polkadot-elastic-scaling-0002-elastic-scaling-doesnt-break-parachains: - extends: - - .zombienet-polkadot-common - before_script: - - !reference [ .zombienet-polkadot-common, before_script ] - - cp --remove-destination ${LOCAL_DIR}/assign-core.js ${LOCAL_DIR}/elastic_scaling - script: - - /home/nonroot/zombie-net/scripts/ci/run-test-local-env-manager.sh - --local-dir="${LOCAL_DIR}/elastic_scaling" - --test="0002-elastic-scaling-doesnt-break-parachains.zndsl" - - .zombienet-polkadot-functional-0012-spam-statement-distribution-requests: extends: - .zombienet-polkadot-common @@ -419,3 +394,33 @@ zombienet-polkadot-elastic-scaling-mixed-receipt-versions: - unset NEXTEST_FAILURE_OUTPUT - unset NEXTEST_SUCCESS_OUTPUT - cargo nextest run --archive-file ./artifacts/polkadot-zombienet-tests.tar.zst --no-capture -- elastic_scaling::mixed_receipt_versions::mixed_receipt_versions_test + +zombienet-polkadot-elastic-scaling-doesnt-break-parachains: + extends: + - .zombienet-polkadot-common + needs: + - job: build-polkadot-zombienet-tests + artifacts: true + before_script: + - !reference [ ".zombienet-polkadot-common", "before_script" ] + - export CUMULUS_IMAGE="docker.io/paritypr/test-parachain:${PIPELINE_IMAGE_TAG}" + script: + # we want to use `--no-capture` in zombienet tests. + - unset NEXTEST_FAILURE_OUTPUT + - unset NEXTEST_SUCCESS_OUTPUT + - cargo nextest run --archive-file ./artifacts/polkadot-zombienet-tests.tar.zst --no-capture -- elastic_scaling::doesnt_break_parachains::doesnt_break_parachains_test + +zombienet-polkadot-elastic-scaling-basic-3cores: + extends: + - .zombienet-polkadot-common + needs: + - job: build-polkadot-zombienet-tests + artifacts: true + before_script: + - !reference [ ".zombienet-polkadot-common", "before_script" ] + - export CUMULUS_IMAGE="${COL_IMAGE}" + script: + # we want to use `--no-capture` in zombienet tests. + - unset NEXTEST_FAILURE_OUTPUT + - unset NEXTEST_SUCCESS_OUTPUT + - cargo nextest run --archive-file ./artifacts/polkadot-zombienet-tests.tar.zst --no-capture -- elastic_scaling::basic_3cores::basic_3cores_test diff --git a/polkadot/zombienet-sdk-tests/tests/elastic_scaling/basic_3cores.rs b/polkadot/zombienet-sdk-tests/tests/elastic_scaling/basic_3cores.rs new file mode 100644 index 000000000000..267a38285d4b --- /dev/null +++ b/polkadot/zombienet-sdk-tests/tests/elastic_scaling/basic_3cores.rs @@ -0,0 +1,133 @@ +// Copyright (C) Parity Technologies (UK) Ltd. +// SPDX-License-Identifier: Apache-2.0 + +// Test that a parachain that uses a basic collator (like adder-collator) with elastic scaling +// can achieve full throughput of 3 candidates per block. + +use anyhow::anyhow; + +use super::{ + helpers::assert_para_throughput, + rococo, + rococo::runtime_types::{ + pallet_broker::coretime_interface::CoreAssignment, + polkadot_runtime_parachains::assigner_coretime::PartsOf57600, + }, +}; +use serde_json::json; +use subxt::{OnlineClient, PolkadotConfig}; +use subxt_signer::sr25519::dev; +use zombienet_sdk::NetworkConfigBuilder; + +#[tokio::test(flavor = "multi_thread")] +async fn basic_3cores_test() -> Result<(), anyhow::Error> { + let _ = env_logger::try_init_from_env( + env_logger::Env::default().filter_or(env_logger::DEFAULT_FILTER_ENV, "info"), + ); + + let images = zombienet_sdk::environment::get_images_from_env(); + + let config = NetworkConfigBuilder::new() + .with_relaychain(|r| { + let r = r + .with_chain("rococo-local") + .with_default_command("polkadot") + .with_default_image(images.polkadot.as_str()) + .with_default_args(vec![("-lparachain=debug").into()]) + .with_genesis_overrides(json!({ + "configuration": { + "config": { + "scheduler_params": { + "num_cores": 2, + "max_validators_per_core": 1 + }, + "async_backing_params": { + "max_candidate_depth": 6, + "allowed_ancestry_len": 2 + } + } + } + })) + // Have to set a `with_node` outside of the loop below, so that `r` has the right + // type. + .with_node(|node| node.with_name("validator-0")); + + (1..4).fold(r, |acc, i| acc.with_node(|node| node.with_name(&format!("validator-{i}")))) + }) + .with_parachain(|p| { + p.with_id(2000) + .with_default_command("adder-collator") + .cumulus_based(false) + .with_default_image(images.cumulus.as_str()) + .with_default_args(vec![("-lparachain=debug").into()]) + .with_collator(|n| n.with_name("adder-2000")) + }) + .with_parachain(|p| { + p.with_id(2001) + .with_default_command("adder-collator") + .cumulus_based(false) + .with_default_image(images.cumulus.as_str()) + .with_default_args(vec![("-lparachain=debug").into()]) + .with_collator(|n| n.with_name("adder-2001")) + }) + .build() + .map_err(|e| { + let errs = e.into_iter().map(|e| e.to_string()).collect::>().join(" "); + anyhow!("config errs: {errs}") + })?; + + let spawn_fn = zombienet_sdk::environment::get_spawn_fn(); + let network = spawn_fn(config).await?; + + let relay_node = network.get_node("validator-0")?; + + let relay_client: OnlineClient = relay_node.wait_client().await?; + let alice = dev::alice(); + + // Assign two extra cores to adder-2000. + relay_client + .tx() + .sign_and_submit_then_watch_default( + &rococo::tx() + .sudo() + .sudo(rococo::runtime_types::rococo_runtime::RuntimeCall::Utility( + rococo::runtime_types::pallet_utility::pallet::Call::batch { + calls: vec![ + rococo::runtime_types::rococo_runtime::RuntimeCall::Coretime( + rococo::runtime_types::polkadot_runtime_parachains::coretime::pallet::Call::assign_core { + core: 0, + begin: 0, + assignment: vec![(CoreAssignment::Task(2000), PartsOf57600(57600))], + end_hint: None + } + ), + rococo::runtime_types::rococo_runtime::RuntimeCall::Coretime( + rococo::runtime_types::polkadot_runtime_parachains::coretime::pallet::Call::assign_core { + core: 1, + begin: 0, + assignment: vec![(CoreAssignment::Task(2000), PartsOf57600(57600))], + end_hint: None + } + ), + ], + }, + )), + &alice, + ) + .await? + .wait_for_finalized_success() + .await?; + + log::info!("2 more cores assigned to adder-2000"); + + assert_para_throughput( + &relay_client, + 15, + [(2000, 40..46), (2001, 12..16)].into_iter().collect(), + ) + .await?; + + log::info!("Test finished successfully"); + + Ok(()) +} 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 new file mode 100644 index 000000000000..df002d64e40e --- /dev/null +++ b/polkadot/zombienet-sdk-tests/tests/elastic_scaling/doesnt_break_parachains.rs @@ -0,0 +1,113 @@ +// Copyright (C) Parity Technologies (UK) Ltd. +// SPDX-License-Identifier: Apache-2.0 + +// Test that a paraid that doesn't use elastic scaling which acquired multiple cores does not brick +// itself if ElasticScalingMVP feature is enabled in genesis. + +use anyhow::anyhow; + +use super::{ + helpers::{assert_finalized_block_height, assert_para_throughput}, + rococo, + rococo::runtime_types::{ + pallet_broker::coretime_interface::CoreAssignment, + polkadot_runtime_parachains::assigner_coretime::PartsOf57600, + }, +}; +use serde_json::json; +use subxt::{OnlineClient, PolkadotConfig}; +use subxt_signer::sr25519::dev; +use zombienet_sdk::NetworkConfigBuilder; + +#[tokio::test(flavor = "multi_thread")] +async fn doesnt_break_parachains_test() -> Result<(), anyhow::Error> { + let _ = env_logger::try_init_from_env( + env_logger::Env::default().filter_or(env_logger::DEFAULT_FILTER_ENV, "info"), + ); + + let images = zombienet_sdk::environment::get_images_from_env(); + + let config = NetworkConfigBuilder::new() + .with_relaychain(|r| { + let r = r + .with_chain("rococo-local") + .with_default_command("polkadot") + .with_default_image(images.polkadot.as_str()) + .with_default_args(vec![("-lparachain=debug").into()]) + .with_genesis_overrides(json!({ + "configuration": { + "config": { + "scheduler_params": { + "num_cores": 1, + "max_validators_per_core": 2 + }, + "async_backing_params": { + "max_candidate_depth": 6, + "allowed_ancestry_len": 2 + } + } + } + })) + // Have to set a `with_node` outside of the loop below, so that `r` has the right + // type. + .with_node(|node| node.with_name("validator-0")); + + (1..4).fold(r, |acc, i| acc.with_node(|node| node.with_name(&format!("validator-{i}")))) + }) + .with_parachain(|p| { + // Use rococo-parachain default, which has 6 second slot time. Also, don't use + // slot-based collator. + p.with_id(2000) + .with_default_command("polkadot-parachain") + .with_default_image(images.cumulus.as_str()) + .with_default_args(vec![("-lparachain=debug,aura=debug").into()]) + .with_collator(|n| n.with_name("collator-2000")) + }) + .build() + .map_err(|e| { + let errs = e.into_iter().map(|e| e.to_string()).collect::>().join(" "); + anyhow!("config errs: {errs}") + })?; + + let spawn_fn = zombienet_sdk::environment::get_spawn_fn(); + let network = spawn_fn(config).await?; + + let relay_node = network.get_node("validator-0")?; + let para_node = network.get_node("collator-2000")?; + + let relay_client: OnlineClient = relay_node.wait_client().await?; + let alice = dev::alice(); + + relay_client + .tx() + .sign_and_submit_then_watch_default( + &rococo::tx() + .sudo() + .sudo(rococo::runtime_types::rococo_runtime::RuntimeCall::Coretime( + rococo::runtime_types::polkadot_runtime_parachains::coretime::pallet::Call::assign_core { + core: 0, + begin: 0, + assignment: vec![(CoreAssignment::Task(2000), PartsOf57600(57600))], + end_hint: None + } + )), + &alice, + ) + .await? + .wait_for_finalized_success() + .await?; + + log::info!("1 more core assigned to the parachain"); + + // 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?; + + 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?; + + log::info!("Test finished successfully"); + + Ok(()) +} diff --git a/polkadot/zombienet-sdk-tests/tests/elastic_scaling/helpers.rs b/polkadot/zombienet-sdk-tests/tests/elastic_scaling/helpers.rs index 7d4ad4a1dd8b..7e1341990fc1 100644 --- a/polkadot/zombienet-sdk-tests/tests/elastic_scaling/helpers.rs +++ b/polkadot/zombienet-sdk-tests/tests/elastic_scaling/helpers.rs @@ -58,3 +58,21 @@ pub async fn assert_para_throughput( Ok(()) } + +// Helper function for retrieving the latest finalized block height and asserting it's within a +// range. +pub async fn assert_finalized_block_height( + client: &OnlineClient, + expected_range: Range, +) -> Result<(), anyhow::Error> { + if let Some(block) = client.blocks().subscribe_finalized().await?.next().await { + let height = block?.number(); + log::info!("Finalized block number number {height}"); + + assert!( + expected_range.contains(&height), + "Finalized block number {height} not within range {expected_range:?}" + ); + } + Ok(()) +} diff --git a/polkadot/zombienet-sdk-tests/tests/elastic_scaling/mixed_receipt_versions.rs b/polkadot/zombienet-sdk-tests/tests/elastic_scaling/mixed_receipt_versions.rs index 68ff125e5694..d219241e8df7 100644 --- a/polkadot/zombienet-sdk-tests/tests/elastic_scaling/mixed_receipt_versions.rs +++ b/polkadot/zombienet-sdk-tests/tests/elastic_scaling/mixed_receipt_versions.rs @@ -7,7 +7,7 @@ use anyhow::anyhow; use super::{ - helpers::assert_para_throughput, + helpers::{assert_finalized_block_height, assert_para_throughput}, rococo, rococo::runtime_types::{ pallet_broker::coretime_interface::CoreAssignment, @@ -33,6 +33,7 @@ async fn mixed_receipt_versions_test() -> Result<(), anyhow::Error> { .with_chain("rococo-local") .with_default_command("polkadot") .with_default_image(images.polkadot.as_str()) + .with_default_args(vec![("-lparachain=debug").into()]) .with_genesis_overrides(json!({ "configuration": { "config": { @@ -59,7 +60,10 @@ async fn mixed_receipt_versions_test() -> Result<(), anyhow::Error> { .with_default_command("test-parachain") .with_default_image(images.cumulus.as_str()) .with_chain("elastic-scaling") - .with_default_args(vec![("--experimental-use-slot-based").into()]) + .with_default_args(vec![ + ("--experimental-use-slot-based").into(), + ("-lparachain=debug,aura=debug").into(), + ]) // This collator uses the image from the PR, which will build a v2 receipt. .with_collator(|n| n.with_name("collator-elastic")) // This collator uses an old image, which will build a v1 receipt. @@ -79,6 +83,7 @@ async fn mixed_receipt_versions_test() -> Result<(), anyhow::Error> { let network = spawn_fn(config).await?; let relay_node = network.get_node("validator-0")?; + let para_node = network.get_node("collator-elastic")?; let relay_client: OnlineClient = relay_node.wait_client().await?; let alice = dev::alice(); @@ -125,6 +130,11 @@ async fn mixed_receipt_versions_test() -> Result<(), anyhow::Error> { // blocks. assert_para_throughput(&relay_client, 15, [(2200, 25..35)].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, 22..35).await?; + log::info!("Test finished successfully"); Ok(()) diff --git a/polkadot/zombienet-sdk-tests/tests/elastic_scaling/mod.rs b/polkadot/zombienet-sdk-tests/tests/elastic_scaling/mod.rs index 24373875fee5..bd6c3961ace9 100644 --- a/polkadot/zombienet-sdk-tests/tests/elastic_scaling/mod.rs +++ b/polkadot/zombienet-sdk-tests/tests/elastic_scaling/mod.rs @@ -4,6 +4,8 @@ #[subxt::subxt(runtime_metadata_path = "metadata-files/rococo-local.scale")] pub mod rococo {} +mod basic_3cores; +mod doesnt_break_parachains; mod helpers; mod mixed_receipt_versions; mod slot_based_3cores; 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 8fdc69a89ff5..4e59fbcfbe23 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 @@ -7,7 +7,7 @@ use anyhow::anyhow; use super::{ - helpers::assert_para_throughput, + helpers::{assert_finalized_block_height, assert_para_throughput}, rococo, rococo::runtime_types::{ pallet_broker::coretime_interface::CoreAssignment, @@ -33,6 +33,7 @@ async fn slot_based_3cores_test() -> Result<(), anyhow::Error> { .with_chain("rococo-local") .with_default_command("polkadot") .with_default_image(images.polkadot.as_str()) + .with_default_args(vec![("-lparachain=debug").into()]) .with_genesis_overrides(json!({ "configuration": { "config": { @@ -62,7 +63,10 @@ async fn slot_based_3cores_test() -> Result<(), anyhow::Error> { .with_default_command("test-parachain") .with_default_image(images.cumulus.as_str()) .with_chain("elastic-scaling-mvp") - .with_default_args(vec![("--experimental-use-slot-based").into()]) + .with_default_args(vec![ + ("--experimental-use-slot-based").into(), + ("-lparachain=debug,aura=debug").into(), + ]) .with_collator(|n| n.with_name("collator-elastic-mvp")) }) .with_parachain(|p| { @@ -72,7 +76,10 @@ async fn slot_based_3cores_test() -> Result<(), anyhow::Error> { .with_default_command("test-parachain") .with_default_image(images.cumulus.as_str()) .with_chain("elastic-scaling") - .with_default_args(vec![("--experimental-use-slot-based").into()]) + .with_default_args(vec![ + ("--experimental-use-slot-based").into(), + ("-lparachain=debug,aura=debug").into(), + ]) .with_collator(|n| n.with_name("collator-elastic")) }) .build() @@ -85,6 +92,8 @@ async fn slot_based_3cores_test() -> Result<(), anyhow::Error> { let network = spawn_fn(config).await?; let relay_node = network.get_node("validator-0")?; + let para_node_elastic = network.get_node("collator-elastic")?; + let para_node_elastic_mvp = network.get_node("collator-elastic-mvp")?; let relay_client: OnlineClient = relay_node.wait_client().await?; let alice = dev::alice(); @@ -141,17 +150,22 @@ async fn slot_based_3cores_test() -> Result<(), anyhow::Error> { log::info!("2 more cores assigned to each parachain"); - // Expect a backed candidate count of at least 42 for each parachain in 15 relay chain blocks - // (2.8 candidates per para per relay chain block). + // Expect a backed candidate count of at least 40 for each parachain in 15 relay chain blocks + // (2.66 candidates per para per relay chain block). // Note that only blocks after the first session change and blocks that don't contain a session // change will be counted. assert_para_throughput( &relay_client, 15, - [(2100, 42..46), (2200, 42..46)].into_iter().collect(), + [(2100, 40..46), (2200, 40..46)].into_iter().collect(), ) .await?; + // Assert the parachain finalized block height is also on par with the number of backed + // candidates. + assert_finalized_block_height(¶_node_elastic.wait_client().await?, 37..46).await?; + assert_finalized_block_height(¶_node_elastic_mvp.wait_client().await?, 37..46).await?; + log::info!("Test finished successfully"); Ok(()) diff --git a/polkadot/zombienet_tests/elastic_scaling/0001-basic-3cores-6s-blocks.toml b/polkadot/zombienet_tests/elastic_scaling/0001-basic-3cores-6s-blocks.toml deleted file mode 100644 index 611978a33a5f..000000000000 --- a/polkadot/zombienet_tests/elastic_scaling/0001-basic-3cores-6s-blocks.toml +++ /dev/null @@ -1,49 +0,0 @@ -[settings] -timeout = 1000 - -[relaychain.genesis.runtimeGenesis.patch.configuration.config.async_backing_params] - max_candidate_depth = 6 - allowed_ancestry_len = 2 - -[relaychain.genesis.runtimeGenesis.patch.configuration.config.scheduler_params] - max_validators_per_core = 1 - num_cores = 3 - -[relaychain.genesis.runtimeGenesis.patch.configuration.config.approval_voting_params] - max_approval_coalesce_count = 5 - -[relaychain] -default_image = "{{ZOMBIENET_INTEGRATION_TEST_IMAGE}}" -chain = "rococo-local" -default_command = "polkadot" - - [relaychain.default_resources] - limits = { memory = "4G", cpu = "3" } - requests = { memory = "4G", cpu = "3" } - - [[relaychain.node_groups]] - name = "elastic-validator" - count = 5 - args = [ "-lparachain=debug,parachain::candidate-backing=trace,parachain::provisioner=trace,parachain::prospective-parachains=trace,runtime=debug"] - -{% for id in range(2000,2002) %} -[[parachains]] -id = {{id}} -addToGenesis = true - [parachains.default_resources] - limits = { memory = "4G", cpu = "3" } - requests = { memory = "4G", cpu = "3" } - - [parachains.collator] - name = "some-parachain" - image = "{{COL_IMAGE}}" - command = "adder-collator" - args = ["-lparachain::collation-generation=trace,parachain::collator-protocol=trace,parachain=debug"] - -{% endfor %} - -# This represents the layout of the adder collator block header. -[types.Header] -number = "u64" -parent_hash = "Hash" -post_state = "Hash" diff --git a/polkadot/zombienet_tests/elastic_scaling/0001-basic-3cores-6s-blocks.zndsl b/polkadot/zombienet_tests/elastic_scaling/0001-basic-3cores-6s-blocks.zndsl deleted file mode 100644 index d47ef8f415f7..000000000000 --- a/polkadot/zombienet_tests/elastic_scaling/0001-basic-3cores-6s-blocks.zndsl +++ /dev/null @@ -1,28 +0,0 @@ -Description: Test with adder collator using 3 cores and async backing -Network: ./0001-basic-3cores-6s-blocks.toml -Creds: config - -# Check authority status. -elastic-validator-0: reports node_roles is 4 -elastic-validator-1: reports node_roles is 4 -elastic-validator-2: reports node_roles is 4 -elastic-validator-3: reports node_roles is 4 -elastic-validator-4: reports node_roles is 4 - - -# Register 2 extra cores to this some-parachain. -elastic-validator-0: js-script ./assign-core.js with "0,2000,57600" return is 0 within 600 seconds -elastic-validator-0: js-script ./assign-core.js with "1,2000,57600" return is 0 within 600 seconds - -# Wait for 20 relay chain blocks -elastic-validator-0: reports substrate_block_height{status="best"} is at least 20 within 600 seconds - -# Non elastic parachain should progress normally -some-parachain-1: count of log lines containing "Parachain velocity: 1" is at least 5 within 20 seconds -# Sanity -some-parachain-1: count of log lines containing "Parachain velocity: 2" is 0 - -# Parachain should progress 3 blocks per relay chain block ideally, however CI might not be -# the most performant environment so we'd just use a lower bound of 2 blocks per RCB -elastic-validator-0: parachain 2000 block height is at least 20 within 200 seconds - diff --git a/polkadot/zombienet_tests/elastic_scaling/0002-elastic-scaling-doesnt-break-parachains.toml b/polkadot/zombienet_tests/elastic_scaling/0002-elastic-scaling-doesnt-break-parachains.toml deleted file mode 100644 index 9b3576eaa3c2..000000000000 --- a/polkadot/zombienet_tests/elastic_scaling/0002-elastic-scaling-doesnt-break-parachains.toml +++ /dev/null @@ -1,40 +0,0 @@ -[settings] -timeout = 1000 -bootnode = true - -[relaychain.genesis.runtimeGenesis.patch.configuration.config] - needed_approvals = 4 - -[relaychain.genesis.runtimeGenesis.patch.configuration.config.scheduler_params] - max_validators_per_core = 2 - num_cores = 2 - -[relaychain] -default_image = "{{ZOMBIENET_INTEGRATION_TEST_IMAGE}}" -chain = "rococo-local" -default_command = "polkadot" - -[relaychain.default_resources] -limits = { memory = "4G", cpu = "2" } -requests = { memory = "2G", cpu = "1" } - - [[relaychain.nodes]] - name = "alice" - validator = "true" - - [[relaychain.node_groups]] - name = "validator" - count = 3 - args = [ "-lparachain=debug,runtime=debug"] - -[[parachains]] -id = 2000 -default_command = "polkadot-parachain" -add_to_genesis = false -register_para = true -onboard_as_parachain = false - - [parachains.collator] - name = "collator2000" - command = "polkadot-parachain" - args = [ "-lparachain=debug" ] diff --git a/polkadot/zombienet_tests/elastic_scaling/0002-elastic-scaling-doesnt-break-parachains.zndsl b/polkadot/zombienet_tests/elastic_scaling/0002-elastic-scaling-doesnt-break-parachains.zndsl deleted file mode 100644 index 7ba896e1c903..000000000000 --- a/polkadot/zombienet_tests/elastic_scaling/0002-elastic-scaling-doesnt-break-parachains.zndsl +++ /dev/null @@ -1,20 +0,0 @@ -Description: Test that a paraid acquiring multiple cores does not brick itself if ElasticScalingMVP feature is enabled in genesis -Network: ./0002-elastic-scaling-doesnt-break-parachains.toml -Creds: config - -# Check authority status. -validator: reports node_roles is 4 - -validator: reports substrate_block_height{status="finalized"} is at least 10 within 100 seconds - -# Ensure parachain was able to make progress. -validator: parachain 2000 block height is at least 10 within 200 seconds - -# Register the second core assigned to this parachain. -alice: js-script ./assign-core.js with "0,2000,57600" return is 0 within 600 seconds -alice: js-script ./assign-core.js with "0,2000,57600" return is 0 within 600 seconds - -validator: reports substrate_block_height{status="finalized"} is at least 35 within 100 seconds - -# Ensure parachain is now making progress. -validator: parachain 2000 block height is at least 30 within 200 seconds diff --git a/polkadot/zombienet_tests/elastic_scaling/assign-core.js b/polkadot/zombienet_tests/elastic_scaling/assign-core.js deleted file mode 120000 index eeb6402c06f5..000000000000 --- a/polkadot/zombienet_tests/elastic_scaling/assign-core.js +++ /dev/null @@ -1 +0,0 @@ -../assign-core.js \ No newline at end of file From 8c1040084ad5c2db6a45dadbc0fcdafdb9727b68 Mon Sep 17 00:00:00 2001 From: alindima Date: Wed, 4 Dec 2024 17:08:19 +0200 Subject: [PATCH 2/4] more work --- .gitlab/pipeline/zombienet/polkadot.yml | 25 ++++--- .../tests/elastic_scaling/basic_3cores.rs | 5 +- .../doesnt_break_parachains.rs | 5 +- .../elastic_scaling/mixed_receipt_versions.rs | 5 +- .../tests/elastic_scaling/mod.rs | 4 -- .../elastic_scaling/slot_based_3cores.rs | 5 +- .../tests/functional/mod.rs | 4 ++ .../tests/functional/sync_backing.rs | 72 +++++++++++++++++++ .../tests/{elastic_scaling => }/helpers.rs | 6 +- polkadot/zombienet-sdk-tests/tests/lib.rs | 5 ++ .../tests/smoke/coretime_revenue.rs | 21 +++--- .../functional/0017-sync-backing.toml | 48 ------------- .../functional/0017-sync-backing.zndsl | 22 ------ 13 files changed, 121 insertions(+), 106 deletions(-) create mode 100644 polkadot/zombienet-sdk-tests/tests/functional/mod.rs create mode 100644 polkadot/zombienet-sdk-tests/tests/functional/sync_backing.rs rename polkadot/zombienet-sdk-tests/tests/{elastic_scaling => }/helpers.rs (94%) delete mode 100644 polkadot/zombienet_tests/functional/0017-sync-backing.toml delete mode 100644 polkadot/zombienet_tests/functional/0017-sync-backing.zndsl diff --git a/.gitlab/pipeline/zombienet/polkadot.yml b/.gitlab/pipeline/zombienet/polkadot.yml index 5ec4fa036d97..2c4049aaedfd 100644 --- a/.gitlab/pipeline/zombienet/polkadot.yml +++ b/.gitlab/pipeline/zombienet/polkadot.yml @@ -209,14 +209,6 @@ zombienet-polkadot-functional-0015-coretime-shared-core: --local-dir="${LOCAL_DIR}/functional" --test="0016-approval-voting-parallel.zndsl" -zombienet-polkadot-functional-0017-sync-backing: - extends: - - .zombienet-polkadot-common - script: - - /home/nonroot/zombie-net/scripts/ci/run-test-local-env-manager.sh - --local-dir="${LOCAL_DIR}/functional" - --test="0017-sync-backing.zndsl" - zombienet-polkadot-functional-0018-shared-core-idle-parachain: extends: - .zombienet-polkadot-common @@ -403,7 +395,6 @@ zombienet-polkadot-elastic-scaling-doesnt-break-parachains: artifacts: true before_script: - !reference [ ".zombienet-polkadot-common", "before_script" ] - - export CUMULUS_IMAGE="docker.io/paritypr/test-parachain:${PIPELINE_IMAGE_TAG}" script: # we want to use `--no-capture` in zombienet tests. - unset NEXTEST_FAILURE_OUTPUT @@ -424,3 +415,19 @@ zombienet-polkadot-elastic-scaling-basic-3cores: - unset NEXTEST_FAILURE_OUTPUT - unset NEXTEST_SUCCESS_OUTPUT - cargo nextest run --archive-file ./artifacts/polkadot-zombienet-tests.tar.zst --no-capture -- elastic_scaling::basic_3cores::basic_3cores_test + +zombienet-polkadot-functional-sync-backing: + extends: + - .zombienet-polkadot-common + needs: + - job: build-polkadot-zombienet-tests + artifacts: true + before_script: + - !reference [ ".zombienet-polkadot-common", "before_script" ] + # Hardcoded to an old polkadot-parachain image, pre async backing. + - export CUMULUS_IMAGE="docker.io/paritypr/polkadot-parachain-debug:master-99623e62" + script: + # we want to use `--no-capture` in zombienet tests. + - unset NEXTEST_FAILURE_OUTPUT + - unset NEXTEST_SUCCESS_OUTPUT + - cargo nextest run --archive-file ./artifacts/polkadot-zombienet-tests.tar.zst --no-capture -- elastic_scaling::sync_backing::sync_backing_test 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 267a38285d4b..3371674bef03 100644 --- a/polkadot/zombienet-sdk-tests/tests/elastic_scaling/basic_3cores.rs +++ b/polkadot/zombienet-sdk-tests/tests/elastic_scaling/basic_3cores.rs @@ -6,9 +6,8 @@ use anyhow::anyhow; -use super::{ - helpers::assert_para_throughput, - rococo, +use crate::helpers::{ + assert_para_throughput, rococo, rococo::runtime_types::{ pallet_broker::coretime_interface::CoreAssignment, polkadot_runtime_parachains::assigner_coretime::PartsOf57600, 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 df002d64e40e..97ac88a00332 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 @@ -6,9 +6,8 @@ use anyhow::anyhow; -use super::{ - helpers::{assert_finalized_block_height, assert_para_throughput}, - rococo, +use crate::helpers::{ + assert_finalized_block_height, assert_para_throughput, rococo, rococo::runtime_types::{ pallet_broker::coretime_interface::CoreAssignment, polkadot_runtime_parachains::assigner_coretime::PartsOf57600, diff --git a/polkadot/zombienet-sdk-tests/tests/elastic_scaling/mixed_receipt_versions.rs b/polkadot/zombienet-sdk-tests/tests/elastic_scaling/mixed_receipt_versions.rs index d219241e8df7..f84daf9f3c78 100644 --- a/polkadot/zombienet-sdk-tests/tests/elastic_scaling/mixed_receipt_versions.rs +++ b/polkadot/zombienet-sdk-tests/tests/elastic_scaling/mixed_receipt_versions.rs @@ -6,9 +6,8 @@ use anyhow::anyhow; -use super::{ - helpers::{assert_finalized_block_height, assert_para_throughput}, - rococo, +use crate::helpers::{ + assert_finalized_block_height, assert_para_throughput, rococo, rococo::runtime_types::{ pallet_broker::coretime_interface::CoreAssignment, polkadot_runtime_parachains::assigner_coretime::PartsOf57600, diff --git a/polkadot/zombienet-sdk-tests/tests/elastic_scaling/mod.rs b/polkadot/zombienet-sdk-tests/tests/elastic_scaling/mod.rs index bd6c3961ace9..58550092168e 100644 --- a/polkadot/zombienet-sdk-tests/tests/elastic_scaling/mod.rs +++ b/polkadot/zombienet-sdk-tests/tests/elastic_scaling/mod.rs @@ -1,11 +1,7 @@ // Copyright (C) Parity Technologies (UK) Ltd. // SPDX-License-Identifier: Apache-2.0 -#[subxt::subxt(runtime_metadata_path = "metadata-files/rococo-local.scale")] -pub mod rococo {} - mod basic_3cores; mod doesnt_break_parachains; -mod helpers; mod mixed_receipt_versions; mod slot_based_3cores; 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 4e59fbcfbe23..59bb1369aff9 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 @@ -6,9 +6,8 @@ use anyhow::anyhow; -use super::{ - helpers::{assert_finalized_block_height, assert_para_throughput}, - rococo, +use crate::helpers::{ + assert_finalized_block_height, assert_para_throughput, rococo, rococo::runtime_types::{ pallet_broker::coretime_interface::CoreAssignment, polkadot_runtime_parachains::assigner_coretime::PartsOf57600, diff --git a/polkadot/zombienet-sdk-tests/tests/functional/mod.rs b/polkadot/zombienet-sdk-tests/tests/functional/mod.rs new file mode 100644 index 000000000000..d059fa75ae2e --- /dev/null +++ b/polkadot/zombienet-sdk-tests/tests/functional/mod.rs @@ -0,0 +1,4 @@ +// Copyright (C) Parity Technologies (UK) Ltd. +// SPDX-License-Identifier: Apache-2.0 + +mod sync_backing; diff --git a/polkadot/zombienet-sdk-tests/tests/functional/sync_backing.rs b/polkadot/zombienet-sdk-tests/tests/functional/sync_backing.rs new file mode 100644 index 000000000000..6d45df259df3 --- /dev/null +++ b/polkadot/zombienet-sdk-tests/tests/functional/sync_backing.rs @@ -0,0 +1,72 @@ +// Copyright (C) Parity Technologies (UK) Ltd. +// SPDX-License-Identifier: Apache-2.0 + +// Test we are producing 12-second parachain blocks if using an old collator, pre async-backing. + +use anyhow::anyhow; + +use crate::helpers::{assert_finalized_block_height, assert_para_throughput}; +use serde_json::json; +use subxt::{OnlineClient, PolkadotConfig}; +use zombienet_sdk::NetworkConfigBuilder; + +#[tokio::test(flavor = "multi_thread")] +async fn sync_backing_test() -> Result<(), anyhow::Error> { + let _ = env_logger::try_init_from_env( + env_logger::Env::default().filter_or(env_logger::DEFAULT_FILTER_ENV, "info"), + ); + + let images = zombienet_sdk::environment::get_images_from_env(); + + let config = NetworkConfigBuilder::new() + .with_relaychain(|r| { + let r = r + .with_chain("rococo-local") + .with_default_command("polkadot") + .with_default_image(images.polkadot.as_str()) + .with_default_args(vec![("-lparachain=debug").into()]) + .with_genesis_overrides(json!({ + "configuration": { + "config": { + "scheduler_params": { + "group_rotation_frequency": 4, + }, + } + } + })) + .with_node(|node| node.with_name("validator-0")); + + (1..5).fold(r, |acc, i| acc.with_node(|node| node.with_name(&format!("validator-{i}")))) + }) + .with_parachain(|p| { + p.with_id(2000) + .with_default_command("polkadot-parachain") + // This must be a very old polkadot-parachain image, pre async backing + .with_default_image(images.cumulus.as_str()) + .with_default_args(vec![("-lparachain=debug,aura=debug").into()]) + .with_collator(|n| n.with_name("collator-2000")) + }) + .build() + .map_err(|e| { + let errs = e.into_iter().map(|e| e.to_string()).collect::>().join(" "); + anyhow!("config errs: {errs}") + })?; + + let spawn_fn = zombienet_sdk::environment::get_spawn_fn(); + let network = spawn_fn(config).await?; + + let relay_node = network.get_node("validator-0")?; + let para_node = network.get_node("collator-2000")?; + + let relay_client: OnlineClient = relay_node.wait_client().await?; + + assert_para_throughput(&relay_client, 15, [(2000, 6..9)].into_iter().collect()).await?; + + // Assert the parachain finalized block height is also on par with the number of backed + // candidates. + assert_finalized_block_height(¶_node.wait_client().await?, 6..9).await?; + + log::info!("Test finished successfully"); + + Ok(()) +} diff --git a/polkadot/zombienet-sdk-tests/tests/elastic_scaling/helpers.rs b/polkadot/zombienet-sdk-tests/tests/helpers.rs similarity index 94% rename from polkadot/zombienet-sdk-tests/tests/elastic_scaling/helpers.rs rename to polkadot/zombienet-sdk-tests/tests/helpers.rs index 7e1341990fc1..2d5a055b0bcc 100644 --- a/polkadot/zombienet-sdk-tests/tests/elastic_scaling/helpers.rs +++ b/polkadot/zombienet-sdk-tests/tests/helpers.rs @@ -1,10 +1,12 @@ // Copyright (C) Parity Technologies (UK) Ltd. // SPDX-License-Identifier: Apache-2.0 -use super::rococo; use std::{collections::HashMap, ops::Range}; use subxt::{OnlineClient, PolkadotConfig}; +#[subxt::subxt(runtime_metadata_path = "metadata-files/rococo-local.scale")] +pub mod rococo {} + // Helper function for asserting the throughput of parachains (total number of backed candidates in // a window of relay chain blocks), after the first session change. pub async fn assert_para_throughput( @@ -67,7 +69,7 @@ pub async fn assert_finalized_block_height( ) -> Result<(), anyhow::Error> { if let Some(block) = client.blocks().subscribe_finalized().await?.next().await { let height = block?.number(); - log::info!("Finalized block number number {height}"); + log::info!("Finalized block number {height}"); assert!( expected_range.contains(&height), diff --git a/polkadot/zombienet-sdk-tests/tests/lib.rs b/polkadot/zombienet-sdk-tests/tests/lib.rs index 977e0f90b1c9..9feb9775e450 100644 --- a/polkadot/zombienet-sdk-tests/tests/lib.rs +++ b/polkadot/zombienet-sdk-tests/tests/lib.rs @@ -1,7 +1,12 @@ // Copyright (C) Parity Technologies (UK) Ltd. // SPDX-License-Identifier: Apache-2.0 +#[cfg(feature = "zombie-metadata")] +mod helpers; + #[cfg(feature = "zombie-metadata")] mod elastic_scaling; #[cfg(feature = "zombie-metadata")] +mod functional; +#[cfg(feature = "zombie-metadata")] mod smoke; diff --git a/polkadot/zombienet-sdk-tests/tests/smoke/coretime_revenue.rs b/polkadot/zombienet-sdk-tests/tests/smoke/coretime_revenue.rs index 2da2436a1111..798a78620bc8 100644 --- a/polkadot/zombienet-sdk-tests/tests/smoke/coretime_revenue.rs +++ b/polkadot/zombienet-sdk-tests/tests/smoke/coretime_revenue.rs @@ -16,15 +16,20 @@ pub mod rococo {} #[subxt::subxt(runtime_metadata_path = "metadata-files/coretime-rococo-local.scale")] mod coretime_rococo {} -use rococo::runtime_types::{ - staging_xcm::v4::{ - asset::{Asset, AssetId, Assets, Fungibility}, - junction::Junction, - junctions::Junctions, - location::Location, +use crate::helpers::rococo::{ + self as rococo_api, + runtime_types::{ + polkadot_parachain_primitives::primitives, + staging_xcm::v4::{ + asset::{Asset, AssetId, Assets, Fungibility}, + junction::Junction, + junctions::Junctions, + location::Location, + }, + xcm::{VersionedAssets, VersionedLocation}, }, - xcm::{VersionedAssets, VersionedLocation}, }; + use serde_json::json; use std::{fmt::Display, sync::Arc}; use subxt::{events::StaticEvent, utils::AccountId32, OnlineClient, PolkadotConfig}; @@ -41,8 +46,6 @@ use coretime_rococo::{ }, }; -use rococo::{self as rococo_api, runtime_types::polkadot_parachain_primitives::primitives}; - type CoretimeRuntimeCall = coretime_api::runtime_types::coretime_rococo_runtime::RuntimeCall; type CoretimeUtilityCall = coretime_api::runtime_types::pallet_utility::pallet::Call; type CoretimeBrokerCall = coretime_api::runtime_types::pallet_broker::pallet::Call; diff --git a/polkadot/zombienet_tests/functional/0017-sync-backing.toml b/polkadot/zombienet_tests/functional/0017-sync-backing.toml deleted file mode 100644 index 2550054c8dad..000000000000 --- a/polkadot/zombienet_tests/functional/0017-sync-backing.toml +++ /dev/null @@ -1,48 +0,0 @@ -[settings] -timeout = 1000 - -[relaychain] -default_image = "{{ZOMBIENET_INTEGRATION_TEST_IMAGE}}" -chain = "rococo-local" - -[relaychain.genesis.runtimeGenesis.patch.configuration.config.async_backing_params] - max_candidate_depth = 0 - allowed_ancestry_len = 0 - -[relaychain.genesis.runtimeGenesis.patch.configuration.config.scheduler_params] - lookahead = 2 - group_rotation_frequency = 4 - -[relaychain.default_resources] -limits = { memory = "4G", cpu = "2" } -requests = { memory = "2G", cpu = "1" } - - [[relaychain.node_groups]] - name = "alice" - args = [ "-lparachain=debug" ] - count = 10 - -[[parachains]] -id = 2000 -addToGenesis = true - - [parachains.collator] - name = "collator01" - image = "{{COL_IMAGE}}" - command = "adder-collator" - args = ["-lparachain=debug"] - -[[parachains]] -id = 2001 -cumulus_based = true - - [parachains.collator] - name = "collator02" - image = "{{CUMULUS_IMAGE}}" - command = "polkadot-parachain" - args = ["-lparachain=debug"] - -[types.Header] -number = "u64" -parent_hash = "Hash" -post_state = "Hash" \ No newline at end of file diff --git a/polkadot/zombienet_tests/functional/0017-sync-backing.zndsl b/polkadot/zombienet_tests/functional/0017-sync-backing.zndsl deleted file mode 100644 index a53de784b2d1..000000000000 --- a/polkadot/zombienet_tests/functional/0017-sync-backing.zndsl +++ /dev/null @@ -1,22 +0,0 @@ -Description: Test we are producing 12-second parachain blocks if sync backing is configured -Network: ./0017-sync-backing.toml -Creds: config - -# Check authority status. -alice: reports node_roles is 4 - -# Ensure parachains are registered. -alice: parachain 2000 is registered within 60 seconds -alice: parachain 2001 is registered within 60 seconds - -# Ensure parachains made progress. -alice: reports substrate_block_height{status="finalized"} is at least 10 within 100 seconds - -# This parachains should produce blocks at 12s clip, let's assume an 14s rate, allowing for -# some slots to be missed on slower machines -alice: parachain 2000 block height is at least 21 within 300 seconds -alice: parachain 2000 block height is lower than 25 within 2 seconds - -# This should already have produced the needed blocks -alice: parachain 2001 block height is at least 21 within 10 seconds -alice: parachain 2001 block height is lower than 25 within 2 seconds From d22d42e65881aae44cb7ad15c87944b6e87b9f6d Mon Sep 17 00:00:00 2001 From: alindima Date: Tue, 10 Dec 2024 16:40:42 +0200 Subject: [PATCH 3/4] move helpers to folder --- .../zombienet-sdk-tests/tests/{helpers.rs => helpers/mod.rs} | 0 polkadot/zombienet-sdk-tests/tests/smoke/coretime_revenue.rs | 2 -- 2 files changed, 2 deletions(-) rename polkadot/zombienet-sdk-tests/tests/{helpers.rs => helpers/mod.rs} (100%) diff --git a/polkadot/zombienet-sdk-tests/tests/helpers.rs b/polkadot/zombienet-sdk-tests/tests/helpers/mod.rs similarity index 100% rename from polkadot/zombienet-sdk-tests/tests/helpers.rs rename to polkadot/zombienet-sdk-tests/tests/helpers/mod.rs diff --git a/polkadot/zombienet-sdk-tests/tests/smoke/coretime_revenue.rs b/polkadot/zombienet-sdk-tests/tests/smoke/coretime_revenue.rs index 798a78620bc8..59a71a83e01e 100644 --- a/polkadot/zombienet-sdk-tests/tests/smoke/coretime_revenue.rs +++ b/polkadot/zombienet-sdk-tests/tests/smoke/coretime_revenue.rs @@ -10,8 +10,6 @@ //! normal parachain runtime WILL mess things up. use anyhow::anyhow; -#[subxt::subxt(runtime_metadata_path = "metadata-files/rococo-local.scale")] -pub mod rococo {} #[subxt::subxt(runtime_metadata_path = "metadata-files/coretime-rococo-local.scale")] mod coretime_rococo {} From f626c8274556bbbb48318fd2a957c05b52a1afdd Mon Sep 17 00:00:00 2001 From: alindima Date: Tue, 10 Dec 2024 18:30:03 +0200 Subject: [PATCH 4/4] rewrite async-backing-6-seconds-rate test --- .gitlab/pipeline/zombienet/polkadot.yml | 24 +++-- .../async_backing_6_seconds_rate.rs | 92 +++++++++++++++++++ .../tests/functional/mod.rs | 1 + .../0011-async-backing-6-seconds-rate.toml | 54 ----------- .../0011-async-backing-6-seconds-rate.zndsl | 20 ---- 5 files changed, 108 insertions(+), 83 deletions(-) create mode 100644 polkadot/zombienet-sdk-tests/tests/functional/async_backing_6_seconds_rate.rs delete mode 100644 polkadot/zombienet_tests/functional/0011-async-backing-6-seconds-rate.toml delete mode 100644 polkadot/zombienet_tests/functional/0011-async-backing-6-seconds-rate.zndsl diff --git a/.gitlab/pipeline/zombienet/polkadot.yml b/.gitlab/pipeline/zombienet/polkadot.yml index 2c4049aaedfd..1843637c834e 100644 --- a/.gitlab/pipeline/zombienet/polkadot.yml +++ b/.gitlab/pipeline/zombienet/polkadot.yml @@ -158,14 +158,6 @@ zombienet-polkadot-functional-0010-validator-disabling: --local-dir="${LOCAL_DIR}/functional" --test="0010-validator-disabling.zndsl" -.zombienet-polkadot-functional-0011-async-backing-6-seconds-rate: - extends: - - .zombienet-polkadot-common - script: - - /home/nonroot/zombie-net/scripts/ci/run-test-local-env-manager.sh - --local-dir="${LOCAL_DIR}/functional" - --test="0011-async-backing-6-seconds-rate.zndsl" - .zombienet-polkadot-functional-0012-spam-statement-distribution-requests: extends: - .zombienet-polkadot-common @@ -430,4 +422,18 @@ zombienet-polkadot-functional-sync-backing: # we want to use `--no-capture` in zombienet tests. - unset NEXTEST_FAILURE_OUTPUT - unset NEXTEST_SUCCESS_OUTPUT - - cargo nextest run --archive-file ./artifacts/polkadot-zombienet-tests.tar.zst --no-capture -- elastic_scaling::sync_backing::sync_backing_test + - cargo nextest run --archive-file ./artifacts/polkadot-zombienet-tests.tar.zst --no-capture -- functional::sync_backing::sync_backing_test + +zombienet-polkadot-functional-async-backing-6-seconds-rate: + extends: + - .zombienet-polkadot-common + needs: + - job: build-polkadot-zombienet-tests + artifacts: true + before_script: + - !reference [ ".zombienet-polkadot-common", "before_script" ] + script: + # we want to use `--no-capture` in zombienet tests. + - unset NEXTEST_FAILURE_OUTPUT + - unset NEXTEST_SUCCESS_OUTPUT + - cargo nextest run --archive-file ./artifacts/polkadot-zombienet-tests.tar.zst --no-capture -- functional::async_backing_6_seconds_rate::async_backing_6_seconds_rate_test 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 new file mode 100644 index 000000000000..419d8ccfcffe --- /dev/null +++ b/polkadot/zombienet-sdk-tests/tests/functional/async_backing_6_seconds_rate.rs @@ -0,0 +1,92 @@ +// Copyright (C) Parity Technologies (UK) Ltd. +// SPDX-License-Identifier: Apache-2.0 + +// Test we are producing 12-second parachain blocks if using an old collator, pre async-backing. + +use anyhow::anyhow; + +use crate::helpers::{assert_finalized_block_height, assert_para_throughput}; +use serde_json::json; +use subxt::{OnlineClient, PolkadotConfig}; +use zombienet_sdk::NetworkConfigBuilder; + +#[tokio::test(flavor = "multi_thread")] +async fn async_backing_6_seconds_rate_test() -> Result<(), anyhow::Error> { + let _ = env_logger::try_init_from_env( + env_logger::Env::default().filter_or(env_logger::DEFAULT_FILTER_ENV, "info"), + ); + + let images = zombienet_sdk::environment::get_images_from_env(); + + let config = NetworkConfigBuilder::new() + .with_relaychain(|r| { + let r = r + .with_chain("rococo-local") + .with_default_command("polkadot") + .with_default_image(images.polkadot.as_str()) + .with_default_args(vec![("-lparachain=debug").into()]) + .with_genesis_overrides(json!({ + "configuration": { + "config": { + "scheduler_params": { + "group_rotation_frequency": 4, + "lookahead": 2, + "max_candidate_depth": 3, + "allowed_ancestry_len": 2, + }, + } + } + })) + .with_node(|node| node.with_name("validator-0")); + + (1..12) + .fold(r, |acc, i| acc.with_node(|node| node.with_name(&format!("validator-{i}")))) + }) + .with_parachain(|p| { + p.with_id(2000) + .with_default_command("adder-collator") + .with_default_image( + std::env::var("COL_IMAGE") + .unwrap_or("docker.io/paritypr/colander:latest".to_string()) + .as_str(), + ) + .cumulus_based(false) + .with_default_args(vec![("-lparachain=debug").into()]) + .with_collator(|n| n.with_name("collator-adder-2000")) + }) + .with_parachain(|p| { + p.with_id(2001) + .with_default_command("polkadot-parachain") + .with_default_image(images.cumulus.as_str()) + .with_default_args(vec![("-lparachain=debug,aura=debug").into()]) + .with_collator(|n| n.with_name("collator-2001")) + }) + .build() + .map_err(|e| { + let errs = e.into_iter().map(|e| e.to_string()).collect::>().join(" "); + anyhow!("config errs: {errs}") + })?; + + let spawn_fn = zombienet_sdk::environment::get_spawn_fn(); + let network = spawn_fn(config).await?; + + let relay_node = network.get_node("validator-0")?; + let para_node_2001 = network.get_node("collator-2001")?; + + let relay_client: OnlineClient = relay_node.wait_client().await?; + + assert_para_throughput( + &relay_client, + 15, + [(2000, 11..16), (2001, 11..16)].into_iter().collect(), + ) + .await?; + + // Assert the parachain finalized block height is also on par with the number of backed + // candidates. We can only do this for the collator based on cumulus. + assert_finalized_block_height(¶_node_2001.wait_client().await?, 10..16).await?; + + log::info!("Test finished successfully"); + + Ok(()) +} diff --git a/polkadot/zombienet-sdk-tests/tests/functional/mod.rs b/polkadot/zombienet-sdk-tests/tests/functional/mod.rs index d059fa75ae2e..ecdab38e1d28 100644 --- a/polkadot/zombienet-sdk-tests/tests/functional/mod.rs +++ b/polkadot/zombienet-sdk-tests/tests/functional/mod.rs @@ -1,4 +1,5 @@ // Copyright (C) Parity Technologies (UK) Ltd. // SPDX-License-Identifier: Apache-2.0 +mod async_backing_6_seconds_rate; mod sync_backing; diff --git a/polkadot/zombienet_tests/functional/0011-async-backing-6-seconds-rate.toml b/polkadot/zombienet_tests/functional/0011-async-backing-6-seconds-rate.toml deleted file mode 100644 index b776622fdce3..000000000000 --- a/polkadot/zombienet_tests/functional/0011-async-backing-6-seconds-rate.toml +++ /dev/null @@ -1,54 +0,0 @@ -[settings] -timeout = 1000 - -[relaychain] -default_image = "{{ZOMBIENET_INTEGRATION_TEST_IMAGE}}" -chain = "rococo-local" - -[relaychain.genesis.runtimeGenesis.patch.configuration.config] - needed_approvals = 4 - relay_vrf_modulo_samples = 6 - -[relaychain.genesis.runtimeGenesis.patch.configuration.config.async_backing_params] - max_candidate_depth = 3 - allowed_ancestry_len = 2 - -[relaychain.genesis.runtimeGenesis.patch.configuration.config.scheduler_params] - lookahead = 2 - group_rotation_frequency = 4 - - -[relaychain.default_resources] -limits = { memory = "4G", cpu = "2" } -requests = { memory = "2G", cpu = "1" } - - [[relaychain.node_groups]] - name = "alice" - args = [ "-lparachain=debug" ] - count = 12 - -[[parachains]] -id = 2000 -addToGenesis = true -genesis_state_generator = "undying-collator export-genesis-state --pov-size=100000 --pvf-complexity=1" - - [parachains.collator] - name = "collator01" - image = "{{COL_IMAGE}}" - command = "undying-collator" - args = ["-lparachain=debug", "--pov-size=100000", "--pvf-complexity=1", "--parachain-id=2000"] - -[[parachains]] -id = 2001 -cumulus_based = true - - [parachains.collator] - name = "collator02" - image = "{{CUMULUS_IMAGE}}" - command = "polkadot-parachain" - args = ["-lparachain=debug"] - -[types.Header] -number = "u64" -parent_hash = "Hash" -post_state = "Hash" \ No newline at end of file diff --git a/polkadot/zombienet_tests/functional/0011-async-backing-6-seconds-rate.zndsl b/polkadot/zombienet_tests/functional/0011-async-backing-6-seconds-rate.zndsl deleted file mode 100644 index 0d01af82833e..000000000000 --- a/polkadot/zombienet_tests/functional/0011-async-backing-6-seconds-rate.zndsl +++ /dev/null @@ -1,20 +0,0 @@ -Description: Test we are producing blocks at 6 seconds clip -Network: ./0011-async-backing-6-seconds-rate.toml -Creds: config - -# Check authority status. -alice: reports node_roles is 4 - -# Ensure parachains are registered. -alice: parachain 2000 is registered within 60 seconds -alice: parachain 2001 is registered within 60 seconds - -# Ensure parachains made progress. -alice: reports substrate_block_height{status="finalized"} is at least 10 within 100 seconds - -# This parachains should produce blocks at 6s clip, let's assume an 8s rate, allowing for -# some slots to be missed on slower machines -alice: parachain 2000 block height is at least 30 within 240 seconds -# This should already have produced the needed blocks -alice: parachain 2001 block height is at least 30 within 6 seconds -