Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
3b0bc90
fix(cumulus): add ah-westend-local parachain info genesis patch
iulianbarbu Jul 14, 2025
507d9a0
ah-westend: impl GetParachainInfo
iulianbarbu Jul 14, 2025
c0bc83f
Merge branch 'master' into fix-ah-westend-local-starting
iulianbarbu Jul 14, 2025
dcb077d
Update from github-actions[bot] running command 'prdoc'
github-actions[bot] Jul 14, 2025
a715b82
update prdoc
iulianbarbu Jul 15, 2025
18d7acf
Merge branch 'master' of github.com:paritytech/polkadot-sdk into fix-…
iulianbarbu Jul 15, 2025
ed6758b
Apply suggestions from code review
iulianbarbu Jul 15, 2025
0eba8c1
Update prdoc/pr_9201.prdoc
iulianbarbu Jul 15, 2025
f79eae8
Update prdoc/pr_9201.prdoc
iulianbarbu Jul 16, 2025
f3a286c
Update prdoc/pr_9201.prdoc
iulianbarbu Jul 16, 2025
cc19091
Update pr_9201.prdoc
iulianbarbu Jul 18, 2025
22354df
remove para_id deprecation from logs/docs/code
iulianbarbu Jul 22, 2025
bc8b8f2
chain-spec-builder: update docs
iulianbarbu Aug 1, 2025
8604bc8
Merge branch 'master' into fix-ah-westend-local-starting
iulianbarbu Aug 1, 2025
09297cb
Apply suggestions from code review
iulianbarbu Aug 1, 2025
b41cd14
chain-spec-builder: update README
iulianbarbu Aug 1, 2025
507b83b
fix/prdoc: remvoe paranthesis audience
iulianbarbu Aug 1, 2025
0b2aff5
polkadot-omni-node-lib: add extensions relay chain getter
iulianbarbu Aug 1, 2025
9d2ccdd
polkadot-parachain: fix clippy
iulianbarbu Aug 1, 2025
8141807
polkadot-omni-node-lib: ensure GetParachainInfo is implemented before…
iulianbarbu Aug 7, 2025
2ffdafb
Update prdoc/pr_9201.prdoc
iulianbarbu Aug 7, 2025
1caf869
Merge branch 'master' into fix-ah-westend-local-starting
iulianbarbu Aug 8, 2025
2e347ca
update prdoc
iulianbarbu Aug 12, 2025
17b8e3b
experiment check-semver
iulianbarbu Aug 12, 2025
b31f3f3
install parity-publish with locked
iulianbarbu Aug 12, 2025
782da88
Merge branch 'master' into fix-ah-westend-local-starting
iulianbarbu Aug 12, 2025
e01266b
Update cumulus/polkadot-parachain/src/chain_spec/asset_hubs.rs
iulianbarbu Aug 13, 2025
3ebdfeb
Revert "install parity-publish with locked"
iulianbarbu Aug 12, 2025
c352e00
Revert "experiment check-semver"
iulianbarbu Aug 12, 2025
f92533b
Merge branch 'master' into fix-ah-westend-local-starting
iulianbarbu Aug 13, 2025
fc3e651
Merge branch 'master' into fix-ah-westend-local-starting
iulianbarbu Aug 18, 2025
5e572b8
Merge branch 'master' into fix-ah-westend-local-starting
iulianbarbu Aug 18, 2025
324a32a
Merge branch 'master' into fix-ah-westend-local-starting
sandreim Aug 19, 2025
f650be3
simplify para_id genesis patching
iulianbarbu Aug 20, 2025
10c7a31
Merge branch 'master' into fix-ah-westend-local-starting
iulianbarbu Aug 20, 2025
6d3949c
remove extra para_id params
iulianbarbu Aug 20, 2025
63d3097
fix clippy
iulianbarbu Aug 20, 2025
1ad27bd
Merge branch 'master' into ib-fix-getparachaininfo
iulianbarbu Aug 20, 2025
75ee9ab
fix: publish-check-compile support no prdoc PRs
iulianbarbu Aug 20, 2025
6e85b8f
update prdoc number
iulianbarbu Aug 20, 2025
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
18 changes: 13 additions & 5 deletions .github/workflows/publish-check-compile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,9 @@ jobs:

- name: parity-publish update plan w/o current prdoc
run: |
mv prdoc/$CURRENT_PRDOC .
if [ -f prdoc/$CURRENT_PRDOC ]; then
mv prdoc/$CURRENT_PRDOC .
fi
parity-publish --color always plan --skip-check --prdoc prdoc/

# The code base is not in master's state (due to commits brought by the
Expand All @@ -61,17 +63,23 @@ jobs:

