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
13 changes: 12 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ members = [
"cumulus/pallets/xcm",
"cumulus/pallets/xcmp-queue",
"cumulus/parachains/common",
"cumulus/parachains/common/types",
"cumulus/parachains/integration-tests/emulated/chains/parachains/assets/asset-hub-rococo",
"cumulus/parachains/integration-tests/emulated/chains/parachains/assets/asset-hub-westend",
"cumulus/parachains/integration-tests/emulated/chains/parachains/bridges/bridge-hub-rococo",
Expand Down Expand Up @@ -1100,6 +1101,7 @@ pallet-xcm-precompiles = { path = "polkadot/xcm/pallet-xcm/precompiles", default
parachain-info = { path = "cumulus/parachains/pallets/parachain-info", default-features = false, package = "staging-parachain-info" }
parachain-template-runtime = { path = "templates/parachain/runtime" }
parachains-common = { path = "cumulus/parachains/common", default-features = false }
parachains-common-types = { path = "cumulus/parachains/common/types", default-features = false }
parachains-relay = { path = "bridges/relays/parachains" }
parachains-runtimes-test-utils = { path = "cumulus/parachains/runtimes/test-utils", default-features = false }
parity-bytes = { version = "0.1.2", default-features = false }
Expand Down
2 changes: 2 additions & 0 deletions cumulus/parachains/common/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ cumulus-primitives-core = { workspace = true }
cumulus-primitives-utility = { workspace = true }
pallet-collator-selection = { workspace = true }
parachain-info = { workspace = true }
parachains-common-types = { workspace = true }

[features]
default = ["std"]
Expand All @@ -65,6 +66,7 @@ std = [
"pallet-treasury/std",
"pallet-xcm/std",
"parachain-info/std",
"parachains-common-types/std",
"polkadot-primitives/std",
"polkadot-runtime-common/std",
"scale-info/std",
Expand Down
72 changes: 2 additions & 70 deletions cumulus/parachains/common/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,66 +22,15 @@ pub mod message_queue;
pub mod pay;
pub mod xcm_config;
pub use constants::*;
pub use opaque::*;
pub use types::*;

/// Common types of parachains.
mod types {
use sp_runtime::traits::{IdentifyAccount, Verify};

/// An index to a block.
pub type BlockNumber = u32;

/// Alias to 512-bit hash when used in the context of a transaction signature on the chain.
pub type Signature = sp_runtime::MultiSignature;

/// Some way of identifying an account on the chain. We intentionally make it equivalent
/// to the public key of our transaction signing scheme.
pub type AccountId = <<Signature as Verify>::Signer as IdentifyAccount>::AccountId;

/// The type for looking up accounts. We don't expect more than 4 billion of them, but you
/// never know...
pub type AccountIndex = u32;

/// Balance of an account.
pub type Balance = u128;

/// Index of a transaction in the chain.
pub type Nonce = u32;

/// A hash of some data used by the chain.
pub type Hash = sp_core::H256;

/// Digest item type.
pub type DigestItem = sp_runtime::generic::DigestItem;

// Aura consensus authority.
pub type AuraId = sp_consensus_aura::sr25519::AuthorityId;

// Aura consensus authority used by Asset Hub Polkadot.
//
// Because of registering the authorities with an ed25519 key before switching from Shell
// to Asset Hub Polkadot, we were required to deploy a hotfix that changed Asset Hub Polkadot's
// Aura keys to ed22519. In the future that may change again.
pub type AssetHubPolkadotAuraId = sp_consensus_aura::ed25519::AuthorityId;

// Id used for identifying assets.
pub type AssetIdForTrustBackedAssets = u32;

// Id used for identifying non-fungible collections.
pub type CollectionId = u32;

// Id used for identifying non-fungible items.
pub type ItemId = u32;
}
pub use parachains_common_types::{opaque::*, *};

/// Common constants of parachains.
mod constants {
use super::types::BlockNumber;
use frame_support::{
weights::{constants::WEIGHT_REF_TIME_PER_SECOND, Weight},
PalletId,
};
use parachains_common_types::BlockNumber;
use sp_runtime::Perbill;

/// This determines the average expected block time that we are targeting. Blocks will be
Expand Down Expand Up @@ -120,20 +69,3 @@ mod constants {
/// Treasury pallet id of the local chain, used to convert into AccountId
pub const TREASURY_PALLET_ID: PalletId = PalletId(*b"py/trsry");
}

/// Opaque types. These are used by the CLI to instantiate machinery that don't need to know
/// the specifics of the runtime. They can then be made to be agnostic over specific formats
/// of data like extrinsics, allowing for them to continue syncing the network through upgrades
/// to even the core data structures.
pub mod opaque {
use super::*;
use sp_runtime::{generic, traits::BlakeTwo256};

pub use sp_runtime::OpaqueExtrinsic as UncheckedExtrinsic;
/// Opaque block header type.
pub type Header = generic::Header<BlockNumber, BlakeTwo256>;
/// Opaque block type.
pub type Block = generic::Block<Header, UncheckedExtrinsic>;
/// Opaque block identifier type.
pub type BlockId = generic::BlockId<Block>;
}
25 changes: 25 additions & 0 deletions cumulus/parachains/common/types/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
[package]
name = "parachains-common-types"
version = "0.1.0"
authors.workspace = true
edition.workspace = true
description = "Common types for parachains"
license = "Apache-2.0"
homepage.workspace = true
repository.workspace = true

[lints]
workspace = true

[dependencies]
sp-consensus-aura = { workspace = true }
sp-core = { workspace = true }
sp-runtime = { workspace = true }

[features]
default = ["std"]
std = [
"sp-consensus-aura/std",
"sp-core/std",
"sp-runtime/std",
]
65 changes: 65 additions & 0 deletions cumulus/parachains/common/types/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
// Copyright (C) Parity Technologies (UK) Ltd.
// SPDX-License-Identifier: Apache-2.0

// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

#![cfg_attr(not(feature = "std"), no_std)]

pub mod opaque;

use sp_runtime::traits::{IdentifyAccount, Verify};

/// An index to a block.
pub type BlockNumber = u32;

/// Alias to 512-bit hash when used in the context of a transaction signature on the chain.
pub type Signature = sp_runtime::MultiSignature;

/// Some way of identifying an account on the chain. We intentionally make it equivalent
/// to the public key of our transaction signing scheme.
pub type AccountId = <<Signature as Verify>::Signer as IdentifyAccount>::AccountId;

/// The type for looking up accounts. We don't expect more than 4 billion of them, but you
/// never know...
pub type AccountIndex = u32;

/// Balance of an account.
pub type Balance = u128;

/// Index of a transaction in the chain.
pub type Nonce = u32;

/// A hash of some data used by the chain.
pub type Hash = sp_core::H256;

/// Digest item type.
pub type DigestItem = sp_runtime::generic::DigestItem;

// Aura consensus authority.
pub type AuraId = sp_consensus_aura::sr25519::AuthorityId;

// Aura consensus authority used by Asset Hub Polkadot.
//
// Because of registering the authorities with an ed25519 key before switching from Shell
// to Asset Hub Polkadot, we were required to deploy a hotfix that changed Asset Hub Polkadot's
// Aura keys to ed22519. In the future that may change again.
pub type AssetHubPolkadotAuraId = sp_consensus_aura::ed25519::AuthorityId;

// Id used for identifying assets.
pub type AssetIdForTrustBackedAssets = u32;

// Id used for identifying non-fungible collections.
pub type CollectionId = u32;

// Id used for identifying non-fungible items.
pub type ItemId = u32;
25 changes: 25 additions & 0 deletions cumulus/parachains/common/types/src/opaque.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
// Copyright (C) Parity Technologies (UK) Ltd.
// SPDX-License-Identifier: Apache-2.0

// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

use super::*;
use sp_runtime::{generic, traits::BlakeTwo256};

pub use sp_runtime::OpaqueExtrinsic as UncheckedExtrinsic;
/// Opaque block header type.
pub type Header = generic::Header<BlockNumber, BlakeTwo256>;
/// Opaque block type.
pub type Block = generic::Block<Header, UncheckedExtrinsic>;
/// Opaque block identifier type.
pub type BlockId = generic::BlockId<Block>;
4 changes: 1 addition & 3 deletions cumulus/polkadot-omni-node/lib/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ serde_json = { workspace = true, default-features = true }

# Local
jsonrpsee = { features = ["server"], workspace = true }
parachains-common = { workspace = true, default-features = true }
parachains-common-types = { workspace = true, default-features = true }
scale-info = { workspace = true }
subxt-metadata = { workspace = true, default-features = true }

Expand Down Expand Up @@ -123,7 +123,6 @@ runtime-benchmarks = [
"frame-benchmarking/runtime-benchmarks",
"frame-support/runtime-benchmarks",
"pallet-transaction-payment/runtime-benchmarks",
"parachains-common/runtime-benchmarks",
"polkadot-cli/runtime-benchmarks",
"polkadot-primitives/runtime-benchmarks",
"sc-client-db/runtime-benchmarks",
Expand All @@ -134,7 +133,6 @@ try-runtime = [
"frame-support/try-runtime",
"frame-try-runtime/try-runtime",
"pallet-transaction-payment/try-runtime",
"parachains-common/try-runtime",
"polkadot-cli/try-runtime",
"sp-runtime/try-runtime",
]
2 changes: 1 addition & 1 deletion cumulus/polkadot-omni-node/lib/src/common/spec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ use cumulus_primitives_core::{BlockT, GetParachainInfo, ParaId};
use cumulus_relay_chain_interface::{OverseerHandle, RelayChainInterface};
use futures::FutureExt;
use log::info;
use parachains_common::Hash;
use parachains_common_types::Hash;
use polkadot_primitives::CollatorPair;
use prometheus_endpoint::Registry;
use sc_client_api::Backend;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
// limitations under the License.

use crate::common::{types::ParachainClient, ConstructNodeRuntimeApi, NodeBlock};
use parachains_common::Hash;
use parachains_common_types::Hash;
use sc_network::{
config::FullNetworkConfiguration, service::traits::NetworkService, NetworkBackend,
};
Expand Down
2 changes: 1 addition & 1 deletion cumulus/polkadot-omni-node/lib/src/common/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ use sc_telemetry::{Telemetry, TelemetryWorkerHandle};
use sc_transaction_pool::TransactionPoolHandle;
use sp_runtime::{generic, traits::BlakeTwo256};

pub use parachains_common::{AccountId, Balance, Hash, Nonce};
pub use parachains_common_types::{AccountId, Balance, Hash, Nonce};

type Header<BlockNumber> = generic::Header<BlockNumber, BlakeTwo256>;
pub type Block<BlockNumber> = generic::Block<Header<BlockNumber>, UncheckedExtrinsic>;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

pub(crate) mod imports {
pub use cumulus_primitives_core::ParaId;
pub use parachains_common::{AccountId, Balance, Nonce};
pub use parachains_common_types::{AccountId, Balance, Nonce};
pub use sp_core::{crypto::KeyTypeId, OpaqueMetadata};
pub use sp_runtime::{
traits::Block as BlockT,
Expand Down
16 changes: 16 additions & 0 deletions prdoc/pr_10513.prdoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
title: Extract parachain types into a dedicated crate
doc:
- audience: Node Dev
description: |-
Closes https://github.com/paritytech/polkadot-sdk/issues/10512.

Moves the common parachain primitives (accounts, balances, hashes, opaque block types) into a new `parachains-common-types` crate. The existing `parachains-common` crate re-exports these definitions, and `polkadot-omni-node-lib` now depends on the lightweight types crate to avoid pulling runtime pallets into omni-node builds.
crates:
- name: parachains-common
bump: major
- name: parachains-common-types
bump: major
- name: polkadot-omni-node-lib
bump: patch
- name: polkadot-sdk
bump: minor
7 changes: 7 additions & 0 deletions umbrella/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,7 @@ std = [
"pallet-xcm-bridge-hub?/std",
"pallet-xcm-precompiles?/std",
"pallet-xcm?/std",
"parachains-common-types?/std",
"parachains-common?/std",
"parachains-runtimes-test-utils?/std",
"polkadot-core-primitives?/std",
Expand Down Expand Up @@ -725,6 +726,7 @@ runtime-full = [
"pallet-xcm-bridge-hub-router",
"pallet-xcm-precompiles",
"parachains-common",
"parachains-common-types",
"polkadot-core-primitives",
"polkadot-parachain-primitives",
"polkadot-primitives",
Expand Down Expand Up @@ -1865,6 +1867,11 @@ default-features = false
optional = true
path = "../cumulus/parachains/common"

[dependencies.parachains-common-types]
default-features = false
optional = true
path = "../cumulus/parachains/common/types"

[dependencies.polkadot-core-primitives]
default-features = false
optional = true
Expand Down
4 changes: 4 additions & 0 deletions umbrella/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -811,6 +811,10 @@ pub use pallet_xcm_precompiles;
#[cfg(feature = "parachains-common")]
pub use parachains_common;

/// Common types for parachains.
#[cfg(feature = "parachains-common-types")]
pub use parachains_common_types;

/// Utils for Runtimes testing.
#[cfg(feature = "parachains-runtimes-test-utils")]
pub use parachains_runtimes_test_utils;
Expand Down
Loading