From 7b1df21772abda3f55c0b45a772b43a0cc0d33b5 Mon Sep 17 00:00:00 2001 From: Stanly Johnson Date: Mon, 19 Apr 2021 00:54:58 +0530 Subject: [PATCH] compile latest cumulus --- Cargo.lock | 210 +++++++++++++++++++++++++++++++ example/Cargo.toml | 4 +- example/src/main.rs | 31 +++-- xcm-simulator/Cargo.toml | 3 + xcm-simulator/src/lib.rs | 44 ++++--- xcm-simulator/src/parachain.rs | 83 +++++++----- xcm-simulator/src/relay_chain.rs | 23 ++-- xcm-simulator/src/traits.rs | 5 +- 8 files changed, 332 insertions(+), 71 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index df7e992..dc846f7 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -280,6 +280,19 @@ version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5024ee8015f02155eee35c711107ddd9a9bf3cb689cf2a9089c97e79b6e1ae83" +[[package]] +name = "beefy-primitives" +version = "0.1.0" +source = "git+https://github.com/paritytech/grandpa-bridge-gadget?branch=rococo-v1#d3599994d4a54fb8573367c22e090354a2df1de6" +dependencies = [ + "parity-scale-codec", + "sp-api", + "sp-application-crypto", + "sp-core", + "sp-runtime", + "sp-std", +] + [[package]] name = "bitflags" version = "1.2.1" @@ -433,6 +446,15 @@ dependencies = [ "winapi", ] +[[package]] +name = "ckb-merkle-mountain-range" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e486fe53bb9f2ca0f58cb60e8679a5354fd6687a839942ef0a75967250289ca6" +dependencies = [ + "cfg-if 0.1.10", +] + [[package]] name = "concurrent-queue" version = "1.2.2" @@ -552,6 +574,24 @@ dependencies = [ "xcm", ] +[[package]] +name = "cumulus-pallet-xcmp-queue" +version = "0.1.0" +source = "git+https://github.com/paritytech/cumulus?branch=rococo-v1#6ed96321a6b004eb860454087b3a7e278f326eb1" +dependencies = [ + "cumulus-primitives-core", + "frame-support", + "frame-system", + "log", + "parity-scale-codec", + "rand 0.8.3", + "rand_chacha 0.3.0", + "sp-runtime", + "sp-std", + "xcm", + "xcm-executor", +] + [[package]] name = "cumulus-primitives-core" version = "0.1.0" @@ -587,6 +627,24 @@ dependencies = [ "tracing", ] +[[package]] +name = "cumulus-primitives-utility" +version = "0.1.0" +source = "git+https://github.com/paritytech/cumulus?branch=rococo-v1#6ed96321a6b004eb860454087b3a7e278f326eb1" +dependencies = [ + "cumulus-primitives-core", + "frame-support", + "impl-trait-for-tuples", + "parity-scale-codec", + "polkadot-core-primitives", + "polkadot-parachain", + "polkadot-primitives", + "sp-runtime", + "sp-std", + "sp-trie", + "xcm", +] + [[package]] name = "curve25519-dalek" version = "2.1.2" @@ -1879,6 +1937,55 @@ dependencies = [ "sp-std", ] +[[package]] +name = "pallet-beefy" +version = "0.1.0" +source = "git+https://github.com/paritytech/grandpa-bridge-gadget?branch=rococo-v1#d3599994d4a54fb8573367c22e090354a2df1de6" +dependencies = [ + "beefy-primitives", + "frame-support", + "frame-system", + "pallet-session", + "parity-scale-codec", + "serde", + "sp-runtime", + "sp-std", +] + +[[package]] +name = "pallet-mmr" +version = "3.0.0" +source = "git+https://github.com/paritytech/substrate?branch=rococo-v1#68cfc326fa0e3d96d0d92509e4db1a104b9da9bb" +dependencies = [ + "ckb-merkle-mountain-range", + "frame-benchmarking", + "frame-support", + "frame-system", + "pallet-mmr-primitives", + "parity-scale-codec", + "serde", + "sp-core", + "sp-io", + "sp-runtime", + "sp-std", +] + +[[package]] +name = "pallet-mmr-primitives" +version = "3.0.0" +source = "git+https://github.com/paritytech/substrate?branch=rococo-v1#68cfc326fa0e3d96d0d92509e4db1a104b9da9bb" +dependencies = [ + "frame-support", + "frame-system", + "log", + "parity-scale-codec", + "serde", + "sp-api", + "sp-core", + "sp-runtime", + "sp-std", +] + [[package]] name = "pallet-offences" version = "3.0.0" @@ -1954,6 +2061,37 @@ dependencies = [ "sp-timestamp", ] +[[package]] +name = "pallet-transaction-payment" +version = "3.0.0" +source = "git+https://github.com/paritytech/substrate?branch=rococo-v1#68cfc326fa0e3d96d0d92509e4db1a104b9da9bb" +dependencies = [ + "frame-support", + "frame-system", + "parity-scale-codec", + "serde", + "smallvec", + "sp-core", + "sp-io", + "sp-runtime", + "sp-std", +] + +[[package]] +name = "pallet-treasury" +version = "3.0.0" +source = "git+https://github.com/paritytech/substrate?branch=rococo-v1#68cfc326fa0e3d96d0d92509e4db1a104b9da9bb" +dependencies = [ + "frame-support", + "frame-system", + "impl-trait-for-tuples", + "pallet-balances", + "parity-scale-codec", + "serde", + "sp-runtime", + "sp-std", +] + [[package]] name = "pallet-vesting" version = "3.0.0" @@ -1968,6 +2106,20 @@ dependencies = [ "sp-std", ] +[[package]] +name = "pallet-xcm" +version = "0.1.0" +source = "git+https://github.com/paritytech/polkadot?branch=rococo-v1#943038a888bfaf736142642e2610b248f7af486c" +dependencies = [ + "frame-support", + "frame-system", + "parity-scale-codec", + "serde", + "sp-runtime", + "sp-std", + "xcm", +] + [[package]] name = "parachain-info" version = "0.1.0" @@ -2263,6 +2415,48 @@ dependencies = [ "thiserror", ] +[[package]] +name = "polkadot-runtime-common" +version = "0.8.30" +source = "git+https://github.com/paritytech/polkadot?branch=rococo-v1#943038a888bfaf736142642e2610b248f7af486c" +dependencies = [ + "beefy-primitives", + "bitvec", + "frame-support", + "frame-system", + "impl-trait-for-tuples", + "libsecp256k1", + "log", + "pallet-authorship", + "pallet-balances", + "pallet-beefy", + "pallet-mmr", + "pallet-offences", + "pallet-session", + "pallet-staking", + "pallet-timestamp", + "pallet-transaction-payment", + "pallet-treasury", + "pallet-vesting", + "parity-scale-codec", + "polkadot-primitives", + "polkadot-runtime-parachains", + "rustc-hex", + "serde", + "serde_derive", + "slot-range-helper", + "sp-api", + "sp-core", + "sp-inherents", + "sp-io", + "sp-runtime", + "sp-session", + "sp-staking", + "sp-std", + "static_assertions", + "xcm", +] + [[package]] name = "polkadot-runtime-parachains" version = "0.8.30" @@ -2965,6 +3159,17 @@ version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c111b5bd5695e56cffe5129854aa230b39c93a305372fdbb2668ca2394eea9f8" +[[package]] +name = "slot-range-helper" +version = "0.8.30" +source = "git+https://github.com/paritytech/polkadot?branch=rococo-v1#943038a888bfaf736142642e2610b248f7af486c" +dependencies = [ + "parity-scale-codec", + "paste 1.0.5", + "sp-runtime", + "sp-std", +] + [[package]] name = "smallvec" version = "1.6.1" @@ -4197,14 +4402,17 @@ dependencies = [ "cumulus-pallet-parachain-system", "cumulus-pallet-xcm", "cumulus-primitives-core", + "cumulus-primitives-utility", "frame-support", "frame-system", "pallet-balances", + "pallet-xcm", "parachain-info", "parity-scale-codec", "paste 1.0.5", "polkadot-core-primitives", "polkadot-parachain", + "polkadot-runtime-common", "polkadot-runtime-parachains", "serde", "sp-core", @@ -4220,7 +4428,9 @@ dependencies = [ name = "xcm-simulator-example" version = "0.1.0" dependencies = [ + "cumulus-pallet-parachain-system", "cumulus-pallet-xcm", + "cumulus-pallet-xcmp-queue", "frame-support", "frame-system", "orml-nft", diff --git a/example/Cargo.toml b/example/Cargo.toml index e89e657..441fcb4 100644 --- a/example/Cargo.toml +++ b/example/Cargo.toml @@ -15,8 +15,10 @@ frame-support = { git = "https://github.com/paritytech/substrate", branch = "roc pallet-balances = { git = "https://github.com/paritytech/substrate", branch = "rococo-v1" } parachain-info = { git = "https://github.com/paritytech/cumulus", branch = "rococo-v1" } cumulus-pallet-xcm = { git = "https://github.com/paritytech/cumulus", branch = "rococo-v1" } +cumulus-pallet-parachain-system = { git = "https://github.com/paritytech/cumulus", branch = "rococo-v1" } +cumulus-pallet-xcmp-queue = { git = "https://github.com/paritytech/cumulus", branch = "rococo-v1" } # [dev-dependencies] xcm = { git = "https://github.com/paritytech/polkadot", branch = "rococo-v1" } orml-nft = { git = "https://github.com/open-web3-stack/open-runtime-module-library", branch = "master" } -xcm-simulator = { path = "../xcm-simulator" } +xcm-simulator = { path = "../xcm-simulator" } \ No newline at end of file diff --git a/example/src/main.rs b/example/src/main.rs index e16a6ff..7639838 100644 --- a/example/src/main.rs +++ b/example/src/main.rs @@ -2,7 +2,7 @@ fn main() {} #[cfg(test)] mod tests { - use xcm::v0::{Junction, OriginKind, SendXcm, Xcm}; + use xcm::v0::{opaque::Xcm, Junction, OriginKind, SendXcm}; use xcm_simulator::{decl_test_network, decl_test_parachain, prelude::*}; decl_test_parachain! { @@ -54,11 +54,12 @@ mod tests { fn try_hrmp() { TestNetwork::reset(); MockAcala::execute_with(|| { - let _ = ::send_xcm( + let _ = ::send_xcm( (Junction::Parent, Junction::Parachain { id: 2 }).into(), Xcm::Transact { origin_type: OriginKind::Native, - call: vec![1], + require_weight_at_most: 1_000, + call: vec![1].into(), }, ); println!(">>> Acala events:"); @@ -94,11 +95,12 @@ mod tests { fn try_ump() { TestNetwork::reset(); MockAcala::execute_with(|| { - let _ = ::send_xcm( + let _ = ::send_xcm( Junction::Parent.into(), Xcm::Transact { origin_type: OriginKind::Native, - call: vec![1], + require_weight_at_most: 1_000, + call: vec![1].into(), }, ); println!(">>> Acala events:"); @@ -117,11 +119,12 @@ mod tests { TestNetwork::reset(); println!("------ network reset ------"); MockAcala::execute_with(|| { - let _ = ::send_xcm( + let _ = ::send_xcm( Junction::Parent.into(), Xcm::Transact { origin_type: OriginKind::Native, - call: vec![1], + require_weight_at_most: 1_000, + call: vec![1].into(), }, ); println!(">>> Acala events:"); @@ -142,10 +145,14 @@ mod tests { TestNetwork::reset(); MockRelay::execute_with(|| { - relay::XcmSender::send_xcm(Junction::Parachain { id: 1 }.into(), Xcm::Transact { - origin_type: OriginKind::Native, - call: vec![1], - }); + relay::XcmSender::send_xcm( + Junction::Parachain { id: 1 }.into(), + Xcm::Transact { + origin_type: OriginKind::Native, + require_weight_at_most: 1_000, + call: vec![1].into(), + }, + ); println!(">>> Relay chain events:"); relay::System::events().iter().for_each(|r| { @@ -160,4 +167,4 @@ mod tests { }); }); } -} +} \ No newline at end of file diff --git a/xcm-simulator/Cargo.toml b/xcm-simulator/Cargo.toml index 30386d9..b393534 100644 --- a/xcm-simulator/Cargo.toml +++ b/xcm-simulator/Cargo.toml @@ -21,6 +21,7 @@ frame-system = { git = "https://github.com/paritytech/substrate", branch = "roco pallet-balances = { git = "https://github.com/paritytech/substrate", branch = "rococo-v1" } cumulus-primitives-core = { git = "https://github.com/paritytech/cumulus", branch = "rococo-v1" } +cumulus-primitives-utility = { git = "https://github.com/paritytech/cumulus", branch = "rococo-v1" } cumulus-pallet-parachain-system = { git = "https://github.com/paritytech/cumulus", branch = "rococo-v1" } parachain-info = { git = "https://github.com/paritytech/cumulus", branch = "rococo-v1" } cumulus-pallet-xcm = { git = "https://github.com/paritytech/cumulus", branch = "rococo-v1" } @@ -31,3 +32,5 @@ xcm-executor = { git = "https://github.com/paritytech/polkadot", branch = "rococ polkadot-parachain = { git = "https://github.com/paritytech/polkadot", branch = "rococo-v1" } polkadot-core-primitives = { git = "https://github.com/paritytech/polkadot", branch = "rococo-v1" } runtime-parachains = { package = "polkadot-runtime-parachains", git = "https://github.com/paritytech/polkadot", branch = "rococo-v1" } +pallet-xcm = { git = "https://github.com/paritytech/polkadot", branch = "rococo-v1" } +polkadot-runtime-common = { git = "https://github.com/paritytech/polkadot", branch = "rococo-v1" } \ No newline at end of file diff --git a/xcm-simulator/src/lib.rs b/xcm-simulator/src/lib.rs index 13017d4..0906b33 100644 --- a/xcm-simulator/src/lib.rs +++ b/xcm-simulator/src/lib.rs @@ -1,5 +1,5 @@ -pub use paste; pub use codec; +pub use paste; pub use frame_support; pub use frame_system; @@ -9,10 +9,14 @@ pub use sp_io; pub use sp_runtime; pub use sp_std; +pub use cumulus_pallet_parachain_system; pub use cumulus_pallet_xcm; pub use cumulus_primitives_core; +pub use cumulus_primitives_utility; pub use parachain_info; pub use polkadot_parachain; +pub use polkadot_runtime_common; +pub use polkadot_core_primitives; pub use runtime_parachains; pub use xcm; pub use xcm_builder; @@ -49,7 +53,7 @@ macro_rules! __decl_test_relay_chain { use $crate::runtime_parachains::ump::UmpSink; Self::execute_with(|| { - $relay_mod::UmpSink::process_upward_message(from.into(), msg); + $relay_mod::UmpSink::process_upward_message(from.into(), &msg, 1_000); }); Ok(()) @@ -89,30 +93,30 @@ macro_rules! decl_test_parachain { } impl $crate::HrmpMsgHandler for $name { - fn handle_hrmp_msg(from: u32, msg: $crate::xcm::VersionedXcm) -> Result<(), ()> { + fn handle_hrmp_msg(from: u32, msg: $crate::xcm::opaque::VersionedXcm) -> Result<(), ()> { use $crate::cumulus_primitives_core::{XcmpMessageHandler, InboundHrmpMessage}; - $name::execute_with(|| { - //TODO: `sent_at` - check with runtime - $para_mod::XcmHandler::handle_xcm_message(from.into(), 1, msg); - }); + // $name::execute_with(|| { + // //TODO: `sent_at` - check with runtime + // $para_mod::ParachainSystem::handle_xcmp_messages(from.into(), 1); + // }); Ok(()) } } impl $crate::DmpMsgHandler for $name { - fn handle_dmp_msg(msg: $crate::xcm::v0::Xcm) -> $crate::xcm::v0::Result { + fn handle_dmp_msg(msg: $crate::xcm::v0::opaque::Xcm) -> $crate::xcm::v0::Result { use $crate::cumulus_primitives_core::{DownwardMessageHandler, InboundDownwardMessage}; use $crate::codec::Encode; - $name::execute_with(|| { - //TODO: `sent_at` - check with runtime - let dmp_msg = InboundDownwardMessage { - sent_at: 1, - msg: $crate::xcm::VersionedXcm::from(msg).encode(), - }; - $para_mod::XcmHandler::handle_downward_message(dmp_msg); - }); + // $name::execute_with(|| { + // //TODO: `sent_at` - check with runtime + // let dmp_msg = InboundDownwardMessage { + // sent_at: 1, + // msg: $crate::xcm::VersionedXcm::from(msg).encode(), + // }; + // $para_mod::XcmHandler::handle_downward_message(dmp_msg); + // }); Ok(()) } } @@ -192,7 +196,7 @@ macro_rules! decl_test_network { MockRelay::handle_ump_msg(from, msg) } - fn send_hrmp_msg(from: u32, to: u32, msg: $crate::xcm::VersionedXcm) -> Result<(), ()> { + fn send_hrmp_msg(from: u32, to: u32, msg: $crate::xcm::opaque::VersionedXcm) -> Result<(), ()> { println!("hrmp: from {:?}, to {:?}, msg {:?}", from, to, msg); match to { @@ -201,14 +205,14 @@ macro_rules! decl_test_network { } } - fn send_dmp_msg(to: u32, msg: $crate::xcm::v0::Xcm) -> $crate::xcm::v0::Result { + fn send_dmp_msg(to: u32, msg: $crate::xcm::v0::opaque::Xcm) -> $crate::xcm::v0::Result { println!("dmp: to {:?}, msg {:?}", to, msg); match to { $( $para_id => <$parachain>::handle_dmp_msg(msg), )* - _ => Err($crate::xcm::v0::Error::CannotReachDestination), + _ => Err($crate::xcm::v0::Error::CannotReachDestination($crate::xcm::v0::MultiLocation::Null, msg)), } } } }; -} +} \ No newline at end of file diff --git a/xcm-simulator/src/parachain.rs b/xcm-simulator/src/parachain.rs index 9d84fc3..dcbe942 100644 --- a/xcm-simulator/src/parachain.rs +++ b/xcm-simulator/src/parachain.rs @@ -21,7 +21,7 @@ macro_rules! __construct_parachain_runtime { xcm_config = { $crate::frame_support::parameter_types! { pub Network: $crate::xcm::v0::NetworkId = $crate::xcm::v0::NetworkId::Any; - pub RelayChainOrigin: Origin = Into::::into($crate::cumulus_pallet_xcm_handler::Origin::Relay); + pub RelayChainOrigin: Origin = Into::::into($crate::cumulus_pallet_xcm::Origin::Relay); pub Ancestry: $crate::xcm::v0::MultiLocation = $crate::xcm::v0::MultiLocation::X1( $crate::xcm::v0::Junction::Parachain { id: >::get().into(), @@ -38,19 +38,41 @@ macro_rules! __construct_parachain_runtime { pub type LocalOriginConverter = ( $crate::xcm_builder::SovereignSignedViaLocation, $crate::xcm_builder::RelayChainAsNative, - $crate::xcm_builder::SiblingParachainAsNative<$crate::cumulus_pallet_xcm_handler::Origin, Origin>, + $crate::xcm_builder::SiblingParachainAsNative<$crate::cumulus_pallet_xcm::Origin, Origin>, $crate::xcm_builder::SignedAccountId32AsNative, ); + pub struct XcmSender; + impl $crate::xcm::v0::SendXcm for XcmSender { + fn send_xcm(dest: $crate::xcm::v0::MultiLocation, msg: $crate::xcm::v0::opaque::Xcm) -> $crate::xcm::v0::Result { + use $crate::xcm::v0::{MultiLocation::*, Junction::*, Error}; + + if let X1(Parachain { id }) = dest { + <$test_network>::send_dmp_msg(id, msg) + } else { + Err(Error::CannotReachDestination(dest, msg)) + } + } + } + + $crate::frame_support::parameter_types! { + pub UnitWeightCost: $crate::frame_support::weights::Weight = 1_000; + pub const WeightPrice: ($crate::xcm::v0::MultiLocation, u128) = ($crate::xcm::v0::MultiLocation::X1($crate::xcm::v0::Junction::Parent), 1_000); + } + pub struct XcmConfig; impl $crate::xcm_executor::Config for XcmConfig { type Call = Call; - type XcmSender = XcmHandler; + type XcmSender = XcmSender; type AssetTransactor = (); type OriginConverter = LocalOriginConverter; - type IsReserve = $crate::xcm_executor::traits::NativeAsset; + type IsReserve = $crate::xcm_builder::NativeAsset; type IsTeleporter = (); type LocationInverter = $crate::xcm_builder::LocationInverter; + type Barrier = (); + type Weigher = $crate::xcm_builder::FixedWeightBounds; + type Trader = $crate::xcm_builder::FixedRateOfConcreteFungible; + type ResponseHandler = (); } }, extra_config = { @@ -104,7 +126,7 @@ macro_rules! __construct_parachain_runtime { type BaseCallFilter = (); type SystemWeightInfo = (); type SS58Prefix = (); - type OnSetCode = (); + type OnSetCode = cumulus_pallet_parachain_system::ParachainSetCode; } impl $crate::parachain_info::Config for Runtime {} @@ -119,34 +141,35 @@ macro_rules! __construct_parachain_runtime { } } - impl $crate::cumulus_primitives_core::XcmpMessageSender for MockMessenger { - fn send_xcm_message( - dest: $crate::cumulus_primitives_core::ParaId, - msg: xcm::VersionedXcm, - qos: $crate::cumulus_primitives_core::ServiceQuality - ) -> Result { - let _ = <$test_network>::send_hrmp_msg(ParachainInfo::parachain_id().into(), dest.into(), msg); - Ok(0) - } + impl $crate::cumulus_primitives_core::XcmpMessageSource for MockMessenger { + fn take_outbound_messages( + _maximum_channels: usize + ) -> Vec<($crate::cumulus_primitives_core::ParaId, Vec)> { vec![] } + } - fn send_blob_message( - dest: $crate::cumulus_primitives_core::ParaId, - msg: Vec, - qos: $crate::cumulus_primitives_core::ServiceQuality - ) -> Result { - Ok(0) - } + impl $crate::cumulus_primitives_core::XcmpMessageHandler for MockMessenger { + fn handle_xcmp_messages<'a, I: Iterator>( + iter: I, + _max_weight: $crate::frame_support::weights::Weight, + ) -> $crate::frame_support::weights::Weight { for _ in iter {} 0 } + } + + impl $crate::cumulus_primitives_core::DownwardMessageHandler for MockMessenger { + fn handle_downward_message(_msg: $crate::cumulus_primitives_core::InboundDownwardMessage) -> $crate::frame_support::weights::Weight { 0 } } $( $xcm_config )* - impl $crate::cumulus_pallet_xcm_handler::Config for Runtime { + impl $crate::cumulus_pallet_xcm::Config for Runtime {} + + impl $crate::cumulus_pallet_parachain_system::Config for Runtime { type Event = Event; - type XcmExecutor = $crate::xcm_executor::XcmExecutor; - type UpwardMessageSender = MockMessenger; - type XcmpMessageSender = MockMessenger; - type SendXcmOrigin = $crate::frame_system::EnsureRoot; - type AccountIdConverter = LocationConverter; + type OnValidationData = (); + type SelfParaId = parachain_info::Module; + type DownwardMessageHandlers = MockMessenger; + type OutboundXcmpMessageSource = MockMessenger; + type XcmpMessageHandler = MockMessenger; + type ReservedXcmpWeight = (); } $( $extra_config )* @@ -164,8 +187,8 @@ macro_rules! __construct_parachain_runtime { // https://github.com/paritytech/substrate/issues/8085 System: frame_system::{Pallet, Call, Storage, Config, Event}, ParachainInfo: parachain_info::{Pallet, Storage, Config}, - XcmHandler: cumulus_pallet_xcm_handler::{Pallet, Call, Event, Origin}, - + XcmHandler: cumulus_pallet_xcm::{Pallet, Origin}, + ParachainSystem: cumulus_pallet_parachain_system::{Pallet, Call, Storage, Inherent, Event}, $( $extra_modules )* } ); @@ -207,4 +230,4 @@ where ::BlockNumber: From, { ExtBuilder::default().build::(para_id) -} +} \ No newline at end of file diff --git a/xcm-simulator/src/relay_chain.rs b/xcm-simulator/src/relay_chain.rs index b9744d3..73eae71 100644 --- a/xcm-simulator/src/relay_chain.rs +++ b/xcm-simulator/src/relay_chain.rs @@ -74,7 +74,7 @@ macro_rules! __construct_relay_chain_runtime { // Use this currency: Balances, // Use this currency when it is a fungible asset matching the given location or name: - $crate::xcm_executor::traits::IsConcrete, + $crate::xcm_builder::IsConcrete, // We can convert the MultiLocations with our converter above: LocationConverter, // Our chain's account ID type (we can't get away without mentioning it explicitly): @@ -90,17 +90,22 @@ macro_rules! __construct_relay_chain_runtime { pub struct XcmSender; impl $crate::xcm::v0::SendXcm for XcmSender { - fn send_xcm(dest: $crate::xcm::v0::MultiLocation, msg: $crate::xcm::v0::Xcm) -> $crate::xcm::v0::Result { + fn send_xcm(dest: $crate::xcm::v0::MultiLocation, msg: $crate::xcm::v0::opaque::Xcm) -> $crate::xcm::v0::Result { use $crate::xcm::v0::{MultiLocation::*, Junction::*, Error}; if let X1(Parachain { id }) = dest { <$test_network>::send_dmp_msg(id, msg) } else { - Err(Error::CannotReachDestination) + Err(Error::CannotReachDestination(dest, msg)) } } } + $crate::frame_support::parameter_types! { + pub UnitWeightCost: $crate::frame_support::weights::Weight = 1_000; + pub const WeightPrice: ($crate::xcm::v0::MultiLocation, u128) = ($crate::xcm::v0::MultiLocation::X1($crate::xcm::v0::Junction::Parent), 1_000); + } + pub struct XcmConfig; impl $crate::xcm_executor::Config for XcmConfig { type Call = Call; @@ -110,17 +115,21 @@ macro_rules! __construct_relay_chain_runtime { type IsReserve = (); type IsTeleporter = (); type LocationInverter = $crate::xcm_builder::LocationInverter; + type Barrier = (); + type Weigher = $crate::xcm_builder::FixedWeightBounds; + type Trader = $crate::xcm_builder::FixedRateOfConcreteFungible; + type ResponseHandler = (); } - impl $crate::runtime_parachains::origin::Config for Runtime {} - - pub type UmpSink = $crate::runtime_parachains::ump::XcmSink; + pub type UmpSink = $crate::runtime_parachains::ump::XcmSink<$crate::xcm_executor::XcmExecutor, Call>; type UncheckedExtrinsic = $crate::frame_system::mocking::MockUncheckedExtrinsic; type Block = $crate::frame_system::mocking::MockBlock; use $crate::runtime_parachains::origin as runtime_parachains_origin; + impl runtime_parachains_origin::Config for Runtime {} + $crate::frame_support::construct_runtime!( pub enum Runtime where Block = Block, @@ -166,4 +175,4 @@ where ::BlockNumber: From, { ExtBuilder::default().build::() -} +} \ No newline at end of file diff --git a/xcm-simulator/src/traits.rs b/xcm-simulator/src/traits.rs index fa401cc..541143c 100644 --- a/xcm-simulator/src/traits.rs +++ b/xcm-simulator/src/traits.rs @@ -1,4 +1,7 @@ -use xcm::{v0::{Result as XcmResult,opaque::Xcm}, opaque::VersionedXcm}; +use xcm::{ + opaque::VersionedXcm, + v0::{opaque::Xcm, Result as XcmResult}, +}; pub trait TestExt { fn new_ext() -> sp_io::TestExternalities;