Integrate a governance XCM origin (#407)

* Introduce the converter into the hub

* Parachain recognises Rococo governance body as admin

* Whitespace

* Use UsingComponents for fee payment in XCM

* Fixes

* Fixes for XCM permissions

* Remove encode_call test

* Fixes

* Fixes

* Fixes
This commit is contained in:
Gavin Wood
2021-04-28 14:41:18 +02:00
committed by GitHub
parent 859524f2f1
commit 0ab15b2e05
8 changed files with 235 additions and 98 deletions
Generated
+27 -9
View File
@@ -1428,6 +1428,7 @@ dependencies = [
"frame-system",
"parity-scale-codec",
"serde",
"sp-io",
"sp-runtime",
"sp-std",
"xcm",
@@ -1528,6 +1529,7 @@ dependencies = [
"frame-support",
"frame-system",
"hex",
"hex-literal 0.3.1",
"log",
"pallet-balances",
"pallet-randomness-collective-flip",
@@ -1598,7 +1600,10 @@ dependencies = [
"frame-executive",
"frame-support",
"frame-system",
"hex",
"hex-literal 0.3.1",
"log",
"pallet-assets",
"pallet-balances",
"pallet-randomness-collective-flip",
"pallet-sudo",
@@ -3885,9 +3890,9 @@ dependencies = [
[[package]]
name = "libp2p-mdns"
version = "0.30.1"
version = "0.30.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "41e282f974c4bea56db8acca50387f05189406e346318cb30190b0bde662961e"
checksum = "c221897b3fd7f215de7ecfec215c5eba598e5b61c605b5f8b56fe8a4fb507724"
dependencies = [
"async-io",
"data-encoding",
@@ -4790,6 +4795,19 @@ dependencies = [
"stable_deref_trait",
]
[[package]]
name = "pallet-assets"
version = "3.0.0"
source = "git+https://github.com/paritytech/substrate?branch=master#282d57c0745b530fe7a9ebaffcd6ac36c09d0554"
dependencies = [
"frame-benchmarking",
"frame-support",
"frame-system",
"parity-scale-codec",
"sp-runtime",
"sp-std",
]
[[package]]
name = "pallet-authority-discovery"
version = "3.0.0"
@@ -9436,7 +9454,7 @@ dependencies = [
[[package]]
name = "sp-consensus-aura"
version = "0.9.0"
source = "git+https://github.com/paritytech/substrate?branch=master#8060a437dc01cc247a757fb318a46f81c8e40d5c"
source = "git+https://github.com/paritytech/substrate?branch=master#282d57c0745b530fe7a9ebaffcd6ac36c09d0554"
dependencies = [
"parity-scale-codec",
"sp-api",
@@ -9845,7 +9863,7 @@ dependencies = [
[[package]]
name = "sp-test-primitives"
version = "2.0.0"
source = "git+https://github.com/paritytech/substrate?branch=master#8060a437dc01cc247a757fb318a46f81c8e40d5c"
source = "git+https://github.com/paritytech/substrate?branch=master#282d57c0745b530fe7a9ebaffcd6ac36c09d0554"
dependencies = [
"parity-scale-codec",
"parity-util-mem",
@@ -10170,7 +10188,7 @@ dependencies = [
[[package]]
name = "substrate-test-runtime"
version = "2.0.0"
source = "git+https://github.com/paritytech/substrate?branch=master#8060a437dc01cc247a757fb318a46f81c8e40d5c"
source = "git+https://github.com/paritytech/substrate?branch=master#282d57c0745b530fe7a9ebaffcd6ac36c09d0554"
dependencies = [
"cfg-if 1.0.0",
"frame-support",
@@ -10211,7 +10229,7 @@ dependencies = [
[[package]]
name = "substrate-test-runtime-client"
version = "2.0.0"
source = "git+https://github.com/paritytech/substrate?branch=master#8060a437dc01cc247a757fb318a46f81c8e40d5c"
source = "git+https://github.com/paritytech/substrate?branch=master#282d57c0745b530fe7a9ebaffcd6ac36c09d0554"
dependencies = [
"futures 0.3.14",
"parity-scale-codec",
@@ -10232,7 +10250,7 @@ dependencies = [
[[package]]
name = "substrate-test-utils"
version = "3.0.0"
source = "git+https://github.com/paritytech/substrate?branch=master#8060a437dc01cc247a757fb318a46f81c8e40d5c"
source = "git+https://github.com/paritytech/substrate?branch=master#282d57c0745b530fe7a9ebaffcd6ac36c09d0554"
dependencies = [
"futures 0.3.14",
"substrate-test-utils-derive",
@@ -10242,7 +10260,7 @@ dependencies = [
[[package]]
name = "substrate-test-utils-derive"
version = "0.9.0"
source = "git+https://github.com/paritytech/substrate?branch=master#8060a437dc01cc247a757fb318a46f81c8e40d5c"
source = "git+https://github.com/paritytech/substrate?branch=master#282d57c0745b530fe7a9ebaffcd6ac36c09d0554"
dependencies = [
"proc-macro-crate 1.0.0",
"quote 1.0.9",
@@ -10268,7 +10286,7 @@ dependencies = [
[[package]]
name = "substrate-wasm-builder"
version = "4.0.0"
source = "git+https://github.com/paritytech/substrate?branch=master#8060a437dc01cc247a757fb318a46f81c8e40d5c"
source = "git+https://github.com/paritytech/substrate?branch=master#282d57c0745b530fe7a9ebaffcd6ac36c09d0554"
dependencies = [
"ansi_term 0.12.1",
"atty",
+39 -20
View File
@@ -471,7 +471,7 @@ impl<T: Config> Module<T> {
assert_eq!(
params.relay_parent_storage_root,
validation_data.relay_parent_storage_root,
"Relay parent stoarage root doesn't match",
"Relay parent storage root doesn't match",
);
});
}
@@ -485,25 +485,38 @@ impl<T: Config> Module<T> {
downward_messages: Vec<InboundDownwardMessage>,
) -> Result<Weight, DispatchError> {
let dm_count = downward_messages.len() as u32;
let mut weight_used = 0;
// Reference fu to avoid the `move` capture.
let weight_used_mut_ref = &mut weight_used;
let result_mqc_head = LastDmqMqcHead::mutate(move |mqc| {
for downward_message in downward_messages {
mqc.extend_downward(&downward_message);
*weight_used_mut_ref += T::DownwardMessageHandlers::handle_downward_message(downward_message);
}
mqc.0
});
if dm_count != 0 {
let mut processed_count = 0;
// After hashing each message in the message queue chain submitted by the collator, we should
// arrive to the MQC head provided by the relay chain.
ensure!(
result_mqc_head == expected_dmq_mqc_head,
Error::<T>::DmpMqcMismatch
);
Self::deposit_event(RawEvent::DownwardMessagesReceived(dm_count));
// Reference fu to avoid the `move` capture.
let weight_used_ref = &mut weight_used;
let processed_count_ref = &mut processed_count;
let result_mqc_head = LastDmqMqcHead::mutate(move |mqc| {
for downward_message in downward_messages {
mqc.extend_downward(&downward_message);
*weight_used_ref += T::DownwardMessageHandlers::handle_downward_message(downward_message);
*processed_count_ref += 1;
}
mqc.0
});
Self::deposit_event(RawEvent::DownwardMessagesProcessed(
processed_count,
weight_used,
result_mqc_head.clone(),
expected_dmq_mqc_head.clone(),
));
// After hashing each message in the message queue chain submitted by the collator, we should
// arrive to the MQC head provided by the relay chain.
assert_eq!(result_mqc_head, expected_dmq_mqc_head);
} else {
assert_eq!(LastDmqMqcHead::get().0, expected_dmq_mqc_head);
}
// Store the processed_downward_messages here so that it will be accessible from
// PVF's `validate_block` wrapper and collation pipeline.
@@ -791,12 +804,18 @@ impl<T: Config> ProvideInherent for Module<T> {
decl_event! {
pub enum Event<T> where Hash = <T as frame_system::Config>::Hash {
// The validation function has been scheduled to apply as of the contained relay chain block number.
/// The validation function has been scheduled to apply as of the contained relay chain block number.
ValidationFunctionStored(RelayChainBlockNumber),
// The validation function was applied as of the contained relay chain block number.
/// The validation function was applied as of the contained relay chain block number.
ValidationFunctionApplied(RelayChainBlockNumber),
// An upgrade has been authorized.
/// An upgrade has been authorized.
UpgradeAuthorized(Hash),
/// Downward messages were processed using the given weight.
/// \[ count, weight_used, result_mqc_head, expected_mqc_head \]
DownwardMessagesProcessed(u32, Weight, relay_chain::Hash, relay_chain::Hash),
/// Some downward messages have been received and will be processed.
/// \[ count \]
DownwardMessagesReceived(u32),
}
}
+1
View File
@@ -9,6 +9,7 @@ codec = { package = "parity-scale-codec", version = "2.0.0", default-features =
serde = { version = "1.0.101", optional = true, features = ["derive"] }
sp-std = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "master" }
sp-io = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "master" }
sp-runtime = { 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" }
+59 -3
View File
@@ -20,13 +20,17 @@
#![cfg_attr(not(feature = "std"), no_std)]
use cumulus_primitives_core::ParaId;
use sp_std::convert::TryFrom;
use cumulus_primitives_core::{ParaId, DownwardMessageHandler, InboundDownwardMessage};
use codec::{Encode, Decode};
use sp_runtime::traits::BadOrigin;
use xcm::{VersionedXcm, v0::{Xcm, Junction, Outcome, ExecuteXcm}};
use frame_support::{traits::Get, dispatch::Weight};
pub use pallet::*;
#[frame_support::pallet]
pub mod pallet {
use super::*;
use frame_support::pallet_prelude::*;
use frame_system::pallet_prelude::*;
@@ -36,16 +40,68 @@ pub mod pallet {
/// The module configuration trait.
#[pallet::config]
pub trait Config: frame_system::Config {}
pub trait Config: frame_system::Config {
/// The overarching event type.
type Event: From<Event<Self>> + IsType<<Self as frame_system::Config>::Event>;
type XcmExecutor: ExecuteXcm<Self::Call>;
#[pallet::constant]
type MaxWeight: Get<Weight>;
}
#[pallet::error]
pub enum Error<T> {}
pub enum Error<T> {
}
#[pallet::hooks]
impl<T: Config> Hooks<BlockNumberFor<T>> for Pallet<T> {}
#[pallet::call]
impl<T: Config> Pallet<T> {}
#[pallet::event]
#[pallet::generate_deposit(pub(super) fn deposit_event)]
#[pallet::metadata(T::BlockNumber = "BlockNumber")]
pub enum Event<T: Config> {
/// Downward message is invalid XCM.
/// \[ id \]
InvalidFormat([u8; 8]),
/// Downward message is unsupported version of XCM.
/// \[ id \]
UnsupportedVersion([u8; 8]),
/// Downward message executed with the given outcome.
/// \[ id, outcome \]
ExecutedDownward([u8; 8], Outcome),
}
/// For an incoming downward message, this just adapts an XCM executor and executes DMP messages
/// immediately up until some `MaxWeight` at which point it errors. Their origin is asserted to be
/// the Parent location.
impl<T: Config> DownwardMessageHandler for Pallet<T> {
fn handle_downward_message(msg: InboundDownwardMessage) -> Weight {
let id = sp_io::hashing::twox_64(&msg.msg[..]);
let msg = VersionedXcm::<T::Call>::decode(&mut &msg.msg[..])
.map(Xcm::<T::Call>::try_from);
match msg {
Ok(Ok(x)) => {
let weight_limit = T::MaxWeight::get();
let outcome = T::XcmExecutor::execute_xcm(Junction::Parent.into(), x, weight_limit);
let weight_used = outcome.weight_used();
Self::deposit_event(Event::ExecutedDownward(id, outcome));
weight_used
}
Ok(Err(())) => {
Self::deposit_event(Event::UnsupportedVersion(id));
0
},
Err(_) => {
Self::deposit_event(Event::InvalidFormat(id));
0
},
}
}
}
}
/// Origin for the parachains module.
+6
View File
@@ -27,6 +27,7 @@ sp-inherents = { git = "https://github.com/paritytech/substrate", default-featur
frame-support = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "master" }
frame-executive = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "master" }
frame-system = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "master" }
pallet-assets = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "master" }
pallet-balances = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "master" }
pallet-randomness-collective-flip = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "master" }
pallet-timestamp = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "master" }
@@ -48,6 +49,10 @@ xcm-builder = { git = "https://github.com/paritytech/polkadot", default-features
xcm-executor = { git = "https://github.com/paritytech/polkadot", default-features = false, branch = "master" }
pallet-xcm = { git = "https://github.com/paritytech/polkadot", default-features = false, branch = "master" }
[dev-dependencies]
hex-literal = "0.3.1"
hex = "0.4.3"
[build-dependencies]
substrate-wasm-builder = "3.0.0"
@@ -71,6 +76,7 @@ std = [
"frame-support/std",
"frame-executive/std",
"frame-system/std",
"pallet-assets/std",
"pallet-balances/std",
"pallet-randomness-collective-flip/std",
"pallet-timestamp/std",
+88 -44
View File
@@ -27,7 +27,7 @@ use sp_api::impl_runtime_apis;
use sp_core::OpaqueMetadata;
use sp_runtime::{
create_runtime_str, generic, impl_opaque_keys,
traits::{BlakeTwo256, Block as BlockT, IdentityLookup},
traits::{BlakeTwo256, Block as BlockT, AccountIdLookup},
transaction_validity::{TransactionSource, TransactionValidity},
ApplyExtrinsicResult,
};
@@ -55,15 +55,16 @@ pub use sp_runtime::{Perbill, Permill};
// XCM imports
use polkadot_parachain::primitives::Sibling;
use xcm::v0::{Junction, MultiLocation, NetworkId};
use xcm::v0::{Junction::*, MultiLocation, MultiLocation::*, NetworkId, BodyId};
use xcm_builder::{
AccountId32Aliases, CurrencyAdapter, LocationInverter, ParentIsDefault, RelayChainAsNative,
SiblingParachainAsNative, SiblingParachainConvertsVia, SignedAccountId32AsNative,
SovereignSignedViaLocation, FixedRateOfConcreteFungible, EnsureXcmOrigin,
SovereignSignedViaLocation, EnsureXcmOrigin, AllowUnpaidExecutionFrom, ParentAsSuperuser,
AllowTopLevelPaidExecutionFrom, TakeWeightCredit, FixedWeightBounds, IsConcrete, NativeAsset,
AllowUnpaidExecutionFrom, ParentAsSuperuser,
UsingComponents,
};
use xcm_executor::{Config, XcmExecutor};
use pallet_xcm::{XcmPassthrough, EnsureXcm, IsMajorityOfBody};
pub type SessionHandlers = ();
@@ -73,10 +74,10 @@ impl_opaque_keys! {
/// This runtime version.
pub const VERSION: RuntimeVersion = RuntimeVersion {
spec_name: create_runtime_str!("cumulus-test-parachain"),
impl_name: create_runtime_str!("cumulus-test-parachain"),
spec_name: create_runtime_str!("test-parachain"),
impl_name: create_runtime_str!("test-parachain"),
authoring_version: 1,
spec_version: 18,
spec_version: 9,
impl_version: 0,
apis: RUNTIME_API_VERSIONS,
transaction_version: 1,
@@ -93,15 +94,13 @@ pub const MINUTES: BlockNumber = 60_000 / (MILLISECS_PER_BLOCK as BlockNumber);
pub const HOURS: BlockNumber = MINUTES * 60;
pub const DAYS: BlockNumber = HOURS * 24;
pub const ROC: Balance = 1_000_000_000_000;
pub const MILLIROC: Balance = 1_000_000_000;
pub const MICROROC: Balance = 1_000_000;
// 1 in 4 blocks (on average, not counting collisions) will be primary babe blocks.
pub const PRIMARY_PROBABILITY: (u64, u64) = (1, 4);
#[derive(codec::Encode, codec::Decode)]
pub enum XCMPMessage<XAccountId, XBalance> {
/// Transfer tokens to the given account from the Parachain account.
TransferToken(XAccountId, XBalance),
}
/// The version information used to identify this runtime when compiled natively.
#[cfg(feature = "std")]
pub fn native_version() -> NativeVersion {
@@ -152,7 +151,7 @@ impl frame_system::Config for Runtime {
/// The aggregated dispatch type that is available for extrinsics.
type Call = Call;
/// The lookup mechanism to get account ID from whatever is passed in dispatchers.
type Lookup = IdentityLookup<AccountId>;
type Lookup = AccountIdLookup<AccountId, ()>;
/// The index type for storing how many extrinsics an account has signed.
type Index = Index;
/// The index type for blocks.
@@ -198,10 +197,10 @@ impl pallet_timestamp::Config for Runtime {
}
parameter_types! {
pub const ExistentialDeposit: u128 = 500;
pub const TransferFee: u128 = 0;
pub const CreationFee: u128 = 0;
pub const TransactionByteFee: u128 = 1;
pub const ExistentialDeposit: u128 = 1 * MILLIROC;
pub const TransferFee: u128 = 1 * MILLIROC;
pub const CreationFee: u128 = 1 * MILLIROC;
pub const TransactionByteFee: u128 = 1 * MICROROC;
pub const MaxLocks: u32 = 50;
}
@@ -237,11 +236,7 @@ impl cumulus_pallet_parachain_system::Config for Runtime {
type Event = Event;
type OnValidationData = ();
type SelfParaId = parachain_info::Module<Runtime>;
type DownwardMessageHandlers = cumulus_primitives_utility::UnqueuedDmpAsParent<
MaxDownwardMessageWeight,
XcmExecutor<XcmConfig>,
Call,
>;
type DownwardMessageHandlers = CumulusXcm;
type OutboundXcmpMessageSource = XcmpQueue;
type XcmpMessageHandler = XcmpQueue;
type ReservedXcmpWeight = ReservedXcmpWeight;
@@ -250,12 +245,10 @@ impl cumulus_pallet_parachain_system::Config for Runtime {
impl parachain_info::Config for Runtime {}
parameter_types! {
pub const RococoLocation: MultiLocation = MultiLocation::X1(Junction::Parent);
pub const RocLocation: MultiLocation = X1(Parent);
pub const RococoNetwork: NetworkId = NetworkId::Polkadot;
pub RelayChainOrigin: Origin = cumulus_pallet_xcm::Origin::Relay.into();
pub Ancestry: MultiLocation = Junction::Parachain(
ParachainInfo::parachain_id().into()
).into();
pub Ancestry: MultiLocation = X1(Parachain(ParachainInfo::parachain_id().into()));
}
/// Type for specifying how a `MultiLocation` can be converted into an `AccountId`. This is used
@@ -275,7 +268,7 @@ pub type LocalAssetTransactor = CurrencyAdapter<
// Use this currency:
Balances,
// Use this currency when it is a fungible asset matching the given location or name:
IsConcrete<RococoLocation>,
IsConcrete<RocLocation>,
// Do a simple punn to convert an AccountId32 MultiLocation into a native chain account ID:
LocationToAccountId,
// Our chain's account ID type (we can't get away without mentioning it explicitly):
@@ -302,23 +295,39 @@ pub type XcmOriginToTransactDispatchOrigin = (
// Native signed account converter; this just converts an `AccountId32` origin into a normal
// `Origin::Signed` origin of the same 32-byte value.
SignedAccountId32AsNative<RococoNetwork, Origin>,
// Xcm origins can be represented natively under the Xcm pallet's Xcm origin.
XcmPassthrough<Origin>,
);
parameter_types! {
pub UnitWeightCost: Weight = 1_000;
// One XCM operation is 1_000_000 weight - almost certainly a conservative estimate.
pub UnitWeightCost: Weight = 1_000_000;
// One ROC buys 1 second of weight.
pub const WeightPrice: (MultiLocation, u128) = (X1(Parent), ROC);
}
parameter_types! {
// 1_000_000_000_000 => 1 unit of asset for 1 unit of Weight.
// TODO: Should take the actual weight price. This is just 1_000 ROC per second of weight.
pub const WeightPrice: (MultiLocation, u128) = (MultiLocation::X1(Junction::Parent), 1_000);
pub AllowUnpaidFrom: Vec<MultiLocation> = vec![ MultiLocation::X1(Junction::Parent) ];
macro_rules! match_type {
( pub type $n:ident: impl Contains<$t:ty> = { $phead:pat $( | $ptail:pat )* } ; ) => {
pub struct $n;
impl frame_support::traits::Contains<$t> for $n {
fn contains(l: &$t) -> bool {
matches!(l, $phead $( | $ptail )* )
}
}
}
}
match_type! {
pub type ParentOrParentsUnitPlurality: impl Contains<MultiLocation> = {
X1(Parent) | X2(Parent, Plurality { id: BodyId::Unit, .. })
};
}
pub type Barrier = (
TakeWeightCredit,
AllowTopLevelPaidExecutionFrom<All<MultiLocation>>,
AllowUnpaidExecutionFrom<IsInVec<AllowUnpaidFrom>>, // <- Parent gets free execution
AllowUnpaidExecutionFrom<ParentOrParentsUnitPlurality>,
// ^^^ Parent & its unit plurality gets free execution
);
pub struct XcmConfig;
@@ -333,7 +342,7 @@ impl Config for XcmConfig {
type LocationInverter = LocationInverter<Ancestry>;
type Barrier = Barrier;
type Weigher = FixedWeightBounds<UnitWeightCost, Call>;
type Trader = FixedRateOfConcreteFungible<WeightPrice, ()>;
type Trader = UsingComponents<IdentityFee<Balance>, RocLocation, AccountId, Balances, ()>;
type ResponseHandler = (); // Don't handle responses for now.
}
@@ -361,7 +370,11 @@ impl pallet_xcm::Config for Runtime {
type XcmExecutor = XcmExecutor<XcmConfig>;
}
impl cumulus_pallet_xcm::Config for Runtime {}
impl cumulus_pallet_xcm::Config for Runtime {
type Event = Event;
type XcmExecutor = XcmExecutor<XcmConfig>;
type MaxWeight = MaxDownwardMessageWeight;
}
impl cumulus_pallet_xcmp_queue::Config for Runtime {
type Event = Event;
@@ -376,6 +389,34 @@ impl cumulus_ping::Config for Runtime {
type XcmSender = XcmRouter;
}
parameter_types! {
pub const AssetDeposit: Balance = 1 * ROC;
pub const ApprovalDeposit: Balance = 100 * MILLIROC;
pub const StringLimit: u32 = 50;
pub const MetadataDepositBase: Balance = 1 * ROC;
pub const MetadataDepositPerByte: Balance = 10 * MILLIROC;
pub const UnitBody: BodyId = BodyId::Unit;
}
/// A majority of the Unit body from Rococo over XCM is our required administration origin.
pub type AdminOrigin = EnsureXcm<IsMajorityOfBody<RocLocation, UnitBody>>;
impl pallet_assets::Config for Runtime {
type Event = Event;
type Balance = u64;
type AssetId = u32;
type Currency = Balances;
type ForceOrigin = AdminOrigin;
type AssetDeposit = AssetDeposit;
type MetadataDepositBase = MetadataDepositBase;
type MetadataDepositPerByte = MetadataDepositPerByte;
type ApprovalDeposit = ApprovalDeposit;
type StringLimit = StringLimit;
type Freezer = ();
type Extra = ();
type WeightInfo = pallet_assets::weights::SubstrateWeight<Runtime>;
}
construct_runtime! {
pub enum Runtime where
Block = Block,
@@ -384,24 +425,27 @@ construct_runtime! {
{
System: frame_system::{Pallet, Call, Storage, Config, Event<T>},
Timestamp: pallet_timestamp::{Pallet, Call, Storage, Inherent},
Balances: pallet_balances::{Pallet, Call, Storage, Config<T>, Event<T>},
Sudo: pallet_sudo::{Pallet, Call, Storage, Config<T>, Event<T>},
RandomnessCollectiveFlip: pallet_randomness_collective_flip::{Pallet, Call, Storage},
ParachainSystem: cumulus_pallet_parachain_system::{Pallet, Call, Storage, Inherent, Event<T>},
TransactionPayment: pallet_transaction_payment::{Pallet, Storage},
ParachainInfo: parachain_info::{Pallet, Storage, Config},
ParachainSystem: cumulus_pallet_parachain_system::{Pallet, Call, Storage, Inherent, Event<T>} = 20,
ParachainInfo: parachain_info::{Pallet, Storage, Config} = 21,
Balances: pallet_balances::{Pallet, Call, Storage, Config<T>, Event<T>} = 30,
Assets: pallet_assets::{Pallet, Call, Storage, Event<T>} = 31,
// XCM helpers.
XcmpQueue: cumulus_pallet_xcmp_queue::{Pallet, Call, Storage, Event<T>},
PolkadotXcm: pallet_xcm::{Pallet, Call, Event<T>, Origin},
CumulusXcm: cumulus_pallet_xcm::{Pallet, Origin},
XcmpQueue: cumulus_pallet_xcmp_queue::{Pallet, Call, Storage, Event<T>} = 50,
PolkadotXcm: pallet_xcm::{Pallet, Call, Event<T>, Origin} = 51,
CumulusXcm: cumulus_pallet_xcm::{Pallet, Call, Event<T>, Origin} = 52,
Spambot: cumulus_ping::{Pallet, Call, Storage, Event<T>} = 99,
}
}
/// The address format for describing accounts.
pub type Address = AccountId;
pub type Address = sp_runtime::MultiAddress<AccountId, ()>;
/// Block header type as expected by this runtime.
pub type Header = generic::Header<BlockNumber, BlakeTwo256>;
/// Block type as expected by this runtime.
@@ -48,6 +48,7 @@ pallet-xcm = { git = "https://github.com/paritytech/polkadot", default-features
[dev-dependencies]
hex = "0.4.3"
hex-literal = "0.3.1"
[build-dependencies]
substrate-wasm-builder = "3.0.0"
+14 -22
View File
@@ -27,7 +27,7 @@ use sp_api::impl_runtime_apis;
use sp_core::OpaqueMetadata;
use sp_runtime::{
create_runtime_str, generic, impl_opaque_keys,
traits::{BlakeTwo256, Block as BlockT, IdentityLookup},
traits::{BlakeTwo256, Block as BlockT, AccountIdLookup},
transaction_validity::{TransactionSource, TransactionValidity},
ApplyExtrinsicResult,
};
@@ -65,18 +65,16 @@ use xcm_builder::{
};
use xcm_executor::{Config, XcmExecutor};
pub type SessionHandlers = ();
impl_opaque_keys! {
pub struct SessionKeys {}
}
/// This runtime version.
pub const VERSION: RuntimeVersion = RuntimeVersion {
spec_name: create_runtime_str!("cumulus-test-parachain"),
impl_name: create_runtime_str!("cumulus-test-parachain"),
spec_name: create_runtime_str!("shell"),
impl_name: create_runtime_str!("shell"),
authoring_version: 1,
spec_version: 18,
spec_version: 2,
impl_version: 0,
apis: RUNTIME_API_VERSIONS,
transaction_version: 1,
@@ -96,12 +94,6 @@ pub const DAYS: BlockNumber = HOURS * 24;
// 1 in 4 blocks (on average, not counting collisions) will be primary babe blocks.
pub const PRIMARY_PROBABILITY: (u64, u64) = (1, 4);
#[derive(codec::Encode, codec::Decode)]
pub enum XCMPMessage<XAccountId, XBalance> {
/// Transfer tokens to the given account from the Parachain account.
TransferToken(XAccountId, XBalance),
}
/// The version information used to identify this runtime when compiled natively.
#[cfg(feature = "std")]
pub fn native_version() -> NativeVersion {
@@ -152,7 +144,7 @@ impl frame_system::Config for Runtime {
/// The aggregated dispatch type that is available for extrinsics.
type Call = Call;
/// The lookup mechanism to get account ID from whatever is passed in dispatchers.
type Lookup = IdentityLookup<AccountId>;
type Lookup = AccountIdLookup<AccountId, ()>;
/// The index type for storing how many extrinsics an account has signed.
type Index = Index;
/// The index type for blocks.
@@ -232,11 +224,7 @@ impl cumulus_pallet_parachain_system::Config for Runtime {
type Event = Event;
type OnValidationData = ();
type SelfParaId = parachain_info::Module<Runtime>;
type DownwardMessageHandlers = cumulus_primitives_utility::UnqueuedDmpAsParent<
MaxDownwardMessageWeight,
XcmExecutor<XcmConfig>,
Call,
>;
type DownwardMessageHandlers = CumulusXcm;
type OutboundXcmpMessageSource = XcmpQueue;
type XcmpMessageHandler = XcmpQueue;
type ReservedXcmpWeight = ReservedXcmpWeight;
@@ -356,7 +344,11 @@ impl pallet_xcm::Config for Runtime {
type XcmExecutor = XcmExecutor<XcmConfig>;
}
impl cumulus_pallet_xcm::Config for Runtime {}
impl cumulus_pallet_xcm::Config for Runtime {
type Event = Event;
type XcmExecutor = XcmExecutor<XcmConfig>;
type MaxWeight = MaxDownwardMessageWeight;
}
impl cumulus_pallet_xcmp_queue::Config for Runtime {
type Event = Event;
@@ -380,13 +372,13 @@ construct_runtime! {
// XCM helpers.
XcmpQueue: cumulus_pallet_xcmp_queue::{Pallet, Call, Storage, Event<T>},
PolkadotXcm: pallet_xcm::{Pallet, Call, Event<T>, Origin},
CumulusXcm: cumulus_pallet_xcm::{Pallet, Origin},
PolkadotXcm: pallet_xcm::{Pallet, Call, Storage, Event<T>, Origin},
CumulusXcm: cumulus_pallet_xcm::{Pallet, Call, Storage, Event<T>, Origin},
}
}
/// The address format for describing accounts.
pub type Address = AccountId;
pub type Address = sp_runtime::MultiAddress<AccountId, ()>;
/// Block header type as expected by this runtime.
pub type Header = generic::Header<BlockNumber, BlakeTwo256>;
/// Block type as expected by this runtime.