From 4f898fcfb735973f873399631eadff7eeda10ecb Mon Sep 17 00:00:00 2001 From: alindima Date: Tue, 12 Nov 2024 13:45:49 +0200 Subject: [PATCH 01/27] add zombienet test for rfc 103 --- .gitlab/pipeline/zombienet/polkadot.yml | 13 +++++ .../testing/rococo-parachain/Cargo.toml | 2 +- cumulus/test/runtime/Cargo.toml | 1 + cumulus/test/runtime/build.rs | 8 ++++ cumulus/test/runtime/src/lib.rs | 5 ++ cumulus/test/service/src/chain_spec.rs | 10 ++++ cumulus/test/service/src/cli.rs | 8 +++- .../rococo/src/genesis_config_presets.rs | 4 +- .../westend/src/genesis_config_presets.rs | 3 +- .../0003-slot-based-3cores.toml | 48 +++++++++++++++++++ .../0003-slot-based-3cores.zndsl | 19 ++++++++ 11 files changed, 117 insertions(+), 4 deletions(-) create mode 100644 polkadot/zombienet_tests/elastic_scaling/0003-slot-based-3cores.toml create mode 100644 polkadot/zombienet_tests/elastic_scaling/0003-slot-based-3cores.zndsl diff --git a/.gitlab/pipeline/zombienet/polkadot.yml b/.gitlab/pipeline/zombienet/polkadot.yml index 3dab49a118e5..253be68c32cc 100644 --- a/.gitlab/pipeline/zombienet/polkadot.yml +++ b/.gitlab/pipeline/zombienet/polkadot.yml @@ -190,6 +190,19 @@ zombienet-polkadot-elastic-scaling-0002-elastic-scaling-doesnt-break-parachains: --local-dir="${LOCAL_DIR}/elastic_scaling" --test="0002-elastic-scaling-doesnt-break-parachains.zndsl" +zombienet-polkadot-elastic-scaling-0003-slot-based-3cores: + 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="0003-slot-based-3cores.zndsl" + .zombienet-polkadot-functional-0012-spam-statement-distribution-requests: extends: - .zombienet-polkadot-common diff --git a/cumulus/parachains/runtimes/testing/rococo-parachain/Cargo.toml b/cumulus/parachains/runtimes/testing/rococo-parachain/Cargo.toml index b0581c8d43ff..bbc1185db0d8 100644 --- a/cumulus/parachains/runtimes/testing/rococo-parachain/Cargo.toml +++ b/cumulus/parachains/runtimes/testing/rococo-parachain/Cargo.toml @@ -49,7 +49,7 @@ polkadot-runtime-common = { workspace = true } # Cumulus cumulus-pallet-aura-ext = { workspace = true } pallet-message-queue = { workspace = true } -cumulus-pallet-parachain-system = { workspace = true, features = ["experimental-ump-signals"] } +cumulus-pallet-parachain-system = { workspace = true } cumulus-pallet-xcm = { workspace = true } cumulus-pallet-xcmp-queue = { workspace = true } cumulus-ping = { workspace = true } diff --git a/cumulus/test/runtime/Cargo.toml b/cumulus/test/runtime/Cargo.toml index 8117e6e69709..b80170af3e83 100644 --- a/cumulus/test/runtime/Cargo.toml +++ b/cumulus/test/runtime/Cargo.toml @@ -96,3 +96,4 @@ std = [ ] increment-spec-version = [] elastic-scaling = [] +experimental-ump-signals = ["cumulus-pallet-parachain-system/experimental-ump-signals"] diff --git a/cumulus/test/runtime/build.rs b/cumulus/test/runtime/build.rs index 7a7fe8ffaa82..43e60c1074a0 100644 --- a/cumulus/test/runtime/build.rs +++ b/cumulus/test/runtime/build.rs @@ -29,6 +29,14 @@ fn main() { .with_current_project() .enable_feature("elastic-scaling") .import_memory() + .set_file_name("wasm_binary_elastic_scaling_mvp.rs") + .build(); + + WasmBuilder::new() + .with_current_project() + .enable_feature("elastic-scaling") + .enable_feature("experimental-ump-signals") + .import_memory() .set_file_name("wasm_binary_elastic_scaling.rs") .build(); } diff --git a/cumulus/test/runtime/src/lib.rs b/cumulus/test/runtime/src/lib.rs index b1649c410581..4abc10276af1 100644 --- a/cumulus/test/runtime/src/lib.rs +++ b/cumulus/test/runtime/src/lib.rs @@ -27,6 +27,11 @@ pub mod wasm_spec_version_incremented { include!(concat!(env!("OUT_DIR"), "/wasm_binary_spec_version_incremented.rs")); } +pub mod elastic_scaling_mvp { + #[cfg(feature = "std")] + include!(concat!(env!("OUT_DIR"), "/wasm_binary_elastic_scaling_mvp.rs")); +} + pub mod elastic_scaling { #[cfg(feature = "std")] include!(concat!(env!("OUT_DIR"), "/wasm_binary_elastic_scaling.rs")); diff --git a/cumulus/test/service/src/chain_spec.rs b/cumulus/test/service/src/chain_spec.rs index 3d4e4dca5f8d..5ebcc14592d7 100644 --- a/cumulus/test/service/src/chain_spec.rs +++ b/cumulus/test/service/src/chain_spec.rs @@ -116,3 +116,13 @@ pub fn get_elastic_scaling_chain_spec(id: Option) -> ChainSpec { .expect("WASM binary was not built, please build it!"), ) } + +/// Get the chain spec for a specific parachain ID. +pub fn get_elastic_scaling_mvp_chain_spec(id: Option) -> ChainSpec { + get_chain_spec_with_extra_endowed( + id, + Default::default(), + cumulus_test_runtime::elastic_scaling_mvp::WASM_BINARY + .expect("WASM binary was not built, please build it!"), + ) +} diff --git a/cumulus/test/service/src/cli.rs b/cumulus/test/service/src/cli.rs index 220b0449f339..e019089e70fe 100644 --- a/cumulus/test/service/src/cli.rs +++ b/cumulus/test/service/src/cli.rs @@ -262,10 +262,16 @@ impl SubstrateCli for TestCollatorCli { tracing::info!("Using default test service chain spec."); Box::new(cumulus_test_service::get_chain_spec(Some(ParaId::from(2000)))) as Box<_> }, + "elastic-scaling-mvp" => { + tracing::info!("Using elastic-scaling mvp chain spec."); + Box::new(cumulus_test_service::get_elastic_scaling_mvp_chain_spec(Some( + ParaId::from(2100), + ))) as Box<_> + }, "elastic-scaling" => { tracing::info!("Using elastic-scaling chain spec."); Box::new(cumulus_test_service::get_elastic_scaling_chain_spec(Some(ParaId::from( - 2100, + 2200, )))) as Box<_> }, path => { diff --git a/polkadot/runtime/rococo/src/genesis_config_presets.rs b/polkadot/runtime/rococo/src/genesis_config_presets.rs index bdbf6f37d92c..a96a509b0e4d 100644 --- a/polkadot/runtime/rococo/src/genesis_config_presets.rs +++ b/polkadot/runtime/rococo/src/genesis_config_presets.rs @@ -129,7 +129,9 @@ fn default_parachains_host_configuration( allowed_ancestry_len: 2, }, node_features: bitvec::vec::BitVec::from_element( - 1u8 << (FeatureIndex::ElasticScalingMVP as usize), + 1u8 << (FeatureIndex::ElasticScalingMVP as usize) | + 1u8 << (FeatureIndex::EnableAssignmentsV2 as usize) | + 1u8 << (FeatureIndex::CandidateReceiptV2 as usize), ), scheduler_params: SchedulerParams { lookahead: 2, diff --git a/polkadot/runtime/westend/src/genesis_config_presets.rs b/polkadot/runtime/westend/src/genesis_config_presets.rs index b8f7710089e0..ea5aff554e8c 100644 --- a/polkadot/runtime/westend/src/genesis_config_presets.rs +++ b/polkadot/runtime/westend/src/genesis_config_presets.rs @@ -133,7 +133,8 @@ fn default_parachains_host_configuration( }, node_features: bitvec::vec::BitVec::from_element( 1u8 << (FeatureIndex::ElasticScalingMVP as usize) | - 1u8 << (FeatureIndex::EnableAssignmentsV2 as usize), + 1u8 << (FeatureIndex::EnableAssignmentsV2 as usize) | + 1u8 << (FeatureIndex::CandidateReceiptV2 as usize), ), scheduler_params: SchedulerParams { lookahead: 2, diff --git a/polkadot/zombienet_tests/elastic_scaling/0003-slot-based-3cores.toml b/polkadot/zombienet_tests/elastic_scaling/0003-slot-based-3cores.toml new file mode 100644 index 000000000000..67b38cbed789 --- /dev/null +++ b/polkadot/zombienet_tests/elastic_scaling/0003-slot-based-3cores.toml @@ -0,0 +1,48 @@ +[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 = 4 + +[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 = 6 + args = [ "-lparachain=debug,parachain::candidate-backing=trace,parachain::provisioner=trace,parachain::prospective-parachains=trace,runtime=debug"] + +# First collator uses elastic scaling MVP. +[[parachains]] +id = 2100 +chain = "elastic-scaling-mvp" +add_to_genesis = true + + [[parachains.collators]] + name = "collator-elastic-mvp" + image = "{{COL_IMAGE}}" + command = "test-parachain" + args = ["-laura=trace,runtime=info,cumulus-consensus=trace,consensus::common=trace,parachain::collation-generation=trace,parachain::collator-protocol=trace,parachain=debug", "--force-authoring", "--experimental-use-slot-based"] + +# Second collator uses UMP commitments (RFC 103). +[[parachains]] +id = 2200 +chain = "elastic-scaling" +add_to_genesis = true + + [[parachains.collators]] + name = "collator-elastic" + image = "{{COL_IMAGE}}" + command = "test-parachain" + args = ["-laura=trace,runtime=info,cumulus-consensus=trace,consensus::common=trace,parachain::collation-generation=trace,parachain::collator-protocol=trace,parachain=debug", "--force-authoring", "--experimental-use-slot-based"] diff --git a/polkadot/zombienet_tests/elastic_scaling/0003-slot-based-3cores.zndsl b/polkadot/zombienet_tests/elastic_scaling/0003-slot-based-3cores.zndsl new file mode 100644 index 000000000000..57f2365f7657 --- /dev/null +++ b/polkadot/zombienet_tests/elastic_scaling/0003-slot-based-3cores.zndsl @@ -0,0 +1,19 @@ +Description: Test with slot-based collator using 3 cores and async backing +Network: ./0003-slot-based-3cores.toml +Creds: config + +elastic-validator: is up +collator-elastic: is up +collator-elastic-mvp: is up + +# Register 2 extra cores to each parachain. +elastic-validator-0: js-script ./assign-core.js with "0,2100,57600" return is 0 within 600 seconds +elastic-validator-1: js-script ./assign-core.js with "1,2100,57600" return is 0 within 600 seconds +elastic-validator-2: js-script ./assign-core.js with "2,2200,57600" return is 0 within 600 seconds +elastic-validator-3: js-script ./assign-core.js with "3,2200,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 140 seconds + +elastic-validator-0: parachain 2100 block height is at least 20 within 10 seconds +elastic-validator-0: parachain 2200 block height is at least 20 within 10 seconds From a2028bf03c941ce654cc6de05105ce027af9f9be Mon Sep 17 00:00:00 2001 From: alindima Date: Wed, 13 Nov 2024 13:29:34 +0200 Subject: [PATCH 02/27] override col_image --- .gitlab/pipeline/zombienet/polkadot.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.gitlab/pipeline/zombienet/polkadot.yml b/.gitlab/pipeline/zombienet/polkadot.yml index 253be68c32cc..30148232ab31 100644 --- a/.gitlab/pipeline/zombienet/polkadot.yml +++ b/.gitlab/pipeline/zombienet/polkadot.yml @@ -195,6 +195,8 @@ zombienet-polkadot-elastic-scaling-0003-slot-based-3cores: - .zombienet-polkadot-common variables: FORCED_INFRA_INSTANCE: "spot-iops" + # override COL_IMAGE to use test-parachain + COL_IMAGE: "docker.io/paritypr/test-parachain":${PIPELINE_IMAGE_TAG} before_script: - !reference [ .zombienet-polkadot-common, before_script ] - cp --remove-destination ${LOCAL_DIR}/assign-core.js ${LOCAL_DIR}/elastic_scaling From 0fcdcbb7881072cd2a6946684f658444d00d0a26 Mon Sep 17 00:00:00 2001 From: alindima Date: Wed, 13 Nov 2024 16:14:59 +0200 Subject: [PATCH 03/27] add zombienet test for mixed receipt versions --- .gitlab/pipeline/zombienet/polkadot.yml | 15 +++++++ .../0004-mixed-receipt-versions.toml | 42 +++++++++++++++++++ .../0004-mixed-receipt-versions.zndsl | 17 ++++++++ 3 files changed, 74 insertions(+) create mode 100644 polkadot/zombienet_tests/elastic_scaling/0004-mixed-receipt-versions.toml create mode 100644 polkadot/zombienet_tests/elastic_scaling/0004-mixed-receipt-versions.zndsl diff --git a/.gitlab/pipeline/zombienet/polkadot.yml b/.gitlab/pipeline/zombienet/polkadot.yml index 30148232ab31..ce21f5f1b818 100644 --- a/.gitlab/pipeline/zombienet/polkadot.yml +++ b/.gitlab/pipeline/zombienet/polkadot.yml @@ -205,6 +205,21 @@ zombienet-polkadot-elastic-scaling-0003-slot-based-3cores: --local-dir="${LOCAL_DIR}/elastic_scaling" --test="0003-slot-based-3cores.zndsl" +zombienet-polkadot-elastic-scaling-0004-mixed-receipt-versions: + extends: + - .zombienet-polkadot-common + variables: + FORCED_INFRA_INSTANCE: "spot-iops" + # override COL_IMAGE to use test-parachain + COL_IMAGE: "docker.io/paritypr/test-parachain":${PIPELINE_IMAGE_TAG} + 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="0004-mixed-receipt-versions.zndsl" + .zombienet-polkadot-functional-0012-spam-statement-distribution-requests: extends: - .zombienet-polkadot-common diff --git a/polkadot/zombienet_tests/elastic_scaling/0004-mixed-receipt-versions.toml b/polkadot/zombienet_tests/elastic_scaling/0004-mixed-receipt-versions.toml new file mode 100644 index 000000000000..87b03656398c --- /dev/null +++ b/polkadot/zombienet_tests/elastic_scaling/0004-mixed-receipt-versions.toml @@ -0,0 +1,42 @@ +[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 = 2 + +[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 = 3 + args = [ "-lparachain=debug,parachain::candidate-backing=trace,parachain::provisioner=trace,parachain::prospective-parachains=trace,runtime=debug"] + +[[parachains]] +id = 2200 +chain = "elastic-scaling" +add_to_genesis = true + + [[parachains.collators]] + name = "collator-elastic" + image = "{{COL_IMAGE}}" + command = "test-parachain" + args = ["-laura=trace,runtime=info,cumulus-consensus=trace,consensus::common=trace,parachain::collation-generation=trace,parachain::collator-protocol=trace,parachain=debug", "--force-authoring", "--experimental-use-slot-based"] + + [[parachains.collators]] + name = "old-collator-elastic" + # Use an old image here, this is roughly the commit where the stable2407 release branched off. + image = "{{COL_IMAGE}}:master-b862b181" + command = "test-parachain" + args = ["-laura=trace,runtime=info,cumulus-consensus=trace,consensus::common=trace,parachain::collation-generation=trace,parachain::collator-protocol=trace,parachain=debug", "--force-authoring", "--experimental-use-slot-based"] diff --git a/polkadot/zombienet_tests/elastic_scaling/0004-mixed-receipt-versions.zndsl b/polkadot/zombienet_tests/elastic_scaling/0004-mixed-receipt-versions.zndsl new file mode 100644 index 000000000000..2dec8914edc5 --- /dev/null +++ b/polkadot/zombienet_tests/elastic_scaling/0004-mixed-receipt-versions.zndsl @@ -0,0 +1,17 @@ +Description: Test 3-core elastic scaling with two slot-based collators using both receipt versions +Network: ./0004-mixed-receipt-versions.toml +Creds: config + +elastic-validator: is up +collator-elastic: is up +old-collator-elastic: is up + +# Register 2 extra cores to the parachain. +elastic-validator-0: js-script ./assign-core.js with "0,2200,57600" return is 0 within 600 seconds +elastic-validator-1: js-script ./assign-core.js with "1,2200,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 140 seconds + +# We won't get full throughput as some candidates would be built for the same block and therefore dropped in the runtime. +elastic-validator-0: parachain 2200 block height is at least 16 within 10 seconds From c81783f3da0442bb0dd8d7879253ceedc0e7b115 Mon Sep 17 00:00:00 2001 From: alindima Date: Wed, 13 Nov 2024 17:56:10 +0200 Subject: [PATCH 04/27] fix yml --- .gitlab/pipeline/zombienet/polkadot.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.gitlab/pipeline/zombienet/polkadot.yml b/.gitlab/pipeline/zombienet/polkadot.yml index ce21f5f1b818..ae7e78e24f70 100644 --- a/.gitlab/pipeline/zombienet/polkadot.yml +++ b/.gitlab/pipeline/zombienet/polkadot.yml @@ -196,7 +196,7 @@ zombienet-polkadot-elastic-scaling-0003-slot-based-3cores: variables: FORCED_INFRA_INSTANCE: "spot-iops" # override COL_IMAGE to use test-parachain - COL_IMAGE: "docker.io/paritypr/test-parachain":${PIPELINE_IMAGE_TAG} + COL_IMAGE: "docker.io/paritypr/test-parachain:${PIPELINE_IMAGE_TAG}" before_script: - !reference [ .zombienet-polkadot-common, before_script ] - cp --remove-destination ${LOCAL_DIR}/assign-core.js ${LOCAL_DIR}/elastic_scaling @@ -211,7 +211,7 @@ zombienet-polkadot-elastic-scaling-0004-mixed-receipt-versions: variables: FORCED_INFRA_INSTANCE: "spot-iops" # override COL_IMAGE to use test-parachain - COL_IMAGE: "docker.io/paritypr/test-parachain":${PIPELINE_IMAGE_TAG} + COL_IMAGE: "docker.io/paritypr/test-parachain:${PIPELINE_IMAGE_TAG}" before_script: - !reference [ .zombienet-polkadot-common, before_script ] - cp --remove-destination ${LOCAL_DIR}/assign-core.js ${LOCAL_DIR}/elastic_scaling From d7fba7550f49db1428cebca556ee66e98ad2c016 Mon Sep 17 00:00:00 2001 From: alindima Date: Thu, 14 Nov 2024 09:51:12 +0200 Subject: [PATCH 05/27] try fixing col_image --- .gitlab/pipeline/zombienet/polkadot.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.gitlab/pipeline/zombienet/polkadot.yml b/.gitlab/pipeline/zombienet/polkadot.yml index ae7e78e24f70..1a1b2b323d0f 100644 --- a/.gitlab/pipeline/zombienet/polkadot.yml +++ b/.gitlab/pipeline/zombienet/polkadot.yml @@ -195,11 +195,11 @@ zombienet-polkadot-elastic-scaling-0003-slot-based-3cores: - .zombienet-polkadot-common variables: FORCED_INFRA_INSTANCE: "spot-iops" - # override COL_IMAGE to use test-parachain - COL_IMAGE: "docker.io/paritypr/test-parachain:${PIPELINE_IMAGE_TAG}" before_script: - !reference [ .zombienet-polkadot-common, before_script ] - cp --remove-destination ${LOCAL_DIR}/assign-core.js ${LOCAL_DIR}/elastic_scaling + # override COL_IMAGE to use test-parachain + - export COL_IMAGE="docker.io/paritypr/test-parachain:${PIPELINE_IMAGE_TAG}" script: - /home/nonroot/zombie-net/scripts/ci/run-test-local-env-manager.sh --local-dir="${LOCAL_DIR}/elastic_scaling" @@ -210,11 +210,11 @@ zombienet-polkadot-elastic-scaling-0004-mixed-receipt-versions: - .zombienet-polkadot-common variables: FORCED_INFRA_INSTANCE: "spot-iops" - # override COL_IMAGE to use test-parachain - COL_IMAGE: "docker.io/paritypr/test-parachain:${PIPELINE_IMAGE_TAG}" before_script: - !reference [ .zombienet-polkadot-common, before_script ] - cp --remove-destination ${LOCAL_DIR}/assign-core.js ${LOCAL_DIR}/elastic_scaling + # override COL_IMAGE to use test-parachain + - export COL_IMAGE="docker.io/paritypr/test-parachain:${PIPELINE_IMAGE_TAG}" script: - /home/nonroot/zombie-net/scripts/ci/run-test-local-env-manager.sh --local-dir="${LOCAL_DIR}/elastic_scaling" From 2e833001ba2b081767880afc3dfa8b4458b3536f Mon Sep 17 00:00:00 2001 From: alindima Date: Thu, 14 Nov 2024 09:51:31 +0200 Subject: [PATCH 06/27] remove resource reqs --- .../elastic_scaling/0003-slot-based-3cores.toml | 4 ---- .../elastic_scaling/0004-mixed-receipt-versions.toml | 4 ---- 2 files changed, 8 deletions(-) diff --git a/polkadot/zombienet_tests/elastic_scaling/0003-slot-based-3cores.toml b/polkadot/zombienet_tests/elastic_scaling/0003-slot-based-3cores.toml index 67b38cbed789..23b1c988ff17 100644 --- a/polkadot/zombienet_tests/elastic_scaling/0003-slot-based-3cores.toml +++ b/polkadot/zombienet_tests/elastic_scaling/0003-slot-based-3cores.toml @@ -14,10 +14,6 @@ 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 = 6 diff --git a/polkadot/zombienet_tests/elastic_scaling/0004-mixed-receipt-versions.toml b/polkadot/zombienet_tests/elastic_scaling/0004-mixed-receipt-versions.toml index 87b03656398c..552e98bf3840 100644 --- a/polkadot/zombienet_tests/elastic_scaling/0004-mixed-receipt-versions.toml +++ b/polkadot/zombienet_tests/elastic_scaling/0004-mixed-receipt-versions.toml @@ -14,10 +14,6 @@ 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 = 3 From 3a6b09efc892a9fa2b0350030eea8bf6dbed525c Mon Sep 17 00:00:00 2001 From: alindima Date: Thu, 14 Nov 2024 11:02:52 +0200 Subject: [PATCH 07/27] fix --- .../elastic_scaling/0003-slot-based-3cores.zndsl | 2 +- .../elastic_scaling/0004-mixed-receipt-versions.toml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/polkadot/zombienet_tests/elastic_scaling/0003-slot-based-3cores.zndsl b/polkadot/zombienet_tests/elastic_scaling/0003-slot-based-3cores.zndsl index 57f2365f7657..97168ed481c4 100644 --- a/polkadot/zombienet_tests/elastic_scaling/0003-slot-based-3cores.zndsl +++ b/polkadot/zombienet_tests/elastic_scaling/0003-slot-based-3cores.zndsl @@ -16,4 +16,4 @@ elastic-validator-3: js-script ./assign-core.js with "3,2200,57600" return is 0 elastic-validator-0: reports substrate_block_height{status="best"} is at least 20 within 140 seconds elastic-validator-0: parachain 2100 block height is at least 20 within 10 seconds -elastic-validator-0: parachain 2200 block height is at least 20 within 10 seconds +elastic-validator-0: parachain 2200 block height is at least 20 within 20 seconds diff --git a/polkadot/zombienet_tests/elastic_scaling/0004-mixed-receipt-versions.toml b/polkadot/zombienet_tests/elastic_scaling/0004-mixed-receipt-versions.toml index 552e98bf3840..929c9be20ab6 100644 --- a/polkadot/zombienet_tests/elastic_scaling/0004-mixed-receipt-versions.toml +++ b/polkadot/zombienet_tests/elastic_scaling/0004-mixed-receipt-versions.toml @@ -33,6 +33,6 @@ add_to_genesis = true [[parachains.collators]] name = "old-collator-elastic" # Use an old image here, this is roughly the commit where the stable2407 release branched off. - image = "{{COL_IMAGE}}:master-b862b181" + image = "docker.io/paritypr/test-parachain:master-b862b181" command = "test-parachain" args = ["-laura=trace,runtime=info,cumulus-consensus=trace,consensus::common=trace,parachain::collation-generation=trace,parachain::collator-protocol=trace,parachain=debug", "--force-authoring", "--experimental-use-slot-based"] From 037a6326df4b9de1c8ea4137d4e697aea8e6d66d Mon Sep 17 00:00:00 2001 From: alindima Date: Wed, 20 Nov 2024 12:10:02 +0200 Subject: [PATCH 08/27] relax --- .../elastic_scaling/0003-slot-based-3cores.zndsl | 4 ++-- .../elastic_scaling/0004-mixed-receipt-versions.zndsl | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/polkadot/zombienet_tests/elastic_scaling/0003-slot-based-3cores.zndsl b/polkadot/zombienet_tests/elastic_scaling/0003-slot-based-3cores.zndsl index 97168ed481c4..b2d9e2a8a528 100644 --- a/polkadot/zombienet_tests/elastic_scaling/0003-slot-based-3cores.zndsl +++ b/polkadot/zombienet_tests/elastic_scaling/0003-slot-based-3cores.zndsl @@ -15,5 +15,5 @@ elastic-validator-3: js-script ./assign-core.js with "3,2200,57600" return is 0 # Wait for 20 relay chain blocks elastic-validator-0: reports substrate_block_height{status="best"} is at least 20 within 140 seconds -elastic-validator-0: parachain 2100 block height is at least 20 within 10 seconds -elastic-validator-0: parachain 2200 block height is at least 20 within 20 seconds +elastic-validator-0: parachain 2100 block height is at least 20 within 30 seconds +elastic-validator-0: parachain 2200 block height is at least 20 within 30 seconds diff --git a/polkadot/zombienet_tests/elastic_scaling/0004-mixed-receipt-versions.zndsl b/polkadot/zombienet_tests/elastic_scaling/0004-mixed-receipt-versions.zndsl index 2dec8914edc5..814bc69284b4 100644 --- a/polkadot/zombienet_tests/elastic_scaling/0004-mixed-receipt-versions.zndsl +++ b/polkadot/zombienet_tests/elastic_scaling/0004-mixed-receipt-versions.zndsl @@ -14,4 +14,4 @@ elastic-validator-1: js-script ./assign-core.js with "1,2200,57600" return is 0 elastic-validator-0: reports substrate_block_height{status="best"} is at least 20 within 140 seconds # We won't get full throughput as some candidates would be built for the same block and therefore dropped in the runtime. -elastic-validator-0: parachain 2200 block height is at least 16 within 10 seconds +elastic-validator-0: parachain 2200 block height is at least 16 within 30 seconds From 6f4dbb48187bd2eb74f8512023c1cca5a8af7bfb Mon Sep 17 00:00:00 2001 From: alindima Date: Mon, 2 Dec 2024 11:57:14 +0200 Subject: [PATCH 09/27] rewrite first test using zombienet-sdk --- .gitlab/pipeline/zombienet/polkadot.yml | 45 ++-- polkadot/zombienet-sdk-tests/build.rs | 65 ++++-- .../tests/elastic_scaling/mod.rs | 5 + .../elastic_scaling/slot_based_3cores.rs | 218 ++++++++++++++++++ polkadot/zombienet-sdk-tests/tests/lib.rs | 1 + .../tests/smoke/coretime_revenue.rs | 2 +- 6 files changed, 284 insertions(+), 52 deletions(-) create mode 100644 polkadot/zombienet-sdk-tests/tests/elastic_scaling/mod.rs create mode 100644 polkadot/zombienet-sdk-tests/tests/elastic_scaling/slot_based_3cores.rs diff --git a/.gitlab/pipeline/zombienet/polkadot.yml b/.gitlab/pipeline/zombienet/polkadot.yml index 1a1b2b323d0f..fdf0f5d6f968 100644 --- a/.gitlab/pipeline/zombienet/polkadot.yml +++ b/.gitlab/pipeline/zombienet/polkadot.yml @@ -190,35 +190,6 @@ zombienet-polkadot-elastic-scaling-0002-elastic-scaling-doesnt-break-parachains: --local-dir="${LOCAL_DIR}/elastic_scaling" --test="0002-elastic-scaling-doesnt-break-parachains.zndsl" -zombienet-polkadot-elastic-scaling-0003-slot-based-3cores: - 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 - # override COL_IMAGE to use test-parachain - - export COL_IMAGE="docker.io/paritypr/test-parachain:${PIPELINE_IMAGE_TAG}" - script: - - /home/nonroot/zombie-net/scripts/ci/run-test-local-env-manager.sh - --local-dir="${LOCAL_DIR}/elastic_scaling" - --test="0003-slot-based-3cores.zndsl" - -zombienet-polkadot-elastic-scaling-0004-mixed-receipt-versions: - 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 - # override COL_IMAGE to use test-parachain - - export COL_IMAGE="docker.io/paritypr/test-parachain:${PIPELINE_IMAGE_TAG}" - script: - - /home/nonroot/zombie-net/scripts/ci/run-test-local-env-manager.sh - --local-dir="${LOCAL_DIR}/elastic_scaling" - --test="0004-mixed-receipt-versions.zndsl" .zombienet-polkadot-functional-0012-spam-statement-distribution-requests: extends: @@ -416,3 +387,19 @@ zombienet-polkadot-malus-0001-dispute-valid: - unset NEXTEST_FAILURE_OUTPUT - unset NEXTEST_SUCCESS_OUTPUT - cargo nextest run --archive-file ./artifacts/polkadot-zombienet-tests.tar.zst --no-capture -- smoke::coretime_revenue::coretime_revenue_test + +zombienet-polkadot-coretime-revenue: + extends: + - .zombienet-polkadot-common + needs: + - job: build-polkadot-zombienet-tests + artifacts: true + before_script: + - !reference [ ".zombienet-polkadot-common", "before_script" ] + - export POLKADOT_IMAGE="${ZOMBIENET_INTEGRATION_TEST_IMAGE}" + - 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::slot_based_3cores::slot_based_3cores_test diff --git a/polkadot/zombienet-sdk-tests/build.rs b/polkadot/zombienet-sdk-tests/build.rs index 240d86386af2..57c5eac5d124 100644 --- a/polkadot/zombienet-sdk-tests/build.rs +++ b/polkadot/zombienet-sdk-tests/build.rs @@ -25,39 +25,47 @@ fn make_env_key(k: &str) -> String { replace_dashes(&k.to_ascii_uppercase()) } +fn wasm_sub_path(chain: &str) -> String { + let (package, runtime_name) = + if let Some(cumulus_test_runtime) = chain.strip_prefix("cumulus-test-runtime-") { + ( + "cumulus-test-runtime".to_string(), + format!("wasm_binary_{}.rs", replace_dashes(cumulus_test_runtime)), + ) + } else { + (format!("{chain}-runtime"), replace_dashes(&format!("{chain}-runtime"))) + }; + + format!("{}/{}.wasm", package, runtime_name) +} + fn find_wasm(chain: &str) -> Option { const PROFILES: [&str; 2] = ["release", "testnet"]; let manifest_path = env::var("CARGO_WORKSPACE_ROOT_DIR").unwrap(); let manifest_path = manifest_path.strip_suffix('/').unwrap(); debug_output!("manifest_path is : {}", manifest_path); - let package = format!("{chain}-runtime"); + + let sub_path = wasm_sub_path(chain); + let profile = PROFILES.into_iter().find(|p| { - let full_path = format!( - "{}/target/{}/wbuild/{}/{}.wasm", - manifest_path, - p, - &package, - replace_dashes(&package) - ); + let full_path = format!("{}/target/{}/wbuild/{}", manifest_path, p, sub_path); debug_output!("checking wasm at : {}", full_path); matches!(path::PathBuf::from(&full_path).try_exists(), Ok(true)) }); debug_output!("profile is : {:?}", profile); profile.map(|profile| { - PathBuf::from(&format!( - "{}/target/{}/wbuild/{}/{}.wasm", - manifest_path, - profile, - &package, - replace_dashes(&package) - )) + PathBuf::from(&format!("{}/target/{}/wbuild/{}", manifest_path, profile, sub_path)) }) } // based on https://gist.github.com/s0me0ne-unkn0wn/bbd83fe32ce10327086adbf13e750eec fn build_wasm(chain: &str) -> PathBuf { - let package = format!("{chain}-runtime"); + let package = if chain.starts_with("cumulus-test-runtime-") { + String::from("cumulus-test-runtime") + } else { + format!("{chain}-runtime") + }; let cargo = env::var("CARGO").unwrap(); let target = env::var("TARGET").unwrap(); @@ -68,7 +76,7 @@ fn build_wasm(chain: &str) -> PathBuf { "-p", &package, "--profile", - "release", + "testnet", "--target", &target, "--target-dir", @@ -81,11 +89,7 @@ fn build_wasm(chain: &str) -> PathBuf { .status() .unwrap(); - let wasm_path = &format!( - "{target_dir}/{target}/release/wbuild/{}/{}.wasm", - &package, - replace_dashes(&package) - ); + let wasm_path = &format!("{target_dir}/{target}/testnet/wbuild/{}", wasm_sub_path(chain)); PathBuf::from(wasm_path) } @@ -127,6 +131,8 @@ fn main() { let manifest_path = env::var("CARGO_MANIFEST_DIR").unwrap(); const METADATA_DIR: &str = "metadata-files"; const CHAINS: [&str; 2] = ["rococo", "coretime-rococo"]; + const CUMULUS_TEST_RUNTIMES: [&str; 2] = + ["cumulus-test-runtime-elastic-scaling", "cumulus-test-runtime-elastic-scaling-mvp"]; let metadata_path = format!("{manifest_path}/{METADATA_DIR}"); @@ -145,6 +151,21 @@ fn main() { }; } + for chain in CUMULUS_TEST_RUNTIMES { + let full_path = format!("{metadata_path}/{chain}-local.scale"); + let output_path = path::PathBuf::from(&full_path); + + match output_path.try_exists() { + Ok(true) => { + debug_output!("got: {}", full_path); + }, + _ => { + debug_output!("needs: {}", full_path); + fetch_metadata_file(chain, &output_path); + }, + }; + } + substrate_build_script_utils::generate_cargo_keys(); substrate_build_script_utils::rerun_if_git_head_changed(); println!("cargo:rerun-if-changed={}", metadata_path); diff --git a/polkadot/zombienet-sdk-tests/tests/elastic_scaling/mod.rs b/polkadot/zombienet-sdk-tests/tests/elastic_scaling/mod.rs new file mode 100644 index 000000000000..5cb42ab48bb8 --- /dev/null +++ b/polkadot/zombienet-sdk-tests/tests/elastic_scaling/mod.rs @@ -0,0 +1,5 @@ +// Copyright (C) Parity Technologies (UK) Ltd. +// SPDX-License-Identifier: Apache-2.0 + +#[cfg(feature = "zombie-metadata")] +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 new file mode 100644 index 000000000000..47245e5bb7a5 --- /dev/null +++ b/polkadot/zombienet-sdk-tests/tests/elastic_scaling/slot_based_3cores.rs @@ -0,0 +1,218 @@ +// Copyright (C) Parity Technologies (UK) Ltd. +// SPDX-License-Identifier: Apache-2.0 + +// Test that parachains that use a single slot-based collator with elastic scaling MVP and with +// elastic scaling with RFC103 can achieve full throughput of 3 candidates per block. + +use anyhow::anyhow; +#[subxt::subxt(runtime_metadata_path = "metadata-files/rococo-local.scale")] +pub mod rococo {} + +#[subxt::subxt( + runtime_metadata_path = "metadata-files/cumulus-test-runtime-elastic-scaling-local.scale" +)] +mod elastic_scaling_para {} + +#[subxt::subxt( + runtime_metadata_path = "metadata-files/cumulus-test-runtime-elastic-scaling-mvp-local.scale" +)] +mod elastic_scaling_mvp_para {} + +use rococo::runtime_types::{ + pallet_broker::coretime_interface::CoreAssignment, + polkadot_runtime_parachains::assigner_coretime::PartsOf57600, +}; +use serde_json::json; +use std::collections::HashMap; +use subxt::{OnlineClient, PolkadotConfig}; +use subxt_signer::sr25519::dev; +use zombienet_sdk::NetworkConfigBuilder; + +use rococo::{self as rococo_api}; + +#[tokio::test(flavor = "multi_thread")] +async fn slot_based_3cores_test() -> Result<(), anyhow::Error> { + env_logger::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_genesis_overrides(json!({ + "configuration": { + "config": { + "scheduler_params": { + // Num cores is 4, because 2 extra will be added automatically when registering the paras. + "num_cores": 4, + "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(&format!("validator-0"))); + + (1..6) + .into_iter() + .fold(r, |acc, i| acc.with_node(|node| node.with_name(&format!("validator-{i}")))) + }) + .with_parachain(|p| { + // Para 2100 uses the old elastic scaling mvp, which doesn't send the new UMP signal + // commitment for selecting the core index. + p.with_id(2100) + .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_collator(|n| n.with_name("collator-elastic-mvp")) + }) + .with_parachain(|p| { + // Para 2200 uses the new RFC103-enabled collator which sens the UMP signal commitment + // for selecting the core index + p.with_id(2200) + .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_collator(|n| n.with_name("collator-elastic")) + }) + .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 each parachain. + relay_client + .tx() + .sign_and_submit_then_watch_default( + &rococo_api::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(2100), 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(2100), PartsOf57600(57600))], + end_hint: None + } + ), + rococo::runtime_types::rococo_runtime::RuntimeCall::Coretime( + rococo::runtime_types::polkadot_runtime_parachains::coretime::pallet::Call::assign_core { + core: 2, + begin: 0, + assignment: vec![(CoreAssignment::Task(2200), PartsOf57600(57600))], + end_hint: None + } + ), + rococo::runtime_types::rococo_runtime::RuntimeCall::Coretime( + rococo::runtime_types::polkadot_runtime_parachains::coretime::pallet::Call::assign_core { + core: 3, + begin: 0, + assignment: vec![(CoreAssignment::Task(2200), PartsOf57600(57600))], + end_hint: None + } + ) + ], + }, + ), + ), + &alice, + ) + .await? + .wait_for_finalized_success() + .await?; + + log::info!("2 more cores assigned to each parachain"); + + // Expect a backed candidate count of 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, 40), (2200, 40)].into_iter().collect()) + .await?; + + log::info!("Test finished successfully"); + + Ok(()) +} + +async fn assert_para_throughput( + relay_client: &OnlineClient, + stop_at: u32, + expected_candidate_counts: HashMap, +) -> Result<(), anyhow::Error> { + let mut blocks_sub = relay_client.blocks().subscribe_finalized().await?; + let mut candidate_count: HashMap = HashMap::new(); + let mut current_block_count = 0; + let mut had_first_session_change = false; + + while let Some(block) = blocks_sub.next().await { + let block = block?; + log::debug!("Finalized relay chain block {}", block.number()); + let events = block.events().await?; + let is_session_change = events.has::()?; + + if !had_first_session_change && is_session_change { + had_first_session_change = true; + } + + if had_first_session_change && !is_session_change { + current_block_count += 1; + + for event in events.find::() { + *(candidate_count.entry(event?.0.descriptor.para_id.0).or_default()) += 1; + } + } + + if current_block_count == stop_at { + break; + } + } + + log::info!( + "Reached {} finalized relay chain blocks that contain backed candidates. The per-parachain distribution is: {:#?}", + stop_at, + candidate_count + ); + + for (para_id, expected_candidate_count) in expected_candidate_counts { + let actual = *candidate_count + .get(¶_id) + .expect("ParaId did not have any backed candidates"); + assert!( + actual >= expected_candidate_count, + "Expected {expected_candidate_count} lower than actual {actual}" + ); + } + + Ok(()) +} diff --git a/polkadot/zombienet-sdk-tests/tests/lib.rs b/polkadot/zombienet-sdk-tests/tests/lib.rs index 74cdc0765600..288aa13844d6 100644 --- a/polkadot/zombienet-sdk-tests/tests/lib.rs +++ b/polkadot/zombienet-sdk-tests/tests/lib.rs @@ -1,4 +1,5 @@ // Copyright (C) Parity Technologies (UK) Ltd. // SPDX-License-Identifier: Apache-2.0 +mod elastic_scaling; 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 7880dc782d05..e57be84be3f3 100644 --- a/polkadot/zombienet-sdk-tests/tests/smoke/coretime_revenue.rs +++ b/polkadot/zombienet-sdk-tests/tests/smoke/coretime_revenue.rs @@ -499,7 +499,7 @@ async fn coretime_revenue_test() -> Result<(), anyhow::Error> { assert_total_issuance(relay_client.clone(), para_client.clone(), total_issuance).await; - log::info!("Test finished successfuly"); + log::info!("Test finished successfully"); Ok(()) } From 610f29dde125c9be2721c37a0be612fc1dfa012d Mon Sep 17 00:00:00 2001 From: alindima Date: Mon, 2 Dec 2024 12:55:16 +0200 Subject: [PATCH 10/27] fixes --- .gitlab/pipeline/zombienet/polkadot.yml | 20 ++++++++- polkadot/zombienet-sdk-tests/build.rs | 7 ++- .../0003-slot-based-3cores.toml | 44 ------------------- .../0003-slot-based-3cores.zndsl | 19 -------- .../0004-mixed-receipt-versions.toml | 38 ---------------- .../0004-mixed-receipt-versions.zndsl | 17 ------- 6 files changed, 23 insertions(+), 122 deletions(-) delete mode 100644 polkadot/zombienet_tests/elastic_scaling/0003-slot-based-3cores.toml delete mode 100644 polkadot/zombienet_tests/elastic_scaling/0003-slot-based-3cores.zndsl delete mode 100644 polkadot/zombienet_tests/elastic_scaling/0004-mixed-receipt-versions.toml delete mode 100644 polkadot/zombienet_tests/elastic_scaling/0004-mixed-receipt-versions.zndsl diff --git a/.gitlab/pipeline/zombienet/polkadot.yml b/.gitlab/pipeline/zombienet/polkadot.yml index fdf0f5d6f968..9bcb9df2dad4 100644 --- a/.gitlab/pipeline/zombienet/polkadot.yml +++ b/.gitlab/pipeline/zombienet/polkadot.yml @@ -388,7 +388,7 @@ zombienet-polkadot-malus-0001-dispute-valid: - unset NEXTEST_SUCCESS_OUTPUT - cargo nextest run --archive-file ./artifacts/polkadot-zombienet-tests.tar.zst --no-capture -- smoke::coretime_revenue::coretime_revenue_test -zombienet-polkadot-coretime-revenue: +zombienet-polkadot-elastic-scaling-slot-based-3cores: extends: - .zombienet-polkadot-common needs: @@ -397,9 +397,25 @@ zombienet-polkadot-coretime-revenue: before_script: - !reference [ ".zombienet-polkadot-common", "before_script" ] - export POLKADOT_IMAGE="${ZOMBIENET_INTEGRATION_TEST_IMAGE}" - - export CUMULUS_IMAGE="docker.io/paritypr/test-parachain:${PIPELINE_IMAGE_TAG} + - 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::slot_based_3cores::slot_based_3cores_test + +zombienet-polkadot-elastic-scaling-mixed-receipt-versions: + extends: + - .zombienet-polkadot-common + needs: + - job: build-polkadot-zombienet-tests + artifacts: true + before_script: + - !reference [ ".zombienet-polkadot-common", "before_script" ] + - export POLKADOT_IMAGE="${ZOMBIENET_INTEGRATION_TEST_IMAGE}" + - 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::mixed_receipt_versions::mixed_receipt_versions_test diff --git a/polkadot/zombienet-sdk-tests/build.rs b/polkadot/zombienet-sdk-tests/build.rs index 57c5eac5d124..9835c1821966 100644 --- a/polkadot/zombienet-sdk-tests/build.rs +++ b/polkadot/zombienet-sdk-tests/build.rs @@ -76,6 +76,7 @@ fn build_wasm(chain: &str) -> PathBuf { "-p", &package, "--profile", + // TODO: switch back to release before merging. "testnet", "--target", &target, @@ -131,8 +132,10 @@ fn main() { let manifest_path = env::var("CARGO_MANIFEST_DIR").unwrap(); const METADATA_DIR: &str = "metadata-files"; const CHAINS: [&str; 2] = ["rococo", "coretime-rococo"]; - const CUMULUS_TEST_RUNTIMES: [&str; 2] = - ["cumulus-test-runtime-elastic-scaling", "cumulus-test-runtime-elastic-scaling-mvp"]; + + // Add some cumulus test runtimes if needed. Formatted like + // "cumulus-test-runtime-elastic-scaling". + const CUMULUS_TEST_RUNTIMES: [&str; 0] = []; let metadata_path = format!("{manifest_path}/{METADATA_DIR}"); diff --git a/polkadot/zombienet_tests/elastic_scaling/0003-slot-based-3cores.toml b/polkadot/zombienet_tests/elastic_scaling/0003-slot-based-3cores.toml deleted file mode 100644 index 23b1c988ff17..000000000000 --- a/polkadot/zombienet_tests/elastic_scaling/0003-slot-based-3cores.toml +++ /dev/null @@ -1,44 +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 = 4 - -[relaychain] -default_image = "{{ZOMBIENET_INTEGRATION_TEST_IMAGE}}" -chain = "rococo-local" -default_command = "polkadot" - - [[relaychain.node_groups]] - name = "elastic-validator" - count = 6 - args = [ "-lparachain=debug,parachain::candidate-backing=trace,parachain::provisioner=trace,parachain::prospective-parachains=trace,runtime=debug"] - -# First collator uses elastic scaling MVP. -[[parachains]] -id = 2100 -chain = "elastic-scaling-mvp" -add_to_genesis = true - - [[parachains.collators]] - name = "collator-elastic-mvp" - image = "{{COL_IMAGE}}" - command = "test-parachain" - args = ["-laura=trace,runtime=info,cumulus-consensus=trace,consensus::common=trace,parachain::collation-generation=trace,parachain::collator-protocol=trace,parachain=debug", "--force-authoring", "--experimental-use-slot-based"] - -# Second collator uses UMP commitments (RFC 103). -[[parachains]] -id = 2200 -chain = "elastic-scaling" -add_to_genesis = true - - [[parachains.collators]] - name = "collator-elastic" - image = "{{COL_IMAGE}}" - command = "test-parachain" - args = ["-laura=trace,runtime=info,cumulus-consensus=trace,consensus::common=trace,parachain::collation-generation=trace,parachain::collator-protocol=trace,parachain=debug", "--force-authoring", "--experimental-use-slot-based"] diff --git a/polkadot/zombienet_tests/elastic_scaling/0003-slot-based-3cores.zndsl b/polkadot/zombienet_tests/elastic_scaling/0003-slot-based-3cores.zndsl deleted file mode 100644 index b2d9e2a8a528..000000000000 --- a/polkadot/zombienet_tests/elastic_scaling/0003-slot-based-3cores.zndsl +++ /dev/null @@ -1,19 +0,0 @@ -Description: Test with slot-based collator using 3 cores and async backing -Network: ./0003-slot-based-3cores.toml -Creds: config - -elastic-validator: is up -collator-elastic: is up -collator-elastic-mvp: is up - -# Register 2 extra cores to each parachain. -elastic-validator-0: js-script ./assign-core.js with "0,2100,57600" return is 0 within 600 seconds -elastic-validator-1: js-script ./assign-core.js with "1,2100,57600" return is 0 within 600 seconds -elastic-validator-2: js-script ./assign-core.js with "2,2200,57600" return is 0 within 600 seconds -elastic-validator-3: js-script ./assign-core.js with "3,2200,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 140 seconds - -elastic-validator-0: parachain 2100 block height is at least 20 within 30 seconds -elastic-validator-0: parachain 2200 block height is at least 20 within 30 seconds diff --git a/polkadot/zombienet_tests/elastic_scaling/0004-mixed-receipt-versions.toml b/polkadot/zombienet_tests/elastic_scaling/0004-mixed-receipt-versions.toml deleted file mode 100644 index 929c9be20ab6..000000000000 --- a/polkadot/zombienet_tests/elastic_scaling/0004-mixed-receipt-versions.toml +++ /dev/null @@ -1,38 +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 = 2 - -[relaychain] -default_image = "{{ZOMBIENET_INTEGRATION_TEST_IMAGE}}" -chain = "rococo-local" -default_command = "polkadot" - - [[relaychain.node_groups]] - name = "elastic-validator" - count = 3 - args = [ "-lparachain=debug,parachain::candidate-backing=trace,parachain::provisioner=trace,parachain::prospective-parachains=trace,runtime=debug"] - -[[parachains]] -id = 2200 -chain = "elastic-scaling" -add_to_genesis = true - - [[parachains.collators]] - name = "collator-elastic" - image = "{{COL_IMAGE}}" - command = "test-parachain" - args = ["-laura=trace,runtime=info,cumulus-consensus=trace,consensus::common=trace,parachain::collation-generation=trace,parachain::collator-protocol=trace,parachain=debug", "--force-authoring", "--experimental-use-slot-based"] - - [[parachains.collators]] - name = "old-collator-elastic" - # Use an old image here, this is roughly the commit where the stable2407 release branched off. - image = "docker.io/paritypr/test-parachain:master-b862b181" - command = "test-parachain" - args = ["-laura=trace,runtime=info,cumulus-consensus=trace,consensus::common=trace,parachain::collation-generation=trace,parachain::collator-protocol=trace,parachain=debug", "--force-authoring", "--experimental-use-slot-based"] diff --git a/polkadot/zombienet_tests/elastic_scaling/0004-mixed-receipt-versions.zndsl b/polkadot/zombienet_tests/elastic_scaling/0004-mixed-receipt-versions.zndsl deleted file mode 100644 index 814bc69284b4..000000000000 --- a/polkadot/zombienet_tests/elastic_scaling/0004-mixed-receipt-versions.zndsl +++ /dev/null @@ -1,17 +0,0 @@ -Description: Test 3-core elastic scaling with two slot-based collators using both receipt versions -Network: ./0004-mixed-receipt-versions.toml -Creds: config - -elastic-validator: is up -collator-elastic: is up -old-collator-elastic: is up - -# Register 2 extra cores to the parachain. -elastic-validator-0: js-script ./assign-core.js with "0,2200,57600" return is 0 within 600 seconds -elastic-validator-1: js-script ./assign-core.js with "1,2200,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 140 seconds - -# We won't get full throughput as some candidates would be built for the same block and therefore dropped in the runtime. -elastic-validator-0: parachain 2200 block height is at least 16 within 30 seconds From 7e1f0d414da3667e5f1e7846d6abad14167cc929 Mon Sep 17 00:00:00 2001 From: alindima Date: Mon, 2 Dec 2024 13:10:17 +0200 Subject: [PATCH 11/27] add second test --- .../tests/elastic_scaling/helpers.rs | 60 ++++++++ .../elastic_scaling/mixed_receipt_versions.rs | 131 ++++++++++++++++++ .../tests/elastic_scaling/mod.rs | 6 +- .../elastic_scaling/slot_based_3cores.rs | 99 +++---------- polkadot/zombienet-sdk-tests/tests/lib.rs | 2 + .../zombienet-sdk-tests/tests/smoke/mod.rs | 1 - 6 files changed, 217 insertions(+), 82 deletions(-) create mode 100644 polkadot/zombienet-sdk-tests/tests/elastic_scaling/helpers.rs create mode 100644 polkadot/zombienet-sdk-tests/tests/elastic_scaling/mixed_receipt_versions.rs diff --git a/polkadot/zombienet-sdk-tests/tests/elastic_scaling/helpers.rs b/polkadot/zombienet-sdk-tests/tests/elastic_scaling/helpers.rs new file mode 100644 index 000000000000..7d4ad4a1dd8b --- /dev/null +++ b/polkadot/zombienet-sdk-tests/tests/elastic_scaling/helpers.rs @@ -0,0 +1,60 @@ +// 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}; + +// 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( + relay_client: &OnlineClient, + stop_at: u32, + 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 current_block_count = 0; + let mut had_first_session_change = false; + + while let Some(block) = blocks_sub.next().await { + let block = block?; + log::debug!("Finalized relay chain block {}", block.number()); + let events = block.events().await?; + let is_session_change = events.has::()?; + + if !had_first_session_change && is_session_change { + had_first_session_change = true; + } + + if had_first_session_change && !is_session_change { + current_block_count += 1; + + for event in events.find::() { + *(candidate_count.entry(event?.0.descriptor.para_id.0).or_default()) += 1; + } + } + + if current_block_count == stop_at { + break; + } + } + + log::info!( + "Reached {} finalized relay chain blocks that contain backed candidates. The per-parachain distribution is: {:#?}", + stop_at, + candidate_count + ); + + for (para_id, expected_candidate_range) in expected_candidate_ranges { + let actual = candidate_count + .get(¶_id) + .expect("ParaId did not have any backed candidates"); + assert!( + expected_candidate_range.contains(actual), + "Candidate count {actual} not within range {expected_candidate_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 new file mode 100644 index 000000000000..aa1c96e574d5 --- /dev/null +++ b/polkadot/zombienet-sdk-tests/tests/elastic_scaling/mixed_receipt_versions.rs @@ -0,0 +1,131 @@ +// Copyright (C) Parity Technologies (UK) Ltd. +// SPDX-License-Identifier: Apache-2.0 + +// Test that a parachain that uses a collator set which builds both V1 and V2 receipts cannot fully +// utilise elastic scaling but can still make some progress. + +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 mixed_receipt_versions_test() -> Result<(), anyhow::Error> { + env_logger::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_genesis_overrides(json!({ + "configuration": { + "config": { + "scheduler_params": { + // Num cores is 2, because 1 extra will be added automatically when registering the paras. + "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..3).fold(r, |acc, i| acc.with_node(|node| node.with_name(&format!("validator-{i}")))) + }) + .with_parachain(|p| { + p.with_id(2200) + .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()]) + // 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. + // The image is hardcoded to roughly where the stable2407 was branched off. + .with_collator(|n| { + n.with_name("old-collator-elastic") + .with_image("docker.io/paritypr/test-parachain:master-b862b181") + }) + }) + .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 the parachain. + 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(2200), 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(2200), PartsOf57600(57600))], + end_hint: None + } + ), + ], + }, + )), + &alice, + ) + .await? + .wait_for_finalized_success() + .await?; + + log::info!("2 more cores assigned to the parachain"); + + // We won't get full throughput as some candidates would be built for the same block and + // therefore dropped in the runtime. + // The perfect throughput would have been 45 for a parachain with 3 cores over 15 relay chain + // blocks. + assert_para_throughput(&relay_client, 15, [(2200, 25..35)].into_iter().collect()).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 5cb42ab48bb8..24373875fee5 100644 --- a/polkadot/zombienet-sdk-tests/tests/elastic_scaling/mod.rs +++ b/polkadot/zombienet-sdk-tests/tests/elastic_scaling/mod.rs @@ -1,5 +1,9 @@ // Copyright (C) Parity Technologies (UK) Ltd. // SPDX-License-Identifier: Apache-2.0 -#[cfg(feature = "zombie-metadata")] +#[subxt::subxt(runtime_metadata_path = "metadata-files/rococo-local.scale")] +pub mod rococo {} + +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 47245e5bb7a5..d237d100af77 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 @@ -5,31 +5,20 @@ // elastic scaling with RFC103 can achieve full throughput of 3 candidates per block. use anyhow::anyhow; -#[subxt::subxt(runtime_metadata_path = "metadata-files/rococo-local.scale")] -pub mod rococo {} -#[subxt::subxt( - runtime_metadata_path = "metadata-files/cumulus-test-runtime-elastic-scaling-local.scale" -)] -mod elastic_scaling_para {} - -#[subxt::subxt( - runtime_metadata_path = "metadata-files/cumulus-test-runtime-elastic-scaling-mvp-local.scale" -)] -mod elastic_scaling_mvp_para {} - -use rococo::runtime_types::{ - pallet_broker::coretime_interface::CoreAssignment, - polkadot_runtime_parachains::assigner_coretime::PartsOf57600, +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 std::collections::HashMap; use subxt::{OnlineClient, PolkadotConfig}; use subxt_signer::sr25519::dev; use zombienet_sdk::NetworkConfigBuilder; -use rococo::{self as rococo_api}; - #[tokio::test(flavor = "multi_thread")] async fn slot_based_3cores_test() -> Result<(), anyhow::Error> { env_logger::init_from_env( @@ -61,11 +50,9 @@ async fn slot_based_3cores_test() -> Result<(), anyhow::Error> { })) // Have to set a `with_node` outside of the loop below, so that `r` has the right // type. - .with_node(|node| node.with_name(&format!("validator-0"))); + .with_node(|node| node.with_name("validator-0")); - (1..6) - .into_iter() - .fold(r, |acc, i| acc.with_node(|node| node.with_name(&format!("validator-{i}")))) + (1..6).fold(r, |acc, i| acc.with_node(|node| node.with_name(&format!("validator-{i}")))) }) .with_parachain(|p| { // Para 2100 uses the old elastic scaling mvp, which doesn't send the new UMP signal @@ -105,8 +92,9 @@ async fn slot_based_3cores_test() -> Result<(), anyhow::Error> { relay_client .tx() .sign_and_submit_then_watch_default( - &rococo_api::tx().sudo().sudo( - rococo::runtime_types::rococo_runtime::RuntimeCall::Utility( + &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( @@ -143,8 +131,7 @@ async fn slot_based_3cores_test() -> Result<(), anyhow::Error> { ) ], }, - ), - ), + )), &alice, ) .await? @@ -157,62 +144,14 @@ async fn slot_based_3cores_test() -> Result<(), anyhow::Error> { // 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, 40), (2200, 40)].into_iter().collect()) - .await?; + assert_para_throughput( + &relay_client, + 15, + [(2100, 42..46), (2200, 42..46)].into_iter().collect(), + ) + .await?; log::info!("Test finished successfully"); Ok(()) } - -async fn assert_para_throughput( - relay_client: &OnlineClient, - stop_at: u32, - expected_candidate_counts: HashMap, -) -> Result<(), anyhow::Error> { - let mut blocks_sub = relay_client.blocks().subscribe_finalized().await?; - let mut candidate_count: HashMap = HashMap::new(); - let mut current_block_count = 0; - let mut had_first_session_change = false; - - while let Some(block) = blocks_sub.next().await { - let block = block?; - log::debug!("Finalized relay chain block {}", block.number()); - let events = block.events().await?; - let is_session_change = events.has::()?; - - if !had_first_session_change && is_session_change { - had_first_session_change = true; - } - - if had_first_session_change && !is_session_change { - current_block_count += 1; - - for event in events.find::() { - *(candidate_count.entry(event?.0.descriptor.para_id.0).or_default()) += 1; - } - } - - if current_block_count == stop_at { - break; - } - } - - log::info!( - "Reached {} finalized relay chain blocks that contain backed candidates. The per-parachain distribution is: {:#?}", - stop_at, - candidate_count - ); - - for (para_id, expected_candidate_count) in expected_candidate_counts { - let actual = *candidate_count - .get(¶_id) - .expect("ParaId did not have any backed candidates"); - assert!( - actual >= expected_candidate_count, - "Expected {expected_candidate_count} lower than actual {actual}" - ); - } - - Ok(()) -} diff --git a/polkadot/zombienet-sdk-tests/tests/lib.rs b/polkadot/zombienet-sdk-tests/tests/lib.rs index 288aa13844d6..977e0f90b1c9 100644 --- a/polkadot/zombienet-sdk-tests/tests/lib.rs +++ b/polkadot/zombienet-sdk-tests/tests/lib.rs @@ -1,5 +1,7 @@ // Copyright (C) Parity Technologies (UK) Ltd. // SPDX-License-Identifier: Apache-2.0 +#[cfg(feature = "zombie-metadata")] mod elastic_scaling; +#[cfg(feature = "zombie-metadata")] mod smoke; diff --git a/polkadot/zombienet-sdk-tests/tests/smoke/mod.rs b/polkadot/zombienet-sdk-tests/tests/smoke/mod.rs index a3fe15382674..072a9d54ecda 100644 --- a/polkadot/zombienet-sdk-tests/tests/smoke/mod.rs +++ b/polkadot/zombienet-sdk-tests/tests/smoke/mod.rs @@ -1,5 +1,4 @@ // Copyright (C) Parity Technologies (UK) Ltd. // SPDX-License-Identifier: Apache-2.0 -#[cfg(feature = "zombie-metadata")] mod coretime_revenue; From 78eaf5efe32a6683c7a03321f29b67ea745fc627 Mon Sep 17 00:00:00 2001 From: alindima Date: Mon, 2 Dec 2024 13:48:01 +0200 Subject: [PATCH 12/27] do not re-init the logger --- .../tests/elastic_scaling/mixed_receipt_versions.rs | 4 +++- .../tests/elastic_scaling/slot_based_3cores.rs | 2 +- polkadot/zombienet-sdk-tests/tests/smoke/coretime_revenue.rs | 2 +- 3 files changed, 5 insertions(+), 3 deletions(-) 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 aa1c96e574d5..76f9b24d9159 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 @@ -21,7 +21,7 @@ use zombienet_sdk::NetworkConfigBuilder; #[tokio::test(flavor = "multi_thread")] async fn mixed_receipt_versions_test() -> Result<(), anyhow::Error> { - env_logger::init_from_env( + let _ = env_logger::try_init_from_env( env_logger::Env::default().filter_or(env_logger::DEFAULT_FILTER_ENV, "info"), ); @@ -67,6 +67,8 @@ async fn mixed_receipt_versions_test() -> Result<(), anyhow::Error> { .with_collator(|n| { n.with_name("old-collator-elastic") .with_image("docker.io/paritypr/test-parachain:master-b862b181") + // TODO: remove this when committing. + .with_command("/Users/alindima/Desktop/code/polkadot-sdk-copy/polkadot-sdk/bin/test-parachain") }) }) .build() 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 d237d100af77..a060172fea56 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 @@ -21,7 +21,7 @@ use zombienet_sdk::NetworkConfigBuilder; #[tokio::test(flavor = "multi_thread")] async fn slot_based_3cores_test() -> Result<(), anyhow::Error> { - env_logger::init_from_env( + let _ = env_logger::try_init_from_env( env_logger::Env::default().filter_or(env_logger::DEFAULT_FILTER_ENV, "info"), ); diff --git a/polkadot/zombienet-sdk-tests/tests/smoke/coretime_revenue.rs b/polkadot/zombienet-sdk-tests/tests/smoke/coretime_revenue.rs index e57be84be3f3..2da2436a1111 100644 --- a/polkadot/zombienet-sdk-tests/tests/smoke/coretime_revenue.rs +++ b/polkadot/zombienet-sdk-tests/tests/smoke/coretime_revenue.rs @@ -180,7 +180,7 @@ where #[tokio::test(flavor = "multi_thread")] async fn coretime_revenue_test() -> Result<(), anyhow::Error> { - env_logger::init_from_env( + let _ = env_logger::try_init_from_env( env_logger::Env::default().filter_or(env_logger::DEFAULT_FILTER_ENV, "info"), ); From 184f206d48a09451c6f1719600b1603fb603eb5e Mon Sep 17 00:00:00 2001 From: alindima Date: Mon, 2 Dec 2024 13:54:04 +0200 Subject: [PATCH 13/27] prdoc --- prdoc/pr_6452.prdoc | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 prdoc/pr_6452.prdoc diff --git a/prdoc/pr_6452.prdoc b/prdoc/pr_6452.prdoc new file mode 100644 index 000000000000..ef5648722e4d --- /dev/null +++ b/prdoc/pr_6452.prdoc @@ -0,0 +1,16 @@ +title: "elastic scaling RFC 103 end-to-end tests" + +doc: + - audience: Node Dev | Runtime Dev + description: | + Adds end-to-end zombienet-sdk tests for elastic scaling using the RFC103 implementation. + Only notable user-facing change is that the default chain configurations of westend and rococo + now enable by default the CandidateReceiptV2 node feature. + +crates: + - name: westend-runtime + bump: patch + - name: rococo-runtime + bump: patch + - name: rococo-parachain-runtime + bump: patch From 01fbf6b98974b3d89401a29b05189ee7c6218c07 Mon Sep 17 00:00:00 2001 From: alindima Date: Mon, 2 Dec 2024 14:23:33 +0200 Subject: [PATCH 14/27] oops --- polkadot/zombienet-sdk-tests/build.rs | 3 +-- .../tests/elastic_scaling/mixed_receipt_versions.rs | 2 -- 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/polkadot/zombienet-sdk-tests/build.rs b/polkadot/zombienet-sdk-tests/build.rs index 9835c1821966..ce276d67dd5c 100644 --- a/polkadot/zombienet-sdk-tests/build.rs +++ b/polkadot/zombienet-sdk-tests/build.rs @@ -76,8 +76,7 @@ fn build_wasm(chain: &str) -> PathBuf { "-p", &package, "--profile", - // TODO: switch back to release before merging. - "testnet", + "release", "--target", &target, "--target-dir", 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 76f9b24d9159..68ff125e5694 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 @@ -67,8 +67,6 @@ async fn mixed_receipt_versions_test() -> Result<(), anyhow::Error> { .with_collator(|n| { n.with_name("old-collator-elastic") .with_image("docker.io/paritypr/test-parachain:master-b862b181") - // TODO: remove this when committing. - .with_command("/Users/alindima/Desktop/code/polkadot-sdk-copy/polkadot-sdk/bin/test-parachain") }) }) .build() From 12c9f10b9ec3ef7a70917d6ee6a68b31fe5ed036 Mon Sep 17 00:00:00 2001 From: alindima Date: Mon, 2 Dec 2024 14:41:19 +0200 Subject: [PATCH 15/27] oops again --- polkadot/zombienet-sdk-tests/build.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/polkadot/zombienet-sdk-tests/build.rs b/polkadot/zombienet-sdk-tests/build.rs index ce276d67dd5c..f7a62a53a8ac 100644 --- a/polkadot/zombienet-sdk-tests/build.rs +++ b/polkadot/zombienet-sdk-tests/build.rs @@ -89,7 +89,7 @@ fn build_wasm(chain: &str) -> PathBuf { .status() .unwrap(); - let wasm_path = &format!("{target_dir}/{target}/testnet/wbuild/{}", wasm_sub_path(chain)); + let wasm_path = &format!("{target_dir}/{target}/release/wbuild/{}", wasm_sub_path(chain)); PathBuf::from(wasm_path) } From 069b7ba0b56d2c505d8749fdeb95e3db952c7592 Mon Sep 17 00:00:00 2001 From: alindima Date: Mon, 2 Dec 2024 17:27:14 +0200 Subject: [PATCH 16/27] fix prdoc --- prdoc/pr_6452.prdoc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/prdoc/pr_6452.prdoc b/prdoc/pr_6452.prdoc index ef5648722e4d..f2cb69875e95 100644 --- a/prdoc/pr_6452.prdoc +++ b/prdoc/pr_6452.prdoc @@ -1,7 +1,7 @@ title: "elastic scaling RFC 103 end-to-end tests" doc: - - audience: Node Dev | Runtime Dev + - audience: [Node Dev, Runtime Dev] description: | Adds end-to-end zombienet-sdk tests for elastic scaling using the RFC103 implementation. Only notable user-facing change is that the default chain configurations of westend and rococo From 0a5f5ed8d178ed5fb9442c42bbda879dc6995e35 Mon Sep 17 00:00:00 2001 From: alindima Date: Wed, 4 Dec 2024 09:52:01 +0200 Subject: [PATCH 17/27] feedback --- .../tests/elastic_scaling/slot_based_3cores.rs | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) 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 a060172fea56..8fdc69a89ff5 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 @@ -39,7 +39,7 @@ async fn slot_based_3cores_test() -> Result<(), anyhow::Error> { "scheduler_params": { // Num cores is 4, because 2 extra will be added automatically when registering the paras. "num_cores": 4, - "max_validators_per_core": 1 + "max_validators_per_core": 2 }, "async_backing_params": { "max_candidate_depth": 6, @@ -52,7 +52,8 @@ async fn slot_based_3cores_test() -> Result<(), anyhow::Error> { // type. .with_node(|node| node.with_name("validator-0")); - (1..6).fold(r, |acc, i| acc.with_node(|node| node.with_name(&format!("validator-{i}")))) + (1..12) + .fold(r, |acc, i| acc.with_node(|node| node.with_name(&format!("validator-{i}")))) }) .with_parachain(|p| { // Para 2100 uses the old elastic scaling mvp, which doesn't send the new UMP signal @@ -65,7 +66,7 @@ async fn slot_based_3cores_test() -> Result<(), anyhow::Error> { .with_collator(|n| n.with_name("collator-elastic-mvp")) }) .with_parachain(|p| { - // Para 2200 uses the new RFC103-enabled collator which sens the UMP signal commitment + // Para 2200 uses the new RFC103-enabled collator which sends the UMP signal commitment // for selecting the core index p.with_id(2200) .with_default_command("test-parachain") @@ -140,8 +141,8 @@ async fn slot_based_3cores_test() -> Result<(), anyhow::Error> { log::info!("2 more cores assigned to each parachain"); - // Expect a backed candidate count of 40 for each parachain in 15 relay chain blocks (2.66 - // candidates per para per relay chain block). + // 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). // Note that only blocks after the first session change and blocks that don't contain a session // change will be counted. assert_para_throughput( From 060bd62a36ecd39bf50ddc3812d6515bf7e0f329 Mon Sep 17 00:00:00 2001 From: alindima Date: Wed, 4 Dec 2024 14:39:46 +0200 Subject: [PATCH 18/27] 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 19/27] 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 7b36433e671b5f0bc22e7583fcef635b091a0fa0 Mon Sep 17 00:00:00 2001 From: alindima Date: Tue, 10 Dec 2024 15:50:32 +0200 Subject: [PATCH 20/27] relax assertion --- .../tests/elastic_scaling/mixed_receipt_versions.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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..10169b4852e5 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 @@ -123,7 +123,7 @@ async fn mixed_receipt_versions_test() -> Result<(), anyhow::Error> { // therefore dropped in the runtime. // The perfect throughput would have been 45 for a parachain with 3 cores over 15 relay chain // blocks. - assert_para_throughput(&relay_client, 15, [(2200, 25..35)].into_iter().collect()).await?; + assert_para_throughput(&relay_client, 15, [(2200, 25..37)].into_iter().collect()).await?; log::info!("Test finished successfully"); From d22d42e65881aae44cb7ad15c87944b6e87b9f6d Mon Sep 17 00:00:00 2001 From: alindima Date: Tue, 10 Dec 2024 16:40:42 +0200 Subject: [PATCH 21/27] 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 22/27] 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 - From 9ba15311b1b2c9850ea09a7f0d5624e802dfa0f5 Mon Sep 17 00:00:00 2001 From: Javier Viola Date: Thu, 19 Dec 2024 11:00:29 +0100 Subject: [PATCH 23/27] add more debug --- .gitlab/pipeline/zombienet/polkadot.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitlab/pipeline/zombienet/polkadot.yml b/.gitlab/pipeline/zombienet/polkadot.yml index 4f77a3d19d41..4a2f00547191 100644 --- a/.gitlab/pipeline/zombienet/polkadot.yml +++ b/.gitlab/pipeline/zombienet/polkadot.yml @@ -388,7 +388,7 @@ zombienet-polkadot-elastic-scaling-doesnt-break-parachains: # 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 + - RUST_LOG=info,zombienet_=trace 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: From 0ec8d89074b8130be96ae1b01d13c8a5579fee12 Mon Sep 17 00:00:00 2001 From: Javier Viola Date: Thu, 19 Dec 2024 11:52:30 +0100 Subject: [PATCH 24/27] add more cpu to runner --- .gitlab/pipeline/zombienet/polkadot.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.gitlab/pipeline/zombienet/polkadot.yml b/.gitlab/pipeline/zombienet/polkadot.yml index 4a2f00547191..831a0b12106c 100644 --- a/.gitlab/pipeline/zombienet/polkadot.yml +++ b/.gitlab/pipeline/zombienet/polkadot.yml @@ -384,6 +384,8 @@ zombienet-polkadot-elastic-scaling-doesnt-break-parachains: artifacts: true before_script: - !reference [ ".zombienet-polkadot-common", "before_script" ] + variables: + KUBERNETES_CPU_REQUEST: "1" script: # we want to use `--no-capture` in zombienet tests. - unset NEXTEST_FAILURE_OUTPUT From 48b81059b51182007ac67c613c8fd3d31da9f781 Mon Sep 17 00:00:00 2001 From: alindima Date: Thu, 19 Dec 2024 13:20:12 +0200 Subject: [PATCH 25/27] address review comments --- Cargo.lock | 1 + polkadot/zombienet-sdk-tests/Cargo.toml | 1 + .../tests/elastic_scaling/basic_3cores.rs | 5 +++- .../doesnt_break_parachains.rs | 23 ++++++++++++++++++- .../elastic_scaling/slot_based_3cores.rs | 5 +++- .../async_backing_6_seconds_rate.rs | 5 +++- .../tests/functional/sync_backing.rs | 4 +++- .../zombienet-sdk-tests/tests/helpers/mod.rs | 7 +++--- 8 files changed, 43 insertions(+), 8 deletions(-) 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; } } From ba27e1a250ff1e79adfc928773f1f26189e2123f Mon Sep 17 00:00:00 2001 From: alindima Date: Mon, 23 Dec 2024 11:38:13 +0200 Subject: [PATCH 26/27] remove redundant file --- .../tests/elastic_scaling/helpers.rs | 60 ------------------- 1 file changed, 60 deletions(-) delete mode 100644 polkadot/zombienet-sdk-tests/tests/elastic_scaling/helpers.rs diff --git a/polkadot/zombienet-sdk-tests/tests/elastic_scaling/helpers.rs b/polkadot/zombienet-sdk-tests/tests/elastic_scaling/helpers.rs deleted file mode 100644 index 7d4ad4a1dd8b..000000000000 --- a/polkadot/zombienet-sdk-tests/tests/elastic_scaling/helpers.rs +++ /dev/null @@ -1,60 +0,0 @@ -// 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}; - -// 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( - relay_client: &OnlineClient, - stop_at: u32, - 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 current_block_count = 0; - let mut had_first_session_change = false; - - while let Some(block) = blocks_sub.next().await { - let block = block?; - log::debug!("Finalized relay chain block {}", block.number()); - let events = block.events().await?; - let is_session_change = events.has::()?; - - if !had_first_session_change && is_session_change { - had_first_session_change = true; - } - - if had_first_session_change && !is_session_change { - current_block_count += 1; - - for event in events.find::() { - *(candidate_count.entry(event?.0.descriptor.para_id.0).or_default()) += 1; - } - } - - if current_block_count == stop_at { - break; - } - } - - log::info!( - "Reached {} finalized relay chain blocks that contain backed candidates. The per-parachain distribution is: {:#?}", - stop_at, - candidate_count - ); - - for (para_id, expected_candidate_range) in expected_candidate_ranges { - let actual = candidate_count - .get(¶_id) - .expect("ParaId did not have any backed candidates"); - assert!( - expected_candidate_range.contains(actual), - "Candidate count {actual} not within range {expected_candidate_range:?}" - ); - } - - Ok(()) -} From 4341161ce39fb80c37265332530dd799e0499451 Mon Sep 17 00:00:00 2001 From: alindima Date: Mon, 23 Dec 2024 11:54:38 +0200 Subject: [PATCH 27/27] sort deps --- polkadot/zombienet-sdk-tests/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/polkadot/zombienet-sdk-tests/Cargo.toml b/polkadot/zombienet-sdk-tests/Cargo.toml index d20d9dc73427..ba7517ddce66 100644 --- a/polkadot/zombienet-sdk-tests/Cargo.toml +++ b/polkadot/zombienet-sdk-tests/Cargo.toml @@ -12,13 +12,13 @@ anyhow = { workspace = true } codec = { workspace = true, features = ["derive"] } env_logger = { workspace = true } log = { workspace = true } +polkadot-primitives = { workspace = true, default-features = true } serde = { workspace = true } serde_json = { workspace = true } subxt = { workspace = true, features = ["substrate-compat"] } subxt-signer = { workspace = true } tokio = { workspace = true, features = ["rt-multi-thread"] } zombienet-sdk = { workspace = true } -polkadot-primitives = { workspace = true, default-features = true } [features] zombie-metadata = []