Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions runtimes/common/src/xcm_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,8 @@ pub type XcmBarrier = DenyThenTry<
// * TakeWeightCredit
// * AllowTopLevelPaidExecutionFrom<Everything>

// We allow everything from the relay chain if it was send by the relay chain legislative.
// Since the relaychain doesn't own KILTs and missing fees shouldn't prevent calls from the relaychain
// We allow everything from the relay chain if it was sent by the relay chain legislative (i.e., democracy
// vote). Since the relaychain doesn't own KILTs and missing fees shouldn't prevent calls from the relaychain
// legislative, we allow unpaid execution.
AllowUnpaidExecutionFrom<ParentLegislative>,
),
Expand Down Expand Up @@ -146,23 +146,23 @@ parameter_types! {
/// `AccountId`. This is used when determining ownership of accounts for asset
/// transacting and when attempting to use XCM `Transact` in order to determine
/// the dispatch Origin.
pub type LocationToAccountId<RelayNetwork> = (
// The parent (Relay-chain) origin converts to the parent `AccountId`.
pub type LocationToAccountId<NetworkId> = (
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The generic refers to a network ID. So especially for the future it is clearer to give the generic the proper name.

// The parent (Relay-chain) origin converts to the b"parent" `AccountId`.
ParentIsPreset<AccountId>,
// Sibling parachain origins convert to AccountId via the `ParaId::into`.
SiblingParachainConvertsVia<Sibling, AccountId>,
// Straight up local `AccountId32` origins just alias directly to `AccountId`.
AccountId32Aliases<RelayNetwork, AccountId>,
AccountId32Aliases<NetworkId, AccountId>,
);

/// Means for transacting assets on this chain.
pub type LocalAssetTransactor<Currency, RelayNetwork> = CurrencyAdapter<
pub type LocalAssetTransactor<Currency, NetworkId> = CurrencyAdapter<
// Use this currency:
Currency,
// Use this currency when it is a fungible asset matching the given location or name:
IsConcrete<HereLocation>,
// Do a simple punn to convert an AccountId32 MultiLocation into a native chain account ID:
LocationToAccountId<RelayNetwork>,
LocationToAccountId<NetworkId>,
// Our chain's account ID type (we can't get away without mentioning it explicitly):
AccountId,
// We don't track any teleports.
Expand Down
22 changes: 10 additions & 12 deletions runtimes/peregrine/src/xcm_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,20 +21,17 @@ use super::{
RuntimeOrigin, Treasury, WeightToFee, XcmpQueue,
};

use frame_support::{
parameter_types,
traits::{Everything, Nothing},
};
use frame_support::{parameter_types, traits::Nothing};
use pallet_xcm::XcmPassthrough;
use xcm::latest::prelude::*;
use xcm_builder::{
EnsureXcmOrigin, FixedWeightBounds, LocationInverter, NativeAsset, RelayChainAsNative, SiblingParachainAsNative,
EnsureXcmOrigin, FixedWeightBounds, LocationInverter, RelayChainAsNative, SiblingParachainAsNative,
SignedAccountId32AsNative, SignedToAccountId32, SovereignSignedViaLocation, UsingComponents,
};
use xcm_executor::XcmExecutor;

use runtime_common::xcm_config::{
LocalAssetTransactor, LocationToAccountId, MaxInstructions, RelayLocation, UnitWeightCost, XcmBarrier,
HereLocation, LocalAssetTransactor, LocationToAccountId, MaxInstructions, UnitWeightCost, XcmBarrier,
};

parameter_types! {
Expand Down Expand Up @@ -75,8 +72,8 @@ impl xcm_executor::Config for XcmConfig {
// How to withdraw and deposit an asset.
type AssetTransactor = LocalAssetTransactor<Balances, RelayNetworkId>;
type OriginConverter = XcmOriginToTransactDispatchOrigin;
// We only trust our own KILT asset reserve.
type IsReserve = NativeAsset;
// Reserving is disabled.
type IsReserve = ();
// Teleporting is disabled.
type IsTeleporter = ();
// Invert a location.
Expand All @@ -92,7 +89,7 @@ impl xcm_executor::Config for XcmConfig {
// How weight is transformed into fees. The fees are not taken out of the
// Balances pallet here. Balances is only used if fees are dropped without being
// used. In that case they are put into the treasury.
type Trader = UsingComponents<WeightToFee<Runtime>, RelayLocation, AccountId, Balances, Treasury>;
type Trader = UsingComponents<WeightToFee<Runtime>, HereLocation, AccountId, Balances, Treasury>;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We allow unpaid execution from the relay chain. Plus, here we were saying that relay chain funds could be used to pay for the fees, when nothing else was allowed. I think keeping it local for now is the most logical choice. We will open up once we open up to other chains.

type ResponseHandler = PolkadotXcm;
// What happens with assets that are left in the register after the XCM message
// was processed. PolkadotXcm has an AssetTrap that stores a hash of the asset
Expand All @@ -102,7 +99,8 @@ impl xcm_executor::Config for XcmConfig {
type SubscriptionService = PolkadotXcm;
}

/// No local origins on this chain are allowed to dispatch XCM sends/executions.
/// Allows only local `Signed` origins to be converted into `MultiLocation`s by
/// the XCM executor.
pub type LocalOriginToLocation = SignedToAccountId32<RuntimeOrigin, AccountId, RelayNetworkId>;

/// The means for routing XCM messages which are not for local execution into
Expand All @@ -122,9 +120,9 @@ impl pallet_xcm::Config for Runtime {
// Disable dispatchable execution on the XCM pallet.
// NOTE: For local testing this needs to be `Everything`.
type XcmExecuteFilter = Nothing;
type XcmExecutor = XcmExecutor<XcmConfig>;
type XcmTeleportFilter = Everything;
type XcmTeleportFilter = Nothing;
type XcmReserveTransferFilter = Nothing;
type XcmExecutor = XcmExecutor<XcmConfig>;
type Weigher = FixedWeightBounds<UnitWeightCost, RuntimeCall, MaxInstructions>;
type LocationInverter = LocationInverter<Ancestry>;
type RuntimeOrigin = RuntimeOrigin;
Expand Down
22 changes: 10 additions & 12 deletions runtimes/spiritnet/src/xcm_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,19 +21,16 @@ use super::{
RuntimeOrigin, Treasury, WeightToFee, XcmpQueue,
};

use frame_support::{
parameter_types,
traits::{Everything, Nothing},
};
use frame_support::{parameter_types, traits::Nothing};
use pallet_xcm::XcmPassthrough;
use xcm::latest::prelude::*;
use xcm_builder::{
EnsureXcmOrigin, FixedWeightBounds, LocationInverter, NativeAsset, RelayChainAsNative, SiblingParachainAsNative,
EnsureXcmOrigin, FixedWeightBounds, LocationInverter, RelayChainAsNative, SiblingParachainAsNative,
SignedAccountId32AsNative, SignedToAccountId32, UsingComponents,
};
use xcm_executor::XcmExecutor;

use runtime_common::xcm_config::{LocalAssetTransactor, MaxInstructions, RelayLocation, UnitWeightCost, XcmBarrier};
use runtime_common::xcm_config::{HereLocation, LocalAssetTransactor, MaxInstructions, UnitWeightCost, XcmBarrier};

parameter_types! {
pub RelayChainOrigin: RuntimeOrigin = cumulus_pallet_xcm::Origin::Relay.into();
Expand Down Expand Up @@ -70,8 +67,8 @@ impl xcm_executor::Config for XcmConfig {
// How to withdraw and deposit an asset.
type AssetTransactor = LocalAssetTransactor<Balances, RelayNetworkId>;
type OriginConverter = XcmOriginToTransactDispatchOrigin;
// We only trust our own KILT asset reserve.
type IsReserve = NativeAsset;
// Reserving is disabled.
type IsReserve = ();
// Teleporting is disabled.
type IsTeleporter = ();
// Invert a location.
Expand All @@ -87,7 +84,7 @@ impl xcm_executor::Config for XcmConfig {
// How weight is transformed into fees. The fees are not taken out of the
// Balances pallet here. Balances is only used if fees are dropped without being
// used. In that case they are put into the treasury.
type Trader = UsingComponents<WeightToFee<Runtime>, RelayLocation, AccountId, Balances, Treasury>;
type Trader = UsingComponents<WeightToFee<Runtime>, HereLocation, AccountId, Balances, Treasury>;
type ResponseHandler = PolkadotXcm;
// What happens with assets that are left in the register after the XCM message
// was processed. PolkadotXcm has an AssetTrap that stores a hash of the asset
Expand All @@ -97,7 +94,8 @@ impl xcm_executor::Config for XcmConfig {
type SubscriptionService = PolkadotXcm;
}

/// No local origins on this chain are allowed to dispatch XCM sends/executions.
/// Allows only local `Signed` origins to be converted into `MultiLocation`s by
/// the XCM executor.
pub type LocalOriginToLocation = SignedToAccountId32<RuntimeOrigin, AccountId, RelayNetworkId>;

/// The means for routing XCM messages which are not for local execution into
Expand All @@ -117,9 +115,9 @@ impl pallet_xcm::Config for Runtime {
// Disable dispatchable execution on the XCM pallet.
// NOTE: For local testing this needs to be `Everything`.
type XcmExecuteFilter = Nothing;
type XcmExecutor = XcmExecutor<XcmConfig>;
type XcmTeleportFilter = Everything;
type XcmTeleportFilter = Nothing;
type XcmReserveTransferFilter = Nothing;
type XcmExecutor = XcmExecutor<XcmConfig>;
type Weigher = FixedWeightBounds<UnitWeightCost, RuntimeCall, MaxInstructions>;
type LocationInverter = LocationInverter<Ancestry>;
type RuntimeOrigin = RuntimeOrigin;
Expand Down