From f8f6b17da754954dbca526ac65bd5b989c5038e4 Mon Sep 17 00:00:00 2001 From: Giles Cope Date: Wed, 5 Apr 2023 15:13:35 +0100 Subject: [PATCH 01/15] Send xcm fees to local treaury --- parachains/common/src/lib.rs | 8 +++++++- .../assets/statemine/src/xcm_config.rs | 16 +++++++++++++-- .../assets/statemint/src/xcm_config.rs | 16 ++++++++++++--- .../assets/westmint/src/xcm_config.rs | 17 +++++++++++++--- .../bridge-hub-kusama/src/xcm_config.rs | 19 ++++++++++++++---- .../bridge-hub-polkadot/src/xcm_config.rs | 19 ++++++++++++++---- .../bridge-hub-rococo/src/xcm_config.rs | 20 +++++++++++++++---- primitives/utility/src/lib.rs | 2 +- 8 files changed, 95 insertions(+), 22 deletions(-) diff --git a/parachains/common/src/lib.rs b/parachains/common/src/lib.rs index 8ac464ea077..55d20c07607 100644 --- a/parachains/common/src/lib.rs +++ b/parachains/common/src/lib.rs @@ -68,7 +68,10 @@ mod types { /// Common constants of parachains. mod constants { use super::types::BlockNumber; - use frame_support::weights::{constants::WEIGHT_REF_TIME_PER_SECOND, Weight}; + use frame_support::{ + weights::{constants::WEIGHT_REF_TIME_PER_SECOND, Weight}, + PalletId, + }; use sp_runtime::Perbill; /// This determines the average expected block time that we are targeting. Blocks will be /// produced at a minimum duration defined by `SLOT_DURATION`. `SLOT_DURATION` is picked up by @@ -96,6 +99,9 @@ mod constants { WEIGHT_REF_TIME_PER_SECOND.saturating_div(2), polkadot_primitives::MAX_POV_SIZE as u64, ); + + /// Treasury pallet id of the local chain, used to convert into AccountId + pub const TREASURY_PALLET_ID: PalletId = PalletId(*b"py/trsry"); } /// Opaque types. These are used by the CLI to instantiate machinery that don't need to know diff --git a/parachains/runtimes/assets/statemine/src/xcm_config.rs b/parachains/runtimes/assets/statemine/src/xcm_config.rs index 5d4c45fd4f3..2cfb8054f6a 100644 --- a/parachains/runtimes/assets/statemine/src/xcm_config.rs +++ b/parachains/runtimes/assets/statemine/src/xcm_config.rs @@ -33,8 +33,11 @@ use parachains_common::{ AssetFeeAsExistentialDepositMultiplier, DenyReserveTransferToRelayChain, DenyThenTry, }, }; +use xcm_builder::XcmFeesToAccount; + +use parachains_common::TREASURY_PALLET_ID; use polkadot_parachain::primitives::Sibling; -use sp_runtime::traits::ConvertInto; +use sp_runtime::traits::{AccountIdConversion, ConvertInto}; use xcm::latest::prelude::*; use xcm_builder::{ AccountId32Aliases, AllowExplicitUnpaidExecutionFrom, AllowKnownQueryResponses, @@ -58,6 +61,7 @@ parameter_types! { pub CheckingAccount: AccountId = PolkadotXcm::check_account(); pub const GovernanceLocation: MultiLocation = MultiLocation::parent(); pub const FellowshipLocation: MultiLocation = MultiLocation::parent(); + pub TreasuryAccount: Option = Some(TREASURY_PALLET_ID.into_account_truncating()); } /// Type for specifying how a `MultiLocation` can be converted into an `AccountId`. This is used @@ -374,6 +378,14 @@ pub type AssetFeeAsExistentialDepositMultiplierFeeCharger = AssetFeeAsExistentia TrustBackedAssetsInstance, >; +match_types! { + pub type RelayOrSystemParachains: impl Contains = { + MultiLocation { parents: 0, interior: X1(Parachain(kusama_runtime_constants::system_parachain::STATEMINE_ID | + kusama_runtime_constants::system_parachain::ENCOINTER_ID)) } | + MultiLocation { parents: 1, interior: Here } + }; +} + pub struct XcmConfig; impl xcm_executor::Config for XcmConfig { type RuntimeCall = RuntimeCall; @@ -420,7 +432,7 @@ impl xcm_executor::Config for XcmConfig { type MaxAssetsIntoHolding = MaxAssetsIntoHolding; type AssetLocker = (); type AssetExchanger = (); - type FeeManager = (); + type FeeManager = XcmFeesToAccount; type MessageExporter = (); type UniversalAliases = Nothing; type CallDispatcher = WithOriginFilter; diff --git a/parachains/runtimes/assets/statemint/src/xcm_config.rs b/parachains/runtimes/assets/statemint/src/xcm_config.rs index 90b0ee85fef..198162d4fed 100644 --- a/parachains/runtimes/assets/statemint/src/xcm_config.rs +++ b/parachains/runtimes/assets/statemint/src/xcm_config.rs @@ -29,9 +29,10 @@ use parachains_common::{ xcm_config::{ AssetFeeAsExistentialDepositMultiplier, DenyReserveTransferToRelayChain, DenyThenTry, }, + TREASURY_PALLET_ID, }; use polkadot_parachain::primitives::Sibling; -use sp_runtime::traits::ConvertInto; +use sp_runtime::traits::{AccountIdConversion, ConvertInto}; use xcm::latest::prelude::*; use xcm_builder::{ AccountId32Aliases, AllowExplicitUnpaidExecutionFrom, AllowKnownQueryResponses, @@ -39,7 +40,7 @@ use xcm_builder::{ FungiblesAdapter, IsConcrete, LocalMint, NativeAsset, ParentAsSuperuser, ParentIsPreset, RelayChainAsNative, SiblingParachainAsNative, SiblingParachainConvertsVia, SignedAccountId32AsNative, SignedToAccountId32, SovereignSignedViaLocation, TakeWeightCredit, - UsingComponents, WeightInfoBounds, WithComputedOrigin, + UsingComponents, WeightInfoBounds, WithComputedOrigin, XcmFeesToAccount, }; use xcm_executor::{traits::WithOriginFilter, XcmExecutor}; @@ -54,6 +55,7 @@ parameter_types! { pub CheckingAccount: AccountId = PolkadotXcm::check_account(); pub FellowshipLocation: MultiLocation = MultiLocation::new(1, Parachain(1001)); pub const GovernanceLocation: MultiLocation = MultiLocation::parent(); + pub TreasuryAccount: Option = Some(TREASURY_PALLET_ID.into_account_truncating()); } /// Type for specifying how a `MultiLocation` can be converted into an `AccountId`. This is used @@ -277,6 +279,14 @@ pub type AssetFeeAsExistentialDepositMultiplierFeeCharger = AssetFeeAsExistentia TrustBackedAssetsInstance, >; +match_types! { + pub type RelayOrSystemParachains: impl Contains = { + MultiLocation { parents: 0, interior: X1(Parachain(polkadot_runtime_constants::system_parachain::STATEMINT_ID | + polkadot_runtime_constants::system_parachain::COLLECTIVES_ID)) } | + MultiLocation { parents: 1, interior: Here } + }; +} + pub struct XcmConfig; impl xcm_executor::Config for XcmConfig { type RuntimeCall = RuntimeCall; @@ -317,7 +327,7 @@ impl xcm_executor::Config for XcmConfig { type MaxAssetsIntoHolding = MaxAssetsIntoHolding; type AssetLocker = (); type AssetExchanger = (); - type FeeManager = (); + type FeeManager = XcmFeesToAccount; type MessageExporter = (); type UniversalAliases = Nothing; type CallDispatcher = WithOriginFilter; diff --git a/parachains/runtimes/assets/westmint/src/xcm_config.rs b/parachains/runtimes/assets/westmint/src/xcm_config.rs index 1f57b34fcae..30670251a0a 100644 --- a/parachains/runtimes/assets/westmint/src/xcm_config.rs +++ b/parachains/runtimes/assets/westmint/src/xcm_config.rs @@ -33,9 +33,10 @@ use parachains_common::{ xcm_config::{ AssetFeeAsExistentialDepositMultiplier, DenyReserveTransferToRelayChain, DenyThenTry, }, + TREASURY_PALLET_ID, }; use polkadot_parachain::primitives::Sibling; -use sp_runtime::traits::ConvertInto; +use sp_runtime::traits::{AccountIdConversion, ConvertInto}; use xcm::latest::prelude::*; use xcm_builder::{ AccountId32Aliases, AllowExplicitUnpaidExecutionFrom, AllowKnownQueryResponses, @@ -43,7 +44,7 @@ use xcm_builder::{ FungiblesAdapter, IsConcrete, LocalMint, NativeAsset, NoChecking, ParentAsSuperuser, ParentIsPreset, RelayChainAsNative, SiblingParachainAsNative, SiblingParachainConvertsVia, SignedAccountId32AsNative, SignedToAccountId32, SovereignSignedViaLocation, TakeWeightCredit, - UsingComponents, WeightInfoBounds, WithComputedOrigin, + UsingComponents, WeightInfoBounds, WithComputedOrigin, XcmFeesToAccount, }; use xcm_executor::{traits::WithOriginFilter, XcmExecutor}; @@ -166,6 +167,8 @@ parameter_types! { pub const MaxInstructions: u32 = 100; pub const MaxAssetsIntoHolding: u32 = 64; pub XcmAssetFeesReceiver: Option = Authorship::author(); + + pub TreasuryAccount: Option = Some(TREASURY_PALLET_ID.into_account_truncating()); } match_types! { @@ -372,6 +375,14 @@ pub type AssetFeeAsExistentialDepositMultiplierFeeCharger = AssetFeeAsExistentia TrustBackedAssetsInstance, >; +match_types! { + pub type RelayOrSystemParachains: impl Contains = { + MultiLocation { parents: 0, interior: X1(Parachain(westend_runtime_constants::system_parachain::WESTMINT_ID | + westend_runtime_constants::system_parachain::COLLECTIVES_ID)) } | + MultiLocation { parents: 1, interior: Here } + }; +} + pub struct XcmConfig; impl xcm_executor::Config for XcmConfig { type RuntimeCall = RuntimeCall; @@ -418,7 +429,7 @@ impl xcm_executor::Config for XcmConfig { type MaxAssetsIntoHolding = MaxAssetsIntoHolding; type AssetLocker = (); type AssetExchanger = (); - type FeeManager = (); + type FeeManager = XcmFeesToAccount; type MessageExporter = (); type UniversalAliases = Nothing; type CallDispatcher = WithOriginFilter; diff --git a/parachains/runtimes/bridge-hubs/bridge-hub-kusama/src/xcm_config.rs b/parachains/runtimes/bridge-hubs/bridge-hub-kusama/src/xcm_config.rs index cfe8662cb7c..62d4e570d49 100644 --- a/parachains/runtimes/bridge-hubs/bridge-hub-kusama/src/xcm_config.rs +++ b/parachains/runtimes/bridge-hubs/bridge-hub-kusama/src/xcm_config.rs @@ -24,11 +24,13 @@ use frame_support::{ }; use frame_system::EnsureRoot; use pallet_xcm::XcmPassthrough; -use parachains_common::xcm_config::{ - ConcreteNativeAssetFrom, DenyReserveTransferToRelayChain, DenyThenTry, +use parachains_common::{ + xcm_config::{ConcreteNativeAssetFrom, DenyReserveTransferToRelayChain, DenyThenTry}, + TREASURY_PALLET_ID, }; use polkadot_parachain::primitives::Sibling; use polkadot_runtime_common::impls::ToAuthor; +use sp_runtime::traits::AccountIdConversion; use xcm::latest::prelude::*; use xcm_builder::{ AccountId32Aliases, AllowExplicitUnpaidExecutionFrom, AllowKnownQueryResponses, @@ -36,7 +38,7 @@ use xcm_builder::{ IsConcrete, ParentAsSuperuser, ParentIsPreset, RelayChainAsNative, SiblingParachainAsNative, SiblingParachainConvertsVia, SignedAccountId32AsNative, SignedToAccountId32, SovereignSignedViaLocation, TakeWeightCredit, UsingComponents, WeightInfoBounds, - WithComputedOrigin, + WithComputedOrigin, XcmFeesToAccount, }; use xcm_executor::{traits::WithOriginFilter, XcmExecutor}; @@ -50,6 +52,7 @@ parameter_types! { pub const MaxAssetsIntoHolding: u32 = 64; pub const GovernanceLocation: MultiLocation = MultiLocation::parent(); pub const FellowshipLocation: MultiLocation = MultiLocation::parent(); + pub TreasuryAccount: Option = Some(TREASURY_PALLET_ID.into_account_truncating()); } /// Type for specifying how a `MultiLocation` can be converted into an `AccountId`. This is used @@ -178,6 +181,14 @@ pub type Barrier = DenyThenTry< ), >; +match_types! { + pub type RelayOrSystemParachains: impl Contains = { + MultiLocation { parents: 0, interior: X1(Parachain(kusama_runtime_constants::system_parachain::STATEMINE_ID | + kusama_runtime_constants::system_parachain::ENCOINTER_ID)) } | + MultiLocation { parents: 1, interior: Here } + }; +} + pub struct XcmConfig; impl xcm_executor::Config for XcmConfig { type RuntimeCall = RuntimeCall; @@ -206,7 +217,7 @@ impl xcm_executor::Config for XcmConfig { type MaxAssetsIntoHolding = MaxAssetsIntoHolding; type AssetLocker = (); type AssetExchanger = (); - type FeeManager = (); + type FeeManager = XcmFeesToAccount; type MessageExporter = (); type UniversalAliases = Nothing; type CallDispatcher = WithOriginFilter; diff --git a/parachains/runtimes/bridge-hubs/bridge-hub-polkadot/src/xcm_config.rs b/parachains/runtimes/bridge-hubs/bridge-hub-polkadot/src/xcm_config.rs index 189e7c74f81..b2666620b94 100644 --- a/parachains/runtimes/bridge-hubs/bridge-hub-polkadot/src/xcm_config.rs +++ b/parachains/runtimes/bridge-hubs/bridge-hub-polkadot/src/xcm_config.rs @@ -24,11 +24,13 @@ use frame_support::{ }; use frame_system::EnsureRoot; use pallet_xcm::XcmPassthrough; -use parachains_common::xcm_config::{ - ConcreteNativeAssetFrom, DenyReserveTransferToRelayChain, DenyThenTry, +use parachains_common::{ + xcm_config::{ConcreteNativeAssetFrom, DenyReserveTransferToRelayChain, DenyThenTry}, + TREASURY_PALLET_ID, }; use polkadot_parachain::primitives::Sibling; use polkadot_runtime_common::impls::ToAuthor; +use sp_runtime::traits::AccountIdConversion; use xcm::latest::prelude::*; use xcm_builder::{ AccountId32Aliases, AllowExplicitUnpaidExecutionFrom, AllowKnownQueryResponses, @@ -36,7 +38,7 @@ use xcm_builder::{ IsConcrete, ParentAsSuperuser, ParentIsPreset, RelayChainAsNative, SiblingParachainAsNative, SiblingParachainConvertsVia, SignedAccountId32AsNative, SignedToAccountId32, SovereignSignedViaLocation, TakeWeightCredit, UsingComponents, WeightInfoBounds, - WithComputedOrigin, + WithComputedOrigin, XcmFeesToAccount, }; use xcm_executor::{traits::WithOriginFilter, XcmExecutor}; @@ -50,6 +52,7 @@ parameter_types! { pub const MaxAssetsIntoHolding: u32 = 64; pub FellowshipLocation: MultiLocation = MultiLocation::new(1, Parachain(1001)); pub const GovernanceLocation: MultiLocation = MultiLocation::parent(); + pub TreasuryAccount: Option = Some(TREASURY_PALLET_ID.into_account_truncating()); } /// Type for specifying how a `MultiLocation` can be converted into an `AccountId`. This is used @@ -178,6 +181,14 @@ pub type Barrier = DenyThenTry< ), >; +match_types! { + pub type RelayOrSystemParachains: impl Contains = { + MultiLocation { parents: 0, interior: X1(Parachain(polkadot_runtime_constants::system_parachain::STATEMINT_ID | + polkadot_runtime_constants::system_parachain::COLLECTIVES_ID)) } | + MultiLocation { parents: 1, interior: Here } + }; +} + pub struct XcmConfig; impl xcm_executor::Config for XcmConfig { type RuntimeCall = RuntimeCall; @@ -206,7 +217,7 @@ impl xcm_executor::Config for XcmConfig { type MaxAssetsIntoHolding = MaxAssetsIntoHolding; type AssetLocker = (); type AssetExchanger = (); - type FeeManager = (); + type FeeManager = XcmFeesToAccount; type MessageExporter = (); type UniversalAliases = Nothing; type CallDispatcher = WithOriginFilter; diff --git a/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/xcm_config.rs b/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/xcm_config.rs index 17ac293c62b..1ed0734b477 100644 --- a/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/xcm_config.rs +++ b/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/xcm_config.rs @@ -24,11 +24,13 @@ use frame_support::{ }; use frame_system::EnsureRoot; use pallet_xcm::XcmPassthrough; -use parachains_common::xcm_config::{ - ConcreteNativeAssetFrom, DenyReserveTransferToRelayChain, DenyThenTry, +use parachains_common::{ + xcm_config::{ConcreteNativeAssetFrom, DenyReserveTransferToRelayChain, DenyThenTry}, + TREASURY_PALLET_ID, }; use polkadot_parachain::primitives::Sibling; use polkadot_runtime_common::impls::ToAuthor; +use sp_runtime::traits::AccountIdConversion; use xcm::latest::prelude::*; use xcm_builder::{ AccountId32Aliases, AllowExplicitUnpaidExecutionFrom, AllowKnownQueryResponses, @@ -36,7 +38,7 @@ use xcm_builder::{ IsConcrete, ParentAsSuperuser, ParentIsPreset, RelayChainAsNative, SiblingParachainAsNative, SiblingParachainConvertsVia, SignedAccountId32AsNative, SignedToAccountId32, SovereignSignedViaLocation, TakeWeightCredit, UsingComponents, WeightInfoBounds, - WithComputedOrigin, + WithComputedOrigin, XcmFeesToAccount, }; use xcm_executor::{traits::WithOriginFilter, XcmExecutor}; @@ -48,6 +50,7 @@ parameter_types! { X2(GlobalConsensus(RelayNetwork::get().unwrap()), Parachain(ParachainInfo::parachain_id().into())); pub const MaxInstructions: u32 = 100; pub const MaxAssetsIntoHolding: u32 = 64; + pub TreasuryAccount: Option = Some(TREASURY_PALLET_ID.into_account_truncating()); } /// Type for specifying how a `MultiLocation` can be converted into an `AccountId`. This is used @@ -176,6 +179,15 @@ pub type Barrier = DenyThenTry< ), >; +match_types! { + pub type RelayOrSystemParachains: impl Contains = { + MultiLocation { parents: 0, interior: X1(Parachain(rococo_runtime_constants::system_parachain::STATEMINE_ID | + rococo_runtime_constants::system_parachain::ENCOINTER_ID | + rococo_runtime_constants::system_parachain::CONTRACTS_ID)) } | + MultiLocation { parents: 1, interior: Here } + }; +} + pub struct XcmConfig; impl xcm_executor::Config for XcmConfig { type RuntimeCall = RuntimeCall; @@ -204,7 +216,7 @@ impl xcm_executor::Config for XcmConfig { type MaxAssetsIntoHolding = MaxAssetsIntoHolding; type AssetLocker = (); type AssetExchanger = (); - type FeeManager = (); + type FeeManager = XcmFeesToAccount; type MessageExporter = (); type UniversalAliases = Nothing; type CallDispatcher = WithOriginFilter; diff --git a/primitives/utility/src/lib.rs b/primitives/utility/src/lib.rs index d3a7c77aed2..041fa67626e 100644 --- a/primitives/utility/src/lib.rs +++ b/primitives/utility/src/lib.rs @@ -288,7 +288,7 @@ impl< &(X1(AccountId32 { network: None, id: receiver.into() }).into()), // We aren't able to track the XCM that initiated the fee deposit, so we create a // fake message hash here - &XcmContext::with_message_hash([0; 32]), + None, ) .is_ok(); From acfe2bda9fa7102af5c211525dd4d7831a97ef3d Mon Sep 17 00:00:00 2001 From: Giles Cope Date: Wed, 5 Apr 2023 15:41:14 +0100 Subject: [PATCH 02/15] should not include self (talking to yourself is the first sign of madness) --- parachains/runtimes/assets/statemine/src/xcm_config.rs | 7 ++++--- parachains/runtimes/assets/statemint/src/xcm_config.rs | 7 ++++--- parachains/runtimes/assets/westmint/src/xcm_config.rs | 7 ++++--- .../bridge-hubs/bridge-hub-kusama/src/xcm_config.rs | 5 +++-- .../bridge-hubs/bridge-hub-polkadot/src/xcm_config.rs | 5 +++-- .../bridge-hubs/bridge-hub-rococo/src/xcm_config.rs | 5 +++-- 6 files changed, 21 insertions(+), 15 deletions(-) diff --git a/parachains/runtimes/assets/statemine/src/xcm_config.rs b/parachains/runtimes/assets/statemine/src/xcm_config.rs index 2cfb8054f6a..2e96e57d708 100644 --- a/parachains/runtimes/assets/statemine/src/xcm_config.rs +++ b/parachains/runtimes/assets/statemine/src/xcm_config.rs @@ -379,8 +379,8 @@ pub type AssetFeeAsExistentialDepositMultiplierFeeCharger = AssetFeeAsExistentia >; match_types! { - pub type RelayOrSystemParachains: impl Contains = { - MultiLocation { parents: 0, interior: X1(Parachain(kusama_runtime_constants::system_parachain::STATEMINE_ID | + pub type RelayOrOtherSystemParachains: impl Contains = { + MultiLocation { parents: 0, interior: X1(Parachain( kusama_runtime_constants::system_parachain::ENCOINTER_ID)) } | MultiLocation { parents: 1, interior: Here } }; @@ -432,7 +432,8 @@ impl xcm_executor::Config for XcmConfig { type MaxAssetsIntoHolding = MaxAssetsIntoHolding; type AssetLocker = (); type AssetExchanger = (); - type FeeManager = XcmFeesToAccount; + type FeeManager = + XcmFeesToAccount; type MessageExporter = (); type UniversalAliases = Nothing; type CallDispatcher = WithOriginFilter; diff --git a/parachains/runtimes/assets/statemint/src/xcm_config.rs b/parachains/runtimes/assets/statemint/src/xcm_config.rs index 198162d4fed..10a46009cfe 100644 --- a/parachains/runtimes/assets/statemint/src/xcm_config.rs +++ b/parachains/runtimes/assets/statemint/src/xcm_config.rs @@ -280,8 +280,8 @@ pub type AssetFeeAsExistentialDepositMultiplierFeeCharger = AssetFeeAsExistentia >; match_types! { - pub type RelayOrSystemParachains: impl Contains = { - MultiLocation { parents: 0, interior: X1(Parachain(polkadot_runtime_constants::system_parachain::STATEMINT_ID | + pub type RelayOrOtherSystemParachains: impl Contains = { + MultiLocation { parents: 0, interior: X1(Parachain( polkadot_runtime_constants::system_parachain::COLLECTIVES_ID)) } | MultiLocation { parents: 1, interior: Here } }; @@ -327,7 +327,8 @@ impl xcm_executor::Config for XcmConfig { type MaxAssetsIntoHolding = MaxAssetsIntoHolding; type AssetLocker = (); type AssetExchanger = (); - type FeeManager = XcmFeesToAccount; + type FeeManager = + XcmFeesToAccount; type MessageExporter = (); type UniversalAliases = Nothing; type CallDispatcher = WithOriginFilter; diff --git a/parachains/runtimes/assets/westmint/src/xcm_config.rs b/parachains/runtimes/assets/westmint/src/xcm_config.rs index 30670251a0a..9b9516cd221 100644 --- a/parachains/runtimes/assets/westmint/src/xcm_config.rs +++ b/parachains/runtimes/assets/westmint/src/xcm_config.rs @@ -376,8 +376,8 @@ pub type AssetFeeAsExistentialDepositMultiplierFeeCharger = AssetFeeAsExistentia >; match_types! { - pub type RelayOrSystemParachains: impl Contains = { - MultiLocation { parents: 0, interior: X1(Parachain(westend_runtime_constants::system_parachain::WESTMINT_ID | + pub type RelayOrOtherSystemParachains: impl Contains = { + MultiLocation { parents: 0, interior: X1(Parachain( westend_runtime_constants::system_parachain::COLLECTIVES_ID)) } | MultiLocation { parents: 1, interior: Here } }; @@ -429,7 +429,8 @@ impl xcm_executor::Config for XcmConfig { type MaxAssetsIntoHolding = MaxAssetsIntoHolding; type AssetLocker = (); type AssetExchanger = (); - type FeeManager = XcmFeesToAccount; + type FeeManager = + XcmFeesToAccount; type MessageExporter = (); type UniversalAliases = Nothing; type CallDispatcher = WithOriginFilter; diff --git a/parachains/runtimes/bridge-hubs/bridge-hub-kusama/src/xcm_config.rs b/parachains/runtimes/bridge-hubs/bridge-hub-kusama/src/xcm_config.rs index 62d4e570d49..9cb16c4223f 100644 --- a/parachains/runtimes/bridge-hubs/bridge-hub-kusama/src/xcm_config.rs +++ b/parachains/runtimes/bridge-hubs/bridge-hub-kusama/src/xcm_config.rs @@ -182,7 +182,7 @@ pub type Barrier = DenyThenTry< >; match_types! { - pub type RelayOrSystemParachains: impl Contains = { + pub type RelayOrOtherSystemParachains: impl Contains = { MultiLocation { parents: 0, interior: X1(Parachain(kusama_runtime_constants::system_parachain::STATEMINE_ID | kusama_runtime_constants::system_parachain::ENCOINTER_ID)) } | MultiLocation { parents: 1, interior: Here } @@ -217,7 +217,8 @@ impl xcm_executor::Config for XcmConfig { type MaxAssetsIntoHolding = MaxAssetsIntoHolding; type AssetLocker = (); type AssetExchanger = (); - type FeeManager = XcmFeesToAccount; + type FeeManager = + XcmFeesToAccount; type MessageExporter = (); type UniversalAliases = Nothing; type CallDispatcher = WithOriginFilter; diff --git a/parachains/runtimes/bridge-hubs/bridge-hub-polkadot/src/xcm_config.rs b/parachains/runtimes/bridge-hubs/bridge-hub-polkadot/src/xcm_config.rs index b2666620b94..c3598a55f18 100644 --- a/parachains/runtimes/bridge-hubs/bridge-hub-polkadot/src/xcm_config.rs +++ b/parachains/runtimes/bridge-hubs/bridge-hub-polkadot/src/xcm_config.rs @@ -182,7 +182,7 @@ pub type Barrier = DenyThenTry< >; match_types! { - pub type RelayOrSystemParachains: impl Contains = { + pub type RelayOrOtherSystemParachains: impl Contains = { MultiLocation { parents: 0, interior: X1(Parachain(polkadot_runtime_constants::system_parachain::STATEMINT_ID | polkadot_runtime_constants::system_parachain::COLLECTIVES_ID)) } | MultiLocation { parents: 1, interior: Here } @@ -217,7 +217,8 @@ impl xcm_executor::Config for XcmConfig { type MaxAssetsIntoHolding = MaxAssetsIntoHolding; type AssetLocker = (); type AssetExchanger = (); - type FeeManager = XcmFeesToAccount; + type FeeManager = + XcmFeesToAccount; type MessageExporter = (); type UniversalAliases = Nothing; type CallDispatcher = WithOriginFilter; diff --git a/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/xcm_config.rs b/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/xcm_config.rs index 1ed0734b477..95647087ffb 100644 --- a/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/xcm_config.rs +++ b/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/xcm_config.rs @@ -180,7 +180,7 @@ pub type Barrier = DenyThenTry< >; match_types! { - pub type RelayOrSystemParachains: impl Contains = { + pub type RelayOrOtherSystemParachains: impl Contains = { MultiLocation { parents: 0, interior: X1(Parachain(rococo_runtime_constants::system_parachain::STATEMINE_ID | rococo_runtime_constants::system_parachain::ENCOINTER_ID | rococo_runtime_constants::system_parachain::CONTRACTS_ID)) } | @@ -216,7 +216,8 @@ impl xcm_executor::Config for XcmConfig { type MaxAssetsIntoHolding = MaxAssetsIntoHolding; type AssetLocker = (); type AssetExchanger = (); - type FeeManager = XcmFeesToAccount; + type FeeManager = + XcmFeesToAccount; type MessageExporter = (); type UniversalAliases = Nothing; type CallDispatcher = WithOriginFilter; From 0b8a88067d44369101b903fb658cad091bf52ee3 Mon Sep 17 00:00:00 2001 From: Giles Cope Date: Wed, 5 Apr 2023 16:16:38 +0100 Subject: [PATCH 03/15] Add collectives and contracts. Contracts rococo was importing kusama constants rather than rococo constants. Have corrected this. --- .../collectives-polkadot/src/xcm_config.rs | 16 +++++++++++++-- .../contracts/contracts-rococo/Cargo.toml | 4 ++-- .../contracts-rococo/src/constants.rs | 2 +- .../contracts-rococo/src/xcm_config.rs | 20 ++++++++++++++++--- 4 files changed, 34 insertions(+), 8 deletions(-) diff --git a/parachains/runtimes/collectives/collectives-polkadot/src/xcm_config.rs b/parachains/runtimes/collectives/collectives-polkadot/src/xcm_config.rs index 3e726b5b4b7..a020ee2806d 100644 --- a/parachains/runtimes/collectives/collectives-polkadot/src/xcm_config.rs +++ b/parachains/runtimes/collectives/collectives-polkadot/src/xcm_config.rs @@ -27,8 +27,10 @@ use pallet_xcm::XcmPassthrough; use parachains_common::{ impls::ToStakingPot, xcm_config::{ConcreteNativeAssetFrom, DenyReserveTransferToRelayChain, DenyThenTry}, + TREASURY_PALLET_ID, }; use polkadot_parachain::primitives::Sibling; +use sp_runtime::traits::AccountIdConversion; use xcm::latest::prelude::*; use xcm_builder::{ AccountId32Aliases, AllowExplicitUnpaidExecutionFrom, AllowKnownQueryResponses, @@ -36,7 +38,7 @@ use xcm_builder::{ FixedWeightBounds, IsConcrete, OriginToPluralityVoice, ParentAsSuperuser, ParentIsPreset, RelayChainAsNative, SiblingParachainAsNative, SiblingParachainConvertsVia, SignedAccountId32AsNative, SignedToAccountId32, SovereignSignedViaLocation, TakeWeightCredit, - UsingComponents, WithComputedOrigin, + UsingComponents, WithComputedOrigin, XcmFeesToAccount, }; use xcm_executor::{traits::WithOriginFilter, XcmExecutor}; @@ -48,6 +50,8 @@ parameter_types! { X2(GlobalConsensus(RelayNetwork::get().unwrap()), Parachain(ParachainInfo::parachain_id().into())); pub CheckingAccount: AccountId = PolkadotXcm::check_account(); pub const GovernanceLocation: MultiLocation = MultiLocation::parent(); + pub TreasuryAccount: Option = Some(TREASURY_PALLET_ID.into_account_truncating()); + } /// Type for specifying how a `MultiLocation` can be converted into an `AccountId`. This is used @@ -217,6 +221,13 @@ pub type Barrier = DenyThenTry< ), >; +match_types! { + pub type RelayOrOtherSystemParachains: impl Contains = { + MultiLocation { parents: 0, interior: X1(Parachain(polkadot_runtime_constants::system_parachain::STATEMINT_ID))} | + MultiLocation { parents: 1, interior: Here } + }; +} + pub struct XcmConfig; impl xcm_executor::Config for XcmConfig { type RuntimeCall = RuntimeCall; @@ -241,7 +252,8 @@ impl xcm_executor::Config for XcmConfig { type MaxAssetsIntoHolding = MaxAssetsIntoHolding; type AssetLocker = (); type AssetExchanger = (); - type FeeManager = (); + type FeeManager = + XcmFeesToAccount; type MessageExporter = (); type UniversalAliases = Nothing; type CallDispatcher = WithOriginFilter; diff --git a/parachains/runtimes/contracts/contracts-rococo/Cargo.toml b/parachains/runtimes/contracts/contracts-rococo/Cargo.toml index 9b5809b3d38..1bab0ea490a 100644 --- a/parachains/runtimes/contracts/contracts-rococo/Cargo.toml +++ b/parachains/runtimes/contracts/contracts-rococo/Cargo.toml @@ -51,7 +51,7 @@ pallet-contracts = { git = "https://github.com/paritytech/substrate", default-fe pallet-contracts-primitives = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "master" } # Polkadot -kusama-runtime-constants = { git = "https://github.com/paritytech/polkadot", default-features = false, branch = "master" } +rococo-runtime-constants = { git = "https://github.com/paritytech/polkadot", default-features = false, branch = "master" } pallet-xcm = { git = "https://github.com/paritytech/polkadot", default-features = false, branch = "master" } polkadot-core-primitives = { git = "https://github.com/paritytech/polkadot", default-features = false, branch = "master" } polkadot-parachain = { git = "https://github.com/paritytech/polkadot", default-features = false, branch = "master" } @@ -86,7 +86,7 @@ std = [ "frame-support/std", "frame-system-rpc-runtime-api/std", "frame-system/std", - "kusama-runtime-constants/std", + "rococo-runtime-constants/std", "pallet-aura/std", "pallet-authorship/std", "pallet-balances/std", diff --git a/parachains/runtimes/contracts/contracts-rococo/src/constants.rs b/parachains/runtimes/contracts/contracts-rococo/src/constants.rs index 4598ddaa264..4601c50732a 100644 --- a/parachains/runtimes/contracts/contracts-rococo/src/constants.rs +++ b/parachains/runtimes/contracts/contracts-rococo/src/constants.rs @@ -14,8 +14,8 @@ // limitations under the License. pub mod currency { - use kusama_runtime_constants as constants; use polkadot_core_primitives::Balance; + use rococo_runtime_constants as constants; /// The existential deposit. Set to 1/10 of its parent Relay Chain. pub const EXISTENTIAL_DEPOSIT: Balance = constants::currency::EXISTENTIAL_DEPOSIT / 10; diff --git a/parachains/runtimes/contracts/contracts-rococo/src/xcm_config.rs b/parachains/runtimes/contracts/contracts-rococo/src/xcm_config.rs index d8ed043fb54..840c1aacaa8 100644 --- a/parachains/runtimes/contracts/contracts-rococo/src/xcm_config.rs +++ b/parachains/runtimes/contracts/contracts-rococo/src/xcm_config.rs @@ -24,8 +24,12 @@ use frame_support::{ }; use frame_system::EnsureRoot; use pallet_xcm::{EnsureXcm, IsMajorityOfBody, XcmPassthrough}; -use parachains_common::xcm_config::{DenyReserveTransferToRelayChain, DenyThenTry}; +use parachains_common::{ + xcm_config::{DenyReserveTransferToRelayChain, DenyThenTry}, + TREASURY_PALLET_ID, +}; use polkadot_parachain::primitives::Sibling; +use sp_runtime::traits::AccountIdConversion; use xcm::latest::prelude::*; use xcm_builder::{ AccountId32Aliases, AllowExplicitUnpaidExecutionFrom, AllowKnownQueryResponses, @@ -33,7 +37,7 @@ use xcm_builder::{ FixedWeightBounds, IsConcrete, NativeAsset, ParentAsSuperuser, ParentIsPreset, RelayChainAsNative, SiblingParachainAsNative, SiblingParachainConvertsVia, SignedAccountId32AsNative, SignedToAccountId32, SovereignSignedViaLocation, TakeWeightCredit, - UsingComponents, WithComputedOrigin, + UsingComponents, WithComputedOrigin, XcmFeesToAccount, }; use xcm_executor::XcmExecutor; @@ -43,6 +47,7 @@ parameter_types! { pub RelayChainOrigin: RuntimeOrigin = cumulus_pallet_xcm::Origin::Relay.into(); pub UniversalLocation: InteriorMultiLocation = Parachain(ParachainInfo::parachain_id().into()).into(); pub const ExecutiveBody: BodyId = BodyId::Executive; + pub TreasuryAccount: Option = Some(TREASURY_PALLET_ID.into_account_truncating()); } /// We allow root and the Relay Chain council to execute privileged collator selection operations. @@ -140,6 +145,14 @@ pub type Barrier = DenyThenTry< ), >; +match_types! { + pub type RelayOrOtherSystemParachains: impl Contains = { + MultiLocation { parents: 0, interior: X1(Parachain(rococo_runtime_constants::system_parachain::STATEMINE_ID | + rococo_runtime_constants::system_parachain::ENCOINTER_ID)) } | + MultiLocation { parents: 1, interior: Here } + }; +} + pub struct XcmConfig; impl xcm_executor::Config for XcmConfig { type RuntimeCall = RuntimeCall; @@ -160,7 +173,8 @@ impl xcm_executor::Config for XcmConfig { type MaxAssetsIntoHolding = ConstU32<8>; type AssetLocker = (); type AssetExchanger = (); - type FeeManager = (); + type FeeManager = + XcmFeesToAccount; type MessageExporter = (); type UniversalAliases = Nothing; type CallDispatcher = RuntimeCall; From a09e954f199a7a0b030b6218e5a3dd39acce7d42 Mon Sep 17 00:00:00 2001 From: Giles Cope Date: Fri, 7 Apr 2023 19:35:50 +0100 Subject: [PATCH 04/15] Less error-prone specifying of system parachains --- Cargo.toml | 4 ++ parachains/common/kusama/Cargo.toml | 41 ++++++++++++++++++ parachains/common/kusama/src/lib.rs | 22 ++++++++++ parachains/common/polkadot/Cargo.toml | 41 ++++++++++++++++++ parachains/common/polkadot/src/lib.rs | 22 ++++++++++ parachains/common/rococo/Cargo.toml | 41 ++++++++++++++++++ parachains/common/rococo/src/lib.rs | 22 ++++++++++ parachains/common/westend/Cargo.toml | 43 +++++++++++++++++++ parachains/common/westend/src/lib.rs | 23 ++++++++++ .../runtimes/assets/statemine/Cargo.toml | 2 + .../assets/statemine/src/xcm_config.rs | 10 +---- .../runtimes/assets/statemint/Cargo.toml | 1 + .../assets/statemint/src/xcm_config.rs | 10 +---- .../runtimes/assets/westmint/Cargo.toml | 1 + .../assets/westmint/src/xcm_config.rs | 10 +---- .../bridge-hubs/bridge-hub-kusama/Cargo.toml | 1 + .../bridge-hub-kusama/src/xcm_config.rs | 10 +---- .../bridge-hub-polkadot/Cargo.toml | 1 + .../bridge-hub-polkadot/src/xcm_config.rs | 10 +---- .../bridge-hubs/bridge-hub-rococo/Cargo.toml | 1 + .../bridge-hub-rococo/src/xcm_config.rs | 11 +---- .../collectives-polkadot/Cargo.toml | 1 + .../collectives-polkadot/src/xcm_config.rs | 9 +--- .../contracts/contracts-rococo/Cargo.toml | 1 + .../contracts-rococo/src/xcm_config.rs | 10 +---- 25 files changed, 276 insertions(+), 72 deletions(-) create mode 100644 parachains/common/kusama/Cargo.toml create mode 100644 parachains/common/kusama/src/lib.rs create mode 100644 parachains/common/polkadot/Cargo.toml create mode 100644 parachains/common/polkadot/src/lib.rs create mode 100644 parachains/common/rococo/Cargo.toml create mode 100644 parachains/common/rococo/src/lib.rs create mode 100644 parachains/common/westend/Cargo.toml create mode 100644 parachains/common/westend/src/lib.rs diff --git a/Cargo.toml b/Cargo.toml index cdcf4730f72..e3b12256dbc 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -30,6 +30,10 @@ members = [ "primitives/utility", "polkadot-parachain", "parachains/common", + "parachains/common/kusama", + "parachains/common/polkadot", + "parachains/common/rococo", + "parachains/common/westend", "parachains/pallets/parachain-info", "parachains/pallets/ping", "parachains/runtimes/testing/rococo-parachain", diff --git a/parachains/common/kusama/Cargo.toml b/parachains/common/kusama/Cargo.toml new file mode 100644 index 00000000000..6f4c32a77c3 --- /dev/null +++ b/parachains/common/kusama/Cargo.toml @@ -0,0 +1,41 @@ +[package] +name = "kusama-common" +version = "0.1.0" +authors = ["Parity Technologies "] +edition = "2021" +description = "Logic which is common to the kusama relay chain" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] +# Substrate +sp-core = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "master" } +frame-support = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "master" } +frame-system = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "master" } +sp-io = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "master" } + +# Polkadot +kusama-runtime-constants = { git = "https://github.com/paritytech/polkadot", default-features = false, branch = "master" } +xcm = { git = "https://github.com/paritytech/polkadot", default-features = false, branch = "master" } + +# Cumulus +parachain-info = { path = "../../pallets/parachain-info", default-features = false } + + +[features] +default = [ "std" ] +runtime-benchmarks = [ + "frame-support/runtime-benchmarks", +] +try-runtime = [ + "parachain-info/try-runtime", +] +std = [ + "sp-core/std", + "frame-support/std", + "frame-system/std", + "kusama-runtime-constants/std", + "xcm/std", + "parachain-info/std", + "sp-io/std", +] diff --git a/parachains/common/kusama/src/lib.rs b/parachains/common/kusama/src/lib.rs new file mode 100644 index 00000000000..50c7d351b26 --- /dev/null +++ b/parachains/common/kusama/src/lib.rs @@ -0,0 +1,22 @@ +#![cfg_attr(not(feature = "std"), no_std)] + +use core::marker::PhantomData; +use sp_core::Get; +use xcm::latest::prelude::*; +use frame_support::traits::Contains; + +pub struct RelayOrOtherSystemParachains { + _runtime: PhantomData +} +impl Contains for RelayOrOtherSystemParachains { + fn contains(l: &MultiLocation) -> bool { + let self_para_id: u32 = parachain_info::Pallet::::get().into(); + if let MultiLocation { parents: 0, interior: X1(Parachain(para_id)) } = l { + if *para_id == self_para_id { + return false + } + } + matches!(l, MultiLocation { parents: 1, interior: Here }) || + kusama_runtime_constants::system_parachain::SystemParachains::contains(l) + } +} \ No newline at end of file diff --git a/parachains/common/polkadot/Cargo.toml b/parachains/common/polkadot/Cargo.toml new file mode 100644 index 00000000000..47ea95c7208 --- /dev/null +++ b/parachains/common/polkadot/Cargo.toml @@ -0,0 +1,41 @@ +[package] +name = "polkadot-common" +version = "0.1.0" +authors = ["Parity Technologies "] +edition = "2021" +description = "Logic which is common to the polkadot relay chain" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] +# Substrate +sp-core = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "master" } +frame-support = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "master" } +frame-system = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "master" } +sp-io = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "master" } + +# Polkadot +polkadot-runtime-constants = { git = "https://github.com/paritytech/polkadot", default-features = false, branch = "master" } +xcm = { git = "https://github.com/paritytech/polkadot", default-features = false, branch = "master" } + +# Cumulus +parachain-info = { path = "../../pallets/parachain-info", default-features = false } + + +[features] +default = [ "std" ] +runtime-benchmarks = [ + "frame-support/runtime-benchmarks", +] +try-runtime = [ + "parachain-info/try-runtime", +] +std = [ + "sp-core/std", + "frame-support/std", + "frame-system/std", + "polkadot-runtime-constants/std", + "xcm/std", + "parachain-info/std", + "sp-io/std", +] diff --git a/parachains/common/polkadot/src/lib.rs b/parachains/common/polkadot/src/lib.rs new file mode 100644 index 00000000000..5f6c55569e6 --- /dev/null +++ b/parachains/common/polkadot/src/lib.rs @@ -0,0 +1,22 @@ +#![cfg_attr(not(feature = "std"), no_std)] + +use core::marker::PhantomData; +use sp_core::Get; +use xcm::latest::prelude::*; +use frame_support::traits::Contains; + +pub struct RelayOrOtherSystemParachains { + _runtime: PhantomData +} +impl Contains for RelayOrOtherSystemParachains { + fn contains(l: &MultiLocation) -> bool { + let self_para_id: u32 = parachain_info::Pallet::::get().into(); + if let MultiLocation { parents: 0, interior: X1(Parachain(para_id)) } = l { + if *para_id == self_para_id { + return false + } + } + matches!(l, MultiLocation { parents: 1, interior: Here }) || + polkadot_runtime_constants::system_parachain::SystemParachains::contains(l) + } +} \ No newline at end of file diff --git a/parachains/common/rococo/Cargo.toml b/parachains/common/rococo/Cargo.toml new file mode 100644 index 00000000000..3db18970b66 --- /dev/null +++ b/parachains/common/rococo/Cargo.toml @@ -0,0 +1,41 @@ +[package] +name = "rococo-common" +version = "0.1.0" +authors = ["Parity Technologies "] +edition = "2021" +description = "Logic which is common to the rococo relay chain" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] +# Substrate +sp-core = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "master" } +frame-support = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "master" } +frame-system = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "master" } +sp-io = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "master" } + +# Polkadot +rococo-runtime-constants = { git = "https://github.com/paritytech/polkadot", default-features = false, branch = "master" } +xcm = { git = "https://github.com/paritytech/polkadot", default-features = false, branch = "master" } + +# Cumulus +parachain-info = { path = "../../pallets/parachain-info", default-features = false } + + +[features] +default = [ "std" ] +runtime-benchmarks = [ + "frame-support/runtime-benchmarks", +] +try-runtime = [ + "parachain-info/try-runtime", +] +std = [ + "sp-core/std", + "frame-support/std", + "frame-system/std", + "rococo-runtime-constants/std", + "xcm/std", + "parachain-info/std", + "sp-io/std", +] diff --git a/parachains/common/rococo/src/lib.rs b/parachains/common/rococo/src/lib.rs new file mode 100644 index 00000000000..d31ccbf1976 --- /dev/null +++ b/parachains/common/rococo/src/lib.rs @@ -0,0 +1,22 @@ +#![cfg_attr(not(feature = "std"), no_std)] + +use core::marker::PhantomData; +use sp_core::Get; +use xcm::latest::prelude::*; +use frame_support::traits::Contains; + +pub struct RelayOrOtherSystemParachains { + _runtime: PhantomData +} +impl Contains for RelayOrOtherSystemParachains { + fn contains(l: &MultiLocation) -> bool { + let self_para_id: u32 = parachain_info::Pallet::::get().into(); + if let MultiLocation { parents: 0, interior: X1(Parachain(para_id)) } = l { + if *para_id == self_para_id { + return false + } + } + matches!(l, MultiLocation { parents: 1, interior: Here }) || + rococo_runtime_constants::system_parachain::SystemParachains::contains(l) + } +} \ No newline at end of file diff --git a/parachains/common/westend/Cargo.toml b/parachains/common/westend/Cargo.toml new file mode 100644 index 00000000000..dd35203b068 --- /dev/null +++ b/parachains/common/westend/Cargo.toml @@ -0,0 +1,43 @@ +[package] +name = "westend-common" +version = "0.1.0" +authors = ["Parity Technologies "] +edition = "2021" +description = "Logic which is common to the westend relay chain" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] +# Substrate +sp-core = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "master" } +frame-support = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "master" } +frame-system = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "master" } +sp-io = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "master" } + +# Polkadot +#TEMP! +polkadot-runtime-constants = { git = "https://github.com/paritytech/polkadot", default-features = false, branch = "master" } +westend-runtime-constants = { git = "https://github.com/paritytech/polkadot", default-features = false, branch = "master" } +xcm = { git = "https://github.com/paritytech/polkadot", default-features = false, branch = "master" } + +# Cumulus +parachain-info = { path = "../../pallets/parachain-info", default-features = false } + + +[features] +default = [ "std" ] +runtime-benchmarks = [ + "frame-support/runtime-benchmarks", +] +try-runtime = [ + "parachain-info/try-runtime", +] +std = [ + "sp-core/std", + "frame-support/std", + "frame-system/std", + "westend-runtime-constants/std", + "xcm/std", + "parachain-info/std", + "sp-io/std", +] diff --git a/parachains/common/westend/src/lib.rs b/parachains/common/westend/src/lib.rs new file mode 100644 index 00000000000..a2f00dc85ae --- /dev/null +++ b/parachains/common/westend/src/lib.rs @@ -0,0 +1,23 @@ +#![cfg_attr(not(feature = "std"), no_std)] + +use core::marker::PhantomData; +use sp_core::Get; +use xcm::latest::prelude::*; +use frame_support::traits::Contains; + +pub struct RelayOrOtherSystemParachains { + _runtime: PhantomData +} +impl Contains for RelayOrOtherSystemParachains { + fn contains(l: &MultiLocation) -> bool { + let self_para_id: u32 = parachain_info::Pallet::::get().into(); + if let MultiLocation { parents: 0, interior: X1(Parachain(para_id)) } = l { + if *para_id == self_para_id { + return false + } + } + //TODO: change this to westend once polkadot PR is updated + matches!(l, MultiLocation { parents: 1, interior: Here }) || + polkadot_runtime_constants::system_parachain::SystemParachains::contains(l) + } +} \ No newline at end of file diff --git a/parachains/runtimes/assets/statemine/Cargo.toml b/parachains/runtimes/assets/statemine/Cargo.toml index 3fdac10c637..ddf60af0967 100644 --- a/parachains/runtimes/assets/statemine/Cargo.toml +++ b/parachains/runtimes/assets/statemine/Cargo.toml @@ -73,6 +73,7 @@ cumulus-primitives-utility = { path = "../../../../primitives/utility", default- pallet-collator-selection = { path = "../../../../pallets/collator-selection", default-features = false } parachain-info = { path = "../../../pallets/parachain-info", default-features = false } parachains-common = { path = "../../../common", default-features = false } +kusama-common = { path = "../../../common/kusama", default-features = false } assets-common = { path = "../common", default-features = false } [dev-dependencies] @@ -195,6 +196,7 @@ std = [ "pallet-collator-selection/std", "parachain-info/std", "parachains-common/std", + "kusama-common/std", "assets-common/std", "substrate-wasm-builder", ] diff --git a/parachains/runtimes/assets/statemine/src/xcm_config.rs b/parachains/runtimes/assets/statemine/src/xcm_config.rs index 2e96e57d708..9b0c56921e4 100644 --- a/parachains/runtimes/assets/statemine/src/xcm_config.rs +++ b/parachains/runtimes/assets/statemine/src/xcm_config.rs @@ -378,13 +378,6 @@ pub type AssetFeeAsExistentialDepositMultiplierFeeCharger = AssetFeeAsExistentia TrustBackedAssetsInstance, >; -match_types! { - pub type RelayOrOtherSystemParachains: impl Contains = { - MultiLocation { parents: 0, interior: X1(Parachain( - kusama_runtime_constants::system_parachain::ENCOINTER_ID)) } | - MultiLocation { parents: 1, interior: Here } - }; -} pub struct XcmConfig; impl xcm_executor::Config for XcmConfig { @@ -432,8 +425,7 @@ impl xcm_executor::Config for XcmConfig { type MaxAssetsIntoHolding = MaxAssetsIntoHolding; type AssetLocker = (); type AssetExchanger = (); - type FeeManager = - XcmFeesToAccount; + type FeeManager = XcmFeesToAccount, AccountId, TreasuryAccount>; type MessageExporter = (); type UniversalAliases = Nothing; type CallDispatcher = WithOriginFilter; diff --git a/parachains/runtimes/assets/statemint/Cargo.toml b/parachains/runtimes/assets/statemint/Cargo.toml index 273c3ff5c2c..93c46036430 100644 --- a/parachains/runtimes/assets/statemint/Cargo.toml +++ b/parachains/runtimes/assets/statemint/Cargo.toml @@ -71,6 +71,7 @@ pallet-collator-selection = { path = "../../../../pallets/collator-selection", d parachain-info = { path = "../../../pallets/parachain-info", default-features = false } parachains-common = { path = "../../../common", default-features = false } assets-common = { path = "../common", default-features = false } +polkadot-common = { path = "../../../common/polkadot", default-features = false } [dev-dependencies] hex-literal = "0.4.0" diff --git a/parachains/runtimes/assets/statemint/src/xcm_config.rs b/parachains/runtimes/assets/statemint/src/xcm_config.rs index 10a46009cfe..1ec18229c4e 100644 --- a/parachains/runtimes/assets/statemint/src/xcm_config.rs +++ b/parachains/runtimes/assets/statemint/src/xcm_config.rs @@ -279,14 +279,6 @@ pub type AssetFeeAsExistentialDepositMultiplierFeeCharger = AssetFeeAsExistentia TrustBackedAssetsInstance, >; -match_types! { - pub type RelayOrOtherSystemParachains: impl Contains = { - MultiLocation { parents: 0, interior: X1(Parachain( - polkadot_runtime_constants::system_parachain::COLLECTIVES_ID)) } | - MultiLocation { parents: 1, interior: Here } - }; -} - pub struct XcmConfig; impl xcm_executor::Config for XcmConfig { type RuntimeCall = RuntimeCall; @@ -328,7 +320,7 @@ impl xcm_executor::Config for XcmConfig { type AssetLocker = (); type AssetExchanger = (); type FeeManager = - XcmFeesToAccount; + XcmFeesToAccount, AccountId, TreasuryAccount>; type MessageExporter = (); type UniversalAliases = Nothing; type CallDispatcher = WithOriginFilter; diff --git a/parachains/runtimes/assets/westmint/Cargo.toml b/parachains/runtimes/assets/westmint/Cargo.toml index 89b59b7def4..ed42e9f9a08 100644 --- a/parachains/runtimes/assets/westmint/Cargo.toml +++ b/parachains/runtimes/assets/westmint/Cargo.toml @@ -72,6 +72,7 @@ pallet-collator-selection = { path = "../../../../pallets/collator-selection", d parachain-info = { path = "../../../pallets/parachain-info", default-features = false } parachains-common = { path = "../../../common", default-features = false } assets-common = { path = "../common", default-features = false } +westend-common = { path = "../../../common/westend", default-features = false } [dev-dependencies] hex-literal = "0.4.0" diff --git a/parachains/runtimes/assets/westmint/src/xcm_config.rs b/parachains/runtimes/assets/westmint/src/xcm_config.rs index 9b9516cd221..b7324137f17 100644 --- a/parachains/runtimes/assets/westmint/src/xcm_config.rs +++ b/parachains/runtimes/assets/westmint/src/xcm_config.rs @@ -375,14 +375,6 @@ pub type AssetFeeAsExistentialDepositMultiplierFeeCharger = AssetFeeAsExistentia TrustBackedAssetsInstance, >; -match_types! { - pub type RelayOrOtherSystemParachains: impl Contains = { - MultiLocation { parents: 0, interior: X1(Parachain( - westend_runtime_constants::system_parachain::COLLECTIVES_ID)) } | - MultiLocation { parents: 1, interior: Here } - }; -} - pub struct XcmConfig; impl xcm_executor::Config for XcmConfig { type RuntimeCall = RuntimeCall; @@ -430,7 +422,7 @@ impl xcm_executor::Config for XcmConfig { type AssetLocker = (); type AssetExchanger = (); type FeeManager = - XcmFeesToAccount; + XcmFeesToAccount, AccountId, TreasuryAccount>; type MessageExporter = (); type UniversalAliases = Nothing; type CallDispatcher = WithOriginFilter; diff --git a/parachains/runtimes/bridge-hubs/bridge-hub-kusama/Cargo.toml b/parachains/runtimes/bridge-hubs/bridge-hub-kusama/Cargo.toml index 9d8703a6ab8..11dc65efe26 100644 --- a/parachains/runtimes/bridge-hubs/bridge-hub-kusama/Cargo.toml +++ b/parachains/runtimes/bridge-hubs/bridge-hub-kusama/Cargo.toml @@ -71,6 +71,7 @@ cumulus-primitives-utility = { path = "../../../../primitives/utility", default- pallet-collator-selection = { path = "../../../../pallets/collator-selection", default-features = false } parachain-info = { path = "../../../../parachains/pallets/parachain-info", default-features = false } parachains-common = { path = "../../../../parachains/common", default-features = false } +kusama-common = { path = "../../../common/kusama", default-features = false } [features] default = [ diff --git a/parachains/runtimes/bridge-hubs/bridge-hub-kusama/src/xcm_config.rs b/parachains/runtimes/bridge-hubs/bridge-hub-kusama/src/xcm_config.rs index 9cb16c4223f..d5c33714523 100644 --- a/parachains/runtimes/bridge-hubs/bridge-hub-kusama/src/xcm_config.rs +++ b/parachains/runtimes/bridge-hubs/bridge-hub-kusama/src/xcm_config.rs @@ -181,14 +181,6 @@ pub type Barrier = DenyThenTry< ), >; -match_types! { - pub type RelayOrOtherSystemParachains: impl Contains = { - MultiLocation { parents: 0, interior: X1(Parachain(kusama_runtime_constants::system_parachain::STATEMINE_ID | - kusama_runtime_constants::system_parachain::ENCOINTER_ID)) } | - MultiLocation { parents: 1, interior: Here } - }; -} - pub struct XcmConfig; impl xcm_executor::Config for XcmConfig { type RuntimeCall = RuntimeCall; @@ -218,7 +210,7 @@ impl xcm_executor::Config for XcmConfig { type AssetLocker = (); type AssetExchanger = (); type FeeManager = - XcmFeesToAccount; + XcmFeesToAccount, AccountId, TreasuryAccount>; type MessageExporter = (); type UniversalAliases = Nothing; type CallDispatcher = WithOriginFilter; diff --git a/parachains/runtimes/bridge-hubs/bridge-hub-polkadot/Cargo.toml b/parachains/runtimes/bridge-hubs/bridge-hub-polkadot/Cargo.toml index 2d00cd9fce3..0203680ee2b 100644 --- a/parachains/runtimes/bridge-hubs/bridge-hub-polkadot/Cargo.toml +++ b/parachains/runtimes/bridge-hubs/bridge-hub-polkadot/Cargo.toml @@ -71,6 +71,7 @@ cumulus-primitives-utility = { path = "../../../../primitives/utility", default- pallet-collator-selection = { path = "../../../../pallets/collator-selection", default-features = false } parachain-info = { path = "../../../../parachains/pallets/parachain-info", default-features = false } parachains-common = { path = "../../../../parachains/common", default-features = false } +polkadot-common = { path = "../../../common/polkadot", default-features = false } [features] default = [ diff --git a/parachains/runtimes/bridge-hubs/bridge-hub-polkadot/src/xcm_config.rs b/parachains/runtimes/bridge-hubs/bridge-hub-polkadot/src/xcm_config.rs index c3598a55f18..86056fe77ce 100644 --- a/parachains/runtimes/bridge-hubs/bridge-hub-polkadot/src/xcm_config.rs +++ b/parachains/runtimes/bridge-hubs/bridge-hub-polkadot/src/xcm_config.rs @@ -181,14 +181,6 @@ pub type Barrier = DenyThenTry< ), >; -match_types! { - pub type RelayOrOtherSystemParachains: impl Contains = { - MultiLocation { parents: 0, interior: X1(Parachain(polkadot_runtime_constants::system_parachain::STATEMINT_ID | - polkadot_runtime_constants::system_parachain::COLLECTIVES_ID)) } | - MultiLocation { parents: 1, interior: Here } - }; -} - pub struct XcmConfig; impl xcm_executor::Config for XcmConfig { type RuntimeCall = RuntimeCall; @@ -218,7 +210,7 @@ impl xcm_executor::Config for XcmConfig { type AssetLocker = (); type AssetExchanger = (); type FeeManager = - XcmFeesToAccount; + XcmFeesToAccount, AccountId, TreasuryAccount>; type MessageExporter = (); type UniversalAliases = Nothing; type CallDispatcher = WithOriginFilter; diff --git a/parachains/runtimes/bridge-hubs/bridge-hub-rococo/Cargo.toml b/parachains/runtimes/bridge-hubs/bridge-hub-rococo/Cargo.toml index 8cc54ac2672..12aba28c480 100644 --- a/parachains/runtimes/bridge-hubs/bridge-hub-rococo/Cargo.toml +++ b/parachains/runtimes/bridge-hubs/bridge-hub-rococo/Cargo.toml @@ -71,6 +71,7 @@ cumulus-primitives-utility = { path = "../../../../primitives/utility", default- pallet-collator-selection = { path = "../../../../pallets/collator-selection", default-features = false } parachain-info = { path = "../../../../parachains/pallets/parachain-info", default-features = false } parachains-common = { path = "../../../../parachains/common", default-features = false } +rococo-common = { path = "../../../common/rococo", default-features = false } [features] default = [ diff --git a/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/xcm_config.rs b/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/xcm_config.rs index 95647087ffb..a88dfb9bf25 100644 --- a/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/xcm_config.rs +++ b/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/xcm_config.rs @@ -179,15 +179,6 @@ pub type Barrier = DenyThenTry< ), >; -match_types! { - pub type RelayOrOtherSystemParachains: impl Contains = { - MultiLocation { parents: 0, interior: X1(Parachain(rococo_runtime_constants::system_parachain::STATEMINE_ID | - rococo_runtime_constants::system_parachain::ENCOINTER_ID | - rococo_runtime_constants::system_parachain::CONTRACTS_ID)) } | - MultiLocation { parents: 1, interior: Here } - }; -} - pub struct XcmConfig; impl xcm_executor::Config for XcmConfig { type RuntimeCall = RuntimeCall; @@ -217,7 +208,7 @@ impl xcm_executor::Config for XcmConfig { type AssetLocker = (); type AssetExchanger = (); type FeeManager = - XcmFeesToAccount; + XcmFeesToAccount, AccountId, TreasuryAccount>; type MessageExporter = (); type UniversalAliases = Nothing; type CallDispatcher = WithOriginFilter; diff --git a/parachains/runtimes/collectives/collectives-polkadot/Cargo.toml b/parachains/runtimes/collectives/collectives-polkadot/Cargo.toml index c0659ffb825..b9b24e0cc21 100644 --- a/parachains/runtimes/collectives/collectives-polkadot/Cargo.toml +++ b/parachains/runtimes/collectives/collectives-polkadot/Cargo.toml @@ -72,6 +72,7 @@ cumulus-primitives-utility = { path = "../../../../primitives/utility", default- pallet-collator-selection = { path = "../../../../pallets/collator-selection", default-features = false } parachain-info = { path = "../../../pallets/parachain-info", default-features = false } parachains-common = { path = "../../../common", default-features = false } +polkadot-common = { path = "../../../common/polkadot", default-features = false } [dev-dependencies] hex-literal = "0.4.0" diff --git a/parachains/runtimes/collectives/collectives-polkadot/src/xcm_config.rs b/parachains/runtimes/collectives/collectives-polkadot/src/xcm_config.rs index a020ee2806d..c722f0c615e 100644 --- a/parachains/runtimes/collectives/collectives-polkadot/src/xcm_config.rs +++ b/parachains/runtimes/collectives/collectives-polkadot/src/xcm_config.rs @@ -221,13 +221,6 @@ pub type Barrier = DenyThenTry< ), >; -match_types! { - pub type RelayOrOtherSystemParachains: impl Contains = { - MultiLocation { parents: 0, interior: X1(Parachain(polkadot_runtime_constants::system_parachain::STATEMINT_ID))} | - MultiLocation { parents: 1, interior: Here } - }; -} - pub struct XcmConfig; impl xcm_executor::Config for XcmConfig { type RuntimeCall = RuntimeCall; @@ -253,7 +246,7 @@ impl xcm_executor::Config for XcmConfig { type AssetLocker = (); type AssetExchanger = (); type FeeManager = - XcmFeesToAccount; + XcmFeesToAccount, AccountId, TreasuryAccount>; type MessageExporter = (); type UniversalAliases = Nothing; type CallDispatcher = WithOriginFilter; diff --git a/parachains/runtimes/contracts/contracts-rococo/Cargo.toml b/parachains/runtimes/contracts/contracts-rococo/Cargo.toml index 1bab0ea490a..c59dbeaf990 100644 --- a/parachains/runtimes/contracts/contracts-rococo/Cargo.toml +++ b/parachains/runtimes/contracts/contracts-rococo/Cargo.toml @@ -73,6 +73,7 @@ cumulus-primitives-utility = { path = "../../../../primitives/utility", default- pallet-collator-selection = { path = "../../../../pallets/collator-selection", default-features = false } parachain-info = { path = "../../../pallets/parachain-info", default-features = false } parachains-common = { path = "../../../common", default-features = false } +rococo-common = { path = "../../../common/rococo", default-features = false } [features] default = [ diff --git a/parachains/runtimes/contracts/contracts-rococo/src/xcm_config.rs b/parachains/runtimes/contracts/contracts-rococo/src/xcm_config.rs index 840c1aacaa8..151a3e42928 100644 --- a/parachains/runtimes/contracts/contracts-rococo/src/xcm_config.rs +++ b/parachains/runtimes/contracts/contracts-rococo/src/xcm_config.rs @@ -145,14 +145,6 @@ pub type Barrier = DenyThenTry< ), >; -match_types! { - pub type RelayOrOtherSystemParachains: impl Contains = { - MultiLocation { parents: 0, interior: X1(Parachain(rococo_runtime_constants::system_parachain::STATEMINE_ID | - rococo_runtime_constants::system_parachain::ENCOINTER_ID)) } | - MultiLocation { parents: 1, interior: Here } - }; -} - pub struct XcmConfig; impl xcm_executor::Config for XcmConfig { type RuntimeCall = RuntimeCall; @@ -174,7 +166,7 @@ impl xcm_executor::Config for XcmConfig { type AssetLocker = (); type AssetExchanger = (); type FeeManager = - XcmFeesToAccount; + XcmFeesToAccount, AccountId, TreasuryAccount>; type MessageExporter = (); type UniversalAliases = Nothing; type CallDispatcher = RuntimeCall; From ac9b0fcd377f290f073ce7c2914601fca74db5fe Mon Sep 17 00:00:00 2001 From: Giles Cope Date: Fri, 7 Apr 2023 19:37:57 +0100 Subject: [PATCH 05/15] cargo fmt --- parachains/common/kusama/src/lib.rs | 10 ++++++---- parachains/common/polkadot/src/lib.rs | 10 ++++++---- parachains/common/rococo/src/lib.rs | 10 ++++++---- parachains/common/westend/src/lib.rs | 10 ++++++---- parachains/runtimes/assets/statemine/src/xcm_config.rs | 8 ++++++-- parachains/runtimes/assets/statemint/src/xcm_config.rs | 8 ++++++-- parachains/runtimes/assets/westmint/src/xcm_config.rs | 8 ++++++-- .../bridge-hubs/bridge-hub-kusama/src/xcm_config.rs | 8 ++++++-- .../bridge-hubs/bridge-hub-polkadot/src/xcm_config.rs | 8 ++++++-- .../bridge-hubs/bridge-hub-rococo/src/xcm_config.rs | 8 ++++++-- .../collectives/collectives-polkadot/src/xcm_config.rs | 8 ++++++-- .../contracts/contracts-rococo/src/xcm_config.rs | 8 ++++++-- 12 files changed, 72 insertions(+), 32 deletions(-) diff --git a/parachains/common/kusama/src/lib.rs b/parachains/common/kusama/src/lib.rs index 50c7d351b26..5b924023b87 100644 --- a/parachains/common/kusama/src/lib.rs +++ b/parachains/common/kusama/src/lib.rs @@ -1,14 +1,16 @@ #![cfg_attr(not(feature = "std"), no_std)] use core::marker::PhantomData; +use frame_support::traits::Contains; use sp_core::Get; use xcm::latest::prelude::*; -use frame_support::traits::Contains; pub struct RelayOrOtherSystemParachains { - _runtime: PhantomData + _runtime: PhantomData, } -impl Contains for RelayOrOtherSystemParachains { +impl Contains + for RelayOrOtherSystemParachains +{ fn contains(l: &MultiLocation) -> bool { let self_para_id: u32 = parachain_info::Pallet::::get().into(); if let MultiLocation { parents: 0, interior: X1(Parachain(para_id)) } = l { @@ -19,4 +21,4 @@ impl Contains for RelayOrOtherS matches!(l, MultiLocation { parents: 1, interior: Here }) || kusama_runtime_constants::system_parachain::SystemParachains::contains(l) } -} \ No newline at end of file +} diff --git a/parachains/common/polkadot/src/lib.rs b/parachains/common/polkadot/src/lib.rs index 5f6c55569e6..e504038f465 100644 --- a/parachains/common/polkadot/src/lib.rs +++ b/parachains/common/polkadot/src/lib.rs @@ -1,14 +1,16 @@ #![cfg_attr(not(feature = "std"), no_std)] use core::marker::PhantomData; +use frame_support::traits::Contains; use sp_core::Get; use xcm::latest::prelude::*; -use frame_support::traits::Contains; pub struct RelayOrOtherSystemParachains { - _runtime: PhantomData + _runtime: PhantomData, } -impl Contains for RelayOrOtherSystemParachains { +impl Contains + for RelayOrOtherSystemParachains +{ fn contains(l: &MultiLocation) -> bool { let self_para_id: u32 = parachain_info::Pallet::::get().into(); if let MultiLocation { parents: 0, interior: X1(Parachain(para_id)) } = l { @@ -19,4 +21,4 @@ impl Contains for RelayOrOtherS matches!(l, MultiLocation { parents: 1, interior: Here }) || polkadot_runtime_constants::system_parachain::SystemParachains::contains(l) } -} \ No newline at end of file +} diff --git a/parachains/common/rococo/src/lib.rs b/parachains/common/rococo/src/lib.rs index d31ccbf1976..23ad78496fb 100644 --- a/parachains/common/rococo/src/lib.rs +++ b/parachains/common/rococo/src/lib.rs @@ -1,14 +1,16 @@ #![cfg_attr(not(feature = "std"), no_std)] use core::marker::PhantomData; +use frame_support::traits::Contains; use sp_core::Get; use xcm::latest::prelude::*; -use frame_support::traits::Contains; pub struct RelayOrOtherSystemParachains { - _runtime: PhantomData + _runtime: PhantomData, } -impl Contains for RelayOrOtherSystemParachains { +impl Contains + for RelayOrOtherSystemParachains +{ fn contains(l: &MultiLocation) -> bool { let self_para_id: u32 = parachain_info::Pallet::::get().into(); if let MultiLocation { parents: 0, interior: X1(Parachain(para_id)) } = l { @@ -19,4 +21,4 @@ impl Contains for RelayOrOtherS matches!(l, MultiLocation { parents: 1, interior: Here }) || rococo_runtime_constants::system_parachain::SystemParachains::contains(l) } -} \ No newline at end of file +} diff --git a/parachains/common/westend/src/lib.rs b/parachains/common/westend/src/lib.rs index a2f00dc85ae..d4fed9a0cc0 100644 --- a/parachains/common/westend/src/lib.rs +++ b/parachains/common/westend/src/lib.rs @@ -1,14 +1,16 @@ #![cfg_attr(not(feature = "std"), no_std)] use core::marker::PhantomData; +use frame_support::traits::Contains; use sp_core::Get; use xcm::latest::prelude::*; -use frame_support::traits::Contains; pub struct RelayOrOtherSystemParachains { - _runtime: PhantomData + _runtime: PhantomData, } -impl Contains for RelayOrOtherSystemParachains { +impl Contains + for RelayOrOtherSystemParachains +{ fn contains(l: &MultiLocation) -> bool { let self_para_id: u32 = parachain_info::Pallet::::get().into(); if let MultiLocation { parents: 0, interior: X1(Parachain(para_id)) } = l { @@ -20,4 +22,4 @@ impl Contains for RelayOrOtherS matches!(l, MultiLocation { parents: 1, interior: Here }) || polkadot_runtime_constants::system_parachain::SystemParachains::contains(l) } -} \ No newline at end of file +} diff --git a/parachains/runtimes/assets/statemine/src/xcm_config.rs b/parachains/runtimes/assets/statemine/src/xcm_config.rs index 9b0c56921e4..845cc5b244f 100644 --- a/parachains/runtimes/assets/statemine/src/xcm_config.rs +++ b/parachains/runtimes/assets/statemine/src/xcm_config.rs @@ -378,7 +378,6 @@ pub type AssetFeeAsExistentialDepositMultiplierFeeCharger = AssetFeeAsExistentia TrustBackedAssetsInstance, >; - pub struct XcmConfig; impl xcm_executor::Config for XcmConfig { type RuntimeCall = RuntimeCall; @@ -425,7 +424,12 @@ impl xcm_executor::Config for XcmConfig { type MaxAssetsIntoHolding = MaxAssetsIntoHolding; type AssetLocker = (); type AssetExchanger = (); - type FeeManager = XcmFeesToAccount, AccountId, TreasuryAccount>; + type FeeManager = XcmFeesToAccount< + Self, + kusama_common::RelayOrOtherSystemParachains, + AccountId, + TreasuryAccount, + >; type MessageExporter = (); type UniversalAliases = Nothing; type CallDispatcher = WithOriginFilter; diff --git a/parachains/runtimes/assets/statemint/src/xcm_config.rs b/parachains/runtimes/assets/statemint/src/xcm_config.rs index 1ec18229c4e..f022127cd40 100644 --- a/parachains/runtimes/assets/statemint/src/xcm_config.rs +++ b/parachains/runtimes/assets/statemint/src/xcm_config.rs @@ -319,8 +319,12 @@ impl xcm_executor::Config for XcmConfig { type MaxAssetsIntoHolding = MaxAssetsIntoHolding; type AssetLocker = (); type AssetExchanger = (); - type FeeManager = - XcmFeesToAccount, AccountId, TreasuryAccount>; + type FeeManager = XcmFeesToAccount< + Self, + polkadot_common::RelayOrOtherSystemParachains, + AccountId, + TreasuryAccount, + >; type MessageExporter = (); type UniversalAliases = Nothing; type CallDispatcher = WithOriginFilter; diff --git a/parachains/runtimes/assets/westmint/src/xcm_config.rs b/parachains/runtimes/assets/westmint/src/xcm_config.rs index b7324137f17..63fa3a1e1a4 100644 --- a/parachains/runtimes/assets/westmint/src/xcm_config.rs +++ b/parachains/runtimes/assets/westmint/src/xcm_config.rs @@ -421,8 +421,12 @@ impl xcm_executor::Config for XcmConfig { type MaxAssetsIntoHolding = MaxAssetsIntoHolding; type AssetLocker = (); type AssetExchanger = (); - type FeeManager = - XcmFeesToAccount, AccountId, TreasuryAccount>; + type FeeManager = XcmFeesToAccount< + Self, + westend_common::RelayOrOtherSystemParachains, + AccountId, + TreasuryAccount, + >; type MessageExporter = (); type UniversalAliases = Nothing; type CallDispatcher = WithOriginFilter; diff --git a/parachains/runtimes/bridge-hubs/bridge-hub-kusama/src/xcm_config.rs b/parachains/runtimes/bridge-hubs/bridge-hub-kusama/src/xcm_config.rs index d5c33714523..5b794525e68 100644 --- a/parachains/runtimes/bridge-hubs/bridge-hub-kusama/src/xcm_config.rs +++ b/parachains/runtimes/bridge-hubs/bridge-hub-kusama/src/xcm_config.rs @@ -209,8 +209,12 @@ impl xcm_executor::Config for XcmConfig { type MaxAssetsIntoHolding = MaxAssetsIntoHolding; type AssetLocker = (); type AssetExchanger = (); - type FeeManager = - XcmFeesToAccount, AccountId, TreasuryAccount>; + type FeeManager = XcmFeesToAccount< + Self, + kusama_common::RelayOrOtherSystemParachains, + AccountId, + TreasuryAccount, + >; type MessageExporter = (); type UniversalAliases = Nothing; type CallDispatcher = WithOriginFilter; diff --git a/parachains/runtimes/bridge-hubs/bridge-hub-polkadot/src/xcm_config.rs b/parachains/runtimes/bridge-hubs/bridge-hub-polkadot/src/xcm_config.rs index 86056fe77ce..6c9359d17fa 100644 --- a/parachains/runtimes/bridge-hubs/bridge-hub-polkadot/src/xcm_config.rs +++ b/parachains/runtimes/bridge-hubs/bridge-hub-polkadot/src/xcm_config.rs @@ -209,8 +209,12 @@ impl xcm_executor::Config for XcmConfig { type MaxAssetsIntoHolding = MaxAssetsIntoHolding; type AssetLocker = (); type AssetExchanger = (); - type FeeManager = - XcmFeesToAccount, AccountId, TreasuryAccount>; + type FeeManager = XcmFeesToAccount< + Self, + polkadot_common::RelayOrOtherSystemParachains, + AccountId, + TreasuryAccount, + >; type MessageExporter = (); type UniversalAliases = Nothing; type CallDispatcher = WithOriginFilter; diff --git a/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/xcm_config.rs b/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/xcm_config.rs index a88dfb9bf25..f5561933825 100644 --- a/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/xcm_config.rs +++ b/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/xcm_config.rs @@ -207,8 +207,12 @@ impl xcm_executor::Config for XcmConfig { type MaxAssetsIntoHolding = MaxAssetsIntoHolding; type AssetLocker = (); type AssetExchanger = (); - type FeeManager = - XcmFeesToAccount, AccountId, TreasuryAccount>; + type FeeManager = XcmFeesToAccount< + Self, + rococo_common::RelayOrOtherSystemParachains, + AccountId, + TreasuryAccount, + >; type MessageExporter = (); type UniversalAliases = Nothing; type CallDispatcher = WithOriginFilter; diff --git a/parachains/runtimes/collectives/collectives-polkadot/src/xcm_config.rs b/parachains/runtimes/collectives/collectives-polkadot/src/xcm_config.rs index c722f0c615e..226fb9558aa 100644 --- a/parachains/runtimes/collectives/collectives-polkadot/src/xcm_config.rs +++ b/parachains/runtimes/collectives/collectives-polkadot/src/xcm_config.rs @@ -245,8 +245,12 @@ impl xcm_executor::Config for XcmConfig { type MaxAssetsIntoHolding = MaxAssetsIntoHolding; type AssetLocker = (); type AssetExchanger = (); - type FeeManager = - XcmFeesToAccount, AccountId, TreasuryAccount>; + type FeeManager = XcmFeesToAccount< + Self, + polkadot_common::RelayOrOtherSystemParachains, + AccountId, + TreasuryAccount, + >; type MessageExporter = (); type UniversalAliases = Nothing; type CallDispatcher = WithOriginFilter; diff --git a/parachains/runtimes/contracts/contracts-rococo/src/xcm_config.rs b/parachains/runtimes/contracts/contracts-rococo/src/xcm_config.rs index 151a3e42928..2229bca74f3 100644 --- a/parachains/runtimes/contracts/contracts-rococo/src/xcm_config.rs +++ b/parachains/runtimes/contracts/contracts-rococo/src/xcm_config.rs @@ -165,8 +165,12 @@ impl xcm_executor::Config for XcmConfig { type MaxAssetsIntoHolding = ConstU32<8>; type AssetLocker = (); type AssetExchanger = (); - type FeeManager = - XcmFeesToAccount, AccountId, TreasuryAccount>; + type FeeManager = XcmFeesToAccount< + Self, + rococo_common::RelayOrOtherSystemParachains, + AccountId, + TreasuryAccount, + >; type MessageExporter = (); type UniversalAliases = Nothing; type CallDispatcher = RuntimeCall; From e459514dffef01011c77ad7bc0f2ef9f6c05f2df Mon Sep 17 00:00:00 2001 From: Giles Cope Date: Fri, 7 Apr 2023 19:45:18 +0100 Subject: [PATCH 06/15] update lock file --- Cargo.lock | 63 +++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 62 insertions(+), 1 deletion(-) diff --git a/Cargo.lock b/Cargo.lock index a9cf1112cb9..645b8017059 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -717,6 +717,7 @@ dependencies = [ "frame-system-rpc-runtime-api", "frame-try-runtime", "hex-literal 0.4.0", + "kusama-common", "kusama-runtime-constants", "log", "pallet-aura", @@ -797,6 +798,7 @@ dependencies = [ "parachain-info", "parachains-common", "parity-scale-codec", + "polkadot-common", "polkadot-core-primitives", "polkadot-parachain", "polkadot-runtime-common", @@ -863,6 +865,7 @@ dependencies = [ "polkadot-core-primitives", "polkadot-parachain", "polkadot-runtime-common", + "rococo-common", "rococo-runtime-constants", "scale-info", "serde", @@ -1306,6 +1309,7 @@ dependencies = [ "parachain-info", "parachains-common", "parity-scale-codec", + "polkadot-common", "polkadot-core-primitives", "polkadot-parachain", "polkadot-runtime-common", @@ -1419,7 +1423,6 @@ dependencies = [ "frame-system-rpc-runtime-api", "frame-try-runtime", "hex-literal 0.4.0", - "kusama-runtime-constants", "log", "pallet-aura", "pallet-authorship", @@ -1442,6 +1445,8 @@ dependencies = [ "polkadot-core-primitives", "polkadot-parachain", "polkadot-runtime-common", + "rococo-common", + "rococo-runtime-constants", "scale-info", "smallvec", "sp-api", @@ -4610,6 +4615,19 @@ version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "67c21572b4949434e4fc1e1978b99c5f77064153c59d998bf13ecd96fb5ecba7" +[[package]] +name = "kusama-common" +version = "0.1.0" +dependencies = [ + "frame-support", + "frame-system", + "kusama-runtime-constants", + "parachain-info", + "sp-core", + "sp-io", + "xcm", +] + [[package]] name = "kusama-runtime" version = "0.9.39" @@ -7941,6 +7959,19 @@ dependencies = [ "tracing-gum", ] +[[package]] +name = "polkadot-common" +version = "0.1.0" +dependencies = [ + "frame-support", + "frame-system", + "parachain-info", + "polkadot-runtime-constants", + "sp-core", + "sp-io", + "xcm", +] + [[package]] name = "polkadot-core-primitives" version = "0.9.39" @@ -9806,6 +9837,19 @@ dependencies = [ "librocksdb-sys", ] +[[package]] +name = "rococo-common" +version = "0.1.0" +dependencies = [ + "frame-support", + "frame-system", + "parachain-info", + "rococo-runtime-constants", + "sp-core", + "sp-io", + "xcm", +] + [[package]] name = "rococo-parachain-runtime" version = "0.1.0" @@ -12662,6 +12706,7 @@ dependencies = [ "frame-system-rpc-runtime-api", "frame-try-runtime", "hex-literal 0.4.0", + "kusama-common", "kusama-runtime-constants", "log", "pallet-asset-tx-payment", @@ -12752,6 +12797,7 @@ dependencies = [ "parachain-info", "parachains-common", "parity-scale-codec", + "polkadot-common", "polkadot-core-primitives", "polkadot-parachain", "polkadot-runtime-common", @@ -14599,6 +14645,20 @@ dependencies = [ "cc", ] +[[package]] +name = "westend-common" +version = "0.1.0" +dependencies = [ + "frame-support", + "frame-system", + "parachain-info", + "polkadot-runtime-constants", + "sp-core", + "sp-io", + "westend-runtime-constants", + "xcm", +] + [[package]] name = "westend-runtime" version = "0.9.39" @@ -14767,6 +14827,7 @@ dependencies = [ "sp-transaction-pool", "sp-version", "substrate-wasm-builder", + "westend-common", "westend-runtime-constants", "xcm", "xcm-builder", From 6b46a4e53f20b1b04d3a5e9553680c4949f62701 Mon Sep 17 00:00:00 2001 From: Giles Cope Date: Fri, 7 Apr 2023 20:01:41 +0100 Subject: [PATCH 07/15] update lock file --- Cargo.lock | 1 - 1 file changed, 1 deletion(-) diff --git a/Cargo.lock b/Cargo.lock index 15106e5e242..829545f8104 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1423,7 +1423,6 @@ dependencies = [ "frame-system-rpc-runtime-api", "frame-try-runtime", "hex-literal 0.4.1", - "kusama-runtime-constants", "log", "pallet-aura", "pallet-authorship", From ef37dc67d06ad0b349e13298fe04b63a59cf4ef1 Mon Sep 17 00:00:00 2001 From: Giles Cope Date: Tue, 18 Apr 2023 16:53:00 +0100 Subject: [PATCH 08/15] No need for per-relay crates --- Cargo.toml | 4 -- parachains/common/Cargo.toml | 1 + parachains/common/kusama/Cargo.toml | 41 ------------------ parachains/common/kusama/src/lib.rs | 24 ----------- parachains/common/polkadot/Cargo.toml | 41 ------------------ parachains/common/polkadot/src/lib.rs | 24 ----------- parachains/common/rococo/Cargo.toml | 41 ------------------ parachains/common/rococo/src/lib.rs | 24 ----------- parachains/common/src/xcm_config.rs | 23 +++++++++- parachains/common/westend/Cargo.toml | 43 ------------------- parachains/common/westend/src/lib.rs | 25 ----------- .../runtimes/assets/statemine/Cargo.toml | 2 - .../assets/statemine/src/xcm_config.rs | 5 ++- .../runtimes/assets/statemint/Cargo.toml | 1 - .../assets/statemint/src/xcm_config.rs | 4 +- .../runtimes/assets/westmint/Cargo.toml | 1 - .../assets/westmint/src/xcm_config.rs | 4 +- .../bridge-hubs/bridge-hub-kusama/Cargo.toml | 1 - .../bridge-hub-kusama/src/xcm_config.rs | 8 +++- .../bridge-hub-polkadot/Cargo.toml | 1 - .../bridge-hub-polkadot/src/xcm_config.rs | 8 +++- .../bridge-hubs/bridge-hub-rococo/Cargo.toml | 1 - .../bridge-hub-rococo/src/xcm_config.rs | 8 +++- .../collectives-polkadot/Cargo.toml | 1 - .../collectives-polkadot/src/xcm_config.rs | 8 +++- .../contracts/contracts-rococo/Cargo.toml | 1 - .../contracts-rococo/src/xcm_config.rs | 5 ++- 27 files changed, 59 insertions(+), 291 deletions(-) delete mode 100644 parachains/common/kusama/Cargo.toml delete mode 100644 parachains/common/kusama/src/lib.rs delete mode 100644 parachains/common/polkadot/Cargo.toml delete mode 100644 parachains/common/polkadot/src/lib.rs delete mode 100644 parachains/common/rococo/Cargo.toml delete mode 100644 parachains/common/rococo/src/lib.rs delete mode 100644 parachains/common/westend/Cargo.toml delete mode 100644 parachains/common/westend/src/lib.rs diff --git a/Cargo.toml b/Cargo.toml index e3b12256dbc..cdcf4730f72 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -30,10 +30,6 @@ members = [ "primitives/utility", "polkadot-parachain", "parachains/common", - "parachains/common/kusama", - "parachains/common/polkadot", - "parachains/common/rococo", - "parachains/common/westend", "parachains/pallets/parachain-info", "parachains/pallets/ping", "parachains/runtimes/testing/rococo-parachain", diff --git a/parachains/common/Cargo.toml b/parachains/common/Cargo.toml index 5898ae3d9ba..b54e2b32a48 100644 --- a/parachains/common/Cargo.toml +++ b/parachains/common/Cargo.toml @@ -34,6 +34,7 @@ xcm-executor = { git = "https://github.com/paritytech/polkadot", default-feature # Cumulus pallet-collator-selection = { path = "../../pallets/collator-selection", default-features = false } cumulus-primitives-utility = { path = "../../primitives/utility", default-features = false } +parachain-info = { path = "../pallets/parachain-info", default-features = false } [dev-dependencies] pallet-authorship = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "master" } diff --git a/parachains/common/kusama/Cargo.toml b/parachains/common/kusama/Cargo.toml deleted file mode 100644 index 6f4c32a77c3..00000000000 --- a/parachains/common/kusama/Cargo.toml +++ /dev/null @@ -1,41 +0,0 @@ -[package] -name = "kusama-common" -version = "0.1.0" -authors = ["Parity Technologies "] -edition = "2021" -description = "Logic which is common to the kusama relay chain" - -# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html - -[dependencies] -# Substrate -sp-core = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "master" } -frame-support = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "master" } -frame-system = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "master" } -sp-io = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "master" } - -# Polkadot -kusama-runtime-constants = { git = "https://github.com/paritytech/polkadot", default-features = false, branch = "master" } -xcm = { git = "https://github.com/paritytech/polkadot", default-features = false, branch = "master" } - -# Cumulus -parachain-info = { path = "../../pallets/parachain-info", default-features = false } - - -[features] -default = [ "std" ] -runtime-benchmarks = [ - "frame-support/runtime-benchmarks", -] -try-runtime = [ - "parachain-info/try-runtime", -] -std = [ - "sp-core/std", - "frame-support/std", - "frame-system/std", - "kusama-runtime-constants/std", - "xcm/std", - "parachain-info/std", - "sp-io/std", -] diff --git a/parachains/common/kusama/src/lib.rs b/parachains/common/kusama/src/lib.rs deleted file mode 100644 index 5b924023b87..00000000000 --- a/parachains/common/kusama/src/lib.rs +++ /dev/null @@ -1,24 +0,0 @@ -#![cfg_attr(not(feature = "std"), no_std)] - -use core::marker::PhantomData; -use frame_support::traits::Contains; -use sp_core::Get; -use xcm::latest::prelude::*; - -pub struct RelayOrOtherSystemParachains { - _runtime: PhantomData, -} -impl Contains - for RelayOrOtherSystemParachains -{ - fn contains(l: &MultiLocation) -> bool { - let self_para_id: u32 = parachain_info::Pallet::::get().into(); - if let MultiLocation { parents: 0, interior: X1(Parachain(para_id)) } = l { - if *para_id == self_para_id { - return false - } - } - matches!(l, MultiLocation { parents: 1, interior: Here }) || - kusama_runtime_constants::system_parachain::SystemParachains::contains(l) - } -} diff --git a/parachains/common/polkadot/Cargo.toml b/parachains/common/polkadot/Cargo.toml deleted file mode 100644 index 47ea95c7208..00000000000 --- a/parachains/common/polkadot/Cargo.toml +++ /dev/null @@ -1,41 +0,0 @@ -[package] -name = "polkadot-common" -version = "0.1.0" -authors = ["Parity Technologies "] -edition = "2021" -description = "Logic which is common to the polkadot relay chain" - -# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html - -[dependencies] -# Substrate -sp-core = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "master" } -frame-support = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "master" } -frame-system = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "master" } -sp-io = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "master" } - -# Polkadot -polkadot-runtime-constants = { git = "https://github.com/paritytech/polkadot", default-features = false, branch = "master" } -xcm = { git = "https://github.com/paritytech/polkadot", default-features = false, branch = "master" } - -# Cumulus -parachain-info = { path = "../../pallets/parachain-info", default-features = false } - - -[features] -default = [ "std" ] -runtime-benchmarks = [ - "frame-support/runtime-benchmarks", -] -try-runtime = [ - "parachain-info/try-runtime", -] -std = [ - "sp-core/std", - "frame-support/std", - "frame-system/std", - "polkadot-runtime-constants/std", - "xcm/std", - "parachain-info/std", - "sp-io/std", -] diff --git a/parachains/common/polkadot/src/lib.rs b/parachains/common/polkadot/src/lib.rs deleted file mode 100644 index e504038f465..00000000000 --- a/parachains/common/polkadot/src/lib.rs +++ /dev/null @@ -1,24 +0,0 @@ -#![cfg_attr(not(feature = "std"), no_std)] - -use core::marker::PhantomData; -use frame_support::traits::Contains; -use sp_core::Get; -use xcm::latest::prelude::*; - -pub struct RelayOrOtherSystemParachains { - _runtime: PhantomData, -} -impl Contains - for RelayOrOtherSystemParachains -{ - fn contains(l: &MultiLocation) -> bool { - let self_para_id: u32 = parachain_info::Pallet::::get().into(); - if let MultiLocation { parents: 0, interior: X1(Parachain(para_id)) } = l { - if *para_id == self_para_id { - return false - } - } - matches!(l, MultiLocation { parents: 1, interior: Here }) || - polkadot_runtime_constants::system_parachain::SystemParachains::contains(l) - } -} diff --git a/parachains/common/rococo/Cargo.toml b/parachains/common/rococo/Cargo.toml deleted file mode 100644 index 3db18970b66..00000000000 --- a/parachains/common/rococo/Cargo.toml +++ /dev/null @@ -1,41 +0,0 @@ -[package] -name = "rococo-common" -version = "0.1.0" -authors = ["Parity Technologies "] -edition = "2021" -description = "Logic which is common to the rococo relay chain" - -# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html - -[dependencies] -# Substrate -sp-core = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "master" } -frame-support = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "master" } -frame-system = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "master" } -sp-io = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "master" } - -# Polkadot -rococo-runtime-constants = { git = "https://github.com/paritytech/polkadot", default-features = false, branch = "master" } -xcm = { git = "https://github.com/paritytech/polkadot", default-features = false, branch = "master" } - -# Cumulus -parachain-info = { path = "../../pallets/parachain-info", default-features = false } - - -[features] -default = [ "std" ] -runtime-benchmarks = [ - "frame-support/runtime-benchmarks", -] -try-runtime = [ - "parachain-info/try-runtime", -] -std = [ - "sp-core/std", - "frame-support/std", - "frame-system/std", - "rococo-runtime-constants/std", - "xcm/std", - "parachain-info/std", - "sp-io/std", -] diff --git a/parachains/common/rococo/src/lib.rs b/parachains/common/rococo/src/lib.rs deleted file mode 100644 index 23ad78496fb..00000000000 --- a/parachains/common/rococo/src/lib.rs +++ /dev/null @@ -1,24 +0,0 @@ -#![cfg_attr(not(feature = "std"), no_std)] - -use core::marker::PhantomData; -use frame_support::traits::Contains; -use sp_core::Get; -use xcm::latest::prelude::*; - -pub struct RelayOrOtherSystemParachains { - _runtime: PhantomData, -} -impl Contains - for RelayOrOtherSystemParachains -{ - fn contains(l: &MultiLocation) -> bool { - let self_para_id: u32 = parachain_info::Pallet::::get().into(); - if let MultiLocation { parents: 0, interior: X1(Parachain(para_id)) } = l { - if *para_id == self_para_id { - return false - } - } - matches!(l, MultiLocation { parents: 1, interior: Here }) || - rococo_runtime_constants::system_parachain::SystemParachains::contains(l) - } -} diff --git a/parachains/common/src/xcm_config.rs b/parachains/common/src/xcm_config.rs index d367fd4d1a1..c177de3abf0 100644 --- a/parachains/common/src/xcm_config.rs +++ b/parachains/common/src/xcm_config.rs @@ -2,7 +2,7 @@ use crate::impls::AccountIdOf; use core::{marker::PhantomData, ops::ControlFlow}; use frame_support::{ log, - traits::{fungibles::Inspect, tokens::ConversionToAssetBalance, ContainsPair}, + traits::{fungibles::Inspect, tokens::ConversionToAssetBalance, Contains, ContainsPair}, weights::Weight, }; use sp_runtime::traits::Get; @@ -134,3 +134,24 @@ impl> ContainsPair matches!(asset.id, Concrete(ref id) if id == origin && origin == &Location::get()) } } + +pub struct RelayOrOtherSystemParachains< + SystemParachainMatcher: Contains, + Runtime: parachain_info::Config, +> { + _runtime: PhantomData<(SystemParachainMatcher, Runtime)>, +} +impl, Runtime: parachain_info::Config> + Contains for RelayOrOtherSystemParachains +{ + fn contains(l: &MultiLocation) -> bool { + let self_para_id: u32 = parachain_info::Pallet::::get().into(); + if let MultiLocation { parents: 0, interior: X1(Parachain(para_id)) } = l { + if *para_id == self_para_id { + return false + } + } + matches!(l, MultiLocation { parents: 1, interior: Here }) || + SystemParachainMatcher::contains(l) + } +} diff --git a/parachains/common/westend/Cargo.toml b/parachains/common/westend/Cargo.toml deleted file mode 100644 index dd35203b068..00000000000 --- a/parachains/common/westend/Cargo.toml +++ /dev/null @@ -1,43 +0,0 @@ -[package] -name = "westend-common" -version = "0.1.0" -authors = ["Parity Technologies "] -edition = "2021" -description = "Logic which is common to the westend relay chain" - -# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html - -[dependencies] -# Substrate -sp-core = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "master" } -frame-support = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "master" } -frame-system = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "master" } -sp-io = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "master" } - -# Polkadot -#TEMP! -polkadot-runtime-constants = { git = "https://github.com/paritytech/polkadot", default-features = false, branch = "master" } -westend-runtime-constants = { git = "https://github.com/paritytech/polkadot", default-features = false, branch = "master" } -xcm = { git = "https://github.com/paritytech/polkadot", default-features = false, branch = "master" } - -# Cumulus -parachain-info = { path = "../../pallets/parachain-info", default-features = false } - - -[features] -default = [ "std" ] -runtime-benchmarks = [ - "frame-support/runtime-benchmarks", -] -try-runtime = [ - "parachain-info/try-runtime", -] -std = [ - "sp-core/std", - "frame-support/std", - "frame-system/std", - "westend-runtime-constants/std", - "xcm/std", - "parachain-info/std", - "sp-io/std", -] diff --git a/parachains/common/westend/src/lib.rs b/parachains/common/westend/src/lib.rs deleted file mode 100644 index d4fed9a0cc0..00000000000 --- a/parachains/common/westend/src/lib.rs +++ /dev/null @@ -1,25 +0,0 @@ -#![cfg_attr(not(feature = "std"), no_std)] - -use core::marker::PhantomData; -use frame_support::traits::Contains; -use sp_core::Get; -use xcm::latest::prelude::*; - -pub struct RelayOrOtherSystemParachains { - _runtime: PhantomData, -} -impl Contains - for RelayOrOtherSystemParachains -{ - fn contains(l: &MultiLocation) -> bool { - let self_para_id: u32 = parachain_info::Pallet::::get().into(); - if let MultiLocation { parents: 0, interior: X1(Parachain(para_id)) } = l { - if *para_id == self_para_id { - return false - } - } - //TODO: change this to westend once polkadot PR is updated - matches!(l, MultiLocation { parents: 1, interior: Here }) || - polkadot_runtime_constants::system_parachain::SystemParachains::contains(l) - } -} diff --git a/parachains/runtimes/assets/statemine/Cargo.toml b/parachains/runtimes/assets/statemine/Cargo.toml index 81353f687c4..8328106fade 100644 --- a/parachains/runtimes/assets/statemine/Cargo.toml +++ b/parachains/runtimes/assets/statemine/Cargo.toml @@ -73,7 +73,6 @@ cumulus-primitives-utility = { path = "../../../../primitives/utility", default- pallet-collator-selection = { path = "../../../../pallets/collator-selection", default-features = false } parachain-info = { path = "../../../pallets/parachain-info", default-features = false } parachains-common = { path = "../../../common", default-features = false } -kusama-common = { path = "../../../common/kusama", default-features = false } assets-common = { path = "../common", default-features = false } [dev-dependencies] @@ -196,7 +195,6 @@ std = [ "pallet-collator-selection/std", "parachain-info/std", "parachains-common/std", - "kusama-common/std", "assets-common/std", "substrate-wasm-builder", ] diff --git a/parachains/runtimes/assets/statemine/src/xcm_config.rs b/parachains/runtimes/assets/statemine/src/xcm_config.rs index 845cc5b244f..b766f7e6a7b 100644 --- a/parachains/runtimes/assets/statemine/src/xcm_config.rs +++ b/parachains/runtimes/assets/statemine/src/xcm_config.rs @@ -35,7 +35,8 @@ use parachains_common::{ }; use xcm_builder::XcmFeesToAccount; -use parachains_common::TREASURY_PALLET_ID; +use kusama_runtime_constants::system_parachain::SystemParachains; +use parachains_common::{xcm_config::RelayOrOtherSystemParachains, TREASURY_PALLET_ID}; use polkadot_parachain::primitives::Sibling; use sp_runtime::traits::{AccountIdConversion, ConvertInto}; use xcm::latest::prelude::*; @@ -426,7 +427,7 @@ impl xcm_executor::Config for XcmConfig { type AssetExchanger = (); type FeeManager = XcmFeesToAccount< Self, - kusama_common::RelayOrOtherSystemParachains, + RelayOrOtherSystemParachains, AccountId, TreasuryAccount, >; diff --git a/parachains/runtimes/assets/statemint/Cargo.toml b/parachains/runtimes/assets/statemint/Cargo.toml index 8b58f10ebae..a5d2841418a 100644 --- a/parachains/runtimes/assets/statemint/Cargo.toml +++ b/parachains/runtimes/assets/statemint/Cargo.toml @@ -71,7 +71,6 @@ pallet-collator-selection = { path = "../../../../pallets/collator-selection", d parachain-info = { path = "../../../pallets/parachain-info", default-features = false } parachains-common = { path = "../../../common", default-features = false } assets-common = { path = "../common", default-features = false } -polkadot-common = { path = "../../../common/polkadot", default-features = false } [dev-dependencies] hex-literal = "0.4.1" diff --git a/parachains/runtimes/assets/statemint/src/xcm_config.rs b/parachains/runtimes/assets/statemint/src/xcm_config.rs index f022127cd40..fcfa713fff9 100644 --- a/parachains/runtimes/assets/statemint/src/xcm_config.rs +++ b/parachains/runtimes/assets/statemint/src/xcm_config.rs @@ -28,10 +28,12 @@ use parachains_common::{ impls::ToStakingPot, xcm_config::{ AssetFeeAsExistentialDepositMultiplier, DenyReserveTransferToRelayChain, DenyThenTry, + RelayOrOtherSystemParachains, }, TREASURY_PALLET_ID, }; use polkadot_parachain::primitives::Sibling; +use polkadot_runtime_constants::system_parachain::SystemParachains; use sp_runtime::traits::{AccountIdConversion, ConvertInto}; use xcm::latest::prelude::*; use xcm_builder::{ @@ -321,7 +323,7 @@ impl xcm_executor::Config for XcmConfig { type AssetExchanger = (); type FeeManager = XcmFeesToAccount< Self, - polkadot_common::RelayOrOtherSystemParachains, + RelayOrOtherSystemParachains, AccountId, TreasuryAccount, >; diff --git a/parachains/runtimes/assets/westmint/Cargo.toml b/parachains/runtimes/assets/westmint/Cargo.toml index 609588b0780..a63353adb4e 100644 --- a/parachains/runtimes/assets/westmint/Cargo.toml +++ b/parachains/runtimes/assets/westmint/Cargo.toml @@ -72,7 +72,6 @@ pallet-collator-selection = { path = "../../../../pallets/collator-selection", d parachain-info = { path = "../../../pallets/parachain-info", default-features = false } parachains-common = { path = "../../../common", default-features = false } assets-common = { path = "../common", default-features = false } -westend-common = { path = "../../../common/westend", default-features = false } [dev-dependencies] hex-literal = "0.4.1" diff --git a/parachains/runtimes/assets/westmint/src/xcm_config.rs b/parachains/runtimes/assets/westmint/src/xcm_config.rs index 63fa3a1e1a4..d0c9cfc7132 100644 --- a/parachains/runtimes/assets/westmint/src/xcm_config.rs +++ b/parachains/runtimes/assets/westmint/src/xcm_config.rs @@ -32,11 +32,13 @@ use parachains_common::{ impls::ToStakingPot, xcm_config::{ AssetFeeAsExistentialDepositMultiplier, DenyReserveTransferToRelayChain, DenyThenTry, + RelayOrOtherSystemParachains, }, TREASURY_PALLET_ID, }; use polkadot_parachain::primitives::Sibling; use sp_runtime::traits::{AccountIdConversion, ConvertInto}; +use westend_runtime_constants::system_parachain::SystemParachains; use xcm::latest::prelude::*; use xcm_builder::{ AccountId32Aliases, AllowExplicitUnpaidExecutionFrom, AllowKnownQueryResponses, @@ -423,7 +425,7 @@ impl xcm_executor::Config for XcmConfig { type AssetExchanger = (); type FeeManager = XcmFeesToAccount< Self, - westend_common::RelayOrOtherSystemParachains, + RelayOrOtherSystemParachains, AccountId, TreasuryAccount, >; diff --git a/parachains/runtimes/bridge-hubs/bridge-hub-kusama/Cargo.toml b/parachains/runtimes/bridge-hubs/bridge-hub-kusama/Cargo.toml index cc089f75445..00a9da0103c 100644 --- a/parachains/runtimes/bridge-hubs/bridge-hub-kusama/Cargo.toml +++ b/parachains/runtimes/bridge-hubs/bridge-hub-kusama/Cargo.toml @@ -71,7 +71,6 @@ cumulus-primitives-utility = { path = "../../../../primitives/utility", default- pallet-collator-selection = { path = "../../../../pallets/collator-selection", default-features = false } parachain-info = { path = "../../../../parachains/pallets/parachain-info", default-features = false } parachains-common = { path = "../../../../parachains/common", default-features = false } -kusama-common = { path = "../../../common/kusama", default-features = false } [features] default = [ diff --git a/parachains/runtimes/bridge-hubs/bridge-hub-kusama/src/xcm_config.rs b/parachains/runtimes/bridge-hubs/bridge-hub-kusama/src/xcm_config.rs index 5b794525e68..cd598d5a4a0 100644 --- a/parachains/runtimes/bridge-hubs/bridge-hub-kusama/src/xcm_config.rs +++ b/parachains/runtimes/bridge-hubs/bridge-hub-kusama/src/xcm_config.rs @@ -23,9 +23,13 @@ use frame_support::{ traits::{ConstU32, Contains, Everything, Nothing}, }; use frame_system::EnsureRoot; +use kusama_runtime_constants::system_parachain::SystemParachains; use pallet_xcm::XcmPassthrough; use parachains_common::{ - xcm_config::{ConcreteNativeAssetFrom, DenyReserveTransferToRelayChain, DenyThenTry}, + xcm_config::{ + ConcreteNativeAssetFrom, DenyReserveTransferToRelayChain, DenyThenTry, + RelayOrOtherSystemParachains, + }, TREASURY_PALLET_ID, }; use polkadot_parachain::primitives::Sibling; @@ -211,7 +215,7 @@ impl xcm_executor::Config for XcmConfig { type AssetExchanger = (); type FeeManager = XcmFeesToAccount< Self, - kusama_common::RelayOrOtherSystemParachains, + RelayOrOtherSystemParachains, AccountId, TreasuryAccount, >; diff --git a/parachains/runtimes/bridge-hubs/bridge-hub-polkadot/Cargo.toml b/parachains/runtimes/bridge-hubs/bridge-hub-polkadot/Cargo.toml index 3a8566742d3..86bb0780027 100644 --- a/parachains/runtimes/bridge-hubs/bridge-hub-polkadot/Cargo.toml +++ b/parachains/runtimes/bridge-hubs/bridge-hub-polkadot/Cargo.toml @@ -71,7 +71,6 @@ cumulus-primitives-utility = { path = "../../../../primitives/utility", default- pallet-collator-selection = { path = "../../../../pallets/collator-selection", default-features = false } parachain-info = { path = "../../../../parachains/pallets/parachain-info", default-features = false } parachains-common = { path = "../../../../parachains/common", default-features = false } -polkadot-common = { path = "../../../common/polkadot", default-features = false } [features] default = [ diff --git a/parachains/runtimes/bridge-hubs/bridge-hub-polkadot/src/xcm_config.rs b/parachains/runtimes/bridge-hubs/bridge-hub-polkadot/src/xcm_config.rs index 6c9359d17fa..fb5b7ba68ce 100644 --- a/parachains/runtimes/bridge-hubs/bridge-hub-polkadot/src/xcm_config.rs +++ b/parachains/runtimes/bridge-hubs/bridge-hub-polkadot/src/xcm_config.rs @@ -25,11 +25,15 @@ use frame_support::{ use frame_system::EnsureRoot; use pallet_xcm::XcmPassthrough; use parachains_common::{ - xcm_config::{ConcreteNativeAssetFrom, DenyReserveTransferToRelayChain, DenyThenTry}, + xcm_config::{ + ConcreteNativeAssetFrom, DenyReserveTransferToRelayChain, DenyThenTry, + RelayOrOtherSystemParachains, + }, TREASURY_PALLET_ID, }; use polkadot_parachain::primitives::Sibling; use polkadot_runtime_common::impls::ToAuthor; +use polkadot_runtime_constants::system_parachain::SystemParachains; use sp_runtime::traits::AccountIdConversion; use xcm::latest::prelude::*; use xcm_builder::{ @@ -211,7 +215,7 @@ impl xcm_executor::Config for XcmConfig { type AssetExchanger = (); type FeeManager = XcmFeesToAccount< Self, - polkadot_common::RelayOrOtherSystemParachains, + RelayOrOtherSystemParachains, AccountId, TreasuryAccount, >; diff --git a/parachains/runtimes/bridge-hubs/bridge-hub-rococo/Cargo.toml b/parachains/runtimes/bridge-hubs/bridge-hub-rococo/Cargo.toml index 9aa30ad6f7f..2efdcfd8263 100644 --- a/parachains/runtimes/bridge-hubs/bridge-hub-rococo/Cargo.toml +++ b/parachains/runtimes/bridge-hubs/bridge-hub-rococo/Cargo.toml @@ -71,7 +71,6 @@ cumulus-primitives-utility = { path = "../../../../primitives/utility", default- pallet-collator-selection = { path = "../../../../pallets/collator-selection", default-features = false } parachain-info = { path = "../../../../parachains/pallets/parachain-info", default-features = false } parachains-common = { path = "../../../../parachains/common", default-features = false } -rococo-common = { path = "../../../common/rococo", default-features = false } [features] default = [ diff --git a/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/xcm_config.rs b/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/xcm_config.rs index f5561933825..c5a5b596102 100644 --- a/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/xcm_config.rs +++ b/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/xcm_config.rs @@ -25,11 +25,15 @@ use frame_support::{ use frame_system::EnsureRoot; use pallet_xcm::XcmPassthrough; use parachains_common::{ - xcm_config::{ConcreteNativeAssetFrom, DenyReserveTransferToRelayChain, DenyThenTry}, + xcm_config::{ + ConcreteNativeAssetFrom, DenyReserveTransferToRelayChain, DenyThenTry, + RelayOrOtherSystemParachains, + }, TREASURY_PALLET_ID, }; use polkadot_parachain::primitives::Sibling; use polkadot_runtime_common::impls::ToAuthor; +use rococo_runtime_constants::system_parachain::SystemParachains; use sp_runtime::traits::AccountIdConversion; use xcm::latest::prelude::*; use xcm_builder::{ @@ -209,7 +213,7 @@ impl xcm_executor::Config for XcmConfig { type AssetExchanger = (); type FeeManager = XcmFeesToAccount< Self, - rococo_common::RelayOrOtherSystemParachains, + RelayOrOtherSystemParachains, AccountId, TreasuryAccount, >; diff --git a/parachains/runtimes/collectives/collectives-polkadot/Cargo.toml b/parachains/runtimes/collectives/collectives-polkadot/Cargo.toml index 4d8f9682a61..3f5c956d454 100644 --- a/parachains/runtimes/collectives/collectives-polkadot/Cargo.toml +++ b/parachains/runtimes/collectives/collectives-polkadot/Cargo.toml @@ -72,7 +72,6 @@ cumulus-primitives-utility = { path = "../../../../primitives/utility", default- pallet-collator-selection = { path = "../../../../pallets/collator-selection", default-features = false } parachain-info = { path = "../../../pallets/parachain-info", default-features = false } parachains-common = { path = "../../../common", default-features = false } -polkadot-common = { path = "../../../common/polkadot", default-features = false } [build-dependencies] substrate-wasm-builder = { git = "https://github.com/paritytech/substrate", branch = "master", optional = true } diff --git a/parachains/runtimes/collectives/collectives-polkadot/src/xcm_config.rs b/parachains/runtimes/collectives/collectives-polkadot/src/xcm_config.rs index 699bca8f20e..82e4ba44800 100644 --- a/parachains/runtimes/collectives/collectives-polkadot/src/xcm_config.rs +++ b/parachains/runtimes/collectives/collectives-polkadot/src/xcm_config.rs @@ -26,10 +26,14 @@ use frame_system::EnsureRoot; use pallet_xcm::XcmPassthrough; use parachains_common::{ impls::ToStakingPot, - xcm_config::{ConcreteNativeAssetFrom, DenyReserveTransferToRelayChain, DenyThenTry}, + xcm_config::{ + ConcreteNativeAssetFrom, DenyReserveTransferToRelayChain, DenyThenTry, + RelayOrOtherSystemParachains, + }, TREASURY_PALLET_ID, }; use polkadot_parachain::primitives::Sibling; +use polkadot_runtime_constants::system_parachain::SystemParachains; use sp_runtime::traits::AccountIdConversion; use xcm::latest::prelude::*; use xcm_builder::{ @@ -245,7 +249,7 @@ impl xcm_executor::Config for XcmConfig { type AssetExchanger = (); type FeeManager = XcmFeesToAccount< Self, - polkadot_common::RelayOrOtherSystemParachains, + RelayOrOtherSystemParachains, AccountId, TreasuryAccount, >; diff --git a/parachains/runtimes/contracts/contracts-rococo/Cargo.toml b/parachains/runtimes/contracts/contracts-rococo/Cargo.toml index e54b4254257..9a6e159a1bc 100644 --- a/parachains/runtimes/contracts/contracts-rococo/Cargo.toml +++ b/parachains/runtimes/contracts/contracts-rococo/Cargo.toml @@ -73,7 +73,6 @@ cumulus-primitives-utility = { path = "../../../../primitives/utility", default- pallet-collator-selection = { path = "../../../../pallets/collator-selection", default-features = false } parachain-info = { path = "../../../pallets/parachain-info", default-features = false } parachains-common = { path = "../../../common", default-features = false } -rococo-common = { path = "../../../common/rococo", default-features = false } [features] default = [ diff --git a/parachains/runtimes/contracts/contracts-rococo/src/xcm_config.rs b/parachains/runtimes/contracts/contracts-rococo/src/xcm_config.rs index 2229bca74f3..3ccdb45595b 100644 --- a/parachains/runtimes/contracts/contracts-rococo/src/xcm_config.rs +++ b/parachains/runtimes/contracts/contracts-rococo/src/xcm_config.rs @@ -25,10 +25,11 @@ use frame_support::{ use frame_system::EnsureRoot; use pallet_xcm::{EnsureXcm, IsMajorityOfBody, XcmPassthrough}; use parachains_common::{ - xcm_config::{DenyReserveTransferToRelayChain, DenyThenTry}, + xcm_config::{DenyReserveTransferToRelayChain, DenyThenTry, RelayOrOtherSystemParachains}, TREASURY_PALLET_ID, }; use polkadot_parachain::primitives::Sibling; +use rococo_runtime_constants::system_parachain::SystemParachains; use sp_runtime::traits::AccountIdConversion; use xcm::latest::prelude::*; use xcm_builder::{ @@ -167,7 +168,7 @@ impl xcm_executor::Config for XcmConfig { type AssetExchanger = (); type FeeManager = XcmFeesToAccount< Self, - rococo_common::RelayOrOtherSystemParachains, + RelayOrOtherSystemParachains, AccountId, TreasuryAccount, >; From e27bb1cd7c0e4792416e42a0f1c5fb567f4b662d Mon Sep 17 00:00:00 2001 From: Giles Cope Date: Tue, 18 Apr 2023 16:59:56 +0100 Subject: [PATCH 09/15] update lock file --- Cargo.lock | 62 +----------------------------------------------------- 1 file changed, 1 insertion(+), 61 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 070e5e907f5..3b67a0c32ae 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -724,7 +724,6 @@ dependencies = [ "frame-system-rpc-runtime-api", "frame-try-runtime", "hex-literal 0.4.1", - "kusama-common", "kusama-runtime-constants", "log", "pallet-aura", @@ -805,7 +804,6 @@ dependencies = [ "parachain-info", "parachains-common", "parity-scale-codec", - "polkadot-common", "polkadot-core-primitives", "polkadot-parachain", "polkadot-runtime-common", @@ -872,7 +870,6 @@ dependencies = [ "polkadot-core-primitives", "polkadot-parachain", "polkadot-runtime-common", - "rococo-common", "rococo-runtime-constants", "scale-info", "serde", @@ -1316,7 +1313,6 @@ dependencies = [ "parachain-info", "parachains-common", "parity-scale-codec", - "polkadot-common", "polkadot-core-primitives", "polkadot-parachain", "polkadot-runtime-common", @@ -1453,7 +1449,6 @@ dependencies = [ "polkadot-core-primitives", "polkadot-parachain", "polkadot-runtime-common", - "rococo-common", "rococo-runtime-constants", "scale-info", "smallvec", @@ -4640,19 +4635,6 @@ version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "67c21572b4949434e4fc1e1978b99c5f77064153c59d998bf13ecd96fb5ecba7" -[[package]] -name = "kusama-common" -version = "0.1.0" -dependencies = [ - "frame-support", - "frame-system", - "kusama-runtime-constants", - "parachain-info", - "sp-core", - "sp-io", - "xcm", -] - [[package]] name = "kusama-runtime" version = "0.9.41" @@ -7420,6 +7402,7 @@ dependencies = [ "pallet-authorship", "pallet-balances", "pallet-collator-selection", + "parachain-info", "parity-scale-codec", "polkadot-primitives", "scale-info", @@ -7984,19 +7967,6 @@ dependencies = [ "tracing-gum", ] -[[package]] -name = "polkadot-common" -version = "0.1.0" -dependencies = [ - "frame-support", - "frame-system", - "parachain-info", - "polkadot-runtime-constants", - "sp-core", - "sp-io", - "xcm", -] - [[package]] name = "polkadot-core-primitives" version = "0.9.41" @@ -9873,19 +9843,6 @@ dependencies = [ "librocksdb-sys", ] -[[package]] -name = "rococo-common" -version = "0.1.0" -dependencies = [ - "frame-support", - "frame-system", - "parachain-info", - "rococo-runtime-constants", - "sp-core", - "sp-io", - "xcm", -] - [[package]] name = "rococo-parachain-runtime" version = "0.1.0" @@ -12755,7 +12712,6 @@ dependencies = [ "frame-system-rpc-runtime-api", "frame-try-runtime", "hex-literal 0.4.1", - "kusama-common", "kusama-runtime-constants", "log", "pallet-asset-tx-payment", @@ -12846,7 +12802,6 @@ dependencies = [ "parachain-info", "parachains-common", "parity-scale-codec", - "polkadot-common", "polkadot-core-primitives", "polkadot-parachain", "polkadot-runtime-common", @@ -14694,20 +14649,6 @@ dependencies = [ "cc", ] -[[package]] -name = "westend-common" -version = "0.1.0" -dependencies = [ - "frame-support", - "frame-system", - "parachain-info", - "polkadot-runtime-constants", - "sp-core", - "sp-io", - "westend-runtime-constants", - "xcm", -] - [[package]] name = "westend-runtime" version = "0.9.41" @@ -14876,7 +14817,6 @@ dependencies = [ "sp-transaction-pool", "sp-version", "substrate-wasm-builder", - "westend-common", "westend-runtime-constants", "xcm", "xcm-builder", From b1d0095e0ff9e52e18015bd4deba16e5004070e3 Mon Sep 17 00:00:00 2001 From: Giles Cope Date: Thu, 4 May 2023 11:04:39 +0100 Subject: [PATCH 10/15] cargo fmt --- parachains/common/src/xcm_config.rs | 3 ++- .../bridge-hubs/bridge-hub-rococo/src/xcm_config.rs | 12 ++++++------ 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/parachains/common/src/xcm_config.rs b/parachains/common/src/xcm_config.rs index 8cbda2bbf63..67a68e2035b 100644 --- a/parachains/common/src/xcm_config.rs +++ b/parachains/common/src/xcm_config.rs @@ -3,7 +3,8 @@ use core::{marker::PhantomData, ops::ControlFlow}; use frame_support::{ log, traits::{ - fungibles::Inspect, tokens::ConversionToAssetBalance, Contains, ContainsPair, ProcessMessageError, + fungibles::Inspect, tokens::ConversionToAssetBalance, Contains, ContainsPair, + ProcessMessageError, }, weights::Weight, }; diff --git a/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/xcm_config.rs b/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/xcm_config.rs index 499484c3b5c..6250fbbfd76 100644 --- a/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/xcm_config.rs +++ b/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/xcm_config.rs @@ -39,16 +39,16 @@ use parachains_common::{ }; use polkadot_parachain::primitives::Sibling; use rococo_runtime_constants::system_parachain::SystemParachains; -use sp_runtime::traits::AccountIdConversion; use sp_core::Get; +use sp_runtime::traits::AccountIdConversion; use xcm::latest::prelude::*; use xcm_builder::{ AccountId32Aliases, AllowExplicitUnpaidExecutionFrom, AllowKnownQueryResponses, - AllowSubscriptionsFrom, AllowTopLevelPaidExecutionFrom, AllowUnpaidExecutionFRom, CurrencyAdapter, EnsureXcmOrigin, - IsConcrete, ParentAsSuperuser, ParentIsPreset, RelayChainAsNative, SiblingParachainAsNative, - SiblingParachainConvertsVia, SignedAccountId32AsNative, SignedToAccountId32, - SovereignSignedViaLocation, TakeWeightCredit, UsingComponents, WeightInfoBounds, - WithComputedOrigin, XcmFeesToAccount, + AllowSubscriptionsFrom, AllowTopLevelPaidExecutionFrom, AllowUnpaidExecutionFRom, + CurrencyAdapter, EnsureXcmOrigin, IsConcrete, ParentAsSuperuser, ParentIsPreset, + RelayChainAsNative, SiblingParachainAsNative, SiblingParachainConvertsVia, + SignedAccountId32AsNative, SignedToAccountId32, SovereignSignedViaLocation, TakeWeightCredit, + UsingComponents, WeightInfoBounds, WithComputedOrigin, XcmFeesToAccount, }; use xcm_executor::{ traits::{ExportXcm, WithOriginFilter}, From dc3ed544683470e738685d6efd4a8a4a648998ba Mon Sep 17 00:00:00 2001 From: Giles Cope Date: Thu, 4 May 2023 14:12:13 +0100 Subject: [PATCH 11/15] fix typo --- .../runtimes/bridge-hubs/bridge-hub-rococo/src/xcm_config.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/xcm_config.rs b/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/xcm_config.rs index 6250fbbfd76..c93288eb4fb 100644 --- a/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/xcm_config.rs +++ b/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/xcm_config.rs @@ -44,7 +44,7 @@ use sp_runtime::traits::AccountIdConversion; use xcm::latest::prelude::*; use xcm_builder::{ AccountId32Aliases, AllowExplicitUnpaidExecutionFrom, AllowKnownQueryResponses, - AllowSubscriptionsFrom, AllowTopLevelPaidExecutionFrom, AllowUnpaidExecutionFRom, + AllowSubscriptionsFrom, AllowTopLevelPaidExecutionFrom, AllowUnpaidExecutionFrom, CurrencyAdapter, EnsureXcmOrigin, IsConcrete, ParentAsSuperuser, ParentIsPreset, RelayChainAsNative, SiblingParachainAsNative, SiblingParachainConvertsVia, SignedAccountId32AsNative, SignedToAccountId32, SovereignSignedViaLocation, TakeWeightCredit, From c09ce6046e5e795628c008d93326c5f13dda7d0b Mon Sep 17 00:00:00 2001 From: joepetrowski Date: Tue, 4 Jul 2023 09:11:08 +0200 Subject: [PATCH 12/15] some --- primitives/utility/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/primitives/utility/src/lib.rs b/primitives/utility/src/lib.rs index f2488b83a51..615b0127337 100644 --- a/primitives/utility/src/lib.rs +++ b/primitives/utility/src/lib.rs @@ -288,7 +288,7 @@ impl< &(X1(AccountId32 { network: None, id: receiver.into() }).into()), // We aren't able to track the XCM that initiated the fee deposit, so we create a // fake message hash here - &XcmContext::with_message_id([0; 32]), + Some(&XcmContext::with_message_id([0; 32])), ) .is_ok(); From abd2114f29fb0ecd259cca5607e5e6843fe35e82 Mon Sep 17 00:00:00 2001 From: joepetrowski Date: Tue, 4 Jul 2023 09:58:10 +0200 Subject: [PATCH 13/15] remove conflicting import --- .../runtimes/contracts/contracts-rococo/src/xcm_config.rs | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/parachains/runtimes/contracts/contracts-rococo/src/xcm_config.rs b/parachains/runtimes/contracts/contracts-rococo/src/xcm_config.rs index 5b5ccd5599f..3d4d4fa48d1 100644 --- a/parachains/runtimes/contracts/contracts-rococo/src/xcm_config.rs +++ b/parachains/runtimes/contracts/contracts-rococo/src/xcm_config.rs @@ -24,10 +24,7 @@ use frame_support::{ }; use frame_system::EnsureRoot; use pallet_xcm::{EnsureXcm, IsMajorityOfBody, XcmPassthrough}; -use parachains_common::{ - xcm_config::{DenyReserveTransferToRelayChain, DenyThenTry, RelayOrOtherSystemParachains}, - TREASURY_PALLET_ID, -}; +use parachains_common::{xcm_config::RelayOrOtherSystemParachains, TREASURY_PALLET_ID}; use polkadot_parachain::primitives::Sibling; use rococo_runtime_constants::system_parachain::SystemParachains; use sp_runtime::traits::AccountIdConversion; From d915244a4caacde4e81634bdcd6103683d815d29 Mon Sep 17 00:00:00 2001 From: Branislav Kontur Date: Tue, 8 Aug 2023 11:44:38 +0200 Subject: [PATCH 14/15] Fix to compile --- parachains/common/src/xcm_config.rs | 5 +- .../assets/asset-hub-kusama/src/xcm_config.rs | 7 +- .../asset-hub-polkadot/src/xcm_config.rs | 7 +- .../assets/statemint/src/xcm_config.rs | 390 ------------------ .../bridge-hub-kusama/src/xcm_config.rs | 5 +- .../bridge-hub-rococo/src/xcm_config.rs | 7 +- .../collectives-polkadot/src/xcm_config.rs | 5 +- 7 files changed, 10 insertions(+), 416 deletions(-) delete mode 100644 parachains/runtimes/assets/statemint/src/xcm_config.rs diff --git a/parachains/common/src/xcm_config.rs b/parachains/common/src/xcm_config.rs index 8fb502213da..884385173c7 100644 --- a/parachains/common/src/xcm_config.rs +++ b/parachains/common/src/xcm_config.rs @@ -2,10 +2,7 @@ use crate::impls::AccountIdOf; use core::marker::PhantomData; use frame_support::{ log, - traits::{ - fungibles::Inspect, tokens::ConversionToAssetBalance, Contains, ContainsPair, - ProcessMessageError, - }, + traits::{fungibles::Inspect, tokens::ConversionToAssetBalance, Contains, ContainsPair}, weights::Weight, }; use sp_runtime::traits::Get; diff --git a/parachains/runtimes/assets/asset-hub-kusama/src/xcm_config.rs b/parachains/runtimes/assets/asset-hub-kusama/src/xcm_config.rs index 6105043f33d..3e6d34c4b67 100644 --- a/parachains/runtimes/assets/asset-hub-kusama/src/xcm_config.rs +++ b/parachains/runtimes/assets/asset-hub-kusama/src/xcm_config.rs @@ -27,12 +27,7 @@ use frame_support::{ }; use frame_system::EnsureRoot; use pallet_xcm::XcmPassthrough; -use parachains_common::{ - impls::ToStakingPot, - xcm_config::{ - AssetFeeAsExistentialDepositMultiplier, DenyReserveTransferToRelayChain, DenyThenTry, - }, -}; +use parachains_common::{impls::ToStakingPot, xcm_config::AssetFeeAsExistentialDepositMultiplier}; use xcm_builder::XcmFeesToAccount; use kusama_runtime_constants::system_parachain::SystemParachains; diff --git a/parachains/runtimes/assets/asset-hub-polkadot/src/xcm_config.rs b/parachains/runtimes/assets/asset-hub-polkadot/src/xcm_config.rs index 8dc446f717f..90deb887087 100644 --- a/parachains/runtimes/assets/asset-hub-polkadot/src/xcm_config.rs +++ b/parachains/runtimes/assets/asset-hub-polkadot/src/xcm_config.rs @@ -29,15 +29,12 @@ use frame_system::EnsureRoot; use pallet_xcm::XcmPassthrough; use parachains_common::{ impls::ToStakingPot, - xcm_config::{ - AssetFeeAsExistentialDepositMultiplier, DenyReserveTransferToRelayChain, DenyThenTry, - RelayOrOtherSystemParachains, - }, + xcm_config::{AssetFeeAsExistentialDepositMultiplier, RelayOrOtherSystemParachains}, TREASURY_PALLET_ID, }; use polkadot_parachain::primitives::Sibling; use sp_runtime::traits::{AccountIdConversion, ConvertInto}; -use westend_runtime_constants::system_parachain::SystemParachains; +use polkadot_runtime_constants::system_parachain::SystemParachains; use xcm::latest::prelude::*; use xcm_builder::{ AccountId32Aliases, AllowExplicitUnpaidExecutionFrom, AllowKnownQueryResponses, diff --git a/parachains/runtimes/assets/statemint/src/xcm_config.rs b/parachains/runtimes/assets/statemint/src/xcm_config.rs deleted file mode 100644 index 2fced7a40c0..00000000000 --- a/parachains/runtimes/assets/statemint/src/xcm_config.rs +++ /dev/null @@ -1,390 +0,0 @@ -// Copyright (C) 2022 Parity Technologies (UK) Ltd. -// SPDX-License-Identifier: Apache-2.0 - -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -use super::{ - AccountId, AllPalletsWithSystem, Assets, Authorship, Balance, Balances, ParachainInfo, - ParachainSystem, PolkadotXcm, Runtime, RuntimeCall, RuntimeEvent, RuntimeOrigin, - TrustBackedAssetsInstance, WeightToFee, XcmpQueue, -}; -use frame_support::{ - match_types, parameter_types, - traits::{ConstU32, Contains, Everything, Nothing, PalletInfoAccess}, -}; -use frame_system::EnsureRoot; -use pallet_xcm::XcmPassthrough; -use parachains_common::{ - impls::ToStakingPot, - xcm_config::{ - AssetFeeAsExistentialDepositMultiplier, DenyReserveTransferToRelayChain, DenyThenTry, - RelayOrOtherSystemParachains, - }, - TREASURY_PALLET_ID, -}; -use polkadot_parachain::primitives::Sibling; -use polkadot_runtime_constants::system_parachain::SystemParachains; -use sp_runtime::traits::{AccountIdConversion, ConvertInto}; -use xcm::latest::prelude::*; -use xcm_builder::{ - AccountId32Aliases, AllowExplicitUnpaidExecutionFrom, AllowKnownQueryResponses, - AllowSubscriptionsFrom, AllowTopLevelPaidExecutionFrom, CurrencyAdapter, EnsureXcmOrigin, - FungiblesAdapter, IsConcrete, LocalMint, NativeAsset, ParentAsSuperuser, ParentIsPreset, - RelayChainAsNative, SiblingParachainAsNative, SiblingParachainConvertsVia, - SignedAccountId32AsNative, SignedToAccountId32, SovereignSignedViaLocation, TakeWeightCredit, - UsingComponents, WeightInfoBounds, WithComputedOrigin, XcmFeesToAccount, -}; -use xcm_executor::{traits::WithOriginFilter, XcmExecutor}; - -parameter_types! { - pub const DotLocation: MultiLocation = MultiLocation::parent(); - pub const RelayNetwork: Option = Some(NetworkId::Polkadot); - pub RelayChainOrigin: RuntimeOrigin = cumulus_pallet_xcm::Origin::Relay.into(); - pub UniversalLocation: InteriorMultiLocation = - X2(GlobalConsensus(RelayNetwork::get().unwrap()), Parachain(ParachainInfo::parachain_id().into())); - pub TrustBackedAssetsPalletLocation: MultiLocation = - PalletInstance(::index() as u8).into(); - pub CheckingAccount: AccountId = PolkadotXcm::check_account(); - pub FellowshipLocation: MultiLocation = MultiLocation::new(1, Parachain(1001)); - pub const GovernanceLocation: MultiLocation = MultiLocation::parent(); - pub TreasuryAccount: Option = Some(TREASURY_PALLET_ID.into_account_truncating()); -} - -/// Type for specifying how a `MultiLocation` can be converted into an `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`. - ParentIsPreset, - // Sibling parachain origins convert to AccountId via the `ParaId::into`. - SiblingParachainConvertsVia, - // Straight up local `AccountId32` origins just alias directly to `AccountId`. - AccountId32Aliases, -); - -/// Means for transacting the native currency on this chain. -pub type CurrencyTransactor = CurrencyAdapter< - // Use this currency: - Balances, - // Use this currency when it is a fungible asset matching the given location or name: - IsConcrete, - // Convert an XCM MultiLocation into a local account id: - LocationToAccountId, - // Our chain's account ID type (we can't get away without mentioning it explicitly): - AccountId, - // We don't track any teleports of `Balances`. - (), ->; - -/// `AssetId/Balance` converter for `TrustBackedAssets`` -pub type TrustBackedAssetsConvertedConcreteId = - assets_common::TrustBackedAssetsConvertedConcreteId; - -/// Means for transacting assets besides the native currency on this chain. -pub type FungiblesTransactor = FungiblesAdapter< - // Use this fungibles implementation: - Assets, - // Use this currency when it is a fungible asset matching the given location or name: - TrustBackedAssetsConvertedConcreteId, - // Convert an XCM MultiLocation into a local account id: - LocationToAccountId, - // Our chain's account ID type (we can't get away without mentioning it explicitly): - AccountId, - // We only want to allow teleports of known assets. We use non-zero issuance as an indication - // that this asset is known. - LocalMint>, - // The account to use for tracking teleports. - CheckingAccount, ->; -/// Means for transacting assets on this chain. -pub type AssetTransactors = (CurrencyTransactor, FungiblesTransactor); - -/// This is the type we use to convert an (incoming) XCM origin into a local `Origin` instance, -/// ready for dispatching a transaction with Xcm's `Transact`. There is an `OriginKind` which can -/// biases the kind of local `Origin` it will become. -pub type XcmOriginToTransactDispatchOrigin = ( - // Sovereign account converter; this attempts to derive an `AccountId` from the origin location - // using `LocationToAccountId` and then turn that into the usual `Signed` origin. Useful for - // foreign chains who want to have a local sovereign account on this chain which they control. - SovereignSignedViaLocation, - // Native converter for Relay-chain (Parent) location; will convert to a `Relay` origin when - // recognised. - RelayChainAsNative, - // Native converter for sibling Parachains; will convert to a `SiblingPara` origin when - // recognised. - SiblingParachainAsNative, - // Superuser converter for the Relay-chain (Parent) location. This will allow it to issue a - // transaction from the Root origin. - ParentAsSuperuser, - // Native signed account converter; this just converts an `AccountId32` origin into a normal - // `RuntimeOrigin::Signed` origin of the same 32-byte value. - SignedAccountId32AsNative, - // Xcm origins can be represented natively under the Xcm pallet's Xcm origin. - XcmPassthrough, -); - -parameter_types! { - pub const MaxInstructions: u32 = 100; - pub const MaxAssetsIntoHolding: u32 = 64; - pub XcmAssetFeesReceiver: Option = Authorship::author(); -} - -match_types! { - pub type ParentOrParentsPlurality: impl Contains = { - MultiLocation { parents: 1, interior: Here } | - MultiLocation { parents: 1, interior: X1(Plurality { .. }) } - }; - pub type ParentOrSiblings: impl Contains = { - MultiLocation { parents: 1, interior: Here } | - MultiLocation { parents: 1, interior: X1(_) } - }; - pub type FellowsPlurality: impl Contains = { - MultiLocation { parents: 1, interior: X2(Parachain(1001), Plurality { id: BodyId::Technical, ..}) } - }; -} - -/// A call filter for the XCM Transact instruction. This is a temporary measure until we properly -/// account for proof size weights. -/// -/// Calls that are allowed through this filter must: -/// 1. Have a fixed weight; -/// 2. Cannot lead to another call being made; -/// 3. Have a defined proof size weight, e.g. no unbounded vecs in call parameters. -pub struct SafeCallFilter; -impl Contains for SafeCallFilter { - fn contains(call: &RuntimeCall) -> bool { - #[cfg(feature = "runtime-benchmarks")] - { - if matches!(call, RuntimeCall::System(frame_system::Call::remark_with_event { .. })) { - return true - } - } - - match call { - RuntimeCall::PolkadotXcm(pallet_xcm::Call::force_xcm_version { .. }) | - RuntimeCall::System( - frame_system::Call::set_heap_pages { .. } | - frame_system::Call::set_code { .. } | - frame_system::Call::set_code_without_checks { .. } | - frame_system::Call::kill_prefix { .. }, - ) | - RuntimeCall::ParachainSystem(..) | - RuntimeCall::Timestamp(..) | - RuntimeCall::Balances(..) | - RuntimeCall::CollatorSelection( - pallet_collator_selection::Call::set_desired_candidates { .. } | - pallet_collator_selection::Call::set_candidacy_bond { .. } | - pallet_collator_selection::Call::register_as_candidate { .. } | - pallet_collator_selection::Call::leave_intent { .. } | - pallet_collator_selection::Call::set_invulnerables { .. }, - ) | - RuntimeCall::Session(pallet_session::Call::purge_keys { .. }) | - RuntimeCall::XcmpQueue(..) | - RuntimeCall::DmpQueue(..) | - RuntimeCall::Utility(pallet_utility::Call::as_derivative { .. }) | - RuntimeCall::Assets( - pallet_assets::Call::create { .. } | - pallet_assets::Call::force_create { .. } | - pallet_assets::Call::start_destroy { .. } | - pallet_assets::Call::destroy_accounts { .. } | - pallet_assets::Call::destroy_approvals { .. } | - pallet_assets::Call::finish_destroy { .. } | - pallet_assets::Call::mint { .. } | - pallet_assets::Call::burn { .. } | - pallet_assets::Call::transfer { .. } | - pallet_assets::Call::transfer_keep_alive { .. } | - pallet_assets::Call::force_transfer { .. } | - pallet_assets::Call::freeze { .. } | - pallet_assets::Call::thaw { .. } | - pallet_assets::Call::freeze_asset { .. } | - pallet_assets::Call::thaw_asset { .. } | - pallet_assets::Call::transfer_ownership { .. } | - pallet_assets::Call::set_team { .. } | - pallet_assets::Call::clear_metadata { .. } | - pallet_assets::Call::force_clear_metadata { .. } | - pallet_assets::Call::force_asset_status { .. } | - pallet_assets::Call::approve_transfer { .. } | - pallet_assets::Call::cancel_approval { .. } | - pallet_assets::Call::force_cancel_approval { .. } | - pallet_assets::Call::transfer_approved { .. } | - pallet_assets::Call::touch { .. } | - pallet_assets::Call::refund { .. }, - ) | - RuntimeCall::Uniques( - pallet_uniques::Call::create { .. } | - pallet_uniques::Call::force_create { .. } | - pallet_uniques::Call::destroy { .. } | - pallet_uniques::Call::mint { .. } | - pallet_uniques::Call::burn { .. } | - pallet_uniques::Call::transfer { .. } | - pallet_uniques::Call::freeze { .. } | - pallet_uniques::Call::thaw { .. } | - pallet_uniques::Call::freeze_collection { .. } | - pallet_uniques::Call::thaw_collection { .. } | - pallet_uniques::Call::transfer_ownership { .. } | - pallet_uniques::Call::set_team { .. } | - pallet_uniques::Call::approve_transfer { .. } | - pallet_uniques::Call::cancel_approval { .. } | - pallet_uniques::Call::force_item_status { .. } | - pallet_uniques::Call::set_attribute { .. } | - pallet_uniques::Call::clear_attribute { .. } | - pallet_uniques::Call::set_metadata { .. } | - pallet_uniques::Call::clear_metadata { .. } | - pallet_uniques::Call::set_collection_metadata { .. } | - pallet_uniques::Call::clear_collection_metadata { .. } | - pallet_uniques::Call::set_accept_ownership { .. } | - pallet_uniques::Call::set_collection_max_supply { .. } | - pallet_uniques::Call::set_price { .. } | - pallet_uniques::Call::buy_item { .. }, - ) => true, - _ => false, - } - } -} - -pub type Barrier = DenyThenTry< - DenyReserveTransferToRelayChain, - ( - TakeWeightCredit, - // Expected responses are OK. - AllowKnownQueryResponses, - // Allow XCMs with some computed origins to pass through. - WithComputedOrigin< - ( - // If the message is one that immediately attemps to pay for execution, then allow it. - AllowTopLevelPaidExecutionFrom, - // Parent, its pluralities (i.e. governance bodies), and the Fellows plurality get free execution. - AllowExplicitUnpaidExecutionFrom<(ParentOrParentsPlurality, FellowsPlurality)>, - // Subscriptions for version tracking are OK. - AllowSubscriptionsFrom, - ), - UniversalLocation, - ConstU32<8>, - >, - ), ->; - -pub type AssetFeeAsExistentialDepositMultiplierFeeCharger = AssetFeeAsExistentialDepositMultiplier< - Runtime, - WeightToFee, - pallet_assets::BalanceToAssetBalance, - TrustBackedAssetsInstance, ->; - -pub struct XcmConfig; -impl xcm_executor::Config for XcmConfig { - type RuntimeCall = RuntimeCall; - type XcmSender = XcmRouter; - type AssetTransactor = AssetTransactors; - type OriginConverter = XcmOriginToTransactDispatchOrigin; - // Statemint does not recognize a reserve location for any asset. This does not prevent - // Statemint acting _as_ a reserve location for DOT and assets created under `pallet-assets`. - // For DOT, users must use teleport where allowed (e.g. with the Relay Chain). - type IsReserve = (); - type IsTeleporter = NativeAsset; // <- should be enough to allow teleportation of DOT - type UniversalLocation = UniversalLocation; - type Barrier = Barrier; - type Weigher = WeightInfoBounds< - crate::weights::xcm::StatemintXcmWeight, - RuntimeCall, - MaxInstructions, - >; - type Trader = ( - UsingComponents>, - cumulus_primitives_utility::TakeFirstAssetTrader< - AccountId, - AssetFeeAsExistentialDepositMultiplierFeeCharger, - TrustBackedAssetsConvertedConcreteId, - Assets, - cumulus_primitives_utility::XcmFeesTo32ByteAccount< - FungiblesTransactor, - AccountId, - XcmAssetFeesReceiver, - >, - >, - ); - type ResponseHandler = PolkadotXcm; - type AssetTrap = PolkadotXcm; - type AssetClaims = PolkadotXcm; - type SubscriptionService = PolkadotXcm; - type PalletInstancesInfo = AllPalletsWithSystem; - type MaxAssetsIntoHolding = MaxAssetsIntoHolding; - type AssetLocker = (); - type AssetExchanger = (); - type FeeManager = XcmFeesToAccount< - Self, - RelayOrOtherSystemParachains, - AccountId, - TreasuryAccount, - >; - type MessageExporter = (); - type UniversalAliases = Nothing; - type CallDispatcher = WithOriginFilter; - type SafeCallFilter = SafeCallFilter; -} - -/// Converts a local signed origin into an XCM multilocation. -/// Forms the basis for local origins sending/executing XCMs. -pub type LocalOriginToLocation = SignedToAccountId32; - -/// The means for routing XCM messages which are not for local execution into the right message -/// queues. -pub type XcmRouter = ( - // Two routers - use UMP to communicate with the relay chain: - cumulus_primitives_utility::ParentAsUmp, - // ..and XCMP to communicate with the sibling chains. - XcmpQueue, -); - -#[cfg(feature = "runtime-benchmarks")] -parameter_types! { - pub ReachableDest: Option = Some(Parent.into()); -} - -impl pallet_xcm::Config for Runtime { - type RuntimeEvent = RuntimeEvent; - // We want to disallow users sending (arbitrary) XCMs from this chain. - type SendXcmOrigin = EnsureXcmOrigin; - type XcmRouter = XcmRouter; - // We support local origins dispatching XCM executions in principle... - type ExecuteXcmOrigin = EnsureXcmOrigin; - // ... but disallow generic XCM execution. As a result only teleports and reserve transfers are allowed. - type XcmExecuteFilter = Nothing; - type XcmExecutor = XcmExecutor; - type XcmTeleportFilter = Everything; - type XcmReserveTransferFilter = Everything; - type Weigher = WeightInfoBounds< - crate::weights::xcm::StatemintXcmWeight, - RuntimeCall, - MaxInstructions, - >; - type UniversalLocation = UniversalLocation; - type RuntimeOrigin = RuntimeOrigin; - type RuntimeCall = RuntimeCall; - const VERSION_DISCOVERY_QUEUE_SIZE: u32 = 100; - type AdvertisedXcmVersion = pallet_xcm::CurrentXcmVersion; - type Currency = Balances; - type CurrencyMatcher = (); - type TrustedLockers = (); - type SovereignAccountOf = LocationToAccountId; - type MaxLockers = ConstU32<8>; - type WeightInfo = crate::weights::pallet_xcm::WeightInfo; - #[cfg(feature = "runtime-benchmarks")] - type ReachableDest = ReachableDest; - type AdminOrigin = EnsureRoot; -} - -impl cumulus_pallet_xcm::Config for Runtime { - type RuntimeEvent = RuntimeEvent; - type XcmExecutor = XcmExecutor; -} diff --git a/parachains/runtimes/bridge-hubs/bridge-hub-kusama/src/xcm_config.rs b/parachains/runtimes/bridge-hubs/bridge-hub-kusama/src/xcm_config.rs index 9013683228c..f3fe1d61d43 100644 --- a/parachains/runtimes/bridge-hubs/bridge-hub-kusama/src/xcm_config.rs +++ b/parachains/runtimes/bridge-hubs/bridge-hub-kusama/src/xcm_config.rs @@ -25,7 +25,10 @@ use frame_support::{ use frame_system::EnsureRoot; use kusama_runtime_constants::system_parachain::SystemParachains; use pallet_xcm::XcmPassthrough; -use parachains_common::{impls::ToStakingPot, xcm_config::ConcreteNativeAssetFrom}; +use parachains_common::{ + impls::ToStakingPot, + xcm_config::{ConcreteNativeAssetFrom, RelayOrOtherSystemParachains}, +}; use polkadot_parachain::primitives::Sibling; use sp_runtime::traits::AccountIdConversion; use xcm::latest::prelude::*; diff --git a/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/xcm_config.rs b/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/xcm_config.rs index 2b3fa99427e..d71ab77e6bb 100644 --- a/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/xcm_config.rs +++ b/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/xcm_config.rs @@ -32,10 +32,7 @@ use frame_system::EnsureRoot; use pallet_xcm::XcmPassthrough; use parachains_common::{ impls::ToStakingPot, - xcm_config::{ - ConcreteNativeAssetFrom, DenyReserveTransferToRelayChain, DenyThenTry, - RelayOrOtherSystemParachains, - }, + xcm_config::{ConcreteNativeAssetFrom, RelayOrOtherSystemParachains}, TREASURY_PALLET_ID, }; use polkadot_parachain::primitives::Sibling; @@ -262,8 +259,6 @@ impl xcm_executor::Config for XcmConfig { type SubscriptionService = PolkadotXcm; type PalletInstancesInfo = AllPalletsWithSystem; type MaxAssetsIntoHolding = MaxAssetsIntoHolding; - type AssetLocker = (); - type AssetExchanger = (); type FeeManager = XcmFeesToAccount< Self, RelayOrOtherSystemParachains, diff --git a/parachains/runtimes/collectives/collectives-polkadot/src/xcm_config.rs b/parachains/runtimes/collectives/collectives-polkadot/src/xcm_config.rs index af667db05aa..ae962fa803f 100644 --- a/parachains/runtimes/collectives/collectives-polkadot/src/xcm_config.rs +++ b/parachains/runtimes/collectives/collectives-polkadot/src/xcm_config.rs @@ -26,10 +26,7 @@ use frame_system::EnsureRoot; use pallet_xcm::XcmPassthrough; use parachains_common::{ impls::ToStakingPot, - xcm_config::{ - ConcreteNativeAssetFrom, DenyReserveTransferToRelayChain, DenyThenTry, - RelayOrOtherSystemParachains, - }, + xcm_config::{ConcreteNativeAssetFrom, RelayOrOtherSystemParachains}, TREASURY_PALLET_ID, }; use polkadot_parachain::primitives::Sibling; From fa04975ae1b7035b4dc849894404d86b8507c90d Mon Sep 17 00:00:00 2001 From: Branislav Kontur Date: Tue, 8 Aug 2023 12:54:54 +0200 Subject: [PATCH 15/15] More compile --- .../runtimes/assets/asset-hub-polkadot/src/xcm_config.rs | 2 +- .../runtimes/bridge-hubs/bridge-hub-kusama/src/xcm_config.rs | 1 + .../bridge-hubs/bridge-hub-polkadot/src/xcm_config.rs | 5 +---- 3 files changed, 3 insertions(+), 5 deletions(-) diff --git a/parachains/runtimes/assets/asset-hub-polkadot/src/xcm_config.rs b/parachains/runtimes/assets/asset-hub-polkadot/src/xcm_config.rs index 90deb887087..83b47142d1b 100644 --- a/parachains/runtimes/assets/asset-hub-polkadot/src/xcm_config.rs +++ b/parachains/runtimes/assets/asset-hub-polkadot/src/xcm_config.rs @@ -33,8 +33,8 @@ use parachains_common::{ TREASURY_PALLET_ID, }; use polkadot_parachain::primitives::Sibling; -use sp_runtime::traits::{AccountIdConversion, ConvertInto}; use polkadot_runtime_constants::system_parachain::SystemParachains; +use sp_runtime::traits::{AccountIdConversion, ConvertInto}; use xcm::latest::prelude::*; use xcm_builder::{ AccountId32Aliases, AllowExplicitUnpaidExecutionFrom, AllowKnownQueryResponses, diff --git a/parachains/runtimes/bridge-hubs/bridge-hub-kusama/src/xcm_config.rs b/parachains/runtimes/bridge-hubs/bridge-hub-kusama/src/xcm_config.rs index f3fe1d61d43..9f124067d85 100644 --- a/parachains/runtimes/bridge-hubs/bridge-hub-kusama/src/xcm_config.rs +++ b/parachains/runtimes/bridge-hubs/bridge-hub-kusama/src/xcm_config.rs @@ -28,6 +28,7 @@ use pallet_xcm::XcmPassthrough; use parachains_common::{ impls::ToStakingPot, xcm_config::{ConcreteNativeAssetFrom, RelayOrOtherSystemParachains}, + TREASURY_PALLET_ID, }; use polkadot_parachain::primitives::Sibling; use sp_runtime::traits::AccountIdConversion; diff --git a/parachains/runtimes/bridge-hubs/bridge-hub-polkadot/src/xcm_config.rs b/parachains/runtimes/bridge-hubs/bridge-hub-polkadot/src/xcm_config.rs index 1ccb3dc0d83..d536374b339 100644 --- a/parachains/runtimes/bridge-hubs/bridge-hub-polkadot/src/xcm_config.rs +++ b/parachains/runtimes/bridge-hubs/bridge-hub-polkadot/src/xcm_config.rs @@ -26,10 +26,7 @@ use frame_system::EnsureRoot; use pallet_xcm::XcmPassthrough; use parachains_common::{ impls::ToStakingPot, - xcm_config::{ - ConcreteNativeAssetFrom, DenyReserveTransferToRelayChain, DenyThenTry, - RelayOrOtherSystemParachains, - }, + xcm_config::{ConcreteNativeAssetFrom, RelayOrOtherSystemParachains}, TREASURY_PALLET_ID, }; use polkadot_parachain::primitives::Sibling;