XCM Revamp Continued (#2865)

* Introduce plurality XCM locations

* Add RelayedFrom

* DMP dispatch weight handling.

* Add pallet for XCM sending, add routing logic.

* Update error types & doc

* Fix warnings.

* Fixes

* Fixes

* Fixes

* Bump Substrate

* Fixes

* Docs

* Docs

* Docs

* Fixes

* Fixes

* Fixes

* Update xcm/pallet-xcm/src/lib.rs

Co-authored-by: Shawn Tabrizi <shawntabrizi@gmail.com>

* Docs

* Fixes

* Update lib.rs

* Fixes

Co-authored-by: Shawn Tabrizi <shawntabrizi@gmail.com>
This commit is contained in:
Gavin Wood
2021-04-09 20:34:28 +02:00
committed by GitHub
parent 8961628e7c
commit c9102c11a4
18 changed files with 632 additions and 227 deletions
+8
View File
@@ -36,6 +36,7 @@ pallet-authorship = { git = "https://github.com/paritytech/substrate", branch =
pallet-babe = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
pallet-beefy = { git = "https://github.com/paritytech/grandpa-bridge-gadget", branch = "master", default-features = false }
pallet-balances = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
pallet-collective = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
pallet-grandpa = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
pallet-im-online = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
pallet-indices = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
@@ -64,6 +65,7 @@ runtime-parachains = { package = "polkadot-runtime-parachains", path = "../parac
xcm = { package = "xcm", path = "../../xcm", default-features = false }
xcm-executor = { package = "xcm-executor", path = "../../xcm/xcm-executor", default-features = false }
xcm-builder = { package = "xcm-builder", path = "../../xcm/xcm-builder", default-features = false }
pallet-xcm = { path = "../../xcm/pallet-xcm", default-features = false }
[build-dependencies]
substrate-wasm-builder = "3.0.0"
@@ -81,6 +83,7 @@ std = [
"pallet-babe/std",
"beefy-primitives/std",
"pallet-balances/std",
"pallet-collective/std",
"pallet-beefy/std",
"pallet-grandpa/std",
"pallet-sudo/std",
@@ -118,6 +121,7 @@ std = [
"xcm/std",
"xcm-executor/std",
"xcm-builder/std",
"pallet-xcm/std",
"log/std",
]
# When enabled, the runtime api will not be build.
@@ -133,11 +137,14 @@ runtime-benchmarks = [
"sp-runtime/runtime-benchmarks",
"pallet-babe/runtime-benchmarks",
"pallet-balances/runtime-benchmarks",
"pallet-collective/runtime-benchmarks",
"pallet-grandpa/runtime-benchmarks",
"pallet-im-online/runtime-benchmarks",
"pallet-indices/runtime-benchmarks",
"pallet-staking/runtime-benchmarks",
"pallet-timestamp/runtime-benchmarks",
"pallet-xcm/runtime-benchmarks",
"xcm-builder/runtime-benchmarks",
]
try-runtime = [
"frame-executive/try-runtime",
@@ -147,6 +154,7 @@ try-runtime = [
"pallet-authorship/try-runtime",
"pallet-babe/try-runtime",
"pallet-balances/try-runtime",
"pallet-collective/try-runtime",
"pallet-grandpa/try-runtime",
"pallet-sudo/try-runtime",
"pallet-indices/try-runtime",
+32 -2
View File
@@ -86,6 +86,7 @@ pub use pallet_balances::Call as BalancesCall;
use polkadot_parachain::primitives::Id as ParaId;
use xcm::v0::{MultiLocation, NetworkId};
use xcm_executor::XcmExecutor;
use xcm_builder::{
AccountId32Aliases, ChildParachainConvertsVia, SovereignSignedViaLocation,
CurrencyAdapter as XcmCurrencyAdapter, ChildParachainAsNative,
@@ -274,6 +275,9 @@ construct_runtime! {
Utility: pallet_utility::{Pallet, Call, Event} = 90,
Proxy: pallet_proxy::{Pallet, Call, Storage, Event<T>} = 91,
// Pallet for sending XCM.
XcmPallet: pallet_xcm::{Pallet, Call, Storage, Event<T>} = 99,
}
}
@@ -619,10 +623,17 @@ parameter_types! {
pub const RocFee: (MultiLocation, u128) = (RocLocation::get(), 1 * CENTS);
}
/// The XCM router. When we want to send an XCM message, we use this type. It amalgamates all of our
/// individual routers.
pub type XcmRouter = (
// Only one router so far - use DMP to communicate with child parachains.
xcm_sender::ChildParachainRouter<Runtime>,
);
pub struct XcmConfig;
impl xcm_executor::Config for XcmConfig {
type Call = Call;
type XcmSender = xcm_sender::RelayChainXcmSender<Runtime>;
type XcmSender = XcmRouter;
type AssetTransactor = LocalAssetTransactor;
type OriginConverter = LocalOriginConverter;
type IsReserve = ();
@@ -634,10 +645,29 @@ impl xcm_executor::Config for XcmConfig {
type ResponseHandler = ();
}
/// Type to convert an `Origin` type value into a `MultiLocation` value which represents an interior location
/// of this chain.
pub type LocalOriginToLocation = (
);
impl pallet_xcm::Config for Runtime {
type Event = Event;
type SendXcmOrigin = xcm_builder::EnsureXcmOrigin<Origin, LocalOriginToLocation>;
type XcmRouter = XcmRouter;
// Right now nobody but root is allowed to dispatch local XCM messages.
type ExecuteXcmOrigin = xcm_builder::EnsureXcmOrigin<Origin, ()>;
type XcmExecutor = XcmExecutor<XcmConfig>;
}
impl parachains_session_info::Config for Runtime {}
parameter_types! {
pub const FirstMessageFactorPercent: u64 = 100;
}
impl parachains_ump::Config for Runtime {
type UmpSink = crate::parachains_ump::XcmSink<XcmConfig>;
type UmpSink = crate::parachains_ump::XcmSink<XcmExecutor<XcmConfig>, Call>;
type FirstMessageFactorPercent = FirstMessageFactorPercent;
}
impl parachains_dmp::Config for Runtime {}