diff --git a/Cargo.lock b/Cargo.lock index bb496f73a62f..a06a7dfbdb4b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -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", diff --git a/pallets/parachain-system/src/lib.rs b/pallets/parachain-system/src/lib.rs index 90c832eb0c6b..65a6baa2d79e 100644 --- a/pallets/parachain-system/src/lib.rs +++ b/pallets/parachain-system/src/lib.rs @@ -471,7 +471,7 @@ impl Module { 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 Module { downward_messages: Vec, ) -> Result { 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::::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 ProvideInherent for Module { decl_event! { pub enum Event where Hash = ::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), } } diff --git a/pallets/xcm/Cargo.toml b/pallets/xcm/Cargo.toml index 7f89b98cfb7f..2d3c0f8220f2 100644 --- a/pallets/xcm/Cargo.toml +++ b/pallets/xcm/Cargo.toml @@ -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" } diff --git a/pallets/xcm/src/lib.rs b/pallets/xcm/src/lib.rs index 5ca05794efcb..717365372d2b 100644 --- a/pallets/xcm/src/lib.rs +++ b/pallets/xcm/src/lib.rs @@ -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> + IsType<::Event>; + + type XcmExecutor: ExecuteXcm; + + #[pallet::constant] + type MaxWeight: Get; + } #[pallet::error] - pub enum Error {} + pub enum Error { + } #[pallet::hooks] impl Hooks> for Pallet {} #[pallet::call] impl Pallet {} + + #[pallet::event] + #[pallet::generate_deposit(pub(super) fn deposit_event)] + #[pallet::metadata(T::BlockNumber = "BlockNumber")] + pub enum Event { + /// 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 DownwardMessageHandler for Pallet { + fn handle_downward_message(msg: InboundDownwardMessage) -> Weight { + let id = sp_io::hashing::twox_64(&msg.msg[..]); + let msg = VersionedXcm::::decode(&mut &msg.msg[..]) + .map(Xcm::::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. diff --git a/rococo-parachains/runtime/Cargo.toml b/rococo-parachains/runtime/Cargo.toml index 1c6064cba412..73c9accb4c3d 100644 --- a/rococo-parachains/runtime/Cargo.toml +++ b/rococo-parachains/runtime/Cargo.toml @@ -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", diff --git a/rococo-parachains/runtime/src/lib.rs b/rococo-parachains/runtime/src/lib.rs index 1a0146d23f0d..f47c567e7c4f 100644 --- a/rococo-parachains/runtime/src/lib.rs +++ b/rococo-parachains/runtime/src/lib.rs @@ -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 { - /// 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; + type Lookup = AccountIdLookup; /// 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; - type DownwardMessageHandlers = cumulus_primitives_utility::UnqueuedDmpAsParent< - MaxDownwardMessageWeight, - XcmExecutor, - 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, + IsConcrete, // 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, + // Xcm origins can be represented natively under the Xcm pallet's Xcm origin. + XcmPassthrough, ); 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 = 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 = { + X1(Parent) | X2(Parent, Plurality { id: BodyId::Unit, .. }) + }; } pub type Barrier = ( TakeWeightCredit, AllowTopLevelPaidExecutionFrom>, - AllowUnpaidExecutionFrom>, // <- Parent gets free execution + AllowUnpaidExecutionFrom, + // ^^^ Parent & its unit plurality gets free execution ); pub struct XcmConfig; @@ -333,7 +342,7 @@ impl Config for XcmConfig { type LocationInverter = LocationInverter; type Barrier = Barrier; type Weigher = FixedWeightBounds; - type Trader = FixedRateOfConcreteFungible; + type Trader = UsingComponents, RocLocation, AccountId, Balances, ()>; type ResponseHandler = (); // Don't handle responses for now. } @@ -361,7 +370,11 @@ impl pallet_xcm::Config for Runtime { type XcmExecutor = XcmExecutor; } -impl cumulus_pallet_xcm::Config for Runtime {} +impl cumulus_pallet_xcm::Config for Runtime { + type Event = Event; + type XcmExecutor = XcmExecutor; + 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>; + +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; +} + construct_runtime! { pub enum Runtime where Block = Block, @@ -384,24 +425,27 @@ construct_runtime! { { System: frame_system::{Pallet, Call, Storage, Config, Event}, Timestamp: pallet_timestamp::{Pallet, Call, Storage, Inherent}, - Balances: pallet_balances::{Pallet, Call, Storage, Config, Event}, Sudo: pallet_sudo::{Pallet, Call, Storage, Config, Event}, RandomnessCollectiveFlip: pallet_randomness_collective_flip::{Pallet, Call, Storage}, - ParachainSystem: cumulus_pallet_parachain_system::{Pallet, Call, Storage, Inherent, Event}, TransactionPayment: pallet_transaction_payment::{Pallet, Storage}, - ParachainInfo: parachain_info::{Pallet, Storage, Config}, + + ParachainSystem: cumulus_pallet_parachain_system::{Pallet, Call, Storage, Inherent, Event} = 20, + ParachainInfo: parachain_info::{Pallet, Storage, Config} = 21, + + Balances: pallet_balances::{Pallet, Call, Storage, Config, Event} = 30, + Assets: pallet_assets::{Pallet, Call, Storage, Event} = 31, // XCM helpers. - XcmpQueue: cumulus_pallet_xcmp_queue::{Pallet, Call, Storage, Event}, - PolkadotXcm: pallet_xcm::{Pallet, Call, Event, Origin}, - CumulusXcm: cumulus_pallet_xcm::{Pallet, Origin}, + XcmpQueue: cumulus_pallet_xcmp_queue::{Pallet, Call, Storage, Event} = 50, + PolkadotXcm: pallet_xcm::{Pallet, Call, Event, Origin} = 51, + CumulusXcm: cumulus_pallet_xcm::{Pallet, Call, Event, Origin} = 52, Spambot: cumulus_ping::{Pallet, Call, Storage, Event} = 99, } } /// The address format for describing accounts. -pub type Address = AccountId; +pub type Address = sp_runtime::MultiAddress; /// Block header type as expected by this runtime. pub type Header = generic::Header; /// Block type as expected by this runtime. diff --git a/rococo-parachains/shell-runtime/Cargo.toml b/rococo-parachains/shell-runtime/Cargo.toml index ab55950e2d16..0aab8e91c243 100644 --- a/rococo-parachains/shell-runtime/Cargo.toml +++ b/rococo-parachains/shell-runtime/Cargo.toml @@ -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" diff --git a/rococo-parachains/shell-runtime/src/lib.rs b/rococo-parachains/shell-runtime/src/lib.rs index 9a45a03fc7dc..03620e3a7b9a 100644 --- a/rococo-parachains/shell-runtime/src/lib.rs +++ b/rococo-parachains/shell-runtime/src/lib.rs @@ -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 { - /// 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; + type Lookup = AccountIdLookup; /// 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; - type DownwardMessageHandlers = cumulus_primitives_utility::UnqueuedDmpAsParent< - MaxDownwardMessageWeight, - XcmExecutor, - 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; } -impl cumulus_pallet_xcm::Config for Runtime {} +impl cumulus_pallet_xcm::Config for Runtime { + type Event = Event; + type XcmExecutor = XcmExecutor; + 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}, - PolkadotXcm: pallet_xcm::{Pallet, Call, Event, Origin}, - CumulusXcm: cumulus_pallet_xcm::{Pallet, Origin}, + PolkadotXcm: pallet_xcm::{Pallet, Call, Storage, Event, Origin}, + CumulusXcm: cumulus_pallet_xcm::{Pallet, Call, Storage, Event, Origin}, } } /// The address format for describing accounts. -pub type Address = AccountId; +pub type Address = sp_runtime::MultiAddress; /// Block header type as expected by this runtime. pub type Header = generic::Header; /// Block type as expected by this runtime.