mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-05-30 08:11:03 +00:00
Move XCM runtime configurations into their own files (#4644)
* Move XCM runtime configurations into their own files * Update copyright year * Fix compilation errors * Import XCM types in westend runtime unit tests
This commit is contained in:
@@ -33,9 +33,9 @@ use primitives::{
|
||||
v2::SessionInfo,
|
||||
};
|
||||
use runtime_common::{
|
||||
auctions, claims, crowdloan, impls::DealWithFees, paras_registrar, slots, xcm_sender,
|
||||
BlockHashCount, BlockLength, BlockWeights, CurrencyToVote, OffchainSolutionLengthLimit,
|
||||
OffchainSolutionWeightLimit, RocksDbWeight, SlowAdjustingFeeUpdate, ToAuthor,
|
||||
auctions, claims, crowdloan, impls::DealWithFees, paras_registrar, slots, BlockHashCount,
|
||||
BlockLength, BlockWeights, CurrencyToVote, OffchainSolutionLengthLimit,
|
||||
OffchainSolutionWeightLimit, RocksDbWeight, SlowAdjustingFeeUpdate,
|
||||
};
|
||||
use sp_core::u32_trait::{_1, _2, _3, _5};
|
||||
use sp_std::{cmp::Ordering, collections::btree_map::BTreeMap, prelude::*};
|
||||
@@ -52,10 +52,10 @@ use runtime_parachains::{
|
||||
use authority_discovery_primitives::AuthorityId as AuthorityDiscoveryId;
|
||||
use beefy_primitives::crypto::AuthorityId as BeefyId;
|
||||
use frame_support::{
|
||||
construct_runtime, match_type, parameter_types,
|
||||
construct_runtime, parameter_types,
|
||||
traits::{
|
||||
Contains, EnsureOneOf, Everything, InstanceFilter, KeyOwnerProofSystem, LockIdentifier,
|
||||
Nothing, OnRuntimeUpgrade, PrivilegeCmp,
|
||||
Contains, EnsureOneOf, InstanceFilter, KeyOwnerProofSystem, LockIdentifier,
|
||||
OnRuntimeUpgrade, PrivilegeCmp,
|
||||
},
|
||||
weights::Weight,
|
||||
PalletId, RuntimeDebug,
|
||||
@@ -82,16 +82,6 @@ use sp_staking::SessionIndex;
|
||||
use sp_version::NativeVersion;
|
||||
use sp_version::RuntimeVersion;
|
||||
use static_assertions::const_assert;
|
||||
use xcm::latest::prelude::*;
|
||||
use xcm_builder::{
|
||||
AccountId32Aliases, AllowKnownQueryResponses, AllowSubscriptionsFrom,
|
||||
AllowTopLevelPaidExecutionFrom, AllowUnpaidExecutionFrom, BackingToPlurality,
|
||||
ChildParachainAsNative, ChildParachainConvertsVia, ChildSystemParachainAsSuperuser,
|
||||
CurrencyAdapter as XcmCurrencyAdapter, FixedWeightBounds, IsChildSystemParachain, IsConcrete,
|
||||
LocationInverter, SignedAccountId32AsNative, SignedToAccountId32, SovereignSignedViaLocation,
|
||||
TakeWeightCredit, UsingComponents,
|
||||
};
|
||||
use xcm_executor::XcmExecutor;
|
||||
|
||||
pub use pallet_balances::Call as BalancesCall;
|
||||
pub use pallet_election_provider_multi_phase::Call as EPMCall;
|
||||
@@ -110,6 +100,9 @@ mod weights;
|
||||
// Voter bag threshold definitions.
|
||||
mod bag_thresholds;
|
||||
|
||||
// XCM configurations.
|
||||
mod xcm_config;
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests;
|
||||
|
||||
@@ -1210,7 +1203,8 @@ parameter_types! {
|
||||
|
||||
impl parachains_ump::Config for Runtime {
|
||||
type Event = Event;
|
||||
type UmpSink = crate::parachains_ump::XcmSink<XcmExecutor<XcmConfig>, Runtime>;
|
||||
type UmpSink =
|
||||
crate::parachains_ump::XcmSink<xcm_executor::XcmExecutor<xcm_config::XcmConfig>, Runtime>;
|
||||
type FirstMessageFactorPercent = FirstMessageFactorPercent;
|
||||
type ExecuteOverweightOrigin = EnsureRoot<AccountId>;
|
||||
}
|
||||
@@ -1316,156 +1310,6 @@ impl auctions::Config for Runtime {
|
||||
type WeightInfo = weights::runtime_common_auctions::WeightInfo<Runtime>;
|
||||
}
|
||||
|
||||
parameter_types! {
|
||||
/// The location of the KSM token, from the context of this chain. Since this token is native to this
|
||||
/// chain, we make it synonymous with it and thus it is the `Here` location, which means "equivalent to
|
||||
/// the context".
|
||||
pub const KsmLocation: MultiLocation = Here.into();
|
||||
/// The Kusama network ID. This is named.
|
||||
pub const KusamaNetwork: NetworkId = NetworkId::Kusama;
|
||||
/// Our XCM location ancestry - i.e. what, if anything, `Parent` means evaluated in our context. Since
|
||||
/// Kusama is a top-level relay-chain, there is no ancestry.
|
||||
pub const Ancestry: MultiLocation = Here.into();
|
||||
/// The check account, which holds any native assets that have been teleported out and not back in (yet).
|
||||
pub CheckAccount: AccountId = XcmPallet::check_account();
|
||||
}
|
||||
|
||||
/// The canonical means of converting a `MultiLocation` into an `AccountId`, used when we want to determine
|
||||
/// the sovereign account controlled by a location.
|
||||
pub type SovereignAccountOf = (
|
||||
// We can convert a child parachain using the standard `AccountId` conversion.
|
||||
ChildParachainConvertsVia<ParaId, AccountId>,
|
||||
// We can directly alias an `AccountId32` into a local account.
|
||||
AccountId32Aliases<KusamaNetwork, AccountId>,
|
||||
);
|
||||
|
||||
/// Our asset transactor. This is what allows us to interest with the runtime facilities from the point of
|
||||
/// view of XCM-only concepts like `MultiLocation` and `MultiAsset`.
|
||||
///
|
||||
/// Ours is only aware of the Balances pallet, which is mapped to `KsmLocation`.
|
||||
pub type LocalAssetTransactor = XcmCurrencyAdapter<
|
||||
// Use this currency:
|
||||
Balances,
|
||||
// Use this currency when it is a fungible asset matching the given location or name:
|
||||
IsConcrete<KsmLocation>,
|
||||
// We can convert the MultiLocations with our converter above:
|
||||
SovereignAccountOf,
|
||||
// Our chain's account ID type (we can't get away without mentioning it explicitly):
|
||||
AccountId,
|
||||
// We track our teleports in/out to keep total issuance correct.
|
||||
CheckAccount,
|
||||
>;
|
||||
|
||||
/// The means that we convert an the XCM message origin location into a local dispatch origin.
|
||||
type LocalOriginConverter = (
|
||||
// A `Signed` origin of the sovereign account that the original location controls.
|
||||
SovereignSignedViaLocation<SovereignAccountOf, Origin>,
|
||||
// A child parachain, natively expressed, has the `Parachain` origin.
|
||||
ChildParachainAsNative<parachains_origin::Origin, Origin>,
|
||||
// The AccountId32 location type can be expressed natively as a `Signed` origin.
|
||||
SignedAccountId32AsNative<KusamaNetwork, Origin>,
|
||||
// A system child parachain, expressed as a Superuser, converts to the `Root` origin.
|
||||
ChildSystemParachainAsSuperuser<ParaId, Origin>,
|
||||
);
|
||||
|
||||
parameter_types! {
|
||||
/// The amount of weight an XCM operation takes. This is a safe overestimate.
|
||||
pub const BaseXcmWeight: Weight = 1_000_000_000;
|
||||
/// Maximum number of instructions in a single XCM fragment. A sanity check against weight
|
||||
/// calculations getting too crazy.
|
||||
pub const MaxInstructions: u32 = 100;
|
||||
}
|
||||
|
||||
/// 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, XcmPallet>,
|
||||
);
|
||||
|
||||
parameter_types! {
|
||||
pub const Kusama: MultiAssetFilter = Wild(AllOf { fun: WildFungible, id: Concrete(KsmLocation::get()) });
|
||||
pub const KusamaForStatemine: (MultiAssetFilter, MultiLocation) = (Kusama::get(), Parachain(1000).into());
|
||||
pub const KusamaForEncointer: (MultiAssetFilter, MultiLocation) = (Kusama::get(), Parachain(1001).into());
|
||||
}
|
||||
pub type TrustedTeleporters =
|
||||
(xcm_builder::Case<KusamaForStatemine>, xcm_builder::Case<KusamaForEncointer>);
|
||||
|
||||
match_type! {
|
||||
pub type OnlyParachains: impl Contains<MultiLocation> = {
|
||||
MultiLocation { parents: 0, interior: X1(Parachain(_)) }
|
||||
};
|
||||
}
|
||||
|
||||
/// The barriers one of which must be passed for an XCM message to be executed.
|
||||
pub type Barrier = (
|
||||
// Weight that is paid for may be consumed.
|
||||
TakeWeightCredit,
|
||||
// If the message is one that immediately attemps to pay for execution, then allow it.
|
||||
AllowTopLevelPaidExecutionFrom<Everything>,
|
||||
// Messages coming from system parachains need not pay for execution.
|
||||
AllowUnpaidExecutionFrom<IsChildSystemParachain<ParaId>>,
|
||||
// Expected responses are OK.
|
||||
AllowKnownQueryResponses<XcmPallet>,
|
||||
// Subscriptions for version tracking are OK.
|
||||
AllowSubscriptionsFrom<OnlyParachains>,
|
||||
);
|
||||
|
||||
pub struct XcmConfig;
|
||||
impl xcm_executor::Config for XcmConfig {
|
||||
type Call = Call;
|
||||
type XcmSender = XcmRouter;
|
||||
type AssetTransactor = LocalAssetTransactor;
|
||||
type OriginConverter = LocalOriginConverter;
|
||||
type IsReserve = ();
|
||||
type IsTeleporter = TrustedTeleporters;
|
||||
type LocationInverter = LocationInverter<Ancestry>;
|
||||
type Barrier = Barrier;
|
||||
type Weigher = FixedWeightBounds<BaseXcmWeight, Call, MaxInstructions>;
|
||||
// The weight trader piggybacks on the existing transaction-fee conversion logic.
|
||||
type Trader = UsingComponents<WeightToFee, KsmLocation, AccountId, Balances, ToAuthor<Runtime>>;
|
||||
type ResponseHandler = XcmPallet;
|
||||
type AssetTrap = XcmPallet;
|
||||
type AssetClaims = XcmPallet;
|
||||
type SubscriptionService = XcmPallet;
|
||||
}
|
||||
|
||||
parameter_types! {
|
||||
pub const CouncilBodyId: BodyId = BodyId::Executive;
|
||||
}
|
||||
|
||||
/// Type to convert an `Origin` type value into a `MultiLocation` value which represents an interior location
|
||||
/// of this chain.
|
||||
pub type LocalOriginToLocation = (
|
||||
// We allow an origin from the Collective pallet to be used in XCM as a corresponding Plurality of the
|
||||
// `Unit` body.
|
||||
BackingToPlurality<
|
||||
Origin,
|
||||
pallet_collective::Origin<Runtime, CouncilCollective>,
|
||||
CouncilBodyId,
|
||||
>,
|
||||
// And a usual Signed origin to be used in XCM as a corresponding AccountId32
|
||||
SignedToAccountId32<Origin, AccountId, KusamaNetwork>,
|
||||
);
|
||||
impl pallet_xcm::Config for Runtime {
|
||||
type Event = Event;
|
||||
type SendXcmOrigin = xcm_builder::EnsureXcmOrigin<Origin, LocalOriginToLocation>;
|
||||
type XcmRouter = XcmRouter;
|
||||
// Anyone can execute XCM messages locally...
|
||||
type ExecuteXcmOrigin = xcm_builder::EnsureXcmOrigin<Origin, LocalOriginToLocation>;
|
||||
// ...but they must match our filter, which rejects all.
|
||||
type XcmExecuteFilter = Nothing;
|
||||
type XcmExecutor = XcmExecutor<XcmConfig>;
|
||||
type XcmTeleportFilter = Everything;
|
||||
type XcmReserveTransferFilter = Everything;
|
||||
type Weigher = FixedWeightBounds<BaseXcmWeight, Call, MaxInstructions>;
|
||||
type LocationInverter = LocationInverter<Ancestry>;
|
||||
type Origin = Origin;
|
||||
type Call = Call;
|
||||
const VERSION_DISCOVERY_QUEUE_SIZE: u32 = 100;
|
||||
type AdvertisedXcmVersion = pallet_xcm::CurrentXcmVersion;
|
||||
}
|
||||
|
||||
parameter_types! {
|
||||
pub IgnoredIssuance: Balance = Treasury::pot();
|
||||
pub const QueueCount: u32 = 300;
|
||||
|
||||
@@ -0,0 +1,187 @@
|
||||
// Copyright 2022 Parity Technologies (UK) Ltd.
|
||||
// This file is part of Polkadot.
|
||||
|
||||
// Polkadot is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
|
||||
// Polkadot is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Polkadot. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
//! XCM configurations for the Kusama runtime.
|
||||
|
||||
use super::{
|
||||
parachains_origin, AccountId, Balances, Call, CouncilCollective, Event, Origin, ParaId,
|
||||
Runtime, WeightToFee, XcmPallet,
|
||||
};
|
||||
use frame_support::{
|
||||
match_type, parameter_types,
|
||||
traits::{Everything, Nothing},
|
||||
weights::Weight,
|
||||
};
|
||||
use runtime_common::{xcm_sender, ToAuthor};
|
||||
use xcm::latest::prelude::*;
|
||||
use xcm_builder::{
|
||||
AccountId32Aliases, AllowKnownQueryResponses, AllowSubscriptionsFrom,
|
||||
AllowTopLevelPaidExecutionFrom, AllowUnpaidExecutionFrom, BackingToPlurality,
|
||||
ChildParachainAsNative, ChildParachainConvertsVia, ChildSystemParachainAsSuperuser,
|
||||
CurrencyAdapter as XcmCurrencyAdapter, FixedWeightBounds, IsChildSystemParachain, IsConcrete,
|
||||
LocationInverter, SignedAccountId32AsNative, SignedToAccountId32, SovereignSignedViaLocation,
|
||||
TakeWeightCredit, UsingComponents,
|
||||
};
|
||||
|
||||
parameter_types! {
|
||||
/// The location of the KSM token, from the context of this chain. Since this token is native to this
|
||||
/// chain, we make it synonymous with it and thus it is the `Here` location, which means "equivalent to
|
||||
/// the context".
|
||||
pub const KsmLocation: MultiLocation = Here.into();
|
||||
/// The Kusama network ID. This is named.
|
||||
pub const KusamaNetwork: NetworkId = NetworkId::Kusama;
|
||||
/// Our XCM location ancestry - i.e. what, if anything, `Parent` means evaluated in our context. Since
|
||||
/// Kusama is a top-level relay-chain, there is no ancestry.
|
||||
pub const Ancestry: MultiLocation = Here.into();
|
||||
/// The check account, which holds any native assets that have been teleported out and not back in (yet).
|
||||
pub CheckAccount: AccountId = XcmPallet::check_account();
|
||||
}
|
||||
|
||||
/// The canonical means of converting a `MultiLocation` into an `AccountId`, used when we want to determine
|
||||
/// the sovereign account controlled by a location.
|
||||
pub type SovereignAccountOf = (
|
||||
// We can convert a child parachain using the standard `AccountId` conversion.
|
||||
ChildParachainConvertsVia<ParaId, AccountId>,
|
||||
// We can directly alias an `AccountId32` into a local account.
|
||||
AccountId32Aliases<KusamaNetwork, AccountId>,
|
||||
);
|
||||
|
||||
/// Our asset transactor. This is what allows us to interest with the runtime facilities from the point of
|
||||
/// view of XCM-only concepts like `MultiLocation` and `MultiAsset`.
|
||||
///
|
||||
/// Ours is only aware of the Balances pallet, which is mapped to `KsmLocation`.
|
||||
pub type LocalAssetTransactor = XcmCurrencyAdapter<
|
||||
// Use this currency:
|
||||
Balances,
|
||||
// Use this currency when it is a fungible asset matching the given location or name:
|
||||
IsConcrete<KsmLocation>,
|
||||
// We can convert the MultiLocations with our converter above:
|
||||
SovereignAccountOf,
|
||||
// Our chain's account ID type (we can't get away without mentioning it explicitly):
|
||||
AccountId,
|
||||
// We track our teleports in/out to keep total issuance correct.
|
||||
CheckAccount,
|
||||
>;
|
||||
|
||||
/// The means that we convert an the XCM message origin location into a local dispatch origin.
|
||||
type LocalOriginConverter = (
|
||||
// A `Signed` origin of the sovereign account that the original location controls.
|
||||
SovereignSignedViaLocation<SovereignAccountOf, Origin>,
|
||||
// A child parachain, natively expressed, has the `Parachain` origin.
|
||||
ChildParachainAsNative<parachains_origin::Origin, Origin>,
|
||||
// The AccountId32 location type can be expressed natively as a `Signed` origin.
|
||||
SignedAccountId32AsNative<KusamaNetwork, Origin>,
|
||||
// A system child parachain, expressed as a Superuser, converts to the `Root` origin.
|
||||
ChildSystemParachainAsSuperuser<ParaId, Origin>,
|
||||
);
|
||||
|
||||
parameter_types! {
|
||||
/// The amount of weight an XCM operation takes. This is a safe overestimate.
|
||||
pub const BaseXcmWeight: Weight = 1_000_000_000;
|
||||
/// Maximum number of instructions in a single XCM fragment. A sanity check against weight
|
||||
/// calculations getting too crazy.
|
||||
pub const MaxInstructions: u32 = 100;
|
||||
}
|
||||
|
||||
/// 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, XcmPallet>,
|
||||
);
|
||||
|
||||
parameter_types! {
|
||||
pub const Kusama: MultiAssetFilter = Wild(AllOf { fun: WildFungible, id: Concrete(KsmLocation::get()) });
|
||||
pub const KusamaForStatemine: (MultiAssetFilter, MultiLocation) = (Kusama::get(), Parachain(1000).into());
|
||||
pub const KusamaForEncointer: (MultiAssetFilter, MultiLocation) = (Kusama::get(), Parachain(1001).into());
|
||||
}
|
||||
pub type TrustedTeleporters =
|
||||
(xcm_builder::Case<KusamaForStatemine>, xcm_builder::Case<KusamaForEncointer>);
|
||||
|
||||
match_type! {
|
||||
pub type OnlyParachains: impl Contains<MultiLocation> = {
|
||||
MultiLocation { parents: 0, interior: X1(Parachain(_)) }
|
||||
};
|
||||
}
|
||||
|
||||
/// The barriers one of which must be passed for an XCM message to be executed.
|
||||
pub type Barrier = (
|
||||
// Weight that is paid for may be consumed.
|
||||
TakeWeightCredit,
|
||||
// If the message is one that immediately attemps to pay for execution, then allow it.
|
||||
AllowTopLevelPaidExecutionFrom<Everything>,
|
||||
// Messages coming from system parachains need not pay for execution.
|
||||
AllowUnpaidExecutionFrom<IsChildSystemParachain<ParaId>>,
|
||||
// Expected responses are OK.
|
||||
AllowKnownQueryResponses<XcmPallet>,
|
||||
// Subscriptions for version tracking are OK.
|
||||
AllowSubscriptionsFrom<OnlyParachains>,
|
||||
);
|
||||
|
||||
pub struct XcmConfig;
|
||||
impl xcm_executor::Config for XcmConfig {
|
||||
type Call = Call;
|
||||
type XcmSender = XcmRouter;
|
||||
type AssetTransactor = LocalAssetTransactor;
|
||||
type OriginConverter = LocalOriginConverter;
|
||||
type IsReserve = ();
|
||||
type IsTeleporter = TrustedTeleporters;
|
||||
type LocationInverter = LocationInverter<Ancestry>;
|
||||
type Barrier = Barrier;
|
||||
type Weigher = FixedWeightBounds<BaseXcmWeight, Call, MaxInstructions>;
|
||||
// The weight trader piggybacks on the existing transaction-fee conversion logic.
|
||||
type Trader = UsingComponents<WeightToFee, KsmLocation, AccountId, Balances, ToAuthor<Runtime>>;
|
||||
type ResponseHandler = XcmPallet;
|
||||
type AssetTrap = XcmPallet;
|
||||
type AssetClaims = XcmPallet;
|
||||
type SubscriptionService = XcmPallet;
|
||||
}
|
||||
|
||||
parameter_types! {
|
||||
pub const CouncilBodyId: BodyId = BodyId::Executive;
|
||||
}
|
||||
|
||||
/// Type to convert an `Origin` type value into a `MultiLocation` value which represents an interior location
|
||||
/// of this chain.
|
||||
pub type LocalOriginToLocation = (
|
||||
// We allow an origin from the Collective pallet to be used in XCM as a corresponding Plurality of the
|
||||
// `Unit` body.
|
||||
BackingToPlurality<
|
||||
Origin,
|
||||
pallet_collective::Origin<Runtime, CouncilCollective>,
|
||||
CouncilBodyId,
|
||||
>,
|
||||
// And a usual Signed origin to be used in XCM as a corresponding AccountId32
|
||||
SignedToAccountId32<Origin, AccountId, KusamaNetwork>,
|
||||
);
|
||||
impl pallet_xcm::Config for Runtime {
|
||||
type Event = Event;
|
||||
type SendXcmOrigin = xcm_builder::EnsureXcmOrigin<Origin, LocalOriginToLocation>;
|
||||
type XcmRouter = XcmRouter;
|
||||
// Anyone can execute XCM messages locally...
|
||||
type ExecuteXcmOrigin = xcm_builder::EnsureXcmOrigin<Origin, LocalOriginToLocation>;
|
||||
// ...but they must match our filter, which rejects all.
|
||||
type XcmExecuteFilter = Nothing;
|
||||
type XcmExecutor = xcm_executor::XcmExecutor<XcmConfig>;
|
||||
type XcmTeleportFilter = Everything;
|
||||
type XcmReserveTransferFilter = Everything;
|
||||
type Weigher = FixedWeightBounds<BaseXcmWeight, Call, MaxInstructions>;
|
||||
type LocationInverter = LocationInverter<Ancestry>;
|
||||
type Origin = Origin;
|
||||
type Call = Call;
|
||||
const VERSION_DISCOVERY_QUEUE_SIZE: u32 = 100;
|
||||
type AdvertisedXcmVersion = pallet_xcm::CurrentXcmVersion;
|
||||
}
|
||||
@@ -22,9 +22,9 @@
|
||||
|
||||
use pallet_transaction_payment::CurrencyAdapter;
|
||||
use runtime_common::{
|
||||
auctions, claims, crowdloan, impls::DealWithFees, paras_registrar, slots, xcm_sender,
|
||||
BlockHashCount, BlockLength, BlockWeights, CurrencyToVote, OffchainSolutionLengthLimit,
|
||||
OffchainSolutionWeightLimit, RocksDbWeight, SlowAdjustingFeeUpdate, ToAuthor,
|
||||
auctions, claims, crowdloan, impls::DealWithFees, paras_registrar, slots, BlockHashCount,
|
||||
BlockLength, BlockWeights, CurrencyToVote, OffchainSolutionLengthLimit,
|
||||
OffchainSolutionWeightLimit, RocksDbWeight, SlowAdjustingFeeUpdate,
|
||||
};
|
||||
|
||||
use runtime_parachains::{
|
||||
@@ -39,10 +39,10 @@ use runtime_parachains::{
|
||||
use authority_discovery_primitives::AuthorityId as AuthorityDiscoveryId;
|
||||
use beefy_primitives::crypto::AuthorityId as BeefyId;
|
||||
use frame_support::{
|
||||
construct_runtime, match_type, parameter_types,
|
||||
construct_runtime, parameter_types,
|
||||
traits::{
|
||||
Contains, EnsureOneOf, Everything, InstanceFilter, KeyOwnerProofSystem, LockIdentifier,
|
||||
Nothing, OnRuntimeUpgrade, PrivilegeCmp,
|
||||
Contains, EnsureOneOf, InstanceFilter, KeyOwnerProofSystem, LockIdentifier,
|
||||
OnRuntimeUpgrade, PrivilegeCmp,
|
||||
},
|
||||
weights::Weight,
|
||||
PalletId, RuntimeDebug,
|
||||
@@ -85,15 +85,6 @@ use sp_std::{cmp::Ordering, collections::btree_map::BTreeMap, prelude::*};
|
||||
use sp_version::NativeVersion;
|
||||
use sp_version::RuntimeVersion;
|
||||
use static_assertions::const_assert;
|
||||
use xcm::latest::prelude::*;
|
||||
use xcm_builder::{
|
||||
AccountId32Aliases, AllowKnownQueryResponses, AllowSubscriptionsFrom,
|
||||
AllowTopLevelPaidExecutionFrom, BackingToPlurality, ChildParachainAsNative,
|
||||
ChildParachainConvertsVia, CurrencyAdapter as XcmCurrencyAdapter, FixedWeightBounds,
|
||||
IsConcrete, LocationInverter, SignedAccountId32AsNative, SignedToAccountId32,
|
||||
SovereignSignedViaLocation, TakeWeightCredit, UsingComponents,
|
||||
};
|
||||
use xcm_executor::XcmExecutor;
|
||||
|
||||
pub use pallet_balances::Call as BalancesCall;
|
||||
pub use pallet_election_provider_multi_phase::Call as EPMCall;
|
||||
@@ -111,6 +102,8 @@ mod weights;
|
||||
|
||||
mod bag_thresholds;
|
||||
|
||||
mod xcm_config;
|
||||
|
||||
// Make the WASM binary available.
|
||||
#[cfg(feature = "std")]
|
||||
include!(concat!(env!("OUT_DIR"), "/wasm_binary.rs"));
|
||||
@@ -1310,154 +1303,6 @@ impl auctions::Config for Runtime {
|
||||
type WeightInfo = weights::runtime_common_auctions::WeightInfo<Runtime>;
|
||||
}
|
||||
|
||||
parameter_types! {
|
||||
/// The location of the DOT token, from the context of this chain. Since this token is native to this
|
||||
/// chain, we make it synonymous with it and thus it is the `Here` location, which means "equivalent to
|
||||
/// the context".
|
||||
pub const DotLocation: MultiLocation = Here.into();
|
||||
/// The Polkadot network ID. This is named.
|
||||
pub const PolkadotNetwork: NetworkId = NetworkId::Polkadot;
|
||||
/// Our XCM location ancestry - i.e. what, if anything, `Parent` means evaluated in our context. Since
|
||||
/// Polkadot is a top-level relay-chain, there is no ancestry.
|
||||
pub const Ancestry: MultiLocation = Here.into();
|
||||
/// The check account, which holds any native assets that have been teleported out and not back in (yet).
|
||||
pub CheckAccount: AccountId = XcmPallet::check_account();
|
||||
}
|
||||
|
||||
/// The canonical means of converting a `MultiLocation` into an `AccountId`, used when we want to determine
|
||||
/// the sovereign account controlled by a location.
|
||||
pub type SovereignAccountOf = (
|
||||
// We can convert a child parachain using the standard `AccountId` conversion.
|
||||
ChildParachainConvertsVia<ParaId, AccountId>,
|
||||
// We can directly alias an `AccountId32` into a local account.
|
||||
AccountId32Aliases<PolkadotNetwork, AccountId>,
|
||||
);
|
||||
|
||||
/// Our asset transactor. This is what allows us to interest with the runtime facilities from the point of
|
||||
/// view of XCM-only concepts like `MultiLocation` and `MultiAsset`.
|
||||
///
|
||||
/// Ours is only aware of the Balances pallet, which is mapped to `DotLocation`.
|
||||
pub type LocalAssetTransactor = XcmCurrencyAdapter<
|
||||
// Use this currency:
|
||||
Balances,
|
||||
// Use this currency when it is a fungible asset matching the given location or name:
|
||||
IsConcrete<DotLocation>,
|
||||
// We can convert the MultiLocations with our converter above:
|
||||
SovereignAccountOf,
|
||||
// Our chain's account ID type (we can't get away without mentioning it explicitly):
|
||||
AccountId,
|
||||
// We track our teleports in/out to keep total issuance correct.
|
||||
CheckAccount,
|
||||
>;
|
||||
|
||||
/// The means that we convert an the XCM message origin location into a local dispatch origin.
|
||||
type LocalOriginConverter = (
|
||||
// A `Signed` origin of the sovereign account that the original location controls.
|
||||
SovereignSignedViaLocation<SovereignAccountOf, Origin>,
|
||||
// A child parachain, natively expressed, has the `Parachain` origin.
|
||||
ChildParachainAsNative<parachains_origin::Origin, Origin>,
|
||||
// The AccountId32 location type can be expressed natively as a `Signed` origin.
|
||||
SignedAccountId32AsNative<PolkadotNetwork, Origin>,
|
||||
);
|
||||
|
||||
parameter_types! {
|
||||
/// The amount of weight an XCM operation takes. This is a safe overestimate.
|
||||
pub const BaseXcmWeight: Weight = 1_000_000_000;
|
||||
/// Maximum number of instructions in a single XCM fragment. A sanity check against weight
|
||||
/// calculations getting too crazy.
|
||||
pub const MaxInstructions: u32 = 100;
|
||||
}
|
||||
|
||||
/// 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, XcmPallet>,
|
||||
);
|
||||
|
||||
parameter_types! {
|
||||
pub const Polkadot: MultiAssetFilter = Wild(AllOf { fun: WildFungible, id: Concrete(DotLocation::get()) });
|
||||
pub const PolkadotForStatemint: (MultiAssetFilter, MultiLocation) = (Polkadot::get(), Parachain(1000).into());
|
||||
}
|
||||
|
||||
pub type TrustedTeleporters = (xcm_builder::Case<PolkadotForStatemint>,);
|
||||
|
||||
match_type! {
|
||||
pub type OnlyParachains: impl Contains<MultiLocation> = {
|
||||
MultiLocation { parents: 0, interior: X1(Parachain(_)) }
|
||||
};
|
||||
}
|
||||
|
||||
/// The barriers one of which must be passed for an XCM message to be executed.
|
||||
pub type Barrier = (
|
||||
// Weight that is paid for may be consumed.
|
||||
TakeWeightCredit,
|
||||
// If the message is one that immediately attemps to pay for execution, then allow it.
|
||||
AllowTopLevelPaidExecutionFrom<Everything>,
|
||||
// Expected responses are OK.
|
||||
AllowKnownQueryResponses<XcmPallet>,
|
||||
// Subscriptions for version tracking are OK.
|
||||
AllowSubscriptionsFrom<OnlyParachains>,
|
||||
);
|
||||
|
||||
pub struct XcmConfig;
|
||||
impl xcm_executor::Config for XcmConfig {
|
||||
type Call = Call;
|
||||
type XcmSender = XcmRouter;
|
||||
type AssetTransactor = LocalAssetTransactor;
|
||||
type OriginConverter = LocalOriginConverter;
|
||||
type IsReserve = ();
|
||||
type IsTeleporter = TrustedTeleporters;
|
||||
type LocationInverter = LocationInverter<Ancestry>;
|
||||
type Barrier = Barrier;
|
||||
type Weigher = FixedWeightBounds<BaseXcmWeight, Call, MaxInstructions>;
|
||||
// The weight trader piggybacks on the existing transaction-fee conversion logic.
|
||||
type Trader = UsingComponents<WeightToFee, DotLocation, AccountId, Balances, ToAuthor<Runtime>>;
|
||||
type ResponseHandler = XcmPallet;
|
||||
type AssetTrap = XcmPallet;
|
||||
type AssetClaims = XcmPallet;
|
||||
type SubscriptionService = XcmPallet;
|
||||
}
|
||||
|
||||
parameter_types! {
|
||||
pub const CouncilBodyId: BodyId = BodyId::Executive;
|
||||
// We are conservative with the XCM version we advertize.
|
||||
pub const AdvertisedXcmVersion: u32 = 2;
|
||||
}
|
||||
|
||||
/// Type to convert an `Origin` type value into a `MultiLocation` value which represents an interior location
|
||||
/// of this chain.
|
||||
pub type LocalOriginToLocation = (
|
||||
// We allow an origin from the Collective pallet to be used in XCM as a corresponding Plurality of the
|
||||
// `Unit` body.
|
||||
BackingToPlurality<
|
||||
Origin,
|
||||
pallet_collective::Origin<Runtime, CouncilCollective>,
|
||||
CouncilBodyId,
|
||||
>,
|
||||
// And a usual Signed origin to be used in XCM as a corresponding AccountId32
|
||||
SignedToAccountId32<Origin, AccountId, PolkadotNetwork>,
|
||||
);
|
||||
|
||||
impl pallet_xcm::Config for Runtime {
|
||||
type Event = Event;
|
||||
type SendXcmOrigin = xcm_builder::EnsureXcmOrigin<Origin, LocalOriginToLocation>;
|
||||
type XcmRouter = XcmRouter;
|
||||
// Anyone can execute XCM messages locally...
|
||||
type ExecuteXcmOrigin = xcm_builder::EnsureXcmOrigin<Origin, LocalOriginToLocation>;
|
||||
// ...but they must match our filter, which rejects all.
|
||||
type XcmExecuteFilter = Nothing;
|
||||
type XcmExecutor = XcmExecutor<XcmConfig>;
|
||||
type XcmTeleportFilter = Nothing;
|
||||
type XcmReserveTransferFilter = Nothing;
|
||||
type Weigher = FixedWeightBounds<BaseXcmWeight, Call, MaxInstructions>;
|
||||
type LocationInverter = LocationInverter<Ancestry>;
|
||||
type Origin = Origin;
|
||||
type Call = Call;
|
||||
const VERSION_DISCOVERY_QUEUE_SIZE: u32 = 100;
|
||||
type AdvertisedXcmVersion = AdvertisedXcmVersion;
|
||||
}
|
||||
|
||||
construct_runtime! {
|
||||
pub enum Runtime where
|
||||
Block = Block,
|
||||
|
||||
@@ -0,0 +1,184 @@
|
||||
// Copyright 2022 Parity Technologies (UK) Ltd.
|
||||
// This file is part of Polkadot.
|
||||
|
||||
// Polkadot is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
|
||||
// Polkadot is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Polkadot. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
//! XCM configuration for Polkadot.
|
||||
|
||||
use super::{
|
||||
parachains_origin, AccountId, Balances, Call, CouncilCollective, Event, Origin, ParaId,
|
||||
Runtime, WeightToFee, XcmPallet,
|
||||
};
|
||||
use frame_support::{
|
||||
match_type, parameter_types,
|
||||
traits::{Everything, Nothing},
|
||||
weights::Weight,
|
||||
};
|
||||
use runtime_common::{xcm_sender, ToAuthor};
|
||||
use xcm::latest::prelude::*;
|
||||
use xcm_builder::{
|
||||
AccountId32Aliases, AllowKnownQueryResponses, AllowSubscriptionsFrom,
|
||||
AllowTopLevelPaidExecutionFrom, BackingToPlurality, ChildParachainAsNative,
|
||||
ChildParachainConvertsVia, CurrencyAdapter as XcmCurrencyAdapter, FixedWeightBounds,
|
||||
IsConcrete, LocationInverter, SignedAccountId32AsNative, SignedToAccountId32,
|
||||
SovereignSignedViaLocation, TakeWeightCredit, UsingComponents,
|
||||
};
|
||||
|
||||
parameter_types! {
|
||||
/// The location of the DOT token, from the context of this chain. Since this token is native to this
|
||||
/// chain, we make it synonymous with it and thus it is the `Here` location, which means "equivalent to
|
||||
/// the context".
|
||||
pub const DotLocation: MultiLocation = Here.into();
|
||||
/// The Polkadot network ID. This is named.
|
||||
pub const PolkadotNetwork: NetworkId = NetworkId::Polkadot;
|
||||
/// Our XCM location ancestry - i.e. what, if anything, `Parent` means evaluated in our context. Since
|
||||
/// Polkadot is a top-level relay-chain, there is no ancestry.
|
||||
pub const Ancestry: MultiLocation = Here.into();
|
||||
/// The check account, which holds any native assets that have been teleported out and not back in (yet).
|
||||
pub CheckAccount: AccountId = XcmPallet::check_account();
|
||||
}
|
||||
|
||||
/// The canonical means of converting a `MultiLocation` into an `AccountId`, used when we want to determine
|
||||
/// the sovereign account controlled by a location.
|
||||
pub type SovereignAccountOf = (
|
||||
// We can convert a child parachain using the standard `AccountId` conversion.
|
||||
ChildParachainConvertsVia<ParaId, AccountId>,
|
||||
// We can directly alias an `AccountId32` into a local account.
|
||||
AccountId32Aliases<PolkadotNetwork, AccountId>,
|
||||
);
|
||||
|
||||
/// Our asset transactor. This is what allows us to interest with the runtime facilities from the point of
|
||||
/// view of XCM-only concepts like `MultiLocation` and `MultiAsset`.
|
||||
///
|
||||
/// Ours is only aware of the Balances pallet, which is mapped to `DotLocation`.
|
||||
pub type LocalAssetTransactor = XcmCurrencyAdapter<
|
||||
// Use this currency:
|
||||
Balances,
|
||||
// Use this currency when it is a fungible asset matching the given location or name:
|
||||
IsConcrete<DotLocation>,
|
||||
// We can convert the MultiLocations with our converter above:
|
||||
SovereignAccountOf,
|
||||
// Our chain's account ID type (we can't get away without mentioning it explicitly):
|
||||
AccountId,
|
||||
// We track our teleports in/out to keep total issuance correct.
|
||||
CheckAccount,
|
||||
>;
|
||||
|
||||
/// The means that we convert an the XCM message origin location into a local dispatch origin.
|
||||
type LocalOriginConverter = (
|
||||
// A `Signed` origin of the sovereign account that the original location controls.
|
||||
SovereignSignedViaLocation<SovereignAccountOf, Origin>,
|
||||
// A child parachain, natively expressed, has the `Parachain` origin.
|
||||
ChildParachainAsNative<parachains_origin::Origin, Origin>,
|
||||
// The AccountId32 location type can be expressed natively as a `Signed` origin.
|
||||
SignedAccountId32AsNative<PolkadotNetwork, Origin>,
|
||||
);
|
||||
|
||||
parameter_types! {
|
||||
/// The amount of weight an XCM operation takes. This is a safe overestimate.
|
||||
pub const BaseXcmWeight: Weight = 1_000_000_000;
|
||||
/// Maximum number of instructions in a single XCM fragment. A sanity check against weight
|
||||
/// calculations getting too crazy.
|
||||
pub const MaxInstructions: u32 = 100;
|
||||
}
|
||||
|
||||
/// 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, XcmPallet>,
|
||||
);
|
||||
|
||||
parameter_types! {
|
||||
pub const Polkadot: MultiAssetFilter = Wild(AllOf { fun: WildFungible, id: Concrete(DotLocation::get()) });
|
||||
pub const PolkadotForStatemint: (MultiAssetFilter, MultiLocation) = (Polkadot::get(), Parachain(1000).into());
|
||||
}
|
||||
|
||||
pub type TrustedTeleporters = (xcm_builder::Case<PolkadotForStatemint>,);
|
||||
|
||||
match_type! {
|
||||
pub type OnlyParachains: impl Contains<MultiLocation> = {
|
||||
MultiLocation { parents: 0, interior: X1(Parachain(_)) }
|
||||
};
|
||||
}
|
||||
|
||||
/// The barriers one of which must be passed for an XCM message to be executed.
|
||||
pub type Barrier = (
|
||||
// Weight that is paid for may be consumed.
|
||||
TakeWeightCredit,
|
||||
// If the message is one that immediately attemps to pay for execution, then allow it.
|
||||
AllowTopLevelPaidExecutionFrom<Everything>,
|
||||
// Expected responses are OK.
|
||||
AllowKnownQueryResponses<XcmPallet>,
|
||||
// Subscriptions for version tracking are OK.
|
||||
AllowSubscriptionsFrom<OnlyParachains>,
|
||||
);
|
||||
|
||||
pub struct XcmConfig;
|
||||
impl xcm_executor::Config for XcmConfig {
|
||||
type Call = Call;
|
||||
type XcmSender = XcmRouter;
|
||||
type AssetTransactor = LocalAssetTransactor;
|
||||
type OriginConverter = LocalOriginConverter;
|
||||
type IsReserve = ();
|
||||
type IsTeleporter = TrustedTeleporters;
|
||||
type LocationInverter = LocationInverter<Ancestry>;
|
||||
type Barrier = Barrier;
|
||||
type Weigher = FixedWeightBounds<BaseXcmWeight, Call, MaxInstructions>;
|
||||
// The weight trader piggybacks on the existing transaction-fee conversion logic.
|
||||
type Trader = UsingComponents<WeightToFee, DotLocation, AccountId, Balances, ToAuthor<Runtime>>;
|
||||
type ResponseHandler = XcmPallet;
|
||||
type AssetTrap = XcmPallet;
|
||||
type AssetClaims = XcmPallet;
|
||||
type SubscriptionService = XcmPallet;
|
||||
}
|
||||
|
||||
parameter_types! {
|
||||
pub const CouncilBodyId: BodyId = BodyId::Executive;
|
||||
// We are conservative with the XCM version we advertize.
|
||||
pub const AdvertisedXcmVersion: u32 = 2;
|
||||
}
|
||||
|
||||
/// Type to convert an `Origin` type value into a `MultiLocation` value which represents an interior location
|
||||
/// of this chain.
|
||||
pub type LocalOriginToLocation = (
|
||||
// We allow an origin from the Collective pallet to be used in XCM as a corresponding Plurality of the
|
||||
// `Unit` body.
|
||||
BackingToPlurality<
|
||||
Origin,
|
||||
pallet_collective::Origin<Runtime, CouncilCollective>,
|
||||
CouncilBodyId,
|
||||
>,
|
||||
// And a usual Signed origin to be used in XCM as a corresponding AccountId32
|
||||
SignedToAccountId32<Origin, AccountId, PolkadotNetwork>,
|
||||
);
|
||||
|
||||
impl pallet_xcm::Config for Runtime {
|
||||
type Event = Event;
|
||||
type SendXcmOrigin = xcm_builder::EnsureXcmOrigin<Origin, LocalOriginToLocation>;
|
||||
type XcmRouter = XcmRouter;
|
||||
// Anyone can execute XCM messages locally...
|
||||
type ExecuteXcmOrigin = xcm_builder::EnsureXcmOrigin<Origin, LocalOriginToLocation>;
|
||||
// ...but they must match our filter, which rejects all.
|
||||
type XcmExecuteFilter = Nothing;
|
||||
type XcmExecutor = xcm_executor::XcmExecutor<XcmConfig>;
|
||||
type XcmTeleportFilter = Nothing;
|
||||
type XcmReserveTransferFilter = Nothing;
|
||||
type Weigher = FixedWeightBounds<BaseXcmWeight, Call, MaxInstructions>;
|
||||
type LocationInverter = LocationInverter<Ancestry>;
|
||||
type Origin = Origin;
|
||||
type Call = Call;
|
||||
const VERSION_DISCOVERY_QUEUE_SIZE: u32 = 100;
|
||||
type AdvertisedXcmVersion = AdvertisedXcmVersion;
|
||||
}
|
||||
@@ -24,8 +24,7 @@ use authority_discovery_primitives::AuthorityId as AuthorityDiscoveryId;
|
||||
use beefy_primitives::{crypto::AuthorityId as BeefyId, mmr::MmrLeafVersion};
|
||||
use frame_support::{
|
||||
construct_runtime, parameter_types,
|
||||
traits::{Contains, Everything, IsInVec, KeyOwnerProofSystem, Nothing, Randomness},
|
||||
weights::Weight,
|
||||
traits::{Contains, KeyOwnerProofSystem, Randomness},
|
||||
PalletId,
|
||||
};
|
||||
use frame_system::EnsureRoot;
|
||||
@@ -46,8 +45,7 @@ use primitives::{
|
||||
};
|
||||
use runtime_common::{
|
||||
assigned_slots, auctions, crowdloan, impls::ToAuthor, paras_registrar, paras_sudo_wrapper,
|
||||
slots, xcm_sender, BlockHashCount, BlockLength, BlockWeights, RocksDbWeight,
|
||||
SlowAdjustingFeeUpdate,
|
||||
slots, BlockHashCount, BlockLength, BlockWeights, RocksDbWeight, SlowAdjustingFeeUpdate,
|
||||
};
|
||||
use runtime_parachains::{self, runtime_api_impl::v1 as runtime_api_impl};
|
||||
use scale_info::TypeInfo;
|
||||
@@ -87,18 +85,11 @@ use polkadot_parachain::primitives::Id as ParaId;
|
||||
use rococo_runtime_constants::{currency::*, fee::*, time::*};
|
||||
|
||||
use frame_support::traits::{InstanceFilter, OnRuntimeUpgrade};
|
||||
use xcm::latest::prelude::*;
|
||||
use xcm_builder::{
|
||||
AccountId32Aliases, AllowKnownQueryResponses, AllowSubscriptionsFrom, BackingToPlurality,
|
||||
ChildParachainAsNative, ChildParachainConvertsVia, ChildSystemParachainAsSuperuser,
|
||||
CurrencyAdapter as XcmCurrencyAdapter, FixedWeightBounds, IsConcrete, LocationInverter,
|
||||
SignedAccountId32AsNative, SignedToAccountId32, SovereignSignedViaLocation, UsingComponents,
|
||||
};
|
||||
use xcm_executor::XcmExecutor;
|
||||
|
||||
mod bridge_messages;
|
||||
mod validator_manager;
|
||||
mod weights;
|
||||
mod xcm_config;
|
||||
|
||||
// Make the WASM binary available.
|
||||
#[cfg(feature = "std")]
|
||||
@@ -634,140 +625,6 @@ impl parachains_paras::Config for Runtime {
|
||||
type NextSessionRotation = Babe;
|
||||
}
|
||||
|
||||
parameter_types! {
|
||||
pub const RocLocation: MultiLocation = Here.into();
|
||||
pub const RococoNetwork: NetworkId = NetworkId::Polkadot;
|
||||
pub const Ancestry: MultiLocation = Here.into();
|
||||
pub CheckAccount: AccountId = XcmPallet::check_account();
|
||||
}
|
||||
|
||||
pub type SovereignAccountOf =
|
||||
(ChildParachainConvertsVia<ParaId, AccountId>, AccountId32Aliases<RococoNetwork, AccountId>);
|
||||
|
||||
pub type LocalAssetTransactor = XcmCurrencyAdapter<
|
||||
// Use this currency:
|
||||
Balances,
|
||||
// Use this currency when it is a fungible asset matching the given location or name:
|
||||
IsConcrete<RocLocation>,
|
||||
// We can convert the MultiLocations with our converter above:
|
||||
SovereignAccountOf,
|
||||
// Our chain's account ID type (we can't get away without mentioning it explicitly):
|
||||
AccountId,
|
||||
// It's a native asset so we keep track of the teleports to maintain total issuance.
|
||||
CheckAccount,
|
||||
>;
|
||||
|
||||
type LocalOriginConverter = (
|
||||
SovereignSignedViaLocation<SovereignAccountOf, Origin>,
|
||||
ChildParachainAsNative<parachains_origin::Origin, Origin>,
|
||||
SignedAccountId32AsNative<RococoNetwork, Origin>,
|
||||
ChildSystemParachainAsSuperuser<ParaId, Origin>,
|
||||
);
|
||||
|
||||
parameter_types! {
|
||||
pub const BaseXcmWeight: Weight = 1_000_000_000;
|
||||
}
|
||||
|
||||
/// 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, XcmPallet>,
|
||||
);
|
||||
|
||||
parameter_types! {
|
||||
pub const Rococo: MultiAssetFilter = Wild(AllOf { fun: WildFungible, id: Concrete(RocLocation::get()) });
|
||||
pub const RococoForTick: (MultiAssetFilter, MultiLocation) = (Rococo::get(), Parachain(100).into());
|
||||
pub const RococoForTrick: (MultiAssetFilter, MultiLocation) = (Rococo::get(), Parachain(110).into());
|
||||
pub const RococoForTrack: (MultiAssetFilter, MultiLocation) = (Rococo::get(), Parachain(120).into());
|
||||
pub const RococoForStatemine: (MultiAssetFilter, MultiLocation) = (Rococo::get(), Parachain(1000).into());
|
||||
pub const RococoForCanvas: (MultiAssetFilter, MultiLocation) = (Rococo::get(), Parachain(1002).into());
|
||||
pub const RococoForEncointer: (MultiAssetFilter, MultiLocation) = (Rococo::get(), Parachain(1003).into());
|
||||
pub const MaxInstructions: u32 = 100;
|
||||
}
|
||||
pub type TrustedTeleporters = (
|
||||
xcm_builder::Case<RococoForTick>,
|
||||
xcm_builder::Case<RococoForTrick>,
|
||||
xcm_builder::Case<RococoForTrack>,
|
||||
xcm_builder::Case<RococoForStatemine>,
|
||||
xcm_builder::Case<RococoForCanvas>,
|
||||
xcm_builder::Case<RococoForEncointer>,
|
||||
);
|
||||
|
||||
parameter_types! {
|
||||
pub AllowUnpaidFrom: Vec<MultiLocation> =
|
||||
vec![
|
||||
Parachain(100).into(),
|
||||
Parachain(110).into(),
|
||||
Parachain(120).into(),
|
||||
Parachain(1000).into(),
|
||||
Parachain(1002).into(),
|
||||
Parachain(1003).into(),
|
||||
];
|
||||
}
|
||||
|
||||
use xcm_builder::{AllowTopLevelPaidExecutionFrom, AllowUnpaidExecutionFrom, TakeWeightCredit};
|
||||
pub type Barrier = (
|
||||
TakeWeightCredit,
|
||||
AllowTopLevelPaidExecutionFrom<Everything>,
|
||||
AllowUnpaidExecutionFrom<IsInVec<AllowUnpaidFrom>>, // <- Trusted parachains get free execution
|
||||
// Expected responses are OK.
|
||||
AllowKnownQueryResponses<XcmPallet>,
|
||||
// Subscriptions for version tracking are OK.
|
||||
AllowSubscriptionsFrom<Everything>,
|
||||
);
|
||||
|
||||
pub struct XcmConfig;
|
||||
impl xcm_executor::Config for XcmConfig {
|
||||
type Call = Call;
|
||||
type XcmSender = XcmRouter;
|
||||
type AssetTransactor = LocalAssetTransactor;
|
||||
type OriginConverter = LocalOriginConverter;
|
||||
type IsReserve = ();
|
||||
type IsTeleporter = TrustedTeleporters;
|
||||
type LocationInverter = LocationInverter<Ancestry>;
|
||||
type Barrier = Barrier;
|
||||
type Weigher = FixedWeightBounds<BaseXcmWeight, Call, MaxInstructions>;
|
||||
type Trader = UsingComponents<WeightToFee, RocLocation, AccountId, Balances, ToAuthor<Runtime>>;
|
||||
type ResponseHandler = XcmPallet;
|
||||
type AssetTrap = XcmPallet;
|
||||
type AssetClaims = XcmPallet;
|
||||
type SubscriptionService = XcmPallet;
|
||||
}
|
||||
|
||||
parameter_types! {
|
||||
pub const CollectiveBodyId: BodyId = BodyId::Unit;
|
||||
}
|
||||
|
||||
/// Type to convert an `Origin` type value into a `MultiLocation` value which represents an interior location
|
||||
/// of this chain.
|
||||
pub type LocalOriginToLocation = (
|
||||
// We allow an origin from the Collective pallet to be used in XCM as a corresponding Plurality of the
|
||||
// `Unit` body.
|
||||
BackingToPlurality<Origin, pallet_collective::Origin<Runtime>, CollectiveBodyId>,
|
||||
// And a usual Signed origin to be used in XCM as a corresponding AccountId32
|
||||
SignedToAccountId32<Origin, AccountId, RococoNetwork>,
|
||||
);
|
||||
|
||||
impl pallet_xcm::Config for Runtime {
|
||||
type Event = Event;
|
||||
type SendXcmOrigin = xcm_builder::EnsureXcmOrigin<Origin, LocalOriginToLocation>;
|
||||
type XcmRouter = XcmRouter;
|
||||
// Anyone can execute XCM messages locally...
|
||||
type ExecuteXcmOrigin = xcm_builder::EnsureXcmOrigin<Origin, LocalOriginToLocation>;
|
||||
// ...but they must match our filter, which right now rejects everything.
|
||||
type XcmExecuteFilter = Nothing;
|
||||
type XcmExecutor = XcmExecutor<XcmConfig>;
|
||||
type XcmTeleportFilter = Everything;
|
||||
type XcmReserveTransferFilter = Everything;
|
||||
type Weigher = FixedWeightBounds<BaseXcmWeight, Call, MaxInstructions>;
|
||||
type LocationInverter = LocationInverter<Ancestry>;
|
||||
type Origin = Origin;
|
||||
type Call = Call;
|
||||
const VERSION_DISCOVERY_QUEUE_SIZE: u32 = 100;
|
||||
type AdvertisedXcmVersion = pallet_xcm::CurrentXcmVersion;
|
||||
}
|
||||
|
||||
impl parachains_session_info::Config for Runtime {}
|
||||
|
||||
parameter_types! {
|
||||
@@ -776,7 +633,8 @@ parameter_types! {
|
||||
|
||||
impl parachains_ump::Config for Runtime {
|
||||
type Event = Event;
|
||||
type UmpSink = crate::parachains_ump::XcmSink<XcmExecutor<XcmConfig>, Runtime>;
|
||||
type UmpSink =
|
||||
crate::parachains_ump::XcmSink<xcm_executor::XcmExecutor<xcm_config::XcmConfig>, Runtime>;
|
||||
type FirstMessageFactorPercent = FirstMessageFactorPercent;
|
||||
type ExecuteOverweightOrigin = EnsureRoot<AccountId>;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,170 @@
|
||||
// Copyright 2022 Parity Technologies (UK) Ltd.
|
||||
// This file is part of Polkadot.
|
||||
|
||||
// Polkadot is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
|
||||
// Polkadot is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Polkadot. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
//! XCM configuration for Rococo.
|
||||
|
||||
use super::{
|
||||
parachains_origin, AccountId, Balances, Call, Event, Origin, ParaId, Runtime, WeightToFee,
|
||||
XcmPallet,
|
||||
};
|
||||
use frame_support::{
|
||||
parameter_types,
|
||||
traits::{Everything, IsInVec, Nothing},
|
||||
weights::Weight,
|
||||
};
|
||||
use runtime_common::{xcm_sender, ToAuthor};
|
||||
use sp_std::prelude::*;
|
||||
use xcm::latest::prelude::*;
|
||||
use xcm_builder::{
|
||||
AccountId32Aliases, AllowKnownQueryResponses, AllowSubscriptionsFrom, BackingToPlurality,
|
||||
ChildParachainAsNative, ChildParachainConvertsVia, ChildSystemParachainAsSuperuser,
|
||||
CurrencyAdapter as XcmCurrencyAdapter, FixedWeightBounds, IsConcrete, LocationInverter,
|
||||
SignedAccountId32AsNative, SignedToAccountId32, SovereignSignedViaLocation, UsingComponents,
|
||||
};
|
||||
|
||||
parameter_types! {
|
||||
pub const RocLocation: MultiLocation = Here.into();
|
||||
pub const RococoNetwork: NetworkId = NetworkId::Polkadot;
|
||||
pub const Ancestry: MultiLocation = Here.into();
|
||||
pub CheckAccount: AccountId = XcmPallet::check_account();
|
||||
}
|
||||
|
||||
pub type SovereignAccountOf =
|
||||
(ChildParachainConvertsVia<ParaId, AccountId>, AccountId32Aliases<RococoNetwork, AccountId>);
|
||||
|
||||
pub type LocalAssetTransactor = XcmCurrencyAdapter<
|
||||
// Use this currency:
|
||||
Balances,
|
||||
// Use this currency when it is a fungible asset matching the given location or name:
|
||||
IsConcrete<RocLocation>,
|
||||
// We can convert the MultiLocations with our converter above:
|
||||
SovereignAccountOf,
|
||||
// Our chain's account ID type (we can't get away without mentioning it explicitly):
|
||||
AccountId,
|
||||
// It's a native asset so we keep track of the teleports to maintain total issuance.
|
||||
CheckAccount,
|
||||
>;
|
||||
|
||||
type LocalOriginConverter = (
|
||||
SovereignSignedViaLocation<SovereignAccountOf, Origin>,
|
||||
ChildParachainAsNative<parachains_origin::Origin, Origin>,
|
||||
SignedAccountId32AsNative<RococoNetwork, Origin>,
|
||||
ChildSystemParachainAsSuperuser<ParaId, Origin>,
|
||||
);
|
||||
|
||||
parameter_types! {
|
||||
pub const BaseXcmWeight: Weight = 1_000_000_000;
|
||||
}
|
||||
|
||||
/// 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, XcmPallet>,
|
||||
);
|
||||
|
||||
parameter_types! {
|
||||
pub const Rococo: MultiAssetFilter = Wild(AllOf { fun: WildFungible, id: Concrete(RocLocation::get()) });
|
||||
pub const RococoForTick: (MultiAssetFilter, MultiLocation) = (Rococo::get(), Parachain(100).into());
|
||||
pub const RococoForTrick: (MultiAssetFilter, MultiLocation) = (Rococo::get(), Parachain(110).into());
|
||||
pub const RococoForTrack: (MultiAssetFilter, MultiLocation) = (Rococo::get(), Parachain(120).into());
|
||||
pub const RococoForStatemine: (MultiAssetFilter, MultiLocation) = (Rococo::get(), Parachain(1000).into());
|
||||
pub const RococoForCanvas: (MultiAssetFilter, MultiLocation) = (Rococo::get(), Parachain(1002).into());
|
||||
pub const RococoForEncointer: (MultiAssetFilter, MultiLocation) = (Rococo::get(), Parachain(1003).into());
|
||||
pub const MaxInstructions: u32 = 100;
|
||||
}
|
||||
pub type TrustedTeleporters = (
|
||||
xcm_builder::Case<RococoForTick>,
|
||||
xcm_builder::Case<RococoForTrick>,
|
||||
xcm_builder::Case<RococoForTrack>,
|
||||
xcm_builder::Case<RococoForStatemine>,
|
||||
xcm_builder::Case<RococoForCanvas>,
|
||||
xcm_builder::Case<RococoForEncointer>,
|
||||
);
|
||||
|
||||
parameter_types! {
|
||||
pub AllowUnpaidFrom: Vec<MultiLocation> =
|
||||
vec![
|
||||
Parachain(100).into(),
|
||||
Parachain(110).into(),
|
||||
Parachain(120).into(),
|
||||
Parachain(1000).into(),
|
||||
Parachain(1002).into(),
|
||||
Parachain(1003).into(),
|
||||
];
|
||||
}
|
||||
|
||||
use xcm_builder::{AllowTopLevelPaidExecutionFrom, AllowUnpaidExecutionFrom, TakeWeightCredit};
|
||||
pub type Barrier = (
|
||||
TakeWeightCredit,
|
||||
AllowTopLevelPaidExecutionFrom<Everything>,
|
||||
AllowUnpaidExecutionFrom<IsInVec<AllowUnpaidFrom>>, // <- Trusted parachains get free execution
|
||||
// Expected responses are OK.
|
||||
AllowKnownQueryResponses<XcmPallet>,
|
||||
// Subscriptions for version tracking are OK.
|
||||
AllowSubscriptionsFrom<Everything>,
|
||||
);
|
||||
|
||||
pub struct XcmConfig;
|
||||
impl xcm_executor::Config for XcmConfig {
|
||||
type Call = Call;
|
||||
type XcmSender = XcmRouter;
|
||||
type AssetTransactor = LocalAssetTransactor;
|
||||
type OriginConverter = LocalOriginConverter;
|
||||
type IsReserve = ();
|
||||
type IsTeleporter = TrustedTeleporters;
|
||||
type LocationInverter = LocationInverter<Ancestry>;
|
||||
type Barrier = Barrier;
|
||||
type Weigher = FixedWeightBounds<BaseXcmWeight, Call, MaxInstructions>;
|
||||
type Trader = UsingComponents<WeightToFee, RocLocation, AccountId, Balances, ToAuthor<Runtime>>;
|
||||
type ResponseHandler = XcmPallet;
|
||||
type AssetTrap = XcmPallet;
|
||||
type AssetClaims = XcmPallet;
|
||||
type SubscriptionService = XcmPallet;
|
||||
}
|
||||
|
||||
parameter_types! {
|
||||
pub const CollectiveBodyId: BodyId = BodyId::Unit;
|
||||
}
|
||||
|
||||
/// Type to convert an `Origin` type value into a `MultiLocation` value which represents an interior location
|
||||
/// of this chain.
|
||||
pub type LocalOriginToLocation = (
|
||||
// We allow an origin from the Collective pallet to be used in XCM as a corresponding Plurality of the
|
||||
// `Unit` body.
|
||||
BackingToPlurality<Origin, pallet_collective::Origin<Runtime>, CollectiveBodyId>,
|
||||
// And a usual Signed origin to be used in XCM as a corresponding AccountId32
|
||||
SignedToAccountId32<Origin, AccountId, RococoNetwork>,
|
||||
);
|
||||
|
||||
impl pallet_xcm::Config for Runtime {
|
||||
type Event = Event;
|
||||
type SendXcmOrigin = xcm_builder::EnsureXcmOrigin<Origin, LocalOriginToLocation>;
|
||||
type XcmRouter = XcmRouter;
|
||||
// Anyone can execute XCM messages locally...
|
||||
type ExecuteXcmOrigin = xcm_builder::EnsureXcmOrigin<Origin, LocalOriginToLocation>;
|
||||
// ...but they must match our filter, which right now rejects everything.
|
||||
type XcmExecuteFilter = Nothing;
|
||||
type XcmExecutor = xcm_executor::XcmExecutor<XcmConfig>;
|
||||
type XcmTeleportFilter = Everything;
|
||||
type XcmReserveTransferFilter = Everything;
|
||||
type Weigher = FixedWeightBounds<BaseXcmWeight, Call, MaxInstructions>;
|
||||
type LocationInverter = LocationInverter<Ancestry>;
|
||||
type Origin = Origin;
|
||||
type Call = Call;
|
||||
const VERSION_DISCOVERY_QUEUE_SIZE: u32 = 100;
|
||||
type AdvertisedXcmVersion = pallet_xcm::CurrentXcmVersion;
|
||||
}
|
||||
@@ -34,9 +34,8 @@ use primitives::{
|
||||
};
|
||||
use runtime_common::{
|
||||
assigned_slots, auctions, crowdloan, impls::ToAuthor, paras_registrar, paras_sudo_wrapper,
|
||||
slots, xcm_sender, BlockHashCount, BlockLength, BlockWeights, CurrencyToVote,
|
||||
OffchainSolutionLengthLimit, OffchainSolutionWeightLimit, RocksDbWeight,
|
||||
SlowAdjustingFeeUpdate,
|
||||
slots, BlockHashCount, BlockLength, BlockWeights, CurrencyToVote, OffchainSolutionLengthLimit,
|
||||
OffchainSolutionWeightLimit, RocksDbWeight, SlowAdjustingFeeUpdate,
|
||||
};
|
||||
use sp_std::{collections::btree_map::BTreeMap, prelude::*};
|
||||
|
||||
@@ -49,24 +48,11 @@ use runtime_parachains::{
|
||||
session_info as parachains_session_info, shared as parachains_shared, ump as parachains_ump,
|
||||
};
|
||||
|
||||
use xcm::latest::prelude::*;
|
||||
use xcm_builder::{
|
||||
AccountId32Aliases, AllowKnownQueryResponses, AllowSubscriptionsFrom,
|
||||
AllowTopLevelPaidExecutionFrom, AllowUnpaidExecutionFrom, ChildParachainAsNative,
|
||||
ChildParachainConvertsVia, ChildSystemParachainAsSuperuser,
|
||||
CurrencyAdapter as XcmCurrencyAdapter, IsChildSystemParachain, IsConcrete, LocationInverter,
|
||||
SignedAccountId32AsNative, SignedToAccountId32, SovereignSignedViaLocation, TakeWeightCredit,
|
||||
UsingComponents, WeightInfoBounds,
|
||||
};
|
||||
use xcm_executor::XcmExecutor;
|
||||
|
||||
use authority_discovery_primitives::AuthorityId as AuthorityDiscoveryId;
|
||||
use beefy_primitives::crypto::AuthorityId as BeefyId;
|
||||
use frame_support::{
|
||||
construct_runtime, parameter_types,
|
||||
traits::{
|
||||
Contains, Everything, InstanceFilter, KeyOwnerProofSystem, Nothing, OnRuntimeUpgrade,
|
||||
},
|
||||
traits::{Contains, InstanceFilter, KeyOwnerProofSystem, OnRuntimeUpgrade},
|
||||
weights::Weight,
|
||||
PalletId, RuntimeDebug,
|
||||
};
|
||||
@@ -110,6 +96,9 @@ mod weights;
|
||||
// Voter bag threshold definitions.
|
||||
mod bag_thresholds;
|
||||
|
||||
// XCM configurations.
|
||||
mod xcm_config;
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests;
|
||||
|
||||
@@ -864,7 +853,8 @@ parameter_types! {
|
||||
|
||||
impl parachains_ump::Config for Runtime {
|
||||
type Event = Event;
|
||||
type UmpSink = crate::parachains_ump::XcmSink<XcmExecutor<XcmConfig>, Runtime>;
|
||||
type UmpSink =
|
||||
crate::parachains_ump::XcmSink<xcm_executor::XcmExecutor<xcm_config::XcmConfig>, Runtime>;
|
||||
type FirstMessageFactorPercent = FirstMessageFactorPercent;
|
||||
type ExecuteOverweightOrigin = EnsureRoot<AccountId>;
|
||||
}
|
||||
@@ -979,113 +969,6 @@ impl auctions::Config for Runtime {
|
||||
type WeightInfo = weights::runtime_common_auctions::WeightInfo<Runtime>;
|
||||
}
|
||||
|
||||
parameter_types! {
|
||||
pub const WndLocation: MultiLocation = Here.into();
|
||||
pub const Ancestry: MultiLocation = Here.into();
|
||||
pub WestendNetwork: NetworkId = NetworkId::Named(b"Westend".to_vec());
|
||||
pub CheckAccount: AccountId = XcmPallet::check_account();
|
||||
}
|
||||
|
||||
pub type LocationConverter =
|
||||
(ChildParachainConvertsVia<ParaId, AccountId>, AccountId32Aliases<WestendNetwork, AccountId>);
|
||||
|
||||
pub type LocalAssetTransactor = XcmCurrencyAdapter<
|
||||
// Use this currency:
|
||||
Balances,
|
||||
// Use this currency when it is a fungible asset matching the given location or name:
|
||||
IsConcrete<WndLocation>,
|
||||
// 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):
|
||||
AccountId,
|
||||
// It's a native asset so we keep track of the teleports to maintain total issuance.
|
||||
CheckAccount,
|
||||
>;
|
||||
|
||||
type LocalOriginConverter = (
|
||||
SovereignSignedViaLocation<LocationConverter, Origin>,
|
||||
ChildParachainAsNative<parachains_origin::Origin, Origin>,
|
||||
SignedAccountId32AsNative<WestendNetwork, Origin>,
|
||||
ChildSystemParachainAsSuperuser<ParaId, Origin>,
|
||||
);
|
||||
|
||||
/// 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, XcmPallet>,
|
||||
);
|
||||
|
||||
parameter_types! {
|
||||
pub const Westmint: MultiLocation = Parachain(1000).into();
|
||||
pub const Encointer: MultiLocation = Parachain(1001).into();
|
||||
pub const WestendForWestmint: (MultiAssetFilter, MultiLocation) =
|
||||
(Wild(AllOf { fun: WildFungible, id: Concrete(WndLocation::get()) }), Westmint::get());
|
||||
pub const WestendForEncointer: (MultiAssetFilter, MultiLocation) =
|
||||
(Wild(AllOf { fun: WildFungible, id: Concrete(WndLocation::get()) }), Encointer::get());
|
||||
pub const MaxInstructions: u32 = 100;
|
||||
}
|
||||
pub type TrustedTeleporters =
|
||||
(xcm_builder::Case<WestendForWestmint>, xcm_builder::Case<WestendForEncointer>);
|
||||
|
||||
/// The barriers one of which must be passed for an XCM message to be executed.
|
||||
pub type Barrier = (
|
||||
// Weight that is paid for may be consumed.
|
||||
TakeWeightCredit,
|
||||
// If the message is one that immediately attemps to pay for execution, then allow it.
|
||||
AllowTopLevelPaidExecutionFrom<Everything>,
|
||||
// Messages coming from system parachains need not pay for execution.
|
||||
AllowUnpaidExecutionFrom<IsChildSystemParachain<ParaId>>,
|
||||
// Expected responses are OK.
|
||||
AllowKnownQueryResponses<XcmPallet>,
|
||||
// Subscriptions for version tracking are OK.
|
||||
AllowSubscriptionsFrom<Everything>,
|
||||
);
|
||||
|
||||
pub struct XcmConfig;
|
||||
impl xcm_executor::Config for XcmConfig {
|
||||
type Call = Call;
|
||||
type XcmSender = XcmRouter;
|
||||
type AssetTransactor = LocalAssetTransactor;
|
||||
type OriginConverter = LocalOriginConverter;
|
||||
type IsReserve = ();
|
||||
type IsTeleporter = TrustedTeleporters;
|
||||
type LocationInverter = LocationInverter<Ancestry>;
|
||||
type Barrier = Barrier;
|
||||
type Weigher = WeightInfoBounds<weights::xcm::WestendXcmWeight<Call>, Call, MaxInstructions>;
|
||||
type Trader = UsingComponents<WeightToFee, WndLocation, AccountId, Balances, ToAuthor<Runtime>>;
|
||||
type ResponseHandler = XcmPallet;
|
||||
type AssetTrap = XcmPallet;
|
||||
type AssetClaims = XcmPallet;
|
||||
type SubscriptionService = XcmPallet;
|
||||
}
|
||||
|
||||
/// Type to convert an `Origin` type value into a `MultiLocation` value which represents an interior location
|
||||
/// of this chain.
|
||||
pub type LocalOriginToLocation = (
|
||||
// And a usual Signed origin to be used in XCM as a corresponding AccountId32
|
||||
SignedToAccountId32<Origin, AccountId, WestendNetwork>,
|
||||
);
|
||||
|
||||
impl pallet_xcm::Config for Runtime {
|
||||
type Event = Event;
|
||||
type SendXcmOrigin = xcm_builder::EnsureXcmOrigin<Origin, LocalOriginToLocation>;
|
||||
type XcmRouter = XcmRouter;
|
||||
// Anyone can execute XCM messages locally...
|
||||
type ExecuteXcmOrigin = xcm_builder::EnsureXcmOrigin<Origin, LocalOriginToLocation>;
|
||||
// ...but they must match our filter, which rejects everything.
|
||||
type XcmExecuteFilter = Nothing;
|
||||
type XcmExecutor = XcmExecutor<XcmConfig>;
|
||||
type XcmTeleportFilter = Everything;
|
||||
type XcmReserveTransferFilter = Everything;
|
||||
type Weigher = WeightInfoBounds<weights::xcm::WestendXcmWeight<Call>, Call, MaxInstructions>;
|
||||
type LocationInverter = LocationInverter<Ancestry>;
|
||||
type Origin = Origin;
|
||||
type Call = Call;
|
||||
const VERSION_DISCOVERY_QUEUE_SIZE: u32 = 100;
|
||||
type AdvertisedXcmVersion = pallet_xcm::CurrentXcmVersion;
|
||||
}
|
||||
|
||||
construct_runtime! {
|
||||
pub enum Runtime where
|
||||
Block = Block,
|
||||
@@ -1653,11 +1536,15 @@ sp_api::impl_runtime_apis! {
|
||||
impl pallet_offences_benchmarking::Config for Runtime {}
|
||||
impl frame_system_benchmarking::Config for Runtime {}
|
||||
|
||||
use xcm::latest::MultiAsset;
|
||||
use xcm::latest::{
|
||||
AssetId::*, Fungibility::*, Junctions::*, MultiAsset, MultiAssets, MultiLocation,
|
||||
Response,
|
||||
};
|
||||
use xcm_config::{Westmint, WndLocation};
|
||||
|
||||
impl pallet_xcm_benchmarks::Config for Runtime {
|
||||
type XcmConfig = XcmConfig;
|
||||
type AccountIdConverter = LocationConverter;
|
||||
type XcmConfig = xcm_config::XcmConfig;
|
||||
type AccountIdConverter = xcm_config::LocationConverter;
|
||||
fn valid_destination() -> Result<MultiLocation, BenchmarkError> {
|
||||
Ok(Westmint::get())
|
||||
}
|
||||
@@ -1680,7 +1567,7 @@ sp_api::impl_runtime_apis! {
|
||||
impl pallet_xcm_benchmarks::fungible::Config for Runtime {
|
||||
type TransactAsset = Balances;
|
||||
|
||||
type CheckedAccount = CheckAccount;
|
||||
type CheckedAccount = xcm_config::CheckAccount;
|
||||
type TrustedTeleporter = TrustedTeleporter;
|
||||
|
||||
fn get_multi_asset() -> MultiAsset {
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
//! Tests for the Westend Runtime Configuration
|
||||
|
||||
use crate::*;
|
||||
use xcm::latest::{AssetId::*, Fungibility::*, MultiLocation};
|
||||
|
||||
#[test]
|
||||
fn remove_keys_weight_is_sensible() {
|
||||
|
||||
@@ -0,0 +1,143 @@
|
||||
// Copyright 2022 Parity Technologies (UK) Ltd.
|
||||
// This file is part of Polkadot.
|
||||
|
||||
// Polkadot is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
|
||||
// Polkadot is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Polkadot. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
//! XCM configurations for Westend.
|
||||
|
||||
use super::{
|
||||
parachains_origin, weights, AccountId, Balances, Call, Event, Origin, ParaId, Runtime,
|
||||
WeightToFee, XcmPallet,
|
||||
};
|
||||
use frame_support::{
|
||||
parameter_types,
|
||||
traits::{Everything, Nothing},
|
||||
};
|
||||
use runtime_common::{xcm_sender, ToAuthor};
|
||||
use xcm::latest::prelude::*;
|
||||
use xcm_builder::{
|
||||
AccountId32Aliases, AllowKnownQueryResponses, AllowSubscriptionsFrom,
|
||||
AllowTopLevelPaidExecutionFrom, AllowUnpaidExecutionFrom, ChildParachainAsNative,
|
||||
ChildParachainConvertsVia, ChildSystemParachainAsSuperuser,
|
||||
CurrencyAdapter as XcmCurrencyAdapter, IsChildSystemParachain, IsConcrete, LocationInverter,
|
||||
SignedAccountId32AsNative, SignedToAccountId32, SovereignSignedViaLocation, TakeWeightCredit,
|
||||
UsingComponents, WeightInfoBounds,
|
||||
};
|
||||
|
||||
parameter_types! {
|
||||
pub const WndLocation: MultiLocation = Here.into();
|
||||
pub const Ancestry: MultiLocation = Here.into();
|
||||
pub WestendNetwork: NetworkId = NetworkId::Named(b"Westend".to_vec());
|
||||
pub CheckAccount: AccountId = XcmPallet::check_account();
|
||||
}
|
||||
|
||||
pub type LocationConverter =
|
||||
(ChildParachainConvertsVia<ParaId, AccountId>, AccountId32Aliases<WestendNetwork, AccountId>);
|
||||
|
||||
pub type LocalAssetTransactor = XcmCurrencyAdapter<
|
||||
// Use this currency:
|
||||
Balances,
|
||||
// Use this currency when it is a fungible asset matching the given location or name:
|
||||
IsConcrete<WndLocation>,
|
||||
// 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):
|
||||
AccountId,
|
||||
// It's a native asset so we keep track of the teleports to maintain total issuance.
|
||||
CheckAccount,
|
||||
>;
|
||||
|
||||
type LocalOriginConverter = (
|
||||
SovereignSignedViaLocation<LocationConverter, Origin>,
|
||||
ChildParachainAsNative<parachains_origin::Origin, Origin>,
|
||||
SignedAccountId32AsNative<WestendNetwork, Origin>,
|
||||
ChildSystemParachainAsSuperuser<ParaId, Origin>,
|
||||
);
|
||||
|
||||
/// 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, XcmPallet>,
|
||||
);
|
||||
|
||||
parameter_types! {
|
||||
pub const Westmint: MultiLocation = Parachain(1000).into();
|
||||
pub const Encointer: MultiLocation = Parachain(1001).into();
|
||||
pub const WestendForWestmint: (MultiAssetFilter, MultiLocation) =
|
||||
(Wild(AllOf { fun: WildFungible, id: Concrete(WndLocation::get()) }), Westmint::get());
|
||||
pub const WestendForEncointer: (MultiAssetFilter, MultiLocation) =
|
||||
(Wild(AllOf { fun: WildFungible, id: Concrete(WndLocation::get()) }), Encointer::get());
|
||||
pub const MaxInstructions: u32 = 100;
|
||||
}
|
||||
pub type TrustedTeleporters =
|
||||
(xcm_builder::Case<WestendForWestmint>, xcm_builder::Case<WestendForEncointer>);
|
||||
|
||||
/// The barriers one of which must be passed for an XCM message to be executed.
|
||||
pub type Barrier = (
|
||||
// Weight that is paid for may be consumed.
|
||||
TakeWeightCredit,
|
||||
// If the message is one that immediately attemps to pay for execution, then allow it.
|
||||
AllowTopLevelPaidExecutionFrom<Everything>,
|
||||
// Messages coming from system parachains need not pay for execution.
|
||||
AllowUnpaidExecutionFrom<IsChildSystemParachain<ParaId>>,
|
||||
// Expected responses are OK.
|
||||
AllowKnownQueryResponses<XcmPallet>,
|
||||
// Subscriptions for version tracking are OK.
|
||||
AllowSubscriptionsFrom<Everything>,
|
||||
);
|
||||
|
||||
pub struct XcmConfig;
|
||||
impl xcm_executor::Config for XcmConfig {
|
||||
type Call = Call;
|
||||
type XcmSender = XcmRouter;
|
||||
type AssetTransactor = LocalAssetTransactor;
|
||||
type OriginConverter = LocalOriginConverter;
|
||||
type IsReserve = ();
|
||||
type IsTeleporter = TrustedTeleporters;
|
||||
type LocationInverter = LocationInverter<Ancestry>;
|
||||
type Barrier = Barrier;
|
||||
type Weigher = WeightInfoBounds<weights::xcm::WestendXcmWeight<Call>, Call, MaxInstructions>;
|
||||
type Trader = UsingComponents<WeightToFee, WndLocation, AccountId, Balances, ToAuthor<Runtime>>;
|
||||
type ResponseHandler = XcmPallet;
|
||||
type AssetTrap = XcmPallet;
|
||||
type AssetClaims = XcmPallet;
|
||||
type SubscriptionService = XcmPallet;
|
||||
}
|
||||
|
||||
/// Type to convert an `Origin` type value into a `MultiLocation` value which represents an interior location
|
||||
/// of this chain.
|
||||
pub type LocalOriginToLocation = (
|
||||
// And a usual Signed origin to be used in XCM as a corresponding AccountId32
|
||||
SignedToAccountId32<Origin, AccountId, WestendNetwork>,
|
||||
);
|
||||
|
||||
impl pallet_xcm::Config for Runtime {
|
||||
type Event = Event;
|
||||
type SendXcmOrigin = xcm_builder::EnsureXcmOrigin<Origin, LocalOriginToLocation>;
|
||||
type XcmRouter = XcmRouter;
|
||||
// Anyone can execute XCM messages locally...
|
||||
type ExecuteXcmOrigin = xcm_builder::EnsureXcmOrigin<Origin, LocalOriginToLocation>;
|
||||
// ...but they must match our filter, which rejects everything.
|
||||
type XcmExecuteFilter = Nothing;
|
||||
type XcmExecutor = xcm_executor::XcmExecutor<XcmConfig>;
|
||||
type XcmTeleportFilter = Everything;
|
||||
type XcmReserveTransferFilter = Everything;
|
||||
type Weigher = WeightInfoBounds<weights::xcm::WestendXcmWeight<Call>, Call, MaxInstructions>;
|
||||
type LocationInverter = LocationInverter<Ancestry>;
|
||||
type Origin = Origin;
|
||||
type Call = Call;
|
||||
const VERSION_DISCOVERY_QUEUE_SIZE: u32 = 100;
|
||||
type AdvertisedXcmVersion = pallet_xcm::CurrentXcmVersion;
|
||||
}
|
||||
Reference in New Issue
Block a user