Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

Companion for #7005 #2433

Open
wants to merge 22 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 8 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
63 changes: 62 additions & 1 deletion Cargo.lock

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

4 changes: 4 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@ members = [
"primitives/utility",
"polkadot-parachain",
"parachains/common",
"parachains/common/kusama",
"parachains/common/polkadot",
"parachains/common/rococo",
"parachains/common/westend",
"parachains/pallets/parachain-info",
"parachains/pallets/ping",
"parachains/runtimes/testing/rococo-parachain",
Expand Down
41 changes: 41 additions & 0 deletions parachains/common/kusama/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
[package]
name = "kusama-common"
version = "0.1.0"
authors = ["Parity Technologies <[email protected]>"]
edition = "2021"
description = "Logic which is common to the kusama relay chain"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
# Substrate
sp-core = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "master" }
frame-support = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "master" }
frame-system = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "master" }
sp-io = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "master" }

# Polkadot
kusama-runtime-constants = { git = "https://github.com/paritytech/polkadot", default-features = false, branch = "master" }
xcm = { git = "https://github.com/paritytech/polkadot", default-features = false, branch = "master" }

# Cumulus
parachain-info = { path = "../../pallets/parachain-info", default-features = false }


[features]
default = [ "std" ]
runtime-benchmarks = [
"frame-support/runtime-benchmarks",
]
try-runtime = [
"parachain-info/try-runtime",
]
std = [
"sp-core/std",
"frame-support/std",
"frame-system/std",
"kusama-runtime-constants/std",
"xcm/std",
"parachain-info/std",
"sp-io/std",
]
24 changes: 24 additions & 0 deletions parachains/common/kusama/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#![cfg_attr(not(feature = "std"), no_std)]

use core::marker::PhantomData;
use frame_support::traits::Contains;
use sp_core::Get;
use xcm::latest::prelude::*;

pub struct RelayOrOtherSystemParachains<Runtime: parachain_info::Config> {
gilescope marked this conversation as resolved.
Show resolved Hide resolved
_runtime: PhantomData<Runtime>,
}
impl<Runtime: parachain_info::Config> Contains<MultiLocation>
for RelayOrOtherSystemParachains<Runtime>
{
fn contains(l: &MultiLocation) -> bool {
let self_para_id: u32 = parachain_info::Pallet::<Runtime>::get().into();
if let MultiLocation { parents: 0, interior: X1(Parachain(para_id)) } = l {
if *para_id == self_para_id {
return false
}
}
matches!(l, MultiLocation { parents: 1, interior: Here }) ||
kusama_runtime_constants::system_parachain::SystemParachains::contains(l)
gilescope marked this conversation as resolved.
Show resolved Hide resolved
}
}
41 changes: 41 additions & 0 deletions parachains/common/polkadot/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
[package]
name = "polkadot-common"
version = "0.1.0"
authors = ["Parity Technologies <[email protected]>"]
edition = "2021"
description = "Logic which is common to the polkadot relay chain"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
# Substrate
sp-core = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "master" }
frame-support = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "master" }
frame-system = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "master" }
sp-io = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "master" }

# Polkadot
polkadot-runtime-constants = { git = "https://github.com/paritytech/polkadot", default-features = false, branch = "master" }
xcm = { git = "https://github.com/paritytech/polkadot", default-features = false, branch = "master" }

# Cumulus
parachain-info = { path = "../../pallets/parachain-info", default-features = false }


[features]
default = [ "std" ]
runtime-benchmarks = [
"frame-support/runtime-benchmarks",
]
try-runtime = [
"parachain-info/try-runtime",
]
std = [
"sp-core/std",
"frame-support/std",
"frame-system/std",
"polkadot-runtime-constants/std",
"xcm/std",
"parachain-info/std",
"sp-io/std",
]
24 changes: 24 additions & 0 deletions parachains/common/polkadot/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#![cfg_attr(not(feature = "std"), no_std)]

use core::marker::PhantomData;
use frame_support::traits::Contains;
use sp_core::Get;
use xcm::latest::prelude::*;

pub struct RelayOrOtherSystemParachains<Runtime: parachain_info::Config> {
_runtime: PhantomData<Runtime>,
}
impl<Runtime: parachain_info::Config> Contains<MultiLocation>
for RelayOrOtherSystemParachains<Runtime>
{
fn contains(l: &MultiLocation) -> bool {
let self_para_id: u32 = parachain_info::Pallet::<Runtime>::get().into();
if let MultiLocation { parents: 0, interior: X1(Parachain(para_id)) } = l {
if *para_id == self_para_id {
return false
}
}
matches!(l, MultiLocation { parents: 1, interior: Here }) ||
polkadot_runtime_constants::system_parachain::SystemParachains::contains(l)
}
}
41 changes: 41 additions & 0 deletions parachains/common/rococo/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
[package]
name = "rococo-common"
version = "0.1.0"
authors = ["Parity Technologies <[email protected]>"]
edition = "2021"
description = "Logic which is common to the rococo relay chain"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
# Substrate
sp-core = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "master" }
frame-support = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "master" }
frame-system = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "master" }
sp-io = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "master" }

# Polkadot
rococo-runtime-constants = { git = "https://github.com/paritytech/polkadot", default-features = false, branch = "master" }
xcm = { git = "https://github.com/paritytech/polkadot", default-features = false, branch = "master" }

# Cumulus
parachain-info = { path = "../../pallets/parachain-info", default-features = false }


[features]
default = [ "std" ]
runtime-benchmarks = [
"frame-support/runtime-benchmarks",
]
try-runtime = [
"parachain-info/try-runtime",
]
std = [
"sp-core/std",
"frame-support/std",
"frame-system/std",
"rococo-runtime-constants/std",
"xcm/std",
"parachain-info/std",
"sp-io/std",
]
24 changes: 24 additions & 0 deletions parachains/common/rococo/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#![cfg_attr(not(feature = "std"), no_std)]

use core::marker::PhantomData;
use frame_support::traits::Contains;
use sp_core::Get;
use xcm::latest::prelude::*;

pub struct RelayOrOtherSystemParachains<Runtime: parachain_info::Config> {
_runtime: PhantomData<Runtime>,
}
impl<Runtime: parachain_info::Config> Contains<MultiLocation>
for RelayOrOtherSystemParachains<Runtime>
{
fn contains(l: &MultiLocation) -> bool {
let self_para_id: u32 = parachain_info::Pallet::<Runtime>::get().into();
if let MultiLocation { parents: 0, interior: X1(Parachain(para_id)) } = l {
if *para_id == self_para_id {
return false
}
}
matches!(l, MultiLocation { parents: 1, interior: Here }) ||
rococo_runtime_constants::system_parachain::SystemParachains::contains(l)
}
}
8 changes: 7 additions & 1 deletion parachains/common/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,10 @@ mod types {
/// Common constants of parachains.
mod constants {
use super::types::BlockNumber;
use frame_support::weights::{constants::WEIGHT_REF_TIME_PER_SECOND, Weight};
use frame_support::{
weights::{constants::WEIGHT_REF_TIME_PER_SECOND, Weight},
PalletId,
};
use sp_runtime::Perbill;
/// This determines the average expected block time that we are targeting. Blocks will be
/// produced at a minimum duration defined by `SLOT_DURATION`. `SLOT_DURATION` is picked up by
Expand Down Expand Up @@ -96,6 +99,9 @@ mod constants {
WEIGHT_REF_TIME_PER_SECOND.saturating_div(2),
polkadot_primitives::MAX_POV_SIZE as u64,
);

/// 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
Expand Down
Loading