- name: move all prdocs except current one to unstable dir
run: |
mkdir prdoc/unstable
mv prdoc/pr_*.prdoc prdoc/unstable
if [ -f $CURRENT_PRDOC ]; then
mkdir prdoc/unstable
mv prdoc/pr_*.prdoc prdoc/unstable
mv $CURRENT_PRDOC prdoc
fi

- name: parity-publish update plan just for PR's prdoc
run: parity-publish --color always plan --skip-check --prdoc prdoc/
run: |
if [ -f "prdoc/$CURRENT_PRDOC" ]; then
parity-publish --color always plan --skip-check --prdoc prdoc/
fi

- name: parity-publish apply plan
run: parity-publish --color always apply --registry
run: |
if [ -f "prdoc/$CURRENT_PRDOC" ]; then
parity-publish --color always apply --registry
fi

- name: parity-publish check compile
run: |
Expand Down
10 changes: 5 additions & 5 deletions cumulus/polkadot-omni-node/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,11 @@ local variants are available only for a build of `polkadot-omni-node` with
`westend-native` and `rococo-native` features respectively.

<!-- TODO: https://github.com/paritytech/polkadot-sdk/issues/8747 -->
<!-- TODO: https://github.com/paritytech/polkadot-sdk/issues/8740 -->
Additionaly, although deprecated, the `--para-id` flag can still be used to set the JSON key named
`para_id`. The removal of the flag will happen starting with `stable2512`. The alternative of not using
it is to implement the `cumulus_primitives_core::GetParachainInfo` runtime API for the runtime, and
upgrade it on-chain as well, to be compatible with nodes released starting with `stable2512`.
Additionaly, the `--para-id` flag can be used to set the JSON key named `para_id`. This flag is used
by nodes to determine the parachain id, and it is especially useful when the parachain id can not be
fetched from the runtime, when the state points to a runtime that does not implement the
`cumulus_primitives_core::GetParachainInfo` runtime API. It is recommended for runtimes to implement
the runtime API and be upgraded on chain.

Example command bellow:

Expand Down
2 changes: 1 addition & 1 deletion cumulus/polkadot-omni-node/lib/src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,7 @@ impl<Config: CliConfig> RelayChainCli<Config> {
let base = FromArgMatches::from_arg_matches(&matches).unwrap_or_else(|e| e.exit());

let extension = Extensions::try_get(&*para_config.chain_spec);
let chain_id = extension.map(|e| e.relay_chain.clone());
let chain_id = extension.map(|e| e.relay_chain());

let base_path = para_config.base_path.path().join("polkadot");
Self { base, chain_id, base_path: Some(base_path), _phantom: Default::default() }
Expand Down
73 changes: 29 additions & 44 deletions cumulus/polkadot-omni-node/lib/src/common/chain_spec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,59 +32,52 @@ pub struct DiskChainSpecLoader;

impl LoadSpec for DiskChainSpecLoader {
fn load_spec(&self, path: &str) -> Result<Box<dyn ChainSpec>, String> {
Ok(Box::new(DeprecatedGenericChainSpec::from_json_file(path.into())?))
}
}

/// Generic extensions for Parachain ChainSpecs.
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, ChainSpecExtension)]
pub struct Extensions {
/// The relay chain of the Parachain.
#[serde(alias = "relayChain", alias = "RelayChain")]
pub relay_chain: String,
}

impl Extensions {
/// Try to get the extension from the given `ChainSpec`.
pub fn try_get(chain_spec: &dyn sc_service::ChainSpec) -> Option<&Self> {
sc_chain_spec::get_extension(chain_spec.extensions())
Ok(Box::new(GenericChainSpec::from_json_file(path.into())?))
}
}

/// Generic extensions for Parachain ChainSpecs used for extracting the extensions from chain specs.
/// This is also used only while `para_id` is around the corner.
// TODO: https://github.com/paritytech/polkadot-sdk/issues/8747
// TODO: https://github.com/paritytech/polkadot-sdk/issues/8740
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, ChainSpecExtension)]
pub struct DeprecatedExtensions {
pub struct Extensions {
/// The relay chain of the Parachain. It is kept here only for compatibility reasons until
/// people migrate to using the new `Extensions` struct and associated logic in the node
/// corresponding to pulling the parachain id from the runtime.
#[serde(alias = "relayChain", alias = "RelayChain")]
pub relay_chain: String,
relay_chain: String,
/// The id of the Parachain.
#[serde(alias = "paraId", alias = "ParaId")]
#[deprecated(
note = "The para_id information is not required anymore and will be removed starting with `stable2512`. Runtimes must implement a new API called `cumulus_primitives_core::GetParachainInfo` to still be compatible with node versions starting with `stable2512`."
)]
pub para_id: Option<u32>,
para_id: Option<u32>,
}

