Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 29 additions & 26 deletions .github/workflows/zombienet_polkadot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -292,32 +292,6 @@ jobs:
local-dir: "${{ env.LOCAL_DIR }}/functional"
#
#
zombienet-polkadot-functional-0018-shared-core-idle-parachain:
needs: [preflight]
if: ${{ (needs.preflight.outputs.changes_substrate || needs.preflight.outputs.changes_polkadot) && ! contains(needs.preflight.outputs.FLAKY_TESTS, 'zombienet-polkadot-functional-0018-shared-core-idle-parachain') }}
runs-on: ${{ needs.preflight.outputs.ZOMBIENET_RUNNER }} # NOTE: should be zombienet-arc-runner (without quotes)
timeout-minutes: 60
container:
image: ${{ needs.preflight.outputs.ZOMBIENET_IMAGE }}
env:
ZOMBIENET_INTEGRATION_TEST_IMAGE: "${{ needs.preflight.outputs.TEMP_IMAGES_BASE }}/polkadot-debug:${{ needs.preflight.outputs.DOCKER_IMAGES_VERSION }}"
CUMULUS_IMAGE: "${{ needs.preflight.outputs.TEMP_IMAGES_BASE }}/polkadot-parachain-debug:${{ needs.preflight.outputs.DOCKER_IMAGES_VERSION }}"
DEBUG: ${{ needs.preflight.outputs.DEBUG }}
steps:
- name: Checkout
uses: actions/checkout@v4

- name: cp_script
run: |
cp --remove-destination ${LOCAL_DIR}/assign-core.js ${LOCAL_DIR}/functional

- name: zombienet_test
uses: ./.github/actions/zombienet
with:
test: "0018-shared-core-idle-parachain.zndsl"
local-dir: "${{ env.LOCAL_DIR }}/functional"
#
#
zombienet-polkadot-functional-0019-coretime-collation-fetching-fairness:
needs: [preflight]
if: ${{ (needs.preflight.outputs.changes_substrate || needs.preflight.outputs.changes_polkadot) && ! contains(needs.preflight.outputs.FLAKY_TESTS, 'zombienet-polkadot-functional-0019-coretime-collation-fetching-fairness') }}
Expand Down Expand Up @@ -882,3 +856,32 @@ jobs:
ref-slug: ${{ needs.preflight.outputs.SOURCE_REF_SLUG }}
test: "functional::approved_peer_mixed_validators::approved_peer_mixed_validators_test"
prefix: "polkadot"

#
#
zombienet-polkadot-shared-core-idle-parachain:
needs: [preflight]
if: ${{ (needs.preflight.outputs.changes_substrate || needs.preflight.outputs.changes_polkadot) && ! contains(needs.preflight.outputs.FLAKY_TESTS, 'zombienet-polkadot-functional-spam-statement-distribution-requests') }}
runs-on: ${{ needs.preflight.outputs.ZOMBIENET_RUNNER }} # NOTE: should be zombienet-arc-runner (without quotes)
timeout-minutes: 60
container:
image: ${{ needs.preflight.outputs.ZOMBIENET_IMAGE }}
env:
# sdk tests are looking for POLKADOT_IMAGE
POLKADOT_IMAGE: "${{ needs.preflight.outputs.TEMP_IMAGES_BASE }}/polkadot-debug:${{ needs.preflight.outputs.DOCKER_IMAGES_VERSION }}"
CUMULUS_IMAGE: "${{ needs.preflight.outputs.TEMP_IMAGES_BASE }}/polkadot-parachain-debug:${{ needs.preflight.outputs.DOCKER_IMAGES_VERSION }}"
RUST_LOG: ${{ needs.preflight.outputs.RUST_LOG }}
ZOMBIE_PROVIDER: ${{ needs.preflight.outputs.ZOMBIE_PROVIDER }}

steps:
- name: Checkout
uses: actions/checkout@v4

- name: zombienet_test
uses: ./.github/actions/zombienet-sdk
with:
gh-token: ${{ secrets.GITHUB_TOKEN }}
build-id: ${{ needs.preflight.outputs.BUILD_RUN_ID }}
ref-slug: ${{ needs.preflight.outputs.SOURCE_REF_SLUG }}
test: "functional::shared_core_idle_parachain::shared_core_idle_parachain_test"
prefix: "polkadot"
6 changes: 4 additions & 2 deletions polkadot/runtime/parachains/src/paras/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -967,8 +967,10 @@ pub mod pallet {
panic!("empty validation code is not allowed in genesis");
}
Pallet::<T>::initialize_para_now(&mut parachains, *id, genesis_args);
T::AssignCoretime::assign_coretime(*id)
.expect("Assigning coretime works at genesis; qed");
if genesis_args.para_kind == ParaKind::Parachain {
Copy link
Copy Markdown
Contributor

@tdimitrov tdimitrov Jun 20, 2025

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_parachain from zombienet-sdk do so that we enter in this if?
(I looked at the linked PR and still don't get it).

Copy link
Copy Markdown
Contributor Author

@alindima alindima Jun 20, 2025

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), the para_kind will end up being Parathread. And I don't want to have any core assigned if it's a parathread.

Copy link
Copy Markdown
Contributor

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::Manual here? 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?

Copy link
Copy Markdown
Contributor Author

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

T::AssignCoretime::assign_coretime(*id)
.expect("Assigning coretime works at genesis; qed");
}
}
// parachains are flushed on drop
}
Expand Down
1 change: 1 addition & 0 deletions polkadot/zombienet-sdk-tests/tests/functional/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,6 @@ mod approval_voting_coalescing;
mod approved_peer_mixed_validators;
mod async_backing_6_seconds_rate;
mod duplicate_collations;
mod shared_core_idle_parachain;
mod spam_statement_distribution_requests;
mod sync_backing;
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(&para_node_2000.wait_client().await?, 5).await?;

log::info!("Test finished successfully");

Ok(())
}

This file was deleted.

This file was deleted.

11 changes: 11 additions & 0 deletions prdoc/pr_8922.prdoc
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
Loading