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 13 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
111 changes: 111 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.

119 changes: 119 additions & 0 deletions cumulus/parachains/chain-specs/people-kusama.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions cumulus/polkadot-parachain/chain-specs/people-kusama.json
44 changes: 41 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,11 @@ 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 =>
todo!("Generate chain-spec: ../../chain-specs/coretime-polkadot.json"),
CoretimeRuntimeType::Rococo => Ok(Box::new(GenericChainSpec::from_json_bytes(
&include_bytes!("../../chain-specs/coretime-rococo.json")[..],
)?)),
Expand All @@ -99,6 +123,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 +324,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";
}
27 changes: 27 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,11 @@ 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 =>
todo!("Generate chain-spec: ../../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 +95,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 +335,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";
}
8 changes: 8 additions & 0 deletions cumulus/polkadot-parachain/src/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -759,6 +759,10 @@ 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 |
chain_spec::coretime::CoretimeRuntimeType::Polkadot |
chain_spec::coretime::CoretimeRuntimeType::PolkadotLocal |
chain_spec::coretime::CoretimeRuntimeType::Rococo |
chain_spec::coretime::CoretimeRuntimeType::RococoLocal |
chain_spec::coretime::CoretimeRuntimeType::RococoDevelopment |
Expand Down Expand Up @@ -790,6 +794,10 @@ 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 |
chain_spec::people::PeopleRuntimeType::Polkadot |
chain_spec::people::PeopleRuntimeType::PolkadotLocal |
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