impl DeprecatedExtensions {
impl Extensions {
/// Try to get the extension from the given `ChainSpec`.
pub fn try_get(chain_spec: &dyn sc_service::ChainSpec) -> Option<&Self> {
sc_chain_spec::get_extension(chain_spec.extensions())
}

/// Create the extensions only with the relay_chain.
pub fn new_with_relay_chain(relay_chain: String) -> Self {
Extensions { relay_chain, para_id: None }
}

/// Initialize extensions based on given parameters.
pub fn new(relay_chain: String, para_id: u32) -> Self {
Extensions { relay_chain, para_id: Some(para_id) }
}

/// Para id field getter
pub fn para_id(&self) -> Option<u32> {
self.para_id
}

/// Relay chain field getter
pub fn relay_chain(&self) -> String {
self.relay_chain.clone()
}
}

/// Generic chain spec for all polkadot-parachain runtimes
pub type GenericChainSpec = sc_service::GenericChainSpec<Extensions>;
/// Generic chain spec which keeps chain spec loading compatible for those who provide
/// `para_id` extension instead of implementing the runtime API
/// `cumulus_primitives_core::GetParachainInfo`.
// TODO: https://github.com/paritytech/polkadot-sdk/issues/8747
// TODO: https://github.com/paritytech/polkadot-sdk/issues/8740
pub type DeprecatedGenericChainSpec = sc_service::GenericChainSpec<DeprecatedExtensions>;

#[cfg(test)]
mod tests {
Expand All @@ -97,21 +90,13 @@ mod tests {
let pascal_case = r#"{"RelayChain":"relay","ParaId":1}"#;
let para_id_missing = r#"{"RelayChain":"westend"}"#;

let camel_case_extension: DeprecatedExtensions = serde_json::from_str(camel_case).unwrap();
let snake_case_extension: DeprecatedExtensions = serde_json::from_str(snake_case).unwrap();
let pascal_case_extension: DeprecatedExtensions =
serde_json::from_str(pascal_case).unwrap();
let camel_case_extension: Extensions = serde_json::from_str(camel_case).unwrap();
let snake_case_extension: Extensions = serde_json::from_str(snake_case).unwrap();
let pascal_case_extension: Extensions = serde_json::from_str(pascal_case).unwrap();
let missing_paraid_extension: Extensions = serde_json::from_str(para_id_missing).unwrap();
let missing_paraid_deprecated: DeprecatedExtensions =
serde_json::from_str(para_id_missing).unwrap();
assert_eq!(camel_case_extension, snake_case_extension);
assert_eq!(snake_case_extension, pascal_case_extension);
assert_eq!(missing_paraid_extension.relay_chain, "westend".to_string());

// TODO: remove it once `para_id` is removed: https://github.com/paritytech/polkadot-sdk/issues/8740
assert_eq!(missing_paraid_deprecated.relay_chain, "westend".to_string());
#[allow(deprecated)]
let test = missing_paraid_deprecated.para_id.is_none();
assert!(test);
assert!(missing_paraid_extension.para_id.is_none());
}
}
36 changes: 22 additions & 14 deletions cumulus/polkadot-omni-node/lib/src/common/spec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
// limitations under the License.

use crate::{
chain_spec::DeprecatedExtensions,
chain_spec::Extensions,
common::{
command::NodeCommandRunner,
rpc::BuildRpcExtensions,
Expand Down Expand Up @@ -51,7 +51,7 @@ use sc_telemetry::{TelemetryHandle, TelemetryWorker};
use sc_tracing::tracing::Instrument;
use sc_transaction_pool::TransactionPoolHandle;
use sc_transaction_pool_api::OffchainTransactionPoolFactory;
use sp_api::ProvideRuntimeApi;
use sp_api::{ApiExt, ProvideRuntimeApi};
use sp_keystore::KeystorePtr;
use sp_runtime::traits::AccountIdConversion;
use std::{future::Future, pin::Pin, sync::Arc, time::Duration};
Expand Down Expand Up @@ -157,19 +157,27 @@ pub(crate) trait BaseNodeSpec {
parachain_config: &Configuration,
) -> Option<ParaId> {
let best_hash = client.chain_info().best_hash;
let para_id = if let Ok(para_id) = client.runtime_api().parachain_id(best_hash) {
para_id
let para_id = if client
.runtime_api()
.has_api::<dyn GetParachainInfo<Self::Block>>(best_hash)
.ok()
.filter(|has_api| *has_api)
.is_some()
{
client
.runtime_api()
.parachain_id(best_hash)
.inspect_err(|err| {
log::error!(
"`cumulus_primitives_core::GetParachainInfo` runtime API call errored with {}",
err
);
})
.ok()?
} else {
// TODO: remove this once `para_id` extension is removed: https://github.com/paritytech/polkadot-sdk/issues/8740
#[allow(deprecated)]
let id = ParaId::from(
DeprecatedExtensions::try_get(&*parachain_config.chain_spec)
.and_then(|ext| ext.para_id)?,
);
// TODO: https://github.com/paritytech/polkadot-sdk/issues/8747
// TODO: https://github.com/paritytech/polkadot-sdk/issues/8740
log::info!("Deprecation notice: the parachain id was provided via the chain spec. This way of providing the parachain id to the node is not recommended. The alternative is to implement the `cumulus_primitives_core::GetParachainInfo` runtime API in the runtime, and upgrade it on-chain. Starting with `stable2512` providing the parachain id via the chain spec will not be supported anymore.");
id
ParaId::from(
Extensions::try_get(&*parachain_config.chain_spec).and_then(|ext| ext.para_id())?,
)
};

let parachain_account =
Expand Down
26 changes: 6 additions & 20 deletions cumulus/polkadot-parachain/src/chain_spec/asset_hubs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ pub fn asset_hub_westend_development_config() -> GenericChainSpec {
GenericChainSpec::builder(
asset_hub_westend_runtime::WASM_BINARY
.expect("WASM binary was not built, please build it!"),
Extensions { relay_chain: "westend".into() },
Extensions::new_with_relay_chain("westend".into()),
)
.with_name("Westend Asset Hub Development")
.with_id("asset-hub-westend-dev")
Expand All @@ -43,7 +43,7 @@ pub fn asset_hub_westend_local_config() -> GenericChainSpec {
GenericChainSpec::builder(
asset_hub_westend_runtime::WASM_BINARY
.expect("WASM binary was not built, please build it!"),
Extensions { relay_chain: "westend-local".into() },
Extensions::new_with_relay_chain("westend-local".into()),
)
.with_name("Westend Asset Hub Local")
.with_id("asset-hub-westend-local")
Expand All @@ -61,7 +61,7 @@ pub fn asset_hub_westend_config() -> GenericChainSpec {
GenericChainSpec::builder(
asset_hub_westend_runtime::WASM_BINARY
.expect("WASM binary was not built, please build it!"),
Extensions { relay_chain: "westend".into() },
Extensions::new_with_relay_chain("westend".into()),
)
.with_name("Westend Asset Hub")
.with_id("asset-hub-westend")
Expand All @@ -80,29 +80,22 @@ pub fn asset_hub_rococo_development_config() -> GenericChainSpec {
properties,
"Rococo Asset Hub Development",
"asset-hub-rococo-dev",
1000,
)
}

fn asset_hub_rococo_like_development_config(
properties: sc_chain_spec::Properties,
name: &str,
chain_id: &str,
para_id: u32,
) -> GenericChainSpec {
GenericChainSpec::builder(
asset_hub_rococo_runtime::WASM_BINARY.expect("WASM binary was not built, please build it!"),
Extensions { relay_chain: "rococo-dev".into() },
Extensions::new_with_relay_chain("rococo-dev".into()),
)
.with_name(name)
.with_id(chain_id)
.with_chain_type(ChainType::Local)
.with_genesis_config_preset_name(sp_genesis_builder::DEV_RUNTIME_PRESET)
.with_genesis_config_patch(serde_json::json!({
"parachainInfo": {
"parachainId": para_id,
},
}))
.with_properties(properties)
.build()
}
Expand All @@ -116,29 +109,22 @@ pub fn asset_hub_rococo_local_config() -> GenericChainSpec {
properties,
"Rococo Asset Hub Local",
"asset-hub-rococo-local",
1000,
)
}

fn asset_hub_rococo_like_local_config(
properties: sc_chain_spec::Properties,
name: &str,
chain_id: &str,
para_id: u32,
) -> GenericChainSpec {
GenericChainSpec::builder(
asset_hub_rococo_runtime::WASM_BINARY.expect("WASM binary was not built, please build it!"),
Extensions { relay_chain: "rococo-local".into() },
Extensions::new_with_relay_chain("rococo-local".into()),
)
.with_name(name)
.with_id(chain_id)
.with_chain_type(ChainType::Local)
.with_genesis_config_preset_name(sp_genesis_builder::LOCAL_TESTNET_RUNTIME_PRESET)
.with_genesis_config_patch(serde_json::json!({
"parachainInfo": {
"parachainId": para_id,
},
}))
.with_properties(properties)
.build()
}
Expand All @@ -149,7 +135,7 @@ pub fn asset_hub_rococo_genesis_config() -> GenericChainSpec {
properties.insert("tokenDecimals".into(), 12.into());
GenericChainSpec::builder(
asset_hub_rococo_runtime::WASM_BINARY.expect("WASM binary was not built, please build it!"),
Extensions { relay_chain: "rococo".into() },
Extensions::new_with_relay_chain("rococo".into()),
)
.with_name("Rococo Asset Hub")
.with_id("asset-hub-rococo")
Expand Down
Loading