Skip to content
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

Added support for coretime-kusama/polkadot and people-kusama/polkadot #3961

Merged
merged 15 commits into from
Apr 4, 2024
Merged
Show file tree
Hide file tree
Changes from 3 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
115 changes: 115 additions & 0 deletions cumulus/parachains/chain-specs/coretime-kusama.json
seadanda marked this conversation as resolved.
Show resolved Hide resolved

Large diffs are not rendered by default.

6 changes: 6 additions & 0 deletions cumulus/parachains/chain-specs/coretime-polkadot.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"name": "Polkadot Coretime",
"id": "coretime-polkadot"
bkontur marked this conversation as resolved.
Show resolved Hide resolved
"chainType": "Live",
"todo": "generate chain spec"
}
6 changes: 6 additions & 0 deletions cumulus/parachains/chain-specs/people-kusama.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"name": "Kusama People",
"id": "people-kusama",
"chainType": "Live",
"todo": "generate chain spec"
}
6 changes: 6 additions & 0 deletions cumulus/parachains/chain-specs/people-polkadot.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"name": "Polkadot People",
"id": "people-polkadot",
"chainType": "Live",
"todo": "generate chain spec"
}
1 change: 1 addition & 0 deletions cumulus/polkadot-parachain/chain-specs/people-kusama.json
45 changes: 42 additions & 3 deletions cumulus/polkadot-parachain/src/chain_spec/coretime.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,12 @@ use std::{borrow::Cow, str::FromStr};
/// Collects all supported Coretime configurations.
#[derive(Debug, PartialEq, Clone, Copy)]
pub enum CoretimeRuntimeType {
Kusama,
KusamaLocal,

Polkadot,
PolkadotLocal,

// Live
Rococo,
// Local
Expand All @@ -42,6 +48,10 @@ impl FromStr for CoretimeRuntimeType {

fn from_str(value: &str) -> Result<Self, Self::Err> {
match value {
kusama::CORETIME_KUSAMA => Ok(CoretimeRuntimeType::Kusama),
kusama::CORETIME_KUSAMA_LOCAL => Ok(CoretimeRuntimeType::KusamaLocal),
polkadot::CORETIME_POLKADOT => Ok(CoretimeRuntimeType::Polkadot),
polkadot::CORETIME_POLKADOT_LOCAL => Ok(CoretimeRuntimeType::PolkadotLocal),
rococo::CORETIME_ROCOCO => Ok(CoretimeRuntimeType::Rococo),
rococo::CORETIME_ROCOCO_LOCAL => Ok(CoretimeRuntimeType::RococoLocal),
rococo::CORETIME_ROCOCO_DEVELOPMENT => Ok(CoretimeRuntimeType::RococoDevelopment),
Expand All @@ -56,6 +66,10 @@ impl FromStr for CoretimeRuntimeType {
impl From<CoretimeRuntimeType> for &str {
fn from(runtime_type: CoretimeRuntimeType) -> Self {
match runtime_type {
CoretimeRuntimeType::Kusama => kusama::CORETIME_KUSAMA,
CoretimeRuntimeType::KusamaLocal => kusama::CORETIME_KUSAMA_LOCAL,
CoretimeRuntimeType::Polkadot => polkadot::CORETIME_POLKADOT,
CoretimeRuntimeType::PolkadotLocal => polkadot::CORETIME_POLKADOT_LOCAL,
CoretimeRuntimeType::Rococo => rococo::CORETIME_ROCOCO,
CoretimeRuntimeType::RococoLocal => rococo::CORETIME_ROCOCO_LOCAL,
CoretimeRuntimeType::RococoDevelopment => rococo::CORETIME_ROCOCO_DEVELOPMENT,
Expand All @@ -69,9 +83,14 @@ impl From<CoretimeRuntimeType> for &str {
impl From<CoretimeRuntimeType> for ChainType {
fn from(runtime_type: CoretimeRuntimeType) -> Self {
match runtime_type {
CoretimeRuntimeType::Rococo | CoretimeRuntimeType::Westend => ChainType::Live,
CoretimeRuntimeType::RococoLocal | CoretimeRuntimeType::WestendLocal =>
ChainType::Local,
CoretimeRuntimeType::Kusama |
CoretimeRuntimeType::Polkadot |
CoretimeRuntimeType::Rococo |
CoretimeRuntimeType::Westend => ChainType::Live,
CoretimeRuntimeType::KusamaLocal |
CoretimeRuntimeType::PolkadotLocal |
CoretimeRuntimeType::RococoLocal |
CoretimeRuntimeType::WestendLocal => ChainType::Local,
CoretimeRuntimeType::RococoDevelopment | CoretimeRuntimeType::WestendDevelopment =>
ChainType::Development,
}
Expand All @@ -85,6 +104,12 @@ impl CoretimeRuntimeType {

pub fn load_config(&self) -> Result<Box<dyn ChainSpec>, String> {
match self {
CoretimeRuntimeType::Kusama => Ok(Box::new(GenericChainSpec::from_json_bytes(
&include_bytes!("../../chain-specs/coretime-kusama.json")[..],
)?)),
CoretimeRuntimeType::Polkadot => Ok(Box::new(GenericChainSpec::from_json_bytes(
&include_bytes!("../../chain-specs/coretime-polkadot.json")[..],
)?)),
bkontur marked this conversation as resolved.
Show resolved Hide resolved
CoretimeRuntimeType::Rococo => Ok(Box::new(GenericChainSpec::from_json_bytes(
&include_bytes!("../../chain-specs/coretime-rococo.json")[..],
)?)),
Expand All @@ -99,6 +124,10 @@ impl CoretimeRuntimeType {
Ok(Box::new(westend::local_config(*self, "westend-local"))),
CoretimeRuntimeType::WestendDevelopment =>
Ok(Box::new(westend::local_config(*self, "westend-dev"))),
other => Err(std::format!(
"No default config present for {:?}, you should provide a chain-spec as json file!",
other
)),
}
}
}
Expand Down Expand Up @@ -296,3 +325,13 @@ pub mod westend {
})
}
}

pub mod kusama {
pub(crate) const CORETIME_KUSAMA: &str = "coretime-kusama";
pub(crate) const CORETIME_KUSAMA_LOCAL: &str = "coretime-kusama-local";
}

pub mod polkadot {
pub(crate) const CORETIME_POLKADOT: &str = "coretime-polkadot";
pub(crate) const CORETIME_POLKADOT_LOCAL: &str = "coretime-polkadot-local";
}
28 changes: 28 additions & 0 deletions cumulus/polkadot-parachain/src/chain_spec/people.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@ use std::str::FromStr;
/// Collects all supported People configurations.
#[derive(Debug, PartialEq)]
pub enum PeopleRuntimeType {
Kusama,
KusamaLocal,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should not include the local variants. If people need them, they need to create the chain specs themselves. Most of the time you want for the local variants any way the latest code.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't the benchmark scripts use local?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, I just remember @serban300's PR where he had to add this local variants to be able run fellows zombienet tests for BridgeHubKusama/BridgeHubPolkadot.

We don't provide chain-specs for local variants here as I explained bellow: #3961 (comment).

These local variants are needed for parsing id string from chain-spec and used for managing what kind of node to run here: https://github.com/paritytech/polkadot-sdk/pull/3961/files#diff-517780020940588a81c29ec543f6c5dff196c985641a28826c955ac35d1aa02bR761-R764

I think, polkadot-parachain-bin should be maybe chain-agnostic and we should provide just chain-spec json file. So we should remove all these chain-specific stuff from polkadot-parachain and extract that to new crate chain-spec-generator for testnets as we have for fellows.
And also, for controlling what setup to run start_generic_aura_node vs start_generic_aura_lookahead_node vs start_asset_hub_node vs start_asset_hub_lookahead_node, we could add new command parameter (or maybe attribute to chain-spec?).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can improve and refactor whatever way, but let's continue here #3944 or is there any other issue?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't the benchmark scripts use local?

I think you need just chain-spec for benchmarks, e.g for fellows benchmarks, I just needed chain-spec-generator to generate a local chain spec for coretime-kusama-local, and then use polkadot binary:

./polkadot benchmark pallet \
    --chain=./$CHAIN-chain-spec.json

I didn't try to run benchmarks with polkadot-parachain, anyway omni-bencher is coming, so we won't even need chain-spec for benchmarking

Polkadot,
PolkadotLocal,
Rococo,
RococoLocal,
RococoDevelopment,
Expand All @@ -36,6 +40,10 @@ impl FromStr for PeopleRuntimeType {

fn from_str(value: &str) -> Result<Self, Self::Err> {
match value {
kusama::PEOPLE_KUSAMA => Ok(PeopleRuntimeType::Kusama),
kusama::PEOPLE_KUSAMA_LOCAL => Ok(PeopleRuntimeType::KusamaLocal),
polkadot::PEOPLE_POLKADOT => Ok(PeopleRuntimeType::Polkadot),
polkadot::PEOPLE_POLKADOT_LOCAL => Ok(PeopleRuntimeType::PolkadotLocal),
rococo::PEOPLE_ROCOCO => Ok(PeopleRuntimeType::Rococo),
rococo::PEOPLE_ROCOCO_LOCAL => Ok(PeopleRuntimeType::RococoLocal),
rococo::PEOPLE_ROCOCO_DEVELOPMENT => Ok(PeopleRuntimeType::RococoDevelopment),
Expand All @@ -52,6 +60,12 @@ impl PeopleRuntimeType {

pub fn load_config(&self) -> Result<Box<dyn ChainSpec>, String> {
match self {
PeopleRuntimeType::Kusama => Ok(Box::new(GenericChainSpec::from_json_bytes(
&include_bytes!("../../chain-specs/people-kusama.json")[..],
)?)),
PeopleRuntimeType::Polkadot => Ok(Box::new(GenericChainSpec::from_json_bytes(
&include_bytes!("../../chain-specs/people-polkadot.json")[..],
)?)),
PeopleRuntimeType::Rococo => Ok(Box::new(GenericChainSpec::from_json_bytes(
&include_bytes!("../../chain-specs/people-rococo.json")[..],
)?)),
Expand Down Expand Up @@ -82,6 +96,10 @@ impl PeopleRuntimeType {
"westend-development",
ParaId::new(1004),
))),
other => Err(std::format!(
"No default config present for {:?}, you should provide a chain-spec as json file!",
seadanda marked this conversation as resolved.
Show resolved Hide resolved
other
)),
}
}
}
Expand Down Expand Up @@ -318,3 +336,13 @@ pub mod westend {
})
}
}

pub mod kusama {
pub(crate) const PEOPLE_KUSAMA: &str = "people-kusama";
pub(crate) const PEOPLE_KUSAMA_LOCAL: &str = "people-kusama-local";
}

pub mod polkadot {
pub(crate) const PEOPLE_POLKADOT: &str = "people-polkadot";
pub(crate) const PEOPLE_POLKADOT_LOCAL: &str = "people-polkadot-local";
}
20 changes: 20 additions & 0 deletions cumulus/polkadot-parachain/src/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -759,6 +759,16 @@ pub fn run() -> Result<()> {
.map_err(Into::into),

Coretime(coretime_runtime_type) => match coretime_runtime_type {
chain_spec::coretime::CoretimeRuntimeType::Kusama |
chain_spec::coretime::CoretimeRuntimeType::KusamaLocal =>
crate::service::start_generic_aura_node(config, polkadot_config, collator_options, id, hwbench)
.await
.map(|r| r.0),
bkontur marked this conversation as resolved.
Show resolved Hide resolved
chain_spec::coretime::CoretimeRuntimeType::Polkadot |
chain_spec::coretime::CoretimeRuntimeType::PolkadotLocal =>
crate::service::start_generic_aura_node(config, polkadot_config, collator_options, id, hwbench)
.await
.map(|r| r.0),
bkontur marked this conversation as resolved.
Show resolved Hide resolved
chain_spec::coretime::CoretimeRuntimeType::Rococo |
chain_spec::coretime::CoretimeRuntimeType::RococoLocal |
chain_spec::coretime::CoretimeRuntimeType::RococoDevelopment |
Expand Down Expand Up @@ -790,6 +800,16 @@ pub fn run() -> Result<()> {
.map_err(Into::into),

People(people_runtime_type) => match people_runtime_type {
chain_spec::people::PeopleRuntimeType::Kusama |
chain_spec::people::PeopleRuntimeType::KusamaLocal =>
crate::service::start_generic_aura_node(config, polkadot_config, collator_options, id, hwbench)
.await
.map(|r| r.0),
bkontur marked this conversation as resolved.
Show resolved Hide resolved
chain_spec::people::PeopleRuntimeType::Polkadot |
chain_spec::people::PeopleRuntimeType::PolkadotLocal =>
crate::service::start_generic_aura_node(config, polkadot_config, collator_options, id, hwbench)
.await
.map(|r| r.0),
bkontur marked this conversation as resolved.
Show resolved Hide resolved
chain_spec::people::PeopleRuntimeType::Rococo |
chain_spec::people::PeopleRuntimeType::RococoLocal |
chain_spec::people::PeopleRuntimeType::RococoDevelopment |
Expand Down
10 changes: 10 additions & 0 deletions prdoc/pr_3961.prdoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
title: Added support for coretime-kusama/polkadot and people-kusama/polkadot

doc:
- audience: Node Operator
description: |
The support for running `coretime-kusama` and `people-kusama` collators with `polkadot-parachain-bin` have been added.

crates:
- name: polkadot-parachain-bin
bump: minor
Loading