Support XCM v1 (Companion to #2815) (#561)

* support for XCM v1

* Fixes

* Fix.

* Use `xcm::latest`

* Bump Polkadot

Co-authored-by: Bastian Köcher <info@kchr.de>
This commit is contained in:
Gavin Wood
2021-08-06 21:13:33 +02:00
committed by GitHub
parent 4f936689ef
commit 6283c1fce9
12 changed files with 313 additions and 306 deletions
Generated
+257 -257
View File
File diff suppressed because it is too large Load Diff
+3 -3
View File
@@ -26,7 +26,7 @@ use cumulus_primitives_core::relay_chain::BlockNumber as RelayBlockNumber;
use cumulus_primitives_core::DmpMessageHandler; use cumulus_primitives_core::DmpMessageHandler;
use codec::{Encode, Decode}; use codec::{Encode, Decode};
use sp_runtime::RuntimeDebug; use sp_runtime::RuntimeDebug;
use xcm::{VersionedXcm, v0::{Xcm, Junction, Outcome, ExecuteXcm, Error as XcmError}}; use xcm::{VersionedXcm, latest::{Xcm, Junction, Outcome, ExecuteXcm, Error as XcmError}};
use frame_support::{traits::EnsureOrigin, dispatch::Weight, weights::constants::WEIGHT_PER_MILLIS}; use frame_support::{traits::EnsureOrigin, dispatch::Weight, weights::constants::WEIGHT_PER_MILLIS};
pub use pallet::*; pub use pallet::*;
@@ -341,11 +341,11 @@ mod tests {
use sp_runtime::{testing::Header, traits::{IdentityLookup, BlakeTwo256}}; use sp_runtime::{testing::Header, traits::{IdentityLookup, BlakeTwo256}};
use sp_runtime::DispatchError::BadOrigin; use sp_runtime::DispatchError::BadOrigin;
use sp_version::RuntimeVersion; use sp_version::RuntimeVersion;
use xcm::v0::{MultiLocation, OriginKind}; use xcm::latest::{MultiLocation, OriginKind};
type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic<Test>; type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic<Test>;
type Block = frame_system::mocking::MockBlock<Test>; type Block = frame_system::mocking::MockBlock<Test>;
type Xcm = xcm::v0::Xcm<Call>; type Xcm = xcm::latest::Xcm<Call>;
frame_support::construct_runtime!( frame_support::construct_runtime!(
pub enum Test where pub enum Test where
+1 -1
View File
@@ -25,7 +25,7 @@ use cumulus_primitives_core::{ParaId, DmpMessageHandler};
use cumulus_primitives_core::relay_chain::BlockNumber as RelayBlockNumber; use cumulus_primitives_core::relay_chain::BlockNumber as RelayBlockNumber;
use codec::{Encode, Decode}; use codec::{Encode, Decode};
use sp_runtime::traits::BadOrigin; use sp_runtime::traits::BadOrigin;
use xcm::{VersionedXcm, v0::{Xcm, Junction, Outcome, ExecuteXcm}}; use xcm::{VersionedXcm, latest::{Xcm, Junction, Outcome, ExecuteXcm}};
use frame_support::dispatch::Weight; use frame_support::dispatch::Weight;
pub use pallet::*; pub use pallet::*;
+11 -10
View File
@@ -42,11 +42,8 @@ use rand_chacha::{
ChaChaRng, ChaChaRng,
}; };
use sp_runtime::{traits::Hash, RuntimeDebug}; use sp_runtime::{traits::Hash, RuntimeDebug};
use sp_std::{convert::TryFrom, prelude::*}; use sp_std::{prelude::*, convert::TryFrom};
use xcm::{ use xcm::{latest::prelude::*, WrapVersion, VersionedXcm};
v0::{Error as XcmError, ExecuteXcm, Junction, MultiLocation, Outcome, SendXcm, Xcm},
VersionedXcm,
};
pub use pallet::*; pub use pallet::*;
@@ -69,6 +66,9 @@ pub mod pallet {
/// Information on the avaialble XCMP channels. /// Information on the avaialble XCMP channels.
type ChannelInfo: GetChannelInfo; type ChannelInfo: GetChannelInfo;
/// Means of converting an `Xcm` into a `VersionedXcm`.
type VersionWrapper: WrapVersion;
} }
impl Default for QueueConfigData { impl Default for QueueConfigData {
@@ -351,7 +351,7 @@ impl<T: Config> Pallet<T> {
log::debug!("Processing XCMP-XCM: {:?}", &hash); log::debug!("Processing XCMP-XCM: {:?}", &hash);
let (result, event) = match Xcm::<T::Call>::try_from(xcm) { let (result, event) = match Xcm::<T::Call>::try_from(xcm) {
Ok(xcm) => { Ok(xcm) => {
let location = (Junction::Parent, Junction::Parachain(sender.into())); let location = (Parent, Parachain(sender.into()));
match T::XcmExecutor::execute_xcm(location.into(), xcm, max_weight) { match T::XcmExecutor::execute_xcm(location.into(), xcm, max_weight) {
Outcome::Error(e) => (Err(e.clone()), Event::Fail(Some(hash), e)), Outcome::Error(e) => (Err(e.clone()), Event::Fail(Some(hash), e)),
Outcome::Complete(w) => (Ok(w), Event::Success(Some(hash))), Outcome::Complete(w) => (Ok(w), Event::Success(Some(hash))),
@@ -777,13 +777,14 @@ impl<T: Config> SendXcm for Pallet<T> {
fn send_xcm(dest: MultiLocation, msg: Xcm<()>) -> Result<(), XcmError> { fn send_xcm(dest: MultiLocation, msg: Xcm<()>) -> Result<(), XcmError> {
match &dest { match &dest {
// An HRMP message for a sibling parachain. // An HRMP message for a sibling parachain.
MultiLocation::X2(Junction::Parent, Junction::Parachain(id)) => { X2(Parent, Parachain(id)) => {
let msg = VersionedXcm::<()>::from(msg); let versioned_xcm = T::VersionWrapper::wrap_version(&dest, msg)
let hash = T::Hashing::hash_of(&msg); .map_err(|()| XcmError::DestinationUnsupported)?;
let hash = T::Hashing::hash_of(&versioned_xcm);
Self::send_fragment( Self::send_fragment(
(*id).into(), (*id).into(),
XcmpMessageFormat::ConcatenatedVersionedXcm, XcmpMessageFormat::ConcatenatedVersionedXcm,
msg, versioned_xcm,
) )
.map_err(|e| XcmError::SendFailed(<&'static str>::from(e)))?; .map_err(|e| XcmError::SendFailed(<&'static str>::from(e)))?;
Self::deposit_event(Event::XcmpMessageSent(Some(hash))); Self::deposit_event(Event::XcmpMessageSent(Some(hash)));
+4 -8
View File
@@ -17,10 +17,7 @@ use super::*;
use crate as xcmp_queue; use crate as xcmp_queue;
use sp_core::H256; use sp_core::H256;
use frame_support::parameter_types; use frame_support::parameter_types;
use sp_runtime::{ use sp_runtime::{traits::{BlakeTwo256, IdentityLookup}, testing::Header};
traits::{BlakeTwo256, IdentityLookup},
testing::{Header},
};
use xcm_builder::{ use xcm_builder::{
FixedWeightBounds, IsConcrete, LocationInverter, NativeAsset, CurrencyAdapter, FixedWeightBounds, IsConcrete, LocationInverter, NativeAsset, CurrencyAdapter,
ParentIsDefault, ParentIsDefault,
@@ -107,10 +104,8 @@ impl cumulus_pallet_parachain_system::Config for Test {
} }
parameter_types! { parameter_types! {
pub const RelayChain: MultiLocation = MultiLocation::X1(Junction::Parent); pub const RelayChain: MultiLocation = X1(Parent);
pub Ancestry: MultiLocation = MultiLocation::X1( pub Ancestry: MultiLocation = X1(Parachain(1u32.into()));
Junction::Parachain(1u32.into())
);
pub UnitWeightCost: Weight = 1_000_000; pub UnitWeightCost: Weight = 1_000_000;
} }
@@ -157,6 +152,7 @@ impl Config for Test {
type Event = Event; type Event = Event;
type XcmExecutor = xcm_executor::XcmExecutor<XcmConfig>; type XcmExecutor = xcm_executor::XcmExecutor<XcmConfig>;
type ChannelInfo = ParachainSystem; type ChannelInfo = ParachainSystem;
type VersionWrapper = ();
} }
pub fn new_test_ext() -> sp_io::TestExternalities { pub fn new_test_ext() -> sp_io::TestExternalities {
+1 -1
View File
@@ -23,7 +23,7 @@ use sp_runtime::traits::Saturating;
use frame_system::Config as SystemConfig; use frame_system::Config as SystemConfig;
use cumulus_primitives_core::ParaId; use cumulus_primitives_core::ParaId;
use cumulus_pallet_xcm::{Origin as CumulusOrigin, ensure_sibling_para}; use cumulus_pallet_xcm::{Origin as CumulusOrigin, ensure_sibling_para};
use xcm::v0::{Xcm, Error as XcmError, SendXcm, OriginKind, MultiLocation, Junction}; use xcm::latest::{Xcm, Error as XcmError, SendXcm, OriginKind, MultiLocation, Junction};
pub use pallet::*; pub use pallet::*;
+4 -2
View File
@@ -56,7 +56,7 @@ pub use sp_runtime::{Perbill, Permill};
// XCM imports // XCM imports
use pallet_xcm::{EnsureXcm, IsMajorityOfBody, XcmPassthrough}; use pallet_xcm::{EnsureXcm, IsMajorityOfBody, XcmPassthrough};
use polkadot_parachain::primitives::Sibling; use polkadot_parachain::primitives::Sibling;
use xcm::v0::{BodyId, Junction::*, MultiAsset, MultiLocation, MultiLocation::*, NetworkId, Xcm}; use xcm::latest::prelude::*;
use xcm_builder::{ use xcm_builder::{
AccountId32Aliases, AllowTopLevelPaidExecutionFrom, AllowUnpaidExecutionFrom, CurrencyAdapter, AccountId32Aliases, AllowTopLevelPaidExecutionFrom, AllowUnpaidExecutionFrom, CurrencyAdapter,
EnsureXcmOrigin, FixedWeightBounds, IsConcrete, LocationInverter, NativeAsset, EnsureXcmOrigin, FixedWeightBounds, IsConcrete, LocationInverter, NativeAsset,
@@ -356,7 +356,7 @@ pub type LocalOriginToLocation = SignedToAccountId32<Origin, AccountId, RococoNe
/// queues. /// queues.
pub type XcmRouter = ( pub type XcmRouter = (
// Two routers - use UMP to communicate with the relay chain: // Two routers - use UMP to communicate with the relay chain:
cumulus_primitives_utility::ParentAsUmp<ParachainSystem>, cumulus_primitives_utility::ParentAsUmp<ParachainSystem, ()>,
// ..and XCMP to communicate with the sibling chains. // ..and XCMP to communicate with the sibling chains.
XcmpQueue, XcmpQueue,
); );
@@ -371,6 +371,7 @@ impl pallet_xcm::Config for Runtime {
type XcmTeleportFilter = All<(MultiLocation, Vec<MultiAsset>)>; type XcmTeleportFilter = All<(MultiLocation, Vec<MultiAsset>)>;
type XcmReserveTransferFilter = (); type XcmReserveTransferFilter = ();
type Weigher = FixedWeightBounds<UnitWeightCost, Call>; type Weigher = FixedWeightBounds<UnitWeightCost, Call>;
type LocationInverter = LocationInverter<Ancestry>;
} }
impl cumulus_pallet_xcm::Config for Runtime { impl cumulus_pallet_xcm::Config for Runtime {
@@ -382,6 +383,7 @@ impl cumulus_pallet_xcmp_queue::Config for Runtime {
type Event = Event; type Event = Event;
type XcmExecutor = XcmExecutor<XcmConfig>; type XcmExecutor = XcmExecutor<XcmConfig>;
type ChannelInfo = ParachainSystem; type ChannelInfo = ParachainSystem;
type VersionWrapper = ();
} }
impl cumulus_pallet_dmp_queue::Config for Runtime { impl cumulus_pallet_dmp_queue::Config for Runtime {
+1 -1
View File
@@ -51,7 +51,7 @@ pub use sp_runtime::BuildStorage;
pub use sp_runtime::{Perbill, Permill}; pub use sp_runtime::{Perbill, Permill};
// XCM imports // XCM imports
use xcm::v0::{Junction::*, MultiLocation, MultiLocation::*, NetworkId}; use xcm::latest::prelude::*;
use xcm_builder::{ use xcm_builder::{
AllowUnpaidExecutionFrom, FixedWeightBounds, LocationInverter, ParentAsSuperuser, AllowUnpaidExecutionFrom, FixedWeightBounds, LocationInverter, ParentAsSuperuser,
ParentIsDefault, SovereignSignedViaLocation, ParentIsDefault, SovereignSignedViaLocation,
+8 -6
View File
@@ -68,7 +68,7 @@ pub use sp_runtime::BuildStorage;
use pallet_xcm::{EnsureXcm, IsMajorityOfBody, XcmPassthrough}; use pallet_xcm::{EnsureXcm, IsMajorityOfBody, XcmPassthrough};
use polkadot_parachain::primitives::Sibling; use polkadot_parachain::primitives::Sibling;
use polkadot_runtime_common::{BlockHashCount, RocksDbWeight, SlowAdjustingFeeUpdate}; use polkadot_runtime_common::{BlockHashCount, RocksDbWeight, SlowAdjustingFeeUpdate};
use xcm::v0::{BodyId, Junction, MultiAsset, MultiLocation, NetworkId, Xcm}; use xcm::latest::prelude::*;
use xcm_builder::{ use xcm_builder::{
AccountId32Aliases, AllowTopLevelPaidExecutionFrom, AllowUnpaidExecutionFrom, CurrencyAdapter, AccountId32Aliases, AllowTopLevelPaidExecutionFrom, AllowUnpaidExecutionFrom, CurrencyAdapter,
EnsureXcmOrigin, FixedWeightBounds, IsConcrete, LocationInverter, NativeAsset, EnsureXcmOrigin, FixedWeightBounds, IsConcrete, LocationInverter, NativeAsset,
@@ -464,10 +464,10 @@ impl parachain_info::Config for Runtime {}
impl cumulus_pallet_aura_ext::Config for Runtime {} impl cumulus_pallet_aura_ext::Config for Runtime {}
parameter_types! { parameter_types! {
pub const KsmLocation: MultiLocation = MultiLocation::X1(Junction::Parent); pub const KsmLocation: MultiLocation = X1(Parent);
pub const RelayNetwork: NetworkId = NetworkId::Kusama; pub const RelayNetwork: NetworkId = NetworkId::Kusama;
pub RelayChainOrigin: Origin = cumulus_pallet_xcm::Origin::Relay.into(); pub RelayChainOrigin: Origin = cumulus_pallet_xcm::Origin::Relay.into();
pub Ancestry: MultiLocation = Junction::Parachain(ParachainInfo::parachain_id().into()).into(); pub Ancestry: MultiLocation = Parachain(ParachainInfo::parachain_id().into()).into();
} }
/// Type for specifying how a `MultiLocation` can be converted into an `AccountId`. This is used /// Type for specifying how a `MultiLocation` can be converted into an `AccountId`. This is used
@@ -527,8 +527,8 @@ parameter_types! {
match_type! { match_type! {
pub type ParentOrParentsExecutivePlurality: impl Contains<MultiLocation> = { pub type ParentOrParentsExecutivePlurality: impl Contains<MultiLocation> = {
MultiLocation::X1(Junction::Parent) | X1(Parent) |
MultiLocation::X2(Junction::Parent, Junction::Plurality { id: BodyId::Executive, .. }) X2(Parent, Plurality { id: BodyId::Executive, .. })
}; };
} }
@@ -566,7 +566,7 @@ pub type LocalOriginToLocation = SignedToAccountId32<Origin, AccountId, RelayNet
/// queues. /// queues.
pub type XcmRouter = ( pub type XcmRouter = (
// Two routers - use UMP to communicate with the relay chain: // Two routers - use UMP to communicate with the relay chain:
cumulus_primitives_utility::ParentAsUmp<ParachainSystem>, cumulus_primitives_utility::ParentAsUmp<ParachainSystem, ()>,
// ..and XCMP to communicate with the sibling chains. // ..and XCMP to communicate with the sibling chains.
XcmpQueue, XcmpQueue,
); );
@@ -581,6 +581,7 @@ impl pallet_xcm::Config for Runtime {
type XcmTeleportFilter = All<(MultiLocation, Vec<MultiAsset>)>; type XcmTeleportFilter = All<(MultiLocation, Vec<MultiAsset>)>;
type XcmReserveTransferFilter = All<(MultiLocation, Vec<MultiAsset>)>; type XcmReserveTransferFilter = All<(MultiLocation, Vec<MultiAsset>)>;
type Weigher = FixedWeightBounds<UnitWeightCost, Call>; type Weigher = FixedWeightBounds<UnitWeightCost, Call>;
type LocationInverter = LocationInverter<Ancestry>;
} }
impl cumulus_pallet_xcm::Config for Runtime { impl cumulus_pallet_xcm::Config for Runtime {
@@ -592,6 +593,7 @@ impl cumulus_pallet_xcmp_queue::Config for Runtime {
type Event = Event; type Event = Event;
type XcmExecutor = XcmExecutor<XcmConfig>; type XcmExecutor = XcmExecutor<XcmConfig>;
type ChannelInfo = ParachainSystem; type ChannelInfo = ParachainSystem;
type VersionWrapper = ();
} }
impl cumulus_pallet_dmp_queue::Config for Runtime { impl cumulus_pallet_dmp_queue::Config for Runtime {
+8 -6
View File
@@ -68,7 +68,7 @@ pub use sp_runtime::BuildStorage;
use pallet_xcm::{EnsureXcm, IsMajorityOfBody, XcmPassthrough}; use pallet_xcm::{EnsureXcm, IsMajorityOfBody, XcmPassthrough};
use polkadot_parachain::primitives::Sibling; use polkadot_parachain::primitives::Sibling;
use polkadot_runtime_common::{BlockHashCount, RocksDbWeight, SlowAdjustingFeeUpdate}; use polkadot_runtime_common::{BlockHashCount, RocksDbWeight, SlowAdjustingFeeUpdate};
use xcm::v0::{BodyId, Junction, MultiAsset, MultiLocation, NetworkId, Xcm}; use xcm::latest::prelude::*;
use xcm_builder::{ use xcm_builder::{
AccountId32Aliases, AllowTopLevelPaidExecutionFrom, AllowUnpaidExecutionFrom, CurrencyAdapter, AccountId32Aliases, AllowTopLevelPaidExecutionFrom, AllowUnpaidExecutionFrom, CurrencyAdapter,
EnsureXcmOrigin, FixedWeightBounds, IsConcrete, LocationInverter, NativeAsset, EnsureXcmOrigin, FixedWeightBounds, IsConcrete, LocationInverter, NativeAsset,
@@ -432,10 +432,10 @@ impl parachain_info::Config for Runtime {}
impl cumulus_pallet_aura_ext::Config for Runtime {} impl cumulus_pallet_aura_ext::Config for Runtime {}
parameter_types! { parameter_types! {
pub const DotLocation: MultiLocation = MultiLocation::X1(Junction::Parent); pub const DotLocation: MultiLocation = X1(Parent);
pub const RelayNetwork: NetworkId = NetworkId::Polkadot; pub const RelayNetwork: NetworkId = NetworkId::Polkadot;
pub RelayChainOrigin: Origin = cumulus_pallet_xcm::Origin::Relay.into(); pub RelayChainOrigin: Origin = cumulus_pallet_xcm::Origin::Relay.into();
pub Ancestry: MultiLocation = Junction::Parachain(ParachainInfo::parachain_id().into()).into(); pub Ancestry: MultiLocation = Parachain(ParachainInfo::parachain_id().into()).into();
} }
/// Type for specifying how a `MultiLocation` can be converted into an `AccountId`. This is used /// Type for specifying how a `MultiLocation` can be converted into an `AccountId`. This is used
@@ -495,8 +495,8 @@ parameter_types! {
match_type! { match_type! {
pub type ParentOrParentsExecutivePlurality: impl Contains<MultiLocation> = { pub type ParentOrParentsExecutivePlurality: impl Contains<MultiLocation> = {
MultiLocation::X1(Junction::Parent) | X1(Parent) |
MultiLocation::X2(Junction::Parent, Junction::Plurality { id: BodyId::Executive, .. }) X2(Parent, Plurality { id: BodyId::Executive, .. })
}; };
} }
@@ -534,7 +534,7 @@ pub type LocalOriginToLocation = SignedToAccountId32<Origin, AccountId, RelayNet
/// queues. /// queues.
pub type XcmRouter = ( pub type XcmRouter = (
// Two routers - use UMP to communicate with the relay chain: // Two routers - use UMP to communicate with the relay chain:
cumulus_primitives_utility::ParentAsUmp<ParachainSystem>, cumulus_primitives_utility::ParentAsUmp<ParachainSystem, ()>,
// ..and XCMP to communicate with the sibling chains. // ..and XCMP to communicate with the sibling chains.
XcmpQueue, XcmpQueue,
); );
@@ -549,6 +549,7 @@ impl pallet_xcm::Config for Runtime {
type XcmTeleportFilter = All<(MultiLocation, Vec<MultiAsset>)>; type XcmTeleportFilter = All<(MultiLocation, Vec<MultiAsset>)>;
type XcmReserveTransferFilter = All<(MultiLocation, Vec<MultiAsset>)>; type XcmReserveTransferFilter = All<(MultiLocation, Vec<MultiAsset>)>;
type Weigher = FixedWeightBounds<UnitWeightCost, Call>; type Weigher = FixedWeightBounds<UnitWeightCost, Call>;
type LocationInverter = LocationInverter<Ancestry>;
} }
impl cumulus_pallet_xcm::Config for Runtime { impl cumulus_pallet_xcm::Config for Runtime {
@@ -560,6 +561,7 @@ impl cumulus_pallet_xcmp_queue::Config for Runtime {
type Event = Event; type Event = Event;
type XcmExecutor = XcmExecutor<XcmConfig>; type XcmExecutor = XcmExecutor<XcmConfig>;
type ChannelInfo = ParachainSystem; type ChannelInfo = ParachainSystem;
type VersionWrapper = ();
} }
impl cumulus_pallet_dmp_queue::Config for Runtime { impl cumulus_pallet_dmp_queue::Config for Runtime {
+8 -6
View File
@@ -68,7 +68,7 @@ pub use sp_runtime::BuildStorage;
use pallet_xcm::XcmPassthrough; use pallet_xcm::XcmPassthrough;
use polkadot_parachain::primitives::Sibling; use polkadot_parachain::primitives::Sibling;
use polkadot_runtime_common::{BlockHashCount, RocksDbWeight, SlowAdjustingFeeUpdate}; use polkadot_runtime_common::{BlockHashCount, RocksDbWeight, SlowAdjustingFeeUpdate};
use xcm::v0::{Junction, MultiAsset, MultiLocation, NetworkId, Xcm}; use xcm::latest::prelude::*;
use xcm_builder::{ use xcm_builder::{
AccountId32Aliases, AllowTopLevelPaidExecutionFrom, AllowUnpaidExecutionFrom, CurrencyAdapter, AccountId32Aliases, AllowTopLevelPaidExecutionFrom, AllowUnpaidExecutionFrom, CurrencyAdapter,
EnsureXcmOrigin, FixedWeightBounds, IsConcrete, LocationInverter, NativeAsset, EnsureXcmOrigin, FixedWeightBounds, IsConcrete, LocationInverter, NativeAsset,
@@ -431,10 +431,10 @@ impl parachain_info::Config for Runtime {}
impl cumulus_pallet_aura_ext::Config for Runtime {} impl cumulus_pallet_aura_ext::Config for Runtime {}
parameter_types! { parameter_types! {
pub const WestendLocation: MultiLocation = MultiLocation::X1(Junction::Parent); pub const WestendLocation: MultiLocation = X1(Parent);
pub RelayNetwork: NetworkId = NetworkId::Named(b"Westend".to_vec()); pub RelayNetwork: NetworkId = NetworkId::Named(b"Westend".to_vec());
pub RelayChainOrigin: Origin = cumulus_pallet_xcm::Origin::Relay.into(); pub RelayChainOrigin: Origin = cumulus_pallet_xcm::Origin::Relay.into();
pub Ancestry: MultiLocation = Junction::Parachain(ParachainInfo::parachain_id().into()).into(); pub Ancestry: MultiLocation = Parachain(ParachainInfo::parachain_id().into()).into();
} }
/// Type for specifying how a `MultiLocation` can be converted into an `AccountId`. This is used /// Type for specifying how a `MultiLocation` can be converted into an `AccountId`. This is used
@@ -493,8 +493,8 @@ parameter_types! {
match_type! { match_type! {
pub type ParentOrParentsPlurality: impl Contains<MultiLocation> = { pub type ParentOrParentsPlurality: impl Contains<MultiLocation> = {
MultiLocation::X1(Junction::Parent) | X1(Parent) |
MultiLocation::X2(Junction::Parent, Junction::Plurality { .. }) X2(Parent, Plurality { .. })
}; };
} }
@@ -532,7 +532,7 @@ pub type LocalOriginToLocation = SignedToAccountId32<Origin, AccountId, RelayNet
/// queues. /// queues.
pub type XcmRouter = ( pub type XcmRouter = (
// Two routers - use UMP to communicate with the relay chain: // Two routers - use UMP to communicate with the relay chain:
cumulus_primitives_utility::ParentAsUmp<ParachainSystem>, cumulus_primitives_utility::ParentAsUmp<ParachainSystem, ()>,
// ..and XCMP to communicate with the sibling chains. // ..and XCMP to communicate with the sibling chains.
XcmpQueue, XcmpQueue,
); );
@@ -547,6 +547,7 @@ impl pallet_xcm::Config for Runtime {
type XcmTeleportFilter = All<(MultiLocation, Vec<MultiAsset>)>; type XcmTeleportFilter = All<(MultiLocation, Vec<MultiAsset>)>;
type XcmReserveTransferFilter = All<(MultiLocation, Vec<MultiAsset>)>; type XcmReserveTransferFilter = All<(MultiLocation, Vec<MultiAsset>)>;
type Weigher = FixedWeightBounds<UnitWeightCost, Call>; type Weigher = FixedWeightBounds<UnitWeightCost, Call>;
type LocationInverter = LocationInverter<Ancestry>;
} }
impl cumulus_pallet_xcm::Config for Runtime { impl cumulus_pallet_xcm::Config for Runtime {
@@ -558,6 +559,7 @@ impl cumulus_pallet_xcmp_queue::Config for Runtime {
type Event = Event; type Event = Event;
type XcmExecutor = XcmExecutor<XcmConfig>; type XcmExecutor = XcmExecutor<XcmConfig>;
type ChannelInfo = ParachainSystem; type ChannelInfo = ParachainSystem;
type VersionWrapper = ();
} }
impl cumulus_pallet_dmp_queue::Config for Runtime { impl cumulus_pallet_dmp_queue::Config for Runtime {
+7 -5
View File
@@ -22,7 +22,7 @@
use sp_std::marker::PhantomData; use sp_std::marker::PhantomData;
use codec::Encode; use codec::Encode;
use cumulus_primitives_core::UpwardMessageSender; use cumulus_primitives_core::UpwardMessageSender;
use xcm::{VersionedXcm, v0::{Xcm, MultiLocation, Junction, SendXcm, Error as XcmError}}; use xcm::{WrapVersion, latest::prelude::*};
/// Xcm router which recognises the `Parent` destination and handles it by sending the message into /// Xcm router which recognises the `Parent` destination and handles it by sending the message into
/// the given UMP `UpwardMessageSender` implementation. Thus this essentially adapts an /// the given UMP `UpwardMessageSender` implementation. Thus this essentially adapts an
@@ -31,13 +31,15 @@ use xcm::{VersionedXcm, v0::{Xcm, MultiLocation, Junction, SendXcm, Error as Xcm
/// NOTE: This is a pretty dumb "just send it" router; we will probably want to introduce queuing /// NOTE: This is a pretty dumb "just send it" router; we will probably want to introduce queuing
/// to UMP eventually and when we do, the pallet which implements the queuing will be responsible /// to UMP eventually and when we do, the pallet which implements the queuing will be responsible
/// for the `SendXcm` implementation. /// for the `SendXcm` implementation.
pub struct ParentAsUmp<T>(PhantomData<T>); pub struct ParentAsUmp<T, W>(PhantomData<(T, W)>);
impl<T: UpwardMessageSender> SendXcm for ParentAsUmp<T> { impl<T: UpwardMessageSender, W: WrapVersion> SendXcm for ParentAsUmp<T, W> {
fn send_xcm(dest: MultiLocation, msg: Xcm<()>) -> Result<(), XcmError> { fn send_xcm(dest: MultiLocation, msg: Xcm<()>) -> Result<(), XcmError> {
match &dest { match &dest {
// An upward message for the relay chain. // An upward message for the relay chain.
MultiLocation::X1(Junction::Parent) => { MultiLocation::X1(Parent) => {
let data = VersionedXcm::<()>::from(msg).encode(); let versioned_xcm = W::wrap_version(&dest, msg)
.map_err(|()| XcmError::DestinationUnsupported)?;
let data = versioned_xcm.encode();
T::send_upward_message(data) T::send_upward_message(data)
.map_err(|e| XcmError::SendFailed(e.into()))?; .map_err(|e| XcmError::SendFailed(e.into()))?;