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
+1 -1
View File
@@ -23,7 +23,7 @@ use sp_runtime::traits::Saturating;
use frame_system::Config as SystemConfig;
use cumulus_primitives_core::ParaId;
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::*;
+4 -2
View File
@@ -56,7 +56,7 @@ pub use sp_runtime::{Perbill, Permill};
// XCM imports
use pallet_xcm::{EnsureXcm, IsMajorityOfBody, XcmPassthrough};
use polkadot_parachain::primitives::Sibling;
use xcm::v0::{BodyId, Junction::*, MultiAsset, MultiLocation, MultiLocation::*, NetworkId, Xcm};
use xcm::latest::prelude::*;
use xcm_builder::{
AccountId32Aliases, AllowTopLevelPaidExecutionFrom, AllowUnpaidExecutionFrom, CurrencyAdapter,
EnsureXcmOrigin, FixedWeightBounds, IsConcrete, LocationInverter, NativeAsset,
@@ -356,7 +356,7 @@ pub type LocalOriginToLocation = SignedToAccountId32<Origin, AccountId, RococoNe
/// queues.
pub type XcmRouter = (
// 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.
XcmpQueue,
);
@@ -371,6 +371,7 @@ impl pallet_xcm::Config for Runtime {
type XcmTeleportFilter = All<(MultiLocation, Vec<MultiAsset>)>;
type XcmReserveTransferFilter = ();
type Weigher = FixedWeightBounds<UnitWeightCost, Call>;
type LocationInverter = LocationInverter<Ancestry>;
}
impl cumulus_pallet_xcm::Config for Runtime {
@@ -382,6 +383,7 @@ impl cumulus_pallet_xcmp_queue::Config for Runtime {
type Event = Event;
type XcmExecutor = XcmExecutor<XcmConfig>;
type ChannelInfo = ParachainSystem;
type VersionWrapper = ();
}
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};
// XCM imports
use xcm::v0::{Junction::*, MultiLocation, MultiLocation::*, NetworkId};
use xcm::latest::prelude::*;
use xcm_builder::{
AllowUnpaidExecutionFrom, FixedWeightBounds, LocationInverter, ParentAsSuperuser,
ParentIsDefault, SovereignSignedViaLocation,
+8 -6
View File
@@ -68,7 +68,7 @@ pub use sp_runtime::BuildStorage;
use pallet_xcm::{EnsureXcm, IsMajorityOfBody, XcmPassthrough};
use polkadot_parachain::primitives::Sibling;
use polkadot_runtime_common::{BlockHashCount, RocksDbWeight, SlowAdjustingFeeUpdate};
use xcm::v0::{BodyId, Junction, MultiAsset, MultiLocation, NetworkId, Xcm};
use xcm::latest::prelude::*;
use xcm_builder::{
AccountId32Aliases, AllowTopLevelPaidExecutionFrom, AllowUnpaidExecutionFrom, CurrencyAdapter,
EnsureXcmOrigin, FixedWeightBounds, IsConcrete, LocationInverter, NativeAsset,
@@ -464,10 +464,10 @@ impl parachain_info::Config for Runtime {}
impl cumulus_pallet_aura_ext::Config for Runtime {}
parameter_types! {
pub const KsmLocation: MultiLocation = MultiLocation::X1(Junction::Parent);
pub const KsmLocation: MultiLocation = X1(Parent);
pub const RelayNetwork: NetworkId = NetworkId::Kusama;
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
@@ -527,8 +527,8 @@ parameter_types! {
match_type! {
pub type ParentOrParentsExecutivePlurality: impl Contains<MultiLocation> = {
MultiLocation::X1(Junction::Parent) |
MultiLocation::X2(Junction::Parent, Junction::Plurality { id: BodyId::Executive, .. })
X1(Parent) |
X2(Parent, Plurality { id: BodyId::Executive, .. })
};
}
@@ -566,7 +566,7 @@ pub type LocalOriginToLocation = SignedToAccountId32<Origin, AccountId, RelayNet
/// queues.
pub type XcmRouter = (
// 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.
XcmpQueue,
);
@@ -581,6 +581,7 @@ impl pallet_xcm::Config for Runtime {
type XcmTeleportFilter = All<(MultiLocation, Vec<MultiAsset>)>;
type XcmReserveTransferFilter = All<(MultiLocation, Vec<MultiAsset>)>;
type Weigher = FixedWeightBounds<UnitWeightCost, Call>;
type LocationInverter = LocationInverter<Ancestry>;
}
impl cumulus_pallet_xcm::Config for Runtime {
@@ -592,6 +593,7 @@ impl cumulus_pallet_xcmp_queue::Config for Runtime {
type Event = Event;
type XcmExecutor = XcmExecutor<XcmConfig>;
type ChannelInfo = ParachainSystem;
type VersionWrapper = ();
}
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 polkadot_parachain::primitives::Sibling;
use polkadot_runtime_common::{BlockHashCount, RocksDbWeight, SlowAdjustingFeeUpdate};
use xcm::v0::{BodyId, Junction, MultiAsset, MultiLocation, NetworkId, Xcm};
use xcm::latest::prelude::*;
use xcm_builder::{
AccountId32Aliases, AllowTopLevelPaidExecutionFrom, AllowUnpaidExecutionFrom, CurrencyAdapter,
EnsureXcmOrigin, FixedWeightBounds, IsConcrete, LocationInverter, NativeAsset,
@@ -432,10 +432,10 @@ impl parachain_info::Config for Runtime {}
impl cumulus_pallet_aura_ext::Config for Runtime {}
parameter_types! {
pub const DotLocation: MultiLocation = MultiLocation::X1(Junction::Parent);
pub const DotLocation: MultiLocation = X1(Parent);
pub const RelayNetwork: 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 = Parachain(ParachainInfo::parachain_id().into()).into();
}
/// Type for specifying how a `MultiLocation` can be converted into an `AccountId`. This is used
@@ -495,8 +495,8 @@ parameter_types! {
match_type! {
pub type ParentOrParentsExecutivePlurality: impl Contains<MultiLocation> = {
MultiLocation::X1(Junction::Parent) |
MultiLocation::X2(Junction::Parent, Junction::Plurality { id: BodyId::Executive, .. })
X1(Parent) |
X2(Parent, Plurality { id: BodyId::Executive, .. })
};
}
@@ -534,7 +534,7 @@ pub type LocalOriginToLocation = SignedToAccountId32<Origin, AccountId, RelayNet
/// queues.
pub type XcmRouter = (
// 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.
XcmpQueue,
);
@@ -549,6 +549,7 @@ impl pallet_xcm::Config for Runtime {
type XcmTeleportFilter = All<(MultiLocation, Vec<MultiAsset>)>;
type XcmReserveTransferFilter = All<(MultiLocation, Vec<MultiAsset>)>;
type Weigher = FixedWeightBounds<UnitWeightCost, Call>;
type LocationInverter = LocationInverter<Ancestry>;
}
impl cumulus_pallet_xcm::Config for Runtime {
@@ -560,6 +561,7 @@ impl cumulus_pallet_xcmp_queue::Config for Runtime {
type Event = Event;
type XcmExecutor = XcmExecutor<XcmConfig>;
type ChannelInfo = ParachainSystem;
type VersionWrapper = ();
}
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 polkadot_parachain::primitives::Sibling;
use polkadot_runtime_common::{BlockHashCount, RocksDbWeight, SlowAdjustingFeeUpdate};
use xcm::v0::{Junction, MultiAsset, MultiLocation, NetworkId, Xcm};
use xcm::latest::prelude::*;
use xcm_builder::{
AccountId32Aliases, AllowTopLevelPaidExecutionFrom, AllowUnpaidExecutionFrom, CurrencyAdapter,
EnsureXcmOrigin, FixedWeightBounds, IsConcrete, LocationInverter, NativeAsset,
@@ -431,10 +431,10 @@ impl parachain_info::Config for Runtime {}
impl cumulus_pallet_aura_ext::Config for Runtime {}
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 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
@@ -493,8 +493,8 @@ parameter_types! {
match_type! {
pub type ParentOrParentsPlurality: impl Contains<MultiLocation> = {
MultiLocation::X1(Junction::Parent) |
MultiLocation::X2(Junction::Parent, Junction::Plurality { .. })
X1(Parent) |
X2(Parent, Plurality { .. })
};
}
@@ -532,7 +532,7 @@ pub type LocalOriginToLocation = SignedToAccountId32<Origin, AccountId, RelayNet
/// queues.
pub type XcmRouter = (
// 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.
XcmpQueue,
);
@@ -547,6 +547,7 @@ impl pallet_xcm::Config for Runtime {
type XcmTeleportFilter = All<(MultiLocation, Vec<MultiAsset>)>;
type XcmReserveTransferFilter = All<(MultiLocation, Vec<MultiAsset>)>;
type Weigher = FixedWeightBounds<UnitWeightCost, Call>;
type LocationInverter = LocationInverter<Ancestry>;
}
impl cumulus_pallet_xcm::Config for Runtime {
@@ -558,6 +559,7 @@ impl cumulus_pallet_xcmp_queue::Config for Runtime {
type Event = Event;
type XcmExecutor = XcmExecutor<XcmConfig>;
type ChannelInfo = ParachainSystem;
type VersionWrapper = ();
}
impl cumulus_pallet_dmp_queue::Config for Runtime {