Skip to content

Commit a146918

Browse files
authored
Move Relay-Specific Shared Code to One Place (#1193)
* add common libs * asset hubs * add westend * bridge hubs * collectives * contracts * emulated tests * parachain bin * delete collectives constants and update docs * integration tests should have apache license (some missing, some needed changing) * propagate features * fmt
1 parent 7217a5d commit a146918

68 files changed

Lines changed: 534 additions & 1009 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

Cargo.lock

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

cumulus/parachains/common/Cargo.toml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ codec = { package = "parity-scale-codec", version = "3.0.0", features = ["derive
1313
log = { version = "0.4.19", default-features = false }
1414
scale-info = { version = "2.9.0", default-features = false, features = ["derive"] }
1515
num-traits = { version = "0.2", default-features = false}
16+
smallvec = "1.11.0"
1617

1718
# Substrate
1819
frame-support = { path = "../../../substrate/frame/support", default-features = false }
@@ -28,6 +29,11 @@ sp-runtime = { path = "../../../substrate/primitives/runtime", default-features
2829
sp-std = { path = "../../../substrate/primitives/std", default-features = false }
2930

3031
# Polkadot
32+
kusama-runtime-constants = { path = "../../../polkadot/runtime/kusama/constants", default-features = false}
33+
polkadot-runtime-constants = { path = "../../../polkadot/runtime/polkadot/constants", default-features = false}
34+
rococo-runtime-constants = { path = "../../../polkadot/runtime/rococo/constants", default-features = false}
35+
westend-runtime-constants = { path = "../../../polkadot/runtime/westend/constants", default-features = false}
36+
polkadot-core-primitives = { path = "../../../polkadot/core-primitives", default-features = false}
3137
polkadot-primitives = { path = "../../../polkadot/primitives", default-features = false}
3238
xcm = { package = "staging-xcm", path = "../../../polkadot/xcm", default-features = false}
3339
xcm-builder = { package = "staging-xcm-builder", path = "../../../polkadot/xcm/xcm-builder", default-features = false}
@@ -52,18 +58,23 @@ std = [
5258
"cumulus-primitives-utility/std",
5359
"frame-support/std",
5460
"frame-system/std",
61+
"kusama-runtime-constants/std",
5562
"log/std",
5663
"pallet-asset-tx-payment/std",
5764
"pallet-assets/std",
5865
"pallet-authorship/std",
5966
"pallet-balances/std",
6067
"pallet-collator-selection/std",
68+
"polkadot-core-primitives/std",
6169
"polkadot-primitives/std",
70+
"polkadot-runtime-constants/std",
71+
"rococo-runtime-constants/std",
6272
"sp-consensus-aura/std",
6373
"sp-core/std",
6474
"sp-io/std",
6575
"sp-runtime/std",
6676
"sp-std/std",
77+
"westend-runtime-constants/std",
6778
"xcm-builder/std",
6879
"xcm-executor/std",
6980
"xcm/std",

cumulus/parachains/runtimes/contracts/contracts-rococo/src/constants.rs renamed to cumulus/parachains/common/src/kusama.rs

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,19 @@
1313
// See the License for the specific language governing permissions and
1414
// limitations under the License.
1515

16+
/// Consensus-related.
17+
pub mod consensus {
18+
/// Maximum number of blocks simultaneously accepted by the Runtime, not yet included
19+
/// into the relay chain.
20+
pub const UNINCLUDED_SEGMENT_CAPACITY: u32 = 1;
21+
/// How many parachain blocks are processed by the relay chain per parent. Limits the
22+
/// number of blocks authored per slot.
23+
pub const BLOCK_PROCESSING_VELOCITY: u32 = 1;
24+
/// Relay chain slot duration, in milliseconds.
25+
pub const RELAY_CHAIN_SLOT_DURATION_MILLIS: u32 = 6000;
26+
}
27+
28+
/// Constants relating to KSM.
1629
pub mod currency {
1730
use kusama_runtime_constants as constants;
1831
use polkadot_core_primitives::Balance;
@@ -31,7 +44,7 @@ pub mod currency {
3144
}
3245
}
3346

34-
/// Fee-related.
47+
/// Constants related to Kusama fee payment.
3548
pub mod fee {
3649
use frame_support::{
3750
pallet_prelude::Weight,
@@ -75,8 +88,8 @@ pub mod fee {
7588
impl WeightToFeePolynomial for RefTimeToFee {
7689
type Balance = Balance;
7790
fn polynomial() -> WeightToFeeCoefficients<Self::Balance> {
78-
// in Kusama, extrinsic base weight (smallest non-zero weight) is mapped to 1/10 CENT:
79-
// in Rococo Contracts, we map to 1/10 of that, or 1/100 CENT
91+
// In Kusama, extrinsic base weight (smallest non-zero weight) is mapped to 1/10 CENT:
92+
// The standard system parachain configuration is 1/10 of that, as in 1/100 CENT.
8093
let p = super::currency::CENTS;
8194
let q = 100 * Balance::from(ExtrinsicBaseWeight::get().ref_time());
8295

@@ -107,15 +120,3 @@ pub mod fee {
107120
}
108121
}
109122
}
110-
111-
/// Consensus-related.
112-
pub mod consensus {
113-
/// Maximum number of blocks simultaneously accepted by the Runtime, not yet included
114-
/// into the relay chain.
115-
pub const UNINCLUDED_SEGMENT_CAPACITY: u32 = 1;
116-
/// How many parachain blocks are processed by the relay chain per parent. Limits the
117-
/// number of blocks authored per slot.
118-
pub const BLOCK_PROCESSING_VELOCITY: u32 = 1;
119-
/// Relay chain slot duration, in milliseconds.
120-
pub const RELAY_CHAIN_SLOT_DURATION_MILLIS: u32 = 6000;
121-
}

cumulus/parachains/common/src/lib.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@
1616
#![cfg_attr(not(feature = "std"), no_std)]
1717

1818
pub mod impls;
19+
pub mod kusama;
20+
pub mod polkadot;
21+
pub mod rococo;
22+
pub mod westend;
1923
pub mod xcm_config;
2024
pub use constants::*;
2125
pub use opaque::*;

cumulus/parachains/runtimes/collectives/collectives-polkadot/src/constants.rs renamed to cumulus/parachains/common/src/polkadot.rs

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
// See the License for the specific language governing permissions and
1414
// limitations under the License.
1515

16+
/// Universally recognized accounts.
1617
pub mod account {
1718
use frame_support::PalletId;
1819

@@ -28,6 +29,19 @@ pub mod account {
2829
pub const REFERENDA_PALLET_ID: PalletId = PalletId(*b"py/refer");
2930
}
3031

32+
/// Consensus-related.
33+
pub mod consensus {
34+
/// Maximum number of blocks simultaneously accepted by the Runtime, not yet included
35+
/// into the relay chain.
36+
pub const UNINCLUDED_SEGMENT_CAPACITY: u32 = 1;
37+
/// How many parachain blocks are processed by the relay chain per parent. Limits the
38+
/// number of blocks authored per slot.
39+
pub const BLOCK_PROCESSING_VELOCITY: u32 = 1;
40+
/// Relay chain slot duration, in milliseconds.
41+
pub const RELAY_CHAIN_SLOT_DURATION_MILLIS: u32 = 6000;
42+
}
43+
44+
/// Constants relating to DOT.
3145
pub mod currency {
3246
use polkadot_core_primitives::Balance;
3347
use polkadot_runtime_constants as constants;
@@ -41,12 +55,12 @@ pub mod currency {
4155
pub const MILLICENTS: Balance = constants::currency::MILLICENTS;
4256

4357
pub const fn deposit(items: u32, bytes: u32) -> Balance {
44-
// 1/100 of Polkadot.
58+
// 1/100 of Polkadot
4559
constants::currency::deposit(items, bytes) / 100
4660
}
4761
}
4862

49-
/// Fee-related.
63+
/// Constants related to Polkadot fee payment.
5064
pub mod fee {
5165
use frame_support::{
5266
pallet_prelude::Weight,
@@ -90,8 +104,8 @@ pub mod fee {
90104
impl WeightToFeePolynomial for RefTimeToFee {
91105
type Balance = Balance;
92106
fn polynomial() -> WeightToFeeCoefficients<Self::Balance> {
93-
// in Polkadot, extrinsic base weight (smallest non-zero weight) is mapped to 1/10 CENT:
94-
// in a parachain, we map to 1/10 of that, or 1/100 CENT
107+
// In Polkadot, extrinsic base weight (smallest non-zero weight) is mapped to 1/10 CENT:
108+
// The standard system parachain configuration is 1/10 of that, as in 1/100 CENT.
95109
let p = super::currency::CENTS;
96110
let q = 100 * Balance::from(ExtrinsicBaseWeight::get().ref_time());
97111

@@ -122,15 +136,3 @@ pub mod fee {
122136
}
123137
}
124138
}
125-
126-
/// Consensus-related.
127-
pub mod consensus {
128-
/// Maximum number of blocks simultaneously accepted by the Runtime, not yet included
129-
/// into the relay chain.
130-
pub const UNINCLUDED_SEGMENT_CAPACITY: u32 = 1;
131-
/// How many parachain blocks are processed by the relay chain per parent. Limits the
132-
/// number of blocks authored per slot.
133-
pub const BLOCK_PROCESSING_VELOCITY: u32 = 1;
134-
/// Relay chain slot duration, in milliseconds.
135-
pub const RELAY_CHAIN_SLOT_DURATION_MILLIS: u32 = 6000;
136-
}

cumulus/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/constants.rs renamed to cumulus/parachains/common/src/rococo.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,8 @@ pub mod fee {
7373
impl WeightToFeePolynomial for RefTimeToFee {
7474
type Balance = Balance;
7575
fn polynomial() -> WeightToFeeCoefficients<Self::Balance> {
76-
// in Rococo, extrinsic base weight (smallest non-zero weight) is mapped to 1/10 CENT:
77-
// in Bridge Hub, we map to 1/10 of that, or 1/100 CENT
76+
// In Rococo, extrinsic base weight (smallest non-zero weight) is mapped to 1/10 CENT:
77+
// The standard system parachain configuration is 1/10 of that, as in 1/100 CENT.
7878
let p = super::currency::CENTS;
7979
let q = 100 * Balance::from(ExtrinsicBaseWeight::get().ref_time());
8080

cumulus/parachains/runtimes/assets/asset-hub-westend/src/constants.rs renamed to cumulus/parachains/common/src/westend.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,8 +75,8 @@ pub mod fee {
7575
impl WeightToFeePolynomial for RefTimeToFee {
7676
type Balance = Balance;
7777
fn polynomial() -> WeightToFeeCoefficients<Self::Balance> {
78-
// in Westend, extrinsic base weight (smallest non-zero weight) is mapped to 1/10 CENT:
79-
// in Asset Hub, we map to 1/10 of that, or 1/100 CENT
78+
// In Westend, extrinsic base weight (smallest non-zero weight) is mapped to 1/10 CENT:
79+
// The standard system parachain configuration is 1/10 of that, as in 1/100 CENT.
8080
let p = super::currency::CENTS;
8181
let q = 100 * Balance::from(ExtrinsicBaseWeight::get().ref_time());
8282

cumulus/parachains/integration-tests/emulated/assets/asset-hub-kusama/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ name = "asset-hub-kusama-integration-tests"
33
version = "1.0.0"
44
authors.workspace = true
55
edition.workspace = true
6+
license = "Apache-2.0"
67
description = "Asset Hub Kusama runtime integration tests with xcm-emulator"
78
publish = false
89

cumulus/parachains/integration-tests/emulated/assets/asset-hub-kusama/src/lib.rs

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,17 @@
11
// Copyright (C) Parity Technologies (UK) Ltd.
2-
// This file is part of Cumulus.
2+
// SPDX-License-Identifier: Apache-2.0
33

4-
// Cumulus is free software: you can redistribute it and/or modify
5-
// it under the terms of the GNU General Public License as published by
6-
// the Free Software Foundation, either version 3 of the License, or
7-
// (at your option) any later version.
8-
9-
// Cumulus is distributed in the hope that it will be useful,
10-
// but WITHOUT ANY WARRANTY; without even the implied warranty of
11-
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12-
// GNU General Public License for more details.
13-
14-
// You should have received a copy of the GNU General Public License
15-
// along with Cumulus. If not, see <http://www.gnu.org/licenses/>.
4+
// Licensed under the Apache License, Version 2.0 (the "License");
5+
// you may not use this file except in compliance with the License.
6+
// You may obtain a copy of the License at
7+
//
8+
// http://www.apache.org/licenses/LICENSE-2.0
9+
//
10+
// Unless required by applicable law or agreed to in writing, software
11+
// distributed under the License is distributed on an "AS IS" BASIS,
12+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
// See the License for the specific language governing permissions and
14+
// limitations under the License.
1615

1716
pub use codec::Encode;
1817
pub use frame_support::{

cumulus/parachains/integration-tests/emulated/assets/asset-hub-kusama/src/tests/hrmp_channels.rs

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,17 @@
11
// Copyright (C) Parity Technologies (UK) Ltd.
2-
// This file is part of Cumulus.
3-
4-
// Cumulus is free software: you can redistribute it and/or modify
5-
// it under the terms of the GNU General Public License as published by
6-
// the Free Software Foundation, either version 3 of the License, or
7-
// (at your option) any later version.
8-
9-
// Cumulus is distributed in the hope that it will be useful,
10-
// but WITHOUT ANY WARRANTY; without even the implied warranty of
11-
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12-
// GNU General Public License for more details.
13-
14-
// You should have received a copy of the GNU General Public License
15-
// along with Cumulus. If not, see <http://www.gnu.org/licenses/>.
2+
// SPDX-License-Identifier: Apache-2.0
3+
4+
// Licensed under the Apache License, Version 2.0 (the "License");
5+
// you may not use this file except in compliance with the License.
6+
// You may obtain a copy of the License at
7+
//
8+
// http://www.apache.org/licenses/LICENSE-2.0
9+
//
10+
// Unless required by applicable law or agreed to in writing, software
11+
// distributed under the License is distributed on an "AS IS" BASIS,
12+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
// See the License for the specific language governing permissions and
14+
// limitations under the License.
1615

1716
use crate::*;
1817

0 commit comments

Comments
 (0)