From 8c1040084ad5c2db6a45dadbc0fcdafdb9727b68 Mon Sep 17 00:00:00 2001 From: alindima Date: Wed, 4 Dec 2024 17:08:19 +0200 Subject: [PATCH] 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