From 544038360da2e484f03bc81a8dd4c9f85454b9fe Mon Sep 17 00:00:00 2001 From: Antonio Antonino Date: Mon, 23 Jan 2023 16:33:16 +0100 Subject: [PATCH 1/4] wip --- runtimes/clone/src/xcm_config.rs | 3 ++- runtimes/peregrine/src/xcm_config.rs | 5 +++-- runtimes/spiritnet/src/xcm_config.rs | 3 ++- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/runtimes/clone/src/xcm_config.rs b/runtimes/clone/src/xcm_config.rs index 69bac86734..ed1bc309ba 100644 --- a/runtimes/clone/src/xcm_config.rs +++ b/runtimes/clone/src/xcm_config.rs @@ -97,7 +97,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; /// The means for routing XCM messages which are not for local execution into diff --git a/runtimes/peregrine/src/xcm_config.rs b/runtimes/peregrine/src/xcm_config.rs index 951e85fb40..114ecb13f6 100644 --- a/runtimes/peregrine/src/xcm_config.rs +++ b/runtimes/peregrine/src/xcm_config.rs @@ -102,7 +102,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; /// The means for routing XCM messages which are not for local execution into @@ -122,9 +123,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; type XcmTeleportFilter = Everything; type XcmReserveTransferFilter = Nothing; + type XcmExecutor = XcmExecutor; type Weigher = FixedWeightBounds; type LocationInverter = LocationInverter; type RuntimeOrigin = RuntimeOrigin; diff --git a/runtimes/spiritnet/src/xcm_config.rs b/runtimes/spiritnet/src/xcm_config.rs index 5fd40e9d38..0806d2a74b 100644 --- a/runtimes/spiritnet/src/xcm_config.rs +++ b/runtimes/spiritnet/src/xcm_config.rs @@ -97,7 +97,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; /// The means for routing XCM messages which are not for local execution into From 220fe92863f8e3ec7d54f6974b1df37f25ad84cb Mon Sep 17 00:00:00 2001 From: Antonio Antonino Date: Tue, 24 Jan 2023 10:32:54 +0100 Subject: [PATCH 2/4] Fix lock file --- Cargo.lock | 96 +----------------------------------------------------- 1 file changed, 1 insertion(+), 95 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index e61d9cd777..7d2aec7998 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -952,65 +952,6 @@ dependencies = [ "os_str_bytes", ] -[[package]] -name = "clone-runtime" -version = "1.9.0-dev" -dependencies = [ - "cumulus-pallet-aura-ext", - "cumulus-pallet-dmp-queue", - "cumulus-pallet-parachain-system", - "cumulus-pallet-session-benchmarking", - "cumulus-pallet-solo-to-para", - "cumulus-pallet-xcm", - "cumulus-pallet-xcmp-queue", - "cumulus-primitives-core", - "cumulus-primitives-timestamp", - "cumulus-primitives-utility", - "frame-benchmarking", - "frame-executive", - "frame-support", - "frame-system", - "frame-system-benchmarking", - "frame-system-rpc-runtime-api", - "frame-try-runtime", - "hex-literal", - "kilt-runtime-api-did", - "kilt-runtime-api-public-credentials", - "log", - "pallet-aura", - "pallet-authorship", - "pallet-balances", - "pallet-collator-selection", - "pallet-did-lookup", - "pallet-session", - "pallet-sudo", - "pallet-timestamp", - "pallet-transaction-payment", - "pallet-transaction-payment-rpc-runtime-api", - "pallet-utility", - "pallet-xcm", - "parachain-info", - "parity-scale-codec", - "public-credentials", - "runtime-common", - "scale-info", - "sp-api", - "sp-block-builder", - "sp-consensus-aura", - "sp-core", - "sp-inherents", - "sp-offchain", - "sp-runtime", - "sp-session", - "sp-std", - "sp-transaction-pool", - "sp-version", - "substrate-wasm-builder", - "xcm", - "xcm-builder", - "xcm-executor", -] - [[package]] name = "coarsetime" version = "0.1.22" @@ -1657,22 +1598,6 @@ dependencies = [ "sp-std", ] -[[package]] -name = "cumulus-pallet-solo-to-para" -version = "0.1.0" -source = "git+https://github.com/paritytech/cumulus?branch=polkadot-v0.9.37#09418fc04c2608b123f36ca80f16df3d2096753b" -dependencies = [ - "cumulus-pallet-parachain-system", - "frame-support", - "frame-system", - "pallet-sudo", - "parity-scale-codec", - "polkadot-primitives", - "scale-info", - "sp-runtime", - "sp-std", -] - [[package]] name = "cumulus-pallet-xcm" version = "0.1.0" @@ -3911,7 +3836,6 @@ name = "kilt-parachain" version = "1.9.0-dev" dependencies = [ "clap", - "clone-runtime", "cumulus-client-cli", "cumulus-client-consensus-aura", "cumulus-client-consensus-common", @@ -5720,25 +5644,6 @@ dependencies = [ "sp-std", ] -[[package]] -name = "pallet-collator-selection" -version = "3.0.0" -source = "git+https://github.com/paritytech/cumulus?branch=polkadot-v0.9.37#09418fc04c2608b123f36ca80f16df3d2096753b" -dependencies = [ - "frame-benchmarking", - "frame-support", - "frame-system", - "log", - "pallet-authorship", - "pallet-session", - "parity-scale-codec", - "rand 0.8.5", - "scale-info", - "sp-runtime", - "sp-staking", - "sp-std", -] - [[package]] name = "pallet-collective" version = "4.0.0-dev" @@ -8904,6 +8809,7 @@ name = "runtime-common" version = "1.9.0-dev" dependencies = [ "attestation", + "ctype", "cumulus-primitives-core", "frame-support", "frame-system", From af4593f95f3f1582776c89670b37b95d286f283e Mon Sep 17 00:00:00 2001 From: Antonio Antonino Date: Tue, 24 Jan 2023 10:58:11 +0100 Subject: [PATCH 3/4] Change filters to Nothing for everything --- runtimes/peregrine/src/xcm_config.rs | 2 +- runtimes/spiritnet/src/xcm_config.rs | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/runtimes/peregrine/src/xcm_config.rs b/runtimes/peregrine/src/xcm_config.rs index 114ecb13f6..db345cfce5 100644 --- a/runtimes/peregrine/src/xcm_config.rs +++ b/runtimes/peregrine/src/xcm_config.rs @@ -123,7 +123,7 @@ 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 XcmTeleportFilter = Everything; + type XcmTeleportFilter = Nothing; type XcmReserveTransferFilter = Nothing; type XcmExecutor = XcmExecutor; type Weigher = FixedWeightBounds; diff --git a/runtimes/spiritnet/src/xcm_config.rs b/runtimes/spiritnet/src/xcm_config.rs index 0806d2a74b..22f62da159 100644 --- a/runtimes/spiritnet/src/xcm_config.rs +++ b/runtimes/spiritnet/src/xcm_config.rs @@ -118,9 +118,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; - type XcmTeleportFilter = Everything; + type XcmTeleportFilter = Nothing; type XcmReserveTransferFilter = Nothing; + type XcmExecutor = XcmExecutor; type Weigher = FixedWeightBounds; type LocationInverter = LocationInverter; type RuntimeOrigin = RuntimeOrigin; From e20059c510fa8cffb0cc7e8b1b5c4530e7f487ba Mon Sep 17 00:00:00 2001 From: Antonio Antonino Date: Wed, 25 Jan 2023 15:03:52 +0100 Subject: [PATCH 4/4] More refactoring --- runtimes/common/src/xcm_config.rs | 14 +++++++------- runtimes/peregrine/src/xcm_config.rs | 15 ++++++--------- runtimes/spiritnet/src/xcm_config.rs | 15 ++++++--------- 3 files changed, 19 insertions(+), 25 deletions(-) diff --git a/runtimes/common/src/xcm_config.rs b/runtimes/common/src/xcm_config.rs index dcb71522ac..bcdad794c1 100644 --- a/runtimes/common/src/xcm_config.rs +++ b/runtimes/common/src/xcm_config.rs @@ -72,8 +72,8 @@ pub type XcmBarrier = DenyThenTry< // * TakeWeightCredit // * AllowTopLevelPaidExecutionFrom - // 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, ), @@ -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 = ( - // The parent (Relay-chain) origin converts to the parent `AccountId`. +pub type LocationToAccountId = ( + // The parent (Relay-chain) origin converts to the b"parent" `AccountId`. ParentIsPreset, // Sibling parachain origins convert to AccountId via the `ParaId::into`. SiblingParachainConvertsVia, // Straight up local `AccountId32` origins just alias directly to `AccountId`. - AccountId32Aliases, + AccountId32Aliases, ); /// Means for transacting assets on this chain. -pub type LocalAssetTransactor = CurrencyAdapter< +pub type LocalAssetTransactor = CurrencyAdapter< // Use this currency: Currency, // Use this currency when it is a fungible asset matching the given location or name: IsConcrete, // Do a simple punn to convert an AccountId32 MultiLocation into a native chain account ID: - LocationToAccountId, + LocationToAccountId, // Our chain's account ID type (we can't get away without mentioning it explicitly): AccountId, // We don't track any teleports. diff --git a/runtimes/peregrine/src/xcm_config.rs b/runtimes/peregrine/src/xcm_config.rs index db345cfce5..eddc0e7a70 100644 --- a/runtimes/peregrine/src/xcm_config.rs +++ b/runtimes/peregrine/src/xcm_config.rs @@ -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! { @@ -75,8 +72,8 @@ impl xcm_executor::Config for XcmConfig { // How to withdraw and deposit an asset. type AssetTransactor = LocalAssetTransactor; 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. @@ -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, RelayLocation, AccountId, Balances, Treasury>; + type Trader = UsingComponents, 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 diff --git a/runtimes/spiritnet/src/xcm_config.rs b/runtimes/spiritnet/src/xcm_config.rs index 22f62da159..a4fb84ab14 100644 --- a/runtimes/spiritnet/src/xcm_config.rs +++ b/runtimes/spiritnet/src/xcm_config.rs @@ -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(); @@ -70,8 +67,8 @@ impl xcm_executor::Config for XcmConfig { // How to withdraw and deposit an asset. type AssetTransactor = LocalAssetTransactor; 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. @@ -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, RelayLocation, AccountId, Balances, Treasury>; + type Trader = UsingComponents, 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