From 2b1650b7a65c814de281aba8219db49db7f7945b Mon Sep 17 00:00:00 2001 From: Stephane Gurgenidze Date: Thu, 9 Jan 2025 00:34:01 +0400 Subject: [PATCH] test(malus-collator): add core assignment and update Zombienet test checks --- .../undying/collator/src/lib.rs | 6 +- .../test-parachains/undying/src/lib.rs | 16 ++-- ...-same-collation-to-all-assigned-cores.toml | 8 +- ...same-collation-to-all-assigned-cores.zndsl | 73 +------------------ 4 files changed, 23 insertions(+), 80 deletions(-) diff --git a/polkadot/parachain/test-parachains/undying/collator/src/lib.rs b/polkadot/parachain/test-parachains/undying/collator/src/lib.rs index a078d22a6ee5..596ce9b86829 100644 --- a/polkadot/parachain/test-parachains/undying/collator/src/lib.rs +++ b/polkadot/parachain/test-parachains/undying/collator/src/lib.rs @@ -66,13 +66,14 @@ fn calculate_head_and_state_for_number( let mut graveyard = vec![0u8; graveyard_size * graveyard_size]; let zombies = 0; let seal = [0u8; 32]; + let core_selector_number = 0; // Ensure a larger compressed PoV. graveyard.iter_mut().enumerate().for_each(|(i, grave)| { *grave = i as u8; }); - let mut state = GraveyardState { index, graveyard, zombies, seal }; + let mut state = GraveyardState { index, graveyard, zombies, seal, core_selector_number }; let mut head = HeadData { number: 0, parent_hash: Hash::default().into(), post_state: hash_state(&state) }; @@ -113,13 +114,14 @@ impl State { let mut graveyard = vec![0u8; graveyard_size * graveyard_size]; let zombies = 0; let seal = [0u8; 32]; + let core_selector_number = 0; // Ensure a larger compressed PoV. graveyard.iter_mut().enumerate().for_each(|(i, grave)| { *grave = i as u8; }); - let state = GraveyardState { index, graveyard, zombies, seal }; + let state = GraveyardState { index, graveyard, zombies, seal, core_selector_number }; let head_data = HeadData { number: 0, parent_hash: Default::default(), post_state: hash_state(&state) }; diff --git a/polkadot/parachain/test-parachains/undying/src/lib.rs b/polkadot/parachain/test-parachains/undying/src/lib.rs index ab4f80ca075d..41c3a8625091 100644 --- a/polkadot/parachain/test-parachains/undying/src/lib.rs +++ b/polkadot/parachain/test-parachains/undying/src/lib.rs @@ -90,6 +90,8 @@ pub struct GraveyardState { pub zombies: u64, // Grave seal. pub seal: [u8; 32], + // Increasing sequence number for core selector. + pub core_selector_number: u8, } /// Block data for this parachain. @@ -123,6 +125,7 @@ pub fn execute_transaction(mut block_data: BlockData) -> GraveyardState { // Chain hash the seals and burn CPU. block_data.state.seal = hash_state(&block_data.state); } + block_data.state.core_selector_number += 1; block_data.state } @@ -150,16 +153,19 @@ pub fn execute( return Err(StateMismatch) } - // We need to clone the block data as the fn will mutate it's state. - let new_state = execute_transaction(block_data.clone()); - let mut upward_messages: UpwardMessages = Default::default(); upward_messages.force_push(UMP_SEPARATOR); upward_messages.force_push( - UMPSignal::SelectCore(CoreSelector(0), ClaimQueueOffset(DEFAULT_CLAIM_QUEUE_OFFSET)) - .encode(), + UMPSignal::SelectCore( + CoreSelector(block_data.state.core_selector_number), + ClaimQueueOffset(DEFAULT_CLAIM_QUEUE_OFFSET), + ) + .encode(), ); + // We need to clone the block data as the fn will mutate it's state. + let new_state = execute_transaction(block_data.clone()); + Ok(( HeadData { number: parent_head.number + 1, diff --git a/polkadot/zombienet_tests/functional/0020-same-collation-to-all-assigned-cores.toml b/polkadot/zombienet_tests/functional/0020-same-collation-to-all-assigned-cores.toml index 1b99f31432c4..c36db8b41126 100644 --- a/polkadot/zombienet_tests/functional/0020-same-collation-to-all-assigned-cores.toml +++ b/polkadot/zombienet_tests/functional/0020-same-collation-to-all-assigned-cores.toml @@ -30,16 +30,16 @@ addToGenesis = true genesis_state_generator = "undying-collator export-genesis-state --pov-size=100000 --pvf-complexity=1" [[parachains.collators]] - name = "collator01" + name = "normal-collator" image = "{{COL_IMAGE}}" command = "undying-collator" - args = ["--malus", "-lparachain=debug", "--pov-size=100000", "--pvf-complexity=1", "--parachain-id=2000"] + args = ["-lparachain=debug", "--pov-size=100000", "--pvf-complexity=1", "--parachain-id=2000"] [[parachains.collators]] - name = "collator02" + name = "malus-collator" image = "{{COL_IMAGE}}" command = "undying-collator" - args = ["-lparachain=debug", "--pov-size=100000", "--pvf-complexity=1", "--parachain-id=2000"] + args = ["-lparachain=debug", "--pov-size=100000", "--pvf-complexity=1", "--parachain-id=2000", "--malus"] [types.Header] number = "u64" diff --git a/polkadot/zombienet_tests/functional/0020-same-collation-to-all-assigned-cores.zndsl b/polkadot/zombienet_tests/functional/0020-same-collation-to-all-assigned-cores.zndsl index 3e1d8ba771c4..460be92c04a4 100644 --- a/polkadot/zombienet_tests/functional/0020-same-collation-to-all-assigned-cores.zndsl +++ b/polkadot/zombienet_tests/functional/0020-same-collation-to-all-assigned-cores.zndsl @@ -1,84 +1,19 @@ Description: PVF preparation & execution time -Network: ./0001-parachains-pvf.toml +Network: ./0020-same-collation-to-all-assigned-cores.toml Creds: config # Check authority status. alice: reports node_roles is 4 bob: reports node_roles is 4 charlie: reports node_roles is 4 -dave: reports node_roles is 4 -eve: reports node_roles is 4 -ferdie: reports node_roles is 4 -one: reports node_roles is 4 -two: reports node_roles is 4 # Ensure parachains are registered. alice: parachain 2000 is registered within 60 seconds -bob: parachain 2001 is registered within 60 seconds -charlie: parachain 2002 is registered within 60 seconds -dave: parachain 2003 is registered within 60 seconds -ferdie: parachain 2004 is registered within 60 seconds -eve: parachain 2005 is registered within 60 seconds -one: parachain 2006 is registered within 60 seconds -two: parachain 2007 is registered within 60 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 # Ensure parachains made progress. alice: parachain 2000 block height is at least 10 within 300 seconds -alice: parachain 2001 block height is at least 10 within 300 seconds -alice: parachain 2002 block height is at least 10 within 300 seconds -alice: parachain 2003 block height is at least 10 within 300 seconds -alice: parachain 2004 block height is at least 10 within 300 seconds -alice: parachain 2005 block height is at least 10 within 300 seconds -alice: parachain 2006 block height is at least 10 within 300 seconds -alice: parachain 2007 block height is at least 10 within 300 seconds alice: reports substrate_block_height{status="finalized"} is at least 30 within 400 seconds - -# Check preparation time is under 10s. -# Check all buckets <= 10. -alice: reports histogram polkadot_pvf_preparation_time has at least 1 samples in buckets ["0.1", "0.5", "1", "2", "3", "10"] within 10 seconds -bob: reports histogram polkadot_pvf_preparation_time has at least 1 samples in buckets ["0.1", "0.5", "1", "2", "3", "10"] within 10 seconds -charlie: reports histogram polkadot_pvf_preparation_time has at least 1 samples in buckets ["0.1", "0.5", "1", "2", "3", "10"] within 10 seconds -dave: reports histogram polkadot_pvf_preparation_time has at least 1 samples in buckets ["0.1", "0.5", "1", "2", "3", "10"] within 10 seconds -ferdie: reports histogram polkadot_pvf_preparation_time has at least 1 samples in buckets ["0.1", "0.5", "1", "2", "3", "10"] within 10 seconds -eve: reports histogram polkadot_pvf_preparation_time has at least 1 samples in buckets ["0.1", "0.5", "1", "2", "3", "10"] within 10 seconds -one: reports histogram polkadot_pvf_preparation_time has at least 1 samples in buckets ["0.1", "0.5", "1", "2", "3", "10"] within 10 seconds -two: reports histogram polkadot_pvf_preparation_time has at least 1 samples in buckets ["0.1", "0.5", "1", "2", "3", "10"] within 10 seconds - -# Check all buckets >= 20. -alice: reports histogram polkadot_pvf_preparation_time has 0 samples in buckets ["20", "30", "60", "120", "+Inf"] within 10 seconds -bob: reports histogram polkadot_pvf_preparation_time has 0 samples in buckets ["20", "30", "60", "120", "+Inf"] within 10 seconds -charlie: reports histogram polkadot_pvf_preparation_time has 0 samples in buckets ["20", "30", "60", "120", "+Inf"] within 10 seconds -dave: reports histogram polkadot_pvf_preparation_time has 0 samples in buckets ["20", "30", "60", "120", "+Inf"] within 10 seconds -ferdie: reports histogram polkadot_pvf_preparation_time has 0 samples in buckets ["20", "30", "60", "120", "+Inf"] within 10 seconds -eve: reports histogram polkadot_pvf_preparation_time has 0 samples in buckets ["20", "30", "60", "120", "+Inf"] within 10 seconds -one: reports histogram polkadot_pvf_preparation_time has 0 samples in buckets ["20", "30", "60", "120", "+Inf"] within 10 seconds -two: reports histogram polkadot_pvf_preparation_time has 0 samples in buckets ["20", "30", "60", "120", "+Inf"] within 10 seconds - -# Check execution time. -# There are two different timeout conditions: DEFAULT_BACKING_EXECUTION_TIMEOUT(2s) and -# DEFAULT_APPROVAL_EXECUTION_TIMEOUT(12s). Currently these are not differentiated by metrics -# because the metrics are defined in `polkadot-node-core-pvf` which is a level below -# the relevant subsystems. -# That being said, we will take the simplifying assumption of testing only the -# 2s timeout. -# We do this check by ensuring all executions fall into bucket le="2" or lower. -# First, check if we have at least 1 sample, but we should have many more. -alice: reports histogram polkadot_pvf_execution_time has at least 1 samples in buckets ["0.1", "0.5", "1", "2"] within 10 seconds -bob: reports histogram polkadot_pvf_execution_time has at least 1 samples in buckets ["0.1", "0.5", "1", "2"] within 10 seconds -charlie: reports histogram polkadot_pvf_execution_time has at least 1 samples in buckets ["0.1", "0.5", "1", "2"] within 10 seconds -dave: reports histogram polkadot_pvf_execution_time has at least 1 samples in buckets ["0.1", "0.5", "1", "2"] within 10 seconds -ferdie: reports histogram polkadot_pvf_execution_time has at least 1 samples in buckets ["0.1", "0.5", "1", "2"] within 10 seconds -eve: reports histogram polkadot_pvf_execution_time has at least 1 samples in buckets ["0.1", "0.5", "1", "2"] within 10 seconds -one: reports histogram polkadot_pvf_execution_time has at least 1 samples in buckets ["0.1", "0.5", "1", "2"] within 10 seconds -two: reports histogram polkadot_pvf_execution_time has at least 1 samples in buckets ["0.1", "0.5", "1", "2"] within 10 seconds - -# Check if we have no samples > 2s. -alice: reports histogram polkadot_pvf_execution_time has 0 samples in buckets ["3", "4", "5", "6", "+Inf"] within 10 seconds -bob: reports histogram polkadot_pvf_execution_time has 0 samples in buckets ["3", "4", "5", "6", "+Inf"] within 10 seconds -charlie: reports histogram polkadot_pvf_execution_time has 0 samples in buckets ["3", "4", "5", "6", "+Inf"] within 10 seconds -dave: reports histogram polkadot_pvf_execution_time has 0 samples in buckets ["3", "4", "5", "6", "+Inf"] within 10 seconds -ferdie: reports histogram polkadot_pvf_execution_time has 0 samples in buckets ["3", "4", "5", "6", "+Inf"] within 10 seconds -eve: reports histogram polkadot_pvf_execution_time has 0 samples in buckets ["3", "4", "5", "6", "+Inf"] within 10 seconds -one: reports histogram polkadot_pvf_execution_time has 0 samples in buckets ["3", "4", "5", "6", "+Inf"] within 10 seconds -two: reports histogram polkadot_pvf_execution_time has 0 samples in buckets ["3", "4", "5", "6", "+Inf"] within 10 seconds