From 272c31de032f9f6d11a075c537427a4e9ee37ae9 Mon Sep 17 00:00:00 2001 From: Keith Yeung Date: Tue, 4 Apr 2023 22:59:28 +0800 Subject: [PATCH 01/27] Introduce XcmFeesToAccount fee manager --- runtime/kusama/src/xcm_config.rs | 11 ++-- runtime/polkadot/src/xcm_config.rs | 11 ++-- runtime/rococo/src/xcm_config.rs | 10 ++-- runtime/westend/src/xcm_config.rs | 15 ++++-- xcm/pallet-xcm-benchmarks/src/generic/mock.rs | 6 ++- xcm/xcm-builder/src/currency_adapter.rs | 6 ++- xcm/xcm-builder/src/fee_handling.rs | 51 +++++++++++++++++++ xcm/xcm-builder/src/fungibles_adapter.rs | 12 ++++- xcm/xcm-builder/src/lib.rs | 3 ++ xcm/xcm-builder/src/nonfungibles_adapter.rs | 12 ++++- xcm/xcm-builder/src/tests/mock.rs | 4 +- xcm/xcm-executor/src/lib.rs | 16 +++--- xcm/xcm-executor/src/traits/fee_manager.rs | 4 +- xcm/xcm-executor/src/traits/transact_asset.rs | 28 ++++++---- 14 files changed, 150 insertions(+), 39 deletions(-) create mode 100644 xcm/xcm-builder/src/fee_handling.rs diff --git a/runtime/kusama/src/xcm_config.rs b/runtime/kusama/src/xcm_config.rs index f08f736f07df..b839f40ae390 100644 --- a/runtime/kusama/src/xcm_config.rs +++ b/runtime/kusama/src/xcm_config.rs @@ -18,7 +18,7 @@ use super::{ parachains_origin, AccountId, AllPalletsWithSystem, Balances, Fellows, ParaId, Runtime, - RuntimeCall, RuntimeEvent, RuntimeOrigin, StakingAdmin, WeightToFee, XcmPallet, + RuntimeCall, RuntimeEvent, RuntimeOrigin, StakingAdmin, Treasury, WeightToFee, XcmPallet, }; use frame_support::{ match_types, parameter_types, @@ -36,7 +36,7 @@ use xcm_builder::{ CurrencyAdapter as XcmCurrencyAdapter, FixedWeightBounds, IsChildSystemParachain, IsConcrete, MintLocation, OriginToPluralityVoice, SignedAccountId32AsNative, SignedToAccountId32, SovereignSignedViaLocation, TakeWeightCredit, UsingComponents, WeightInfoBounds, - WithComputedOrigin, + WithComputedOrigin, XcmFeesToAccount, }; use xcm_executor::traits::WithOriginFilter; @@ -55,6 +55,8 @@ parameter_types! { pub CheckAccount: AccountId = XcmPallet::check_account(); /// The check account that is allowed to mint assets locally. pub LocalCheckAccount: (AccountId, MintLocation) = (CheckAccount::get(), MintLocation::Local); + /// The treasury account where XCM fees would be sent to. + pub TreasuryAccount: Option = Some(Treasury::account_id()); } /// The canonical means of converting a `MultiLocation` into an `AccountId`, used when we want to determine @@ -125,6 +127,9 @@ match_types! { pub type OnlyParachains: impl Contains = { MultiLocation { parents: 0, interior: X1(Parachain(_)) } }; + pub type SystemParachains: impl Contains = { + MultiLocation { parents: 0, interior: X1(Parachain(1000)) } + } } /// The barriers one of which must be passed for an XCM message to be executed. @@ -335,7 +340,7 @@ impl xcm_executor::Config for XcmConfig { type SubscriptionService = XcmPallet; type PalletInstancesInfo = AllPalletsWithSystem; type MaxAssetsIntoHolding = MaxAssetsIntoHolding; - type FeeManager = (); + type FeeManager = XcmFeesToAccount; // No bridges yet... type MessageExporter = (); type UniversalAliases = Nothing; diff --git a/runtime/polkadot/src/xcm_config.rs b/runtime/polkadot/src/xcm_config.rs index bd95a7586594..308aceb4ecc0 100644 --- a/runtime/polkadot/src/xcm_config.rs +++ b/runtime/polkadot/src/xcm_config.rs @@ -19,7 +19,7 @@ use super::{ parachains_origin, AccountId, AllPalletsWithSystem, Balances, CouncilCollective, FellowshipAdmin, ParaId, Runtime, RuntimeCall, RuntimeEvent, RuntimeOrigin, StakingAdmin, - WeightToFee, XcmPallet, + Treasury, WeightToFee, XcmPallet, }; use frame_support::{ match_types, parameter_types, @@ -38,7 +38,7 @@ use xcm_builder::{ ChildParachainAsNative, ChildParachainConvertsVia, CurrencyAdapter as XcmCurrencyAdapter, FixedWeightBounds, IsConcrete, MintLocation, OriginToPluralityVoice, SignedAccountId32AsNative, SignedToAccountId32, SovereignSignedViaLocation, TakeWeightCredit, UsingComponents, - WithComputedOrigin, + WithComputedOrigin, XcmFeesToAccount, }; use xcm_executor::traits::WithOriginFilter; @@ -55,6 +55,8 @@ parameter_types! { pub CheckAccount: AccountId = XcmPallet::check_account(); /// The Checking Account along with the indication that the local chain is able to mint tokens. pub LocalCheckAccount: (AccountId, MintLocation) = (CheckAccount::get(), MintLocation::Local); + /// The treasury account where XCM fees would be sent to. + pub TreasuryAccount: Option = Some(Treasury::account_id()); } /// The canonical means of converting a `MultiLocation` into an `AccountId`, used when we want to determine @@ -135,6 +137,9 @@ match_types! { MultiLocation { parents: 0, interior: X1(Parachain(COLLECTIVES_ID)) } | MultiLocation { parents: 0, interior: X2(Parachain(COLLECTIVES_ID), Plurality { id: BodyId::Technical, .. }) } }; + pub type SystemParachains: impl Contains = { + MultiLocation { parents: 0, interior: X1(Parachain(STATEMINT_ID | COLLECTIVES_ID)) } + } } /// The barriers one of which must be passed for an XCM message to be executed. @@ -354,7 +359,7 @@ impl xcm_executor::Config for XcmConfig { type SubscriptionService = XcmPallet; type PalletInstancesInfo = AllPalletsWithSystem; type MaxAssetsIntoHolding = MaxAssetsIntoHolding; - type FeeManager = (); + type FeeManager = XcmFeesToAccount; // No bridges yet... type MessageExporter = (); type UniversalAliases = Nothing; diff --git a/runtime/rococo/src/xcm_config.rs b/runtime/rococo/src/xcm_config.rs index 7b864939bdb5..a7f15cdda30c 100644 --- a/runtime/rococo/src/xcm_config.rs +++ b/runtime/rococo/src/xcm_config.rs @@ -18,7 +18,7 @@ use super::{ parachains_origin, AccountId, AllPalletsWithSystem, Balances, CouncilCollective, ParaId, - Runtime, RuntimeCall, RuntimeEvent, RuntimeOrigin, WeightToFee, XcmPallet, + Runtime, RuntimeCall, RuntimeEvent, RuntimeOrigin, Treasury, WeightToFee, XcmPallet, }; use frame_support::{ match_types, parameter_types, @@ -35,7 +35,7 @@ use xcm_builder::{ ChildParachainAsNative, ChildParachainConvertsVia, ChildSystemParachainAsSuperuser, CurrencyAdapter as XcmCurrencyAdapter, FixedWeightBounds, IsChildSystemParachain, IsConcrete, MintLocation, SignedAccountId32AsNative, SignedToAccountId32, SovereignSignedViaLocation, - TakeWeightCredit, UsingComponents, WeightInfoBounds, WithComputedOrigin, + TakeWeightCredit, UsingComponents, WeightInfoBounds, WithComputedOrigin, XcmFeesToAccount, }; use xcm_executor::{traits::WithOriginFilter, XcmExecutor}; @@ -45,6 +45,7 @@ parameter_types! { pub UniversalLocation: InteriorMultiLocation = ThisNetwork::get().into(); pub CheckAccount: AccountId = XcmPallet::check_account(); pub LocalCheckAccount: (AccountId, MintLocation) = (CheckAccount::get(), MintLocation::Local); + pub TreasuryAccount: Option = Some(Treasury::account_id()); } pub type LocationConverter = @@ -120,6 +121,9 @@ match_types! { pub type OnlyParachains: impl Contains = { MultiLocation { parents: 0, interior: X1(Parachain(_)) } }; + pub type SystemParachains: impl Contains = { + MultiLocation { parents: 0, interior: X1(Parachain(1000 | 1002)) } + }; } /// The barriers one of which must be passed for an XCM message to be executed. @@ -313,7 +317,7 @@ impl xcm_executor::Config for XcmConfig { type SubscriptionService = XcmPallet; type PalletInstancesInfo = AllPalletsWithSystem; type MaxAssetsIntoHolding = MaxAssetsIntoHolding; - type FeeManager = (); + type FeeManager = XcmFeesToAccount; type MessageExporter = (); type UniversalAliases = Nothing; type CallDispatcher = WithOriginFilter; diff --git a/runtime/westend/src/xcm_config.rs b/runtime/westend/src/xcm_config.rs index 834472f5fb2c..35d102a8e58f 100644 --- a/runtime/westend/src/xcm_config.rs +++ b/runtime/westend/src/xcm_config.rs @@ -18,10 +18,10 @@ use super::{ parachains_origin, weights, AccountId, AllPalletsWithSystem, Balances, ParaId, Runtime, - RuntimeCall, RuntimeEvent, RuntimeOrigin, WeightToFee, XcmPallet, + RuntimeCall, RuntimeEvent, RuntimeOrigin, Treasury, WeightToFee, XcmPallet, }; use frame_support::{ - parameter_types, + match_types, parameter_types, traits::{Contains, Everything, Nothing}, }; use frame_system::EnsureRoot; @@ -34,7 +34,7 @@ use xcm_builder::{ ChildParachainConvertsVia, ChildSystemParachainAsSuperuser, CurrencyAdapter as XcmCurrencyAdapter, IsChildSystemParachain, IsConcrete, MintLocation, SignedAccountId32AsNative, SignedToAccountId32, SovereignSignedViaLocation, TakeWeightCredit, - UsingComponents, WeightInfoBounds, WithComputedOrigin, + UsingComponents, WeightInfoBounds, WithComputedOrigin, XcmFeesToAccount, }; use xcm_executor::{traits::WithOriginFilter, XcmExecutor}; @@ -44,6 +44,7 @@ parameter_types! { pub UniversalLocation: InteriorMultiLocation = ThisNetwork::get().into(); pub CheckAccount: AccountId = XcmPallet::check_account(); pub LocalCheckAccount: (AccountId, MintLocation) = (CheckAccount::get(), MintLocation::Local); + pub TreasuryAccount: Option = Some(Treasury::account_id()); } pub type LocationConverter = @@ -228,6 +229,12 @@ impl Contains for SafeCallFilter { } } +match_types! { + pub type SystemParachains: impl Contains = { + MultiLocation { parents: 0, interior: X1(Parachain(1000 | 1001)) } + }; +} + pub struct XcmConfig; impl xcm_executor::Config for XcmConfig { type RuntimeCall = RuntimeCall; @@ -250,7 +257,7 @@ impl xcm_executor::Config for XcmConfig { type SubscriptionService = XcmPallet; type PalletInstancesInfo = AllPalletsWithSystem; type MaxAssetsIntoHolding = MaxAssetsIntoHolding; - type FeeManager = (); + type FeeManager = XcmFeesToAccount; type MessageExporter = (); type UniversalAliases = Nothing; type CallDispatcher = WithOriginFilter; diff --git a/xcm/pallet-xcm-benchmarks/src/generic/mock.rs b/xcm/pallet-xcm-benchmarks/src/generic/mock.rs index 3cb5c5d0c8e7..69a9304842dd 100644 --- a/xcm/pallet-xcm-benchmarks/src/generic/mock.rs +++ b/xcm/pallet-xcm-benchmarks/src/generic/mock.rs @@ -88,7 +88,11 @@ impl frame_system::Config for Test { /// The benchmarks in this pallet should never need an asset transactor to begin with. pub struct NoAssetTransactor; impl xcm_executor::traits::TransactAsset for NoAssetTransactor { - fn deposit_asset(_: &MultiAsset, _: &MultiLocation, _: &XcmContext) -> Result<(), XcmError> { + fn deposit_asset( + _: &MultiAsset, + _: &MultiLocation, + _: Option<&XcmContext>, + ) -> Result<(), XcmError> { unreachable!(); } diff --git a/xcm/xcm-builder/src/currency_adapter.rs b/xcm/xcm-builder/src/currency_adapter.rs index bb7ac7a648da..aad108212487 100644 --- a/xcm/xcm-builder/src/currency_adapter.rs +++ b/xcm/xcm-builder/src/currency_adapter.rs @@ -191,7 +191,11 @@ impl< } } - fn deposit_asset(what: &MultiAsset, who: &MultiLocation, _context: &XcmContext) -> Result { + fn deposit_asset( + what: &MultiAsset, + who: &MultiLocation, + _context: Option<&XcmContext>, + ) -> Result { log::trace!(target: "xcm::currency_adapter", "deposit_asset what: {:?}, who: {:?}", what, who); // Check we handle this asset. let amount = Matcher::matches_fungible(&what).ok_or(Error::AssetNotHandled)?; diff --git a/xcm/xcm-builder/src/fee_handling.rs b/xcm/xcm-builder/src/fee_handling.rs new file mode 100644 index 000000000000..dc831dd81847 --- /dev/null +++ b/xcm/xcm-builder/src/fee_handling.rs @@ -0,0 +1,51 @@ +// Copyright Parity Technologies (UK) Ltd. +// This file is part of Polkadot. + +// Polkadot is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. + +// Polkadot is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with Polkadot. If not, see . + +use core::marker::PhantomData; +use frame_support::traits::{Contains, Get}; +use xcm::prelude::*; +use xcm_executor::traits::{FeeManager, FeeReason, TransactAsset}; + +/// A `FeeManager` implementation that simply deposits the fees handled into a specific on-chain +/// `ReceiverAccount`. +/// +/// It reuses the `AssetTransactor` configured on the XCM executor to deposit fee assets, and also +/// permits specifying `WaivedLocations` for locations that are privileged to not pay for fees. +pub struct XcmFeesToAccount( + PhantomData<(XcmConfig, WaivedLocations, AccountId, ReceiverAccount)>, +); +impl< + XcmConfig: xcm_executor::Config, + WaivedLocations: Contains, + AccountId: Clone + Into<[u8; 32]>, + ReceiverAccount: Get>, + > FeeManager for XcmFeesToAccount +{ + fn is_waived(origin: Option<&MultiLocation>, _: FeeReason) -> bool { + let Some(loc) = origin else { return false }; + WaivedLocations::contains(loc) + } + + fn handle_fee(fees: MultiAssets, context: Option<&XcmContext>) { + if let Some(receiver) = ReceiverAccount::get() { + let dest = AccountId32 { network: None, id: receiver.into() }.into(); + for asset in fees.into_inner() { + let ok = XcmConfig::AssetTransactor::deposit_asset(&asset, &dest, context).is_ok(); + debug_assert!(ok, "`deposit_asset` cannot generally fail"); + } + } + } +} diff --git a/xcm/xcm-builder/src/fungibles_adapter.rs b/xcm/xcm-builder/src/fungibles_adapter.rs index 33e451393106..851f2fb399f0 100644 --- a/xcm/xcm-builder/src/fungibles_adapter.rs +++ b/xcm/xcm-builder/src/fungibles_adapter.rs @@ -274,7 +274,11 @@ impl< } } - fn deposit_asset(what: &MultiAsset, who: &MultiLocation, _context: &XcmContext) -> XcmResult { + fn deposit_asset( + what: &MultiAsset, + who: &MultiLocation, + _context: Option<&XcmContext>, + ) -> XcmResult { log::trace!( target: "xcm::fungibles_adapter", "deposit_asset what: {:?}, who: {:?}", @@ -371,7 +375,11 @@ impl< >::check_out(dest, what, context) } - fn deposit_asset(what: &MultiAsset, who: &MultiLocation, context: &XcmContext) -> XcmResult { + fn deposit_asset( + what: &MultiAsset, + who: &MultiLocation, + context: Option<&XcmContext>, + ) -> XcmResult { FungiblesMutateAdapter::< Assets, Matcher, diff --git a/xcm/xcm-builder/src/lib.rs b/xcm/xcm-builder/src/lib.rs index 2379297010a1..487d1cda7ca9 100644 --- a/xcm/xcm-builder/src/lib.rs +++ b/xcm/xcm-builder/src/lib.rs @@ -57,6 +57,9 @@ pub use barriers::{ mod currency_adapter; pub use currency_adapter::CurrencyAdapter; +mod fee_handling; +pub use fee_handling::XcmFeesToAccount; + mod fungibles_adapter; pub use fungibles_adapter::{ AssetChecking, DualMint, FungiblesAdapter, FungiblesMutateAdapter, FungiblesTransferAdapter, diff --git a/xcm/xcm-builder/src/nonfungibles_adapter.rs b/xcm/xcm-builder/src/nonfungibles_adapter.rs index 2735a03ab6f3..41964dffdc59 100644 --- a/xcm/xcm-builder/src/nonfungibles_adapter.rs +++ b/xcm/xcm-builder/src/nonfungibles_adapter.rs @@ -192,7 +192,11 @@ impl< } } - fn deposit_asset(what: &MultiAsset, who: &MultiLocation, context: &XcmContext) -> XcmResult { + fn deposit_asset( + what: &MultiAsset, + who: &MultiLocation, + context: Option<&XcmContext>, + ) -> XcmResult { log::trace!( target: "xcm::fungibles_adapter", "deposit_asset what: {:?}, who: {:?}, context: {:?}", @@ -288,7 +292,11 @@ impl< >::check_out(dest, what, context) } - fn deposit_asset(what: &MultiAsset, who: &MultiLocation, context: &XcmContext) -> XcmResult { + fn deposit_asset( + what: &MultiAsset, + who: &MultiLocation, + context: Option<&XcmContext>, + ) -> XcmResult { NonFungiblesMutateAdapter::< Assets, Matcher, diff --git a/xcm/xcm-builder/src/tests/mock.rs b/xcm/xcm-builder/src/tests/mock.rs index fa85d09a443e..986c73d753e1 100644 --- a/xcm/xcm-builder/src/tests/mock.rs +++ b/xcm/xcm-builder/src/tests/mock.rs @@ -243,7 +243,7 @@ impl TransactAsset for TestAssetTransactor { fn deposit_asset( what: &MultiAsset, who: &MultiLocation, - _context: &XcmContext, + _context: Option<&XcmContext>, ) -> Result<(), XcmError> { add_asset(who.clone(), what.clone()); Ok(()) @@ -441,7 +441,7 @@ impl FeeManager for TestFeeManager { fn is_waived(_: Option<&MultiLocation>, r: FeeReason) -> bool { IS_WAIVED.with(|l| l.borrow().contains(&r)) } - fn handle_fee(_: MultiAssets) {} + fn handle_fee(_: MultiAssets, _: Option<&XcmContext>) {} } #[derive(Clone, Eq, PartialEq, Debug)] diff --git a/xcm/xcm-executor/src/lib.rs b/xcm/xcm-executor/src/lib.rs index 4e63ad91479f..e67cfd8424ef 100644 --- a/xcm/xcm-executor/src/lib.rs +++ b/xcm/xcm-executor/src/lib.rs @@ -245,7 +245,7 @@ impl ExecuteXcm for XcmExecutor XcmExecutor { let (ticket, fee) = validate_send::(dest, msg)?; if !Config::FeeManager::is_waived(self.origin_ref(), reason) { let paid = self.holding.try_take(fee.into()).map_err(|_| XcmError::NotHoldingFees)?; - Config::FeeManager::handle_fee(paid.into()); + Config::FeeManager::handle_fee(paid.into(), Some(&self.context)); } Config::XcmSender::deliver(ticket).map_err(Into::into) } @@ -613,14 +613,18 @@ impl XcmExecutor { DepositAsset { assets, beneficiary } => { let deposited = self.holding.saturating_take(assets); for asset in deposited.into_assets_iter() { - Config::AssetTransactor::deposit_asset(&asset, &beneficiary, &self.context)?; + Config::AssetTransactor::deposit_asset( + &asset, + &beneficiary, + Some(&self.context), + )?; } Ok(()) }, DepositReserveAsset { assets, dest, xcm } => { let deposited = self.holding.saturating_take(assets); for asset in deposited.assets_iter() { - Config::AssetTransactor::deposit_asset(&asset, &dest, &self.context)?; + Config::AssetTransactor::deposit_asset(&asset, &dest, Some(&self.context))?; } // Note that we pass `None` as `maybe_failed_bin` and drop any assets which cannot // be reanchored because we have already called `deposit_asset` on all assets. @@ -936,7 +940,7 @@ impl XcmExecutor { } else { self.holding.try_take(fee.into()).map_err(|_| XcmError::NotHoldingFees)?.into() }; - Config::FeeManager::handle_fee(paid); + Config::FeeManager::handle_fee(paid, Some(&self.context)); Ok(()) } @@ -971,7 +975,7 @@ impl XcmExecutor { let (ticket, fee) = validate_send::(destination, message)?; if !Config::FeeManager::is_waived(self.origin_ref(), fee_reason) { let paid = self.holding.try_take(fee.into()).map_err(|_| XcmError::NotHoldingFees)?; - Config::FeeManager::handle_fee(paid.into()); + Config::FeeManager::handle_fee(paid.into(), Some(&self.context)); } Config::XcmSender::deliver(ticket).map_err(Into::into) } diff --git a/xcm/xcm-executor/src/traits/fee_manager.rs b/xcm/xcm-executor/src/traits/fee_manager.rs index b883a6d573c8..fc60c004bd6d 100644 --- a/xcm/xcm-executor/src/traits/fee_manager.rs +++ b/xcm/xcm-executor/src/traits/fee_manager.rs @@ -23,7 +23,7 @@ pub trait FeeManager { /// Do something with the fee which has been paid. Doing nothing here silently burns the /// fees. - fn handle_fee(fee: MultiAssets); + fn handle_fee(fee: MultiAssets, context: Option<&XcmContext>); } /// Context under which a fee is paid. @@ -55,5 +55,5 @@ impl FeeManager for () { fn is_waived(_: Option<&MultiLocation>, _: FeeReason) -> bool { true } - fn handle_fee(_: MultiAssets) {} + fn handle_fee(_: MultiAssets, _: Option<&XcmContext>) {} } diff --git a/xcm/xcm-executor/src/traits/transact_asset.rs b/xcm/xcm-executor/src/traits/transact_asset.rs index 9f4b9b5ad392..2229f3efb2db 100644 --- a/xcm/xcm-executor/src/traits/transact_asset.rs +++ b/xcm/xcm-executor/src/traits/transact_asset.rs @@ -78,7 +78,11 @@ pub trait TransactAsset { /// Deposit the `what` asset into the account of `who`. /// /// Implementations should return `XcmError::FailedToTransactAsset` if deposit failed. - fn deposit_asset(_what: &MultiAsset, _who: &MultiLocation, _context: &XcmContext) -> XcmResult { + fn deposit_asset( + _what: &MultiAsset, + _who: &MultiLocation, + _context: Option<&XcmContext>, + ) -> XcmResult { Err(XcmError::Unimplemented) } @@ -130,7 +134,7 @@ pub trait TransactAsset { Err(XcmError::AssetNotFound | XcmError::Unimplemented) => { let assets = Self::withdraw_asset(asset, from, Some(context))?; // Not a very forgiving attitude; once we implement roll-backs then it'll be nicer. - Self::deposit_asset(asset, to, context)?; + Self::deposit_asset(asset, to, Some(context))?; Ok(assets) }, result => result, @@ -186,7 +190,11 @@ impl TransactAsset for Tuple { )* ); } - fn deposit_asset(what: &MultiAsset, who: &MultiLocation, context: &XcmContext) -> XcmResult { + fn deposit_asset( + what: &MultiAsset, + who: &MultiLocation, + context: Option<&XcmContext>, + ) -> XcmResult { for_tuples!( #( match Tuple::deposit_asset(what, who, context) { Err(XcmError::AssetNotFound) | Err(XcmError::Unimplemented) => (), @@ -277,7 +285,7 @@ mod tests { fn deposit_asset( _what: &MultiAsset, _who: &MultiLocation, - _context: &XcmContext, + _context: Option<&XcmContext>, ) -> XcmResult { Err(XcmError::AssetNotFound) } @@ -321,7 +329,7 @@ mod tests { fn deposit_asset( _what: &MultiAsset, _who: &MultiLocation, - _context: &XcmContext, + _context: Option<&XcmContext>, ) -> XcmResult { Err(XcmError::Overflow) } @@ -365,7 +373,7 @@ mod tests { fn deposit_asset( _what: &MultiAsset, _who: &MultiLocation, - _context: &XcmContext, + _context: Option<&XcmContext>, ) -> XcmResult { Ok(()) } @@ -397,7 +405,7 @@ mod tests { MultiTransactor::deposit_asset( &(Here, 1u128).into(), &Here.into(), - &XcmContext::with_message_hash([0; 32]), + Some(&XcmContext::with_message_hash([0; 32])), ), Err(XcmError::AssetNotFound) ); @@ -411,7 +419,7 @@ mod tests { MultiTransactor::deposit_asset( &(Here, 1u128).into(), &Here.into(), - &XcmContext::with_message_hash([0; 32]), + Some(&XcmContext::with_message_hash([0; 32])), ), Ok(()) ); @@ -425,7 +433,7 @@ mod tests { MultiTransactor::deposit_asset( &(Here, 1u128).into(), &Here.into(), - &XcmContext::with_message_hash([0; 32]), + Some(&XcmContext::with_message_hash([0; 32])), ), Err(XcmError::Overflow) ); @@ -439,7 +447,7 @@ mod tests { MultiTransactor::deposit_asset( &(Here, 1u128).into(), &Here.into(), - &XcmContext::with_message_hash([0; 32]), + Some(&XcmContext::with_message_hash([0; 32])), ), Ok(()), ); From 13f59440e188a616f67a90fdeaf950086afdd70a Mon Sep 17 00:00:00 2001 From: Keith Yeung Date: Tue, 4 Apr 2023 23:18:42 +0800 Subject: [PATCH 02/27] Fixes --- .../src/fungible/benchmarking.rs | 30 ++----------------- 1 file changed, 3 insertions(+), 27 deletions(-) diff --git a/xcm/pallet-xcm-benchmarks/src/fungible/benchmarking.rs b/xcm/pallet-xcm-benchmarks/src/fungible/benchmarking.rs index fade0d4869b3..bf7190fd5ae2 100644 --- a/xcm/pallet-xcm-benchmarks/src/fungible/benchmarking.rs +++ b/xcm/pallet-xcm-benchmarks/src/fungible/benchmarking.rs @@ -44,15 +44,7 @@ benchmarks_instance_pallet! { let worst_case_holding = T::worst_case_holding(0); let asset = T::get_multi_asset(); - >::deposit_asset( - &asset, - &sender_location, - &XcmContext { - origin: Some(sender_location.clone()), - message_hash: [0; 32], - topic: None, - }, - ).unwrap(); + >::deposit_asset(&asset, &sender_location, &None).unwrap(); // check the assets of origin. assert!(!T::TransactAsset::balance(&sender_account).is_zero()); @@ -77,15 +69,7 @@ benchmarks_instance_pallet! { let dest_location = T::valid_destination()?; let dest_account = T::AccountIdConverter::convert(dest_location.clone()).unwrap(); - >::deposit_asset( - &asset, - &sender_location, - &XcmContext { - origin: Some(sender_location.clone()), - message_hash: [0; 32], - topic: None, - }, - ).unwrap(); + >::deposit_asset(&asset, &sender_location, &None).unwrap(); assert!(T::TransactAsset::balance(&dest_account).is_zero()); let mut executor = new_executor::(sender_location); @@ -104,15 +88,7 @@ benchmarks_instance_pallet! { let dest_account = T::AccountIdConverter::convert(dest_location.clone()).unwrap(); let asset = T::get_multi_asset(); - >::deposit_asset( - &asset, - &sender_location, - &XcmContext { - origin: Some(sender_location.clone()), - message_hash: [0; 32], - topic: None, - }, - ).unwrap(); + >::deposit_asset(&asset, &sender_location, &None).unwrap(); let assets: MultiAssets = vec![ asset ].into(); assert!(T::TransactAsset::balance(&dest_account).is_zero()); From 3d0cfdebc7f1734f4e268a69f91954eea2610d7f Mon Sep 17 00:00:00 2001 From: Keith Yeung Date: Tue, 4 Apr 2023 23:33:07 +0800 Subject: [PATCH 03/27] Fixes --- xcm/pallet-xcm-benchmarks/src/fungible/benchmarking.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/xcm/pallet-xcm-benchmarks/src/fungible/benchmarking.rs b/xcm/pallet-xcm-benchmarks/src/fungible/benchmarking.rs index bf7190fd5ae2..b8555a9f8534 100644 --- a/xcm/pallet-xcm-benchmarks/src/fungible/benchmarking.rs +++ b/xcm/pallet-xcm-benchmarks/src/fungible/benchmarking.rs @@ -44,7 +44,7 @@ benchmarks_instance_pallet! { let worst_case_holding = T::worst_case_holding(0); let asset = T::get_multi_asset(); - >::deposit_asset(&asset, &sender_location, &None).unwrap(); + >::deposit_asset(&asset, &sender_location, None).unwrap(); // check the assets of origin. assert!(!T::TransactAsset::balance(&sender_account).is_zero()); @@ -69,7 +69,7 @@ benchmarks_instance_pallet! { let dest_location = T::valid_destination()?; let dest_account = T::AccountIdConverter::convert(dest_location.clone()).unwrap(); - >::deposit_asset(&asset, &sender_location, &None).unwrap(); + >::deposit_asset(&asset, &sender_location, None).unwrap(); assert!(T::TransactAsset::balance(&dest_account).is_zero()); let mut executor = new_executor::(sender_location); @@ -88,7 +88,7 @@ benchmarks_instance_pallet! { let dest_account = T::AccountIdConverter::convert(dest_location.clone()).unwrap(); let asset = T::get_multi_asset(); - >::deposit_asset(&asset, &sender_location, &None).unwrap(); + >::deposit_asset(&asset, &sender_location, None).unwrap(); let assets: MultiAssets = vec![ asset ].into(); assert!(T::TransactAsset::balance(&dest_account).is_zero()); From c28700d1fa62eeeb4ffae3412fe852f1b2b84ea7 Mon Sep 17 00:00:00 2001 From: Keith Yeung Date: Tue, 4 Apr 2023 23:43:42 +0800 Subject: [PATCH 04/27] Put system parachain IDs into consts --- runtime/kusama/constants/src/lib.rs | 6 ++++++ runtime/kusama/src/xcm_config.rs | 7 ++++--- runtime/rococo/constants/src/lib.rs | 8 ++++++++ runtime/rococo/src/xcm_config.rs | 9 +++++---- runtime/westend/constants/src/lib.rs | 8 ++++++++ runtime/westend/src/xcm_config.rs | 9 +++++---- 6 files changed, 36 insertions(+), 11 deletions(-) diff --git a/runtime/kusama/constants/src/lib.rs b/runtime/kusama/constants/src/lib.rs index 73ca3d31652b..c0f89d01bb7a 100644 --- a/runtime/kusama/constants/src/lib.rs +++ b/runtime/kusama/constants/src/lib.rs @@ -97,6 +97,12 @@ pub mod fee { } } +/// System Parachains. +pub mod system_parachain { + /// Statemine parachain ID. + pub const STATEMINE_ID: u32 = 1000; +} + #[cfg(test)] mod tests { use super::{ diff --git a/runtime/kusama/src/xcm_config.rs b/runtime/kusama/src/xcm_config.rs index b839f40ae390..d6e824f87792 100644 --- a/runtime/kusama/src/xcm_config.rs +++ b/runtime/kusama/src/xcm_config.rs @@ -26,6 +26,7 @@ use frame_support::{ weights::Weight, }; use frame_system::EnsureRoot; +use kusama_runtime_constants::system_parachain::*; use runtime_common::{crowdloan, paras_registrar, xcm_sender, ToAuthor}; use sp_core::ConstU32; use xcm::latest::prelude::*; @@ -114,7 +115,7 @@ pub type XcmRouter = ( parameter_types! { pub const Ksm: MultiAssetFilter = Wild(AllOf { fun: WildFungible, id: Concrete(TokenLocation::get()) }); - pub const Statemine: MultiLocation = Parachain(1000).into_location(); + pub const Statemine: MultiLocation = Parachain(STATEMINE_ID).into_location(); pub const Encointer: MultiLocation = Parachain(1001).into_location(); pub const KsmForStatemine: (MultiAssetFilter, MultiLocation) = (Ksm::get(), Statemine::get()); pub const KsmForEncointer: (MultiAssetFilter, MultiLocation) = (Ksm::get(), Encointer::get()); @@ -128,7 +129,7 @@ match_types! { MultiLocation { parents: 0, interior: X1(Parachain(_)) } }; pub type SystemParachains: impl Contains = { - MultiLocation { parents: 0, interior: X1(Parachain(1000)) } + MultiLocation { parents: 0, interior: X1(Parachain(STATEMINE_ID)) } } } @@ -357,7 +358,7 @@ parameter_types! { #[cfg(feature = "runtime-benchmarks")] parameter_types! { - pub ReachableDest: Option = Some(Parachain(1000).into()); + pub ReachableDest: Option = Some(Parachain(STATEMINE_ID).into()); } /// Type to convert an `Origin` type value into a `MultiLocation` value which represents an interior location diff --git a/runtime/rococo/constants/src/lib.rs b/runtime/rococo/constants/src/lib.rs index 0683bc377e13..a4c643165b2b 100644 --- a/runtime/rococo/constants/src/lib.rs +++ b/runtime/rococo/constants/src/lib.rs @@ -99,6 +99,14 @@ pub mod fee { } } +/// System Parachains. +pub mod system_parachain { + /// Statemine parachain ID. + pub const STATEMINE_ID: u32 = 1000; + /// Contracts parachain ID. + pub const CONTRACTS_ID: u32 = 1002; +} + #[cfg(test)] mod tests { use super::{ diff --git a/runtime/rococo/src/xcm_config.rs b/runtime/rococo/src/xcm_config.rs index a7f15cdda30c..942e44f3cf97 100644 --- a/runtime/rococo/src/xcm_config.rs +++ b/runtime/rococo/src/xcm_config.rs @@ -26,6 +26,7 @@ use frame_support::{ weights::Weight, }; use frame_system::EnsureRoot; +use rococo_runtime_constants::system_parachain::*; use runtime_common::{crowdloan, paras_registrar, xcm_sender, ToAuthor}; use sp_core::ConstU32; use xcm::latest::prelude::*; @@ -93,8 +94,8 @@ pub type XcmRouter = ( parameter_types! { pub const Roc: MultiAssetFilter = Wild(AllOf { fun: WildFungible, id: Concrete(TokenLocation::get()) }); - pub const Statemine: MultiLocation = Parachain(1000).into_location(); - pub const Contracts: MultiLocation = Parachain(1002).into_location(); + pub const Statemine: MultiLocation = Parachain(STATEMINE_ID).into_location(); + pub const Contracts: MultiLocation = Parachain(CONTRACTS_ID).into_location(); pub const Encointer: MultiLocation = Parachain(1003).into_location(); pub const Tick: MultiLocation = Parachain(100).into_location(); pub const Trick: MultiLocation = Parachain(110).into_location(); @@ -122,7 +123,7 @@ match_types! { MultiLocation { parents: 0, interior: X1(Parachain(_)) } }; pub type SystemParachains: impl Contains = { - MultiLocation { parents: 0, interior: X1(Parachain(1000 | 1002)) } + MultiLocation { parents: 0, interior: X1(Parachain(STATEMINE_ID | CONTRACTS_ID)) } }; } @@ -334,7 +335,7 @@ parameter_types! { #[cfg(feature = "runtime-benchmarks")] parameter_types! { - pub ReachableDest: Option = Some(Parachain(1000).into()); + pub ReachableDest: Option = Some(Parachain(STATEMINE_ID).into()); } /// Type to convert the council origin to a Plurality `MultiLocation` value. diff --git a/runtime/westend/constants/src/lib.rs b/runtime/westend/constants/src/lib.rs index e7d1a627713f..e48944f9332f 100644 --- a/runtime/westend/constants/src/lib.rs +++ b/runtime/westend/constants/src/lib.rs @@ -96,6 +96,14 @@ pub mod fee { } } +/// System Parachains. +pub mod system_parachain { + /// Westmint parachain ID. + pub const WESTMINT_ID: u32 = 1000; + /// Collectives parachain ID. + pub const COLLECTIVES_ID: u32 = 1001; +} + #[cfg(test)] mod tests { use super::{ diff --git a/runtime/westend/src/xcm_config.rs b/runtime/westend/src/xcm_config.rs index 35d102a8e58f..ffc07215754b 100644 --- a/runtime/westend/src/xcm_config.rs +++ b/runtime/westend/src/xcm_config.rs @@ -27,6 +27,7 @@ use frame_support::{ use frame_system::EnsureRoot; use runtime_common::{crowdloan, paras_registrar, xcm_sender, ToAuthor}; use sp_core::ConstU32; +use westend_runtime_constants::system_parachain::*; use xcm::latest::prelude::*; use xcm_builder::{ AccountId32Aliases, AllowExplicitUnpaidExecutionFrom, AllowKnownQueryResponses, @@ -78,8 +79,8 @@ pub type XcmRouter = ( ); parameter_types! { - pub const Westmint: MultiLocation = Parachain(1000).into_location(); - pub const Collectives: MultiLocation = Parachain(1001).into_location(); + pub const Westmint: MultiLocation = Parachain(WESTMINT_ID).into_location(); + pub const Collectives: MultiLocation = Parachain(COLLECTIVES_ID).into_location(); pub const Wnd: MultiAssetFilter = Wild(AllOf { fun: WildFungible, id: Concrete(TokenLocation::get()) }); pub const WndForWestmint: (MultiAssetFilter, MultiLocation) = (Wnd::get(), Westmint::get()); pub const WndForCollectives: (MultiAssetFilter, MultiLocation) = (Wnd::get(), Collectives::get()); @@ -89,7 +90,7 @@ parameter_types! { #[cfg(feature = "runtime-benchmarks")] parameter_types! { - pub ReachableDest: Option = Some(Parachain(1000).into()); + pub ReachableDest: Option = Some(Parachain(WESTMINT_ID).into()); } pub type TrustedTeleporters = @@ -231,7 +232,7 @@ impl Contains for SafeCallFilter { match_types! { pub type SystemParachains: impl Contains = { - MultiLocation { parents: 0, interior: X1(Parachain(1000 | 1001)) } + MultiLocation { parents: 0, interior: X1(Parachain(WESTMINT_ID | COLLECTIVES_ID)) } }; } From d5b760b1908b5948c4c2cbce1b2293585af190d5 Mon Sep 17 00:00:00 2001 From: Keith Yeung Date: Tue, 4 Apr 2023 23:50:08 +0800 Subject: [PATCH 05/27] Fixes --- runtime/kusama/src/xcm_config.rs | 2 +- runtime/polkadot/src/xcm_config.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/runtime/kusama/src/xcm_config.rs b/runtime/kusama/src/xcm_config.rs index d6e824f87792..b99128347a3b 100644 --- a/runtime/kusama/src/xcm_config.rs +++ b/runtime/kusama/src/xcm_config.rs @@ -130,7 +130,7 @@ match_types! { }; pub type SystemParachains: impl Contains = { MultiLocation { parents: 0, interior: X1(Parachain(STATEMINE_ID)) } - } + }; } /// The barriers one of which must be passed for an XCM message to be executed. diff --git a/runtime/polkadot/src/xcm_config.rs b/runtime/polkadot/src/xcm_config.rs index 308aceb4ecc0..9153eb56e0a3 100644 --- a/runtime/polkadot/src/xcm_config.rs +++ b/runtime/polkadot/src/xcm_config.rs @@ -139,7 +139,7 @@ match_types! { }; pub type SystemParachains: impl Contains = { MultiLocation { parents: 0, interior: X1(Parachain(STATEMINT_ID | COLLECTIVES_ID)) } - } + }; } /// The barriers one of which must be passed for an XCM message to be executed. From a2d3604b273e3b449930ca6ad031de832c7ea3e6 Mon Sep 17 00:00:00 2001 From: Keith Yeung Date: Tue, 4 Apr 2023 23:52:06 +0800 Subject: [PATCH 06/27] Remove XcmFeesToAccount config for Westend --- runtime/westend/src/xcm_config.rs | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/runtime/westend/src/xcm_config.rs b/runtime/westend/src/xcm_config.rs index ffc07215754b..f6e5a9247628 100644 --- a/runtime/westend/src/xcm_config.rs +++ b/runtime/westend/src/xcm_config.rs @@ -18,10 +18,10 @@ use super::{ parachains_origin, weights, AccountId, AllPalletsWithSystem, Balances, ParaId, Runtime, - RuntimeCall, RuntimeEvent, RuntimeOrigin, Treasury, WeightToFee, XcmPallet, + RuntimeCall, RuntimeEvent, RuntimeOrigin, WeightToFee, XcmPallet, }; use frame_support::{ - match_types, parameter_types, + parameter_types, traits::{Contains, Everything, Nothing}, }; use frame_system::EnsureRoot; @@ -35,7 +35,7 @@ use xcm_builder::{ ChildParachainConvertsVia, ChildSystemParachainAsSuperuser, CurrencyAdapter as XcmCurrencyAdapter, IsChildSystemParachain, IsConcrete, MintLocation, SignedAccountId32AsNative, SignedToAccountId32, SovereignSignedViaLocation, TakeWeightCredit, - UsingComponents, WeightInfoBounds, WithComputedOrigin, XcmFeesToAccount, + UsingComponents, WeightInfoBounds, WithComputedOrigin, }; use xcm_executor::{traits::WithOriginFilter, XcmExecutor}; @@ -45,7 +45,6 @@ parameter_types! { pub UniversalLocation: InteriorMultiLocation = ThisNetwork::get().into(); pub CheckAccount: AccountId = XcmPallet::check_account(); pub LocalCheckAccount: (AccountId, MintLocation) = (CheckAccount::get(), MintLocation::Local); - pub TreasuryAccount: Option = Some(Treasury::account_id()); } pub type LocationConverter = @@ -230,12 +229,6 @@ impl Contains for SafeCallFilter { } } -match_types! { - pub type SystemParachains: impl Contains = { - MultiLocation { parents: 0, interior: X1(Parachain(WESTMINT_ID | COLLECTIVES_ID)) } - }; -} - pub struct XcmConfig; impl xcm_executor::Config for XcmConfig { type RuntimeCall = RuntimeCall; @@ -258,7 +251,7 @@ impl xcm_executor::Config for XcmConfig { type SubscriptionService = XcmPallet; type PalletInstancesInfo = AllPalletsWithSystem; type MaxAssetsIntoHolding = MaxAssetsIntoHolding; - type FeeManager = XcmFeesToAccount; + type FeeManager = (); type MessageExporter = (); type UniversalAliases = Nothing; type CallDispatcher = WithOriginFilter; From 7e99987d96ac7d3d9a38e9fe03077a9e028f0fe9 Mon Sep 17 00:00:00 2001 From: Keith Yeung Date: Wed, 5 Apr 2023 03:18:51 +0800 Subject: [PATCH 07/27] Include Encointer as a system parachain --- runtime/kusama/constants/src/lib.rs | 2 ++ runtime/kusama/src/xcm_config.rs | 4 ++-- runtime/rococo/constants/src/lib.rs | 2 ++ runtime/rococo/src/xcm_config.rs | 4 ++-- 4 files changed, 8 insertions(+), 4 deletions(-) diff --git a/runtime/kusama/constants/src/lib.rs b/runtime/kusama/constants/src/lib.rs index c0f89d01bb7a..876c884e7d26 100644 --- a/runtime/kusama/constants/src/lib.rs +++ b/runtime/kusama/constants/src/lib.rs @@ -101,6 +101,8 @@ pub mod fee { pub mod system_parachain { /// Statemine parachain ID. pub const STATEMINE_ID: u32 = 1000; + /// Encointer parachain ID. + pub const ENCOINTER_ID: u32 = 1001; } #[cfg(test)] diff --git a/runtime/kusama/src/xcm_config.rs b/runtime/kusama/src/xcm_config.rs index b99128347a3b..f17ecc089d59 100644 --- a/runtime/kusama/src/xcm_config.rs +++ b/runtime/kusama/src/xcm_config.rs @@ -116,7 +116,7 @@ pub type XcmRouter = ( parameter_types! { pub const Ksm: MultiAssetFilter = Wild(AllOf { fun: WildFungible, id: Concrete(TokenLocation::get()) }); pub const Statemine: MultiLocation = Parachain(STATEMINE_ID).into_location(); - pub const Encointer: MultiLocation = Parachain(1001).into_location(); + pub const Encointer: MultiLocation = Parachain(ENCOINTER_ID).into_location(); pub const KsmForStatemine: (MultiAssetFilter, MultiLocation) = (Ksm::get(), Statemine::get()); pub const KsmForEncointer: (MultiAssetFilter, MultiLocation) = (Ksm::get(), Encointer::get()); pub const MaxAssetsIntoHolding: u32 = 64; @@ -129,7 +129,7 @@ match_types! { MultiLocation { parents: 0, interior: X1(Parachain(_)) } }; pub type SystemParachains: impl Contains = { - MultiLocation { parents: 0, interior: X1(Parachain(STATEMINE_ID)) } + MultiLocation { parents: 0, interior: X1(Parachain(STATEMINE_ID | ENCOINTER_ID)) } }; } diff --git a/runtime/rococo/constants/src/lib.rs b/runtime/rococo/constants/src/lib.rs index a4c643165b2b..ab57668ba633 100644 --- a/runtime/rococo/constants/src/lib.rs +++ b/runtime/rococo/constants/src/lib.rs @@ -105,6 +105,8 @@ pub mod system_parachain { pub const STATEMINE_ID: u32 = 1000; /// Contracts parachain ID. pub const CONTRACTS_ID: u32 = 1002; + /// Encointer parachain ID. + pub const ENCOINTER_ID: u32 = 1003; } #[cfg(test)] diff --git a/runtime/rococo/src/xcm_config.rs b/runtime/rococo/src/xcm_config.rs index 942e44f3cf97..9ac62b1deda4 100644 --- a/runtime/rococo/src/xcm_config.rs +++ b/runtime/rococo/src/xcm_config.rs @@ -96,7 +96,7 @@ parameter_types! { pub const Roc: MultiAssetFilter = Wild(AllOf { fun: WildFungible, id: Concrete(TokenLocation::get()) }); pub const Statemine: MultiLocation = Parachain(STATEMINE_ID).into_location(); pub const Contracts: MultiLocation = Parachain(CONTRACTS_ID).into_location(); - pub const Encointer: MultiLocation = Parachain(1003).into_location(); + pub const Encointer: MultiLocation = Parachain(ENCOINTER_ID).into_location(); pub const Tick: MultiLocation = Parachain(100).into_location(); pub const Trick: MultiLocation = Parachain(110).into_location(); pub const Track: MultiLocation = Parachain(120).into_location(); @@ -123,7 +123,7 @@ match_types! { MultiLocation { parents: 0, interior: X1(Parachain(_)) } }; pub type SystemParachains: impl Contains = { - MultiLocation { parents: 0, interior: X1(Parachain(STATEMINE_ID | CONTRACTS_ID)) } + MultiLocation { parents: 0, interior: X1(Parachain(STATEMINE_ID | CONTRACTS_ID | ENCOINTER_ID)) } }; } From 04d441072f21b9a3295a2ad4e9dddb9d806a4f89 Mon Sep 17 00:00:00 2001 From: Keith Yeung Date: Wed, 5 Apr 2023 18:11:00 +0800 Subject: [PATCH 08/27] Emit warning when deposit_asset fails --- xcm/xcm-builder/src/fee_handling.rs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/xcm/xcm-builder/src/fee_handling.rs b/xcm/xcm-builder/src/fee_handling.rs index dc831dd81847..3710210fd03b 100644 --- a/xcm/xcm-builder/src/fee_handling.rs +++ b/xcm/xcm-builder/src/fee_handling.rs @@ -43,8 +43,13 @@ impl< if let Some(receiver) = ReceiverAccount::get() { let dest = AccountId32 { network: None, id: receiver.into() }.into(); for asset in fees.into_inner() { - let ok = XcmConfig::AssetTransactor::deposit_asset(&asset, &dest, context).is_ok(); - debug_assert!(ok, "`deposit_asset` cannot generally fail"); + if let Err(e) = XcmConfig::AssetTransactor::deposit_asset(&asset, &dest, context) { + log::warn!( + target: "xcm::fees", + "`AssetTransactor::deposit_asset` returned error: {:?}, burning fees: {:?}", + e, asset, + ); + } } } } From 5d6e2c28903c73e0cbfd96a487439ab4f46ca609 Mon Sep 17 00:00:00 2001 From: Keith Yeung Date: Wed, 5 Apr 2023 18:12:55 +0800 Subject: [PATCH 09/27] Add comment on what happens when deposit_asset errors --- xcm/xcm-builder/src/fee_handling.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/xcm/xcm-builder/src/fee_handling.rs b/xcm/xcm-builder/src/fee_handling.rs index 3710210fd03b..049055471d32 100644 --- a/xcm/xcm-builder/src/fee_handling.rs +++ b/xcm/xcm-builder/src/fee_handling.rs @@ -23,7 +23,9 @@ use xcm_executor::traits::{FeeManager, FeeReason, TransactAsset}; /// `ReceiverAccount`. /// /// It reuses the `AssetTransactor` configured on the XCM executor to deposit fee assets, and also -/// permits specifying `WaivedLocations` for locations that are privileged to not pay for fees. +/// permits specifying `WaivedLocations` for locations that are privileged to not pay for fees. If +/// the `AssetTransactor` returns an error while calling `deposit_asset`, then a warning will be +/// logged. pub struct XcmFeesToAccount( PhantomData<(XcmConfig, WaivedLocations, AccountId, ReceiverAccount)>, ); From 7e4cc0acc83b295a570f793e2ce7386579b0246d Mon Sep 17 00:00:00 2001 From: Keith Yeung Date: Wed, 5 Apr 2023 18:14:23 +0800 Subject: [PATCH 10/27] Fixes --- runtime/test-runtime/src/xcm_config.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/runtime/test-runtime/src/xcm_config.rs b/runtime/test-runtime/src/xcm_config.rs index e346f54a1575..5aeebb2720c9 100644 --- a/runtime/test-runtime/src/xcm_config.rs +++ b/runtime/test-runtime/src/xcm_config.rs @@ -60,7 +60,11 @@ pub type Barrier = AllowUnpaidExecutionFrom; pub struct DummyAssetTransactor; impl TransactAsset for DummyAssetTransactor { - fn deposit_asset(_what: &MultiAsset, _who: &MultiLocation, _context: &XcmContext) -> XcmResult { + fn deposit_asset( + _what: &MultiAsset, + _who: &MultiLocation, + _context: Option<&XcmContext>, + ) -> XcmResult { Ok(()) } From 17c0f5c7fa8494111e5469736ccb20035ebcefb2 Mon Sep 17 00:00:00 2001 From: Keith Yeung Date: Thu, 6 Apr 2023 15:09:44 +0800 Subject: [PATCH 11/27] Move SystemParachains to constants --- Cargo.lock | 3 +++ runtime/kusama/constants/Cargo.toml | 5 ++++- runtime/kusama/constants/src/lib.rs | 8 ++++++++ runtime/kusama/src/xcm_config.rs | 5 +---- runtime/polkadot/constants/Cargo.toml | 5 ++++- runtime/polkadot/constants/src/lib.rs | 8 ++++++++ runtime/polkadot/src/xcm_config.rs | 5 +---- runtime/rococo/constants/Cargo.toml | 5 ++++- runtime/rococo/constants/src/lib.rs | 10 +++++++++- runtime/rococo/src/lib.rs | 2 +- runtime/rococo/src/xcm_config.rs | 11 ++++------- 11 files changed, 47 insertions(+), 20 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 71cbc38c60a3..52c84e19398b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3781,6 +3781,7 @@ dependencies = [ "sp-core", "sp-runtime", "sp-weights", + "xcm", ] [[package]] @@ -7704,6 +7705,7 @@ dependencies = [ "sp-core", "sp-runtime", "sp-weights", + "xcm", ] [[package]] @@ -8954,6 +8956,7 @@ dependencies = [ "sp-core", "sp-runtime", "sp-weights", + "xcm", ] [[package]] diff --git a/runtime/kusama/constants/Cargo.toml b/runtime/kusama/constants/Cargo.toml index 6d5dc406586c..a9302e892a09 100644 --- a/runtime/kusama/constants/Cargo.toml +++ b/runtime/kusama/constants/Cargo.toml @@ -14,6 +14,8 @@ sp-runtime = { git = "https://github.com/paritytech/substrate", default-features sp-weights = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "master" } sp-core = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "master" } +xcm = { package = "xcm", path = "../../../xcm", default-features = false } + [features] default = ["std"] std = [ @@ -22,5 +24,6 @@ std = [ "runtime-common/std", "sp-core/std", "sp-runtime/std", - "sp-weights/std" + "sp-weights/std", + "xcm/std", ] diff --git a/runtime/kusama/constants/src/lib.rs b/runtime/kusama/constants/src/lib.rs index 876c884e7d26..b7213352a58a 100644 --- a/runtime/kusama/constants/src/lib.rs +++ b/runtime/kusama/constants/src/lib.rs @@ -99,10 +99,18 @@ pub mod fee { /// System Parachains. pub mod system_parachain { + use xcm::latest::prelude::*; + /// Statemine parachain ID. pub const STATEMINE_ID: u32 = 1000; /// Encointer parachain ID. pub const ENCOINTER_ID: u32 = 1001; + + frame_support::match_types! { + pub type SystemParachains: impl Contains = { + MultiLocation { parents: 0, interior: X1(Parachain(STATEMINE_ID | ENCOINTER_ID)) } + }; + } } #[cfg(test)] diff --git a/runtime/kusama/src/xcm_config.rs b/runtime/kusama/src/xcm_config.rs index f17ecc089d59..da4c483f44f7 100644 --- a/runtime/kusama/src/xcm_config.rs +++ b/runtime/kusama/src/xcm_config.rs @@ -26,7 +26,7 @@ use frame_support::{ weights::Weight, }; use frame_system::EnsureRoot; -use kusama_runtime_constants::system_parachain::*; +use kusama_runtime_constants::system_parachain::SystemParachains; use runtime_common::{crowdloan, paras_registrar, xcm_sender, ToAuthor}; use sp_core::ConstU32; use xcm::latest::prelude::*; @@ -128,9 +128,6 @@ match_types! { pub type OnlyParachains: impl Contains = { MultiLocation { parents: 0, interior: X1(Parachain(_)) } }; - pub type SystemParachains: impl Contains = { - MultiLocation { parents: 0, interior: X1(Parachain(STATEMINE_ID | ENCOINTER_ID)) } - }; } /// The barriers one of which must be passed for an XCM message to be executed. diff --git a/runtime/polkadot/constants/Cargo.toml b/runtime/polkadot/constants/Cargo.toml index ad8159e7463d..cb7542100247 100644 --- a/runtime/polkadot/constants/Cargo.toml +++ b/runtime/polkadot/constants/Cargo.toml @@ -14,6 +14,8 @@ sp-runtime = { git = "https://github.com/paritytech/substrate", default-features sp-weights = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "master" } sp-core = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "master" } +xcm = { package = "xcm", path = "../../../xcm", default-features = false } + [features] default = ["std"] std = [ @@ -22,5 +24,6 @@ std = [ "runtime-common/std", "sp-core/std", "sp-runtime/std", - "sp-weights/std" + "sp-weights/std", + "xcm/std", ] diff --git a/runtime/polkadot/constants/src/lib.rs b/runtime/polkadot/constants/src/lib.rs index 6aec6768e889..df6f8a70e9fb 100644 --- a/runtime/polkadot/constants/src/lib.rs +++ b/runtime/polkadot/constants/src/lib.rs @@ -113,10 +113,18 @@ pub mod xcm { /// System Parachains. pub mod system_parachain { + use xcm::latest::prelude::*; + /// Statemint parachain ID. pub const STATEMINT_ID: u32 = 1000; /// Collectives parachain ID. pub const COLLECTIVES_ID: u32 = 1001; + + frame_support::match_types! { + pub type SystemParachains: impl Contains = { + MultiLocation { parents: 0, interior: X1(Parachain(STATEMINT_ID | COLLECTIVES_ID)) } + }; + } } #[cfg(test)] diff --git a/runtime/polkadot/src/xcm_config.rs b/runtime/polkadot/src/xcm_config.rs index 9153eb56e0a3..de00c8daedcb 100644 --- a/runtime/polkadot/src/xcm_config.rs +++ b/runtime/polkadot/src/xcm_config.rs @@ -28,7 +28,7 @@ use frame_support::{ }; use frame_system::EnsureRoot; use pallet_xcm::XcmPassthrough; -use polkadot_runtime_constants::{system_parachain::*, xcm::body::FELLOWSHIP_ADMIN_INDEX}; +use polkadot_runtime_constants::{system_parachain::SystemParachains, xcm::body::FELLOWSHIP_ADMIN_INDEX}; use runtime_common::{crowdloan, paras_registrar, xcm_sender, ToAuthor}; use sp_core::ConstU32; use xcm::latest::prelude::*; @@ -137,9 +137,6 @@ match_types! { MultiLocation { parents: 0, interior: X1(Parachain(COLLECTIVES_ID)) } | MultiLocation { parents: 0, interior: X2(Parachain(COLLECTIVES_ID), Plurality { id: BodyId::Technical, .. }) } }; - pub type SystemParachains: impl Contains = { - MultiLocation { parents: 0, interior: X1(Parachain(STATEMINT_ID | COLLECTIVES_ID)) } - }; } /// The barriers one of which must be passed for an XCM message to be executed. diff --git a/runtime/rococo/constants/Cargo.toml b/runtime/rococo/constants/Cargo.toml index 9383a9de6c68..03000da3f662 100644 --- a/runtime/rococo/constants/Cargo.toml +++ b/runtime/rococo/constants/Cargo.toml @@ -14,6 +14,8 @@ sp-runtime = { git = "https://github.com/paritytech/substrate", default-features sp-weights = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "master" } sp-core = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "master" } +xcm = { package = "xcm", path = "../../../xcm", default-features = false } + [features] default = ["std"] std = [ @@ -22,5 +24,6 @@ std = [ "runtime-common/std", "sp-core/std", "sp-runtime/std", - "sp-weights/std" + "sp-weights/std", + "xcm/std", ] diff --git a/runtime/rococo/constants/src/lib.rs b/runtime/rococo/constants/src/lib.rs index ab57668ba633..aa42cbda3890 100644 --- a/runtime/rococo/constants/src/lib.rs +++ b/runtime/rococo/constants/src/lib.rs @@ -101,12 +101,20 @@ pub mod fee { /// System Parachains. pub mod system_parachain { + use xcm::latest::prelude::*; + /// Statemine parachain ID. - pub const STATEMINE_ID: u32 = 1000; + pub const ROCKMINE_ID: u32 = 1000; /// Contracts parachain ID. pub const CONTRACTS_ID: u32 = 1002; /// Encointer parachain ID. pub const ENCOINTER_ID: u32 = 1003; + + frame_support::match_types! { + pub type SystemParachains: impl Contains = { + MultiLocation { parents: 0, interior: X1(Parachain(ROCKMINE_ID | CONTRACTS_ID | ENCOINTER_ID)) } + }; + } } #[cfg(test)] diff --git a/runtime/rococo/src/lib.rs b/runtime/rococo/src/lib.rs index 139a65c7347e..7e1a6ec46aa5 100644 --- a/runtime/rococo/src/lib.rs +++ b/runtime/rococo/src/lib.rs @@ -2038,7 +2038,7 @@ sp_api::impl_runtime_apis! { use frame_benchmarking::baseline::Pallet as Baseline; use xcm::latest::prelude::*; use xcm_config::{ - LocalCheckAccount, LocationConverter, Statemine, TokenLocation, XcmConfig, + LocalCheckAccount, LocationConverter, Rockmine, TokenLocation, XcmConfig, }; impl frame_system_benchmarking::Config for Runtime {} diff --git a/runtime/rococo/src/xcm_config.rs b/runtime/rococo/src/xcm_config.rs index 9ac62b1deda4..0a193c1f42ae 100644 --- a/runtime/rococo/src/xcm_config.rs +++ b/runtime/rococo/src/xcm_config.rs @@ -26,7 +26,7 @@ use frame_support::{ weights::Weight, }; use frame_system::EnsureRoot; -use rococo_runtime_constants::system_parachain::*; +use rococo_runtime_constants::system_parachain::SystemParachains; use runtime_common::{crowdloan, paras_registrar, xcm_sender, ToAuthor}; use sp_core::ConstU32; use xcm::latest::prelude::*; @@ -94,7 +94,7 @@ pub type XcmRouter = ( parameter_types! { pub const Roc: MultiAssetFilter = Wild(AllOf { fun: WildFungible, id: Concrete(TokenLocation::get()) }); - pub const Statemine: MultiLocation = Parachain(STATEMINE_ID).into_location(); + pub const Rockmine: MultiLocation = Parachain(ROCKMINE_ID).into_location(); pub const Contracts: MultiLocation = Parachain(CONTRACTS_ID).into_location(); pub const Encointer: MultiLocation = Parachain(ENCOINTER_ID).into_location(); pub const Tick: MultiLocation = Parachain(100).into_location(); @@ -103,7 +103,7 @@ parameter_types! { pub const RocForTick: (MultiAssetFilter, MultiLocation) = (Roc::get(), Tick::get()); pub const RocForTrick: (MultiAssetFilter, MultiLocation) = (Roc::get(), Trick::get()); pub const RocForTrack: (MultiAssetFilter, MultiLocation) = (Roc::get(), Track::get()); - pub const RocForStatemine: (MultiAssetFilter, MultiLocation) = (Roc::get(), Statemine::get()); + pub const RocForStatemine: (MultiAssetFilter, MultiLocation) = (Roc::get(), Rockmine::get()); pub const RocForContracts: (MultiAssetFilter, MultiLocation) = (Roc::get(), Contracts::get()); pub const RocForEncointer: (MultiAssetFilter, MultiLocation) = (Roc::get(), Encointer::get()); pub const MaxInstructions: u32 = 100; @@ -122,9 +122,6 @@ match_types! { pub type OnlyParachains: impl Contains = { MultiLocation { parents: 0, interior: X1(Parachain(_)) } }; - pub type SystemParachains: impl Contains = { - MultiLocation { parents: 0, interior: X1(Parachain(STATEMINE_ID | CONTRACTS_ID | ENCOINTER_ID)) } - }; } /// The barriers one of which must be passed for an XCM message to be executed. @@ -335,7 +332,7 @@ parameter_types! { #[cfg(feature = "runtime-benchmarks")] parameter_types! { - pub ReachableDest: Option = Some(Parachain(STATEMINE_ID).into()); + pub ReachableDest: Option = Some(Parachain(ROCKMINE_ID).into()); } /// Type to convert the council origin to a Plurality `MultiLocation` value. From 12b816e30811df36141037614cddb3ba00bca07f Mon Sep 17 00:00:00 2001 From: Keith Yeung Date: Thu, 6 Apr 2023 19:20:38 +0800 Subject: [PATCH 12/27] Fixes --- runtime/kusama/src/xcm_config.rs | 2 +- runtime/polkadot/src/xcm_config.rs | 2 +- runtime/rococo/src/xcm_config.rs | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/runtime/kusama/src/xcm_config.rs b/runtime/kusama/src/xcm_config.rs index da4c483f44f7..1f927c01fefe 100644 --- a/runtime/kusama/src/xcm_config.rs +++ b/runtime/kusama/src/xcm_config.rs @@ -26,7 +26,7 @@ use frame_support::{ weights::Weight, }; use frame_system::EnsureRoot; -use kusama_runtime_constants::system_parachain::SystemParachains; +use kusama_runtime_constants::system_parachain::*; use runtime_common::{crowdloan, paras_registrar, xcm_sender, ToAuthor}; use sp_core::ConstU32; use xcm::latest::prelude::*; diff --git a/runtime/polkadot/src/xcm_config.rs b/runtime/polkadot/src/xcm_config.rs index de00c8daedcb..0bf44518dead 100644 --- a/runtime/polkadot/src/xcm_config.rs +++ b/runtime/polkadot/src/xcm_config.rs @@ -28,7 +28,7 @@ use frame_support::{ }; use frame_system::EnsureRoot; use pallet_xcm::XcmPassthrough; -use polkadot_runtime_constants::{system_parachain::SystemParachains, xcm::body::FELLOWSHIP_ADMIN_INDEX}; +use polkadot_runtime_constants::{system_parachain::*, xcm::body::FELLOWSHIP_ADMIN_INDEX}; use runtime_common::{crowdloan, paras_registrar, xcm_sender, ToAuthor}; use sp_core::ConstU32; use xcm::latest::prelude::*; diff --git a/runtime/rococo/src/xcm_config.rs b/runtime/rococo/src/xcm_config.rs index 0a193c1f42ae..6fbc26b2b723 100644 --- a/runtime/rococo/src/xcm_config.rs +++ b/runtime/rococo/src/xcm_config.rs @@ -26,7 +26,7 @@ use frame_support::{ weights::Weight, }; use frame_system::EnsureRoot; -use rococo_runtime_constants::system_parachain::SystemParachains; +use rococo_runtime_constants::system_parachain::*; use runtime_common::{crowdloan, paras_registrar, xcm_sender, ToAuthor}; use sp_core::ConstU32; use xcm::latest::prelude::*; From d22046fa6af2c776c9b2adb950dabb782c1d84af Mon Sep 17 00:00:00 2001 From: Keith Yeung Date: Thu, 6 Apr 2023 21:28:38 +0800 Subject: [PATCH 13/27] Fixes --- runtime/rococo/src/lib.rs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/runtime/rococo/src/lib.rs b/runtime/rococo/src/lib.rs index 7e1a6ec46aa5..93f1307bac88 100644 --- a/runtime/rococo/src/lib.rs +++ b/runtime/rococo/src/lib.rs @@ -2047,7 +2047,7 @@ sp_api::impl_runtime_apis! { type XcmConfig = XcmConfig; type AccountIdConverter = LocationConverter; fn valid_destination() -> Result { - Ok(Statemine::get()) + Ok(Rockmine::get()) } fn worst_case_holding(_depositable_count: u32) -> MultiAssets { // Rococo only knows about ROC @@ -2060,11 +2060,11 @@ sp_api::impl_runtime_apis! { parameter_types! { pub const TrustedTeleporter: Option<(MultiLocation, MultiAsset)> = Some(( - Statemine::get(), + Rockmine::get(), MultiAsset { fun: Fungible(1 * UNITS), id: Concrete(TokenLocation::get()) }, )); pub const TrustedReserve: Option<(MultiLocation, MultiAsset)> = Some(( - Statemine::get(), + Rockmine::get(), MultiAsset { fun: Fungible(1 * UNITS), id: Concrete(TokenLocation::get()) }, )); } @@ -2101,15 +2101,15 @@ sp_api::impl_runtime_apis! { } fn transact_origin_and_runtime_call() -> Result<(MultiLocation, RuntimeCall), BenchmarkError> { - Ok((Statemine::get(), frame_system::Call::remark_with_event { remark: vec![] }.into())) + Ok((Rockmine::get(), frame_system::Call::remark_with_event { remark: vec![] }.into())) } fn subscribe_origin() -> Result { - Ok(Statemine::get()) + Ok(Rockmine::get()) } fn claimable_asset() -> Result<(MultiLocation, MultiLocation, MultiAssets), BenchmarkError> { - let origin = Statemine::get(); + let origin = Rockmine::get(); let assets: MultiAssets = (Concrete(TokenLocation::get()), 1_000 * UNITS).into(); let ticket = MultiLocation { parents: 0, interior: Here }; Ok((origin, ticket, assets)) From 6c9f3f9cad3f26108687a798c006d69c0f0e5e68 Mon Sep 17 00:00:00 2001 From: Keith Yeung Date: Fri, 7 Apr 2023 23:37:01 +0800 Subject: [PATCH 14/27] cargo fmt --- runtime/kusama/constants/src/lib.rs | 2 +- runtime/rococo/constants/src/lib.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/runtime/kusama/constants/src/lib.rs b/runtime/kusama/constants/src/lib.rs index b7213352a58a..e8a0d5a2a35a 100644 --- a/runtime/kusama/constants/src/lib.rs +++ b/runtime/kusama/constants/src/lib.rs @@ -105,7 +105,7 @@ pub mod system_parachain { pub const STATEMINE_ID: u32 = 1000; /// Encointer parachain ID. pub const ENCOINTER_ID: u32 = 1001; - + frame_support::match_types! { pub type SystemParachains: impl Contains = { MultiLocation { parents: 0, interior: X1(Parachain(STATEMINE_ID | ENCOINTER_ID)) } diff --git a/runtime/rococo/constants/src/lib.rs b/runtime/rococo/constants/src/lib.rs index aa42cbda3890..41eb6ff37fff 100644 --- a/runtime/rococo/constants/src/lib.rs +++ b/runtime/rococo/constants/src/lib.rs @@ -109,7 +109,7 @@ pub mod system_parachain { pub const CONTRACTS_ID: u32 = 1002; /// Encointer parachain ID. pub const ENCOINTER_ID: u32 = 1003; - + frame_support::match_types! { pub type SystemParachains: impl Contains = { MultiLocation { parents: 0, interior: X1(Parachain(ROCKMINE_ID | CONTRACTS_ID | ENCOINTER_ID)) } From 424c903fcf9b93df905bc11d0b496e6f666c51fc Mon Sep 17 00:00:00 2001 From: Branislav Kontur Date: Wed, 12 Apr 2023 15:54:30 +0200 Subject: [PATCH 15/27] Added BridgeHubs constants (#7053) --- runtime/kusama/constants/src/lib.rs | 4 +++- runtime/kusama/src/xcm_config.rs | 9 +++++++-- runtime/polkadot/constants/src/lib.rs | 4 +++- runtime/polkadot/src/xcm_config.rs | 8 ++++++-- runtime/rococo/constants/src/lib.rs | 4 +++- runtime/rococo/src/xcm_config.rs | 3 +++ runtime/westend/constants/src/lib.rs | 2 ++ runtime/westend/src/xcm_config.rs | 9 +++++++-- 8 files changed, 34 insertions(+), 9 deletions(-) diff --git a/runtime/kusama/constants/src/lib.rs b/runtime/kusama/constants/src/lib.rs index e8a0d5a2a35a..9f07551ff478 100644 --- a/runtime/kusama/constants/src/lib.rs +++ b/runtime/kusama/constants/src/lib.rs @@ -105,10 +105,12 @@ pub mod system_parachain { pub const STATEMINE_ID: u32 = 1000; /// Encointer parachain ID. pub const ENCOINTER_ID: u32 = 1001; + /// BridgeHub parachain ID. + pub const BRIDGE_HUB_ID: u32 = 1002; frame_support::match_types! { pub type SystemParachains: impl Contains = { - MultiLocation { parents: 0, interior: X1(Parachain(STATEMINE_ID | ENCOINTER_ID)) } + MultiLocation { parents: 0, interior: X1(Parachain(STATEMINE_ID | ENCOINTER_ID | BRIDGE_HUB_ID)) } }; } } diff --git a/runtime/kusama/src/xcm_config.rs b/runtime/kusama/src/xcm_config.rs index 1f927c01fefe..3cb3d1cbc5be 100644 --- a/runtime/kusama/src/xcm_config.rs +++ b/runtime/kusama/src/xcm_config.rs @@ -117,12 +117,17 @@ parameter_types! { pub const Ksm: MultiAssetFilter = Wild(AllOf { fun: WildFungible, id: Concrete(TokenLocation::get()) }); pub const Statemine: MultiLocation = Parachain(STATEMINE_ID).into_location(); pub const Encointer: MultiLocation = Parachain(ENCOINTER_ID).into_location(); + pub const BridgeHub: MultiLocation = Parachain(BRIDGE_HUB_ID).into_location(); pub const KsmForStatemine: (MultiAssetFilter, MultiLocation) = (Ksm::get(), Statemine::get()); pub const KsmForEncointer: (MultiAssetFilter, MultiLocation) = (Ksm::get(), Encointer::get()); + pub const KsmForBridgeHub: (MultiAssetFilter, MultiLocation) = (Ksm::get(), BridgeHub::get()); pub const MaxAssetsIntoHolding: u32 = 64; } -pub type TrustedTeleporters = - (xcm_builder::Case, xcm_builder::Case); +pub type TrustedTeleporters = ( + xcm_builder::Case, + xcm_builder::Case, + xcm_builder::Case, +); match_types! { pub type OnlyParachains: impl Contains = { diff --git a/runtime/polkadot/constants/src/lib.rs b/runtime/polkadot/constants/src/lib.rs index df6f8a70e9fb..50fa3c886529 100644 --- a/runtime/polkadot/constants/src/lib.rs +++ b/runtime/polkadot/constants/src/lib.rs @@ -119,10 +119,12 @@ pub mod system_parachain { pub const STATEMINT_ID: u32 = 1000; /// Collectives parachain ID. pub const COLLECTIVES_ID: u32 = 1001; + /// BridgeHub parachain ID. + pub const BRIDGE_HUB_ID: u32 = 1002; frame_support::match_types! { pub type SystemParachains: impl Contains = { - MultiLocation { parents: 0, interior: X1(Parachain(STATEMINT_ID | COLLECTIVES_ID)) } + MultiLocation { parents: 0, interior: X1(Parachain(STATEMINT_ID | COLLECTIVES_ID | BRIDGE_HUB_ID)) } }; } } diff --git a/runtime/polkadot/src/xcm_config.rs b/runtime/polkadot/src/xcm_config.rs index 0bf44518dead..d220dbaccf9a 100644 --- a/runtime/polkadot/src/xcm_config.rs +++ b/runtime/polkadot/src/xcm_config.rs @@ -122,12 +122,16 @@ parameter_types! { pub const DotForStatemint: (MultiAssetFilter, MultiLocation) = (Dot::get(), Parachain(STATEMINT_ID).into_location()); pub const CollectivesLocation: MultiLocation = Parachain(COLLECTIVES_ID).into_location(); pub const DotForCollectives: (MultiAssetFilter, MultiLocation) = (Dot::get(), CollectivesLocation::get()); + pub const DotForBridgeHub: (MultiAssetFilter, MultiLocation) = (Dot::get(), Parachain(BRIDGE_HUB_ID).into_location()); pub const MaxAssetsIntoHolding: u32 = 64; } /// Polkadot Relay recognizes/respects the Statemint chain as a teleporter. -pub type TrustedTeleporters = - (xcm_builder::Case, xcm_builder::Case); +pub type TrustedTeleporters = ( + xcm_builder::Case, + xcm_builder::Case, + xcm_builder::Case, +); match_types! { pub type OnlyParachains: impl Contains = { diff --git a/runtime/rococo/constants/src/lib.rs b/runtime/rococo/constants/src/lib.rs index 41eb6ff37fff..60053e282f40 100644 --- a/runtime/rococo/constants/src/lib.rs +++ b/runtime/rococo/constants/src/lib.rs @@ -109,10 +109,12 @@ pub mod system_parachain { pub const CONTRACTS_ID: u32 = 1002; /// Encointer parachain ID. pub const ENCOINTER_ID: u32 = 1003; + /// BridgeHub parachain ID. + pub const BRIDGE_HUB_ID: u32 = 1013; frame_support::match_types! { pub type SystemParachains: impl Contains = { - MultiLocation { parents: 0, interior: X1(Parachain(ROCKMINE_ID | CONTRACTS_ID | ENCOINTER_ID)) } + MultiLocation { parents: 0, interior: X1(Parachain(ROCKMINE_ID | CONTRACTS_ID | ENCOINTER_ID | BRIDGE_HUB_ID)) } }; } } diff --git a/runtime/rococo/src/xcm_config.rs b/runtime/rococo/src/xcm_config.rs index 6fbc26b2b723..60afc772e3b6 100644 --- a/runtime/rococo/src/xcm_config.rs +++ b/runtime/rococo/src/xcm_config.rs @@ -97,6 +97,7 @@ parameter_types! { pub const Rockmine: MultiLocation = Parachain(ROCKMINE_ID).into_location(); pub const Contracts: MultiLocation = Parachain(CONTRACTS_ID).into_location(); pub const Encointer: MultiLocation = Parachain(ENCOINTER_ID).into_location(); + pub const BridgeHub: MultiLocation = Parachain(BRIDGE_HUB_ID).into_location(); pub const Tick: MultiLocation = Parachain(100).into_location(); pub const Trick: MultiLocation = Parachain(110).into_location(); pub const Track: MultiLocation = Parachain(120).into_location(); @@ -106,6 +107,7 @@ parameter_types! { pub const RocForStatemine: (MultiAssetFilter, MultiLocation) = (Roc::get(), Rockmine::get()); pub const RocForContracts: (MultiAssetFilter, MultiLocation) = (Roc::get(), Contracts::get()); pub const RocForEncointer: (MultiAssetFilter, MultiLocation) = (Roc::get(), Encointer::get()); + pub const RocForBridgeHub: (MultiAssetFilter, MultiLocation) = (Roc::get(), BridgeHub::get()); pub const MaxInstructions: u32 = 100; pub const MaxAssetsIntoHolding: u32 = 64; } @@ -116,6 +118,7 @@ pub type TrustedTeleporters = ( xcm_builder::Case, xcm_builder::Case, xcm_builder::Case, + xcm_builder::Case, ); match_types! { diff --git a/runtime/westend/constants/src/lib.rs b/runtime/westend/constants/src/lib.rs index e48944f9332f..537b720110e4 100644 --- a/runtime/westend/constants/src/lib.rs +++ b/runtime/westend/constants/src/lib.rs @@ -102,6 +102,8 @@ pub mod system_parachain { pub const WESTMINT_ID: u32 = 1000; /// Collectives parachain ID. pub const COLLECTIVES_ID: u32 = 1001; + /// BridgeHub parachain ID. + pub const BRIDGE_HUB_ID: u32 = 1002; } #[cfg(test)] diff --git a/runtime/westend/src/xcm_config.rs b/runtime/westend/src/xcm_config.rs index f6e5a9247628..95b26784b19c 100644 --- a/runtime/westend/src/xcm_config.rs +++ b/runtime/westend/src/xcm_config.rs @@ -80,9 +80,11 @@ pub type XcmRouter = ( parameter_types! { pub const Westmint: MultiLocation = Parachain(WESTMINT_ID).into_location(); pub const Collectives: MultiLocation = Parachain(COLLECTIVES_ID).into_location(); + pub const BridgeHub: MultiLocation = Parachain(BRIDGE_HUB_ID).into_location(); pub const Wnd: MultiAssetFilter = Wild(AllOf { fun: WildFungible, id: Concrete(TokenLocation::get()) }); pub const WndForWestmint: (MultiAssetFilter, MultiLocation) = (Wnd::get(), Westmint::get()); pub const WndForCollectives: (MultiAssetFilter, MultiLocation) = (Wnd::get(), Collectives::get()); + pub const WndForBridgeHub: (MultiAssetFilter, MultiLocation) = (Wnd::get(), BridgeHub::get()); pub const MaxInstructions: u32 = 100; pub const MaxAssetsIntoHolding: u32 = 64; } @@ -92,8 +94,11 @@ parameter_types! { pub ReachableDest: Option = Some(Parachain(WESTMINT_ID).into()); } -pub type TrustedTeleporters = - (xcm_builder::Case, xcm_builder::Case); +pub type TrustedTeleporters = ( + xcm_builder::Case, + xcm_builder::Case, + xcm_builder::Case, +); /// The barriers one of which must be passed for an XCM message to be executed. pub type Barrier = ( From a8529570670d66024c51b34142f28e36a45706c1 Mon Sep 17 00:00:00 2001 From: Keith Yeung Date: Thu, 13 Apr 2023 19:08:55 +0800 Subject: [PATCH 16/27] Add SystemParachain type to Westmint --- Cargo.lock | 1 + runtime/westend/constants/Cargo.toml | 4 +++- runtime/westend/constants/src/lib.rs | 11 +++++++++++ 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/Cargo.lock b/Cargo.lock index 5cd788f76538..d628a7971d39 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -13740,6 +13740,7 @@ dependencies = [ "sp-core", "sp-runtime", "sp-weights", + "xcm", ] [[package]] diff --git a/runtime/westend/constants/Cargo.toml b/runtime/westend/constants/Cargo.toml index c6fac15dca32..154207862369 100644 --- a/runtime/westend/constants/Cargo.toml +++ b/runtime/westend/constants/Cargo.toml @@ -13,6 +13,7 @@ runtime-common = { package = "polkadot-runtime-common", path = "../../common", d sp-runtime = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "master" } sp-weights = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "master" } sp-core = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "master" } +xcm = { path = "../../../xcm", default-features = false } [features] default = ["std"] @@ -22,5 +23,6 @@ std = [ "runtime-common/std", "sp-core/std", "sp-runtime/std", - "sp-weights/std" + "sp-weights/std", + "xcm/std", ] diff --git a/runtime/westend/constants/src/lib.rs b/runtime/westend/constants/src/lib.rs index 7d8be78ea246..58aa3ab0e179 100644 --- a/runtime/westend/constants/src/lib.rs +++ b/runtime/westend/constants/src/lib.rs @@ -98,12 +98,23 @@ pub mod fee { /// System Parachains. pub mod system_parachain { + use xcm::latest::prelude::*; + /// Westmint parachain ID. pub const WESTMINT_ID: u32 = 1000; /// Collectives parachain ID. pub const COLLECTIVES_ID: u32 = 1001; /// BridgeHub parachain ID. pub const BRIDGE_HUB_ID: u32 = 1002; + + frame_support::match_types! { + pub type SystemParachain: impl Contains = { + MultiLocation { + parents: 0, + interior: X1(Parachain(WESTMINT_ID | COLLECTIVES_ID | BRIDGE_HUB_ID)), + } + }; + } } #[cfg(test)] From e1b6af06baf67e0e232b9803ff5ba4ec2970b583 Mon Sep 17 00:00:00 2001 From: Keith Yeung Date: Thu, 20 Apr 2023 20:41:28 +0800 Subject: [PATCH 17/27] Fixes --- runtime/westend/constants/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/runtime/westend/constants/src/lib.rs b/runtime/westend/constants/src/lib.rs index 58aa3ab0e179..5455687b3e99 100644 --- a/runtime/westend/constants/src/lib.rs +++ b/runtime/westend/constants/src/lib.rs @@ -108,7 +108,7 @@ pub mod system_parachain { pub const BRIDGE_HUB_ID: u32 = 1002; frame_support::match_types! { - pub type SystemParachain: impl Contains = { + pub type SystemParachains: impl Contains = { MultiLocation { parents: 0, interior: X1(Parachain(WESTMINT_ID | COLLECTIVES_ID | BRIDGE_HUB_ID)), From 09828dad80b80e8ce0f021fcb4e8906c89e015bf Mon Sep 17 00:00:00 2001 From: Keith Yeung Date: Mon, 24 Apr 2023 21:18:27 +0800 Subject: [PATCH 18/27] Fixes --- runtime/rococo/constants/src/lib.rs | 2 +- runtime/rococo/src/xcm_config.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/runtime/rococo/constants/src/lib.rs b/runtime/rococo/constants/src/lib.rs index 1742524a6e56..2dc775ca0e25 100644 --- a/runtime/rococo/constants/src/lib.rs +++ b/runtime/rococo/constants/src/lib.rs @@ -103,7 +103,7 @@ pub mod fee { pub mod system_parachain { use xcm::latest::prelude::*; - /// Statemine parachain ID. + /// Rockmine parachain ID. pub const ROCKMINE_ID: u32 = 1000; /// Contracts parachain ID. pub const CONTRACTS_ID: u32 = 1002; diff --git a/runtime/rococo/src/xcm_config.rs b/runtime/rococo/src/xcm_config.rs index c0bd9de654c4..8088b062e06e 100644 --- a/runtime/rococo/src/xcm_config.rs +++ b/runtime/rococo/src/xcm_config.rs @@ -27,7 +27,7 @@ use frame_support::{ weights::Weight, }; use frame_system::EnsureRoot; -use rococo_runtime_constants::{currency::CENTS, system_parachain}; +use rococo_runtime_constants::{currency::CENTS, system_parachain::*}; use runtime_common::{ crowdloan, paras_registrar, xcm_sender::{ChildParachainRouter, ExponentialPrice}, From 0e06f73317157c17b05f6851e1728667a26f50b7 Mon Sep 17 00:00:00 2001 From: Keith Yeung Date: Fri, 28 Apr 2023 17:40:34 +0800 Subject: [PATCH 19/27] Waive fee handling during benchmarking --- xcm/xcm-builder/src/fee_handling.rs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/xcm/xcm-builder/src/fee_handling.rs b/xcm/xcm-builder/src/fee_handling.rs index 049055471d32..bd47a932c802 100644 --- a/xcm/xcm-builder/src/fee_handling.rs +++ b/xcm/xcm-builder/src/fee_handling.rs @@ -37,6 +37,10 @@ impl< > FeeManager for XcmFeesToAccount { fn is_waived(origin: Option<&MultiLocation>, _: FeeReason) -> bool { + #[cfg(feature = "runtime-benchmarks")] + { + return true + } let Some(loc) = origin else { return false }; WaivedLocations::contains(loc) } From 6a4fd76e4c78cd95af7a927c5c8fd415e3bee88e Mon Sep 17 00:00:00 2001 From: Keith Yeung Date: Fri, 28 Apr 2023 17:52:16 +0800 Subject: [PATCH 20/27] Fixes --- xcm/xcm-builder/src/fee_handling.rs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/xcm/xcm-builder/src/fee_handling.rs b/xcm/xcm-builder/src/fee_handling.rs index bd47a932c802..8a67d0c44eb9 100644 --- a/xcm/xcm-builder/src/fee_handling.rs +++ b/xcm/xcm-builder/src/fee_handling.rs @@ -41,8 +41,11 @@ impl< { return true } - let Some(loc) = origin else { return false }; - WaivedLocations::contains(loc) + #[cfg(not(feature = "runtime-benchmarks"))] + { + let Some(loc) = origin else { return false }; + WaivedLocations::contains(loc) + } } fn handle_fee(fees: MultiAssets, context: Option<&XcmContext>) { From 6eccb055b8095a6eb4727bb5a1d64df0af5b73c2 Mon Sep 17 00:00:00 2001 From: Keith Yeung Date: Fri, 28 Apr 2023 20:36:06 +0800 Subject: [PATCH 21/27] Fixes --- xcm/xcm-builder/src/fee_handling.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/xcm/xcm-builder/src/fee_handling.rs b/xcm/xcm-builder/src/fee_handling.rs index 8a67d0c44eb9..207d58d1fa00 100644 --- a/xcm/xcm-builder/src/fee_handling.rs +++ b/xcm/xcm-builder/src/fee_handling.rs @@ -39,7 +39,8 @@ impl< fn is_waived(origin: Option<&MultiLocation>, _: FeeReason) -> bool { #[cfg(feature = "runtime-benchmarks")] { - return true + let _ = origin; + true } #[cfg(not(feature = "runtime-benchmarks"))] { From de0e3970b35211a8373dc26d8a2100f6b58f79d7 Mon Sep 17 00:00:00 2001 From: Keith Yeung Date: Thu, 22 Jun 2023 14:15:57 +0100 Subject: [PATCH 22/27] Rename to ASSET_HUB_ID Co-authored-by: joe petrowski <25483142+joepetrowski@users.noreply.github.com> --- runtime/kusama/constants/src/lib.rs | 6 +++--- runtime/kusama/src/xcm_config.rs | 4 ++-- runtime/polkadot/constants/src/lib.rs | 6 +++--- runtime/rococo/constants/src/lib.rs | 6 +++--- runtime/rococo/src/xcm_config.rs | 4 ++-- runtime/westend/constants/src/lib.rs | 4 ++-- runtime/westend/src/xcm_config.rs | 4 ++-- 7 files changed, 17 insertions(+), 17 deletions(-) diff --git a/runtime/kusama/constants/src/lib.rs b/runtime/kusama/constants/src/lib.rs index 195d0135b38c..3edac3b302ad 100644 --- a/runtime/kusama/constants/src/lib.rs +++ b/runtime/kusama/constants/src/lib.rs @@ -101,8 +101,8 @@ pub mod fee { pub mod system_parachain { use xcm::latest::prelude::*; - /// Statemine parachain ID. - pub const STATEMINE_ID: u32 = 1000; + /// Network's Asset Hub parachain ID. + pub const ASSET_HUB_ID: u32 = 1000; /// Encointer parachain ID. pub const ENCOINTER_ID: u32 = 1001; /// BridgeHub parachain ID. @@ -110,7 +110,7 @@ pub mod system_parachain { frame_support::match_types! { pub type SystemParachains: impl Contains = { - MultiLocation { parents: 0, interior: X1(Parachain(STATEMINE_ID | ENCOINTER_ID | BRIDGE_HUB_ID)) } + MultiLocation { parents: 0, interior: X1(Parachain(ASSET_HUB_ID | ENCOINTER_ID | BRIDGE_HUB_ID)) } }; } } diff --git a/runtime/kusama/src/xcm_config.rs b/runtime/kusama/src/xcm_config.rs index 3b3342f33b3b..f54cb051e5c5 100644 --- a/runtime/kusama/src/xcm_config.rs +++ b/runtime/kusama/src/xcm_config.rs @@ -128,7 +128,7 @@ pub type XcmRouter = ( parameter_types! { pub const Ksm: MultiAssetFilter = Wild(AllOf { fun: WildFungible, id: Concrete(TokenLocation::get()) }); - pub const Statemine: MultiLocation = Parachain(STATEMINE_ID).into_location(); + pub const Statemine: MultiLocation = Parachain(ASSET_HUB_ID).into_location(); pub const Encointer: MultiLocation = Parachain(ENCOINTER_ID).into_location(); pub const BridgeHub: MultiLocation = Parachain(BRIDGE_HUB_ID).into_location(); pub const KsmForStatemine: (MultiAssetFilter, MultiLocation) = (Ksm::get(), Statemine::get()); @@ -375,7 +375,7 @@ parameter_types! { #[cfg(feature = "runtime-benchmarks")] parameter_types! { - pub ReachableDest: Option = Some(Parachain(STATEMINE_ID).into()); + pub ReachableDest: Option = Some(Parachain(ASSET_HUB_ID).into()); } /// Type to convert an `Origin` type value into a `MultiLocation` value which represents an interior location diff --git a/runtime/polkadot/constants/src/lib.rs b/runtime/polkadot/constants/src/lib.rs index c86537f7bde5..9c0df0bba39f 100644 --- a/runtime/polkadot/constants/src/lib.rs +++ b/runtime/polkadot/constants/src/lib.rs @@ -115,8 +115,8 @@ pub mod xcm { pub mod system_parachain { use xcm::latest::prelude::*; - /// Statemint parachain ID. - pub const STATEMINT_ID: u32 = 1000; + /// Network's Asset Hub parachain ID. + pub const ASSET_HUB_ID: u32 = 1000; /// Collectives parachain ID. pub const COLLECTIVES_ID: u32 = 1001; /// BridgeHub parachain ID. @@ -124,7 +124,7 @@ pub mod system_parachain { frame_support::match_types! { pub type SystemParachains: impl Contains = { - MultiLocation { parents: 0, interior: X1(Parachain(STATEMINT_ID | COLLECTIVES_ID | BRIDGE_HUB_ID)) } + MultiLocation { parents: 0, interior: X1(Parachain(ASSET_HUB_ID | COLLECTIVES_ID | BRIDGE_HUB_ID)) } }; } } diff --git a/runtime/rococo/constants/src/lib.rs b/runtime/rococo/constants/src/lib.rs index 2dc775ca0e25..bda05db149a2 100644 --- a/runtime/rococo/constants/src/lib.rs +++ b/runtime/rococo/constants/src/lib.rs @@ -103,8 +103,8 @@ pub mod fee { pub mod system_parachain { use xcm::latest::prelude::*; - /// Rockmine parachain ID. - pub const ROCKMINE_ID: u32 = 1000; + /// Network's Asset Hub parachain ID. + pub const ASSET_HUB_ID: u32 = 1000; /// Contracts parachain ID. pub const CONTRACTS_ID: u32 = 1002; /// Encointer parachain ID. @@ -114,7 +114,7 @@ pub mod system_parachain { frame_support::match_types! { pub type SystemParachains: impl Contains = { - MultiLocation { parents: 0, interior: X1(Parachain(ROCKMINE_ID | CONTRACTS_ID | ENCOINTER_ID | BRIDGE_HUB_ID)) } + MultiLocation { parents: 0, interior: X1(Parachain(ASSET_HUB_ID | CONTRACTS_ID | ENCOINTER_ID | BRIDGE_HUB_ID)) } }; } } diff --git a/runtime/rococo/src/xcm_config.rs b/runtime/rococo/src/xcm_config.rs index 8088b062e06e..9a4c8aace99c 100644 --- a/runtime/rococo/src/xcm_config.rs +++ b/runtime/rococo/src/xcm_config.rs @@ -108,7 +108,7 @@ pub type XcmRouter = ( parameter_types! { pub const Roc: MultiAssetFilter = Wild(AllOf { fun: WildFungible, id: Concrete(TokenLocation::get()) }); - pub const Rockmine: MultiLocation = Parachain(ROCKMINE_ID).into_location(); + pub const Rockmine: MultiLocation = Parachain(ASSET_HUB_ID).into_location(); pub const Contracts: MultiLocation = Parachain(CONTRACTS_ID).into_location(); pub const Encointer: MultiLocation = Parachain(ENCOINTER_ID).into_location(); pub const BridgeHub: MultiLocation = Parachain(BRIDGE_HUB_ID).into_location(); @@ -347,7 +347,7 @@ parameter_types! { #[cfg(feature = "runtime-benchmarks")] parameter_types! { - pub ReachableDest: Option = Some(Parachain(ROCKMINE_ID).into()); + pub ReachableDest: Option = Some(Parachain(ASSET_HUB_ID).into()); } /// Type to convert the council origin to a Plurality `MultiLocation` value. diff --git a/runtime/westend/constants/src/lib.rs b/runtime/westend/constants/src/lib.rs index 5455687b3e99..b01805c9dfa8 100644 --- a/runtime/westend/constants/src/lib.rs +++ b/runtime/westend/constants/src/lib.rs @@ -100,8 +100,8 @@ pub mod fee { pub mod system_parachain { use xcm::latest::prelude::*; - /// Westmint parachain ID. - pub const WESTMINT_ID: u32 = 1000; + /// Network's Asset Hub parachain ID. + pub const ASSET_HUB_ID: u32 = 1000; /// Collectives parachain ID. pub const COLLECTIVES_ID: u32 = 1001; /// BridgeHub parachain ID. diff --git a/runtime/westend/src/xcm_config.rs b/runtime/westend/src/xcm_config.rs index a7b82e00a02c..9717fd04b2c2 100644 --- a/runtime/westend/src/xcm_config.rs +++ b/runtime/westend/src/xcm_config.rs @@ -90,7 +90,7 @@ pub type XcmRouter = ( ); parameter_types! { - pub const Westmint: MultiLocation = Parachain(WESTMINT_ID).into_location(); + pub const Westmint: MultiLocation = Parachain(ASSET_HUB_ID).into_location(); pub const Collectives: MultiLocation = Parachain(COLLECTIVES_ID).into_location(); pub const BridgeHub: MultiLocation = Parachain(BRIDGE_HUB_ID).into_location(); pub const Wnd: MultiAssetFilter = Wild(AllOf { fun: WildFungible, id: Concrete(TokenLocation::get()) }); @@ -103,7 +103,7 @@ parameter_types! { #[cfg(feature = "runtime-benchmarks")] parameter_types! { - pub ReachableDest: Option = Some(Parachain(WESTMINT_ID).into()); + pub ReachableDest: Option = Some(Parachain(ASSET_HUB_ID).into()); } pub type TrustedTeleporters = ( From 8bb8fb90eac20d6c35f82212c70153163e133f94 Mon Sep 17 00:00:00 2001 From: Keith Yeung Date: Thu, 22 Jun 2023 14:47:40 +0000 Subject: [PATCH 23/27] Rename all asset parachains to AssetHub --- runtime/kusama/src/lib.rs | 12 ++++++------ runtime/kusama/src/xcm_config.rs | 6 +++--- runtime/polkadot/src/xcm_config.rs | 7 ++++--- runtime/rococo/src/lib.rs | 14 +++++++------- runtime/rococo/src/xcm_config.rs | 6 +++--- runtime/westend/constants/src/lib.rs | 2 +- runtime/westend/src/lib.rs | 12 ++++++------ runtime/westend/src/xcm_config.rs | 6 +++--- scripts/ci/gitlab/lingua.dic | 1 - xcm/src/v3/mod.rs | 2 +- xcm/xcm-builder/tests/mock/mod.rs | 4 ++-- xcm/xcm-builder/tests/scenarios.rs | 12 ++++++------ 12 files changed, 42 insertions(+), 42 deletions(-) diff --git a/runtime/kusama/src/lib.rs b/runtime/kusama/src/lib.rs index 5dd7819ea587..6dacab8f848a 100644 --- a/runtime/kusama/src/lib.rs +++ b/runtime/kusama/src/lib.rs @@ -2016,7 +2016,7 @@ sp_api::impl_runtime_apis! { use frame_benchmarking::baseline::Pallet as Baseline; use xcm::latest::prelude::*; use xcm_config::{ - LocalCheckAccount, SovereignAccountOf, Statemine, TokenLocation, XcmConfig, + LocalCheckAccount, SovereignAccountOf, AssetHub, TokenLocation, XcmConfig, }; impl pallet_session_benchmarking::Config for Runtime {} @@ -2031,7 +2031,7 @@ sp_api::impl_runtime_apis! { type XcmConfig = XcmConfig; type AccountIdConverter = SovereignAccountOf; fn valid_destination() -> Result { - Ok(Statemine::get()) + Ok(AssetHub::get()) } fn worst_case_holding(_depositable_count: u32) -> MultiAssets { // Kusama only knows about KSM. @@ -2044,7 +2044,7 @@ sp_api::impl_runtime_apis! { parameter_types! { pub const TrustedTeleporter: Option<(MultiLocation, MultiAsset)> = Some(( - Statemine::get(), + AssetHub::get(), MultiAsset { fun: Fungible(1 * UNITS), id: Concrete(TokenLocation::get()) }, )); } @@ -2081,15 +2081,15 @@ sp_api::impl_runtime_apis! { } fn transact_origin_and_runtime_call() -> Result<(MultiLocation, RuntimeCall), BenchmarkError> { - Ok((Statemine::get(), frame_system::Call::remark_with_event { remark: vec![] }.into())) + Ok((AssetHub::get(), frame_system::Call::remark_with_event { remark: vec![] }.into())) } fn subscribe_origin() -> Result { - Ok(Statemine::get()) + Ok(AssetHub::get()) } fn claimable_asset() -> Result<(MultiLocation, MultiLocation, MultiAssets), BenchmarkError> { - let origin = Statemine::get(); + let origin = AssetHub::get(); let assets: MultiAssets = (Concrete(TokenLocation::get()), 1_000 * UNITS).into(); let ticket = MultiLocation { parents: 0, interior: Here }; Ok((origin, ticket, assets)) diff --git a/runtime/kusama/src/xcm_config.rs b/runtime/kusama/src/xcm_config.rs index f54cb051e5c5..6e04fc113368 100644 --- a/runtime/kusama/src/xcm_config.rs +++ b/runtime/kusama/src/xcm_config.rs @@ -128,16 +128,16 @@ pub type XcmRouter = ( parameter_types! { pub const Ksm: MultiAssetFilter = Wild(AllOf { fun: WildFungible, id: Concrete(TokenLocation::get()) }); - pub const Statemine: MultiLocation = Parachain(ASSET_HUB_ID).into_location(); + pub const AssetHub: MultiLocation = Parachain(ASSET_HUB_ID).into_location(); pub const Encointer: MultiLocation = Parachain(ENCOINTER_ID).into_location(); pub const BridgeHub: MultiLocation = Parachain(BRIDGE_HUB_ID).into_location(); - pub const KsmForStatemine: (MultiAssetFilter, MultiLocation) = (Ksm::get(), Statemine::get()); + pub const KsmForAssetHub: (MultiAssetFilter, MultiLocation) = (Ksm::get(), AssetHub::get()); pub const KsmForEncointer: (MultiAssetFilter, MultiLocation) = (Ksm::get(), Encointer::get()); pub const KsmForBridgeHub: (MultiAssetFilter, MultiLocation) = (Ksm::get(), BridgeHub::get()); pub const MaxAssetsIntoHolding: u32 = 64; } pub type TrustedTeleporters = ( - xcm_builder::Case, + xcm_builder::Case, xcm_builder::Case, xcm_builder::Case, ); diff --git a/runtime/polkadot/src/xcm_config.rs b/runtime/polkadot/src/xcm_config.rs index d23a3808be58..f6307696d61f 100644 --- a/runtime/polkadot/src/xcm_config.rs +++ b/runtime/polkadot/src/xcm_config.rs @@ -136,16 +136,17 @@ pub type XcmRouter = ( parameter_types! { pub const Dot: MultiAssetFilter = Wild(AllOf { fun: WildFungible, id: Concrete(TokenLocation::get()) }); - pub const DotForStatemint: (MultiAssetFilter, MultiLocation) = (Dot::get(), Parachain(STATEMINT_ID).into_location()); + pub const DotForAssetHub: (MultiAssetFilter, MultiLocation) = (Dot::get(), Parachain(ASSET_HUB_ID).into_location()); pub const CollectivesLocation: MultiLocation = Parachain(COLLECTIVES_ID).into_location(); pub const DotForCollectives: (MultiAssetFilter, MultiLocation) = (Dot::get(), CollectivesLocation::get()); pub const DotForBridgeHub: (MultiAssetFilter, MultiLocation) = (Dot::get(), Parachain(BRIDGE_HUB_ID).into_location()); pub const MaxAssetsIntoHolding: u32 = 64; } -/// Polkadot Relay recognizes/respects the Statemint chain as a teleporter. +/// Polkadot Relay recognizes/respects the Asset Hub, Collectives and Bridge hub chains as a +/// teleporter. pub type TrustedTeleporters = ( - xcm_builder::Case, + xcm_builder::Case, xcm_builder::Case, xcm_builder::Case, ); diff --git a/runtime/rococo/src/lib.rs b/runtime/rococo/src/lib.rs index 1c907eadb62a..ec18d70930d1 100644 --- a/runtime/rococo/src/lib.rs +++ b/runtime/rococo/src/lib.rs @@ -2025,7 +2025,7 @@ sp_api::impl_runtime_apis! { use frame_benchmarking::baseline::Pallet as Baseline; use xcm::latest::prelude::*; use xcm_config::{ - LocalCheckAccount, LocationConverter, Rockmine, TokenLocation, XcmConfig, + LocalCheckAccount, LocationConverter, AssetHub, TokenLocation, XcmConfig, }; impl frame_system_benchmarking::Config for Runtime {} @@ -2034,7 +2034,7 @@ sp_api::impl_runtime_apis! { type XcmConfig = XcmConfig; type AccountIdConverter = LocationConverter; fn valid_destination() -> Result { - Ok(Rockmine::get()) + Ok(AssetHub::get()) } fn worst_case_holding(_depositable_count: u32) -> MultiAssets { // Rococo only knows about ROC @@ -2047,11 +2047,11 @@ sp_api::impl_runtime_apis! { parameter_types! { pub const TrustedTeleporter: Option<(MultiLocation, MultiAsset)> = Some(( - Rockmine::get(), + AssetHub::get(), MultiAsset { fun: Fungible(1 * UNITS), id: Concrete(TokenLocation::get()) }, )); pub const TrustedReserve: Option<(MultiLocation, MultiAsset)> = Some(( - Rockmine::get(), + AssetHub::get(), MultiAsset { fun: Fungible(1 * UNITS), id: Concrete(TokenLocation::get()) }, )); } @@ -2088,15 +2088,15 @@ sp_api::impl_runtime_apis! { } fn transact_origin_and_runtime_call() -> Result<(MultiLocation, RuntimeCall), BenchmarkError> { - Ok((Rockmine::get(), frame_system::Call::remark_with_event { remark: vec![] }.into())) + Ok((AssetHub::get(), frame_system::Call::remark_with_event { remark: vec![] }.into())) } fn subscribe_origin() -> Result { - Ok(Rockmine::get()) + Ok(AssetHub::get()) } fn claimable_asset() -> Result<(MultiLocation, MultiLocation, MultiAssets), BenchmarkError> { - let origin = Rockmine::get(); + let origin = AssetHub::get(); let assets: MultiAssets = (Concrete(TokenLocation::get()), 1_000 * UNITS).into(); let ticket = MultiLocation { parents: 0, interior: Here }; Ok((origin, ticket, assets)) diff --git a/runtime/rococo/src/xcm_config.rs b/runtime/rococo/src/xcm_config.rs index 9a4c8aace99c..69fbb48a4806 100644 --- a/runtime/rococo/src/xcm_config.rs +++ b/runtime/rococo/src/xcm_config.rs @@ -108,7 +108,7 @@ pub type XcmRouter = ( parameter_types! { pub const Roc: MultiAssetFilter = Wild(AllOf { fun: WildFungible, id: Concrete(TokenLocation::get()) }); - pub const Rockmine: MultiLocation = Parachain(ASSET_HUB_ID).into_location(); + pub const AssetHub: MultiLocation = Parachain(ASSET_HUB_ID).into_location(); pub const Contracts: MultiLocation = Parachain(CONTRACTS_ID).into_location(); pub const Encointer: MultiLocation = Parachain(ENCOINTER_ID).into_location(); pub const BridgeHub: MultiLocation = Parachain(BRIDGE_HUB_ID).into_location(); @@ -118,7 +118,7 @@ parameter_types! { pub const RocForTick: (MultiAssetFilter, MultiLocation) = (Roc::get(), Tick::get()); pub const RocForTrick: (MultiAssetFilter, MultiLocation) = (Roc::get(), Trick::get()); pub const RocForTrack: (MultiAssetFilter, MultiLocation) = (Roc::get(), Track::get()); - pub const RocForStatemine: (MultiAssetFilter, MultiLocation) = (Roc::get(), Rockmine::get()); + pub const RocForAssetHub: (MultiAssetFilter, MultiLocation) = (Roc::get(), AssetHub::get()); pub const RocForContracts: (MultiAssetFilter, MultiLocation) = (Roc::get(), Contracts::get()); pub const RocForEncointer: (MultiAssetFilter, MultiLocation) = (Roc::get(), Encointer::get()); pub const RocForBridgeHub: (MultiAssetFilter, MultiLocation) = (Roc::get(), BridgeHub::get()); @@ -129,7 +129,7 @@ pub type TrustedTeleporters = ( xcm_builder::Case, xcm_builder::Case, xcm_builder::Case, - xcm_builder::Case, + xcm_builder::Case, xcm_builder::Case, xcm_builder::Case, xcm_builder::Case, diff --git a/runtime/westend/constants/src/lib.rs b/runtime/westend/constants/src/lib.rs index b01805c9dfa8..930743ce162a 100644 --- a/runtime/westend/constants/src/lib.rs +++ b/runtime/westend/constants/src/lib.rs @@ -111,7 +111,7 @@ pub mod system_parachain { pub type SystemParachains: impl Contains = { MultiLocation { parents: 0, - interior: X1(Parachain(WESTMINT_ID | COLLECTIVES_ID | BRIDGE_HUB_ID)), + interior: X1(Parachain(ASSET_HUB_ID | COLLECTIVES_ID | BRIDGE_HUB_ID)), } }; } diff --git a/runtime/westend/src/lib.rs b/runtime/westend/src/lib.rs index c4fcbc35e545..a6f3cdcce1de 100644 --- a/runtime/westend/src/lib.rs +++ b/runtime/westend/src/lib.rs @@ -1770,13 +1770,13 @@ sp_api::impl_runtime_apis! { AssetId::*, Fungibility::*, InteriorMultiLocation, Junction, Junctions::*, MultiAsset, MultiAssets, MultiLocation, NetworkId, Response, }; - use xcm_config::{Westmint, TokenLocation}; + use xcm_config::{AssetHub, TokenLocation}; impl pallet_xcm_benchmarks::Config for Runtime { type XcmConfig = xcm_config::XcmConfig; type AccountIdConverter = xcm_config::LocationConverter; fn valid_destination() -> Result { - Ok(Westmint::get()) + Ok(AssetsHub::get()) } fn worst_case_holding(_depositable_count: u32) -> MultiAssets { // Westend only knows about WND. @@ -1789,7 +1789,7 @@ sp_api::impl_runtime_apis! { parameter_types! { pub const TrustedTeleporter: Option<(MultiLocation, MultiAsset)> = Some(( - Westmint::get(), + AssetHub::get(), MultiAsset { fun: Fungible(1 * UNITS), id: Concrete(TokenLocation::get()) }, )); } @@ -1826,15 +1826,15 @@ sp_api::impl_runtime_apis! { } fn transact_origin_and_runtime_call() -> Result<(MultiLocation, RuntimeCall), BenchmarkError> { - Ok((Westmint::get(), frame_system::Call::remark_with_event { remark: vec![] }.into())) + Ok((AssetHub::get(), frame_system::Call::remark_with_event { remark: vec![] }.into())) } fn subscribe_origin() -> Result { - Ok(Westmint::get()) + Ok(AssetHub::get()) } fn claimable_asset() -> Result<(MultiLocation, MultiLocation, MultiAssets), BenchmarkError> { - let origin = Westmint::get(); + let origin = AssetHub::get(); let assets: MultiAssets = (Concrete(TokenLocation::get()), 1_000 * UNITS).into(); let ticket = MultiLocation { parents: 0, interior: Here }; Ok((origin, ticket, assets)) diff --git a/runtime/westend/src/xcm_config.rs b/runtime/westend/src/xcm_config.rs index 9717fd04b2c2..e31e5a709956 100644 --- a/runtime/westend/src/xcm_config.rs +++ b/runtime/westend/src/xcm_config.rs @@ -90,11 +90,11 @@ pub type XcmRouter = ( ); parameter_types! { - pub const Westmint: MultiLocation = Parachain(ASSET_HUB_ID).into_location(); + pub const AssetHub: MultiLocation = Parachain(ASSET_HUB_ID).into_location(); pub const Collectives: MultiLocation = Parachain(COLLECTIVES_ID).into_location(); pub const BridgeHub: MultiLocation = Parachain(BRIDGE_HUB_ID).into_location(); pub const Wnd: MultiAssetFilter = Wild(AllOf { fun: WildFungible, id: Concrete(TokenLocation::get()) }); - pub const WndForWestmint: (MultiAssetFilter, MultiLocation) = (Wnd::get(), Westmint::get()); + pub const WndForAssetHub: (MultiAssetFilter, MultiLocation) = (Wnd::get(), AssetHub::get()); pub const WndForCollectives: (MultiAssetFilter, MultiLocation) = (Wnd::get(), Collectives::get()); pub const WndForBridgeHub: (MultiAssetFilter, MultiLocation) = (Wnd::get(), BridgeHub::get()); pub const MaxInstructions: u32 = 100; @@ -107,7 +107,7 @@ parameter_types! { } pub type TrustedTeleporters = ( - xcm_builder::Case, + xcm_builder::Case, xcm_builder::Case, xcm_builder::Case, ); diff --git a/scripts/ci/gitlab/lingua.dic b/scripts/ci/gitlab/lingua.dic index d9dad4540277..57b28afa6b74 100644 --- a/scripts/ci/gitlab/lingua.dic +++ b/scripts/ci/gitlab/lingua.dic @@ -256,7 +256,6 @@ SS58 SSL startup/MS stateful -Statemine str struct/MS subcommand/SM diff --git a/xcm/src/v3/mod.rs b/xcm/src/v3/mod.rs index 435998255a9c..c37d626a3893 100644 --- a/xcm/src/v3/mod.rs +++ b/xcm/src/v3/mod.rs @@ -893,7 +893,7 @@ pub enum Instruction { /// should be sent on arrival. /// - `xcm`: The message to be exported. /// - /// As an example, to export a message for execution on Statemine (parachain #1000 in the + /// As an example, to export a message for execution on Asset Hub (parachain #1000 in the /// Kusama network), you would call with `network: NetworkId::Kusama` and /// `destination: X1(Parachain(1000))`. Alternatively, to export a message for execution on /// Polkadot, you would call with `network: NetworkId:: Polkadot` and `destination: Here`. diff --git a/xcm/xcm-builder/tests/mock/mod.rs b/xcm/xcm-builder/tests/mock/mod.rs index 4bd1d78b5fbb..1312f4f65acd 100644 --- a/xcm/xcm-builder/tests/mock/mod.rs +++ b/xcm/xcm-builder/tests/mock/mod.rs @@ -170,13 +170,13 @@ pub type Barrier = ( ); parameter_types! { - pub KusamaForStatemine: (MultiAssetFilter, MultiLocation) = + pub KusamaForAssetHub: (MultiAssetFilter, MultiLocation) = (Wild(AllOf { id: Concrete(Here.into()), fun: WildFungible }), Parachain(1000).into()); pub const MaxInstructions: u32 = 100; pub const MaxAssetsIntoHolding: u32 = 4; } -pub type TrustedTeleporters = (xcm_builder::Case,); +pub type TrustedTeleporters = (xcm_builder::Case,); pub struct XcmConfig; impl xcm_executor::Config for XcmConfig { diff --git a/xcm/xcm-builder/tests/scenarios.rs b/xcm/xcm-builder/tests/scenarios.rs index 64e9b86a91cd..95d939a6027c 100644 --- a/xcm/xcm-builder/tests/scenarios.rs +++ b/xcm/xcm-builder/tests/scenarios.rs @@ -175,7 +175,7 @@ fn report_holding_works() { } /// Scenario: -/// A parachain wants to move KSM from Kusama to Statemine. +/// A parachain wants to move KSM from Kusama to Asset Hub. /// The parachain sends an XCM to withdraw funds combined with a teleport to the destination. /// /// This way of moving funds from a relay to a parachain will only work for trusted chains. @@ -183,12 +183,12 @@ fn report_holding_works() { /// /// Asserts that the balances are updated accordingly and the correct XCM is sent. #[test] -fn teleport_to_statemine_works() { +fn teleport_to_asset_hub_works() { use xcm::opaque::latest::prelude::*; let para_acc: AccountId = ParaId::from(PARA_ID).into_account_truncating(); let balances = vec![(ALICE, INITIAL_BALANCE), (para_acc.clone(), INITIAL_BALANCE)]; kusama_like_with_balances(balances).execute_with(|| { - let statemine_id = 1000; + let asset_hub_id = 1000; let other_para_id = 3000; let amount = REGISTER_AMOUNT; let teleport_effects = vec![ @@ -223,13 +223,13 @@ fn teleport_to_statemine_works() { vec![(Parachain(other_para_id).into(), expected_msg, expected_hash,)] ); - // teleports are allowed from statemine to kusama. + // teleports are allowed from asset hub to kusama. let message = Xcm(vec![ WithdrawAsset((Here, amount).into()), buy_execution(), InitiateTeleport { assets: All.into(), - dest: Parachain(statemine_id).into(), + dest: Parachain(asset_hub_id).into(), xcm: Xcm(teleport_effects.clone()), }, ]); @@ -247,7 +247,7 @@ fn teleport_to_statemine_works() { mock::sent_xcm(), vec![ (Parachain(other_para_id).into(), expected_msg.clone(), expected_hash,), - (Parachain(statemine_id).into(), expected_msg, expected_hash,) + (Parachain(asset_hub_id).into(), expected_msg, expected_hash,) ] ); }); From 4843e581d141cd85e23d549783ea0b0d3ce50b83 Mon Sep 17 00:00:00 2001 From: Keith Yeung Date: Thu, 22 Jun 2023 15:32:09 +0000 Subject: [PATCH 24/27] Fix typo --- runtime/westend/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/runtime/westend/src/lib.rs b/runtime/westend/src/lib.rs index 65514f7a6190..78757aea5b0e 100644 --- a/runtime/westend/src/lib.rs +++ b/runtime/westend/src/lib.rs @@ -1917,7 +1917,7 @@ sp_api::impl_runtime_apis! { type XcmConfig = xcm_config::XcmConfig; type AccountIdConverter = xcm_config::LocationConverter; fn valid_destination() -> Result { - Ok(AssetsHub::get()) + Ok(AssetHub::get()) } fn worst_case_holding(_depositable_count: u32) -> MultiAssets { // Westend only knows about WND. From 7c3bb1af26db991978fe6f226b7acd1487f718a4 Mon Sep 17 00:00:00 2001 From: command-bot <> Date: Thu, 22 Jun 2023 16:34:31 +0000 Subject: [PATCH 25/27] ".git/.scripts/commands/fmt/fmt.sh" --- runtime/kusama/src/xcm_config.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/runtime/kusama/src/xcm_config.rs b/runtime/kusama/src/xcm_config.rs index 76b51a20b267..e68982f8f4c2 100644 --- a/runtime/kusama/src/xcm_config.rs +++ b/runtime/kusama/src/xcm_config.rs @@ -42,7 +42,7 @@ use xcm_builder::{ CurrencyAdapter as XcmCurrencyAdapter, FixedWeightBounds, IsChildSystemParachain, IsConcrete, MintLocation, OriginToPluralityVoice, SignedAccountId32AsNative, SignedToAccountId32, SovereignSignedViaLocation, TakeWeightCredit, TrailingSetTopicAsId, UsingComponents, - WeightInfoBounds, WithComputedOrigin, WithUniqueTopic, XcmFeesToAccount, + WeightInfoBounds, WithComputedOrigin, WithUniqueTopic, XcmFeesToAccount, }; use xcm_executor::traits::WithOriginFilter; From 7d61d2e331bbc60c433d4825841e7b8e36862556 Mon Sep 17 00:00:00 2001 From: Keith Yeung Date: Wed, 2 Aug 2023 15:07:55 -0700 Subject: [PATCH 26/27] Fixes --- runtime/rococo/src/lib.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/runtime/rococo/src/lib.rs b/runtime/rococo/src/lib.rs index 5720f19c33c1..418d65a6f576 100644 --- a/runtime/rococo/src/lib.rs +++ b/runtime/rococo/src/lib.rs @@ -2121,7 +2121,6 @@ sp_api::impl_runtime_apis! { AssetHub::get(), MultiAsset { fun: Fungible(1 * UNITS), id: Concrete(TokenLocation::get()) }, )); - pub const TrustedReserve: Option<(MultiLocation, MultiAsset)> = None; } impl pallet_xcm_benchmarks::fungible::Config for Runtime { From 18945f8d04f147bf35ade62db25ea1ccccce29bd Mon Sep 17 00:00:00 2001 From: Keith Yeung Date: Wed, 2 Aug 2023 16:34:46 -0700 Subject: [PATCH 27/27] Fixes --- runtime/kusama/src/xcm_config.rs | 13 ++++++++----- runtime/polkadot/src/lib.rs | 12 ++++++------ runtime/polkadot/src/xcm_config.rs | 2 +- 3 files changed, 15 insertions(+), 12 deletions(-) diff --git a/runtime/kusama/src/xcm_config.rs b/runtime/kusama/src/xcm_config.rs index 1305e8c4504a..3e7e51aad571 100644 --- a/runtime/kusama/src/xcm_config.rs +++ b/runtime/kusama/src/xcm_config.rs @@ -439,8 +439,10 @@ fn karura_liquid_staking_xcm_has_sane_weight_upper_limt() { // should be [WithdrawAsset, BuyExecution, Transact, RefundSurplus, DepositAsset] let blob = hex_literal::hex!("02140004000000000700e40b540213000000000700e40b54020006010700c817a804341801000006010b00c490bf4302140d010003ffffffff000100411f"); - let Ok(VersionedXcm::V2(old_xcm)) = - VersionedXcm::::decode(&mut &blob[..]) else { panic!("can't decode XCM blob") }; + let Ok(VersionedXcm::V2(old_xcm)) = VersionedXcm::::decode(&mut &blob[..]) + else { + panic!("can't decode XCM blob") + }; let mut xcm: Xcm = old_xcm.try_into().expect("conversion from v2 to v3 failed"); let weight = ::Weigher::weight(&mut xcm) @@ -451,9 +453,10 @@ fn karura_liquid_staking_xcm_has_sane_weight_upper_limt() { assert!(weight.all_lte(Weight::from_parts(30_313_281_000, 72_722))); let Some(Transact { require_weight_at_most, call, .. }) = - xcm.inner_mut().into_iter().find(|inst| matches!(inst, Transact { .. })) else { - panic!("no Transact instruction found") - }; + xcm.inner_mut().into_iter().find(|inst| matches!(inst, Transact { .. })) + else { + panic!("no Transact instruction found") + }; // should be pallet_utility.as_derivative { index: 0, call: pallet_staking::bond_extra { max_additional: 2490000000000 } } let message_call = call.take_decoded().expect("can't decode Transact call"); let call_weight = message_call.get_dispatch_info().weight; diff --git a/runtime/polkadot/src/lib.rs b/runtime/polkadot/src/lib.rs index 55ddb4707791..00fac5eb5eb1 100644 --- a/runtime/polkadot/src/lib.rs +++ b/runtime/polkadot/src/lib.rs @@ -2084,7 +2084,7 @@ sp_api::impl_runtime_apis! { use frame_system_benchmarking::Pallet as SystemBench; use frame_benchmarking::baseline::Pallet as Baseline; use xcm::latest::prelude::*; - use xcm_config::{XcmConfig, StatemintLocation, TokenLocation, LocalCheckAccount, SovereignAccountOf}; + use xcm_config::{XcmConfig, AssetHubLocation, TokenLocation, LocalCheckAccount, SovereignAccountOf}; impl pallet_session_benchmarking::Config for Runtime {} impl pallet_offences_benchmarking::Config for Runtime {} @@ -2102,7 +2102,7 @@ sp_api::impl_runtime_apis! { type XcmConfig = XcmConfig; type AccountIdConverter = SovereignAccountOf; fn valid_destination() -> Result { - Ok(StatemintLocation::get()) + Ok(AssetHubLocation::get()) } fn worst_case_holding(_depositable_count: u32) -> MultiAssets { // Polkadot only knows about DOT @@ -2112,7 +2112,7 @@ sp_api::impl_runtime_apis! { parameter_types! { pub const TrustedTeleporter: Option<(MultiLocation, MultiAsset)> = Some(( - StatemintLocation::get(), + AssetHubLocation::get(), MultiAsset { id: Concrete(TokenLocation::get()), fun: Fungible(1 * UNITS) } )); pub const TrustedReserve: Option<(MultiLocation, MultiAsset)> = None; @@ -2151,15 +2151,15 @@ sp_api::impl_runtime_apis! { } fn transact_origin_and_runtime_call() -> Result<(MultiLocation, RuntimeCall), BenchmarkError> { - Ok((StatemintLocation::get(), frame_system::Call::remark_with_event { remark: vec![] }.into())) + Ok((AssetHubLocation::get(), frame_system::Call::remark_with_event { remark: vec![] }.into())) } fn subscribe_origin() -> Result { - Ok(StatemintLocation::get()) + Ok(AssetHubLocation::get()) } fn claimable_asset() -> Result<(MultiLocation, MultiLocation, MultiAssets), BenchmarkError> { - let origin = StatemintLocation::get(); + let origin = AssetHubLocation::get(); let assets: MultiAssets = (Concrete(TokenLocation::get()), 1_000 * UNITS).into(); let ticket = MultiLocation { parents: 0, interior: Here }; Ok((origin, ticket, assets)) diff --git a/runtime/polkadot/src/xcm_config.rs b/runtime/polkadot/src/xcm_config.rs index 1dab756b3671..5ae13cb89d16 100644 --- a/runtime/polkadot/src/xcm_config.rs +++ b/runtime/polkadot/src/xcm_config.rs @@ -133,7 +133,7 @@ pub type XcmRouter = ( parameter_types! { pub const Dot: MultiAssetFilter = Wild(AllOf { fun: WildFungible, id: Concrete(TokenLocation::get()) }); - pub const AssetHubLocation: MultiLocation = Parachan(ASSET_HUB_ID).into_location(); + pub const AssetHubLocation: MultiLocation = Parachain(ASSET_HUB_ID).into_location(); pub const DotForAssetHub: (MultiAssetFilter, MultiLocation) = (Dot::get(), AssetHubLocation::get()); pub const CollectivesLocation: MultiLocation = Parachain(COLLECTIVES_ID).into_location(); pub const DotForCollectives: (MultiAssetFilter, MultiLocation) = (Dot::get(), CollectivesLocation::get());