-
Notifications
You must be signed in to change notification settings - Fork 1.2k
fix shared-core-idle-parachain test #8922
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
106 changes: 106 additions & 0 deletions
106
polkadot/zombienet-sdk-tests/tests/functional/shared_core_idle_parachain.rs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,106 @@ | ||
| // Copyright (C) Parity Technologies (UK) Ltd. | ||
| // SPDX-License-Identifier: Apache-2.0 | ||
|
|
||
| // Test that a parachain can keep producing blocks even if the other parachain with which it's | ||
| // sharing a core doesn't | ||
|
|
||
| use anyhow::anyhow; | ||
|
|
||
| use cumulus_zombienet_sdk_helpers::{assert_finality_lag, assert_finalized_para_throughput}; | ||
| use polkadot_primitives::Id as ParaId; | ||
| use serde_json::json; | ||
| use zombienet_sdk::{ | ||
| subxt::{self, ext::scale_value::value, OnlineClient, PolkadotConfig}, | ||
| subxt_signer::sr25519::dev, | ||
| NetworkConfigBuilder, | ||
| }; | ||
|
|
||
| #[tokio::test(flavor = "multi_thread")] | ||
| async fn shared_core_idle_parachain_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": 4, | ||
| "group_rotation_frequency": 4 | ||
| } | ||
| } | ||
| } | ||
| })) | ||
| .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) | ||
| // Don't onboard as parachain, as this would automatically add one more core and | ||
| // assign it to the para. | ||
| .onboard_as_parachain(false) | ||
| .with_default_command("polkadot-parachain") | ||
| .with_default_image(images.cumulus.as_str()) | ||
| .with_default_args(vec![ | ||
| ("-lparachain=debug,aura=debug").into(), | ||
| "--authoring=slot-based".into(), | ||
| ]) | ||
| .with_collator(|n| n.with_name("collator-2000")) | ||
| }) | ||
| .build() | ||
| .map_err(|e| { | ||
| let errs = e.into_iter().map(|e| e.to_string()).collect::<Vec<_>>().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_2000 = network.get_node("collator-2000")?; | ||
|
|
||
| let relay_client: OnlineClient<PolkadotConfig> = relay_node.wait_client().await?; | ||
| let alice = dev::alice(); | ||
|
|
||
| // Assign core 0 to be shared between paraid 2000 and another, non-existant paraid 2001. | ||
| let assign_core_call = subxt::tx::dynamic( | ||
| "Sudo", | ||
| "sudo", | ||
| vec![value! { | ||
| Coretime(assign_core { core: 0, begin: 0, assignment: ((Task(2000), 28800), (Task(2001), 28800)), end_hint: None() }) | ||
| }], | ||
| ); | ||
| relay_client | ||
| .tx() | ||
| .sign_and_submit_then_watch_default(&assign_core_call, &alice) | ||
| .await? | ||
| .wait_for_finalized_success() | ||
| .await?; | ||
|
|
||
| log::info!("Assigned core 0 to be shared between paras"); | ||
|
|
||
| // Check that para 2000 is essentially getting 12-second block time, while para 2001 does not | ||
| // produce anything. | ||
| assert_finalized_para_throughput( | ||
| &relay_client, | ||
| 15, | ||
| [(ParaId::from(2000), 5..9)].into_iter().collect(), | ||
| ) | ||
| .await?; | ||
|
|
||
| assert_finality_lag(¶_node_2000.wait_client().await?, 5).await?; | ||
|
|
||
| log::info!("Test finished successfully"); | ||
|
|
||
| Ok(()) | ||
| } |
38 changes: 0 additions & 38 deletions
38
polkadot/zombienet_tests/functional/0018-shared-core-idle-parachain.toml
This file was deleted.
Oops, something went wrong.
11 changes: 0 additions & 11 deletions
11
polkadot/zombienet_tests/functional/0018-shared-core-idle-parachain.zndsl
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| title: "paras pallet: don't assign core if para_kind is ParaThread" | ||
|
|
||
| doc: | ||
| - audience: Runtime Dev | ||
| description: |- | ||
| Only force assign core to genesis para if declared as parachain. | ||
| For parathread, proceed only with registering the para. | ||
|
|
||
| crates: | ||
| - name: polkadot-runtime-parachains | ||
| bump: minor |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't get this. What does
with_parachainfrom zombienet-sdk do so that we enter in this if?(I looked at the linked PR and still don't get it).
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
By default zombienet-sdk adds parachains to the genesis state (which end up calling this code that I modified). Here is what zombienet ends up doing: https://github.com/paritytech/zombienet-sdk/blob/722993c5665efa0dd74e190729fba95abc2c0b71/crates/orchestrator/src/generators/chain_spec.rs#L670.
Whether we add the para to genesis state is determined by the RegistrationStrategy.
If we set
onboard_as_parachain(false)(which I do here), thepara_kindwill end up being Parathread. And I don't want to have any core assigned if it's a parathread.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @alindima, could be use the
RegistrationStrategy::Manualhere? With this variant zombienet doesn't register the parachain, only generate the spec/artifacts and spawn the collator. Then you can register the para and assign the core from the test itself.wdyt?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's what this test used to do, but it's more tedious and it takes one extra session before the parachain starts producing blocks