From 31f7879a1d9200fa01e3dcd21f6701a1cc34dbee Mon Sep 17 00:00:00 2001 From: Adrian Catangiu Date: Fri, 1 Nov 2024 17:11:30 +0200 Subject: [PATCH 01/40] make docs for LocalOriginToLocation uniform across codebase --- .../assets/asset-hub-rococo/src/xcm_config.rs | 4 ++-- .../assets/asset-hub-westend/src/xcm_config.rs | 3 ++- .../bridge-hubs/bridge-hub-rococo/src/xcm_config.rs | 4 ++-- .../bridge-hubs/bridge-hub-westend/src/xcm_config.rs | 4 ++-- .../collectives-westend/src/xcm_config.rs | 4 ++-- .../contracts/contracts-rococo/src/xcm_config.rs | 4 ++-- .../runtimes/testing/penpal/src/xcm_config.rs | 3 ++- .../runtimes/testing/rococo-parachain/src/lib.rs | 3 ++- polkadot/runtime/westend/src/xcm_config.rs | 3 ++- .../relay_token_transactor/parachain/xcm_config.rs | 2 ++ .../relay_token_transactor/relay_chain/xcm_config.rs | 2 ++ polkadot/xcm/pallet-xcm/src/lib.rs | 12 ++++++++++++ polkadot/xcm/pallet-xcm/src/mock.rs | 2 ++ .../src/asset_exchange/single_asset_adapter/mock.rs | 2 ++ polkadot/xcm/xcm-builder/src/tests/pay/mock.rs | 2 ++ polkadot/xcm/xcm-builder/tests/mock/mod.rs | 2 ++ polkadot/xcm/xcm-runtime-apis/tests/mock.rs | 2 ++ .../parachain/runtime/src/configs/xcm_config.rs | 3 ++- 18 files changed, 46 insertions(+), 15 deletions(-) diff --git a/cumulus/parachains/runtimes/assets/asset-hub-rococo/src/xcm_config.rs b/cumulus/parachains/runtimes/assets/asset-hub-rococo/src/xcm_config.rs index 56310959aa80..3f075cb1b36f 100644 --- a/cumulus/parachains/runtimes/assets/asset-hub-rococo/src/xcm_config.rs +++ b/cumulus/parachains/runtimes/assets/asset-hub-rococo/src/xcm_config.rs @@ -448,8 +448,8 @@ impl xcm_executor::Config for XcmConfig { type XcmRecorder = PolkadotXcm; } -/// Converts a local signed origin into an XCM location. -/// Forms the basis for local origins sending/executing XCMs. +/// Converts a local signed origin into an XCM location. Forms the basis for local origins +/// sending/executing XCMs. pub type LocalOriginToLocation = SignedToAccountId32; pub type PriceForParentDelivery = diff --git a/cumulus/parachains/runtimes/assets/asset-hub-westend/src/xcm_config.rs b/cumulus/parachains/runtimes/assets/asset-hub-westend/src/xcm_config.rs index f16dbcc02519..b8f64da0228c 100644 --- a/cumulus/parachains/runtimes/assets/asset-hub-westend/src/xcm_config.rs +++ b/cumulus/parachains/runtimes/assets/asset-hub-westend/src/xcm_config.rs @@ -470,7 +470,8 @@ impl xcm_executor::Config for XcmConfig { type XcmRecorder = PolkadotXcm; } -/// Local origins on this chain are allowed to dispatch XCM sends/executions. +/// Converts a local signed origin into an XCM location. Forms the basis for local origins +/// sending/executing XCMs. pub type LocalOriginToLocation = SignedToAccountId32; pub type PriceForParentDelivery = diff --git a/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/xcm_config.rs b/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/xcm_config.rs index 2fb186703a88..d66c5e5acccb 100644 --- a/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/xcm_config.rs +++ b/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/xcm_config.rs @@ -237,8 +237,8 @@ impl xcm_executor::Config for XcmConfig { pub type PriceForParentDelivery = ExponentialPrice; -/// Converts a local signed origin into an XCM location. -/// Forms the basis for local origins sending/executing XCMs. +/// Converts a local signed origin into an XCM location. Forms the basis for local origins +/// sending/executing XCMs. pub type LocalOriginToLocation = SignedToAccountId32; /// The means for routing XCM messages which are not for local execution into the right message diff --git a/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-westend/src/xcm_config.rs b/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-westend/src/xcm_config.rs index ae31ca4cedf2..edd62bb68c1c 100644 --- a/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-westend/src/xcm_config.rs +++ b/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-westend/src/xcm_config.rs @@ -231,8 +231,8 @@ impl xcm_executor::Config for XcmConfig { pub type PriceForParentDelivery = ExponentialPrice; -/// Converts a local signed origin into an XCM location. -/// Forms the basis for local origins sending/executing XCMs. +/// Converts a local signed origin into an XCM location. Forms the basis for local origins +/// sending/executing XCMs. pub type LocalOriginToLocation = SignedToAccountId32; /// The means for routing XCM messages which are not for local execution into the right message diff --git a/cumulus/parachains/runtimes/collectives/collectives-westend/src/xcm_config.rs b/cumulus/parachains/runtimes/collectives/collectives-westend/src/xcm_config.rs index f8e03303c32e..d7f75ba47e04 100644 --- a/cumulus/parachains/runtimes/collectives/collectives-westend/src/xcm_config.rs +++ b/cumulus/parachains/runtimes/collectives/collectives-westend/src/xcm_config.rs @@ -235,8 +235,8 @@ impl xcm_executor::Config for XcmConfig { type XcmRecorder = PolkadotXcm; } -/// Converts a local signed origin into an XCM location. -/// Forms the basis for local origins sending/executing XCMs. +/// Converts a local signed origin into an XCM location. Forms the basis for local origins +/// sending/executing XCMs. pub type LocalOriginToLocation = SignedToAccountId32; pub type PriceForParentDelivery = diff --git a/cumulus/parachains/runtimes/contracts/contracts-rococo/src/xcm_config.rs b/cumulus/parachains/runtimes/contracts/contracts-rococo/src/xcm_config.rs index 39fdd30a0498..5aa0f15b6f18 100644 --- a/cumulus/parachains/runtimes/contracts/contracts-rococo/src/xcm_config.rs +++ b/cumulus/parachains/runtimes/contracts/contracts-rococo/src/xcm_config.rs @@ -208,8 +208,8 @@ impl xcm_executor::Config for XcmConfig { type XcmRecorder = PolkadotXcm; } -/// Converts a local signed origin into an XCM location. -/// Forms the basis for local origins sending/executing XCMs. +/// Converts a local signed origin into an XCM location. Forms the basis for local origins +/// sending/executing XCMs. pub type LocalOriginToLocation = SignedToAccountId32; pub type PriceForParentDelivery = diff --git a/cumulus/parachains/runtimes/testing/penpal/src/xcm_config.rs b/cumulus/parachains/runtimes/testing/penpal/src/xcm_config.rs index b72d6d232a1d..71004bce11bb 100644 --- a/cumulus/parachains/runtimes/testing/penpal/src/xcm_config.rs +++ b/cumulus/parachains/runtimes/testing/penpal/src/xcm_config.rs @@ -415,7 +415,8 @@ pub type ForeignAssetFeeAsExistentialDepositMultiplierFeeCharger = ForeignAssetsInstance, >; -/// No local origins on this chain are allowed to dispatch XCM sends/executions. +/// Converts a local signed origin into an XCM location. Forms the basis for local origins +/// sending/executing XCMs. pub type LocalOriginToLocation = SignedToAccountId32; pub type PriceForParentDelivery = diff --git a/cumulus/parachains/runtimes/testing/rococo-parachain/src/lib.rs b/cumulus/parachains/runtimes/testing/rococo-parachain/src/lib.rs index 095f571974f0..e7f1e7145847 100644 --- a/cumulus/parachains/runtimes/testing/rococo-parachain/src/lib.rs +++ b/cumulus/parachains/runtimes/testing/rococo-parachain/src/lib.rs @@ -498,7 +498,8 @@ impl xcm_executor::Config for XcmConfig { type XcmRecorder = PolkadotXcm; } -/// Local origins on this chain are allowed to dispatch XCM sends/executions. +/// Converts a local signed origin into an XCM location. Forms the basis for local origins +/// sending/executing XCMs. pub type LocalOriginToLocation = SignedToAccountId32; /// The means for routing XCM messages which are not for local execution into the right message diff --git a/polkadot/runtime/westend/src/xcm_config.rs b/polkadot/runtime/westend/src/xcm_config.rs index d75083929a04..fd615095f4b9 100644 --- a/polkadot/runtime/westend/src/xcm_config.rs +++ b/polkadot/runtime/westend/src/xcm_config.rs @@ -239,7 +239,8 @@ parameter_types! { pub type GeneralAdminToPlurality = OriginToPluralityVoice; -/// location of this chain. +/// Converts a local signed origin into an XCM location. Forms the basis for local origins +/// sending/executing XCMs. pub type LocalOriginToLocation = ( GeneralAdminToPlurality, // And a usual Signed origin to be used in XCM as a corresponding AccountId32 diff --git a/polkadot/xcm/docs/src/cookbook/relay_token_transactor/parachain/xcm_config.rs b/polkadot/xcm/docs/src/cookbook/relay_token_transactor/parachain/xcm_config.rs index f8a1826b8ab1..d2d5da1f040a 100644 --- a/polkadot/xcm/docs/src/cookbook/relay_token_transactor/parachain/xcm_config.rs +++ b/polkadot/xcm/docs/src/cookbook/relay_token_transactor/parachain/xcm_config.rs @@ -146,6 +146,8 @@ impl xcm_executor::Config for XcmConfig { type XcmRecorder = (); } +/// Converts a local signed origin into an XCM location. Forms the basis for local origins +/// sending/executing XCMs. pub type LocalOriginToLocation = SignedToAccountId32; impl pallet_xcm::Config for Runtime { diff --git a/polkadot/xcm/docs/src/cookbook/relay_token_transactor/relay_chain/xcm_config.rs b/polkadot/xcm/docs/src/cookbook/relay_token_transactor/relay_chain/xcm_config.rs index e7b602df7338..ebb068b064a7 100644 --- a/polkadot/xcm/docs/src/cookbook/relay_token_transactor/relay_chain/xcm_config.rs +++ b/polkadot/xcm/docs/src/cookbook/relay_token_transactor/relay_chain/xcm_config.rs @@ -119,6 +119,8 @@ impl xcm_executor::Config for XcmConfig { type XcmRecorder = (); } +/// Converts a local signed origin into an XCM location. Forms the basis for local origins +/// sending/executing XCMs. pub type LocalOriginToLocation = SignedToAccountId32; impl pallet_xcm::Config for Runtime { diff --git a/polkadot/xcm/pallet-xcm/src/lib.rs b/polkadot/xcm/pallet-xcm/src/lib.rs index 9b8f735b478f..37cc7df81b11 100644 --- a/polkadot/xcm/pallet-xcm/src/lib.rs +++ b/polkadot/xcm/pallet-xcm/src/lib.rs @@ -3429,6 +3429,18 @@ where } } +/// Filter for `(origin: Location, target: Location)` to find whether `target` has explicitly +/// authorized `origin` to alias it. +/// +/// TODO: how to authorize?. +pub struct AuthorizedAliases; +impl ContainsPair for AuthorizedAliases { + fn contains(origin: &Location, target: &Location) -> bool { + // TODO: use storage + return false + } +} + /// Filter for `Location` to find those which represent a strict majority approval of an /// identified plurality. /// diff --git a/polkadot/xcm/pallet-xcm/src/mock.rs b/polkadot/xcm/pallet-xcm/src/mock.rs index 8d0476b0e70d..604f1e100e21 100644 --- a/polkadot/xcm/pallet-xcm/src/mock.rs +++ b/polkadot/xcm/pallet-xcm/src/mock.rs @@ -518,6 +518,8 @@ impl xcm_executor::Config for XcmConfig { type XcmRecorder = XcmPallet; } +/// Converts a local signed origin into an XCM location. Forms the basis for local origins +/// sending/executing XCMs. pub type LocalOriginToLocation = SignedToAccountId32; parameter_types! { diff --git a/polkadot/xcm/xcm-builder/src/asset_exchange/single_asset_adapter/mock.rs b/polkadot/xcm/xcm-builder/src/asset_exchange/single_asset_adapter/mock.rs index e6fe8e45c265..2f0287c3c2b7 100644 --- a/polkadot/xcm/xcm-builder/src/asset_exchange/single_asset_adapter/mock.rs +++ b/polkadot/xcm/xcm-builder/src/asset_exchange/single_asset_adapter/mock.rs @@ -290,6 +290,8 @@ parameter_types! { pub const NoNetwork: Option = None; } +/// Converts a local signed origin into an XCM location. Forms the basis for local origins +/// sending/executing XCMs. pub type LocalOriginToLocation = SignedToAccountIndex64; impl pallet_xcm::Config for Runtime { diff --git a/polkadot/xcm/xcm-builder/src/tests/pay/mock.rs b/polkadot/xcm/xcm-builder/src/tests/pay/mock.rs index 26ea226313f0..e4771a185cf7 100644 --- a/polkadot/xcm/xcm-builder/src/tests/pay/mock.rs +++ b/polkadot/xcm/xcm-builder/src/tests/pay/mock.rs @@ -160,6 +160,8 @@ impl MaybeEquivalence } } +/// Converts a local signed origin into an XCM location. Forms the basis for local origins +/// sending/executing XCMs. pub type LocalOriginToLocation = SignedToAccountId32; pub type LocalAssetsTransactor = FungiblesAdapter< Assets, diff --git a/polkadot/xcm/xcm-builder/tests/mock/mod.rs b/polkadot/xcm/xcm-builder/tests/mock/mod.rs index 0468b0a5410c..2a0148d409c5 100644 --- a/polkadot/xcm/xcm-builder/tests/mock/mod.rs +++ b/polkadot/xcm/xcm-builder/tests/mock/mod.rs @@ -197,6 +197,8 @@ impl xcm_executor::Config for XcmConfig { type XcmRecorder = XcmPallet; } +/// Converts a local signed origin into an XCM location. Forms the basis for local origins +/// sending/executing XCMs. pub type LocalOriginToLocation = SignedToAccountId32; impl pallet_xcm::Config for Runtime { diff --git a/polkadot/xcm/xcm-runtime-apis/tests/mock.rs b/polkadot/xcm/xcm-runtime-apis/tests/mock.rs index 4a5de8875007..c3ff778b4dc8 100644 --- a/polkadot/xcm/xcm-runtime-apis/tests/mock.rs +++ b/polkadot/xcm/xcm-runtime-apis/tests/mock.rs @@ -332,6 +332,8 @@ where } } +/// Converts a local signed origin into an XCM location. Forms the basis for local origins +/// sending/executing XCMs. pub type LocalOriginToLocation = SignedToAccountIndex64; impl pallet_xcm::Config for TestRuntime { diff --git a/templates/parachain/runtime/src/configs/xcm_config.rs b/templates/parachain/runtime/src/configs/xcm_config.rs index 3da3b711f4ff..09e8e3bfef1b 100644 --- a/templates/parachain/runtime/src/configs/xcm_config.rs +++ b/templates/parachain/runtime/src/configs/xcm_config.rs @@ -150,7 +150,8 @@ impl xcm_executor::Config for XcmConfig { type XcmRecorder = PolkadotXcm; } -/// No local origins on this chain are allowed to dispatch XCM sends/executions. +/// Converts a local signed origin into an XCM location. Forms the basis for local origins +/// sending/executing XCMs. pub type LocalOriginToLocation = SignedToAccountId32; /// The means for routing XCM messages which are not for local execution into the right message From 7a0af10404bc876de5d61d62ee9ea42f2336a62e Mon Sep 17 00:00:00 2001 From: Adrian Catangiu Date: Fri, 1 Nov 2024 18:36:56 +0200 Subject: [PATCH 02/40] pallet-xcm: add support for authorizing aliases --- polkadot/xcm/pallet-xcm/src/lib.rs | 82 ++++++++++++++++++++++++++++-- 1 file changed, 77 insertions(+), 5 deletions(-) diff --git a/polkadot/xcm/pallet-xcm/src/lib.rs b/polkadot/xcm/pallet-xcm/src/lib.rs index 37cc7df81b11..d4392fb51456 100644 --- a/polkadot/xcm/pallet-xcm/src/lib.rs +++ b/polkadot/xcm/pallet-xcm/src/lib.rs @@ -97,6 +97,8 @@ pub trait WeightInfo { fn new_query() -> Weight; fn take_response() -> Weight; fn claim_assets() -> Weight; + fn add_authorized_alias() -> Weight; + fn remove_authorized_alias() -> Weight; } /// fallback implementation @@ -181,6 +183,14 @@ impl WeightInfo for TestWeightInfo { fn claim_assets() -> Weight { Weight::from_parts(100_000_000, 0) } + + fn add_authorized_alias() -> Weight { + Weight::from_parts(100_000, 0) + } + + fn remove_authorized_alias() -> Weight { + Weight::from_parts(100_000, 0) + } } #[frame_support::pallet] @@ -199,6 +209,9 @@ pub mod pallet { /// An implementation of `Get` which just returns the latest XCM version which we can /// support. pub const CurrentXcmVersion: u32 = XCM_VERSION; + + /// The maximum number of distinct locations allowed as authorized aliases for a local origin. + pub const MaxAuthorizedAliases: u32 = 10; } const STORAGE_VERSION: StorageVersion = StorageVersion::new(1); @@ -574,6 +587,9 @@ pub mod pallet { /// Local XCM execution incomplete. #[codec(index = 24)] LocalExecutionIncomplete, + /// Too many locations authorized to alias origin. + #[codec(index = 25)] + TooManyAuthorizedAliases, } impl From for Error { @@ -793,6 +809,17 @@ pub mod pallet { #[pallet::storage] pub(crate) type RecordedXcm = StorageValue<_, Xcm<()>>; + /// Map of authorized aliasers of local origins. Each local location can authorize a list of + /// other locations to alias into it. + #[pallet::storage] + pub(super) type AuthorizedAliases = StorageMap< + _, + Blake2_128Concat, + Location, + BoundedVec, + ValueQuery, + >; + #[pallet::genesis_config] pub struct GenesisConfig { #[serde(skip)] @@ -1425,6 +1452,51 @@ pub mod pallet { weight_limit, ) } + + /// Authorize another `aliaser` location to alias into the local `origin` making this call. + /// + /// Usually useful to allow your local account to be aliased into from a remote location + /// also under your control (like your account on another chain). + /// + /// WARNING: make sure the caller `origin` (you) trusts the `aliaser` location to act in + /// their/your name. Once authorized using this call, the `aliaser` can freely impersonate + /// `origin` in XCM programs executed on the local chain. + #[pallet::call_index(14)] + pub fn add_authorized_alias( + origin: OriginFor, + aliaser: Box, + ) -> DispatchResult { + let origin = T::ExecuteXcmOrigin::ensure_origin(origin)?; + let aliaser = (*aliaser).try_into().map_err(|()| Error::::BadVersion)?; + ensure!(origin != aliaser, Error::::BadLocation); + let mut authorized_aliases = AuthorizedAliases::::get(&origin); + if !authorized_aliases.contains(&aliaser) { + authorized_aliases + .try_push(aliaser) + .map_err(|_| Error::::TooManyAuthorizedAliases)?; + AuthorizedAliases::::insert(&origin, authorized_aliases); + } + Ok(()) + } + + /// Remove a previously authorized `aliaser` from the list of locations that can alias into + /// the local `origin` making this call. + #[pallet::call_index(15)] + pub fn remove_authorized_alias( + origin: OriginFor, + aliaser: Box, + ) -> DispatchResult { + let origin = T::ExecuteXcmOrigin::ensure_origin(origin)?; + let to_remove = (*aliaser).try_into().map_err(|()| Error::::BadVersion)?; + ensure!(origin != to_remove, Error::::BadLocation); + let mut authorized_aliases = AuthorizedAliases::::get(&origin); + let original_length = authorized_aliases.len(); + authorized_aliases.retain(|alias| to_remove.ne(alias)); + if original_length != authorized_aliases.len() { + AuthorizedAliases::::insert(&origin, authorized_aliases); + } + Ok(()) + } } } @@ -3432,12 +3504,12 @@ where /// Filter for `(origin: Location, target: Location)` to find whether `target` has explicitly /// authorized `origin` to alias it. /// -/// TODO: how to authorize?. -pub struct AuthorizedAliases; -impl ContainsPair for AuthorizedAliases { +/// Note: users can authorize other locations to alias them by using +/// `pallet_xcm::add_authorized_alias()`. +pub struct AuthorizedAliases(PhantomData); +impl ContainsPair for AuthorizedAliases { fn contains(origin: &Location, target: &Location) -> bool { - // TODO: use storage - return false + pallet::AuthorizedAliases::::get(&origin).contains(target) } } From 879d48b4666b4b394a90b43155ad16a878eeb9db Mon Sep 17 00:00:00 2001 From: Adrian Catangiu Date: Wed, 6 Nov 2024 16:41:18 +0200 Subject: [PATCH 03/40] add stub weights --- .../asset-hub-rococo/src/weights/pallet_xcm.rs | 14 ++++++++++++++ .../asset-hub-westend/src/weights/pallet_xcm.rs | 14 ++++++++++++++ .../bridge-hub-rococo/src/weights/pallet_xcm.rs | 14 ++++++++++++++ .../bridge-hub-westend/src/weights/pallet_xcm.rs | 14 ++++++++++++++ .../collectives-westend/src/weights/pallet_xcm.rs | 14 ++++++++++++++ .../coretime-rococo/src/weights/pallet_xcm.rs | 14 ++++++++++++++ .../coretime-westend/src/weights/pallet_xcm.rs | 14 ++++++++++++++ .../people/people-rococo/src/weights/pallet_xcm.rs | 14 ++++++++++++++ .../people-westend/src/weights/pallet_xcm.rs | 14 ++++++++++++++ polkadot/runtime/rococo/src/weights/pallet_xcm.rs | 14 ++++++++++++++ polkadot/runtime/westend/src/weights/pallet_xcm.rs | 14 ++++++++++++++ 11 files changed, 154 insertions(+) diff --git a/cumulus/parachains/runtimes/assets/asset-hub-rococo/src/weights/pallet_xcm.rs b/cumulus/parachains/runtimes/assets/asset-hub-rococo/src/weights/pallet_xcm.rs index 51b6543bae82..ab4dd9af31ad 100644 --- a/cumulus/parachains/runtimes/assets/asset-hub-rococo/src/weights/pallet_xcm.rs +++ b/cumulus/parachains/runtimes/assets/asset-hub-rococo/src/weights/pallet_xcm.rs @@ -48,6 +48,20 @@ use core::marker::PhantomData; /// Weight functions for `pallet_xcm`. pub struct WeightInfo(PhantomData); impl pallet_xcm::WeightInfo for WeightInfo { + fn add_authorized_alias() -> Weight { + // TODO: benchmark + Weight::from_parts(3_724_000, 0) + .saturating_add(Weight::from_parts(0, 1517)) + .saturating_add(T::DbWeight::get().reads(1)) + .saturating_add(T::DbWeight::get().writes(1)) + } + fn remove_authorized_alias() -> Weight { + // TODO: benchmark + Weight::from_parts(3_724_000, 0) + .saturating_add(Weight::from_parts(0, 1517)) + .saturating_add(T::DbWeight::get().reads(1)) + .saturating_add(T::DbWeight::get().writes(1)) + } /// Storage: `ParachainSystem::UpwardDeliveryFeeFactor` (r:1 w:0) /// Proof: `ParachainSystem::UpwardDeliveryFeeFactor` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) /// Storage: `PolkadotXcm::SupportedVersion` (r:1 w:0) diff --git a/cumulus/parachains/runtimes/assets/asset-hub-westend/src/weights/pallet_xcm.rs b/cumulus/parachains/runtimes/assets/asset-hub-westend/src/weights/pallet_xcm.rs index be3d7661ab3c..0c0c08077dab 100644 --- a/cumulus/parachains/runtimes/assets/asset-hub-westend/src/weights/pallet_xcm.rs +++ b/cumulus/parachains/runtimes/assets/asset-hub-westend/src/weights/pallet_xcm.rs @@ -48,6 +48,20 @@ use core::marker::PhantomData; /// Weight functions for `pallet_xcm`. pub struct WeightInfo(PhantomData); impl pallet_xcm::WeightInfo for WeightInfo { + fn add_authorized_alias() -> Weight { + // TODO: benchmark + Weight::from_parts(3_724_000, 0) + .saturating_add(Weight::from_parts(0, 1517)) + .saturating_add(T::DbWeight::get().reads(1)) + .saturating_add(T::DbWeight::get().writes(1)) + } + fn remove_authorized_alias() -> Weight { + // TODO: benchmark + Weight::from_parts(3_724_000, 0) + .saturating_add(Weight::from_parts(0, 1517)) + .saturating_add(T::DbWeight::get().reads(1)) + .saturating_add(T::DbWeight::get().writes(1)) + } /// Storage: `ParachainSystem::UpwardDeliveryFeeFactor` (r:1 w:0) /// Proof: `ParachainSystem::UpwardDeliveryFeeFactor` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) /// Storage: `PolkadotXcm::SupportedVersion` (r:1 w:0) diff --git a/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/weights/pallet_xcm.rs b/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/weights/pallet_xcm.rs index a732e1a57343..c01243ef1c5b 100644 --- a/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/weights/pallet_xcm.rs +++ b/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/weights/pallet_xcm.rs @@ -48,6 +48,20 @@ use core::marker::PhantomData; /// Weight functions for `pallet_xcm`. pub struct WeightInfo(PhantomData); impl pallet_xcm::WeightInfo for WeightInfo { + fn add_authorized_alias() -> Weight { + // TODO: benchmark + Weight::from_parts(3_724_000, 0) + .saturating_add(Weight::from_parts(0, 1517)) + .saturating_add(T::DbWeight::get().reads(1)) + .saturating_add(T::DbWeight::get().writes(1)) + } + fn remove_authorized_alias() -> Weight { + // TODO: benchmark + Weight::from_parts(3_724_000, 0) + .saturating_add(Weight::from_parts(0, 1517)) + .saturating_add(T::DbWeight::get().reads(1)) + .saturating_add(T::DbWeight::get().writes(1)) + } /// Storage: `ParachainSystem::UpwardDeliveryFeeFactor` (r:1 w:0) /// Proof: `ParachainSystem::UpwardDeliveryFeeFactor` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) /// Storage: `PolkadotXcm::SupportedVersion` (r:1 w:0) diff --git a/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-westend/src/weights/pallet_xcm.rs b/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-westend/src/weights/pallet_xcm.rs index a78ff2355efa..76846397c7d2 100644 --- a/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-westend/src/weights/pallet_xcm.rs +++ b/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-westend/src/weights/pallet_xcm.rs @@ -48,6 +48,20 @@ use core::marker::PhantomData; /// Weight functions for `pallet_xcm`. pub struct WeightInfo(PhantomData); impl pallet_xcm::WeightInfo for WeightInfo { + fn add_authorized_alias() -> Weight { + // TODO: benchmark + Weight::from_parts(3_724_000, 0) + .saturating_add(Weight::from_parts(0, 1517)) + .saturating_add(T::DbWeight::get().reads(1)) + .saturating_add(T::DbWeight::get().writes(1)) + } + fn remove_authorized_alias() -> Weight { + // TODO: benchmark + Weight::from_parts(3_724_000, 0) + .saturating_add(Weight::from_parts(0, 1517)) + .saturating_add(T::DbWeight::get().reads(1)) + .saturating_add(T::DbWeight::get().writes(1)) + } /// Storage: `ParachainSystem::UpwardDeliveryFeeFactor` (r:1 w:0) /// Proof: `ParachainSystem::UpwardDeliveryFeeFactor` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) /// Storage: `PolkadotXcm::SupportedVersion` (r:1 w:0) diff --git a/cumulus/parachains/runtimes/collectives/collectives-westend/src/weights/pallet_xcm.rs b/cumulus/parachains/runtimes/collectives/collectives-westend/src/weights/pallet_xcm.rs index 5d427d850046..58b773939de6 100644 --- a/cumulus/parachains/runtimes/collectives/collectives-westend/src/weights/pallet_xcm.rs +++ b/cumulus/parachains/runtimes/collectives/collectives-westend/src/weights/pallet_xcm.rs @@ -48,6 +48,20 @@ use core::marker::PhantomData; /// Weight functions for `pallet_xcm`. pub struct WeightInfo(PhantomData); impl pallet_xcm::WeightInfo for WeightInfo { + fn add_authorized_alias() -> Weight { + // TODO: benchmark + Weight::from_parts(3_724_000, 0) + .saturating_add(Weight::from_parts(0, 1517)) + .saturating_add(T::DbWeight::get().reads(1)) + .saturating_add(T::DbWeight::get().writes(1)) + } + fn remove_authorized_alias() -> Weight { + // TODO: benchmark + Weight::from_parts(3_724_000, 0) + .saturating_add(Weight::from_parts(0, 1517)) + .saturating_add(T::DbWeight::get().reads(1)) + .saturating_add(T::DbWeight::get().writes(1)) + } /// Storage: `ParachainSystem::UpwardDeliveryFeeFactor` (r:1 w:0) /// Proof: `ParachainSystem::UpwardDeliveryFeeFactor` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) /// Storage: `PolkadotXcm::SupportedVersion` (r:1 w:0) diff --git a/cumulus/parachains/runtimes/coretime/coretime-rococo/src/weights/pallet_xcm.rs b/cumulus/parachains/runtimes/coretime/coretime-rococo/src/weights/pallet_xcm.rs index 7fb492173dad..d5ec7614a5c2 100644 --- a/cumulus/parachains/runtimes/coretime/coretime-rococo/src/weights/pallet_xcm.rs +++ b/cumulus/parachains/runtimes/coretime/coretime-rococo/src/weights/pallet_xcm.rs @@ -48,6 +48,20 @@ use core::marker::PhantomData; /// Weight functions for `pallet_xcm`. pub struct WeightInfo(PhantomData); impl pallet_xcm::WeightInfo for WeightInfo { + fn add_authorized_alias() -> Weight { + // TODO: benchmark + Weight::from_parts(3_724_000, 0) + .saturating_add(Weight::from_parts(0, 1517)) + .saturating_add(T::DbWeight::get().reads(1)) + .saturating_add(T::DbWeight::get().writes(1)) + } + fn remove_authorized_alias() -> Weight { + // TODO: benchmark + Weight::from_parts(3_724_000, 0) + .saturating_add(Weight::from_parts(0, 1517)) + .saturating_add(T::DbWeight::get().reads(1)) + .saturating_add(T::DbWeight::get().writes(1)) + } /// Storage: `PolkadotXcm::SupportedVersion` (r:1 w:0) /// Proof: `PolkadotXcm::SupportedVersion` (`max_values`: None, `max_size`: None, mode: `Measured`) /// Storage: `PolkadotXcm::VersionDiscoveryQueue` (r:1 w:1) diff --git a/cumulus/parachains/runtimes/coretime/coretime-westend/src/weights/pallet_xcm.rs b/cumulus/parachains/runtimes/coretime/coretime-westend/src/weights/pallet_xcm.rs index fa588e982f09..0b3fc7ae23ed 100644 --- a/cumulus/parachains/runtimes/coretime/coretime-westend/src/weights/pallet_xcm.rs +++ b/cumulus/parachains/runtimes/coretime/coretime-westend/src/weights/pallet_xcm.rs @@ -48,6 +48,20 @@ use core::marker::PhantomData; /// Weight functions for `pallet_xcm`. pub struct WeightInfo(PhantomData); impl pallet_xcm::WeightInfo for WeightInfo { + fn add_authorized_alias() -> Weight { + // TODO: benchmark + Weight::from_parts(3_724_000, 0) + .saturating_add(Weight::from_parts(0, 1517)) + .saturating_add(T::DbWeight::get().reads(1)) + .saturating_add(T::DbWeight::get().writes(1)) + } + fn remove_authorized_alias() -> Weight { + // TODO: benchmark + Weight::from_parts(3_724_000, 0) + .saturating_add(Weight::from_parts(0, 1517)) + .saturating_add(T::DbWeight::get().reads(1)) + .saturating_add(T::DbWeight::get().writes(1)) + } /// Storage: `PolkadotXcm::SupportedVersion` (r:1 w:0) /// Proof: `PolkadotXcm::SupportedVersion` (`max_values`: None, `max_size`: None, mode: `Measured`) /// Storage: `PolkadotXcm::VersionDiscoveryQueue` (r:1 w:1) diff --git a/cumulus/parachains/runtimes/people/people-rococo/src/weights/pallet_xcm.rs b/cumulus/parachains/runtimes/people/people-rococo/src/weights/pallet_xcm.rs index fabce29b5fd9..d6e370eebe89 100644 --- a/cumulus/parachains/runtimes/people/people-rococo/src/weights/pallet_xcm.rs +++ b/cumulus/parachains/runtimes/people/people-rococo/src/weights/pallet_xcm.rs @@ -48,6 +48,20 @@ use core::marker::PhantomData; /// Weight functions for `pallet_xcm`. pub struct WeightInfo(PhantomData); impl pallet_xcm::WeightInfo for WeightInfo { + fn add_authorized_alias() -> Weight { + // TODO: benchmark + Weight::from_parts(3_724_000, 0) + .saturating_add(Weight::from_parts(0, 1517)) + .saturating_add(T::DbWeight::get().reads(1)) + .saturating_add(T::DbWeight::get().writes(1)) + } + fn remove_authorized_alias() -> Weight { + // TODO: benchmark + Weight::from_parts(3_724_000, 0) + .saturating_add(Weight::from_parts(0, 1517)) + .saturating_add(T::DbWeight::get().reads(1)) + .saturating_add(T::DbWeight::get().writes(1)) + } /// Storage: `PolkadotXcm::SupportedVersion` (r:1 w:0) /// Proof: `PolkadotXcm::SupportedVersion` (`max_values`: None, `max_size`: None, mode: `Measured`) /// Storage: `PolkadotXcm::VersionDiscoveryQueue` (r:1 w:1) diff --git a/cumulus/parachains/runtimes/people/people-westend/src/weights/pallet_xcm.rs b/cumulus/parachains/runtimes/people/people-westend/src/weights/pallet_xcm.rs index c337289243b7..e50b2b70daae 100644 --- a/cumulus/parachains/runtimes/people/people-westend/src/weights/pallet_xcm.rs +++ b/cumulus/parachains/runtimes/people/people-westend/src/weights/pallet_xcm.rs @@ -48,6 +48,20 @@ use core::marker::PhantomData; /// Weight functions for `pallet_xcm`. pub struct WeightInfo(PhantomData); impl pallet_xcm::WeightInfo for WeightInfo { + fn add_authorized_alias() -> Weight { + // TODO: benchmark + Weight::from_parts(3_724_000, 0) + .saturating_add(Weight::from_parts(0, 1517)) + .saturating_add(T::DbWeight::get().reads(1)) + .saturating_add(T::DbWeight::get().writes(1)) + } + fn remove_authorized_alias() -> Weight { + // TODO: benchmark + Weight::from_parts(3_724_000, 0) + .saturating_add(Weight::from_parts(0, 1517)) + .saturating_add(T::DbWeight::get().reads(1)) + .saturating_add(T::DbWeight::get().writes(1)) + } /// Storage: `PolkadotXcm::SupportedVersion` (r:1 w:0) /// Proof: `PolkadotXcm::SupportedVersion` (`max_values`: None, `max_size`: None, mode: `Measured`) /// Storage: `PolkadotXcm::VersionDiscoveryQueue` (r:1 w:1) diff --git a/polkadot/runtime/rococo/src/weights/pallet_xcm.rs b/polkadot/runtime/rococo/src/weights/pallet_xcm.rs index d5cf33515e6b..3e7d29e973c4 100644 --- a/polkadot/runtime/rococo/src/weights/pallet_xcm.rs +++ b/polkadot/runtime/rococo/src/weights/pallet_xcm.rs @@ -50,6 +50,20 @@ use core::marker::PhantomData; /// Weight functions for `pallet_xcm`. pub struct WeightInfo(PhantomData); impl pallet_xcm::WeightInfo for WeightInfo { + fn add_authorized_alias() -> Weight { + // TODO: benchmark + Weight::from_parts(3_724_000, 0) + .saturating_add(Weight::from_parts(0, 1517)) + .saturating_add(T::DbWeight::get().reads(1)) + .saturating_add(T::DbWeight::get().writes(1)) + } + fn remove_authorized_alias() -> Weight { + // TODO: benchmark + Weight::from_parts(3_724_000, 0) + .saturating_add(Weight::from_parts(0, 1517)) + .saturating_add(T::DbWeight::get().reads(1)) + .saturating_add(T::DbWeight::get().writes(1)) + } /// Storage: `Dmp::DeliveryFeeFactor` (r:1 w:0) /// Proof: `Dmp::DeliveryFeeFactor` (`max_values`: None, `max_size`: None, mode: `Measured`) /// Storage: `XcmPallet::SupportedVersion` (r:1 w:0) diff --git a/polkadot/runtime/westend/src/weights/pallet_xcm.rs b/polkadot/runtime/westend/src/weights/pallet_xcm.rs index 10725cecf249..aac57102613d 100644 --- a/polkadot/runtime/westend/src/weights/pallet_xcm.rs +++ b/polkadot/runtime/westend/src/weights/pallet_xcm.rs @@ -48,6 +48,20 @@ use core::marker::PhantomData; /// Weight functions for `pallet_xcm`. pub struct WeightInfo(PhantomData); impl pallet_xcm::WeightInfo for WeightInfo { + fn add_authorized_alias() -> Weight { + // TODO: benchmark + Weight::from_parts(3_724_000, 0) + .saturating_add(Weight::from_parts(0, 1517)) + .saturating_add(T::DbWeight::get().reads(1)) + .saturating_add(T::DbWeight::get().writes(1)) + } + fn remove_authorized_alias() -> Weight { + // TODO: benchmark + Weight::from_parts(3_724_000, 0) + .saturating_add(Weight::from_parts(0, 1517)) + .saturating_add(T::DbWeight::get().reads(1)) + .saturating_add(T::DbWeight::get().writes(1)) + } /// Storage: `Dmp::DeliveryFeeFactor` (r:1 w:0) /// Proof: `Dmp::DeliveryFeeFactor` (`max_values`: None, `max_size`: None, mode: `Measured`) /// Storage: `XcmPallet::SupportedVersion` (r:1 w:0) From 9103e27deab28e974870a60921543cf8f389e5f3 Mon Sep 17 00:00:00 2001 From: Adrian Catangiu Date: Wed, 6 Nov 2024 16:41:51 +0200 Subject: [PATCH 04/40] add benchmark code --- polkadot/xcm/pallet-xcm/src/benchmarking.rs | 30 +++++++++++++++++++++ polkadot/xcm/pallet-xcm/src/lib.rs | 12 ++++----- 2 files changed, 36 insertions(+), 6 deletions(-) diff --git a/polkadot/xcm/pallet-xcm/src/benchmarking.rs b/polkadot/xcm/pallet-xcm/src/benchmarking.rs index 404b9358d4d9..093129a4bde7 100644 --- a/polkadot/xcm/pallet-xcm/src/benchmarking.rs +++ b/polkadot/xcm/pallet-xcm/src/benchmarking.rs @@ -385,6 +385,36 @@ benchmarks! { let versioned_assets = VersionedAssets::V4(asset.into()); }: _>(claim_origin.into(), Box::new(versioned_assets), Box::new(VersionedLocation::V4(claim_location))) + add_authorized_alias { + let origin = RawOrigin::Root; + let origin_location = T::ExecuteXcmOrigin::ensure_origin(origin.clone().into()).unwrap(); + let mut existing_aliases = BoundedVec::::new(); + // prepopulate list with `max-1` aliases to benchmark worst case + for i in 1..MaxAuthorizedAliases::get() { + let alias = Location::new(1, [Parachain(i), AccountId32 { network: None, id: [42_u8; 32] }]); + existing_aliases.try_push(alias).unwrap() + } + AuthorizedAliasesMap::::insert(&origin_location, existing_aliases); + // now benchmark adding new alias + let aliaser: VersionedLocation = + Location::new(1, [Parachain(1234), AccountId32 { network: None, id: [42_u8; 32] }]).into(); + }: _(origin, Box::new(aliaser)) + + remove_authorized_alias { + let origin = RawOrigin::Root; + let origin_location = T::ExecuteXcmOrigin::ensure_origin(origin.clone().into()).unwrap(); + let mut existing_aliases = BoundedVec::::new(); + // prepopulate list with `max` aliases to benchmark worst case + for i in 1..MaxAuthorizedAliases::get()+1 { + let alias = Location::new(1, [Parachain(i), AccountId32 { network: None, id: [42_u8; 32] }]); + existing_aliases.try_push(alias).unwrap() + } + AuthorizedAliasesMap::::insert(&origin_location, existing_aliases); + // now benchmark adding new alias + let aliaser_to_remove: VersionedLocation = + Location::new(1, [Parachain(1), AccountId32 { network: None, id: [42_u8; 32] }]).into(); + }: _(origin, Box::new(aliaser_to_remove)) + impl_benchmark_test_suite!( Pallet, crate::mock::new_test_ext_with_balances(Vec::new()), diff --git a/polkadot/xcm/pallet-xcm/src/lib.rs b/polkadot/xcm/pallet-xcm/src/lib.rs index d4392fb51456..27880893c584 100644 --- a/polkadot/xcm/pallet-xcm/src/lib.rs +++ b/polkadot/xcm/pallet-xcm/src/lib.rs @@ -812,7 +812,7 @@ pub mod pallet { /// Map of authorized aliasers of local origins. Each local location can authorize a list of /// other locations to alias into it. #[pallet::storage] - pub(super) type AuthorizedAliases = StorageMap< + pub(super) type AuthorizedAliasesMap = StorageMap< _, Blake2_128Concat, Location, @@ -1469,12 +1469,12 @@ pub mod pallet { let origin = T::ExecuteXcmOrigin::ensure_origin(origin)?; let aliaser = (*aliaser).try_into().map_err(|()| Error::::BadVersion)?; ensure!(origin != aliaser, Error::::BadLocation); - let mut authorized_aliases = AuthorizedAliases::::get(&origin); + let mut authorized_aliases = AuthorizedAliasesMap::::get(&origin); if !authorized_aliases.contains(&aliaser) { authorized_aliases .try_push(aliaser) .map_err(|_| Error::::TooManyAuthorizedAliases)?; - AuthorizedAliases::::insert(&origin, authorized_aliases); + AuthorizedAliasesMap::::insert(&origin, authorized_aliases); } Ok(()) } @@ -1489,11 +1489,11 @@ pub mod pallet { let origin = T::ExecuteXcmOrigin::ensure_origin(origin)?; let to_remove = (*aliaser).try_into().map_err(|()| Error::::BadVersion)?; ensure!(origin != to_remove, Error::::BadLocation); - let mut authorized_aliases = AuthorizedAliases::::get(&origin); + let mut authorized_aliases = AuthorizedAliasesMap::::get(&origin); let original_length = authorized_aliases.len(); authorized_aliases.retain(|alias| to_remove.ne(alias)); if original_length != authorized_aliases.len() { - AuthorizedAliases::::insert(&origin, authorized_aliases); + AuthorizedAliasesMap::::insert(&origin, authorized_aliases); } Ok(()) } @@ -3509,7 +3509,7 @@ where pub struct AuthorizedAliases(PhantomData); impl ContainsPair for AuthorizedAliases { fn contains(origin: &Location, target: &Location) -> bool { - pallet::AuthorizedAliases::::get(&origin).contains(target) + AuthorizedAliasesMap::::get(&origin).contains(target) } } From c29fc5dd910c416b8bdbf00cf68f3f35f0cd8e6c Mon Sep 17 00:00:00 2001 From: Adrian Catangiu Date: Wed, 6 Nov 2024 18:31:15 +0200 Subject: [PATCH 05/40] add migration for authorized aliases --- polkadot/xcm/pallet-xcm/src/benchmarking.rs | 14 ++-- polkadot/xcm/pallet-xcm/src/lib.rs | 45 +++++++----- polkadot/xcm/pallet-xcm/src/migration.rs | 76 +++++++++++++++++++++ 3 files changed, 113 insertions(+), 22 deletions(-) diff --git a/polkadot/xcm/pallet-xcm/src/benchmarking.rs b/polkadot/xcm/pallet-xcm/src/benchmarking.rs index 093129a4bde7..227bf58d2fd9 100644 --- a/polkadot/xcm/pallet-xcm/src/benchmarking.rs +++ b/polkadot/xcm/pallet-xcm/src/benchmarking.rs @@ -387,11 +387,12 @@ benchmarks! { add_authorized_alias { let origin = RawOrigin::Root; - let origin_location = T::ExecuteXcmOrigin::ensure_origin(origin.clone().into()).unwrap(); - let mut existing_aliases = BoundedVec::::new(); + let origin_location: VersionedLocation = + T::ExecuteXcmOrigin::ensure_origin(origin.clone().into()).unwrap().into(); + let mut existing_aliases = BoundedVec::::new(); // prepopulate list with `max-1` aliases to benchmark worst case for i in 1..MaxAuthorizedAliases::get() { - let alias = Location::new(1, [Parachain(i), AccountId32 { network: None, id: [42_u8; 32] }]); + let alias = Location::new(1, [Parachain(i), AccountId32 { network: None, id: [42_u8; 32] }]).into(); existing_aliases.try_push(alias).unwrap() } AuthorizedAliasesMap::::insert(&origin_location, existing_aliases); @@ -402,11 +403,12 @@ benchmarks! { remove_authorized_alias { let origin = RawOrigin::Root; - let origin_location = T::ExecuteXcmOrigin::ensure_origin(origin.clone().into()).unwrap(); - let mut existing_aliases = BoundedVec::::new(); + let origin_location: VersionedLocation = + T::ExecuteXcmOrigin::ensure_origin(origin.clone().into()).unwrap().into(); + let mut existing_aliases = BoundedVec::::new(); // prepopulate list with `max` aliases to benchmark worst case for i in 1..MaxAuthorizedAliases::get()+1 { - let alias = Location::new(1, [Parachain(i), AccountId32 { network: None, id: [42_u8; 32] }]); + let alias = Location::new(1, [Parachain(i), AccountId32 { network: None, id: [42_u8; 32] }]).into(); existing_aliases.try_push(alias).unwrap() } AuthorizedAliasesMap::::insert(&origin_location, existing_aliases); diff --git a/polkadot/xcm/pallet-xcm/src/lib.rs b/polkadot/xcm/pallet-xcm/src/lib.rs index 27880893c584..18a8cf0174f7 100644 --- a/polkadot/xcm/pallet-xcm/src/lib.rs +++ b/polkadot/xcm/pallet-xcm/src/lib.rs @@ -815,8 +815,8 @@ pub mod pallet { pub(super) type AuthorizedAliasesMap = StorageMap< _, Blake2_128Concat, - Location, - BoundedVec, + VersionedLocation, + BoundedVec, ValueQuery, >; @@ -1466,15 +1466,17 @@ pub mod pallet { origin: OriginFor, aliaser: Box, ) -> DispatchResult { - let origin = T::ExecuteXcmOrigin::ensure_origin(origin)?; - let aliaser = (*aliaser).try_into().map_err(|()| Error::::BadVersion)?; + let origin: Location = T::ExecuteXcmOrigin::ensure_origin(origin)?; + let aliaser: Location = (*aliaser).try_into().map_err(|()| Error::::BadVersion)?; ensure!(origin != aliaser, Error::::BadLocation); - let mut authorized_aliases = AuthorizedAliasesMap::::get(&origin); - if !authorized_aliases.contains(&aliaser) { + let v_origin = VersionedLocation::from(origin); + let v_aliaser = VersionedLocation::from(aliaser); + let mut authorized_aliases = AuthorizedAliasesMap::::get(&v_origin); + if !authorized_aliases.contains(&v_aliaser) { authorized_aliases - .try_push(aliaser) + .try_push(v_aliaser) .map_err(|_| Error::::TooManyAuthorizedAliases)?; - AuthorizedAliasesMap::::insert(&origin, authorized_aliases); + AuthorizedAliasesMap::::insert(&v_origin, authorized_aliases); } Ok(()) } @@ -1486,14 +1488,16 @@ pub mod pallet { origin: OriginFor, aliaser: Box, ) -> DispatchResult { - let origin = T::ExecuteXcmOrigin::ensure_origin(origin)?; - let to_remove = (*aliaser).try_into().map_err(|()| Error::::BadVersion)?; + let origin: Location = T::ExecuteXcmOrigin::ensure_origin(origin)?; + let to_remove: Location = (*aliaser).try_into().map_err(|()| Error::::BadVersion)?; ensure!(origin != to_remove, Error::::BadLocation); - let mut authorized_aliases = AuthorizedAliasesMap::::get(&origin); + let v_origin = VersionedLocation::from(origin); + let v_to_remove = VersionedLocation::from(to_remove); + let mut authorized_aliases = AuthorizedAliasesMap::::get(&v_origin); let original_length = authorized_aliases.len(); - authorized_aliases.retain(|alias| to_remove.ne(alias)); + authorized_aliases.retain(|alias| v_to_remove.ne(alias)); if original_length != authorized_aliases.len() { - AuthorizedAliasesMap::::insert(&origin, authorized_aliases); + AuthorizedAliasesMap::::insert(&v_origin, authorized_aliases); } Ok(()) } @@ -3507,11 +3511,20 @@ where /// Note: users can authorize other locations to alias them by using /// `pallet_xcm::add_authorized_alias()`. pub struct AuthorizedAliases(PhantomData); -impl ContainsPair for AuthorizedAliases { - fn contains(origin: &Location, target: &Location) -> bool { - AuthorizedAliasesMap::::get(&origin).contains(target) +impl + Clone, T: Config> ContainsPair for AuthorizedAliases { + fn contains(origin: &L, target: &L) -> bool { + let origin: VersionedLocation = origin.clone().into(); + let target: VersionedLocation = target.clone().into(); + AuthorizedAliasesMap::::get(&origin).contains(&target) } } +// pub struct AuthorizedAliases(PhantomData); +// impl ContainsPair for AuthorizedAliases { +// fn contains(origin: &Location, target: &Location) -> bool { +// let target = VersionedLocation::from(target.clone()); +// AuthorizedAliasesMap::::get(&origin).contains(&target) +// } +// } /// Filter for `Location` to find those which represent a strict majority approval of an /// identified plurality. diff --git a/polkadot/xcm/pallet-xcm/src/migration.rs b/polkadot/xcm/pallet-xcm/src/migration.rs index 80154f57ddfb..64b35bd8566d 100644 --- a/polkadot/xcm/pallet-xcm/src/migration.rs +++ b/polkadot/xcm/pallet-xcm/src/migration.rs @@ -170,6 +170,49 @@ pub mod data { } } + /// Implementation of `NeedsMigration` for `AuthorizedAliasesMap` data. + impl> NeedsMigration for (&VersionedLocation, &BoundedVec) { + type MigratedData = (VersionedLocation, BoundedVec); + + fn needs_migration(&self, _: XcmVersion) -> bool { + self.0.identify_version() < XCM_VERSION || + self.1.iter().any(|alias| alias.identify_version() < XCM_VERSION) + } + + fn try_migrate(self, new_version: XcmVersion) -> Result, ()> { + if !self.needs_migration(new_version) { + return Ok(None) + } + + let key = if self.0.identify_version() < new_version { + let Ok(converted_key) = self.0.clone().into_version(new_version) else { + return Err(()) + }; + converted_key + } else { + self.0.clone() + }; + let mut aliases = BoundedVec::::new(); + for alias in self.1 { + if aliases + .try_push(if alias.identify_version() < new_version { + let Ok(new_alias) = alias.clone().into_version(new_version) else { + return Err(()) + }; + new_alias + } else { + alias.clone() + }) + .is_err() + { + return Err(()) + }; + } + + Ok(Some((key, aliases))) + } + } + impl Pallet { /// Migrates relevant data to the `required_xcm_version`. pub(crate) fn migrate_data_to_xcm_version( @@ -323,6 +366,39 @@ pub mod data { >(&old_key, &new_key); weight.saturating_add(T::DbWeight::get().writes(1)); } + + // check and migrate `AuthorizedAliasesMap` + let aliases_to_migrate = AuthorizedAliasesMap::::iter().filter_map(|(id, data)| { + weight.saturating_add(T::DbWeight::get().reads(1)); + match (&id, &data).try_migrate(required_xcm_version) { + Ok(Some((new_id, new_data))) => Some((id, new_id, new_data)), + Ok(None) => None, + Err(_) => { + tracing::error!( + target: LOG_TARGET, + ?id, + ?data, + ?required_xcm_version, + "`AuthorizedAliasesMap` cannot be migrated!" + ); + None + }, + } + }); + let mut count = 0; + for (old_id, new_id, new_data) in aliases_to_migrate { + tracing::info!( + target: LOG_TARGET, + ?new_id, + ?new_data, + "Migrating `AuthorizedAliasesMap`" + ); + AuthorizedAliasesMap::::remove(old_id); + AuthorizedAliasesMap::::insert(new_id, new_data); + count = count + 1; + } + // two writes per key, one to remove old entry, one to write new entry + weight.saturating_add(T::DbWeight::get().writes(count * 2)); } } } From e84293fc5f53d106d2788f4e7457216c746b7d03 Mon Sep 17 00:00:00 2001 From: Adrian Catangiu Date: Wed, 6 Nov 2024 19:30:34 +0200 Subject: [PATCH 06/40] fix pallet-xcm authorized aliases --- polkadot/xcm/pallet-xcm/src/lib.rs | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/polkadot/xcm/pallet-xcm/src/lib.rs b/polkadot/xcm/pallet-xcm/src/lib.rs index 18a8cf0174f7..bbe094c8cb63 100644 --- a/polkadot/xcm/pallet-xcm/src/lib.rs +++ b/polkadot/xcm/pallet-xcm/src/lib.rs @@ -1468,6 +1468,7 @@ pub mod pallet { ) -> DispatchResult { let origin: Location = T::ExecuteXcmOrigin::ensure_origin(origin)?; let aliaser: Location = (*aliaser).try_into().map_err(|()| Error::::BadVersion)?; + tracing::debug!(target: "xcm::pallet_xcm::add_authorized_alias", ?origin, ?aliaser); ensure!(origin != aliaser, Error::::BadLocation); let v_origin = VersionedLocation::from(origin); let v_aliaser = VersionedLocation::from(aliaser); @@ -1490,6 +1491,7 @@ pub mod pallet { ) -> DispatchResult { let origin: Location = T::ExecuteXcmOrigin::ensure_origin(origin)?; let to_remove: Location = (*aliaser).try_into().map_err(|()| Error::::BadVersion)?; + tracing::debug!(target: "xcm::pallet_xcm::add_authorized_alias", ?origin, ?to_remove); ensure!(origin != to_remove, Error::::BadLocation); let v_origin = VersionedLocation::from(origin); let v_to_remove = VersionedLocation::from(to_remove); @@ -3515,16 +3517,10 @@ impl + Clone, T: Config> ContainsPair for Autho fn contains(origin: &L, target: &L) -> bool { let origin: VersionedLocation = origin.clone().into(); let target: VersionedLocation = target.clone().into(); - AuthorizedAliasesMap::::get(&origin).contains(&target) + tracing::trace!(target: "xcm::pallet_xcm::AuthorizedAliases::contains", ?origin, ?target); + AuthorizedAliasesMap::::get(&target).contains(&origin) } } -// pub struct AuthorizedAliases(PhantomData); -// impl ContainsPair for AuthorizedAliases { -// fn contains(origin: &Location, target: &Location) -> bool { -// let target = VersionedLocation::from(target.clone()); -// AuthorizedAliasesMap::::get(&origin).contains(&target) -// } -// } /// Filter for `Location` to find those which represent a strict majority approval of an /// identified plurality. From 0332aca754ed4c8b5636feb069edff62d815f389 Mon Sep 17 00:00:00 2001 From: Adrian Catangiu Date: Wed, 6 Nov 2024 19:30:58 +0200 Subject: [PATCH 07/40] asset hub westend: add support for authorized aliases --- .../asset-hub-westend/src/xcm_config.rs | 6 +- .../assets/asset-hub-westend/tests/tests.rs | 92 +++++++++++++++++++ 2 files changed, 95 insertions(+), 3 deletions(-) diff --git a/cumulus/parachains/runtimes/assets/asset-hub-westend/src/xcm_config.rs b/cumulus/parachains/runtimes/assets/asset-hub-westend/src/xcm_config.rs index b8f64da0228c..82ce96ea03af 100644 --- a/cumulus/parachains/runtimes/assets/asset-hub-westend/src/xcm_config.rs +++ b/cumulus/parachains/runtimes/assets/asset-hub-westend/src/xcm_config.rs @@ -28,11 +28,11 @@ use frame_support::{ parameter_types, traits::{ tokens::imbalance::{ResolveAssetTo, ResolveTo}, - ConstU32, Contains, Equals, Everything, Nothing, PalletInfoAccess, + ConstU32, Contains, Equals, Everything, PalletInfoAccess, }, }; use frame_system::EnsureRoot; -use pallet_xcm::XcmPassthrough; +use pallet_xcm::{AuthorizedAliases, XcmPassthrough}; use parachains_common::{ xcm_config::{ AllSiblingSystemParachains, AssetFeeAsExistentialDepositMultiplier, @@ -462,7 +462,7 @@ impl xcm_executor::Config for XcmConfig { (bridging::to_rococo::UniversalAliases, bridging::to_ethereum::UniversalAliases); type CallDispatcher = RuntimeCall; type SafeCallFilter = Everything; - type Aliasers = Nothing; + type Aliasers = AuthorizedAliases; type TransactionalProcessor = FrameTransactionalProcessor; type HrmpNewChannelOpenRequestHandler = (); type HrmpChannelAcceptedHandler = (); diff --git a/cumulus/parachains/runtimes/assets/asset-hub-westend/tests/tests.rs b/cumulus/parachains/runtimes/assets/asset-hub-westend/tests/tests.rs index 6a48b19ce946..9ddc0cfa5f07 100644 --- a/cumulus/parachains/runtimes/assets/asset-hub-westend/tests/tests.rs +++ b/cumulus/parachains/runtimes/assets/asset-hub-westend/tests/tests.rs @@ -43,6 +43,7 @@ use frame_support::{ fungibles::{ Create, Inspect as FungiblesInspect, InspectEnumerable, Mutate as FungiblesMutate, }, + ContainsPair, }, weights::{Weight, WeightToFee as WeightToFeeT}, }; @@ -133,6 +134,7 @@ fn setup_pool_for_paying_fees_with_foreign_assets( #[test] fn test_buy_and_refund_weight_in_native() { ExtBuilder::::default() + .with_tracing() .with_collators(vec![AccountId::from(ALICE)]) .with_session_keys(vec![( AccountId::from(ALICE), @@ -191,6 +193,7 @@ fn test_buy_and_refund_weight_in_native() { #[test] fn test_buy_and_refund_weight_with_swap_local_asset_xcm_trader() { ExtBuilder::::default() + .with_tracing() .with_collators(vec![AccountId::from(ALICE)]) .with_session_keys(vec![( AccountId::from(ALICE), @@ -300,6 +303,7 @@ fn test_buy_and_refund_weight_with_swap_local_asset_xcm_trader() { #[test] fn test_buy_and_refund_weight_with_swap_foreign_asset_xcm_trader() { ExtBuilder::::default() + .with_tracing() .with_collators(vec![AccountId::from(ALICE)]) .with_session_keys(vec![( AccountId::from(ALICE), @@ -410,6 +414,7 @@ fn test_buy_and_refund_weight_with_swap_foreign_asset_xcm_trader() { #[test] fn test_asset_xcm_take_first_trader() { ExtBuilder::::default() + .with_tracing() .with_collators(vec![AccountId::from(ALICE)]) .with_session_keys(vec![( AccountId::from(ALICE), @@ -488,6 +493,7 @@ fn test_asset_xcm_take_first_trader() { #[test] fn test_foreign_asset_xcm_take_first_trader() { ExtBuilder::::default() + .with_tracing() .with_collators(vec![AccountId::from(ALICE)]) .with_session_keys(vec![( AccountId::from(ALICE), @@ -569,6 +575,7 @@ fn test_foreign_asset_xcm_take_first_trader() { #[test] fn test_asset_xcm_take_first_trader_with_refund() { ExtBuilder::::default() + .with_tracing() .with_collators(vec![AccountId::from(ALICE)]) .with_session_keys(vec![( AccountId::from(ALICE), @@ -648,6 +655,7 @@ fn test_asset_xcm_take_first_trader_with_refund() { #[test] fn test_asset_xcm_take_first_trader_refund_not_possible_since_amount_less_than_ed() { ExtBuilder::::default() + .with_tracing() .with_collators(vec![AccountId::from(ALICE)]) .with_session_keys(vec![( AccountId::from(ALICE), @@ -700,6 +708,7 @@ fn test_asset_xcm_take_first_trader_refund_not_possible_since_amount_less_than_e #[test] fn test_that_buying_ed_refund_does_not_refund_for_take_first_trader() { ExtBuilder::::default() + .with_tracing() .with_collators(vec![AccountId::from(ALICE)]) .with_session_keys(vec![( AccountId::from(ALICE), @@ -764,6 +773,7 @@ fn test_that_buying_ed_refund_does_not_refund_for_take_first_trader() { #[test] fn test_asset_xcm_take_first_trader_not_possible_for_non_sufficient_assets() { ExtBuilder::::default() + .with_tracing() .with_collators(vec![AccountId::from(ALICE)]) .with_session_keys(vec![( AccountId::from(ALICE), @@ -825,6 +835,7 @@ fn test_assets_balances_api_works() { use assets_common::runtime_api::runtime_decl_for_fungibles_api::FungiblesApi; ExtBuilder::::default() + .with_tracing() .with_collators(vec![AccountId::from(ALICE)]) .with_session_keys(vec![( AccountId::from(ALICE), @@ -939,6 +950,87 @@ fn test_assets_balances_api_works() { }); } +#[test] +fn authorized_aliases_work() { + ExtBuilder::::default() + .with_tracing() + .with_collators(vec![AccountId::from(ALICE)]) + .with_session_keys(vec![( + AccountId::from(ALICE), + AccountId::from(ALICE), + SessionKeys { aura: AuraId::from(sp_core::sr25519::Public::from_raw(ALICE)) }, + )]) + .build() + .execute_with(|| { + let alice: AccountId = ALICE.into(); + let local_alice = Location::new(0, AccountId32 { network: Some(Westend), id: ALICE }); + let alice_on_sibling_para = + Location::new(1, [Parachain(42), AccountId32 { network: None, id: ALICE }]); + let alice_on_relay = Location::new(1, AccountId32 { network: None, id: ALICE }); + let bob_on_relay = Location::new(1, AccountId32 { network: None, id: [42_u8; 32] }); + + // neither `alice_on_sibling_para`, `alice_on_relay`, `bob_on_relay` are allowed to + // alias into `local_alice` + for aliaser in [&alice_on_sibling_para, &alice_on_relay, &bob_on_relay] { + assert!(!::Aliasers::contains( + aliaser, + &local_alice + )); + } + + // Alice explicitly authorizes `alice_on_sibling_para` to alias her local account + assert_ok!(PolkadotXcm::add_authorized_alias( + RuntimeHelper::origin_of(alice.clone()), + Box::new(alice_on_sibling_para.clone().into()) + )); + + // `alice_on_sibling_para` now explicitly allowed to alias into `local_alice` + assert!(::Aliasers::contains( + &alice_on_sibling_para, + &local_alice + )); + // as expected, `alice_on_relay` and `bob_on_relay` still can't alias into `local_alice` + for aliaser in [&alice_on_relay, &bob_on_relay] { + assert!(!::Aliasers::contains( + aliaser, + &local_alice + )); + } + + // Alice explicitly authorizes `alice_on_relay` to alias her local account + assert_ok!(PolkadotXcm::add_authorized_alias( + RuntimeHelper::origin_of(alice.clone()), + Box::new(alice_on_relay.clone().into()) + )); + // Now both `alice_on_relay` and `alice_on_sibling_para` can alias into her local + // account + for aliaser in [&alice_on_relay, &alice_on_sibling_para] { + assert!(::Aliasers::contains( + aliaser, + &local_alice + )); + } + + // Alice removes authorization for `alice_on_relay` to alias her local account + assert_ok!(PolkadotXcm::remove_authorized_alias( + RuntimeHelper::origin_of(alice.clone()), + Box::new(alice_on_relay.clone().into()) + )); + + // `alice_on_relay` no longer allowed to alias into `local_alice` + assert!(!::Aliasers::contains( + &alice_on_relay, + &local_alice + )); + + // `alice_on_sibling_para` still allowed to alias into `local_alice` + assert!(::Aliasers::contains( + &alice_on_sibling_para, + &local_alice + )); + }) +} + asset_test_utils::include_teleports_for_native_asset_works!( Runtime, AllPalletsWithoutSystem, From 4611498b3159c20c7429c455f1877b50da6469af Mon Sep 17 00:00:00 2001 From: Adrian Catangiu Date: Thu, 7 Nov 2024 13:30:41 +0200 Subject: [PATCH 08/40] address comments and fix tests after rebase --- .../runtimes/assets/asset-hub-westend/tests/tests.rs | 7 +++++-- polkadot/xcm/pallet-xcm/src/benchmarking.rs | 8 ++++---- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/cumulus/parachains/runtimes/assets/asset-hub-westend/tests/tests.rs b/cumulus/parachains/runtimes/assets/asset-hub-westend/tests/tests.rs index 9438f317ce74..23bec5016832 100644 --- a/cumulus/parachains/runtimes/assets/asset-hub-westend/tests/tests.rs +++ b/cumulus/parachains/runtimes/assets/asset-hub-westend/tests/tests.rs @@ -55,7 +55,7 @@ use std::{convert::Into, ops::Mul}; use testnet_parachains_constants::westend::{consensus::*, currency::UNITS, fee::WeightToFee}; use xcm::latest::{ prelude::{Assets as XcmAssets, *}, - ROCOCO_GENESIS_HASH, + ROCOCO_GENESIS_HASH, WESTEND_GENESIS_HASH, }; use xcm_builder::WithLatestLocationConverter; use xcm_executor::traits::{ConvertLocation, JustTry, WeightTrader}; @@ -966,7 +966,10 @@ fn authorized_aliases_work() { .build() .execute_with(|| { let alice: AccountId = ALICE.into(); - let local_alice = Location::new(0, AccountId32 { network: Some(Westend), id: ALICE }); + let local_alice = Location::new( + 0, + AccountId32 { network: Some(ByGenesis(WESTEND_GENESIS_HASH)), id: ALICE }, + ); let alice_on_sibling_para = Location::new(1, [Parachain(42), AccountId32 { network: None, id: ALICE }]); let alice_on_relay = Location::new(1, AccountId32 { network: None, id: ALICE }); diff --git a/polkadot/xcm/pallet-xcm/src/benchmarking.rs b/polkadot/xcm/pallet-xcm/src/benchmarking.rs index d5672addf6ea..e858edf29d29 100644 --- a/polkadot/xcm/pallet-xcm/src/benchmarking.rs +++ b/polkadot/xcm/pallet-xcm/src/benchmarking.rs @@ -387,8 +387,8 @@ benchmarks! { add_authorized_alias { let origin = RawOrigin::Root; - let origin_location: VersionedLocation = - T::ExecuteXcmOrigin::ensure_origin(origin.clone().into()).unwrap().into(); + let origin_location: VersionedLocation = T::ExecuteXcmOrigin::try_origin(origin.clone().into()) + .map_err(|_| BenchmarkError::Override(BenchmarkResult::from_weight(Weight::MAX)))?.into(); let mut existing_aliases = BoundedVec::::new(); // prepopulate list with `max-1` aliases to benchmark worst case for i in 1..MaxAuthorizedAliases::get() { @@ -403,8 +403,8 @@ benchmarks! { remove_authorized_alias { let origin = RawOrigin::Root; - let origin_location: VersionedLocation = - T::ExecuteXcmOrigin::ensure_origin(origin.clone().into()).unwrap().into(); + let origin_location: VersionedLocation = T::ExecuteXcmOrigin::try_origin(origin.clone().into()) + .map_err(|_| BenchmarkError::Override(BenchmarkResult::from_weight(Weight::MAX)))?.into(); let mut existing_aliases = BoundedVec::::new(); // prepopulate list with `max` aliases to benchmark worst case for i in 1..MaxAuthorizedAliases::get()+1 { From 709cf3ef39c43b5d0fbaff25b41cecf3fd071374 Mon Sep 17 00:00:00 2001 From: Adrian Catangiu Date: Thu, 7 Nov 2024 13:58:56 +0200 Subject: [PATCH 09/40] add prdoc --- prdoc/pr_6336.prdoc | 58 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100644 prdoc/pr_6336.prdoc diff --git a/prdoc/pr_6336.prdoc b/prdoc/pr_6336.prdoc new file mode 100644 index 000000000000..dec27cf18f22 --- /dev/null +++ b/prdoc/pr_6336.prdoc @@ -0,0 +1,58 @@ +# Schema: Polkadot SDK PRDoc Schema (prdoc) v1.0.0 +# See doc at https://raw.githubusercontent.com/paritytech/polkadot-sdk/master/prdoc/schema_user.json + +title: "pallet-xcm: add support to authorize aliases" + +doc: + - audience: Runtime User + description: | + Added new `add_authorized_alias()` and `remove_authorized_alias()` calls to `pallet-xcm`. + These can be used by a "caller" to explicitly authorize another location to alias into the "caller" origin. + Usually useful to allow one's local account to be aliased into from a remote location also under + one's control (one's account on another chain). + WARNING: make sure that you as the caller `origin` trust the `aliaser` location to act in your name on this + chain. Once authorized using this call, the `aliaser` can freely impersonate `origin` in XCM programs + executed on the local chain. + + - audience: Runtime Dev + description: | + Added `AuthorizedAliases` type exposed by `pallet-xcm`, that acts as a filter for explicitly authorized + aliases using `pallet-xcm::add_authorized_alias()` and `pallet-xcm::remove_authorized_alias()`. + Runtime developers can simply plug this `pallet-xcm::AuthorizedAliases` type in their runtime's `XcmConfig`, + specifically in `::Aliasers`. + +crates: + - name: pallet-xcm + bump: minor + - name: staging-xcm-builder + bump: none + - name: xcm-runtime-apis + bump: none + - name: westend-runtime + bump: none + - name: rococo-runtime + bump: none + - name: asset-hub-rococo-runtime + bump: none + - name: asset-hub-westend-runtime + bump: none + - name: bridge-hub-rococo-runtime + bump: none + - name: bridge-hub-westend-runtime + bump: none + - name: collectives-westend-runtime + bump: none + - name: coretime-rococo-runtime + bump: none + - name: coretime-westend-runtime + bump: none + - name: people-rococo-runtime + bump: none + - name: people-westend-runtime + bump: none + - name: penpal-runtime + bump: none + - name: contracts-rococo-runtime + bump: none + - name: rococo-parachain-runtime + bump: none From 35b4859464c4d3d241edd2a41e9a47975db65129 Mon Sep 17 00:00:00 2001 From: command-bot <> Date: Thu, 7 Nov 2024 12:44:26 +0000 Subject: [PATCH 10/40] ".git/.scripts/commands/bench/bench.sh" --subcommand=xcm --runtime=westend --target_dir=polkadot --pallet=pallet_xcm --- .../westend/src/weights/xcm/pallet_xcm.rs | 363 ++++++++++++++++++ 1 file changed, 363 insertions(+) create mode 100644 polkadot/runtime/westend/src/weights/xcm/pallet_xcm.rs diff --git a/polkadot/runtime/westend/src/weights/xcm/pallet_xcm.rs b/polkadot/runtime/westend/src/weights/xcm/pallet_xcm.rs new file mode 100644 index 000000000000..0e770a88c069 --- /dev/null +++ b/polkadot/runtime/westend/src/weights/xcm/pallet_xcm.rs @@ -0,0 +1,363 @@ +// Copyright (C) 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 . + +//! Autogenerated weights for `pallet_xcm` +//! +//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 32.0.0 +//! DATE: 2024-11-07, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! WORST CASE MAP SIZE: `1000000` +//! HOSTNAME: `runner-vcatxqpx-project-674-concurrent-0`, CPU: `Intel(R) Xeon(R) CPU @ 2.60GHz` +//! WASM-EXECUTION: Compiled, CHAIN: Some("westend-dev"), DB CACHE: 1024 + +// Executed Command: +// target/production/polkadot +// benchmark +// pallet +// --steps=50 +// --repeat=20 +// --extrinsic=* +// --wasm-execution=compiled +// --heap-pages=4096 +// --json-file=/builds/parity/mirrors/polkadot-sdk/.git/.artifacts/bench.json +// --pallet=pallet_xcm +// --chain=westend-dev +// --header=./polkadot/file_header.txt +// --template=./polkadot/xcm/pallet-xcm-benchmarks/template.hbs +// --output=./polkadot/runtime/westend/src/weights/xcm/ + +#![cfg_attr(rustfmt, rustfmt_skip)] +#![allow(unused_parens)] +#![allow(unused_imports)] +#![allow(missing_docs)] + +use frame_support::{traits::Get, weights::Weight}; +use core::marker::PhantomData; + +/// Weight functions for `pallet_xcm`. +pub struct WeightInfo(PhantomData); +impl WeightInfo { + /// Storage: `Dmp::DeliveryFeeFactor` (r:1 w:0) + /// Proof: `Dmp::DeliveryFeeFactor` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `XcmPallet::SupportedVersion` (r:1 w:0) + /// Proof: `XcmPallet::SupportedVersion` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `Dmp::DownwardMessageQueues` (r:1 w:1) + /// Proof: `Dmp::DownwardMessageQueues` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `Dmp::DownwardMessageQueueHeads` (r:1 w:1) + /// Proof: `Dmp::DownwardMessageQueueHeads` (`max_values`: None, `max_size`: None, mode: `Measured`) + pub(crate) fn send() -> Weight { + // Proof Size summary in bytes: + // Measured: `147` + // Estimated: `3612` + // Minimum execution time: 30_777_000 picoseconds. + Weight::from_parts(31_746_000, 3612) + .saturating_add(T::DbWeight::get().reads(4)) + .saturating_add(T::DbWeight::get().writes(2)) + } + /// Storage: `System::Account` (r:2 w:2) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`) + /// Storage: `XcmPallet::ShouldRecordXcm` (r:1 w:0) + /// Proof: `XcmPallet::ShouldRecordXcm` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + /// Storage: `Dmp::DeliveryFeeFactor` (r:1 w:0) + /// Proof: `Dmp::DeliveryFeeFactor` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `XcmPallet::SupportedVersion` (r:1 w:0) + /// Proof: `XcmPallet::SupportedVersion` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `Dmp::DownwardMessageQueues` (r:1 w:1) + /// Proof: `Dmp::DownwardMessageQueues` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `Dmp::DownwardMessageQueueHeads` (r:1 w:1) + /// Proof: `Dmp::DownwardMessageQueueHeads` (`max_values`: None, `max_size`: None, mode: `Measured`) + pub(crate) fn teleport_assets() -> Weight { + // Proof Size summary in bytes: + // Measured: `250` + // Estimated: `6196` + // Minimum execution time: 130_855_000 picoseconds. + Weight::from_parts(135_315_000, 6196) + .saturating_add(T::DbWeight::get().reads(7)) + .saturating_add(T::DbWeight::get().writes(4)) + } + /// Storage: `XcmPallet::ShouldRecordXcm` (r:1 w:0) + /// Proof: `XcmPallet::ShouldRecordXcm` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + /// Storage: `System::Account` (r:2 w:2) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`) + /// Storage: `Dmp::DeliveryFeeFactor` (r:1 w:0) + /// Proof: `Dmp::DeliveryFeeFactor` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `XcmPallet::SupportedVersion` (r:1 w:0) + /// Proof: `XcmPallet::SupportedVersion` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `Dmp::DownwardMessageQueues` (r:1 w:1) + /// Proof: `Dmp::DownwardMessageQueues` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `Dmp::DownwardMessageQueueHeads` (r:1 w:1) + /// Proof: `Dmp::DownwardMessageQueueHeads` (`max_values`: None, `max_size`: None, mode: `Measured`) + pub(crate) fn reserve_transfer_assets() -> Weight { + // Proof Size summary in bytes: + // Measured: `302` + // Estimated: `6196` + // Minimum execution time: 128_185_000 picoseconds. + Weight::from_parts(132_459_000, 6196) + .saturating_add(T::DbWeight::get().reads(7)) + .saturating_add(T::DbWeight::get().writes(4)) + } + /// Storage: `System::Account` (r:2 w:2) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`) + /// Storage: `XcmPallet::ShouldRecordXcm` (r:1 w:0) + /// Proof: `XcmPallet::ShouldRecordXcm` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + /// Storage: `Dmp::DeliveryFeeFactor` (r:1 w:0) + /// Proof: `Dmp::DeliveryFeeFactor` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `XcmPallet::SupportedVersion` (r:1 w:0) + /// Proof: `XcmPallet::SupportedVersion` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `Dmp::DownwardMessageQueues` (r:1 w:1) + /// Proof: `Dmp::DownwardMessageQueues` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `Dmp::DownwardMessageQueueHeads` (r:1 w:1) + /// Proof: `Dmp::DownwardMessageQueueHeads` (`max_values`: None, `max_size`: None, mode: `Measured`) + pub(crate) fn transfer_assets() -> Weight { + // Proof Size summary in bytes: + // Measured: `250` + // Estimated: `6196` + // Minimum execution time: 132_603_000 picoseconds. + Weight::from_parts(135_485_000, 6196) + .saturating_add(T::DbWeight::get().reads(7)) + .saturating_add(T::DbWeight::get().writes(4)) + } + /// Storage: `XcmPallet::ShouldRecordXcm` (r:1 w:0) + /// Proof: `XcmPallet::ShouldRecordXcm` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + pub(crate) fn execute() -> Weight { + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `1485` + // Minimum execution time: 9_227_000 picoseconds. + Weight::from_parts(9_554_000, 1485) + .saturating_add(T::DbWeight::get().reads(1)) + } + /// Storage: `XcmPallet::SupportedVersion` (r:0 w:1) + /// Proof: `XcmPallet::SupportedVersion` (`max_values`: None, `max_size`: None, mode: `Measured`) + pub(crate) fn force_xcm_version() -> Weight { + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 8_033_000 picoseconds. + Weight::from_parts(8_269_000, 0) + .saturating_add(T::DbWeight::get().writes(1)) + } + pub(crate) fn force_default_xcm_version() -> Weight { + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 2_294_000 picoseconds. + Weight::from_parts(2_445_000, 0) + } + /// Storage: `XcmPallet::VersionNotifiers` (r:1 w:1) + /// Proof: `XcmPallet::VersionNotifiers` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `XcmPallet::QueryCounter` (r:1 w:1) + /// Proof: `XcmPallet::QueryCounter` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + /// Storage: `Dmp::DeliveryFeeFactor` (r:1 w:0) + /// Proof: `Dmp::DeliveryFeeFactor` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `XcmPallet::SupportedVersion` (r:1 w:0) + /// Proof: `XcmPallet::SupportedVersion` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `Dmp::DownwardMessageQueues` (r:1 w:1) + /// Proof: `Dmp::DownwardMessageQueues` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `Dmp::DownwardMessageQueueHeads` (r:1 w:1) + /// Proof: `Dmp::DownwardMessageQueueHeads` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `XcmPallet::Queries` (r:0 w:1) + /// Proof: `XcmPallet::Queries` (`max_values`: None, `max_size`: None, mode: `Measured`) + pub(crate) fn force_subscribe_version_notify() -> Weight { + // Proof Size summary in bytes: + // Measured: `147` + // Estimated: `3612` + // Minimum execution time: 36_912_000 picoseconds. + Weight::from_parts(38_677_000, 3612) + .saturating_add(T::DbWeight::get().reads(6)) + .saturating_add(T::DbWeight::get().writes(5)) + } + /// Storage: `XcmPallet::VersionNotifiers` (r:1 w:1) + /// Proof: `XcmPallet::VersionNotifiers` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `Dmp::DeliveryFeeFactor` (r:1 w:0) + /// Proof: `Dmp::DeliveryFeeFactor` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `XcmPallet::SupportedVersion` (r:1 w:0) + /// Proof: `XcmPallet::SupportedVersion` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `Dmp::DownwardMessageQueues` (r:1 w:1) + /// Proof: `Dmp::DownwardMessageQueues` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `Dmp::DownwardMessageQueueHeads` (r:1 w:1) + /// Proof: `Dmp::DownwardMessageQueueHeads` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `XcmPallet::Queries` (r:0 w:1) + /// Proof: `XcmPallet::Queries` (`max_values`: None, `max_size`: None, mode: `Measured`) + pub(crate) fn force_unsubscribe_version_notify() -> Weight { + // Proof Size summary in bytes: + // Measured: `327` + // Estimated: `3792` + // Minimum execution time: 46_175_000 picoseconds. + Weight::from_parts(47_850_000, 3792) + .saturating_add(T::DbWeight::get().reads(5)) + .saturating_add(T::DbWeight::get().writes(4)) + } + /// Storage: `XcmPallet::XcmExecutionSuspended` (r:0 w:1) + /// Proof: `XcmPallet::XcmExecutionSuspended` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + pub(crate) fn force_suspension() -> Weight { + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 2_328_000 picoseconds. + Weight::from_parts(2_464_000, 0) + .saturating_add(T::DbWeight::get().writes(1)) + } + /// Storage: `XcmPallet::SupportedVersion` (r:6 w:2) + /// Proof: `XcmPallet::SupportedVersion` (`max_values`: None, `max_size`: None, mode: `Measured`) + pub(crate) fn migrate_supported_version() -> Weight { + // Proof Size summary in bytes: + // Measured: `22` + // Estimated: `15862` + // Minimum execution time: 22_130_000 picoseconds. + Weight::from_parts(22_492_000, 15862) + .saturating_add(T::DbWeight::get().reads(6)) + .saturating_add(T::DbWeight::get().writes(2)) + } + /// Storage: `XcmPallet::VersionNotifiers` (r:6 w:2) + /// Proof: `XcmPallet::VersionNotifiers` (`max_values`: None, `max_size`: None, mode: `Measured`) + pub(crate) fn migrate_version_notifiers() -> Weight { + // Proof Size summary in bytes: + // Measured: `26` + // Estimated: `15866` + // Minimum execution time: 22_043_000 picoseconds. + Weight::from_parts(22_750_000, 15866) + .saturating_add(T::DbWeight::get().reads(6)) + .saturating_add(T::DbWeight::get().writes(2)) + } + /// Storage: `XcmPallet::VersionNotifyTargets` (r:7 w:0) + /// Proof: `XcmPallet::VersionNotifyTargets` (`max_values`: None, `max_size`: None, mode: `Measured`) + pub(crate) fn already_notified_target() -> Weight { + // Proof Size summary in bytes: + // Measured: `40` + // Estimated: `18355` + // Minimum execution time: 25_046_000 picoseconds. + Weight::from_parts(25_660_000, 18355) + .saturating_add(T::DbWeight::get().reads(7)) + } + /// Storage: `XcmPallet::VersionNotifyTargets` (r:2 w:1) + /// Proof: `XcmPallet::VersionNotifyTargets` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `Dmp::DeliveryFeeFactor` (r:1 w:0) + /// Proof: `Dmp::DeliveryFeeFactor` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `XcmPallet::SupportedVersion` (r:1 w:0) + /// Proof: `XcmPallet::SupportedVersion` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `Dmp::DownwardMessageQueues` (r:1 w:1) + /// Proof: `Dmp::DownwardMessageQueues` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `Dmp::DownwardMessageQueueHeads` (r:1 w:1) + /// Proof: `Dmp::DownwardMessageQueueHeads` (`max_values`: None, `max_size`: None, mode: `Measured`) + pub(crate) fn notify_current_targets() -> Weight { + // Proof Size summary in bytes: + // Measured: `183` + // Estimated: `6123` + // Minimum execution time: 36_029_000 picoseconds. + Weight::from_parts(37_313_000, 6123) + .saturating_add(T::DbWeight::get().reads(6)) + .saturating_add(T::DbWeight::get().writes(3)) + } + /// Storage: `XcmPallet::VersionNotifyTargets` (r:5 w:0) + /// Proof: `XcmPallet::VersionNotifyTargets` (`max_values`: None, `max_size`: None, mode: `Measured`) + pub(crate) fn notify_target_migration_fail() -> Weight { + // Proof Size summary in bytes: + // Measured: `40` + // Estimated: `13405` + // Minimum execution time: 17_295_000 picoseconds. + Weight::from_parts(17_961_000, 13405) + .saturating_add(T::DbWeight::get().reads(5)) + } + /// Storage: `XcmPallet::VersionNotifyTargets` (r:6 w:2) + /// Proof: `XcmPallet::VersionNotifyTargets` (`max_values`: None, `max_size`: None, mode: `Measured`) + pub(crate) fn migrate_version_notify_targets() -> Weight { + // Proof Size summary in bytes: + // Measured: `33` + // Estimated: `15873` + // Minimum execution time: 21_606_000 picoseconds. + Weight::from_parts(21_939_000, 15873) + .saturating_add(T::DbWeight::get().reads(6)) + .saturating_add(T::DbWeight::get().writes(2)) + } + /// Storage: `XcmPallet::VersionNotifyTargets` (r:6 w:2) + /// Proof: `XcmPallet::VersionNotifyTargets` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `Dmp::DeliveryFeeFactor` (r:1 w:0) + /// Proof: `Dmp::DeliveryFeeFactor` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `XcmPallet::SupportedVersion` (r:1 w:0) + /// Proof: `XcmPallet::SupportedVersion` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `Dmp::DownwardMessageQueues` (r:1 w:1) + /// Proof: `Dmp::DownwardMessageQueues` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `Dmp::DownwardMessageQueueHeads` (r:1 w:1) + /// Proof: `Dmp::DownwardMessageQueueHeads` (`max_values`: None, `max_size`: None, mode: `Measured`) + pub(crate) fn migrate_and_notify_old_targets() -> Weight { + // Proof Size summary in bytes: + // Measured: `183` + // Estimated: `16023` + // Minimum execution time: 49_623_000 picoseconds. + Weight::from_parts(50_940_000, 16023) + .saturating_add(T::DbWeight::get().reads(10)) + .saturating_add(T::DbWeight::get().writes(4)) + } + /// Storage: `XcmPallet::QueryCounter` (r:1 w:1) + /// Proof: `XcmPallet::QueryCounter` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + /// Storage: `XcmPallet::Queries` (r:0 w:1) + /// Proof: `XcmPallet::Queries` (`max_values`: None, `max_size`: None, mode: `Measured`) + pub(crate) fn new_query() -> Weight { + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `1485` + // Minimum execution time: 2_662_000 picoseconds. + Weight::from_parts(2_832_000, 1485) + .saturating_add(T::DbWeight::get().reads(1)) + .saturating_add(T::DbWeight::get().writes(2)) + } + /// Storage: `XcmPallet::Queries` (r:1 w:1) + /// Proof: `XcmPallet::Queries` (`max_values`: None, `max_size`: None, mode: `Measured`) + pub(crate) fn take_response() -> Weight { + // Proof Size summary in bytes: + // Measured: `7576` + // Estimated: `11041` + // Minimum execution time: 26_358_000 picoseconds. + Weight::from_parts(26_871_000, 11041) + .saturating_add(T::DbWeight::get().reads(1)) + .saturating_add(T::DbWeight::get().writes(1)) + } + /// Storage: `XcmPallet::ShouldRecordXcm` (r:1 w:0) + /// Proof: `XcmPallet::ShouldRecordXcm` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + /// Storage: `XcmPallet::AssetTraps` (r:1 w:1) + /// Proof: `XcmPallet::AssetTraps` (`max_values`: None, `max_size`: None, mode: `Measured`) + pub(crate) fn claim_assets() -> Weight { + // Proof Size summary in bytes: + // Measured: `23` + // Estimated: `3488` + // Minimum execution time: 39_745_000 picoseconds. + Weight::from_parts(40_188_000, 3488) + .saturating_add(T::DbWeight::get().reads(2)) + .saturating_add(T::DbWeight::get().writes(1)) + } + /// Storage: `XcmPallet::AuthorizedAliasesMap` (r:1 w:1) + /// Proof: `XcmPallet::AuthorizedAliasesMap` (`max_values`: None, `max_size`: None, mode: `Measured`) + pub(crate) fn add_authorized_alias() -> Weight { + // Proof Size summary in bytes: + // Measured: `361` + // Estimated: `3826` + // Minimum execution time: 15_726_000 picoseconds. + Weight::from_parts(16_154_000, 3826) + .saturating_add(T::DbWeight::get().reads(1)) + .saturating_add(T::DbWeight::get().writes(1)) + } + /// Storage: `XcmPallet::AuthorizedAliasesMap` (r:1 w:1) + /// Proof: `XcmPallet::AuthorizedAliasesMap` (`max_values`: None, `max_size`: None, mode: `Measured`) + pub(crate) fn remove_authorized_alias() -> Weight { + // Proof Size summary in bytes: + // Measured: `400` + // Estimated: `3865` + // Minimum execution time: 17_404_000 picoseconds. + Weight::from_parts(17_718_000, 3865) + .saturating_add(T::DbWeight::get().reads(1)) + .saturating_add(T::DbWeight::get().writes(1)) + } +} From 79bfce2bdd5a726c6651cc55c71d066805e6d01d Mon Sep 17 00:00:00 2001 From: command-bot <> Date: Thu, 7 Nov 2024 12:44:34 +0000 Subject: [PATCH 11/40] ".git/.scripts/commands/bench/bench.sh" --subcommand=xcm --runtime=rococo --target_dir=polkadot --pallet=pallet_xcm --- .../rococo/src/weights/xcm/pallet_xcm.rs | 363 ++++++++++++++++++ 1 file changed, 363 insertions(+) create mode 100644 polkadot/runtime/rococo/src/weights/xcm/pallet_xcm.rs diff --git a/polkadot/runtime/rococo/src/weights/xcm/pallet_xcm.rs b/polkadot/runtime/rococo/src/weights/xcm/pallet_xcm.rs new file mode 100644 index 000000000000..4309c155ca9a --- /dev/null +++ b/polkadot/runtime/rococo/src/weights/xcm/pallet_xcm.rs @@ -0,0 +1,363 @@ +// Copyright (C) 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 . + +//! Autogenerated weights for `pallet_xcm` +//! +//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 32.0.0 +//! DATE: 2024-11-07, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! WORST CASE MAP SIZE: `1000000` +//! HOSTNAME: `runner-vcatxqpx-project-674-concurrent-0`, CPU: `Intel(R) Xeon(R) CPU @ 2.60GHz` +//! WASM-EXECUTION: Compiled, CHAIN: Some("rococo-dev"), DB CACHE: 1024 + +// Executed Command: +// target/production/polkadot +// benchmark +// pallet +// --steps=50 +// --repeat=20 +// --extrinsic=* +// --wasm-execution=compiled +// --heap-pages=4096 +// --json-file=/builds/parity/mirrors/polkadot-sdk/.git/.artifacts/bench.json +// --pallet=pallet_xcm +// --chain=rococo-dev +// --header=./polkadot/file_header.txt +// --template=./polkadot/xcm/pallet-xcm-benchmarks/template.hbs +// --output=./polkadot/runtime/rococo/src/weights/xcm/ + +#![cfg_attr(rustfmt, rustfmt_skip)] +#![allow(unused_parens)] +#![allow(unused_imports)] +#![allow(missing_docs)] + +use frame_support::{traits::Get, weights::Weight}; +use core::marker::PhantomData; + +/// Weight functions for `pallet_xcm`. +pub struct WeightInfo(PhantomData); +impl WeightInfo { + /// Storage: `Dmp::DeliveryFeeFactor` (r:1 w:0) + /// Proof: `Dmp::DeliveryFeeFactor` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `XcmPallet::SupportedVersion` (r:1 w:0) + /// Proof: `XcmPallet::SupportedVersion` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `Dmp::DownwardMessageQueues` (r:1 w:1) + /// Proof: `Dmp::DownwardMessageQueues` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `Dmp::DownwardMessageQueueHeads` (r:1 w:1) + /// Proof: `Dmp::DownwardMessageQueueHeads` (`max_values`: None, `max_size`: None, mode: `Measured`) + pub(crate) fn send() -> Weight { + // Proof Size summary in bytes: + // Measured: `180` + // Estimated: `3645` + // Minimum execution time: 30_643_000 picoseconds. + Weight::from_parts(31_782_000, 3645) + .saturating_add(T::DbWeight::get().reads(4)) + .saturating_add(T::DbWeight::get().writes(2)) + } + /// Storage: `System::Account` (r:1 w:1) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`) + /// Storage: `XcmPallet::ShouldRecordXcm` (r:1 w:0) + /// Proof: `XcmPallet::ShouldRecordXcm` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + /// Storage: `Dmp::DeliveryFeeFactor` (r:1 w:0) + /// Proof: `Dmp::DeliveryFeeFactor` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `XcmPallet::SupportedVersion` (r:1 w:0) + /// Proof: `XcmPallet::SupportedVersion` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `Dmp::DownwardMessageQueues` (r:1 w:1) + /// Proof: `Dmp::DownwardMessageQueues` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `Dmp::DownwardMessageQueueHeads` (r:1 w:1) + /// Proof: `Dmp::DownwardMessageQueueHeads` (`max_values`: None, `max_size`: None, mode: `Measured`) + pub(crate) fn teleport_assets() -> Weight { + // Proof Size summary in bytes: + // Measured: `180` + // Estimated: `3645` + // Minimum execution time: 130_791_000 picoseconds. + Weight::from_parts(134_979_000, 3645) + .saturating_add(T::DbWeight::get().reads(6)) + .saturating_add(T::DbWeight::get().writes(3)) + } + /// Storage: `XcmPallet::ShouldRecordXcm` (r:1 w:0) + /// Proof: `XcmPallet::ShouldRecordXcm` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + /// Storage: `System::Account` (r:1 w:1) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`) + /// Storage: `Dmp::DeliveryFeeFactor` (r:1 w:0) + /// Proof: `Dmp::DeliveryFeeFactor` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `XcmPallet::SupportedVersion` (r:1 w:0) + /// Proof: `XcmPallet::SupportedVersion` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `Dmp::DownwardMessageQueues` (r:1 w:1) + /// Proof: `Dmp::DownwardMessageQueues` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `Dmp::DownwardMessageQueueHeads` (r:1 w:1) + /// Proof: `Dmp::DownwardMessageQueueHeads` (`max_values`: None, `max_size`: None, mode: `Measured`) + pub(crate) fn reserve_transfer_assets() -> Weight { + // Proof Size summary in bytes: + // Measured: `232` + // Estimated: `3697` + // Minimum execution time: 129_933_000 picoseconds. + Weight::from_parts(134_918_000, 3697) + .saturating_add(T::DbWeight::get().reads(6)) + .saturating_add(T::DbWeight::get().writes(3)) + } + /// Storage: `System::Account` (r:1 w:1) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`) + /// Storage: `XcmPallet::ShouldRecordXcm` (r:1 w:0) + /// Proof: `XcmPallet::ShouldRecordXcm` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + /// Storage: `Dmp::DeliveryFeeFactor` (r:1 w:0) + /// Proof: `Dmp::DeliveryFeeFactor` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `XcmPallet::SupportedVersion` (r:1 w:0) + /// Proof: `XcmPallet::SupportedVersion` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `Dmp::DownwardMessageQueues` (r:1 w:1) + /// Proof: `Dmp::DownwardMessageQueues` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `Dmp::DownwardMessageQueueHeads` (r:1 w:1) + /// Proof: `Dmp::DownwardMessageQueueHeads` (`max_values`: None, `max_size`: None, mode: `Measured`) + pub(crate) fn transfer_assets() -> Weight { + // Proof Size summary in bytes: + // Measured: `180` + // Estimated: `3645` + // Minimum execution time: 130_466_000 picoseconds. + Weight::from_parts(135_449_000, 3645) + .saturating_add(T::DbWeight::get().reads(6)) + .saturating_add(T::DbWeight::get().writes(3)) + } + /// Storage: `XcmPallet::ShouldRecordXcm` (r:1 w:0) + /// Proof: `XcmPallet::ShouldRecordXcm` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + pub(crate) fn execute() -> Weight { + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `1485` + // Minimum execution time: 9_620_000 picoseconds. + Weight::from_parts(10_073_000, 1485) + .saturating_add(T::DbWeight::get().reads(1)) + } + /// Storage: `XcmPallet::SupportedVersion` (r:0 w:1) + /// Proof: `XcmPallet::SupportedVersion` (`max_values`: None, `max_size`: None, mode: `Measured`) + pub(crate) fn force_xcm_version() -> Weight { + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 8_386_000 picoseconds. + Weight::from_parts(8_727_000, 0) + .saturating_add(T::DbWeight::get().writes(1)) + } + pub(crate) fn force_default_xcm_version() -> Weight { + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 2_481_000 picoseconds. + Weight::from_parts(2_653_000, 0) + } + /// Storage: `XcmPallet::VersionNotifiers` (r:1 w:1) + /// Proof: `XcmPallet::VersionNotifiers` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `XcmPallet::QueryCounter` (r:1 w:1) + /// Proof: `XcmPallet::QueryCounter` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + /// Storage: `Dmp::DeliveryFeeFactor` (r:1 w:0) + /// Proof: `Dmp::DeliveryFeeFactor` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `XcmPallet::SupportedVersion` (r:1 w:0) + /// Proof: `XcmPallet::SupportedVersion` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `Dmp::DownwardMessageQueues` (r:1 w:1) + /// Proof: `Dmp::DownwardMessageQueues` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `Dmp::DownwardMessageQueueHeads` (r:1 w:1) + /// Proof: `Dmp::DownwardMessageQueueHeads` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `XcmPallet::Queries` (r:0 w:1) + /// Proof: `XcmPallet::Queries` (`max_values`: None, `max_size`: None, mode: `Measured`) + pub(crate) fn force_subscribe_version_notify() -> Weight { + // Proof Size summary in bytes: + // Measured: `180` + // Estimated: `3645` + // Minimum execution time: 37_250_000 picoseconds. + Weight::from_parts(38_353_000, 3645) + .saturating_add(T::DbWeight::get().reads(6)) + .saturating_add(T::DbWeight::get().writes(5)) + } + /// Storage: `XcmPallet::VersionNotifiers` (r:1 w:1) + /// Proof: `XcmPallet::VersionNotifiers` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `Dmp::DeliveryFeeFactor` (r:1 w:0) + /// Proof: `Dmp::DeliveryFeeFactor` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `XcmPallet::SupportedVersion` (r:1 w:0) + /// Proof: `XcmPallet::SupportedVersion` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `Dmp::DownwardMessageQueues` (r:1 w:1) + /// Proof: `Dmp::DownwardMessageQueues` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `Dmp::DownwardMessageQueueHeads` (r:1 w:1) + /// Proof: `Dmp::DownwardMessageQueueHeads` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `XcmPallet::Queries` (r:0 w:1) + /// Proof: `XcmPallet::Queries` (`max_values`: None, `max_size`: None, mode: `Measured`) + pub(crate) fn force_unsubscribe_version_notify() -> Weight { + // Proof Size summary in bytes: + // Measured: `360` + // Estimated: `3825` + // Minimum execution time: 46_257_000 picoseconds. + Weight::from_parts(47_915_000, 3825) + .saturating_add(T::DbWeight::get().reads(5)) + .saturating_add(T::DbWeight::get().writes(4)) + } + /// Storage: `XcmPallet::XcmExecutionSuspended` (r:0 w:1) + /// Proof: `XcmPallet::XcmExecutionSuspended` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + pub(crate) fn force_suspension() -> Weight { + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 2_530_000 picoseconds. + Weight::from_parts(2_619_000, 0) + .saturating_add(T::DbWeight::get().writes(1)) + } + /// Storage: `XcmPallet::SupportedVersion` (r:6 w:2) + /// Proof: `XcmPallet::SupportedVersion` (`max_values`: None, `max_size`: None, mode: `Measured`) + pub(crate) fn migrate_supported_version() -> Weight { + // Proof Size summary in bytes: + // Measured: `22` + // Estimated: `15862` + // Minimum execution time: 21_851_000 picoseconds. + Weight::from_parts(22_104_000, 15862) + .saturating_add(T::DbWeight::get().reads(6)) + .saturating_add(T::DbWeight::get().writes(2)) + } + /// Storage: `XcmPallet::VersionNotifiers` (r:6 w:2) + /// Proof: `XcmPallet::VersionNotifiers` (`max_values`: None, `max_size`: None, mode: `Measured`) + pub(crate) fn migrate_version_notifiers() -> Weight { + // Proof Size summary in bytes: + // Measured: `26` + // Estimated: `15866` + // Minimum execution time: 22_063_000 picoseconds. + Weight::from_parts(22_386_000, 15866) + .saturating_add(T::DbWeight::get().reads(6)) + .saturating_add(T::DbWeight::get().writes(2)) + } + /// Storage: `XcmPallet::VersionNotifyTargets` (r:7 w:0) + /// Proof: `XcmPallet::VersionNotifyTargets` (`max_values`: None, `max_size`: None, mode: `Measured`) + pub(crate) fn already_notified_target() -> Weight { + // Proof Size summary in bytes: + // Measured: `40` + // Estimated: `18355` + // Minimum execution time: 25_210_000 picoseconds. + Weight::from_parts(25_527_000, 18355) + .saturating_add(T::DbWeight::get().reads(7)) + } + /// Storage: `XcmPallet::VersionNotifyTargets` (r:2 w:1) + /// Proof: `XcmPallet::VersionNotifyTargets` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `Dmp::DeliveryFeeFactor` (r:1 w:0) + /// Proof: `Dmp::DeliveryFeeFactor` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `XcmPallet::SupportedVersion` (r:1 w:0) + /// Proof: `XcmPallet::SupportedVersion` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `Dmp::DownwardMessageQueues` (r:1 w:1) + /// Proof: `Dmp::DownwardMessageQueues` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `Dmp::DownwardMessageQueueHeads` (r:1 w:1) + /// Proof: `Dmp::DownwardMessageQueueHeads` (`max_values`: None, `max_size`: None, mode: `Measured`) + pub(crate) fn notify_current_targets() -> Weight { + // Proof Size summary in bytes: + // Measured: `216` + // Estimated: `6156` + // Minimum execution time: 36_418_000 picoseconds. + Weight::from_parts(37_557_000, 6156) + .saturating_add(T::DbWeight::get().reads(6)) + .saturating_add(T::DbWeight::get().writes(3)) + } + /// Storage: `XcmPallet::VersionNotifyTargets` (r:5 w:0) + /// Proof: `XcmPallet::VersionNotifyTargets` (`max_values`: None, `max_size`: None, mode: `Measured`) + pub(crate) fn notify_target_migration_fail() -> Weight { + // Proof Size summary in bytes: + // Measured: `40` + // Estimated: `13405` + // Minimum execution time: 17_617_000 picoseconds. + Weight::from_parts(17_794_000, 13405) + .saturating_add(T::DbWeight::get().reads(5)) + } + /// Storage: `XcmPallet::VersionNotifyTargets` (r:6 w:2) + /// Proof: `XcmPallet::VersionNotifyTargets` (`max_values`: None, `max_size`: None, mode: `Measured`) + pub(crate) fn migrate_version_notify_targets() -> Weight { + // Proof Size summary in bytes: + // Measured: `33` + // Estimated: `15873` + // Minimum execution time: 22_091_000 picoseconds. + Weight::from_parts(22_394_000, 15873) + .saturating_add(T::DbWeight::get().reads(6)) + .saturating_add(T::DbWeight::get().writes(2)) + } + /// Storage: `XcmPallet::VersionNotifyTargets` (r:6 w:2) + /// Proof: `XcmPallet::VersionNotifyTargets` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `Dmp::DeliveryFeeFactor` (r:1 w:0) + /// Proof: `Dmp::DeliveryFeeFactor` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `XcmPallet::SupportedVersion` (r:1 w:0) + /// Proof: `XcmPallet::SupportedVersion` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `Dmp::DownwardMessageQueues` (r:1 w:1) + /// Proof: `Dmp::DownwardMessageQueues` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `Dmp::DownwardMessageQueueHeads` (r:1 w:1) + /// Proof: `Dmp::DownwardMessageQueueHeads` (`max_values`: None, `max_size`: None, mode: `Measured`) + pub(crate) fn migrate_and_notify_old_targets() -> Weight { + // Proof Size summary in bytes: + // Measured: `216` + // Estimated: `16056` + // Minimum execution time: 49_581_000 picoseconds. + Weight::from_parts(50_795_000, 16056) + .saturating_add(T::DbWeight::get().reads(10)) + .saturating_add(T::DbWeight::get().writes(4)) + } + /// Storage: `XcmPallet::QueryCounter` (r:1 w:1) + /// Proof: `XcmPallet::QueryCounter` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + /// Storage: `XcmPallet::Queries` (r:0 w:1) + /// Proof: `XcmPallet::Queries` (`max_values`: None, `max_size`: None, mode: `Measured`) + pub(crate) fn new_query() -> Weight { + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `1485` + // Minimum execution time: 2_781_000 picoseconds. + Weight::from_parts(2_893_000, 1485) + .saturating_add(T::DbWeight::get().reads(1)) + .saturating_add(T::DbWeight::get().writes(2)) + } + /// Storage: `XcmPallet::Queries` (r:1 w:1) + /// Proof: `XcmPallet::Queries` (`max_values`: None, `max_size`: None, mode: `Measured`) + pub(crate) fn take_response() -> Weight { + // Proof Size summary in bytes: + // Measured: `7576` + // Estimated: `11041` + // Minimum execution time: 26_391_000 picoseconds. + Weight::from_parts(26_902_000, 11041) + .saturating_add(T::DbWeight::get().reads(1)) + .saturating_add(T::DbWeight::get().writes(1)) + } + /// Storage: `XcmPallet::ShouldRecordXcm` (r:1 w:0) + /// Proof: `XcmPallet::ShouldRecordXcm` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + /// Storage: `XcmPallet::AssetTraps` (r:1 w:1) + /// Proof: `XcmPallet::AssetTraps` (`max_values`: None, `max_size`: None, mode: `Measured`) + pub(crate) fn claim_assets() -> Weight { + // Proof Size summary in bytes: + // Measured: `23` + // Estimated: `3488` + // Minimum execution time: 39_963_000 picoseconds. + Weight::from_parts(41_025_000, 3488) + .saturating_add(T::DbWeight::get().reads(2)) + .saturating_add(T::DbWeight::get().writes(1)) + } + /// Storage: `XcmPallet::AuthorizedAliasesMap` (r:1 w:1) + /// Proof: `XcmPallet::AuthorizedAliasesMap` (`max_values`: None, `max_size`: None, mode: `Measured`) + pub(crate) fn add_authorized_alias() -> Weight { + // Proof Size summary in bytes: + // Measured: `361` + // Estimated: `3826` + // Minimum execution time: 15_975_000 picoseconds. + Weight::from_parts(16_398_000, 3826) + .saturating_add(T::DbWeight::get().reads(1)) + .saturating_add(T::DbWeight::get().writes(1)) + } + /// Storage: `XcmPallet::AuthorizedAliasesMap` (r:1 w:1) + /// Proof: `XcmPallet::AuthorizedAliasesMap` (`max_values`: None, `max_size`: None, mode: `Measured`) + pub(crate) fn remove_authorized_alias() -> Weight { + // Proof Size summary in bytes: + // Measured: `400` + // Estimated: `3865` + // Minimum execution time: 17_326_000 picoseconds. + Weight::from_parts(17_622_000, 3865) + .saturating_add(T::DbWeight::get().reads(1)) + .saturating_add(T::DbWeight::get().writes(1)) + } +} From 673c3f6f086fb3dfcaa67c5492ee2294740ad791 Mon Sep 17 00:00:00 2001 From: command-bot <> Date: Thu, 7 Nov 2024 13:14:26 +0000 Subject: [PATCH 12/40] ".git/.scripts/commands/bench/bench.sh" --subcommand=xcm --runtime=asset-hub-westend --runtime_dir=assets --target_dir=cumulus --pallet=pallet_xcm --- .../src/weights/xcm/pallet_xcm.rs | 411 ++++++++++++++++++ 1 file changed, 411 insertions(+) create mode 100644 cumulus/parachains/runtimes/assets/asset-hub-westend/src/weights/xcm/pallet_xcm.rs diff --git a/cumulus/parachains/runtimes/assets/asset-hub-westend/src/weights/xcm/pallet_xcm.rs b/cumulus/parachains/runtimes/assets/asset-hub-westend/src/weights/xcm/pallet_xcm.rs new file mode 100644 index 000000000000..1bf29cae6509 --- /dev/null +++ b/cumulus/parachains/runtimes/assets/asset-hub-westend/src/weights/xcm/pallet_xcm.rs @@ -0,0 +1,411 @@ +// Copyright (C) Parity Technologies (UK) Ltd. +// This file is part of Cumulus. + +// Cumulus 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. + +// Cumulus 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 Cumulus. If not, see . + +//! Autogenerated weights for `pallet_xcm` +//! +//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 32.0.0 +//! DATE: 2024-11-07, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! WORST CASE MAP SIZE: `1000000` +//! HOSTNAME: `runner-vcatxqpx-project-674-concurrent-0`, CPU: `Intel(R) Xeon(R) CPU @ 2.60GHz` +//! WASM-EXECUTION: Compiled, CHAIN: Some("asset-hub-westend-dev"), DB CACHE: 1024 + +// Executed Command: +// target/production/polkadot-parachain +// benchmark +// pallet +// --steps=50 +// --repeat=20 +// --extrinsic=* +// --wasm-execution=compiled +// --heap-pages=4096 +// --json-file=/builds/parity/mirrors/polkadot-sdk/.git/.artifacts/bench.json +// --pallet=pallet_xcm +// --chain=asset-hub-westend-dev +// --header=./cumulus/file_header.txt +// --template=./cumulus/templates/xcm-bench-template.hbs +// --output=./cumulus/parachains/runtimes/assets/asset-hub-westend/src/weights/xcm/ + +#![cfg_attr(rustfmt, rustfmt_skip)] +#![allow(unused_parens)] +#![allow(unused_imports)] + +use frame_support::{traits::Get, weights::Weight}; +use core::marker::PhantomData; + +/// Weights for `pallet_xcm`. +pub struct WeightInfo(PhantomData); +impl WeightInfo { + // Storage: `ParachainSystem::UpwardDeliveryFeeFactor` (r:1 w:0) + // Proof: `ParachainSystem::UpwardDeliveryFeeFactor` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + // Storage: `PolkadotXcm::SupportedVersion` (r:1 w:0) + // Proof: `PolkadotXcm::SupportedVersion` (`max_values`: None, `max_size`: None, mode: `Measured`) + // Storage: `PolkadotXcm::VersionDiscoveryQueue` (r:1 w:1) + // Proof: `PolkadotXcm::VersionDiscoveryQueue` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + // Storage: `PolkadotXcm::SafeXcmVersion` (r:1 w:0) + // Proof: `PolkadotXcm::SafeXcmVersion` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + // Storage: `ParachainSystem::HostConfiguration` (r:1 w:0) + // Proof: `ParachainSystem::HostConfiguration` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + // Storage: `ParachainSystem::PendingUpwardMessages` (r:1 w:1) + // Proof: `ParachainSystem::PendingUpwardMessages` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + pub fn send() -> Weight { + // Proof Size summary in bytes: + // Measured: `145` + // Estimated: `3610` + // Minimum execution time: 27_966_000 picoseconds. + Weight::from_parts(28_529_000, 3610) + .saturating_add(T::DbWeight::get().reads(6)) + .saturating_add(T::DbWeight::get().writes(2)) + } + // Storage: `ParachainInfo::ParachainId` (r:1 w:0) + // Proof: `ParachainInfo::ParachainId` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) + // Storage: `PolkadotXcm::ShouldRecordXcm` (r:1 w:0) + // Proof: `PolkadotXcm::ShouldRecordXcm` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + // Storage: `ParachainSystem::UpwardDeliveryFeeFactor` (r:1 w:0) + // Proof: `ParachainSystem::UpwardDeliveryFeeFactor` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + // Storage: `PolkadotXcm::SupportedVersion` (r:1 w:0) + // Proof: `PolkadotXcm::SupportedVersion` (`max_values`: None, `max_size`: None, mode: `Measured`) + // Storage: `PolkadotXcm::VersionDiscoveryQueue` (r:1 w:1) + // Proof: `PolkadotXcm::VersionDiscoveryQueue` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + // Storage: `PolkadotXcm::SafeXcmVersion` (r:1 w:0) + // Proof: `PolkadotXcm::SafeXcmVersion` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + // Storage: `System::Account` (r:1 w:1) + // Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`) + // Storage: `ParachainSystem::HostConfiguration` (r:1 w:0) + // Proof: `ParachainSystem::HostConfiguration` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + // Storage: `ParachainSystem::PendingUpwardMessages` (r:1 w:1) + // Proof: `ParachainSystem::PendingUpwardMessages` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + pub fn teleport_assets() -> Weight { + // Proof Size summary in bytes: + // Measured: `145` + // Estimated: `3610` + // Minimum execution time: 111_910_000 picoseconds. + Weight::from_parts(114_432_000, 3610) + .saturating_add(T::DbWeight::get().reads(9)) + .saturating_add(T::DbWeight::get().writes(3)) + } + // Storage: `ParachainInfo::ParachainId` (r:1 w:0) + // Proof: `ParachainInfo::ParachainId` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) + // Storage: `PolkadotXcm::ShouldRecordXcm` (r:1 w:0) + // Proof: `PolkadotXcm::ShouldRecordXcm` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + // Storage: `System::Account` (r:2 w:2) + // Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`) + // Storage: `XcmpQueue::DeliveryFeeFactor` (r:1 w:0) + // Proof: `XcmpQueue::DeliveryFeeFactor` (`max_values`: None, `max_size`: Some(28), added: 2503, mode: `MaxEncodedLen`) + // Storage: `PolkadotXcm::SupportedVersion` (r:1 w:0) + // Proof: `PolkadotXcm::SupportedVersion` (`max_values`: None, `max_size`: None, mode: `Measured`) + // Storage: `PolkadotXcm::VersionDiscoveryQueue` (r:1 w:1) + // Proof: `PolkadotXcm::VersionDiscoveryQueue` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + // Storage: `PolkadotXcm::SafeXcmVersion` (r:1 w:0) + // Proof: `PolkadotXcm::SafeXcmVersion` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + // Storage: `ParachainSystem::RelevantMessagingState` (r:1 w:0) + // Proof: `ParachainSystem::RelevantMessagingState` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + // Storage: `XcmpQueue::OutboundXcmpStatus` (r:1 w:1) + // Proof: `XcmpQueue::OutboundXcmpStatus` (`max_values`: Some(1), `max_size`: Some(1282), added: 1777, mode: `MaxEncodedLen`) + // Storage: `XcmpQueue::OutboundXcmpMessages` (r:0 w:1) + // Proof: `XcmpQueue::OutboundXcmpMessages` (`max_values`: None, `max_size`: Some(105506), added: 107981, mode: `MaxEncodedLen`) + pub fn reserve_transfer_assets() -> Weight { + // Proof Size summary in bytes: + // Measured: `400` + // Estimated: `6196` + // Minimum execution time: 136_886_000 picoseconds. + Weight::from_parts(141_399_000, 6196) + .saturating_add(T::DbWeight::get().reads(10)) + .saturating_add(T::DbWeight::get().writes(5)) + } + // Storage: `ParachainInfo::ParachainId` (r:1 w:0) + // Proof: `ParachainInfo::ParachainId` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) + // Storage: `PolkadotXcm::ShouldRecordXcm` (r:1 w:0) + // Proof: `PolkadotXcm::ShouldRecordXcm` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + // Storage: `Assets::Asset` (r:1 w:1) + // Proof: `Assets::Asset` (`max_values`: None, `max_size`: Some(210), added: 2685, mode: `MaxEncodedLen`) + // Storage: `Assets::Account` (r:2 w:2) + // Proof: `Assets::Account` (`max_values`: None, `max_size`: Some(134), added: 2609, mode: `MaxEncodedLen`) + // Storage: `AssetsFreezer::FrozenBalances` (r:1 w:0) + // Proof: `AssetsFreezer::FrozenBalances` (`max_values`: None, `max_size`: Some(84), added: 2559, mode: `MaxEncodedLen`) + // Storage: `System::Account` (r:2 w:2) + // Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`) + // Storage: `ParachainSystem::UpwardDeliveryFeeFactor` (r:1 w:0) + // Proof: `ParachainSystem::UpwardDeliveryFeeFactor` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + // Storage: `PolkadotXcm::SupportedVersion` (r:1 w:0) + // Proof: `PolkadotXcm::SupportedVersion` (`max_values`: None, `max_size`: None, mode: `Measured`) + // Storage: `PolkadotXcm::VersionDiscoveryQueue` (r:1 w:1) + // Proof: `PolkadotXcm::VersionDiscoveryQueue` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + // Storage: `PolkadotXcm::SafeXcmVersion` (r:1 w:0) + // Proof: `PolkadotXcm::SafeXcmVersion` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + // Storage: `ParachainSystem::HostConfiguration` (r:1 w:0) + // Proof: `ParachainSystem::HostConfiguration` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + // Storage: `ParachainSystem::PendingUpwardMessages` (r:1 w:1) + // Proof: `ParachainSystem::PendingUpwardMessages` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + pub fn transfer_assets() -> Weight { + // Proof Size summary in bytes: + // Measured: `571` + // Estimated: `6208` + // Minimum execution time: 176_288_000 picoseconds. + Weight::from_parts(184_999_000, 6208) + .saturating_add(T::DbWeight::get().reads(14)) + .saturating_add(T::DbWeight::get().writes(7)) + } + // Storage: `PolkadotXcm::ShouldRecordXcm` (r:1 w:0) + // Proof: `PolkadotXcm::ShouldRecordXcm` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + pub fn execute() -> Weight { + // Proof Size summary in bytes: + // Measured: `103` + // Estimated: `1588` + // Minimum execution time: 12_420_000 picoseconds. + Weight::from_parts(12_882_000, 1588) + .saturating_add(T::DbWeight::get().reads(1)) + } + // Storage: `PolkadotXcm::SupportedVersion` (r:0 w:1) + // Proof: `PolkadotXcm::SupportedVersion` (`max_values`: None, `max_size`: None, mode: `Measured`) + pub fn force_xcm_version() -> Weight { + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 6_994_000 picoseconds. + Weight::from_parts(7_196_000, 0) + .saturating_add(T::DbWeight::get().writes(1)) + } + // Storage: `PolkadotXcm::SafeXcmVersion` (r:0 w:1) + // Proof: `PolkadotXcm::SafeXcmVersion` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + pub fn force_default_xcm_version() -> Weight { + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 2_216_000 picoseconds. + Weight::from_parts(2_352_000, 0) + .saturating_add(T::DbWeight::get().writes(1)) + } + // Storage: `PolkadotXcm::VersionNotifiers` (r:1 w:1) + // Proof: `PolkadotXcm::VersionNotifiers` (`max_values`: None, `max_size`: None, mode: `Measured`) + // Storage: `PolkadotXcm::QueryCounter` (r:1 w:1) + // Proof: `PolkadotXcm::QueryCounter` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + // Storage: `ParachainSystem::UpwardDeliveryFeeFactor` (r:1 w:0) + // Proof: `ParachainSystem::UpwardDeliveryFeeFactor` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + // Storage: `PolkadotXcm::SupportedVersion` (r:1 w:0) + // Proof: `PolkadotXcm::SupportedVersion` (`max_values`: None, `max_size`: None, mode: `Measured`) + // Storage: `PolkadotXcm::VersionDiscoveryQueue` (r:1 w:1) + // Proof: `PolkadotXcm::VersionDiscoveryQueue` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + // Storage: `PolkadotXcm::SafeXcmVersion` (r:1 w:0) + // Proof: `PolkadotXcm::SafeXcmVersion` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + // Storage: `ParachainSystem::HostConfiguration` (r:1 w:0) + // Proof: `ParachainSystem::HostConfiguration` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + // Storage: `ParachainSystem::PendingUpwardMessages` (r:1 w:1) + // Proof: `ParachainSystem::PendingUpwardMessages` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + // Storage: `PolkadotXcm::Queries` (r:0 w:1) + // Proof: `PolkadotXcm::Queries` (`max_values`: None, `max_size`: None, mode: `Measured`) + pub fn force_subscribe_version_notify() -> Weight { + // Proof Size summary in bytes: + // Measured: `145` + // Estimated: `3610` + // Minimum execution time: 34_493_000 picoseconds. + Weight::from_parts(35_689_000, 3610) + .saturating_add(T::DbWeight::get().reads(8)) + .saturating_add(T::DbWeight::get().writes(5)) + } + // Storage: `PolkadotXcm::VersionNotifiers` (r:1 w:1) + // Proof: `PolkadotXcm::VersionNotifiers` (`max_values`: None, `max_size`: None, mode: `Measured`) + // Storage: `ParachainSystem::UpwardDeliveryFeeFactor` (r:1 w:0) + // Proof: `ParachainSystem::UpwardDeliveryFeeFactor` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + // Storage: `PolkadotXcm::SupportedVersion` (r:1 w:0) + // Proof: `PolkadotXcm::SupportedVersion` (`max_values`: None, `max_size`: None, mode: `Measured`) + // Storage: `PolkadotXcm::VersionDiscoveryQueue` (r:1 w:1) + // Proof: `PolkadotXcm::VersionDiscoveryQueue` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + // Storage: `PolkadotXcm::SafeXcmVersion` (r:1 w:0) + // Proof: `PolkadotXcm::SafeXcmVersion` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + // Storage: `ParachainSystem::HostConfiguration` (r:1 w:0) + // Proof: `ParachainSystem::HostConfiguration` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + // Storage: `ParachainSystem::PendingUpwardMessages` (r:1 w:1) + // Proof: `ParachainSystem::PendingUpwardMessages` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + // Storage: `PolkadotXcm::Queries` (r:0 w:1) + // Proof: `PolkadotXcm::Queries` (`max_values`: None, `max_size`: None, mode: `Measured`) + pub fn force_unsubscribe_version_notify() -> Weight { + // Proof Size summary in bytes: + // Measured: `363` + // Estimated: `3828` + // Minimum execution time: 38_104_000 picoseconds. + Weight::from_parts(39_185_000, 3828) + .saturating_add(T::DbWeight::get().reads(7)) + .saturating_add(T::DbWeight::get().writes(4)) + } + // Storage: `PolkadotXcm::XcmExecutionSuspended` (r:0 w:1) + // Proof: `PolkadotXcm::XcmExecutionSuspended` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + pub fn force_suspension() -> Weight { + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 2_303_000 picoseconds. + Weight::from_parts(2_445_000, 0) + .saturating_add(T::DbWeight::get().writes(1)) + } + // Storage: `PolkadotXcm::SupportedVersion` (r:6 w:2) + // Proof: `PolkadotXcm::SupportedVersion` (`max_values`: None, `max_size`: None, mode: `Measured`) + pub fn migrate_supported_version() -> Weight { + // Proof Size summary in bytes: + // Measured: `159` + // Estimated: `15999` + // Minimum execution time: 25_339_000 picoseconds. + Weight::from_parts(25_983_000, 15999) + .saturating_add(T::DbWeight::get().reads(6)) + .saturating_add(T::DbWeight::get().writes(2)) + } + // Storage: `PolkadotXcm::VersionNotifiers` (r:6 w:2) + // Proof: `PolkadotXcm::VersionNotifiers` (`max_values`: None, `max_size`: None, mode: `Measured`) + pub fn migrate_version_notifiers() -> Weight { + // Proof Size summary in bytes: + // Measured: `163` + // Estimated: `16003` + // Minimum execution time: 25_010_000 picoseconds. + Weight::from_parts(25_742_000, 16003) + .saturating_add(T::DbWeight::get().reads(6)) + .saturating_add(T::DbWeight::get().writes(2)) + } + // Storage: `PolkadotXcm::VersionNotifyTargets` (r:7 w:0) + // Proof: `PolkadotXcm::VersionNotifyTargets` (`max_values`: None, `max_size`: None, mode: `Measured`) + pub fn already_notified_target() -> Weight { + // Proof Size summary in bytes: + // Measured: `173` + // Estimated: `18488` + // Minimum execution time: 28_326_000 picoseconds. + Weight::from_parts(28_909_000, 18488) + .saturating_add(T::DbWeight::get().reads(7)) + } + // Storage: `PolkadotXcm::VersionNotifyTargets` (r:2 w:1) + // Proof: `PolkadotXcm::VersionNotifyTargets` (`max_values`: None, `max_size`: None, mode: `Measured`) + // Storage: `ParachainSystem::UpwardDeliveryFeeFactor` (r:1 w:0) + // Proof: `ParachainSystem::UpwardDeliveryFeeFactor` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + // Storage: `PolkadotXcm::SupportedVersion` (r:1 w:0) + // Proof: `PolkadotXcm::SupportedVersion` (`max_values`: None, `max_size`: None, mode: `Measured`) + // Storage: `PolkadotXcm::VersionDiscoveryQueue` (r:1 w:1) + // Proof: `PolkadotXcm::VersionDiscoveryQueue` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + // Storage: `PolkadotXcm::SafeXcmVersion` (r:1 w:0) + // Proof: `PolkadotXcm::SafeXcmVersion` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + // Storage: `ParachainSystem::HostConfiguration` (r:1 w:0) + // Proof: `ParachainSystem::HostConfiguration` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + // Storage: `ParachainSystem::PendingUpwardMessages` (r:1 w:1) + // Proof: `ParachainSystem::PendingUpwardMessages` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + pub fn notify_current_targets() -> Weight { + // Proof Size summary in bytes: + // Measured: `212` + // Estimated: `6152` + // Minimum execution time: 32_943_000 picoseconds. + Weight::from_parts(33_935_000, 6152) + .saturating_add(T::DbWeight::get().reads(8)) + .saturating_add(T::DbWeight::get().writes(3)) + } + // Storage: `PolkadotXcm::VersionNotifyTargets` (r:5 w:0) + // Proof: `PolkadotXcm::VersionNotifyTargets` (`max_values`: None, `max_size`: None, mode: `Measured`) + pub fn notify_target_migration_fail() -> Weight { + // Proof Size summary in bytes: + // Measured: `176` + // Estimated: `13541` + // Minimum execution time: 17_887_000 picoseconds. + Weight::from_parts(18_345_000, 13541) + .saturating_add(T::DbWeight::get().reads(5)) + } + // Storage: `PolkadotXcm::VersionNotifyTargets` (r:6 w:2) + // Proof: `PolkadotXcm::VersionNotifyTargets` (`max_values`: None, `max_size`: None, mode: `Measured`) + pub fn migrate_version_notify_targets() -> Weight { + // Proof Size summary in bytes: + // Measured: `170` + // Estimated: `16010` + // Minimum execution time: 25_926_000 picoseconds. + Weight::from_parts(26_253_000, 16010) + .saturating_add(T::DbWeight::get().reads(6)) + .saturating_add(T::DbWeight::get().writes(2)) + } + // Storage: `PolkadotXcm::VersionNotifyTargets` (r:6 w:2) + // Proof: `PolkadotXcm::VersionNotifyTargets` (`max_values`: None, `max_size`: None, mode: `Measured`) + // Storage: `ParachainSystem::UpwardDeliveryFeeFactor` (r:1 w:0) + // Proof: `ParachainSystem::UpwardDeliveryFeeFactor` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + // Storage: `PolkadotXcm::SupportedVersion` (r:1 w:0) + // Proof: `PolkadotXcm::SupportedVersion` (`max_values`: None, `max_size`: None, mode: `Measured`) + // Storage: `PolkadotXcm::VersionDiscoveryQueue` (r:1 w:1) + // Proof: `PolkadotXcm::VersionDiscoveryQueue` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + // Storage: `PolkadotXcm::SafeXcmVersion` (r:1 w:0) + // Proof: `PolkadotXcm::SafeXcmVersion` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + // Storage: `ParachainSystem::HostConfiguration` (r:1 w:0) + // Proof: `ParachainSystem::HostConfiguration` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + // Storage: `ParachainSystem::PendingUpwardMessages` (r:1 w:1) + // Proof: `ParachainSystem::PendingUpwardMessages` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + pub fn migrate_and_notify_old_targets() -> Weight { + // Proof Size summary in bytes: + // Measured: `212` + // Estimated: `16052` + // Minimum execution time: 46_227_000 picoseconds. + Weight::from_parts(47_320_000, 16052) + .saturating_add(T::DbWeight::get().reads(12)) + .saturating_add(T::DbWeight::get().writes(4)) + } + // Storage: `PolkadotXcm::QueryCounter` (r:1 w:1) + // Proof: `PolkadotXcm::QueryCounter` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + // Storage: `PolkadotXcm::Queries` (r:0 w:1) + // Proof: `PolkadotXcm::Queries` (`max_values`: None, `max_size`: None, mode: `Measured`) + pub fn new_query() -> Weight { + // Proof Size summary in bytes: + // Measured: `103` + // Estimated: `1588` + // Minimum execution time: 5_634_000 picoseconds. + Weight::from_parts(5_918_000, 1588) + .saturating_add(T::DbWeight::get().reads(1)) + .saturating_add(T::DbWeight::get().writes(2)) + } + // Storage: `PolkadotXcm::Queries` (r:1 w:1) + // Proof: `PolkadotXcm::Queries` (`max_values`: None, `max_size`: None, mode: `Measured`) + pub fn take_response() -> Weight { + // Proof Size summary in bytes: + // Measured: `7740` + // Estimated: `11205` + // Minimum execution time: 30_787_000 picoseconds. + Weight::from_parts(31_078_000, 11205) + .saturating_add(T::DbWeight::get().reads(1)) + .saturating_add(T::DbWeight::get().writes(1)) + } + // Storage: `PolkadotXcm::ShouldRecordXcm` (r:1 w:0) + // Proof: `PolkadotXcm::ShouldRecordXcm` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + // Storage: `PolkadotXcm::AssetTraps` (r:1 w:1) + // Proof: `PolkadotXcm::AssetTraps` (`max_values`: None, `max_size`: None, mode: `Measured`) + pub fn claim_assets() -> Weight { + // Proof Size summary in bytes: + // Measured: `160` + // Estimated: `3625` + // Minimum execution time: 43_765_000 picoseconds. + Weight::from_parts(45_070_000, 3625) + .saturating_add(T::DbWeight::get().reads(2)) + .saturating_add(T::DbWeight::get().writes(1)) + } + // Storage: `PolkadotXcm::AuthorizedAliasesMap` (r:1 w:1) + // Proof: `PolkadotXcm::AuthorizedAliasesMap` (`max_values`: None, `max_size`: None, mode: `Measured`) + pub fn add_authorized_alias() -> Weight { + // Proof Size summary in bytes: + // Measured: `498` + // Estimated: `3963` + // Minimum execution time: 19_160_000 picoseconds. + Weight::from_parts(19_749_000, 3963) + .saturating_add(T::DbWeight::get().reads(1)) + .saturating_add(T::DbWeight::get().writes(1)) + } + // Storage: `PolkadotXcm::AuthorizedAliasesMap` (r:1 w:1) + // Proof: `PolkadotXcm::AuthorizedAliasesMap` (`max_values`: None, `max_size`: None, mode: `Measured`) + pub fn remove_authorized_alias() -> Weight { + // Proof Size summary in bytes: + // Measured: `537` + // Estimated: `4002` + // Minimum execution time: 20_372_000 picoseconds. + Weight::from_parts(21_198_000, 4002) + .saturating_add(T::DbWeight::get().reads(1)) + .saturating_add(T::DbWeight::get().writes(1)) + } +} From ac5d4a6de31b262cf1340ac2a1cbe5a75b6dec25 Mon Sep 17 00:00:00 2001 From: command-bot <> Date: Thu, 7 Nov 2024 13:18:07 +0000 Subject: [PATCH 13/40] ".git/.scripts/commands/bench/bench.sh" --subcommand=xcm --runtime=asset-hub-rococo --runtime_dir=assets --target_dir=cumulus --pallet=pallet_xcm --- .../src/weights/xcm/pallet_xcm.rs | 411 ++++++++++++++++++ 1 file changed, 411 insertions(+) create mode 100644 cumulus/parachains/runtimes/assets/asset-hub-rococo/src/weights/xcm/pallet_xcm.rs diff --git a/cumulus/parachains/runtimes/assets/asset-hub-rococo/src/weights/xcm/pallet_xcm.rs b/cumulus/parachains/runtimes/assets/asset-hub-rococo/src/weights/xcm/pallet_xcm.rs new file mode 100644 index 000000000000..d9ad8d67bcb1 --- /dev/null +++ b/cumulus/parachains/runtimes/assets/asset-hub-rococo/src/weights/xcm/pallet_xcm.rs @@ -0,0 +1,411 @@ +// Copyright (C) Parity Technologies (UK) Ltd. +// This file is part of Cumulus. + +// Cumulus 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. + +// Cumulus 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 Cumulus. If not, see . + +//! Autogenerated weights for `pallet_xcm` +//! +//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 32.0.0 +//! DATE: 2024-11-07, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! WORST CASE MAP SIZE: `1000000` +//! HOSTNAME: `runner-vcatxqpx-project-674-concurrent-0`, CPU: `Intel(R) Xeon(R) CPU @ 2.60GHz` +//! WASM-EXECUTION: Compiled, CHAIN: Some("asset-hub-rococo-dev"), DB CACHE: 1024 + +// Executed Command: +// target/production/polkadot-parachain +// benchmark +// pallet +// --steps=50 +// --repeat=20 +// --extrinsic=* +// --wasm-execution=compiled +// --heap-pages=4096 +// --json-file=/builds/parity/mirrors/polkadot-sdk/.git/.artifacts/bench.json +// --pallet=pallet_xcm +// --chain=asset-hub-rococo-dev +// --header=./cumulus/file_header.txt +// --template=./cumulus/templates/xcm-bench-template.hbs +// --output=./cumulus/parachains/runtimes/assets/asset-hub-rococo/src/weights/xcm/ + +#![cfg_attr(rustfmt, rustfmt_skip)] +#![allow(unused_parens)] +#![allow(unused_imports)] + +use frame_support::{traits::Get, weights::Weight}; +use core::marker::PhantomData; + +/// Weights for `pallet_xcm`. +pub struct WeightInfo(PhantomData); +impl WeightInfo { + // Storage: `ParachainSystem::UpwardDeliveryFeeFactor` (r:1 w:0) + // Proof: `ParachainSystem::UpwardDeliveryFeeFactor` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + // Storage: `PolkadotXcm::SupportedVersion` (r:1 w:0) + // Proof: `PolkadotXcm::SupportedVersion` (`max_values`: None, `max_size`: None, mode: `Measured`) + // Storage: `PolkadotXcm::VersionDiscoveryQueue` (r:1 w:1) + // Proof: `PolkadotXcm::VersionDiscoveryQueue` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + // Storage: `PolkadotXcm::SafeXcmVersion` (r:1 w:0) + // Proof: `PolkadotXcm::SafeXcmVersion` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + // Storage: `ParachainSystem::HostConfiguration` (r:1 w:0) + // Proof: `ParachainSystem::HostConfiguration` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + // Storage: `ParachainSystem::PendingUpwardMessages` (r:1 w:1) + // Proof: `ParachainSystem::PendingUpwardMessages` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + pub fn send() -> Weight { + // Proof Size summary in bytes: + // Measured: `145` + // Estimated: `3610` + // Minimum execution time: 28_037_000 picoseconds. + Weight::from_parts(28_751_000, 3610) + .saturating_add(T::DbWeight::get().reads(6)) + .saturating_add(T::DbWeight::get().writes(2)) + } + // Storage: `ParachainInfo::ParachainId` (r:1 w:0) + // Proof: `ParachainInfo::ParachainId` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) + // Storage: `PolkadotXcm::ShouldRecordXcm` (r:1 w:0) + // Proof: `PolkadotXcm::ShouldRecordXcm` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + // Storage: `ParachainSystem::UpwardDeliveryFeeFactor` (r:1 w:0) + // Proof: `ParachainSystem::UpwardDeliveryFeeFactor` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + // Storage: `PolkadotXcm::SupportedVersion` (r:1 w:0) + // Proof: `PolkadotXcm::SupportedVersion` (`max_values`: None, `max_size`: None, mode: `Measured`) + // Storage: `PolkadotXcm::VersionDiscoveryQueue` (r:1 w:1) + // Proof: `PolkadotXcm::VersionDiscoveryQueue` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + // Storage: `PolkadotXcm::SafeXcmVersion` (r:1 w:0) + // Proof: `PolkadotXcm::SafeXcmVersion` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + // Storage: `System::Account` (r:1 w:1) + // Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`) + // Storage: `ParachainSystem::HostConfiguration` (r:1 w:0) + // Proof: `ParachainSystem::HostConfiguration` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + // Storage: `ParachainSystem::PendingUpwardMessages` (r:1 w:1) + // Proof: `ParachainSystem::PendingUpwardMessages` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + pub fn teleport_assets() -> Weight { + // Proof Size summary in bytes: + // Measured: `145` + // Estimated: `3610` + // Minimum execution time: 107_295_000 picoseconds. + Weight::from_parts(110_562_000, 3610) + .saturating_add(T::DbWeight::get().reads(9)) + .saturating_add(T::DbWeight::get().writes(3)) + } + // Storage: `ParachainInfo::ParachainId` (r:1 w:0) + // Proof: `ParachainInfo::ParachainId` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) + // Storage: `PolkadotXcm::ShouldRecordXcm` (r:1 w:0) + // Proof: `PolkadotXcm::ShouldRecordXcm` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + // Storage: `System::Account` (r:2 w:2) + // Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`) + // Storage: `XcmpQueue::DeliveryFeeFactor` (r:1 w:0) + // Proof: `XcmpQueue::DeliveryFeeFactor` (`max_values`: None, `max_size`: Some(28), added: 2503, mode: `MaxEncodedLen`) + // Storage: `PolkadotXcm::SupportedVersion` (r:1 w:0) + // Proof: `PolkadotXcm::SupportedVersion` (`max_values`: None, `max_size`: None, mode: `Measured`) + // Storage: `PolkadotXcm::VersionDiscoveryQueue` (r:1 w:1) + // Proof: `PolkadotXcm::VersionDiscoveryQueue` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + // Storage: `PolkadotXcm::SafeXcmVersion` (r:1 w:0) + // Proof: `PolkadotXcm::SafeXcmVersion` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + // Storage: `ParachainSystem::RelevantMessagingState` (r:1 w:0) + // Proof: `ParachainSystem::RelevantMessagingState` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + // Storage: `XcmpQueue::OutboundXcmpStatus` (r:1 w:1) + // Proof: `XcmpQueue::OutboundXcmpStatus` (`max_values`: Some(1), `max_size`: Some(1282), added: 1777, mode: `MaxEncodedLen`) + // Storage: `XcmpQueue::OutboundXcmpMessages` (r:0 w:1) + // Proof: `XcmpQueue::OutboundXcmpMessages` (`max_values`: None, `max_size`: Some(105506), added: 107981, mode: `MaxEncodedLen`) + pub fn reserve_transfer_assets() -> Weight { + // Proof Size summary in bytes: + // Measured: `400` + // Estimated: `6196` + // Minimum execution time: 133_841_000 picoseconds. + Weight::from_parts(137_244_000, 6196) + .saturating_add(T::DbWeight::get().reads(10)) + .saturating_add(T::DbWeight::get().writes(5)) + } + // Storage: `ParachainInfo::ParachainId` (r:1 w:0) + // Proof: `ParachainInfo::ParachainId` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) + // Storage: `PolkadotXcm::ShouldRecordXcm` (r:1 w:0) + // Proof: `PolkadotXcm::ShouldRecordXcm` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + // Storage: `Assets::Asset` (r:1 w:1) + // Proof: `Assets::Asset` (`max_values`: None, `max_size`: Some(210), added: 2685, mode: `MaxEncodedLen`) + // Storage: `Assets::Account` (r:2 w:2) + // Proof: `Assets::Account` (`max_values`: None, `max_size`: Some(134), added: 2609, mode: `MaxEncodedLen`) + // Storage: `AssetsFreezer::FrozenBalances` (r:1 w:0) + // Proof: `AssetsFreezer::FrozenBalances` (`max_values`: None, `max_size`: Some(84), added: 2559, mode: `MaxEncodedLen`) + // Storage: `System::Account` (r:2 w:2) + // Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`) + // Storage: `ParachainSystem::UpwardDeliveryFeeFactor` (r:1 w:0) + // Proof: `ParachainSystem::UpwardDeliveryFeeFactor` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + // Storage: `PolkadotXcm::SupportedVersion` (r:1 w:0) + // Proof: `PolkadotXcm::SupportedVersion` (`max_values`: None, `max_size`: None, mode: `Measured`) + // Storage: `PolkadotXcm::VersionDiscoveryQueue` (r:1 w:1) + // Proof: `PolkadotXcm::VersionDiscoveryQueue` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + // Storage: `PolkadotXcm::SafeXcmVersion` (r:1 w:0) + // Proof: `PolkadotXcm::SafeXcmVersion` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + // Storage: `ParachainSystem::HostConfiguration` (r:1 w:0) + // Proof: `ParachainSystem::HostConfiguration` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + // Storage: `ParachainSystem::PendingUpwardMessages` (r:1 w:1) + // Proof: `ParachainSystem::PendingUpwardMessages` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + pub fn transfer_assets() -> Weight { + // Proof Size summary in bytes: + // Measured: `537` + // Estimated: `6208` + // Minimum execution time: 174_612_000 picoseconds. + Weight::from_parts(178_221_000, 6208) + .saturating_add(T::DbWeight::get().reads(14)) + .saturating_add(T::DbWeight::get().writes(7)) + } + // Storage: `PolkadotXcm::ShouldRecordXcm` (r:1 w:0) + // Proof: `PolkadotXcm::ShouldRecordXcm` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + pub fn execute() -> Weight { + // Proof Size summary in bytes: + // Measured: `103` + // Estimated: `1588` + // Minimum execution time: 13_537_000 picoseconds. + Weight::from_parts(14_041_000, 1588) + .saturating_add(T::DbWeight::get().reads(1)) + } + // Storage: `PolkadotXcm::SupportedVersion` (r:0 w:1) + // Proof: `PolkadotXcm::SupportedVersion` (`max_values`: None, `max_size`: None, mode: `Measured`) + pub fn force_xcm_version() -> Weight { + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 7_186_000 picoseconds. + Weight::from_parts(7_366_000, 0) + .saturating_add(T::DbWeight::get().writes(1)) + } + // Storage: `PolkadotXcm::SafeXcmVersion` (r:0 w:1) + // Proof: `PolkadotXcm::SafeXcmVersion` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + pub fn force_default_xcm_version() -> Weight { + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 2_358_000 picoseconds. + Weight::from_parts(2_459_000, 0) + .saturating_add(T::DbWeight::get().writes(1)) + } + // Storage: `PolkadotXcm::VersionNotifiers` (r:1 w:1) + // Proof: `PolkadotXcm::VersionNotifiers` (`max_values`: None, `max_size`: None, mode: `Measured`) + // Storage: `PolkadotXcm::QueryCounter` (r:1 w:1) + // Proof: `PolkadotXcm::QueryCounter` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + // Storage: `ParachainSystem::UpwardDeliveryFeeFactor` (r:1 w:0) + // Proof: `ParachainSystem::UpwardDeliveryFeeFactor` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + // Storage: `PolkadotXcm::SupportedVersion` (r:1 w:0) + // Proof: `PolkadotXcm::SupportedVersion` (`max_values`: None, `max_size`: None, mode: `Measured`) + // Storage: `PolkadotXcm::VersionDiscoveryQueue` (r:1 w:1) + // Proof: `PolkadotXcm::VersionDiscoveryQueue` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + // Storage: `PolkadotXcm::SafeXcmVersion` (r:1 w:0) + // Proof: `PolkadotXcm::SafeXcmVersion` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + // Storage: `ParachainSystem::HostConfiguration` (r:1 w:0) + // Proof: `ParachainSystem::HostConfiguration` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + // Storage: `ParachainSystem::PendingUpwardMessages` (r:1 w:1) + // Proof: `ParachainSystem::PendingUpwardMessages` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + // Storage: `PolkadotXcm::Queries` (r:0 w:1) + // Proof: `PolkadotXcm::Queries` (`max_values`: None, `max_size`: None, mode: `Measured`) + pub fn force_subscribe_version_notify() -> Weight { + // Proof Size summary in bytes: + // Measured: `145` + // Estimated: `3610` + // Minimum execution time: 34_134_000 picoseconds. + Weight::from_parts(35_407_000, 3610) + .saturating_add(T::DbWeight::get().reads(8)) + .saturating_add(T::DbWeight::get().writes(5)) + } + // Storage: `PolkadotXcm::VersionNotifiers` (r:1 w:1) + // Proof: `PolkadotXcm::VersionNotifiers` (`max_values`: None, `max_size`: None, mode: `Measured`) + // Storage: `ParachainSystem::UpwardDeliveryFeeFactor` (r:1 w:0) + // Proof: `ParachainSystem::UpwardDeliveryFeeFactor` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + // Storage: `PolkadotXcm::SupportedVersion` (r:1 w:0) + // Proof: `PolkadotXcm::SupportedVersion` (`max_values`: None, `max_size`: None, mode: `Measured`) + // Storage: `PolkadotXcm::VersionDiscoveryQueue` (r:1 w:1) + // Proof: `PolkadotXcm::VersionDiscoveryQueue` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + // Storage: `PolkadotXcm::SafeXcmVersion` (r:1 w:0) + // Proof: `PolkadotXcm::SafeXcmVersion` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + // Storage: `ParachainSystem::HostConfiguration` (r:1 w:0) + // Proof: `ParachainSystem::HostConfiguration` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + // Storage: `ParachainSystem::PendingUpwardMessages` (r:1 w:1) + // Proof: `ParachainSystem::PendingUpwardMessages` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + // Storage: `PolkadotXcm::Queries` (r:0 w:1) + // Proof: `PolkadotXcm::Queries` (`max_values`: None, `max_size`: None, mode: `Measured`) + pub fn force_unsubscribe_version_notify() -> Weight { + // Proof Size summary in bytes: + // Measured: `363` + // Estimated: `3828` + // Minimum execution time: 37_823_000 picoseconds. + Weight::from_parts(39_541_000, 3828) + .saturating_add(T::DbWeight::get().reads(7)) + .saturating_add(T::DbWeight::get().writes(4)) + } + // Storage: `PolkadotXcm::XcmExecutionSuspended` (r:0 w:1) + // Proof: `PolkadotXcm::XcmExecutionSuspended` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + pub fn force_suspension() -> Weight { + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 2_267_000 picoseconds. + Weight::from_parts(2_426_000, 0) + .saturating_add(T::DbWeight::get().writes(1)) + } + // Storage: `PolkadotXcm::SupportedVersion` (r:6 w:2) + // Proof: `PolkadotXcm::SupportedVersion` (`max_values`: None, `max_size`: None, mode: `Measured`) + pub fn migrate_supported_version() -> Weight { + // Proof Size summary in bytes: + // Measured: `159` + // Estimated: `15999` + // Minimum execution time: 25_999_000 picoseconds. + Weight::from_parts(26_384_000, 15999) + .saturating_add(T::DbWeight::get().reads(6)) + .saturating_add(T::DbWeight::get().writes(2)) + } + // Storage: `PolkadotXcm::VersionNotifiers` (r:6 w:2) + // Proof: `PolkadotXcm::VersionNotifiers` (`max_values`: None, `max_size`: None, mode: `Measured`) + pub fn migrate_version_notifiers() -> Weight { + // Proof Size summary in bytes: + // Measured: `163` + // Estimated: `16003` + // Minimum execution time: 25_468_000 picoseconds. + Weight::from_parts(25_872_000, 16003) + .saturating_add(T::DbWeight::get().reads(6)) + .saturating_add(T::DbWeight::get().writes(2)) + } + // Storage: `PolkadotXcm::VersionNotifyTargets` (r:7 w:0) + // Proof: `PolkadotXcm::VersionNotifyTargets` (`max_values`: None, `max_size`: None, mode: `Measured`) + pub fn already_notified_target() -> Weight { + // Proof Size summary in bytes: + // Measured: `173` + // Estimated: `18488` + // Minimum execution time: 28_828_000 picoseconds. + Weight::from_parts(29_442_000, 18488) + .saturating_add(T::DbWeight::get().reads(7)) + } + // Storage: `PolkadotXcm::VersionNotifyTargets` (r:2 w:1) + // Proof: `PolkadotXcm::VersionNotifyTargets` (`max_values`: None, `max_size`: None, mode: `Measured`) + // Storage: `ParachainSystem::UpwardDeliveryFeeFactor` (r:1 w:0) + // Proof: `ParachainSystem::UpwardDeliveryFeeFactor` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + // Storage: `PolkadotXcm::SupportedVersion` (r:1 w:0) + // Proof: `PolkadotXcm::SupportedVersion` (`max_values`: None, `max_size`: None, mode: `Measured`) + // Storage: `PolkadotXcm::VersionDiscoveryQueue` (r:1 w:1) + // Proof: `PolkadotXcm::VersionDiscoveryQueue` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + // Storage: `PolkadotXcm::SafeXcmVersion` (r:1 w:0) + // Proof: `PolkadotXcm::SafeXcmVersion` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + // Storage: `ParachainSystem::HostConfiguration` (r:1 w:0) + // Proof: `ParachainSystem::HostConfiguration` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + // Storage: `ParachainSystem::PendingUpwardMessages` (r:1 w:1) + // Proof: `ParachainSystem::PendingUpwardMessages` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + pub fn notify_current_targets() -> Weight { + // Proof Size summary in bytes: + // Measured: `212` + // Estimated: `6152` + // Minimum execution time: 32_950_000 picoseconds. + Weight::from_parts(34_114_000, 6152) + .saturating_add(T::DbWeight::get().reads(8)) + .saturating_add(T::DbWeight::get().writes(3)) + } + // Storage: `PolkadotXcm::VersionNotifyTargets` (r:5 w:0) + // Proof: `PolkadotXcm::VersionNotifyTargets` (`max_values`: None, `max_size`: None, mode: `Measured`) + pub fn notify_target_migration_fail() -> Weight { + // Proof Size summary in bytes: + // Measured: `176` + // Estimated: `13541` + // Minimum execution time: 18_210_000 picoseconds. + Weight::from_parts(18_770_000, 13541) + .saturating_add(T::DbWeight::get().reads(5)) + } + // Storage: `PolkadotXcm::VersionNotifyTargets` (r:6 w:2) + // Proof: `PolkadotXcm::VersionNotifyTargets` (`max_values`: None, `max_size`: None, mode: `Measured`) + pub fn migrate_version_notify_targets() -> Weight { + // Proof Size summary in bytes: + // Measured: `170` + // Estimated: `16010` + // Minimum execution time: 25_773_000 picoseconds. + Weight::from_parts(26_286_000, 16010) + .saturating_add(T::DbWeight::get().reads(6)) + .saturating_add(T::DbWeight::get().writes(2)) + } + // Storage: `PolkadotXcm::VersionNotifyTargets` (r:6 w:2) + // Proof: `PolkadotXcm::VersionNotifyTargets` (`max_values`: None, `max_size`: None, mode: `Measured`) + // Storage: `ParachainSystem::UpwardDeliveryFeeFactor` (r:1 w:0) + // Proof: `ParachainSystem::UpwardDeliveryFeeFactor` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + // Storage: `PolkadotXcm::SupportedVersion` (r:1 w:0) + // Proof: `PolkadotXcm::SupportedVersion` (`max_values`: None, `max_size`: None, mode: `Measured`) + // Storage: `PolkadotXcm::VersionDiscoveryQueue` (r:1 w:1) + // Proof: `PolkadotXcm::VersionDiscoveryQueue` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + // Storage: `PolkadotXcm::SafeXcmVersion` (r:1 w:0) + // Proof: `PolkadotXcm::SafeXcmVersion` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + // Storage: `ParachainSystem::HostConfiguration` (r:1 w:0) + // Proof: `ParachainSystem::HostConfiguration` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + // Storage: `ParachainSystem::PendingUpwardMessages` (r:1 w:1) + // Proof: `ParachainSystem::PendingUpwardMessages` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + pub fn migrate_and_notify_old_targets() -> Weight { + // Proof Size summary in bytes: + // Measured: `212` + // Estimated: `16052` + // Minimum execution time: 45_974_000 picoseconds. + Weight::from_parts(46_967_000, 16052) + .saturating_add(T::DbWeight::get().reads(12)) + .saturating_add(T::DbWeight::get().writes(4)) + } + // Storage: `PolkadotXcm::QueryCounter` (r:1 w:1) + // Proof: `PolkadotXcm::QueryCounter` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + // Storage: `PolkadotXcm::Queries` (r:0 w:1) + // Proof: `PolkadotXcm::Queries` (`max_values`: None, `max_size`: None, mode: `Measured`) + pub fn new_query() -> Weight { + // Proof Size summary in bytes: + // Measured: `103` + // Estimated: `1588` + // Minimum execution time: 7_076_000 picoseconds. + Weight::from_parts(7_318_000, 1588) + .saturating_add(T::DbWeight::get().reads(1)) + .saturating_add(T::DbWeight::get().writes(2)) + } + // Storage: `PolkadotXcm::Queries` (r:1 w:1) + // Proof: `PolkadotXcm::Queries` (`max_values`: None, `max_size`: None, mode: `Measured`) + pub fn take_response() -> Weight { + // Proof Size summary in bytes: + // Measured: `7740` + // Estimated: `11205` + // Minimum execution time: 30_736_000 picoseconds. + Weight::from_parts(31_187_000, 11205) + .saturating_add(T::DbWeight::get().reads(1)) + .saturating_add(T::DbWeight::get().writes(1)) + } + // Storage: `PolkadotXcm::ShouldRecordXcm` (r:1 w:0) + // Proof: `PolkadotXcm::ShouldRecordXcm` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + // Storage: `PolkadotXcm::AssetTraps` (r:1 w:1) + // Proof: `PolkadotXcm::AssetTraps` (`max_values`: None, `max_size`: None, mode: `Measured`) + pub fn claim_assets() -> Weight { + // Proof Size summary in bytes: + // Measured: `160` + // Estimated: `3625` + // Minimum execution time: 43_226_000 picoseconds. + Weight::from_parts(44_498_000, 3625) + .saturating_add(T::DbWeight::get().reads(2)) + .saturating_add(T::DbWeight::get().writes(1)) + } + // Storage: `PolkadotXcm::AuthorizedAliasesMap` (r:1 w:1) + // Proof: `PolkadotXcm::AuthorizedAliasesMap` (`max_values`: None, `max_size`: None, mode: `Measured`) + pub fn add_authorized_alias() -> Weight { + // Proof Size summary in bytes: + // Measured: `498` + // Estimated: `3963` + // Minimum execution time: 19_789_000 picoseconds. + Weight::from_parts(20_317_000, 3963) + .saturating_add(T::DbWeight::get().reads(1)) + .saturating_add(T::DbWeight::get().writes(1)) + } + // Storage: `PolkadotXcm::AuthorizedAliasesMap` (r:1 w:1) + // Proof: `PolkadotXcm::AuthorizedAliasesMap` (`max_values`: None, `max_size`: None, mode: `Measured`) + pub fn remove_authorized_alias() -> Weight { + // Proof Size summary in bytes: + // Measured: `537` + // Estimated: `4002` + // Minimum execution time: 20_805_000 picoseconds. + Weight::from_parts(21_481_000, 4002) + .saturating_add(T::DbWeight::get().reads(1)) + .saturating_add(T::DbWeight::get().writes(1)) + } +} From 70694ddbe609c82e0200db5d43cbfbc9cec2fbf2 Mon Sep 17 00:00:00 2001 From: Adrian Catangiu Date: Thu, 7 Nov 2024 16:17:35 +0200 Subject: [PATCH 14/40] fix benchmarks --- .../src/weights/pallet_xcm.rs | 20 +- .../src/weights/xcm/pallet_xcm.rs | 411 ------------------ .../src/weights/pallet_xcm.rs | 20 +- .../src/weights/xcm/pallet_xcm.rs | 411 ------------------ .../src/weights/pallet_xcm.rs | 20 +- .../src/weights/pallet_xcm.rs | 20 +- .../src/weights/pallet_xcm.rs | 20 +- .../coretime-rococo/src/weights/pallet_xcm.rs | 20 +- .../src/weights/pallet_xcm.rs | 20 +- .../people-rococo/src/weights/pallet_xcm.rs | 20 +- .../people-westend/src/weights/pallet_xcm.rs | 20 +- .../runtime/rococo/src/weights/pallet_xcm.rs | 36 +- .../rococo/src/weights/xcm/pallet_xcm.rs | 363 ---------------- .../runtime/westend/src/weights/pallet_xcm.rs | 36 +- .../westend/src/weights/xcm/pallet_xcm.rs | 363 ---------------- 15 files changed, 170 insertions(+), 1630 deletions(-) delete mode 100644 cumulus/parachains/runtimes/assets/asset-hub-rococo/src/weights/xcm/pallet_xcm.rs delete mode 100644 cumulus/parachains/runtimes/assets/asset-hub-westend/src/weights/xcm/pallet_xcm.rs delete mode 100644 polkadot/runtime/rococo/src/weights/xcm/pallet_xcm.rs delete mode 100644 polkadot/runtime/westend/src/weights/xcm/pallet_xcm.rs diff --git a/cumulus/parachains/runtimes/assets/asset-hub-rococo/src/weights/pallet_xcm.rs b/cumulus/parachains/runtimes/assets/asset-hub-rococo/src/weights/pallet_xcm.rs index ab4dd9af31ad..b39a4440f308 100644 --- a/cumulus/parachains/runtimes/assets/asset-hub-rococo/src/weights/pallet_xcm.rs +++ b/cumulus/parachains/runtimes/assets/asset-hub-rococo/src/weights/pallet_xcm.rs @@ -48,17 +48,25 @@ use core::marker::PhantomData; /// Weight functions for `pallet_xcm`. pub struct WeightInfo(PhantomData); impl pallet_xcm::WeightInfo for WeightInfo { + /// Storage: `PolkadotXcm::AuthorizedAliasesMap` (r:1 w:1) + /// Proof: `PolkadotXcm::AuthorizedAliasesMap` (`max_values`: None, `max_size`: None, mode: `Measured`) fn add_authorized_alias() -> Weight { - // TODO: benchmark - Weight::from_parts(3_724_000, 0) - .saturating_add(Weight::from_parts(0, 1517)) + // Proof Size summary in bytes: + // Measured: `498` + // Estimated: `3963` + // Minimum execution time: 19_789_000 picoseconds. + Weight::from_parts(20_317_000, 3963) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(1)) } + /// Storage: `PolkadotXcm::AuthorizedAliasesMap` (r:1 w:1) + /// Proof: `PolkadotXcm::AuthorizedAliasesMap` (`max_values`: None, `max_size`: None, mode: `Measured`) fn remove_authorized_alias() -> Weight { - // TODO: benchmark - Weight::from_parts(3_724_000, 0) - .saturating_add(Weight::from_parts(0, 1517)) + // Proof Size summary in bytes: + // Measured: `537` + // Estimated: `4002` + // Minimum execution time: 20_805_000 picoseconds. + Weight::from_parts(21_481_000, 4002) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(1)) } diff --git a/cumulus/parachains/runtimes/assets/asset-hub-rococo/src/weights/xcm/pallet_xcm.rs b/cumulus/parachains/runtimes/assets/asset-hub-rococo/src/weights/xcm/pallet_xcm.rs deleted file mode 100644 index d9ad8d67bcb1..000000000000 --- a/cumulus/parachains/runtimes/assets/asset-hub-rococo/src/weights/xcm/pallet_xcm.rs +++ /dev/null @@ -1,411 +0,0 @@ -// Copyright (C) Parity Technologies (UK) Ltd. -// This file is part of Cumulus. - -// Cumulus 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. - -// Cumulus 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 Cumulus. If not, see . - -//! Autogenerated weights for `pallet_xcm` -//! -//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 32.0.0 -//! DATE: 2024-11-07, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` -//! WORST CASE MAP SIZE: `1000000` -//! HOSTNAME: `runner-vcatxqpx-project-674-concurrent-0`, CPU: `Intel(R) Xeon(R) CPU @ 2.60GHz` -//! WASM-EXECUTION: Compiled, CHAIN: Some("asset-hub-rococo-dev"), DB CACHE: 1024 - -// Executed Command: -// target/production/polkadot-parachain -// benchmark -// pallet -// --steps=50 -// --repeat=20 -// --extrinsic=* -// --wasm-execution=compiled -// --heap-pages=4096 -// --json-file=/builds/parity/mirrors/polkadot-sdk/.git/.artifacts/bench.json -// --pallet=pallet_xcm -// --chain=asset-hub-rococo-dev -// --header=./cumulus/file_header.txt -// --template=./cumulus/templates/xcm-bench-template.hbs -// --output=./cumulus/parachains/runtimes/assets/asset-hub-rococo/src/weights/xcm/ - -#![cfg_attr(rustfmt, rustfmt_skip)] -#![allow(unused_parens)] -#![allow(unused_imports)] - -use frame_support::{traits::Get, weights::Weight}; -use core::marker::PhantomData; - -/// Weights for `pallet_xcm`. -pub struct WeightInfo(PhantomData); -impl WeightInfo { - // Storage: `ParachainSystem::UpwardDeliveryFeeFactor` (r:1 w:0) - // Proof: `ParachainSystem::UpwardDeliveryFeeFactor` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) - // Storage: `PolkadotXcm::SupportedVersion` (r:1 w:0) - // Proof: `PolkadotXcm::SupportedVersion` (`max_values`: None, `max_size`: None, mode: `Measured`) - // Storage: `PolkadotXcm::VersionDiscoveryQueue` (r:1 w:1) - // Proof: `PolkadotXcm::VersionDiscoveryQueue` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) - // Storage: `PolkadotXcm::SafeXcmVersion` (r:1 w:0) - // Proof: `PolkadotXcm::SafeXcmVersion` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) - // Storage: `ParachainSystem::HostConfiguration` (r:1 w:0) - // Proof: `ParachainSystem::HostConfiguration` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) - // Storage: `ParachainSystem::PendingUpwardMessages` (r:1 w:1) - // Proof: `ParachainSystem::PendingUpwardMessages` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) - pub fn send() -> Weight { - // Proof Size summary in bytes: - // Measured: `145` - // Estimated: `3610` - // Minimum execution time: 28_037_000 picoseconds. - Weight::from_parts(28_751_000, 3610) - .saturating_add(T::DbWeight::get().reads(6)) - .saturating_add(T::DbWeight::get().writes(2)) - } - // Storage: `ParachainInfo::ParachainId` (r:1 w:0) - // Proof: `ParachainInfo::ParachainId` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) - // Storage: `PolkadotXcm::ShouldRecordXcm` (r:1 w:0) - // Proof: `PolkadotXcm::ShouldRecordXcm` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) - // Storage: `ParachainSystem::UpwardDeliveryFeeFactor` (r:1 w:0) - // Proof: `ParachainSystem::UpwardDeliveryFeeFactor` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) - // Storage: `PolkadotXcm::SupportedVersion` (r:1 w:0) - // Proof: `PolkadotXcm::SupportedVersion` (`max_values`: None, `max_size`: None, mode: `Measured`) - // Storage: `PolkadotXcm::VersionDiscoveryQueue` (r:1 w:1) - // Proof: `PolkadotXcm::VersionDiscoveryQueue` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) - // Storage: `PolkadotXcm::SafeXcmVersion` (r:1 w:0) - // Proof: `PolkadotXcm::SafeXcmVersion` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) - // Storage: `System::Account` (r:1 w:1) - // Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`) - // Storage: `ParachainSystem::HostConfiguration` (r:1 w:0) - // Proof: `ParachainSystem::HostConfiguration` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) - // Storage: `ParachainSystem::PendingUpwardMessages` (r:1 w:1) - // Proof: `ParachainSystem::PendingUpwardMessages` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) - pub fn teleport_assets() -> Weight { - // Proof Size summary in bytes: - // Measured: `145` - // Estimated: `3610` - // Minimum execution time: 107_295_000 picoseconds. - Weight::from_parts(110_562_000, 3610) - .saturating_add(T::DbWeight::get().reads(9)) - .saturating_add(T::DbWeight::get().writes(3)) - } - // Storage: `ParachainInfo::ParachainId` (r:1 w:0) - // Proof: `ParachainInfo::ParachainId` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) - // Storage: `PolkadotXcm::ShouldRecordXcm` (r:1 w:0) - // Proof: `PolkadotXcm::ShouldRecordXcm` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) - // Storage: `System::Account` (r:2 w:2) - // Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`) - // Storage: `XcmpQueue::DeliveryFeeFactor` (r:1 w:0) - // Proof: `XcmpQueue::DeliveryFeeFactor` (`max_values`: None, `max_size`: Some(28), added: 2503, mode: `MaxEncodedLen`) - // Storage: `PolkadotXcm::SupportedVersion` (r:1 w:0) - // Proof: `PolkadotXcm::SupportedVersion` (`max_values`: None, `max_size`: None, mode: `Measured`) - // Storage: `PolkadotXcm::VersionDiscoveryQueue` (r:1 w:1) - // Proof: `PolkadotXcm::VersionDiscoveryQueue` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) - // Storage: `PolkadotXcm::SafeXcmVersion` (r:1 w:0) - // Proof: `PolkadotXcm::SafeXcmVersion` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) - // Storage: `ParachainSystem::RelevantMessagingState` (r:1 w:0) - // Proof: `ParachainSystem::RelevantMessagingState` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) - // Storage: `XcmpQueue::OutboundXcmpStatus` (r:1 w:1) - // Proof: `XcmpQueue::OutboundXcmpStatus` (`max_values`: Some(1), `max_size`: Some(1282), added: 1777, mode: `MaxEncodedLen`) - // Storage: `XcmpQueue::OutboundXcmpMessages` (r:0 w:1) - // Proof: `XcmpQueue::OutboundXcmpMessages` (`max_values`: None, `max_size`: Some(105506), added: 107981, mode: `MaxEncodedLen`) - pub fn reserve_transfer_assets() -> Weight { - // Proof Size summary in bytes: - // Measured: `400` - // Estimated: `6196` - // Minimum execution time: 133_841_000 picoseconds. - Weight::from_parts(137_244_000, 6196) - .saturating_add(T::DbWeight::get().reads(10)) - .saturating_add(T::DbWeight::get().writes(5)) - } - // Storage: `ParachainInfo::ParachainId` (r:1 w:0) - // Proof: `ParachainInfo::ParachainId` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) - // Storage: `PolkadotXcm::ShouldRecordXcm` (r:1 w:0) - // Proof: `PolkadotXcm::ShouldRecordXcm` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) - // Storage: `Assets::Asset` (r:1 w:1) - // Proof: `Assets::Asset` (`max_values`: None, `max_size`: Some(210), added: 2685, mode: `MaxEncodedLen`) - // Storage: `Assets::Account` (r:2 w:2) - // Proof: `Assets::Account` (`max_values`: None, `max_size`: Some(134), added: 2609, mode: `MaxEncodedLen`) - // Storage: `AssetsFreezer::FrozenBalances` (r:1 w:0) - // Proof: `AssetsFreezer::FrozenBalances` (`max_values`: None, `max_size`: Some(84), added: 2559, mode: `MaxEncodedLen`) - // Storage: `System::Account` (r:2 w:2) - // Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`) - // Storage: `ParachainSystem::UpwardDeliveryFeeFactor` (r:1 w:0) - // Proof: `ParachainSystem::UpwardDeliveryFeeFactor` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) - // Storage: `PolkadotXcm::SupportedVersion` (r:1 w:0) - // Proof: `PolkadotXcm::SupportedVersion` (`max_values`: None, `max_size`: None, mode: `Measured`) - // Storage: `PolkadotXcm::VersionDiscoveryQueue` (r:1 w:1) - // Proof: `PolkadotXcm::VersionDiscoveryQueue` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) - // Storage: `PolkadotXcm::SafeXcmVersion` (r:1 w:0) - // Proof: `PolkadotXcm::SafeXcmVersion` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) - // Storage: `ParachainSystem::HostConfiguration` (r:1 w:0) - // Proof: `ParachainSystem::HostConfiguration` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) - // Storage: `ParachainSystem::PendingUpwardMessages` (r:1 w:1) - // Proof: `ParachainSystem::PendingUpwardMessages` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) - pub fn transfer_assets() -> Weight { - // Proof Size summary in bytes: - // Measured: `537` - // Estimated: `6208` - // Minimum execution time: 174_612_000 picoseconds. - Weight::from_parts(178_221_000, 6208) - .saturating_add(T::DbWeight::get().reads(14)) - .saturating_add(T::DbWeight::get().writes(7)) - } - // Storage: `PolkadotXcm::ShouldRecordXcm` (r:1 w:0) - // Proof: `PolkadotXcm::ShouldRecordXcm` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) - pub fn execute() -> Weight { - // Proof Size summary in bytes: - // Measured: `103` - // Estimated: `1588` - // Minimum execution time: 13_537_000 picoseconds. - Weight::from_parts(14_041_000, 1588) - .saturating_add(T::DbWeight::get().reads(1)) - } - // Storage: `PolkadotXcm::SupportedVersion` (r:0 w:1) - // Proof: `PolkadotXcm::SupportedVersion` (`max_values`: None, `max_size`: None, mode: `Measured`) - pub fn force_xcm_version() -> Weight { - // Proof Size summary in bytes: - // Measured: `0` - // Estimated: `0` - // Minimum execution time: 7_186_000 picoseconds. - Weight::from_parts(7_366_000, 0) - .saturating_add(T::DbWeight::get().writes(1)) - } - // Storage: `PolkadotXcm::SafeXcmVersion` (r:0 w:1) - // Proof: `PolkadotXcm::SafeXcmVersion` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) - pub fn force_default_xcm_version() -> Weight { - // Proof Size summary in bytes: - // Measured: `0` - // Estimated: `0` - // Minimum execution time: 2_358_000 picoseconds. - Weight::from_parts(2_459_000, 0) - .saturating_add(T::DbWeight::get().writes(1)) - } - // Storage: `PolkadotXcm::VersionNotifiers` (r:1 w:1) - // Proof: `PolkadotXcm::VersionNotifiers` (`max_values`: None, `max_size`: None, mode: `Measured`) - // Storage: `PolkadotXcm::QueryCounter` (r:1 w:1) - // Proof: `PolkadotXcm::QueryCounter` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) - // Storage: `ParachainSystem::UpwardDeliveryFeeFactor` (r:1 w:0) - // Proof: `ParachainSystem::UpwardDeliveryFeeFactor` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) - // Storage: `PolkadotXcm::SupportedVersion` (r:1 w:0) - // Proof: `PolkadotXcm::SupportedVersion` (`max_values`: None, `max_size`: None, mode: `Measured`) - // Storage: `PolkadotXcm::VersionDiscoveryQueue` (r:1 w:1) - // Proof: `PolkadotXcm::VersionDiscoveryQueue` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) - // Storage: `PolkadotXcm::SafeXcmVersion` (r:1 w:0) - // Proof: `PolkadotXcm::SafeXcmVersion` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) - // Storage: `ParachainSystem::HostConfiguration` (r:1 w:0) - // Proof: `ParachainSystem::HostConfiguration` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) - // Storage: `ParachainSystem::PendingUpwardMessages` (r:1 w:1) - // Proof: `ParachainSystem::PendingUpwardMessages` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) - // Storage: `PolkadotXcm::Queries` (r:0 w:1) - // Proof: `PolkadotXcm::Queries` (`max_values`: None, `max_size`: None, mode: `Measured`) - pub fn force_subscribe_version_notify() -> Weight { - // Proof Size summary in bytes: - // Measured: `145` - // Estimated: `3610` - // Minimum execution time: 34_134_000 picoseconds. - Weight::from_parts(35_407_000, 3610) - .saturating_add(T::DbWeight::get().reads(8)) - .saturating_add(T::DbWeight::get().writes(5)) - } - // Storage: `PolkadotXcm::VersionNotifiers` (r:1 w:1) - // Proof: `PolkadotXcm::VersionNotifiers` (`max_values`: None, `max_size`: None, mode: `Measured`) - // Storage: `ParachainSystem::UpwardDeliveryFeeFactor` (r:1 w:0) - // Proof: `ParachainSystem::UpwardDeliveryFeeFactor` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) - // Storage: `PolkadotXcm::SupportedVersion` (r:1 w:0) - // Proof: `PolkadotXcm::SupportedVersion` (`max_values`: None, `max_size`: None, mode: `Measured`) - // Storage: `PolkadotXcm::VersionDiscoveryQueue` (r:1 w:1) - // Proof: `PolkadotXcm::VersionDiscoveryQueue` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) - // Storage: `PolkadotXcm::SafeXcmVersion` (r:1 w:0) - // Proof: `PolkadotXcm::SafeXcmVersion` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) - // Storage: `ParachainSystem::HostConfiguration` (r:1 w:0) - // Proof: `ParachainSystem::HostConfiguration` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) - // Storage: `ParachainSystem::PendingUpwardMessages` (r:1 w:1) - // Proof: `ParachainSystem::PendingUpwardMessages` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) - // Storage: `PolkadotXcm::Queries` (r:0 w:1) - // Proof: `PolkadotXcm::Queries` (`max_values`: None, `max_size`: None, mode: `Measured`) - pub fn force_unsubscribe_version_notify() -> Weight { - // Proof Size summary in bytes: - // Measured: `363` - // Estimated: `3828` - // Minimum execution time: 37_823_000 picoseconds. - Weight::from_parts(39_541_000, 3828) - .saturating_add(T::DbWeight::get().reads(7)) - .saturating_add(T::DbWeight::get().writes(4)) - } - // Storage: `PolkadotXcm::XcmExecutionSuspended` (r:0 w:1) - // Proof: `PolkadotXcm::XcmExecutionSuspended` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) - pub fn force_suspension() -> Weight { - // Proof Size summary in bytes: - // Measured: `0` - // Estimated: `0` - // Minimum execution time: 2_267_000 picoseconds. - Weight::from_parts(2_426_000, 0) - .saturating_add(T::DbWeight::get().writes(1)) - } - // Storage: `PolkadotXcm::SupportedVersion` (r:6 w:2) - // Proof: `PolkadotXcm::SupportedVersion` (`max_values`: None, `max_size`: None, mode: `Measured`) - pub fn migrate_supported_version() -> Weight { - // Proof Size summary in bytes: - // Measured: `159` - // Estimated: `15999` - // Minimum execution time: 25_999_000 picoseconds. - Weight::from_parts(26_384_000, 15999) - .saturating_add(T::DbWeight::get().reads(6)) - .saturating_add(T::DbWeight::get().writes(2)) - } - // Storage: `PolkadotXcm::VersionNotifiers` (r:6 w:2) - // Proof: `PolkadotXcm::VersionNotifiers` (`max_values`: None, `max_size`: None, mode: `Measured`) - pub fn migrate_version_notifiers() -> Weight { - // Proof Size summary in bytes: - // Measured: `163` - // Estimated: `16003` - // Minimum execution time: 25_468_000 picoseconds. - Weight::from_parts(25_872_000, 16003) - .saturating_add(T::DbWeight::get().reads(6)) - .saturating_add(T::DbWeight::get().writes(2)) - } - // Storage: `PolkadotXcm::VersionNotifyTargets` (r:7 w:0) - // Proof: `PolkadotXcm::VersionNotifyTargets` (`max_values`: None, `max_size`: None, mode: `Measured`) - pub fn already_notified_target() -> Weight { - // Proof Size summary in bytes: - // Measured: `173` - // Estimated: `18488` - // Minimum execution time: 28_828_000 picoseconds. - Weight::from_parts(29_442_000, 18488) - .saturating_add(T::DbWeight::get().reads(7)) - } - // Storage: `PolkadotXcm::VersionNotifyTargets` (r:2 w:1) - // Proof: `PolkadotXcm::VersionNotifyTargets` (`max_values`: None, `max_size`: None, mode: `Measured`) - // Storage: `ParachainSystem::UpwardDeliveryFeeFactor` (r:1 w:0) - // Proof: `ParachainSystem::UpwardDeliveryFeeFactor` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) - // Storage: `PolkadotXcm::SupportedVersion` (r:1 w:0) - // Proof: `PolkadotXcm::SupportedVersion` (`max_values`: None, `max_size`: None, mode: `Measured`) - // Storage: `PolkadotXcm::VersionDiscoveryQueue` (r:1 w:1) - // Proof: `PolkadotXcm::VersionDiscoveryQueue` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) - // Storage: `PolkadotXcm::SafeXcmVersion` (r:1 w:0) - // Proof: `PolkadotXcm::SafeXcmVersion` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) - // Storage: `ParachainSystem::HostConfiguration` (r:1 w:0) - // Proof: `ParachainSystem::HostConfiguration` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) - // Storage: `ParachainSystem::PendingUpwardMessages` (r:1 w:1) - // Proof: `ParachainSystem::PendingUpwardMessages` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) - pub fn notify_current_targets() -> Weight { - // Proof Size summary in bytes: - // Measured: `212` - // Estimated: `6152` - // Minimum execution time: 32_950_000 picoseconds. - Weight::from_parts(34_114_000, 6152) - .saturating_add(T::DbWeight::get().reads(8)) - .saturating_add(T::DbWeight::get().writes(3)) - } - // Storage: `PolkadotXcm::VersionNotifyTargets` (r:5 w:0) - // Proof: `PolkadotXcm::VersionNotifyTargets` (`max_values`: None, `max_size`: None, mode: `Measured`) - pub fn notify_target_migration_fail() -> Weight { - // Proof Size summary in bytes: - // Measured: `176` - // Estimated: `13541` - // Minimum execution time: 18_210_000 picoseconds. - Weight::from_parts(18_770_000, 13541) - .saturating_add(T::DbWeight::get().reads(5)) - } - // Storage: `PolkadotXcm::VersionNotifyTargets` (r:6 w:2) - // Proof: `PolkadotXcm::VersionNotifyTargets` (`max_values`: None, `max_size`: None, mode: `Measured`) - pub fn migrate_version_notify_targets() -> Weight { - // Proof Size summary in bytes: - // Measured: `170` - // Estimated: `16010` - // Minimum execution time: 25_773_000 picoseconds. - Weight::from_parts(26_286_000, 16010) - .saturating_add(T::DbWeight::get().reads(6)) - .saturating_add(T::DbWeight::get().writes(2)) - } - // Storage: `PolkadotXcm::VersionNotifyTargets` (r:6 w:2) - // Proof: `PolkadotXcm::VersionNotifyTargets` (`max_values`: None, `max_size`: None, mode: `Measured`) - // Storage: `ParachainSystem::UpwardDeliveryFeeFactor` (r:1 w:0) - // Proof: `ParachainSystem::UpwardDeliveryFeeFactor` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) - // Storage: `PolkadotXcm::SupportedVersion` (r:1 w:0) - // Proof: `PolkadotXcm::SupportedVersion` (`max_values`: None, `max_size`: None, mode: `Measured`) - // Storage: `PolkadotXcm::VersionDiscoveryQueue` (r:1 w:1) - // Proof: `PolkadotXcm::VersionDiscoveryQueue` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) - // Storage: `PolkadotXcm::SafeXcmVersion` (r:1 w:0) - // Proof: `PolkadotXcm::SafeXcmVersion` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) - // Storage: `ParachainSystem::HostConfiguration` (r:1 w:0) - // Proof: `ParachainSystem::HostConfiguration` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) - // Storage: `ParachainSystem::PendingUpwardMessages` (r:1 w:1) - // Proof: `ParachainSystem::PendingUpwardMessages` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) - pub fn migrate_and_notify_old_targets() -> Weight { - // Proof Size summary in bytes: - // Measured: `212` - // Estimated: `16052` - // Minimum execution time: 45_974_000 picoseconds. - Weight::from_parts(46_967_000, 16052) - .saturating_add(T::DbWeight::get().reads(12)) - .saturating_add(T::DbWeight::get().writes(4)) - } - // Storage: `PolkadotXcm::QueryCounter` (r:1 w:1) - // Proof: `PolkadotXcm::QueryCounter` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) - // Storage: `PolkadotXcm::Queries` (r:0 w:1) - // Proof: `PolkadotXcm::Queries` (`max_values`: None, `max_size`: None, mode: `Measured`) - pub fn new_query() -> Weight { - // Proof Size summary in bytes: - // Measured: `103` - // Estimated: `1588` - // Minimum execution time: 7_076_000 picoseconds. - Weight::from_parts(7_318_000, 1588) - .saturating_add(T::DbWeight::get().reads(1)) - .saturating_add(T::DbWeight::get().writes(2)) - } - // Storage: `PolkadotXcm::Queries` (r:1 w:1) - // Proof: `PolkadotXcm::Queries` (`max_values`: None, `max_size`: None, mode: `Measured`) - pub fn take_response() -> Weight { - // Proof Size summary in bytes: - // Measured: `7740` - // Estimated: `11205` - // Minimum execution time: 30_736_000 picoseconds. - Weight::from_parts(31_187_000, 11205) - .saturating_add(T::DbWeight::get().reads(1)) - .saturating_add(T::DbWeight::get().writes(1)) - } - // Storage: `PolkadotXcm::ShouldRecordXcm` (r:1 w:0) - // Proof: `PolkadotXcm::ShouldRecordXcm` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) - // Storage: `PolkadotXcm::AssetTraps` (r:1 w:1) - // Proof: `PolkadotXcm::AssetTraps` (`max_values`: None, `max_size`: None, mode: `Measured`) - pub fn claim_assets() -> Weight { - // Proof Size summary in bytes: - // Measured: `160` - // Estimated: `3625` - // Minimum execution time: 43_226_000 picoseconds. - Weight::from_parts(44_498_000, 3625) - .saturating_add(T::DbWeight::get().reads(2)) - .saturating_add(T::DbWeight::get().writes(1)) - } - // Storage: `PolkadotXcm::AuthorizedAliasesMap` (r:1 w:1) - // Proof: `PolkadotXcm::AuthorizedAliasesMap` (`max_values`: None, `max_size`: None, mode: `Measured`) - pub fn add_authorized_alias() -> Weight { - // Proof Size summary in bytes: - // Measured: `498` - // Estimated: `3963` - // Minimum execution time: 19_789_000 picoseconds. - Weight::from_parts(20_317_000, 3963) - .saturating_add(T::DbWeight::get().reads(1)) - .saturating_add(T::DbWeight::get().writes(1)) - } - // Storage: `PolkadotXcm::AuthorizedAliasesMap` (r:1 w:1) - // Proof: `PolkadotXcm::AuthorizedAliasesMap` (`max_values`: None, `max_size`: None, mode: `Measured`) - pub fn remove_authorized_alias() -> Weight { - // Proof Size summary in bytes: - // Measured: `537` - // Estimated: `4002` - // Minimum execution time: 20_805_000 picoseconds. - Weight::from_parts(21_481_000, 4002) - .saturating_add(T::DbWeight::get().reads(1)) - .saturating_add(T::DbWeight::get().writes(1)) - } -} diff --git a/cumulus/parachains/runtimes/assets/asset-hub-westend/src/weights/pallet_xcm.rs b/cumulus/parachains/runtimes/assets/asset-hub-westend/src/weights/pallet_xcm.rs index 0c0c08077dab..d10a348abcdf 100644 --- a/cumulus/parachains/runtimes/assets/asset-hub-westend/src/weights/pallet_xcm.rs +++ b/cumulus/parachains/runtimes/assets/asset-hub-westend/src/weights/pallet_xcm.rs @@ -48,17 +48,25 @@ use core::marker::PhantomData; /// Weight functions for `pallet_xcm`. pub struct WeightInfo(PhantomData); impl pallet_xcm::WeightInfo for WeightInfo { + /// Storage: `PolkadotXcm::AuthorizedAliasesMap` (r:1 w:1) + /// Proof: `PolkadotXcm::AuthorizedAliasesMap` (`max_values`: None, `max_size`: None, mode: `Measured`) fn add_authorized_alias() -> Weight { - // TODO: benchmark - Weight::from_parts(3_724_000, 0) - .saturating_add(Weight::from_parts(0, 1517)) + // Proof Size summary in bytes: + // Measured: `498` + // Estimated: `3963` + // Minimum execution time: 19_789_000 picoseconds. + Weight::from_parts(20_317_000, 3963) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(1)) } + /// Storage: `PolkadotXcm::AuthorizedAliasesMap` (r:1 w:1) + /// Proof: `PolkadotXcm::AuthorizedAliasesMap` (`max_values`: None, `max_size`: None, mode: `Measured`) fn remove_authorized_alias() -> Weight { - // TODO: benchmark - Weight::from_parts(3_724_000, 0) - .saturating_add(Weight::from_parts(0, 1517)) + // Proof Size summary in bytes: + // Measured: `537` + // Estimated: `4002` + // Minimum execution time: 20_805_000 picoseconds. + Weight::from_parts(21_481_000, 4002) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(1)) } diff --git a/cumulus/parachains/runtimes/assets/asset-hub-westend/src/weights/xcm/pallet_xcm.rs b/cumulus/parachains/runtimes/assets/asset-hub-westend/src/weights/xcm/pallet_xcm.rs deleted file mode 100644 index 1bf29cae6509..000000000000 --- a/cumulus/parachains/runtimes/assets/asset-hub-westend/src/weights/xcm/pallet_xcm.rs +++ /dev/null @@ -1,411 +0,0 @@ -// Copyright (C) Parity Technologies (UK) Ltd. -// This file is part of Cumulus. - -// Cumulus 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. - -// Cumulus 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 Cumulus. If not, see . - -//! Autogenerated weights for `pallet_xcm` -//! -//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 32.0.0 -//! DATE: 2024-11-07, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` -//! WORST CASE MAP SIZE: `1000000` -//! HOSTNAME: `runner-vcatxqpx-project-674-concurrent-0`, CPU: `Intel(R) Xeon(R) CPU @ 2.60GHz` -//! WASM-EXECUTION: Compiled, CHAIN: Some("asset-hub-westend-dev"), DB CACHE: 1024 - -// Executed Command: -// target/production/polkadot-parachain -// benchmark -// pallet -// --steps=50 -// --repeat=20 -// --extrinsic=* -// --wasm-execution=compiled -// --heap-pages=4096 -// --json-file=/builds/parity/mirrors/polkadot-sdk/.git/.artifacts/bench.json -// --pallet=pallet_xcm -// --chain=asset-hub-westend-dev -// --header=./cumulus/file_header.txt -// --template=./cumulus/templates/xcm-bench-template.hbs -// --output=./cumulus/parachains/runtimes/assets/asset-hub-westend/src/weights/xcm/ - -#![cfg_attr(rustfmt, rustfmt_skip)] -#![allow(unused_parens)] -#![allow(unused_imports)] - -use frame_support::{traits::Get, weights::Weight}; -use core::marker::PhantomData; - -/// Weights for `pallet_xcm`. -pub struct WeightInfo(PhantomData); -impl WeightInfo { - // Storage: `ParachainSystem::UpwardDeliveryFeeFactor` (r:1 w:0) - // Proof: `ParachainSystem::UpwardDeliveryFeeFactor` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) - // Storage: `PolkadotXcm::SupportedVersion` (r:1 w:0) - // Proof: `PolkadotXcm::SupportedVersion` (`max_values`: None, `max_size`: None, mode: `Measured`) - // Storage: `PolkadotXcm::VersionDiscoveryQueue` (r:1 w:1) - // Proof: `PolkadotXcm::VersionDiscoveryQueue` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) - // Storage: `PolkadotXcm::SafeXcmVersion` (r:1 w:0) - // Proof: `PolkadotXcm::SafeXcmVersion` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) - // Storage: `ParachainSystem::HostConfiguration` (r:1 w:0) - // Proof: `ParachainSystem::HostConfiguration` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) - // Storage: `ParachainSystem::PendingUpwardMessages` (r:1 w:1) - // Proof: `ParachainSystem::PendingUpwardMessages` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) - pub fn send() -> Weight { - // Proof Size summary in bytes: - // Measured: `145` - // Estimated: `3610` - // Minimum execution time: 27_966_000 picoseconds. - Weight::from_parts(28_529_000, 3610) - .saturating_add(T::DbWeight::get().reads(6)) - .saturating_add(T::DbWeight::get().writes(2)) - } - // Storage: `ParachainInfo::ParachainId` (r:1 w:0) - // Proof: `ParachainInfo::ParachainId` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) - // Storage: `PolkadotXcm::ShouldRecordXcm` (r:1 w:0) - // Proof: `PolkadotXcm::ShouldRecordXcm` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) - // Storage: `ParachainSystem::UpwardDeliveryFeeFactor` (r:1 w:0) - // Proof: `ParachainSystem::UpwardDeliveryFeeFactor` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) - // Storage: `PolkadotXcm::SupportedVersion` (r:1 w:0) - // Proof: `PolkadotXcm::SupportedVersion` (`max_values`: None, `max_size`: None, mode: `Measured`) - // Storage: `PolkadotXcm::VersionDiscoveryQueue` (r:1 w:1) - // Proof: `PolkadotXcm::VersionDiscoveryQueue` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) - // Storage: `PolkadotXcm::SafeXcmVersion` (r:1 w:0) - // Proof: `PolkadotXcm::SafeXcmVersion` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) - // Storage: `System::Account` (r:1 w:1) - // Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`) - // Storage: `ParachainSystem::HostConfiguration` (r:1 w:0) - // Proof: `ParachainSystem::HostConfiguration` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) - // Storage: `ParachainSystem::PendingUpwardMessages` (r:1 w:1) - // Proof: `ParachainSystem::PendingUpwardMessages` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) - pub fn teleport_assets() -> Weight { - // Proof Size summary in bytes: - // Measured: `145` - // Estimated: `3610` - // Minimum execution time: 111_910_000 picoseconds. - Weight::from_parts(114_432_000, 3610) - .saturating_add(T::DbWeight::get().reads(9)) - .saturating_add(T::DbWeight::get().writes(3)) - } - // Storage: `ParachainInfo::ParachainId` (r:1 w:0) - // Proof: `ParachainInfo::ParachainId` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) - // Storage: `PolkadotXcm::ShouldRecordXcm` (r:1 w:0) - // Proof: `PolkadotXcm::ShouldRecordXcm` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) - // Storage: `System::Account` (r:2 w:2) - // Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`) - // Storage: `XcmpQueue::DeliveryFeeFactor` (r:1 w:0) - // Proof: `XcmpQueue::DeliveryFeeFactor` (`max_values`: None, `max_size`: Some(28), added: 2503, mode: `MaxEncodedLen`) - // Storage: `PolkadotXcm::SupportedVersion` (r:1 w:0) - // Proof: `PolkadotXcm::SupportedVersion` (`max_values`: None, `max_size`: None, mode: `Measured`) - // Storage: `PolkadotXcm::VersionDiscoveryQueue` (r:1 w:1) - // Proof: `PolkadotXcm::VersionDiscoveryQueue` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) - // Storage: `PolkadotXcm::SafeXcmVersion` (r:1 w:0) - // Proof: `PolkadotXcm::SafeXcmVersion` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) - // Storage: `ParachainSystem::RelevantMessagingState` (r:1 w:0) - // Proof: `ParachainSystem::RelevantMessagingState` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) - // Storage: `XcmpQueue::OutboundXcmpStatus` (r:1 w:1) - // Proof: `XcmpQueue::OutboundXcmpStatus` (`max_values`: Some(1), `max_size`: Some(1282), added: 1777, mode: `MaxEncodedLen`) - // Storage: `XcmpQueue::OutboundXcmpMessages` (r:0 w:1) - // Proof: `XcmpQueue::OutboundXcmpMessages` (`max_values`: None, `max_size`: Some(105506), added: 107981, mode: `MaxEncodedLen`) - pub fn reserve_transfer_assets() -> Weight { - // Proof Size summary in bytes: - // Measured: `400` - // Estimated: `6196` - // Minimum execution time: 136_886_000 picoseconds. - Weight::from_parts(141_399_000, 6196) - .saturating_add(T::DbWeight::get().reads(10)) - .saturating_add(T::DbWeight::get().writes(5)) - } - // Storage: `ParachainInfo::ParachainId` (r:1 w:0) - // Proof: `ParachainInfo::ParachainId` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) - // Storage: `PolkadotXcm::ShouldRecordXcm` (r:1 w:0) - // Proof: `PolkadotXcm::ShouldRecordXcm` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) - // Storage: `Assets::Asset` (r:1 w:1) - // Proof: `Assets::Asset` (`max_values`: None, `max_size`: Some(210), added: 2685, mode: `MaxEncodedLen`) - // Storage: `Assets::Account` (r:2 w:2) - // Proof: `Assets::Account` (`max_values`: None, `max_size`: Some(134), added: 2609, mode: `MaxEncodedLen`) - // Storage: `AssetsFreezer::FrozenBalances` (r:1 w:0) - // Proof: `AssetsFreezer::FrozenBalances` (`max_values`: None, `max_size`: Some(84), added: 2559, mode: `MaxEncodedLen`) - // Storage: `System::Account` (r:2 w:2) - // Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`) - // Storage: `ParachainSystem::UpwardDeliveryFeeFactor` (r:1 w:0) - // Proof: `ParachainSystem::UpwardDeliveryFeeFactor` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) - // Storage: `PolkadotXcm::SupportedVersion` (r:1 w:0) - // Proof: `PolkadotXcm::SupportedVersion` (`max_values`: None, `max_size`: None, mode: `Measured`) - // Storage: `PolkadotXcm::VersionDiscoveryQueue` (r:1 w:1) - // Proof: `PolkadotXcm::VersionDiscoveryQueue` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) - // Storage: `PolkadotXcm::SafeXcmVersion` (r:1 w:0) - // Proof: `PolkadotXcm::SafeXcmVersion` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) - // Storage: `ParachainSystem::HostConfiguration` (r:1 w:0) - // Proof: `ParachainSystem::HostConfiguration` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) - // Storage: `ParachainSystem::PendingUpwardMessages` (r:1 w:1) - // Proof: `ParachainSystem::PendingUpwardMessages` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) - pub fn transfer_assets() -> Weight { - // Proof Size summary in bytes: - // Measured: `571` - // Estimated: `6208` - // Minimum execution time: 176_288_000 picoseconds. - Weight::from_parts(184_999_000, 6208) - .saturating_add(T::DbWeight::get().reads(14)) - .saturating_add(T::DbWeight::get().writes(7)) - } - // Storage: `PolkadotXcm::ShouldRecordXcm` (r:1 w:0) - // Proof: `PolkadotXcm::ShouldRecordXcm` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) - pub fn execute() -> Weight { - // Proof Size summary in bytes: - // Measured: `103` - // Estimated: `1588` - // Minimum execution time: 12_420_000 picoseconds. - Weight::from_parts(12_882_000, 1588) - .saturating_add(T::DbWeight::get().reads(1)) - } - // Storage: `PolkadotXcm::SupportedVersion` (r:0 w:1) - // Proof: `PolkadotXcm::SupportedVersion` (`max_values`: None, `max_size`: None, mode: `Measured`) - pub fn force_xcm_version() -> Weight { - // Proof Size summary in bytes: - // Measured: `0` - // Estimated: `0` - // Minimum execution time: 6_994_000 picoseconds. - Weight::from_parts(7_196_000, 0) - .saturating_add(T::DbWeight::get().writes(1)) - } - // Storage: `PolkadotXcm::SafeXcmVersion` (r:0 w:1) - // Proof: `PolkadotXcm::SafeXcmVersion` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) - pub fn force_default_xcm_version() -> Weight { - // Proof Size summary in bytes: - // Measured: `0` - // Estimated: `0` - // Minimum execution time: 2_216_000 picoseconds. - Weight::from_parts(2_352_000, 0) - .saturating_add(T::DbWeight::get().writes(1)) - } - // Storage: `PolkadotXcm::VersionNotifiers` (r:1 w:1) - // Proof: `PolkadotXcm::VersionNotifiers` (`max_values`: None, `max_size`: None, mode: `Measured`) - // Storage: `PolkadotXcm::QueryCounter` (r:1 w:1) - // Proof: `PolkadotXcm::QueryCounter` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) - // Storage: `ParachainSystem::UpwardDeliveryFeeFactor` (r:1 w:0) - // Proof: `ParachainSystem::UpwardDeliveryFeeFactor` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) - // Storage: `PolkadotXcm::SupportedVersion` (r:1 w:0) - // Proof: `PolkadotXcm::SupportedVersion` (`max_values`: None, `max_size`: None, mode: `Measured`) - // Storage: `PolkadotXcm::VersionDiscoveryQueue` (r:1 w:1) - // Proof: `PolkadotXcm::VersionDiscoveryQueue` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) - // Storage: `PolkadotXcm::SafeXcmVersion` (r:1 w:0) - // Proof: `PolkadotXcm::SafeXcmVersion` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) - // Storage: `ParachainSystem::HostConfiguration` (r:1 w:0) - // Proof: `ParachainSystem::HostConfiguration` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) - // Storage: `ParachainSystem::PendingUpwardMessages` (r:1 w:1) - // Proof: `ParachainSystem::PendingUpwardMessages` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) - // Storage: `PolkadotXcm::Queries` (r:0 w:1) - // Proof: `PolkadotXcm::Queries` (`max_values`: None, `max_size`: None, mode: `Measured`) - pub fn force_subscribe_version_notify() -> Weight { - // Proof Size summary in bytes: - // Measured: `145` - // Estimated: `3610` - // Minimum execution time: 34_493_000 picoseconds. - Weight::from_parts(35_689_000, 3610) - .saturating_add(T::DbWeight::get().reads(8)) - .saturating_add(T::DbWeight::get().writes(5)) - } - // Storage: `PolkadotXcm::VersionNotifiers` (r:1 w:1) - // Proof: `PolkadotXcm::VersionNotifiers` (`max_values`: None, `max_size`: None, mode: `Measured`) - // Storage: `ParachainSystem::UpwardDeliveryFeeFactor` (r:1 w:0) - // Proof: `ParachainSystem::UpwardDeliveryFeeFactor` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) - // Storage: `PolkadotXcm::SupportedVersion` (r:1 w:0) - // Proof: `PolkadotXcm::SupportedVersion` (`max_values`: None, `max_size`: None, mode: `Measured`) - // Storage: `PolkadotXcm::VersionDiscoveryQueue` (r:1 w:1) - // Proof: `PolkadotXcm::VersionDiscoveryQueue` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) - // Storage: `PolkadotXcm::SafeXcmVersion` (r:1 w:0) - // Proof: `PolkadotXcm::SafeXcmVersion` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) - // Storage: `ParachainSystem::HostConfiguration` (r:1 w:0) - // Proof: `ParachainSystem::HostConfiguration` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) - // Storage: `ParachainSystem::PendingUpwardMessages` (r:1 w:1) - // Proof: `ParachainSystem::PendingUpwardMessages` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) - // Storage: `PolkadotXcm::Queries` (r:0 w:1) - // Proof: `PolkadotXcm::Queries` (`max_values`: None, `max_size`: None, mode: `Measured`) - pub fn force_unsubscribe_version_notify() -> Weight { - // Proof Size summary in bytes: - // Measured: `363` - // Estimated: `3828` - // Minimum execution time: 38_104_000 picoseconds. - Weight::from_parts(39_185_000, 3828) - .saturating_add(T::DbWeight::get().reads(7)) - .saturating_add(T::DbWeight::get().writes(4)) - } - // Storage: `PolkadotXcm::XcmExecutionSuspended` (r:0 w:1) - // Proof: `PolkadotXcm::XcmExecutionSuspended` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) - pub fn force_suspension() -> Weight { - // Proof Size summary in bytes: - // Measured: `0` - // Estimated: `0` - // Minimum execution time: 2_303_000 picoseconds. - Weight::from_parts(2_445_000, 0) - .saturating_add(T::DbWeight::get().writes(1)) - } - // Storage: `PolkadotXcm::SupportedVersion` (r:6 w:2) - // Proof: `PolkadotXcm::SupportedVersion` (`max_values`: None, `max_size`: None, mode: `Measured`) - pub fn migrate_supported_version() -> Weight { - // Proof Size summary in bytes: - // Measured: `159` - // Estimated: `15999` - // Minimum execution time: 25_339_000 picoseconds. - Weight::from_parts(25_983_000, 15999) - .saturating_add(T::DbWeight::get().reads(6)) - .saturating_add(T::DbWeight::get().writes(2)) - } - // Storage: `PolkadotXcm::VersionNotifiers` (r:6 w:2) - // Proof: `PolkadotXcm::VersionNotifiers` (`max_values`: None, `max_size`: None, mode: `Measured`) - pub fn migrate_version_notifiers() -> Weight { - // Proof Size summary in bytes: - // Measured: `163` - // Estimated: `16003` - // Minimum execution time: 25_010_000 picoseconds. - Weight::from_parts(25_742_000, 16003) - .saturating_add(T::DbWeight::get().reads(6)) - .saturating_add(T::DbWeight::get().writes(2)) - } - // Storage: `PolkadotXcm::VersionNotifyTargets` (r:7 w:0) - // Proof: `PolkadotXcm::VersionNotifyTargets` (`max_values`: None, `max_size`: None, mode: `Measured`) - pub fn already_notified_target() -> Weight { - // Proof Size summary in bytes: - // Measured: `173` - // Estimated: `18488` - // Minimum execution time: 28_326_000 picoseconds. - Weight::from_parts(28_909_000, 18488) - .saturating_add(T::DbWeight::get().reads(7)) - } - // Storage: `PolkadotXcm::VersionNotifyTargets` (r:2 w:1) - // Proof: `PolkadotXcm::VersionNotifyTargets` (`max_values`: None, `max_size`: None, mode: `Measured`) - // Storage: `ParachainSystem::UpwardDeliveryFeeFactor` (r:1 w:0) - // Proof: `ParachainSystem::UpwardDeliveryFeeFactor` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) - // Storage: `PolkadotXcm::SupportedVersion` (r:1 w:0) - // Proof: `PolkadotXcm::SupportedVersion` (`max_values`: None, `max_size`: None, mode: `Measured`) - // Storage: `PolkadotXcm::VersionDiscoveryQueue` (r:1 w:1) - // Proof: `PolkadotXcm::VersionDiscoveryQueue` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) - // Storage: `PolkadotXcm::SafeXcmVersion` (r:1 w:0) - // Proof: `PolkadotXcm::SafeXcmVersion` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) - // Storage: `ParachainSystem::HostConfiguration` (r:1 w:0) - // Proof: `ParachainSystem::HostConfiguration` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) - // Storage: `ParachainSystem::PendingUpwardMessages` (r:1 w:1) - // Proof: `ParachainSystem::PendingUpwardMessages` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) - pub fn notify_current_targets() -> Weight { - // Proof Size summary in bytes: - // Measured: `212` - // Estimated: `6152` - // Minimum execution time: 32_943_000 picoseconds. - Weight::from_parts(33_935_000, 6152) - .saturating_add(T::DbWeight::get().reads(8)) - .saturating_add(T::DbWeight::get().writes(3)) - } - // Storage: `PolkadotXcm::VersionNotifyTargets` (r:5 w:0) - // Proof: `PolkadotXcm::VersionNotifyTargets` (`max_values`: None, `max_size`: None, mode: `Measured`) - pub fn notify_target_migration_fail() -> Weight { - // Proof Size summary in bytes: - // Measured: `176` - // Estimated: `13541` - // Minimum execution time: 17_887_000 picoseconds. - Weight::from_parts(18_345_000, 13541) - .saturating_add(T::DbWeight::get().reads(5)) - } - // Storage: `PolkadotXcm::VersionNotifyTargets` (r:6 w:2) - // Proof: `PolkadotXcm::VersionNotifyTargets` (`max_values`: None, `max_size`: None, mode: `Measured`) - pub fn migrate_version_notify_targets() -> Weight { - // Proof Size summary in bytes: - // Measured: `170` - // Estimated: `16010` - // Minimum execution time: 25_926_000 picoseconds. - Weight::from_parts(26_253_000, 16010) - .saturating_add(T::DbWeight::get().reads(6)) - .saturating_add(T::DbWeight::get().writes(2)) - } - // Storage: `PolkadotXcm::VersionNotifyTargets` (r:6 w:2) - // Proof: `PolkadotXcm::VersionNotifyTargets` (`max_values`: None, `max_size`: None, mode: `Measured`) - // Storage: `ParachainSystem::UpwardDeliveryFeeFactor` (r:1 w:0) - // Proof: `ParachainSystem::UpwardDeliveryFeeFactor` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) - // Storage: `PolkadotXcm::SupportedVersion` (r:1 w:0) - // Proof: `PolkadotXcm::SupportedVersion` (`max_values`: None, `max_size`: None, mode: `Measured`) - // Storage: `PolkadotXcm::VersionDiscoveryQueue` (r:1 w:1) - // Proof: `PolkadotXcm::VersionDiscoveryQueue` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) - // Storage: `PolkadotXcm::SafeXcmVersion` (r:1 w:0) - // Proof: `PolkadotXcm::SafeXcmVersion` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) - // Storage: `ParachainSystem::HostConfiguration` (r:1 w:0) - // Proof: `ParachainSystem::HostConfiguration` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) - // Storage: `ParachainSystem::PendingUpwardMessages` (r:1 w:1) - // Proof: `ParachainSystem::PendingUpwardMessages` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) - pub fn migrate_and_notify_old_targets() -> Weight { - // Proof Size summary in bytes: - // Measured: `212` - // Estimated: `16052` - // Minimum execution time: 46_227_000 picoseconds. - Weight::from_parts(47_320_000, 16052) - .saturating_add(T::DbWeight::get().reads(12)) - .saturating_add(T::DbWeight::get().writes(4)) - } - // Storage: `PolkadotXcm::QueryCounter` (r:1 w:1) - // Proof: `PolkadotXcm::QueryCounter` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) - // Storage: `PolkadotXcm::Queries` (r:0 w:1) - // Proof: `PolkadotXcm::Queries` (`max_values`: None, `max_size`: None, mode: `Measured`) - pub fn new_query() -> Weight { - // Proof Size summary in bytes: - // Measured: `103` - // Estimated: `1588` - // Minimum execution time: 5_634_000 picoseconds. - Weight::from_parts(5_918_000, 1588) - .saturating_add(T::DbWeight::get().reads(1)) - .saturating_add(T::DbWeight::get().writes(2)) - } - // Storage: `PolkadotXcm::Queries` (r:1 w:1) - // Proof: `PolkadotXcm::Queries` (`max_values`: None, `max_size`: None, mode: `Measured`) - pub fn take_response() -> Weight { - // Proof Size summary in bytes: - // Measured: `7740` - // Estimated: `11205` - // Minimum execution time: 30_787_000 picoseconds. - Weight::from_parts(31_078_000, 11205) - .saturating_add(T::DbWeight::get().reads(1)) - .saturating_add(T::DbWeight::get().writes(1)) - } - // Storage: `PolkadotXcm::ShouldRecordXcm` (r:1 w:0) - // Proof: `PolkadotXcm::ShouldRecordXcm` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) - // Storage: `PolkadotXcm::AssetTraps` (r:1 w:1) - // Proof: `PolkadotXcm::AssetTraps` (`max_values`: None, `max_size`: None, mode: `Measured`) - pub fn claim_assets() -> Weight { - // Proof Size summary in bytes: - // Measured: `160` - // Estimated: `3625` - // Minimum execution time: 43_765_000 picoseconds. - Weight::from_parts(45_070_000, 3625) - .saturating_add(T::DbWeight::get().reads(2)) - .saturating_add(T::DbWeight::get().writes(1)) - } - // Storage: `PolkadotXcm::AuthorizedAliasesMap` (r:1 w:1) - // Proof: `PolkadotXcm::AuthorizedAliasesMap` (`max_values`: None, `max_size`: None, mode: `Measured`) - pub fn add_authorized_alias() -> Weight { - // Proof Size summary in bytes: - // Measured: `498` - // Estimated: `3963` - // Minimum execution time: 19_160_000 picoseconds. - Weight::from_parts(19_749_000, 3963) - .saturating_add(T::DbWeight::get().reads(1)) - .saturating_add(T::DbWeight::get().writes(1)) - } - // Storage: `PolkadotXcm::AuthorizedAliasesMap` (r:1 w:1) - // Proof: `PolkadotXcm::AuthorizedAliasesMap` (`max_values`: None, `max_size`: None, mode: `Measured`) - pub fn remove_authorized_alias() -> Weight { - // Proof Size summary in bytes: - // Measured: `537` - // Estimated: `4002` - // Minimum execution time: 20_372_000 picoseconds. - Weight::from_parts(21_198_000, 4002) - .saturating_add(T::DbWeight::get().reads(1)) - .saturating_add(T::DbWeight::get().writes(1)) - } -} diff --git a/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/weights/pallet_xcm.rs b/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/weights/pallet_xcm.rs index c01243ef1c5b..12ff328ca2cb 100644 --- a/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/weights/pallet_xcm.rs +++ b/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/weights/pallet_xcm.rs @@ -48,17 +48,25 @@ use core::marker::PhantomData; /// Weight functions for `pallet_xcm`. pub struct WeightInfo(PhantomData); impl pallet_xcm::WeightInfo for WeightInfo { + /// Storage: `PolkadotXcm::AuthorizedAliasesMap` (r:1 w:1) + /// Proof: `PolkadotXcm::AuthorizedAliasesMap` (`max_values`: None, `max_size`: None, mode: `Measured`) fn add_authorized_alias() -> Weight { - // TODO: benchmark - Weight::from_parts(3_724_000, 0) - .saturating_add(Weight::from_parts(0, 1517)) + // Proof Size summary in bytes: + // Measured: `498` + // Estimated: `3963` + // Minimum execution time: 19_789_000 picoseconds. + Weight::from_parts(20_317_000, 3963) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(1)) } + /// Storage: `PolkadotXcm::AuthorizedAliasesMap` (r:1 w:1) + /// Proof: `PolkadotXcm::AuthorizedAliasesMap` (`max_values`: None, `max_size`: None, mode: `Measured`) fn remove_authorized_alias() -> Weight { - // TODO: benchmark - Weight::from_parts(3_724_000, 0) - .saturating_add(Weight::from_parts(0, 1517)) + // Proof Size summary in bytes: + // Measured: `537` + // Estimated: `4002` + // Minimum execution time: 20_805_000 picoseconds. + Weight::from_parts(21_481_000, 4002) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(1)) } diff --git a/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-westend/src/weights/pallet_xcm.rs b/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-westend/src/weights/pallet_xcm.rs index 76846397c7d2..48ba7656ac71 100644 --- a/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-westend/src/weights/pallet_xcm.rs +++ b/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-westend/src/weights/pallet_xcm.rs @@ -48,17 +48,25 @@ use core::marker::PhantomData; /// Weight functions for `pallet_xcm`. pub struct WeightInfo(PhantomData); impl pallet_xcm::WeightInfo for WeightInfo { + /// Storage: `PolkadotXcm::AuthorizedAliasesMap` (r:1 w:1) + /// Proof: `PolkadotXcm::AuthorizedAliasesMap` (`max_values`: None, `max_size`: None, mode: `Measured`) fn add_authorized_alias() -> Weight { - // TODO: benchmark - Weight::from_parts(3_724_000, 0) - .saturating_add(Weight::from_parts(0, 1517)) + // Proof Size summary in bytes: + // Measured: `498` + // Estimated: `3963` + // Minimum execution time: 19_789_000 picoseconds. + Weight::from_parts(20_317_000, 3963) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(1)) } + /// Storage: `PolkadotXcm::AuthorizedAliasesMap` (r:1 w:1) + /// Proof: `PolkadotXcm::AuthorizedAliasesMap` (`max_values`: None, `max_size`: None, mode: `Measured`) fn remove_authorized_alias() -> Weight { - // TODO: benchmark - Weight::from_parts(3_724_000, 0) - .saturating_add(Weight::from_parts(0, 1517)) + // Proof Size summary in bytes: + // Measured: `537` + // Estimated: `4002` + // Minimum execution time: 20_805_000 picoseconds. + Weight::from_parts(21_481_000, 4002) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(1)) } diff --git a/cumulus/parachains/runtimes/collectives/collectives-westend/src/weights/pallet_xcm.rs b/cumulus/parachains/runtimes/collectives/collectives-westend/src/weights/pallet_xcm.rs index 58b773939de6..c9b597050ca8 100644 --- a/cumulus/parachains/runtimes/collectives/collectives-westend/src/weights/pallet_xcm.rs +++ b/cumulus/parachains/runtimes/collectives/collectives-westend/src/weights/pallet_xcm.rs @@ -48,17 +48,25 @@ use core::marker::PhantomData; /// Weight functions for `pallet_xcm`. pub struct WeightInfo(PhantomData); impl pallet_xcm::WeightInfo for WeightInfo { + /// Storage: `PolkadotXcm::AuthorizedAliasesMap` (r:1 w:1) + /// Proof: `PolkadotXcm::AuthorizedAliasesMap` (`max_values`: None, `max_size`: None, mode: `Measured`) fn add_authorized_alias() -> Weight { - // TODO: benchmark - Weight::from_parts(3_724_000, 0) - .saturating_add(Weight::from_parts(0, 1517)) + // Proof Size summary in bytes: + // Measured: `498` + // Estimated: `3963` + // Minimum execution time: 19_789_000 picoseconds. + Weight::from_parts(20_317_000, 3963) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(1)) } + /// Storage: `PolkadotXcm::AuthorizedAliasesMap` (r:1 w:1) + /// Proof: `PolkadotXcm::AuthorizedAliasesMap` (`max_values`: None, `max_size`: None, mode: `Measured`) fn remove_authorized_alias() -> Weight { - // TODO: benchmark - Weight::from_parts(3_724_000, 0) - .saturating_add(Weight::from_parts(0, 1517)) + // Proof Size summary in bytes: + // Measured: `537` + // Estimated: `4002` + // Minimum execution time: 20_805_000 picoseconds. + Weight::from_parts(21_481_000, 4002) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(1)) } diff --git a/cumulus/parachains/runtimes/coretime/coretime-rococo/src/weights/pallet_xcm.rs b/cumulus/parachains/runtimes/coretime/coretime-rococo/src/weights/pallet_xcm.rs index d5ec7614a5c2..9b05842003bd 100644 --- a/cumulus/parachains/runtimes/coretime/coretime-rococo/src/weights/pallet_xcm.rs +++ b/cumulus/parachains/runtimes/coretime/coretime-rococo/src/weights/pallet_xcm.rs @@ -48,17 +48,25 @@ use core::marker::PhantomData; /// Weight functions for `pallet_xcm`. pub struct WeightInfo(PhantomData); impl pallet_xcm::WeightInfo for WeightInfo { + /// Storage: `PolkadotXcm::AuthorizedAliasesMap` (r:1 w:1) + /// Proof: `PolkadotXcm::AuthorizedAliasesMap` (`max_values`: None, `max_size`: None, mode: `Measured`) fn add_authorized_alias() -> Weight { - // TODO: benchmark - Weight::from_parts(3_724_000, 0) - .saturating_add(Weight::from_parts(0, 1517)) + // Proof Size summary in bytes: + // Measured: `498` + // Estimated: `3963` + // Minimum execution time: 19_789_000 picoseconds. + Weight::from_parts(20_317_000, 3963) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(1)) } + /// Storage: `PolkadotXcm::AuthorizedAliasesMap` (r:1 w:1) + /// Proof: `PolkadotXcm::AuthorizedAliasesMap` (`max_values`: None, `max_size`: None, mode: `Measured`) fn remove_authorized_alias() -> Weight { - // TODO: benchmark - Weight::from_parts(3_724_000, 0) - .saturating_add(Weight::from_parts(0, 1517)) + // Proof Size summary in bytes: + // Measured: `537` + // Estimated: `4002` + // Minimum execution time: 20_805_000 picoseconds. + Weight::from_parts(21_481_000, 4002) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(1)) } diff --git a/cumulus/parachains/runtimes/coretime/coretime-westend/src/weights/pallet_xcm.rs b/cumulus/parachains/runtimes/coretime/coretime-westend/src/weights/pallet_xcm.rs index 0b3fc7ae23ed..16010d08b7b4 100644 --- a/cumulus/parachains/runtimes/coretime/coretime-westend/src/weights/pallet_xcm.rs +++ b/cumulus/parachains/runtimes/coretime/coretime-westend/src/weights/pallet_xcm.rs @@ -48,17 +48,25 @@ use core::marker::PhantomData; /// Weight functions for `pallet_xcm`. pub struct WeightInfo(PhantomData); impl pallet_xcm::WeightInfo for WeightInfo { + /// Storage: `PolkadotXcm::AuthorizedAliasesMap` (r:1 w:1) + /// Proof: `PolkadotXcm::AuthorizedAliasesMap` (`max_values`: None, `max_size`: None, mode: `Measured`) fn add_authorized_alias() -> Weight { - // TODO: benchmark - Weight::from_parts(3_724_000, 0) - .saturating_add(Weight::from_parts(0, 1517)) + // Proof Size summary in bytes: + // Measured: `498` + // Estimated: `3963` + // Minimum execution time: 19_789_000 picoseconds. + Weight::from_parts(20_317_000, 3963) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(1)) } + /// Storage: `PolkadotXcm::AuthorizedAliasesMap` (r:1 w:1) + /// Proof: `PolkadotXcm::AuthorizedAliasesMap` (`max_values`: None, `max_size`: None, mode: `Measured`) fn remove_authorized_alias() -> Weight { - // TODO: benchmark - Weight::from_parts(3_724_000, 0) - .saturating_add(Weight::from_parts(0, 1517)) + // Proof Size summary in bytes: + // Measured: `537` + // Estimated: `4002` + // Minimum execution time: 20_805_000 picoseconds. + Weight::from_parts(21_481_000, 4002) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(1)) } diff --git a/cumulus/parachains/runtimes/people/people-rococo/src/weights/pallet_xcm.rs b/cumulus/parachains/runtimes/people/people-rococo/src/weights/pallet_xcm.rs index d6e370eebe89..9868db381cbf 100644 --- a/cumulus/parachains/runtimes/people/people-rococo/src/weights/pallet_xcm.rs +++ b/cumulus/parachains/runtimes/people/people-rococo/src/weights/pallet_xcm.rs @@ -48,17 +48,25 @@ use core::marker::PhantomData; /// Weight functions for `pallet_xcm`. pub struct WeightInfo(PhantomData); impl pallet_xcm::WeightInfo for WeightInfo { + /// Storage: `PolkadotXcm::AuthorizedAliasesMap` (r:1 w:1) + /// Proof: `PolkadotXcm::AuthorizedAliasesMap` (`max_values`: None, `max_size`: None, mode: `Measured`) fn add_authorized_alias() -> Weight { - // TODO: benchmark - Weight::from_parts(3_724_000, 0) - .saturating_add(Weight::from_parts(0, 1517)) + // Proof Size summary in bytes: + // Measured: `498` + // Estimated: `3963` + // Minimum execution time: 19_789_000 picoseconds. + Weight::from_parts(20_317_000, 3963) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(1)) } + /// Storage: `PolkadotXcm::AuthorizedAliasesMap` (r:1 w:1) + /// Proof: `PolkadotXcm::AuthorizedAliasesMap` (`max_values`: None, `max_size`: None, mode: `Measured`) fn remove_authorized_alias() -> Weight { - // TODO: benchmark - Weight::from_parts(3_724_000, 0) - .saturating_add(Weight::from_parts(0, 1517)) + // Proof Size summary in bytes: + // Measured: `537` + // Estimated: `4002` + // Minimum execution time: 20_805_000 picoseconds. + Weight::from_parts(21_481_000, 4002) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(1)) } diff --git a/cumulus/parachains/runtimes/people/people-westend/src/weights/pallet_xcm.rs b/cumulus/parachains/runtimes/people/people-westend/src/weights/pallet_xcm.rs index e50b2b70daae..636152779906 100644 --- a/cumulus/parachains/runtimes/people/people-westend/src/weights/pallet_xcm.rs +++ b/cumulus/parachains/runtimes/people/people-westend/src/weights/pallet_xcm.rs @@ -48,17 +48,25 @@ use core::marker::PhantomData; /// Weight functions for `pallet_xcm`. pub struct WeightInfo(PhantomData); impl pallet_xcm::WeightInfo for WeightInfo { + /// Storage: `PolkadotXcm::AuthorizedAliasesMap` (r:1 w:1) + /// Proof: `PolkadotXcm::AuthorizedAliasesMap` (`max_values`: None, `max_size`: None, mode: `Measured`) fn add_authorized_alias() -> Weight { - // TODO: benchmark - Weight::from_parts(3_724_000, 0) - .saturating_add(Weight::from_parts(0, 1517)) + // Proof Size summary in bytes: + // Measured: `498` + // Estimated: `3963` + // Minimum execution time: 19_789_000 picoseconds. + Weight::from_parts(20_317_000, 3963) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(1)) } + /// Storage: `PolkadotXcm::AuthorizedAliasesMap` (r:1 w:1) + /// Proof: `PolkadotXcm::AuthorizedAliasesMap` (`max_values`: None, `max_size`: None, mode: `Measured`) fn remove_authorized_alias() -> Weight { - // TODO: benchmark - Weight::from_parts(3_724_000, 0) - .saturating_add(Weight::from_parts(0, 1517)) + // Proof Size summary in bytes: + // Measured: `537` + // Estimated: `4002` + // Minimum execution time: 20_805_000 picoseconds. + Weight::from_parts(21_481_000, 4002) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(1)) } diff --git a/polkadot/runtime/rococo/src/weights/pallet_xcm.rs b/polkadot/runtime/rococo/src/weights/pallet_xcm.rs index 3e7d29e973c4..5849b8806b1e 100644 --- a/polkadot/runtime/rococo/src/weights/pallet_xcm.rs +++ b/polkadot/runtime/rococo/src/weights/pallet_xcm.rs @@ -50,20 +50,6 @@ use core::marker::PhantomData; /// Weight functions for `pallet_xcm`. pub struct WeightInfo(PhantomData); impl pallet_xcm::WeightInfo for WeightInfo { - fn add_authorized_alias() -> Weight { - // TODO: benchmark - Weight::from_parts(3_724_000, 0) - .saturating_add(Weight::from_parts(0, 1517)) - .saturating_add(T::DbWeight::get().reads(1)) - .saturating_add(T::DbWeight::get().writes(1)) - } - fn remove_authorized_alias() -> Weight { - // TODO: benchmark - Weight::from_parts(3_724_000, 0) - .saturating_add(Weight::from_parts(0, 1517)) - .saturating_add(T::DbWeight::get().reads(1)) - .saturating_add(T::DbWeight::get().writes(1)) - } /// Storage: `Dmp::DeliveryFeeFactor` (r:1 w:0) /// Proof: `Dmp::DeliveryFeeFactor` (`max_values`: None, `max_size`: None, mode: `Measured`) /// Storage: `XcmPallet::SupportedVersion` (r:1 w:0) @@ -362,4 +348,26 @@ impl pallet_xcm::WeightInfo for WeightInfo { .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(1)) } + /// Storage: `XcmPallet::AuthorizedAliasesMap` (r:1 w:1) + /// Proof: `XcmPallet::AuthorizedAliasesMap` (`max_values`: None, `max_size`: None, mode: `Measured`) + fn add_authorized_alias() -> Weight { + // Proof Size summary in bytes: + // Measured: `361` + // Estimated: `3826` + // Minimum execution time: 15_975_000 picoseconds. + Weight::from_parts(16_398_000, 3826) + .saturating_add(T::DbWeight::get().reads(1)) + .saturating_add(T::DbWeight::get().writes(1)) + } + /// Storage: `XcmPallet::AuthorizedAliasesMap` (r:1 w:1) + /// Proof: `XcmPallet::AuthorizedAliasesMap` (`max_values`: None, `max_size`: None, mode: `Measured`) + fn remove_authorized_alias() -> Weight { + // Proof Size summary in bytes: + // Measured: `400` + // Estimated: `3865` + // Minimum execution time: 17_326_000 picoseconds. + Weight::from_parts(17_622_000, 3865) + .saturating_add(T::DbWeight::get().reads(1)) + .saturating_add(T::DbWeight::get().writes(1)) + } } diff --git a/polkadot/runtime/rococo/src/weights/xcm/pallet_xcm.rs b/polkadot/runtime/rococo/src/weights/xcm/pallet_xcm.rs deleted file mode 100644 index 4309c155ca9a..000000000000 --- a/polkadot/runtime/rococo/src/weights/xcm/pallet_xcm.rs +++ /dev/null @@ -1,363 +0,0 @@ -// Copyright (C) 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 . - -//! Autogenerated weights for `pallet_xcm` -//! -//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 32.0.0 -//! DATE: 2024-11-07, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` -//! WORST CASE MAP SIZE: `1000000` -//! HOSTNAME: `runner-vcatxqpx-project-674-concurrent-0`, CPU: `Intel(R) Xeon(R) CPU @ 2.60GHz` -//! WASM-EXECUTION: Compiled, CHAIN: Some("rococo-dev"), DB CACHE: 1024 - -// Executed Command: -// target/production/polkadot -// benchmark -// pallet -// --steps=50 -// --repeat=20 -// --extrinsic=* -// --wasm-execution=compiled -// --heap-pages=4096 -// --json-file=/builds/parity/mirrors/polkadot-sdk/.git/.artifacts/bench.json -// --pallet=pallet_xcm -// --chain=rococo-dev -// --header=./polkadot/file_header.txt -// --template=./polkadot/xcm/pallet-xcm-benchmarks/template.hbs -// --output=./polkadot/runtime/rococo/src/weights/xcm/ - -#![cfg_attr(rustfmt, rustfmt_skip)] -#![allow(unused_parens)] -#![allow(unused_imports)] -#![allow(missing_docs)] - -use frame_support::{traits::Get, weights::Weight}; -use core::marker::PhantomData; - -/// Weight functions for `pallet_xcm`. -pub struct WeightInfo(PhantomData); -impl WeightInfo { - /// Storage: `Dmp::DeliveryFeeFactor` (r:1 w:0) - /// Proof: `Dmp::DeliveryFeeFactor` (`max_values`: None, `max_size`: None, mode: `Measured`) - /// Storage: `XcmPallet::SupportedVersion` (r:1 w:0) - /// Proof: `XcmPallet::SupportedVersion` (`max_values`: None, `max_size`: None, mode: `Measured`) - /// Storage: `Dmp::DownwardMessageQueues` (r:1 w:1) - /// Proof: `Dmp::DownwardMessageQueues` (`max_values`: None, `max_size`: None, mode: `Measured`) - /// Storage: `Dmp::DownwardMessageQueueHeads` (r:1 w:1) - /// Proof: `Dmp::DownwardMessageQueueHeads` (`max_values`: None, `max_size`: None, mode: `Measured`) - pub(crate) fn send() -> Weight { - // Proof Size summary in bytes: - // Measured: `180` - // Estimated: `3645` - // Minimum execution time: 30_643_000 picoseconds. - Weight::from_parts(31_782_000, 3645) - .saturating_add(T::DbWeight::get().reads(4)) - .saturating_add(T::DbWeight::get().writes(2)) - } - /// Storage: `System::Account` (r:1 w:1) - /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`) - /// Storage: `XcmPallet::ShouldRecordXcm` (r:1 w:0) - /// Proof: `XcmPallet::ShouldRecordXcm` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) - /// Storage: `Dmp::DeliveryFeeFactor` (r:1 w:0) - /// Proof: `Dmp::DeliveryFeeFactor` (`max_values`: None, `max_size`: None, mode: `Measured`) - /// Storage: `XcmPallet::SupportedVersion` (r:1 w:0) - /// Proof: `XcmPallet::SupportedVersion` (`max_values`: None, `max_size`: None, mode: `Measured`) - /// Storage: `Dmp::DownwardMessageQueues` (r:1 w:1) - /// Proof: `Dmp::DownwardMessageQueues` (`max_values`: None, `max_size`: None, mode: `Measured`) - /// Storage: `Dmp::DownwardMessageQueueHeads` (r:1 w:1) - /// Proof: `Dmp::DownwardMessageQueueHeads` (`max_values`: None, `max_size`: None, mode: `Measured`) - pub(crate) fn teleport_assets() -> Weight { - // Proof Size summary in bytes: - // Measured: `180` - // Estimated: `3645` - // Minimum execution time: 130_791_000 picoseconds. - Weight::from_parts(134_979_000, 3645) - .saturating_add(T::DbWeight::get().reads(6)) - .saturating_add(T::DbWeight::get().writes(3)) - } - /// Storage: `XcmPallet::ShouldRecordXcm` (r:1 w:0) - /// Proof: `XcmPallet::ShouldRecordXcm` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) - /// Storage: `System::Account` (r:1 w:1) - /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`) - /// Storage: `Dmp::DeliveryFeeFactor` (r:1 w:0) - /// Proof: `Dmp::DeliveryFeeFactor` (`max_values`: None, `max_size`: None, mode: `Measured`) - /// Storage: `XcmPallet::SupportedVersion` (r:1 w:0) - /// Proof: `XcmPallet::SupportedVersion` (`max_values`: None, `max_size`: None, mode: `Measured`) - /// Storage: `Dmp::DownwardMessageQueues` (r:1 w:1) - /// Proof: `Dmp::DownwardMessageQueues` (`max_values`: None, `max_size`: None, mode: `Measured`) - /// Storage: `Dmp::DownwardMessageQueueHeads` (r:1 w:1) - /// Proof: `Dmp::DownwardMessageQueueHeads` (`max_values`: None, `max_size`: None, mode: `Measured`) - pub(crate) fn reserve_transfer_assets() -> Weight { - // Proof Size summary in bytes: - // Measured: `232` - // Estimated: `3697` - // Minimum execution time: 129_933_000 picoseconds. - Weight::from_parts(134_918_000, 3697) - .saturating_add(T::DbWeight::get().reads(6)) - .saturating_add(T::DbWeight::get().writes(3)) - } - /// Storage: `System::Account` (r:1 w:1) - /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`) - /// Storage: `XcmPallet::ShouldRecordXcm` (r:1 w:0) - /// Proof: `XcmPallet::ShouldRecordXcm` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) - /// Storage: `Dmp::DeliveryFeeFactor` (r:1 w:0) - /// Proof: `Dmp::DeliveryFeeFactor` (`max_values`: None, `max_size`: None, mode: `Measured`) - /// Storage: `XcmPallet::SupportedVersion` (r:1 w:0) - /// Proof: `XcmPallet::SupportedVersion` (`max_values`: None, `max_size`: None, mode: `Measured`) - /// Storage: `Dmp::DownwardMessageQueues` (r:1 w:1) - /// Proof: `Dmp::DownwardMessageQueues` (`max_values`: None, `max_size`: None, mode: `Measured`) - /// Storage: `Dmp::DownwardMessageQueueHeads` (r:1 w:1) - /// Proof: `Dmp::DownwardMessageQueueHeads` (`max_values`: None, `max_size`: None, mode: `Measured`) - pub(crate) fn transfer_assets() -> Weight { - // Proof Size summary in bytes: - // Measured: `180` - // Estimated: `3645` - // Minimum execution time: 130_466_000 picoseconds. - Weight::from_parts(135_449_000, 3645) - .saturating_add(T::DbWeight::get().reads(6)) - .saturating_add(T::DbWeight::get().writes(3)) - } - /// Storage: `XcmPallet::ShouldRecordXcm` (r:1 w:0) - /// Proof: `XcmPallet::ShouldRecordXcm` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) - pub(crate) fn execute() -> Weight { - // Proof Size summary in bytes: - // Measured: `0` - // Estimated: `1485` - // Minimum execution time: 9_620_000 picoseconds. - Weight::from_parts(10_073_000, 1485) - .saturating_add(T::DbWeight::get().reads(1)) - } - /// Storage: `XcmPallet::SupportedVersion` (r:0 w:1) - /// Proof: `XcmPallet::SupportedVersion` (`max_values`: None, `max_size`: None, mode: `Measured`) - pub(crate) fn force_xcm_version() -> Weight { - // Proof Size summary in bytes: - // Measured: `0` - // Estimated: `0` - // Minimum execution time: 8_386_000 picoseconds. - Weight::from_parts(8_727_000, 0) - .saturating_add(T::DbWeight::get().writes(1)) - } - pub(crate) fn force_default_xcm_version() -> Weight { - // Proof Size summary in bytes: - // Measured: `0` - // Estimated: `0` - // Minimum execution time: 2_481_000 picoseconds. - Weight::from_parts(2_653_000, 0) - } - /// Storage: `XcmPallet::VersionNotifiers` (r:1 w:1) - /// Proof: `XcmPallet::VersionNotifiers` (`max_values`: None, `max_size`: None, mode: `Measured`) - /// Storage: `XcmPallet::QueryCounter` (r:1 w:1) - /// Proof: `XcmPallet::QueryCounter` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) - /// Storage: `Dmp::DeliveryFeeFactor` (r:1 w:0) - /// Proof: `Dmp::DeliveryFeeFactor` (`max_values`: None, `max_size`: None, mode: `Measured`) - /// Storage: `XcmPallet::SupportedVersion` (r:1 w:0) - /// Proof: `XcmPallet::SupportedVersion` (`max_values`: None, `max_size`: None, mode: `Measured`) - /// Storage: `Dmp::DownwardMessageQueues` (r:1 w:1) - /// Proof: `Dmp::DownwardMessageQueues` (`max_values`: None, `max_size`: None, mode: `Measured`) - /// Storage: `Dmp::DownwardMessageQueueHeads` (r:1 w:1) - /// Proof: `Dmp::DownwardMessageQueueHeads` (`max_values`: None, `max_size`: None, mode: `Measured`) - /// Storage: `XcmPallet::Queries` (r:0 w:1) - /// Proof: `XcmPallet::Queries` (`max_values`: None, `max_size`: None, mode: `Measured`) - pub(crate) fn force_subscribe_version_notify() -> Weight { - // Proof Size summary in bytes: - // Measured: `180` - // Estimated: `3645` - // Minimum execution time: 37_250_000 picoseconds. - Weight::from_parts(38_353_000, 3645) - .saturating_add(T::DbWeight::get().reads(6)) - .saturating_add(T::DbWeight::get().writes(5)) - } - /// Storage: `XcmPallet::VersionNotifiers` (r:1 w:1) - /// Proof: `XcmPallet::VersionNotifiers` (`max_values`: None, `max_size`: None, mode: `Measured`) - /// Storage: `Dmp::DeliveryFeeFactor` (r:1 w:0) - /// Proof: `Dmp::DeliveryFeeFactor` (`max_values`: None, `max_size`: None, mode: `Measured`) - /// Storage: `XcmPallet::SupportedVersion` (r:1 w:0) - /// Proof: `XcmPallet::SupportedVersion` (`max_values`: None, `max_size`: None, mode: `Measured`) - /// Storage: `Dmp::DownwardMessageQueues` (r:1 w:1) - /// Proof: `Dmp::DownwardMessageQueues` (`max_values`: None, `max_size`: None, mode: `Measured`) - /// Storage: `Dmp::DownwardMessageQueueHeads` (r:1 w:1) - /// Proof: `Dmp::DownwardMessageQueueHeads` (`max_values`: None, `max_size`: None, mode: `Measured`) - /// Storage: `XcmPallet::Queries` (r:0 w:1) - /// Proof: `XcmPallet::Queries` (`max_values`: None, `max_size`: None, mode: `Measured`) - pub(crate) fn force_unsubscribe_version_notify() -> Weight { - // Proof Size summary in bytes: - // Measured: `360` - // Estimated: `3825` - // Minimum execution time: 46_257_000 picoseconds. - Weight::from_parts(47_915_000, 3825) - .saturating_add(T::DbWeight::get().reads(5)) - .saturating_add(T::DbWeight::get().writes(4)) - } - /// Storage: `XcmPallet::XcmExecutionSuspended` (r:0 w:1) - /// Proof: `XcmPallet::XcmExecutionSuspended` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) - pub(crate) fn force_suspension() -> Weight { - // Proof Size summary in bytes: - // Measured: `0` - // Estimated: `0` - // Minimum execution time: 2_530_000 picoseconds. - Weight::from_parts(2_619_000, 0) - .saturating_add(T::DbWeight::get().writes(1)) - } - /// Storage: `XcmPallet::SupportedVersion` (r:6 w:2) - /// Proof: `XcmPallet::SupportedVersion` (`max_values`: None, `max_size`: None, mode: `Measured`) - pub(crate) fn migrate_supported_version() -> Weight { - // Proof Size summary in bytes: - // Measured: `22` - // Estimated: `15862` - // Minimum execution time: 21_851_000 picoseconds. - Weight::from_parts(22_104_000, 15862) - .saturating_add(T::DbWeight::get().reads(6)) - .saturating_add(T::DbWeight::get().writes(2)) - } - /// Storage: `XcmPallet::VersionNotifiers` (r:6 w:2) - /// Proof: `XcmPallet::VersionNotifiers` (`max_values`: None, `max_size`: None, mode: `Measured`) - pub(crate) fn migrate_version_notifiers() -> Weight { - // Proof Size summary in bytes: - // Measured: `26` - // Estimated: `15866` - // Minimum execution time: 22_063_000 picoseconds. - Weight::from_parts(22_386_000, 15866) - .saturating_add(T::DbWeight::get().reads(6)) - .saturating_add(T::DbWeight::get().writes(2)) - } - /// Storage: `XcmPallet::VersionNotifyTargets` (r:7 w:0) - /// Proof: `XcmPallet::VersionNotifyTargets` (`max_values`: None, `max_size`: None, mode: `Measured`) - pub(crate) fn already_notified_target() -> Weight { - // Proof Size summary in bytes: - // Measured: `40` - // Estimated: `18355` - // Minimum execution time: 25_210_000 picoseconds. - Weight::from_parts(25_527_000, 18355) - .saturating_add(T::DbWeight::get().reads(7)) - } - /// Storage: `XcmPallet::VersionNotifyTargets` (r:2 w:1) - /// Proof: `XcmPallet::VersionNotifyTargets` (`max_values`: None, `max_size`: None, mode: `Measured`) - /// Storage: `Dmp::DeliveryFeeFactor` (r:1 w:0) - /// Proof: `Dmp::DeliveryFeeFactor` (`max_values`: None, `max_size`: None, mode: `Measured`) - /// Storage: `XcmPallet::SupportedVersion` (r:1 w:0) - /// Proof: `XcmPallet::SupportedVersion` (`max_values`: None, `max_size`: None, mode: `Measured`) - /// Storage: `Dmp::DownwardMessageQueues` (r:1 w:1) - /// Proof: `Dmp::DownwardMessageQueues` (`max_values`: None, `max_size`: None, mode: `Measured`) - /// Storage: `Dmp::DownwardMessageQueueHeads` (r:1 w:1) - /// Proof: `Dmp::DownwardMessageQueueHeads` (`max_values`: None, `max_size`: None, mode: `Measured`) - pub(crate) fn notify_current_targets() -> Weight { - // Proof Size summary in bytes: - // Measured: `216` - // Estimated: `6156` - // Minimum execution time: 36_418_000 picoseconds. - Weight::from_parts(37_557_000, 6156) - .saturating_add(T::DbWeight::get().reads(6)) - .saturating_add(T::DbWeight::get().writes(3)) - } - /// Storage: `XcmPallet::VersionNotifyTargets` (r:5 w:0) - /// Proof: `XcmPallet::VersionNotifyTargets` (`max_values`: None, `max_size`: None, mode: `Measured`) - pub(crate) fn notify_target_migration_fail() -> Weight { - // Proof Size summary in bytes: - // Measured: `40` - // Estimated: `13405` - // Minimum execution time: 17_617_000 picoseconds. - Weight::from_parts(17_794_000, 13405) - .saturating_add(T::DbWeight::get().reads(5)) - } - /// Storage: `XcmPallet::VersionNotifyTargets` (r:6 w:2) - /// Proof: `XcmPallet::VersionNotifyTargets` (`max_values`: None, `max_size`: None, mode: `Measured`) - pub(crate) fn migrate_version_notify_targets() -> Weight { - // Proof Size summary in bytes: - // Measured: `33` - // Estimated: `15873` - // Minimum execution time: 22_091_000 picoseconds. - Weight::from_parts(22_394_000, 15873) - .saturating_add(T::DbWeight::get().reads(6)) - .saturating_add(T::DbWeight::get().writes(2)) - } - /// Storage: `XcmPallet::VersionNotifyTargets` (r:6 w:2) - /// Proof: `XcmPallet::VersionNotifyTargets` (`max_values`: None, `max_size`: None, mode: `Measured`) - /// Storage: `Dmp::DeliveryFeeFactor` (r:1 w:0) - /// Proof: `Dmp::DeliveryFeeFactor` (`max_values`: None, `max_size`: None, mode: `Measured`) - /// Storage: `XcmPallet::SupportedVersion` (r:1 w:0) - /// Proof: `XcmPallet::SupportedVersion` (`max_values`: None, `max_size`: None, mode: `Measured`) - /// Storage: `Dmp::DownwardMessageQueues` (r:1 w:1) - /// Proof: `Dmp::DownwardMessageQueues` (`max_values`: None, `max_size`: None, mode: `Measured`) - /// Storage: `Dmp::DownwardMessageQueueHeads` (r:1 w:1) - /// Proof: `Dmp::DownwardMessageQueueHeads` (`max_values`: None, `max_size`: None, mode: `Measured`) - pub(crate) fn migrate_and_notify_old_targets() -> Weight { - // Proof Size summary in bytes: - // Measured: `216` - // Estimated: `16056` - // Minimum execution time: 49_581_000 picoseconds. - Weight::from_parts(50_795_000, 16056) - .saturating_add(T::DbWeight::get().reads(10)) - .saturating_add(T::DbWeight::get().writes(4)) - } - /// Storage: `XcmPallet::QueryCounter` (r:1 w:1) - /// Proof: `XcmPallet::QueryCounter` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) - /// Storage: `XcmPallet::Queries` (r:0 w:1) - /// Proof: `XcmPallet::Queries` (`max_values`: None, `max_size`: None, mode: `Measured`) - pub(crate) fn new_query() -> Weight { - // Proof Size summary in bytes: - // Measured: `0` - // Estimated: `1485` - // Minimum execution time: 2_781_000 picoseconds. - Weight::from_parts(2_893_000, 1485) - .saturating_add(T::DbWeight::get().reads(1)) - .saturating_add(T::DbWeight::get().writes(2)) - } - /// Storage: `XcmPallet::Queries` (r:1 w:1) - /// Proof: `XcmPallet::Queries` (`max_values`: None, `max_size`: None, mode: `Measured`) - pub(crate) fn take_response() -> Weight { - // Proof Size summary in bytes: - // Measured: `7576` - // Estimated: `11041` - // Minimum execution time: 26_391_000 picoseconds. - Weight::from_parts(26_902_000, 11041) - .saturating_add(T::DbWeight::get().reads(1)) - .saturating_add(T::DbWeight::get().writes(1)) - } - /// Storage: `XcmPallet::ShouldRecordXcm` (r:1 w:0) - /// Proof: `XcmPallet::ShouldRecordXcm` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) - /// Storage: `XcmPallet::AssetTraps` (r:1 w:1) - /// Proof: `XcmPallet::AssetTraps` (`max_values`: None, `max_size`: None, mode: `Measured`) - pub(crate) fn claim_assets() -> Weight { - // Proof Size summary in bytes: - // Measured: `23` - // Estimated: `3488` - // Minimum execution time: 39_963_000 picoseconds. - Weight::from_parts(41_025_000, 3488) - .saturating_add(T::DbWeight::get().reads(2)) - .saturating_add(T::DbWeight::get().writes(1)) - } - /// Storage: `XcmPallet::AuthorizedAliasesMap` (r:1 w:1) - /// Proof: `XcmPallet::AuthorizedAliasesMap` (`max_values`: None, `max_size`: None, mode: `Measured`) - pub(crate) fn add_authorized_alias() -> Weight { - // Proof Size summary in bytes: - // Measured: `361` - // Estimated: `3826` - // Minimum execution time: 15_975_000 picoseconds. - Weight::from_parts(16_398_000, 3826) - .saturating_add(T::DbWeight::get().reads(1)) - .saturating_add(T::DbWeight::get().writes(1)) - } - /// Storage: `XcmPallet::AuthorizedAliasesMap` (r:1 w:1) - /// Proof: `XcmPallet::AuthorizedAliasesMap` (`max_values`: None, `max_size`: None, mode: `Measured`) - pub(crate) fn remove_authorized_alias() -> Weight { - // Proof Size summary in bytes: - // Measured: `400` - // Estimated: `3865` - // Minimum execution time: 17_326_000 picoseconds. - Weight::from_parts(17_622_000, 3865) - .saturating_add(T::DbWeight::get().reads(1)) - .saturating_add(T::DbWeight::get().writes(1)) - } -} diff --git a/polkadot/runtime/westend/src/weights/pallet_xcm.rs b/polkadot/runtime/westend/src/weights/pallet_xcm.rs index aac57102613d..0032dfaa3b64 100644 --- a/polkadot/runtime/westend/src/weights/pallet_xcm.rs +++ b/polkadot/runtime/westend/src/weights/pallet_xcm.rs @@ -48,20 +48,6 @@ use core::marker::PhantomData; /// Weight functions for `pallet_xcm`. pub struct WeightInfo(PhantomData); impl pallet_xcm::WeightInfo for WeightInfo { - fn add_authorized_alias() -> Weight { - // TODO: benchmark - Weight::from_parts(3_724_000, 0) - .saturating_add(Weight::from_parts(0, 1517)) - .saturating_add(T::DbWeight::get().reads(1)) - .saturating_add(T::DbWeight::get().writes(1)) - } - fn remove_authorized_alias() -> Weight { - // TODO: benchmark - Weight::from_parts(3_724_000, 0) - .saturating_add(Weight::from_parts(0, 1517)) - .saturating_add(T::DbWeight::get().reads(1)) - .saturating_add(T::DbWeight::get().writes(1)) - } /// Storage: `Dmp::DeliveryFeeFactor` (r:1 w:0) /// Proof: `Dmp::DeliveryFeeFactor` (`max_values`: None, `max_size`: None, mode: `Measured`) /// Storage: `XcmPallet::SupportedVersion` (r:1 w:0) @@ -362,4 +348,26 @@ impl pallet_xcm::WeightInfo for WeightInfo { .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(1)) } + /// Storage: `XcmPallet::AuthorizedAliasesMap` (r:1 w:1) + /// Proof: `XcmPallet::AuthorizedAliasesMap` (`max_values`: None, `max_size`: None, mode: `Measured`) + fn add_authorized_alias() -> Weight { + // Proof Size summary in bytes: + // Measured: `361` + // Estimated: `3826` + // Minimum execution time: 15_975_000 picoseconds. + Weight::from_parts(16_398_000, 3826) + .saturating_add(T::DbWeight::get().reads(1)) + .saturating_add(T::DbWeight::get().writes(1)) + } + /// Storage: `XcmPallet::AuthorizedAliasesMap` (r:1 w:1) + /// Proof: `XcmPallet::AuthorizedAliasesMap` (`max_values`: None, `max_size`: None, mode: `Measured`) + fn remove_authorized_alias() -> Weight { + // Proof Size summary in bytes: + // Measured: `400` + // Estimated: `3865` + // Minimum execution time: 17_326_000 picoseconds. + Weight::from_parts(17_622_000, 3865) + .saturating_add(T::DbWeight::get().reads(1)) + .saturating_add(T::DbWeight::get().writes(1)) + } } diff --git a/polkadot/runtime/westend/src/weights/xcm/pallet_xcm.rs b/polkadot/runtime/westend/src/weights/xcm/pallet_xcm.rs deleted file mode 100644 index 0e770a88c069..000000000000 --- a/polkadot/runtime/westend/src/weights/xcm/pallet_xcm.rs +++ /dev/null @@ -1,363 +0,0 @@ -// Copyright (C) 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 . - -//! Autogenerated weights for `pallet_xcm` -//! -//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 32.0.0 -//! DATE: 2024-11-07, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` -//! WORST CASE MAP SIZE: `1000000` -//! HOSTNAME: `runner-vcatxqpx-project-674-concurrent-0`, CPU: `Intel(R) Xeon(R) CPU @ 2.60GHz` -//! WASM-EXECUTION: Compiled, CHAIN: Some("westend-dev"), DB CACHE: 1024 - -// Executed Command: -// target/production/polkadot -// benchmark -// pallet -// --steps=50 -// --repeat=20 -// --extrinsic=* -// --wasm-execution=compiled -// --heap-pages=4096 -// --json-file=/builds/parity/mirrors/polkadot-sdk/.git/.artifacts/bench.json -// --pallet=pallet_xcm -// --chain=westend-dev -// --header=./polkadot/file_header.txt -// --template=./polkadot/xcm/pallet-xcm-benchmarks/template.hbs -// --output=./polkadot/runtime/westend/src/weights/xcm/ - -#![cfg_attr(rustfmt, rustfmt_skip)] -#![allow(unused_parens)] -#![allow(unused_imports)] -#![allow(missing_docs)] - -use frame_support::{traits::Get, weights::Weight}; -use core::marker::PhantomData; - -/// Weight functions for `pallet_xcm`. -pub struct WeightInfo(PhantomData); -impl WeightInfo { - /// Storage: `Dmp::DeliveryFeeFactor` (r:1 w:0) - /// Proof: `Dmp::DeliveryFeeFactor` (`max_values`: None, `max_size`: None, mode: `Measured`) - /// Storage: `XcmPallet::SupportedVersion` (r:1 w:0) - /// Proof: `XcmPallet::SupportedVersion` (`max_values`: None, `max_size`: None, mode: `Measured`) - /// Storage: `Dmp::DownwardMessageQueues` (r:1 w:1) - /// Proof: `Dmp::DownwardMessageQueues` (`max_values`: None, `max_size`: None, mode: `Measured`) - /// Storage: `Dmp::DownwardMessageQueueHeads` (r:1 w:1) - /// Proof: `Dmp::DownwardMessageQueueHeads` (`max_values`: None, `max_size`: None, mode: `Measured`) - pub(crate) fn send() -> Weight { - // Proof Size summary in bytes: - // Measured: `147` - // Estimated: `3612` - // Minimum execution time: 30_777_000 picoseconds. - Weight::from_parts(31_746_000, 3612) - .saturating_add(T::DbWeight::get().reads(4)) - .saturating_add(T::DbWeight::get().writes(2)) - } - /// Storage: `System::Account` (r:2 w:2) - /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`) - /// Storage: `XcmPallet::ShouldRecordXcm` (r:1 w:0) - /// Proof: `XcmPallet::ShouldRecordXcm` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) - /// Storage: `Dmp::DeliveryFeeFactor` (r:1 w:0) - /// Proof: `Dmp::DeliveryFeeFactor` (`max_values`: None, `max_size`: None, mode: `Measured`) - /// Storage: `XcmPallet::SupportedVersion` (r:1 w:0) - /// Proof: `XcmPallet::SupportedVersion` (`max_values`: None, `max_size`: None, mode: `Measured`) - /// Storage: `Dmp::DownwardMessageQueues` (r:1 w:1) - /// Proof: `Dmp::DownwardMessageQueues` (`max_values`: None, `max_size`: None, mode: `Measured`) - /// Storage: `Dmp::DownwardMessageQueueHeads` (r:1 w:1) - /// Proof: `Dmp::DownwardMessageQueueHeads` (`max_values`: None, `max_size`: None, mode: `Measured`) - pub(crate) fn teleport_assets() -> Weight { - // Proof Size summary in bytes: - // Measured: `250` - // Estimated: `6196` - // Minimum execution time: 130_855_000 picoseconds. - Weight::from_parts(135_315_000, 6196) - .saturating_add(T::DbWeight::get().reads(7)) - .saturating_add(T::DbWeight::get().writes(4)) - } - /// Storage: `XcmPallet::ShouldRecordXcm` (r:1 w:0) - /// Proof: `XcmPallet::ShouldRecordXcm` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) - /// Storage: `System::Account` (r:2 w:2) - /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`) - /// Storage: `Dmp::DeliveryFeeFactor` (r:1 w:0) - /// Proof: `Dmp::DeliveryFeeFactor` (`max_values`: None, `max_size`: None, mode: `Measured`) - /// Storage: `XcmPallet::SupportedVersion` (r:1 w:0) - /// Proof: `XcmPallet::SupportedVersion` (`max_values`: None, `max_size`: None, mode: `Measured`) - /// Storage: `Dmp::DownwardMessageQueues` (r:1 w:1) - /// Proof: `Dmp::DownwardMessageQueues` (`max_values`: None, `max_size`: None, mode: `Measured`) - /// Storage: `Dmp::DownwardMessageQueueHeads` (r:1 w:1) - /// Proof: `Dmp::DownwardMessageQueueHeads` (`max_values`: None, `max_size`: None, mode: `Measured`) - pub(crate) fn reserve_transfer_assets() -> Weight { - // Proof Size summary in bytes: - // Measured: `302` - // Estimated: `6196` - // Minimum execution time: 128_185_000 picoseconds. - Weight::from_parts(132_459_000, 6196) - .saturating_add(T::DbWeight::get().reads(7)) - .saturating_add(T::DbWeight::get().writes(4)) - } - /// Storage: `System::Account` (r:2 w:2) - /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`) - /// Storage: `XcmPallet::ShouldRecordXcm` (r:1 w:0) - /// Proof: `XcmPallet::ShouldRecordXcm` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) - /// Storage: `Dmp::DeliveryFeeFactor` (r:1 w:0) - /// Proof: `Dmp::DeliveryFeeFactor` (`max_values`: None, `max_size`: None, mode: `Measured`) - /// Storage: `XcmPallet::SupportedVersion` (r:1 w:0) - /// Proof: `XcmPallet::SupportedVersion` (`max_values`: None, `max_size`: None, mode: `Measured`) - /// Storage: `Dmp::DownwardMessageQueues` (r:1 w:1) - /// Proof: `Dmp::DownwardMessageQueues` (`max_values`: None, `max_size`: None, mode: `Measured`) - /// Storage: `Dmp::DownwardMessageQueueHeads` (r:1 w:1) - /// Proof: `Dmp::DownwardMessageQueueHeads` (`max_values`: None, `max_size`: None, mode: `Measured`) - pub(crate) fn transfer_assets() -> Weight { - // Proof Size summary in bytes: - // Measured: `250` - // Estimated: `6196` - // Minimum execution time: 132_603_000 picoseconds. - Weight::from_parts(135_485_000, 6196) - .saturating_add(T::DbWeight::get().reads(7)) - .saturating_add(T::DbWeight::get().writes(4)) - } - /// Storage: `XcmPallet::ShouldRecordXcm` (r:1 w:0) - /// Proof: `XcmPallet::ShouldRecordXcm` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) - pub(crate) fn execute() -> Weight { - // Proof Size summary in bytes: - // Measured: `0` - // Estimated: `1485` - // Minimum execution time: 9_227_000 picoseconds. - Weight::from_parts(9_554_000, 1485) - .saturating_add(T::DbWeight::get().reads(1)) - } - /// Storage: `XcmPallet::SupportedVersion` (r:0 w:1) - /// Proof: `XcmPallet::SupportedVersion` (`max_values`: None, `max_size`: None, mode: `Measured`) - pub(crate) fn force_xcm_version() -> Weight { - // Proof Size summary in bytes: - // Measured: `0` - // Estimated: `0` - // Minimum execution time: 8_033_000 picoseconds. - Weight::from_parts(8_269_000, 0) - .saturating_add(T::DbWeight::get().writes(1)) - } - pub(crate) fn force_default_xcm_version() -> Weight { - // Proof Size summary in bytes: - // Measured: `0` - // Estimated: `0` - // Minimum execution time: 2_294_000 picoseconds. - Weight::from_parts(2_445_000, 0) - } - /// Storage: `XcmPallet::VersionNotifiers` (r:1 w:1) - /// Proof: `XcmPallet::VersionNotifiers` (`max_values`: None, `max_size`: None, mode: `Measured`) - /// Storage: `XcmPallet::QueryCounter` (r:1 w:1) - /// Proof: `XcmPallet::QueryCounter` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) - /// Storage: `Dmp::DeliveryFeeFactor` (r:1 w:0) - /// Proof: `Dmp::DeliveryFeeFactor` (`max_values`: None, `max_size`: None, mode: `Measured`) - /// Storage: `XcmPallet::SupportedVersion` (r:1 w:0) - /// Proof: `XcmPallet::SupportedVersion` (`max_values`: None, `max_size`: None, mode: `Measured`) - /// Storage: `Dmp::DownwardMessageQueues` (r:1 w:1) - /// Proof: `Dmp::DownwardMessageQueues` (`max_values`: None, `max_size`: None, mode: `Measured`) - /// Storage: `Dmp::DownwardMessageQueueHeads` (r:1 w:1) - /// Proof: `Dmp::DownwardMessageQueueHeads` (`max_values`: None, `max_size`: None, mode: `Measured`) - /// Storage: `XcmPallet::Queries` (r:0 w:1) - /// Proof: `XcmPallet::Queries` (`max_values`: None, `max_size`: None, mode: `Measured`) - pub(crate) fn force_subscribe_version_notify() -> Weight { - // Proof Size summary in bytes: - // Measured: `147` - // Estimated: `3612` - // Minimum execution time: 36_912_000 picoseconds. - Weight::from_parts(38_677_000, 3612) - .saturating_add(T::DbWeight::get().reads(6)) - .saturating_add(T::DbWeight::get().writes(5)) - } - /// Storage: `XcmPallet::VersionNotifiers` (r:1 w:1) - /// Proof: `XcmPallet::VersionNotifiers` (`max_values`: None, `max_size`: None, mode: `Measured`) - /// Storage: `Dmp::DeliveryFeeFactor` (r:1 w:0) - /// Proof: `Dmp::DeliveryFeeFactor` (`max_values`: None, `max_size`: None, mode: `Measured`) - /// Storage: `XcmPallet::SupportedVersion` (r:1 w:0) - /// Proof: `XcmPallet::SupportedVersion` (`max_values`: None, `max_size`: None, mode: `Measured`) - /// Storage: `Dmp::DownwardMessageQueues` (r:1 w:1) - /// Proof: `Dmp::DownwardMessageQueues` (`max_values`: None, `max_size`: None, mode: `Measured`) - /// Storage: `Dmp::DownwardMessageQueueHeads` (r:1 w:1) - /// Proof: `Dmp::DownwardMessageQueueHeads` (`max_values`: None, `max_size`: None, mode: `Measured`) - /// Storage: `XcmPallet::Queries` (r:0 w:1) - /// Proof: `XcmPallet::Queries` (`max_values`: None, `max_size`: None, mode: `Measured`) - pub(crate) fn force_unsubscribe_version_notify() -> Weight { - // Proof Size summary in bytes: - // Measured: `327` - // Estimated: `3792` - // Minimum execution time: 46_175_000 picoseconds. - Weight::from_parts(47_850_000, 3792) - .saturating_add(T::DbWeight::get().reads(5)) - .saturating_add(T::DbWeight::get().writes(4)) - } - /// Storage: `XcmPallet::XcmExecutionSuspended` (r:0 w:1) - /// Proof: `XcmPallet::XcmExecutionSuspended` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) - pub(crate) fn force_suspension() -> Weight { - // Proof Size summary in bytes: - // Measured: `0` - // Estimated: `0` - // Minimum execution time: 2_328_000 picoseconds. - Weight::from_parts(2_464_000, 0) - .saturating_add(T::DbWeight::get().writes(1)) - } - /// Storage: `XcmPallet::SupportedVersion` (r:6 w:2) - /// Proof: `XcmPallet::SupportedVersion` (`max_values`: None, `max_size`: None, mode: `Measured`) - pub(crate) fn migrate_supported_version() -> Weight { - // Proof Size summary in bytes: - // Measured: `22` - // Estimated: `15862` - // Minimum execution time: 22_130_000 picoseconds. - Weight::from_parts(22_492_000, 15862) - .saturating_add(T::DbWeight::get().reads(6)) - .saturating_add(T::DbWeight::get().writes(2)) - } - /// Storage: `XcmPallet::VersionNotifiers` (r:6 w:2) - /// Proof: `XcmPallet::VersionNotifiers` (`max_values`: None, `max_size`: None, mode: `Measured`) - pub(crate) fn migrate_version_notifiers() -> Weight { - // Proof Size summary in bytes: - // Measured: `26` - // Estimated: `15866` - // Minimum execution time: 22_043_000 picoseconds. - Weight::from_parts(22_750_000, 15866) - .saturating_add(T::DbWeight::get().reads(6)) - .saturating_add(T::DbWeight::get().writes(2)) - } - /// Storage: `XcmPallet::VersionNotifyTargets` (r:7 w:0) - /// Proof: `XcmPallet::VersionNotifyTargets` (`max_values`: None, `max_size`: None, mode: `Measured`) - pub(crate) fn already_notified_target() -> Weight { - // Proof Size summary in bytes: - // Measured: `40` - // Estimated: `18355` - // Minimum execution time: 25_046_000 picoseconds. - Weight::from_parts(25_660_000, 18355) - .saturating_add(T::DbWeight::get().reads(7)) - } - /// Storage: `XcmPallet::VersionNotifyTargets` (r:2 w:1) - /// Proof: `XcmPallet::VersionNotifyTargets` (`max_values`: None, `max_size`: None, mode: `Measured`) - /// Storage: `Dmp::DeliveryFeeFactor` (r:1 w:0) - /// Proof: `Dmp::DeliveryFeeFactor` (`max_values`: None, `max_size`: None, mode: `Measured`) - /// Storage: `XcmPallet::SupportedVersion` (r:1 w:0) - /// Proof: `XcmPallet::SupportedVersion` (`max_values`: None, `max_size`: None, mode: `Measured`) - /// Storage: `Dmp::DownwardMessageQueues` (r:1 w:1) - /// Proof: `Dmp::DownwardMessageQueues` (`max_values`: None, `max_size`: None, mode: `Measured`) - /// Storage: `Dmp::DownwardMessageQueueHeads` (r:1 w:1) - /// Proof: `Dmp::DownwardMessageQueueHeads` (`max_values`: None, `max_size`: None, mode: `Measured`) - pub(crate) fn notify_current_targets() -> Weight { - // Proof Size summary in bytes: - // Measured: `183` - // Estimated: `6123` - // Minimum execution time: 36_029_000 picoseconds. - Weight::from_parts(37_313_000, 6123) - .saturating_add(T::DbWeight::get().reads(6)) - .saturating_add(T::DbWeight::get().writes(3)) - } - /// Storage: `XcmPallet::VersionNotifyTargets` (r:5 w:0) - /// Proof: `XcmPallet::VersionNotifyTargets` (`max_values`: None, `max_size`: None, mode: `Measured`) - pub(crate) fn notify_target_migration_fail() -> Weight { - // Proof Size summary in bytes: - // Measured: `40` - // Estimated: `13405` - // Minimum execution time: 17_295_000 picoseconds. - Weight::from_parts(17_961_000, 13405) - .saturating_add(T::DbWeight::get().reads(5)) - } - /// Storage: `XcmPallet::VersionNotifyTargets` (r:6 w:2) - /// Proof: `XcmPallet::VersionNotifyTargets` (`max_values`: None, `max_size`: None, mode: `Measured`) - pub(crate) fn migrate_version_notify_targets() -> Weight { - // Proof Size summary in bytes: - // Measured: `33` - // Estimated: `15873` - // Minimum execution time: 21_606_000 picoseconds. - Weight::from_parts(21_939_000, 15873) - .saturating_add(T::DbWeight::get().reads(6)) - .saturating_add(T::DbWeight::get().writes(2)) - } - /// Storage: `XcmPallet::VersionNotifyTargets` (r:6 w:2) - /// Proof: `XcmPallet::VersionNotifyTargets` (`max_values`: None, `max_size`: None, mode: `Measured`) - /// Storage: `Dmp::DeliveryFeeFactor` (r:1 w:0) - /// Proof: `Dmp::DeliveryFeeFactor` (`max_values`: None, `max_size`: None, mode: `Measured`) - /// Storage: `XcmPallet::SupportedVersion` (r:1 w:0) - /// Proof: `XcmPallet::SupportedVersion` (`max_values`: None, `max_size`: None, mode: `Measured`) - /// Storage: `Dmp::DownwardMessageQueues` (r:1 w:1) - /// Proof: `Dmp::DownwardMessageQueues` (`max_values`: None, `max_size`: None, mode: `Measured`) - /// Storage: `Dmp::DownwardMessageQueueHeads` (r:1 w:1) - /// Proof: `Dmp::DownwardMessageQueueHeads` (`max_values`: None, `max_size`: None, mode: `Measured`) - pub(crate) fn migrate_and_notify_old_targets() -> Weight { - // Proof Size summary in bytes: - // Measured: `183` - // Estimated: `16023` - // Minimum execution time: 49_623_000 picoseconds. - Weight::from_parts(50_940_000, 16023) - .saturating_add(T::DbWeight::get().reads(10)) - .saturating_add(T::DbWeight::get().writes(4)) - } - /// Storage: `XcmPallet::QueryCounter` (r:1 w:1) - /// Proof: `XcmPallet::QueryCounter` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) - /// Storage: `XcmPallet::Queries` (r:0 w:1) - /// Proof: `XcmPallet::Queries` (`max_values`: None, `max_size`: None, mode: `Measured`) - pub(crate) fn new_query() -> Weight { - // Proof Size summary in bytes: - // Measured: `0` - // Estimated: `1485` - // Minimum execution time: 2_662_000 picoseconds. - Weight::from_parts(2_832_000, 1485) - .saturating_add(T::DbWeight::get().reads(1)) - .saturating_add(T::DbWeight::get().writes(2)) - } - /// Storage: `XcmPallet::Queries` (r:1 w:1) - /// Proof: `XcmPallet::Queries` (`max_values`: None, `max_size`: None, mode: `Measured`) - pub(crate) fn take_response() -> Weight { - // Proof Size summary in bytes: - // Measured: `7576` - // Estimated: `11041` - // Minimum execution time: 26_358_000 picoseconds. - Weight::from_parts(26_871_000, 11041) - .saturating_add(T::DbWeight::get().reads(1)) - .saturating_add(T::DbWeight::get().writes(1)) - } - /// Storage: `XcmPallet::ShouldRecordXcm` (r:1 w:0) - /// Proof: `XcmPallet::ShouldRecordXcm` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) - /// Storage: `XcmPallet::AssetTraps` (r:1 w:1) - /// Proof: `XcmPallet::AssetTraps` (`max_values`: None, `max_size`: None, mode: `Measured`) - pub(crate) fn claim_assets() -> Weight { - // Proof Size summary in bytes: - // Measured: `23` - // Estimated: `3488` - // Minimum execution time: 39_745_000 picoseconds. - Weight::from_parts(40_188_000, 3488) - .saturating_add(T::DbWeight::get().reads(2)) - .saturating_add(T::DbWeight::get().writes(1)) - } - /// Storage: `XcmPallet::AuthorizedAliasesMap` (r:1 w:1) - /// Proof: `XcmPallet::AuthorizedAliasesMap` (`max_values`: None, `max_size`: None, mode: `Measured`) - pub(crate) fn add_authorized_alias() -> Weight { - // Proof Size summary in bytes: - // Measured: `361` - // Estimated: `3826` - // Minimum execution time: 15_726_000 picoseconds. - Weight::from_parts(16_154_000, 3826) - .saturating_add(T::DbWeight::get().reads(1)) - .saturating_add(T::DbWeight::get().writes(1)) - } - /// Storage: `XcmPallet::AuthorizedAliasesMap` (r:1 w:1) - /// Proof: `XcmPallet::AuthorizedAliasesMap` (`max_values`: None, `max_size`: None, mode: `Measured`) - pub(crate) fn remove_authorized_alias() -> Weight { - // Proof Size summary in bytes: - // Measured: `400` - // Estimated: `3865` - // Minimum execution time: 17_404_000 picoseconds. - Weight::from_parts(17_718_000, 3865) - .saturating_add(T::DbWeight::get().reads(1)) - .saturating_add(T::DbWeight::get().writes(1)) - } -} From 61c822433a4f655dc34e65294cfa49861a46f64a Mon Sep 17 00:00:00 2001 From: Francisco Aguirre Date: Thu, 7 Nov 2024 18:17:23 -0300 Subject: [PATCH 15/40] Update polkadot/xcm/pallet-xcm/src/benchmarking.rs --- polkadot/xcm/pallet-xcm/src/benchmarking.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/polkadot/xcm/pallet-xcm/src/benchmarking.rs b/polkadot/xcm/pallet-xcm/src/benchmarking.rs index e858edf29d29..034b4508c744 100644 --- a/polkadot/xcm/pallet-xcm/src/benchmarking.rs +++ b/polkadot/xcm/pallet-xcm/src/benchmarking.rs @@ -412,7 +412,7 @@ benchmarks! { existing_aliases.try_push(alias).unwrap() } AuthorizedAliasesMap::::insert(&origin_location, existing_aliases); - // now benchmark adding new alias + // now benchmark removing an alias let aliaser_to_remove: VersionedLocation = Location::new(1, [Parachain(1), AccountId32 { network: None, id: [42_u8; 32] }]).into(); }: _(origin, Box::new(aliaser_to_remove)) From 9d59105661978586d428d9708f640c20b00f91d1 Mon Sep 17 00:00:00 2001 From: Francisco Aguirre Date: Thu, 7 Nov 2024 18:17:35 -0300 Subject: [PATCH 16/40] Update polkadot/xcm/pallet-xcm/src/lib.rs --- polkadot/xcm/pallet-xcm/src/lib.rs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/polkadot/xcm/pallet-xcm/src/lib.rs b/polkadot/xcm/pallet-xcm/src/lib.rs index 9ded29527334..b15cf3e47aaa 100644 --- a/polkadot/xcm/pallet-xcm/src/lib.rs +++ b/polkadot/xcm/pallet-xcm/src/lib.rs @@ -1470,14 +1470,14 @@ pub mod pallet { let aliaser: Location = (*aliaser).try_into().map_err(|()| Error::::BadVersion)?; tracing::debug!(target: "xcm::pallet_xcm::add_authorized_alias", ?origin, ?aliaser); ensure!(origin != aliaser, Error::::BadLocation); - let v_origin = VersionedLocation::from(origin); - let v_aliaser = VersionedLocation::from(aliaser); - let mut authorized_aliases = AuthorizedAliasesMap::::get(&v_origin); - if !authorized_aliases.contains(&v_aliaser) { + let versioned_origin = VersionedLocation::from(origin); + let versioned_aliaser = VersionedLocation::from(aliaser); + let mut authorized_aliases = AuthorizedAliasesMap::::get(&versioned_origin); + if !authorized_aliases.contains(&versioned_aliaser) { authorized_aliases - .try_push(v_aliaser) + .try_push(versioned_aliaser) .map_err(|_| Error::::TooManyAuthorizedAliases)?; - AuthorizedAliasesMap::::insert(&v_origin, authorized_aliases); + AuthorizedAliasesMap::::insert(&versioned_origin, authorized_aliases); } Ok(()) } From 1b647db5880a405a2834dc0c457294236fb31ebc Mon Sep 17 00:00:00 2001 From: Francisco Aguirre Date: Thu, 7 Nov 2024 18:17:45 -0300 Subject: [PATCH 17/40] Update polkadot/xcm/pallet-xcm/src/lib.rs --- polkadot/xcm/pallet-xcm/src/lib.rs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/polkadot/xcm/pallet-xcm/src/lib.rs b/polkadot/xcm/pallet-xcm/src/lib.rs index b15cf3e47aaa..2a201557245c 100644 --- a/polkadot/xcm/pallet-xcm/src/lib.rs +++ b/polkadot/xcm/pallet-xcm/src/lib.rs @@ -1493,13 +1493,13 @@ pub mod pallet { let to_remove: Location = (*aliaser).try_into().map_err(|()| Error::::BadVersion)?; tracing::debug!(target: "xcm::pallet_xcm::add_authorized_alias", ?origin, ?to_remove); ensure!(origin != to_remove, Error::::BadLocation); - let v_origin = VersionedLocation::from(origin); - let v_to_remove = VersionedLocation::from(to_remove); - let mut authorized_aliases = AuthorizedAliasesMap::::get(&v_origin); + let versioned_origin = VersionedLocation::from(origin); + let versioned_to_remove = VersionedLocation::from(to_remove); + let mut authorized_aliases = AuthorizedAliasesMap::::get(&versioned_origin); let original_length = authorized_aliases.len(); - authorized_aliases.retain(|alias| v_to_remove.ne(alias)); + authorized_aliases.retain(|alias| versioned_to_remove.ne(alias)); if original_length != authorized_aliases.len() { - AuthorizedAliasesMap::::insert(&v_origin, authorized_aliases); + AuthorizedAliasesMap::::insert(&versioned_origin, authorized_aliases); } Ok(()) } From 7b58df8f7ee7c70e74dc0fb5fc235ab61bdc9a2d Mon Sep 17 00:00:00 2001 From: Francisco Aguirre Date: Thu, 7 Nov 2024 18:20:17 -0300 Subject: [PATCH 18/40] chore: change new_version to XCM_VERSION --- polkadot/xcm/pallet-xcm/src/migration.rs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/polkadot/xcm/pallet-xcm/src/migration.rs b/polkadot/xcm/pallet-xcm/src/migration.rs index 64b35bd8566d..aee5cde6dfe3 100644 --- a/polkadot/xcm/pallet-xcm/src/migration.rs +++ b/polkadot/xcm/pallet-xcm/src/migration.rs @@ -179,13 +179,13 @@ pub mod data { self.1.iter().any(|alias| alias.identify_version() < XCM_VERSION) } - fn try_migrate(self, new_version: XcmVersion) -> Result, ()> { - if !self.needs_migration(new_version) { + fn try_migrate(self, _: XcmVersion) -> Result, ()> { + if !self.needs_migration(XCM_VERSION) { return Ok(None) } - let key = if self.0.identify_version() < new_version { - let Ok(converted_key) = self.0.clone().into_version(new_version) else { + let key = if self.0.identify_version() < XCM_VERSION { + let Ok(converted_key) = self.0.clone().into_version(XCM_VERSION) else { return Err(()) }; converted_key @@ -195,8 +195,8 @@ pub mod data { let mut aliases = BoundedVec::::new(); for alias in self.1 { if aliases - .try_push(if alias.identify_version() < new_version { - let Ok(new_alias) = alias.clone().into_version(new_version) else { + .try_push(if alias.identify_version() < XCM_VERSION { + let Ok(new_alias) = alias.clone().into_version(XCM_VERSION) else { return Err(()) }; new_alias From c239f8dd6f6a034b64dcbcdc8c039569d9787761 Mon Sep 17 00:00:00 2001 From: Adrian Catangiu Date: Mon, 11 Nov 2024 20:01:18 +0200 Subject: [PATCH 19/40] rename vars --- .../asset-hub-rococo/src/weights/pallet_xcm.rs | 8 ++++---- .../src/weights/pallet_xcm.rs | 8 ++++---- .../assets/asset-hub-westend/src/xcm_config.rs | 4 ++-- .../src/weights/pallet_xcm.rs | 8 ++++---- .../src/weights/pallet_xcm.rs | 8 ++++---- .../src/weights/pallet_xcm.rs | 8 ++++---- .../coretime-rococo/src/weights/pallet_xcm.rs | 8 ++++---- .../coretime-westend/src/weights/pallet_xcm.rs | 8 ++++---- .../people-rococo/src/weights/pallet_xcm.rs | 8 ++++---- .../people-westend/src/weights/pallet_xcm.rs | 8 ++++---- .../runtime/rococo/src/weights/pallet_xcm.rs | 8 ++++---- .../runtime/westend/src/weights/pallet_xcm.rs | 8 ++++---- polkadot/xcm/pallet-xcm/src/benchmarking.rs | 4 ++-- polkadot/xcm/pallet-xcm/src/lib.rs | 18 +++++++++--------- polkadot/xcm/pallet-xcm/src/migration.rs | 14 +++++++------- prdoc/pr_6336.prdoc | 4 ++-- 16 files changed, 66 insertions(+), 66 deletions(-) diff --git a/cumulus/parachains/runtimes/assets/asset-hub-rococo/src/weights/pallet_xcm.rs b/cumulus/parachains/runtimes/assets/asset-hub-rococo/src/weights/pallet_xcm.rs index b39a4440f308..b05fd39fa9d0 100644 --- a/cumulus/parachains/runtimes/assets/asset-hub-rococo/src/weights/pallet_xcm.rs +++ b/cumulus/parachains/runtimes/assets/asset-hub-rococo/src/weights/pallet_xcm.rs @@ -48,8 +48,8 @@ use core::marker::PhantomData; /// Weight functions for `pallet_xcm`. pub struct WeightInfo(PhantomData); impl pallet_xcm::WeightInfo for WeightInfo { - /// Storage: `PolkadotXcm::AuthorizedAliasesMap` (r:1 w:1) - /// Proof: `PolkadotXcm::AuthorizedAliasesMap` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `PolkadotXcm::AuthorizedAliases` (r:1 w:1) + /// Proof: `PolkadotXcm::AuthorizedAliases` (`max_values`: None, `max_size`: None, mode: `Measured`) fn add_authorized_alias() -> Weight { // Proof Size summary in bytes: // Measured: `498` @@ -59,8 +59,8 @@ impl pallet_xcm::WeightInfo for WeightInfo { .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(1)) } - /// Storage: `PolkadotXcm::AuthorizedAliasesMap` (r:1 w:1) - /// Proof: `PolkadotXcm::AuthorizedAliasesMap` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `PolkadotXcm::AuthorizedAliases` (r:1 w:1) + /// Proof: `PolkadotXcm::AuthorizedAliases` (`max_values`: None, `max_size`: None, mode: `Measured`) fn remove_authorized_alias() -> Weight { // Proof Size summary in bytes: // Measured: `537` diff --git a/cumulus/parachains/runtimes/assets/asset-hub-westend/src/weights/pallet_xcm.rs b/cumulus/parachains/runtimes/assets/asset-hub-westend/src/weights/pallet_xcm.rs index d10a348abcdf..65943a0d6bc2 100644 --- a/cumulus/parachains/runtimes/assets/asset-hub-westend/src/weights/pallet_xcm.rs +++ b/cumulus/parachains/runtimes/assets/asset-hub-westend/src/weights/pallet_xcm.rs @@ -48,8 +48,8 @@ use core::marker::PhantomData; /// Weight functions for `pallet_xcm`. pub struct WeightInfo(PhantomData); impl pallet_xcm::WeightInfo for WeightInfo { - /// Storage: `PolkadotXcm::AuthorizedAliasesMap` (r:1 w:1) - /// Proof: `PolkadotXcm::AuthorizedAliasesMap` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `PolkadotXcm::AuthorizedAliases` (r:1 w:1) + /// Proof: `PolkadotXcm::AuthorizedAliases` (`max_values`: None, `max_size`: None, mode: `Measured`) fn add_authorized_alias() -> Weight { // Proof Size summary in bytes: // Measured: `498` @@ -59,8 +59,8 @@ impl pallet_xcm::WeightInfo for WeightInfo { .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(1)) } - /// Storage: `PolkadotXcm::AuthorizedAliasesMap` (r:1 w:1) - /// Proof: `PolkadotXcm::AuthorizedAliasesMap` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `PolkadotXcm::AuthorizedAliases` (r:1 w:1) + /// Proof: `PolkadotXcm::AuthorizedAliases` (`max_values`: None, `max_size`: None, mode: `Measured`) fn remove_authorized_alias() -> Weight { // Proof Size summary in bytes: // Measured: `537` diff --git a/cumulus/parachains/runtimes/assets/asset-hub-westend/src/xcm_config.rs b/cumulus/parachains/runtimes/assets/asset-hub-westend/src/xcm_config.rs index fa4040f461b7..647356fd2bec 100644 --- a/cumulus/parachains/runtimes/assets/asset-hub-westend/src/xcm_config.rs +++ b/cumulus/parachains/runtimes/assets/asset-hub-westend/src/xcm_config.rs @@ -32,7 +32,7 @@ use frame_support::{ }, }; use frame_system::EnsureRoot; -use pallet_xcm::{AuthorizedAliases, XcmPassthrough}; +use pallet_xcm::{AuthorizedAliasers, XcmPassthrough}; use parachains_common::{ xcm_config::{ AllSiblingSystemParachains, AssetFeeAsExistentialDepositMultiplier, @@ -357,7 +357,7 @@ pub type TrustedTeleporters = ( /// /// - Allow any origin to alias into a child sub-location (equivalent to DescendOrigin), /// - Allow origins explicitly authorized by the alias target location. -pub type TrustedAliasers = (AliasChildLocation, AuthorizedAliases); +pub type TrustedAliasers = (AliasChildLocation, AuthorizedAliasers); /// Asset converter for pool assets. /// Used to convert one asset to another, when there is a pool available between the two. diff --git a/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/weights/pallet_xcm.rs b/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/weights/pallet_xcm.rs index 12ff328ca2cb..ce572fa16356 100644 --- a/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/weights/pallet_xcm.rs +++ b/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/weights/pallet_xcm.rs @@ -48,8 +48,8 @@ use core::marker::PhantomData; /// Weight functions for `pallet_xcm`. pub struct WeightInfo(PhantomData); impl pallet_xcm::WeightInfo for WeightInfo { - /// Storage: `PolkadotXcm::AuthorizedAliasesMap` (r:1 w:1) - /// Proof: `PolkadotXcm::AuthorizedAliasesMap` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `PolkadotXcm::AuthorizedAliases` (r:1 w:1) + /// Proof: `PolkadotXcm::AuthorizedAliases` (`max_values`: None, `max_size`: None, mode: `Measured`) fn add_authorized_alias() -> Weight { // Proof Size summary in bytes: // Measured: `498` @@ -59,8 +59,8 @@ impl pallet_xcm::WeightInfo for WeightInfo { .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(1)) } - /// Storage: `PolkadotXcm::AuthorizedAliasesMap` (r:1 w:1) - /// Proof: `PolkadotXcm::AuthorizedAliasesMap` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `PolkadotXcm::AuthorizedAliases` (r:1 w:1) + /// Proof: `PolkadotXcm::AuthorizedAliases` (`max_values`: None, `max_size`: None, mode: `Measured`) fn remove_authorized_alias() -> Weight { // Proof Size summary in bytes: // Measured: `537` diff --git a/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-westend/src/weights/pallet_xcm.rs b/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-westend/src/weights/pallet_xcm.rs index 48ba7656ac71..19ecbfb5727e 100644 --- a/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-westend/src/weights/pallet_xcm.rs +++ b/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-westend/src/weights/pallet_xcm.rs @@ -48,8 +48,8 @@ use core::marker::PhantomData; /// Weight functions for `pallet_xcm`. pub struct WeightInfo(PhantomData); impl pallet_xcm::WeightInfo for WeightInfo { - /// Storage: `PolkadotXcm::AuthorizedAliasesMap` (r:1 w:1) - /// Proof: `PolkadotXcm::AuthorizedAliasesMap` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `PolkadotXcm::AuthorizedAliases` (r:1 w:1) + /// Proof: `PolkadotXcm::AuthorizedAliases` (`max_values`: None, `max_size`: None, mode: `Measured`) fn add_authorized_alias() -> Weight { // Proof Size summary in bytes: // Measured: `498` @@ -59,8 +59,8 @@ impl pallet_xcm::WeightInfo for WeightInfo { .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(1)) } - /// Storage: `PolkadotXcm::AuthorizedAliasesMap` (r:1 w:1) - /// Proof: `PolkadotXcm::AuthorizedAliasesMap` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `PolkadotXcm::AuthorizedAliases` (r:1 w:1) + /// Proof: `PolkadotXcm::AuthorizedAliases` (`max_values`: None, `max_size`: None, mode: `Measured`) fn remove_authorized_alias() -> Weight { // Proof Size summary in bytes: // Measured: `537` diff --git a/cumulus/parachains/runtimes/collectives/collectives-westend/src/weights/pallet_xcm.rs b/cumulus/parachains/runtimes/collectives/collectives-westend/src/weights/pallet_xcm.rs index c9b597050ca8..043710b0d7ab 100644 --- a/cumulus/parachains/runtimes/collectives/collectives-westend/src/weights/pallet_xcm.rs +++ b/cumulus/parachains/runtimes/collectives/collectives-westend/src/weights/pallet_xcm.rs @@ -48,8 +48,8 @@ use core::marker::PhantomData; /// Weight functions for `pallet_xcm`. pub struct WeightInfo(PhantomData); impl pallet_xcm::WeightInfo for WeightInfo { - /// Storage: `PolkadotXcm::AuthorizedAliasesMap` (r:1 w:1) - /// Proof: `PolkadotXcm::AuthorizedAliasesMap` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `PolkadotXcm::AuthorizedAliases` (r:1 w:1) + /// Proof: `PolkadotXcm::AuthorizedAliases` (`max_values`: None, `max_size`: None, mode: `Measured`) fn add_authorized_alias() -> Weight { // Proof Size summary in bytes: // Measured: `498` @@ -59,8 +59,8 @@ impl pallet_xcm::WeightInfo for WeightInfo { .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(1)) } - /// Storage: `PolkadotXcm::AuthorizedAliasesMap` (r:1 w:1) - /// Proof: `PolkadotXcm::AuthorizedAliasesMap` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `PolkadotXcm::AuthorizedAliases` (r:1 w:1) + /// Proof: `PolkadotXcm::AuthorizedAliases` (`max_values`: None, `max_size`: None, mode: `Measured`) fn remove_authorized_alias() -> Weight { // Proof Size summary in bytes: // Measured: `537` diff --git a/cumulus/parachains/runtimes/coretime/coretime-rococo/src/weights/pallet_xcm.rs b/cumulus/parachains/runtimes/coretime/coretime-rococo/src/weights/pallet_xcm.rs index 9b05842003bd..9997422961fd 100644 --- a/cumulus/parachains/runtimes/coretime/coretime-rococo/src/weights/pallet_xcm.rs +++ b/cumulus/parachains/runtimes/coretime/coretime-rococo/src/weights/pallet_xcm.rs @@ -48,8 +48,8 @@ use core::marker::PhantomData; /// Weight functions for `pallet_xcm`. pub struct WeightInfo(PhantomData); impl pallet_xcm::WeightInfo for WeightInfo { - /// Storage: `PolkadotXcm::AuthorizedAliasesMap` (r:1 w:1) - /// Proof: `PolkadotXcm::AuthorizedAliasesMap` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `PolkadotXcm::AuthorizedAliases` (r:1 w:1) + /// Proof: `PolkadotXcm::AuthorizedAliases` (`max_values`: None, `max_size`: None, mode: `Measured`) fn add_authorized_alias() -> Weight { // Proof Size summary in bytes: // Measured: `498` @@ -59,8 +59,8 @@ impl pallet_xcm::WeightInfo for WeightInfo { .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(1)) } - /// Storage: `PolkadotXcm::AuthorizedAliasesMap` (r:1 w:1) - /// Proof: `PolkadotXcm::AuthorizedAliasesMap` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `PolkadotXcm::AuthorizedAliases` (r:1 w:1) + /// Proof: `PolkadotXcm::AuthorizedAliases` (`max_values`: None, `max_size`: None, mode: `Measured`) fn remove_authorized_alias() -> Weight { // Proof Size summary in bytes: // Measured: `537` diff --git a/cumulus/parachains/runtimes/coretime/coretime-westend/src/weights/pallet_xcm.rs b/cumulus/parachains/runtimes/coretime/coretime-westend/src/weights/pallet_xcm.rs index 16010d08b7b4..42ef5c2b4071 100644 --- a/cumulus/parachains/runtimes/coretime/coretime-westend/src/weights/pallet_xcm.rs +++ b/cumulus/parachains/runtimes/coretime/coretime-westend/src/weights/pallet_xcm.rs @@ -48,8 +48,8 @@ use core::marker::PhantomData; /// Weight functions for `pallet_xcm`. pub struct WeightInfo(PhantomData); impl pallet_xcm::WeightInfo for WeightInfo { - /// Storage: `PolkadotXcm::AuthorizedAliasesMap` (r:1 w:1) - /// Proof: `PolkadotXcm::AuthorizedAliasesMap` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `PolkadotXcm::AuthorizedAliases` (r:1 w:1) + /// Proof: `PolkadotXcm::AuthorizedAliases` (`max_values`: None, `max_size`: None, mode: `Measured`) fn add_authorized_alias() -> Weight { // Proof Size summary in bytes: // Measured: `498` @@ -59,8 +59,8 @@ impl pallet_xcm::WeightInfo for WeightInfo { .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(1)) } - /// Storage: `PolkadotXcm::AuthorizedAliasesMap` (r:1 w:1) - /// Proof: `PolkadotXcm::AuthorizedAliasesMap` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `PolkadotXcm::AuthorizedAliases` (r:1 w:1) + /// Proof: `PolkadotXcm::AuthorizedAliases` (`max_values`: None, `max_size`: None, mode: `Measured`) fn remove_authorized_alias() -> Weight { // Proof Size summary in bytes: // Measured: `537` diff --git a/cumulus/parachains/runtimes/people/people-rococo/src/weights/pallet_xcm.rs b/cumulus/parachains/runtimes/people/people-rococo/src/weights/pallet_xcm.rs index 9868db381cbf..5a9c069c2e07 100644 --- a/cumulus/parachains/runtimes/people/people-rococo/src/weights/pallet_xcm.rs +++ b/cumulus/parachains/runtimes/people/people-rococo/src/weights/pallet_xcm.rs @@ -48,8 +48,8 @@ use core::marker::PhantomData; /// Weight functions for `pallet_xcm`. pub struct WeightInfo(PhantomData); impl pallet_xcm::WeightInfo for WeightInfo { - /// Storage: `PolkadotXcm::AuthorizedAliasesMap` (r:1 w:1) - /// Proof: `PolkadotXcm::AuthorizedAliasesMap` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `PolkadotXcm::AuthorizedAliases` (r:1 w:1) + /// Proof: `PolkadotXcm::AuthorizedAliases` (`max_values`: None, `max_size`: None, mode: `Measured`) fn add_authorized_alias() -> Weight { // Proof Size summary in bytes: // Measured: `498` @@ -59,8 +59,8 @@ impl pallet_xcm::WeightInfo for WeightInfo { .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(1)) } - /// Storage: `PolkadotXcm::AuthorizedAliasesMap` (r:1 w:1) - /// Proof: `PolkadotXcm::AuthorizedAliasesMap` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `PolkadotXcm::AuthorizedAliases` (r:1 w:1) + /// Proof: `PolkadotXcm::AuthorizedAliases` (`max_values`: None, `max_size`: None, mode: `Measured`) fn remove_authorized_alias() -> Weight { // Proof Size summary in bytes: // Measured: `537` diff --git a/cumulus/parachains/runtimes/people/people-westend/src/weights/pallet_xcm.rs b/cumulus/parachains/runtimes/people/people-westend/src/weights/pallet_xcm.rs index 636152779906..5307360e2713 100644 --- a/cumulus/parachains/runtimes/people/people-westend/src/weights/pallet_xcm.rs +++ b/cumulus/parachains/runtimes/people/people-westend/src/weights/pallet_xcm.rs @@ -48,8 +48,8 @@ use core::marker::PhantomData; /// Weight functions for `pallet_xcm`. pub struct WeightInfo(PhantomData); impl pallet_xcm::WeightInfo for WeightInfo { - /// Storage: `PolkadotXcm::AuthorizedAliasesMap` (r:1 w:1) - /// Proof: `PolkadotXcm::AuthorizedAliasesMap` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `PolkadotXcm::AuthorizedAliases` (r:1 w:1) + /// Proof: `PolkadotXcm::AuthorizedAliases` (`max_values`: None, `max_size`: None, mode: `Measured`) fn add_authorized_alias() -> Weight { // Proof Size summary in bytes: // Measured: `498` @@ -59,8 +59,8 @@ impl pallet_xcm::WeightInfo for WeightInfo { .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(1)) } - /// Storage: `PolkadotXcm::AuthorizedAliasesMap` (r:1 w:1) - /// Proof: `PolkadotXcm::AuthorizedAliasesMap` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `PolkadotXcm::AuthorizedAliases` (r:1 w:1) + /// Proof: `PolkadotXcm::AuthorizedAliases` (`max_values`: None, `max_size`: None, mode: `Measured`) fn remove_authorized_alias() -> Weight { // Proof Size summary in bytes: // Measured: `537` diff --git a/polkadot/runtime/rococo/src/weights/pallet_xcm.rs b/polkadot/runtime/rococo/src/weights/pallet_xcm.rs index 5849b8806b1e..06ebd68a19c5 100644 --- a/polkadot/runtime/rococo/src/weights/pallet_xcm.rs +++ b/polkadot/runtime/rococo/src/weights/pallet_xcm.rs @@ -348,8 +348,8 @@ impl pallet_xcm::WeightInfo for WeightInfo { .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(1)) } - /// Storage: `XcmPallet::AuthorizedAliasesMap` (r:1 w:1) - /// Proof: `XcmPallet::AuthorizedAliasesMap` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `XcmPallet::AuthorizedAliases` (r:1 w:1) + /// Proof: `XcmPallet::AuthorizedAliases` (`max_values`: None, `max_size`: None, mode: `Measured`) fn add_authorized_alias() -> Weight { // Proof Size summary in bytes: // Measured: `361` @@ -359,8 +359,8 @@ impl pallet_xcm::WeightInfo for WeightInfo { .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(1)) } - /// Storage: `XcmPallet::AuthorizedAliasesMap` (r:1 w:1) - /// Proof: `XcmPallet::AuthorizedAliasesMap` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `XcmPallet::AuthorizedAliases` (r:1 w:1) + /// Proof: `XcmPallet::AuthorizedAliases` (`max_values`: None, `max_size`: None, mode: `Measured`) fn remove_authorized_alias() -> Weight { // Proof Size summary in bytes: // Measured: `400` diff --git a/polkadot/runtime/westend/src/weights/pallet_xcm.rs b/polkadot/runtime/westend/src/weights/pallet_xcm.rs index 0032dfaa3b64..aaeb0438520e 100644 --- a/polkadot/runtime/westend/src/weights/pallet_xcm.rs +++ b/polkadot/runtime/westend/src/weights/pallet_xcm.rs @@ -348,8 +348,8 @@ impl pallet_xcm::WeightInfo for WeightInfo { .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(1)) } - /// Storage: `XcmPallet::AuthorizedAliasesMap` (r:1 w:1) - /// Proof: `XcmPallet::AuthorizedAliasesMap` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `XcmPallet::AuthorizedAliases` (r:1 w:1) + /// Proof: `XcmPallet::AuthorizedAliases` (`max_values`: None, `max_size`: None, mode: `Measured`) fn add_authorized_alias() -> Weight { // Proof Size summary in bytes: // Measured: `361` @@ -359,8 +359,8 @@ impl pallet_xcm::WeightInfo for WeightInfo { .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(1)) } - /// Storage: `XcmPallet::AuthorizedAliasesMap` (r:1 w:1) - /// Proof: `XcmPallet::AuthorizedAliasesMap` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `XcmPallet::AuthorizedAliases` (r:1 w:1) + /// Proof: `XcmPallet::AuthorizedAliases` (`max_values`: None, `max_size`: None, mode: `Measured`) fn remove_authorized_alias() -> Weight { // Proof Size summary in bytes: // Measured: `400` diff --git a/polkadot/xcm/pallet-xcm/src/benchmarking.rs b/polkadot/xcm/pallet-xcm/src/benchmarking.rs index 034b4508c744..69d710a35d4b 100644 --- a/polkadot/xcm/pallet-xcm/src/benchmarking.rs +++ b/polkadot/xcm/pallet-xcm/src/benchmarking.rs @@ -395,7 +395,7 @@ benchmarks! { let alias = Location::new(1, [Parachain(i), AccountId32 { network: None, id: [42_u8; 32] }]).into(); existing_aliases.try_push(alias).unwrap() } - AuthorizedAliasesMap::::insert(&origin_location, existing_aliases); + AuthorizedAliases::::insert(&origin_location, existing_aliases); // now benchmark adding new alias let aliaser: VersionedLocation = Location::new(1, [Parachain(1234), AccountId32 { network: None, id: [42_u8; 32] }]).into(); @@ -411,7 +411,7 @@ benchmarks! { let alias = Location::new(1, [Parachain(i), AccountId32 { network: None, id: [42_u8; 32] }]).into(); existing_aliases.try_push(alias).unwrap() } - AuthorizedAliasesMap::::insert(&origin_location, existing_aliases); + AuthorizedAliases::::insert(&origin_location, existing_aliases); // now benchmark removing an alias let aliaser_to_remove: VersionedLocation = Location::new(1, [Parachain(1), AccountId32 { network: None, id: [42_u8; 32] }]).into(); diff --git a/polkadot/xcm/pallet-xcm/src/lib.rs b/polkadot/xcm/pallet-xcm/src/lib.rs index 135f98cddc52..8b4ba937fec6 100644 --- a/polkadot/xcm/pallet-xcm/src/lib.rs +++ b/polkadot/xcm/pallet-xcm/src/lib.rs @@ -813,7 +813,7 @@ pub mod pallet { /// Map of authorized aliasers of local origins. Each local location can authorize a list of /// other locations to alias into it. #[pallet::storage] - pub(super) type AuthorizedAliasesMap = StorageMap< + pub(super) type AuthorizedAliases = StorageMap< _, Blake2_128Concat, VersionedLocation, @@ -1473,12 +1473,12 @@ pub mod pallet { ensure!(origin != aliaser, Error::::BadLocation); let versioned_origin = VersionedLocation::from(origin); let versioned_aliaser = VersionedLocation::from(aliaser); - let mut authorized_aliases = AuthorizedAliasesMap::::get(&versioned_origin); + let mut authorized_aliases = AuthorizedAliases::::get(&versioned_origin); if !authorized_aliases.contains(&versioned_aliaser) { authorized_aliases .try_push(versioned_aliaser) .map_err(|_| Error::::TooManyAuthorizedAliases)?; - AuthorizedAliasesMap::::insert(&versioned_origin, authorized_aliases); + AuthorizedAliases::::insert(&versioned_origin, authorized_aliases); } Ok(()) } @@ -1496,11 +1496,11 @@ pub mod pallet { ensure!(origin != to_remove, Error::::BadLocation); let versioned_origin = VersionedLocation::from(origin); let versioned_to_remove = VersionedLocation::from(to_remove); - let mut authorized_aliases = AuthorizedAliasesMap::::get(&versioned_origin); + let mut authorized_aliases = AuthorizedAliases::::get(&versioned_origin); let original_length = authorized_aliases.len(); authorized_aliases.retain(|alias| versioned_to_remove.ne(alias)); if original_length != authorized_aliases.len() { - AuthorizedAliasesMap::::insert(&versioned_origin, authorized_aliases); + AuthorizedAliases::::insert(&versioned_origin, authorized_aliases); } Ok(()) } @@ -3513,13 +3513,13 @@ where /// /// Note: users can authorize other locations to alias them by using /// `pallet_xcm::add_authorized_alias()`. -pub struct AuthorizedAliases(PhantomData); -impl + Clone, T: Config> ContainsPair for AuthorizedAliases { +pub struct AuthorizedAliasers(PhantomData); +impl + Clone, T: Config> ContainsPair for AuthorizedAliasers { fn contains(origin: &L, target: &L) -> bool { let origin: VersionedLocation = origin.clone().into(); let target: VersionedLocation = target.clone().into(); - tracing::trace!(target: "xcm::pallet_xcm::AuthorizedAliases::contains", ?origin, ?target); - AuthorizedAliasesMap::::get(&target).contains(&origin) + tracing::trace!(target: "xcm::pallet_xcm::AuthorizedAliasers::contains", ?origin, ?target); + AuthorizedAliases::::get(&target).contains(&origin) } } diff --git a/polkadot/xcm/pallet-xcm/src/migration.rs b/polkadot/xcm/pallet-xcm/src/migration.rs index aee5cde6dfe3..fafef2b23d86 100644 --- a/polkadot/xcm/pallet-xcm/src/migration.rs +++ b/polkadot/xcm/pallet-xcm/src/migration.rs @@ -170,7 +170,7 @@ pub mod data { } } - /// Implementation of `NeedsMigration` for `AuthorizedAliasesMap` data. + /// Implementation of `NeedsMigration` for `AuthorizedAliases` data. impl> NeedsMigration for (&VersionedLocation, &BoundedVec) { type MigratedData = (VersionedLocation, BoundedVec); @@ -367,8 +367,8 @@ pub mod data { weight.saturating_add(T::DbWeight::get().writes(1)); } - // check and migrate `AuthorizedAliasesMap` - let aliases_to_migrate = AuthorizedAliasesMap::::iter().filter_map(|(id, data)| { + // check and migrate `AuthorizedAliases` + let aliases_to_migrate = AuthorizedAliases::::iter().filter_map(|(id, data)| { weight.saturating_add(T::DbWeight::get().reads(1)); match (&id, &data).try_migrate(required_xcm_version) { Ok(Some((new_id, new_data))) => Some((id, new_id, new_data)), @@ -379,7 +379,7 @@ pub mod data { ?id, ?data, ?required_xcm_version, - "`AuthorizedAliasesMap` cannot be migrated!" + "`AuthorizedAliases` cannot be migrated!" ); None }, @@ -391,10 +391,10 @@ pub mod data { target: LOG_TARGET, ?new_id, ?new_data, - "Migrating `AuthorizedAliasesMap`" + "Migrating `AuthorizedAliases`" ); - AuthorizedAliasesMap::::remove(old_id); - AuthorizedAliasesMap::::insert(new_id, new_data); + AuthorizedAliases::::remove(old_id); + AuthorizedAliases::::insert(new_id, new_data); count = count + 1; } // two writes per key, one to remove old entry, one to write new entry diff --git a/prdoc/pr_6336.prdoc b/prdoc/pr_6336.prdoc index dec27cf18f22..5edf7ed01b22 100644 --- a/prdoc/pr_6336.prdoc +++ b/prdoc/pr_6336.prdoc @@ -16,9 +16,9 @@ doc: - audience: Runtime Dev description: | - Added `AuthorizedAliases` type exposed by `pallet-xcm`, that acts as a filter for explicitly authorized + Added `AuthorizedAliasers` type exposed by `pallet-xcm`, that acts as a filter for explicitly authorized aliases using `pallet-xcm::add_authorized_alias()` and `pallet-xcm::remove_authorized_alias()`. - Runtime developers can simply plug this `pallet-xcm::AuthorizedAliases` type in their runtime's `XcmConfig`, + Runtime developers can simply plug this `pallet-xcm::AuthorizedAliasers` type in their runtime's `XcmConfig`, specifically in `::Aliasers`. crates: From a606607344f688aeed2912bffbf233654cadc6f0 Mon Sep 17 00:00:00 2001 From: Adrian Catangiu Date: Tue, 12 Nov 2024 14:27:01 +0200 Subject: [PATCH 20/40] pallet-xcm: add expiry to authorized aliases --- .../assets/asset-hub-westend/tests/tests.rs | 6 +- polkadot/xcm/pallet-xcm/src/benchmarking.rs | 26 ++--- polkadot/xcm/pallet-xcm/src/lib.rs | 97 ++++++++++++++++--- polkadot/xcm/pallet-xcm/src/migration.rs | 42 ++++---- polkadot/xcm/pallet-xcm/src/tests/mod.rs | 4 +- 5 files changed, 126 insertions(+), 49 deletions(-) diff --git a/cumulus/parachains/runtimes/assets/asset-hub-westend/tests/tests.rs b/cumulus/parachains/runtimes/assets/asset-hub-westend/tests/tests.rs index 23bec5016832..e64a365ca5bd 100644 --- a/cumulus/parachains/runtimes/assets/asset-hub-westend/tests/tests.rs +++ b/cumulus/parachains/runtimes/assets/asset-hub-westend/tests/tests.rs @@ -987,7 +987,8 @@ fn authorized_aliases_work() { // Alice explicitly authorizes `alice_on_sibling_para` to alias her local account assert_ok!(PolkadotXcm::add_authorized_alias( RuntimeHelper::origin_of(alice.clone()), - Box::new(alice_on_sibling_para.clone().into()) + Box::new(alice_on_sibling_para.clone().into()), + None )); // `alice_on_sibling_para` now explicitly allowed to alias into `local_alice` @@ -1006,7 +1007,8 @@ fn authorized_aliases_work() { // Alice explicitly authorizes `alice_on_relay` to alias her local account assert_ok!(PolkadotXcm::add_authorized_alias( RuntimeHelper::origin_of(alice.clone()), - Box::new(alice_on_relay.clone().into()) + Box::new(alice_on_relay.clone().into()), + None )); // Now both `alice_on_relay` and `alice_on_sibling_para` can alias into her local // account diff --git a/polkadot/xcm/pallet-xcm/src/benchmarking.rs b/polkadot/xcm/pallet-xcm/src/benchmarking.rs index 69d710a35d4b..0e0f50e7cc7d 100644 --- a/polkadot/xcm/pallet-xcm/src/benchmarking.rs +++ b/polkadot/xcm/pallet-xcm/src/benchmarking.rs @@ -276,7 +276,7 @@ benchmarks! { let loc = VersionedLocation::from(Location::from(Parent)); SupportedVersion::::insert(old_version, loc, old_version); }: { - crate::Pallet::::check_xcm_version_change(VersionMigrationStage::MigrateSupportedVersion, Weight::zero()); + crate::Pallet::::lazy_migration(VersionMigrationStage::MigrateSupportedVersion, Weight::zero()); } migrate_version_notifiers { @@ -284,7 +284,7 @@ benchmarks! { let loc = VersionedLocation::from(Location::from(Parent)); VersionNotifiers::::insert(old_version, loc, 0); }: { - crate::Pallet::::check_xcm_version_change(VersionMigrationStage::MigrateVersionNotifiers, Weight::zero()); + crate::Pallet::::lazy_migration(VersionMigrationStage::MigrateVersionNotifiers, Weight::zero()); } already_notified_target { @@ -295,7 +295,7 @@ benchmarks! { let current_version = T::AdvertisedXcmVersion::get(); VersionNotifyTargets::::insert(current_version, loc, (0, Weight::zero(), current_version)); }: { - crate::Pallet::::check_xcm_version_change(VersionMigrationStage::NotifyCurrentTargets(None), Weight::zero()); + crate::Pallet::::lazy_migration(VersionMigrationStage::NotifyCurrentTargets(None), Weight::zero()); } notify_current_targets { @@ -307,7 +307,7 @@ benchmarks! { let old_version = current_version - 1; VersionNotifyTargets::::insert(current_version, loc, (0, Weight::zero(), old_version)); }: { - crate::Pallet::::check_xcm_version_change(VersionMigrationStage::NotifyCurrentTargets(None), Weight::zero()); + crate::Pallet::::lazy_migration(VersionMigrationStage::NotifyCurrentTargets(None), Weight::zero()); } notify_target_migration_fail { @@ -323,7 +323,7 @@ benchmarks! { let current_version = T::AdvertisedXcmVersion::get(); VersionNotifyTargets::::insert(current_version, bad_location, (0, Weight::zero(), current_version)); }: { - crate::Pallet::::check_xcm_version_change(VersionMigrationStage::MigrateAndNotifyOldTargets, Weight::zero()); + crate::Pallet::::lazy_migration(VersionMigrationStage::MigrateAndNotifyOldTargets, Weight::zero()); } migrate_version_notify_targets { @@ -332,7 +332,7 @@ benchmarks! { let loc = VersionedLocation::from(Location::from(Parent)); VersionNotifyTargets::::insert(old_version, loc, (0, Weight::zero(), current_version)); }: { - crate::Pallet::::check_xcm_version_change(VersionMigrationStage::MigrateAndNotifyOldTargets, Weight::zero()); + crate::Pallet::::lazy_migration(VersionMigrationStage::MigrateAndNotifyOldTargets, Weight::zero()); } migrate_and_notify_old_targets { @@ -343,7 +343,7 @@ benchmarks! { let old_version = T::AdvertisedXcmVersion::get() - 1; VersionNotifyTargets::::insert(old_version, loc, (0, Weight::zero(), old_version)); }: { - crate::Pallet::::check_xcm_version_change(VersionMigrationStage::MigrateAndNotifyOldTargets, Weight::zero()); + crate::Pallet::::lazy_migration(VersionMigrationStage::MigrateAndNotifyOldTargets, Weight::zero()); } new_query { @@ -389,27 +389,29 @@ benchmarks! { let origin = RawOrigin::Root; let origin_location: VersionedLocation = T::ExecuteXcmOrigin::try_origin(origin.clone().into()) .map_err(|_| BenchmarkError::Override(BenchmarkResult::from_weight(Weight::MAX)))?.into(); - let mut existing_aliases = BoundedVec::::new(); + let mut existing_aliases = BoundedVec::::new(); // prepopulate list with `max-1` aliases to benchmark worst case for i in 1..MaxAuthorizedAliases::get() { let alias = Location::new(1, [Parachain(i), AccountId32 { network: None, id: [42_u8; 32] }]).into(); - existing_aliases.try_push(alias).unwrap() + let aliaser = OriginAliaser { location: alias, expiry: None }; + existing_aliases.try_push(aliaser).unwrap() } AuthorizedAliases::::insert(&origin_location, existing_aliases); // now benchmark adding new alias let aliaser: VersionedLocation = Location::new(1, [Parachain(1234), AccountId32 { network: None, id: [42_u8; 32] }]).into(); - }: _(origin, Box::new(aliaser)) + }: _(origin, Box::new(aliaser), None) remove_authorized_alias { let origin = RawOrigin::Root; let origin_location: VersionedLocation = T::ExecuteXcmOrigin::try_origin(origin.clone().into()) .map_err(|_| BenchmarkError::Override(BenchmarkResult::from_weight(Weight::MAX)))?.into(); - let mut existing_aliases = BoundedVec::::new(); + let mut existing_aliases = BoundedVec::::new(); // prepopulate list with `max` aliases to benchmark worst case for i in 1..MaxAuthorizedAliases::get()+1 { let alias = Location::new(1, [Parachain(i), AccountId32 { network: None, id: [42_u8; 32] }]).into(); - existing_aliases.try_push(alias).unwrap() + let aliaser = OriginAliaser { location: alias, expiry: None }; + existing_aliases.try_push(aliaser).unwrap() } AuthorizedAliases::::insert(&origin_location, existing_aliases); // now benchmark removing an alias diff --git a/polkadot/xcm/pallet-xcm/src/lib.rs b/polkadot/xcm/pallet-xcm/src/lib.rs index 8b4ba937fec6..167c4e20f1c6 100644 --- a/polkadot/xcm/pallet-xcm/src/lib.rs +++ b/polkadot/xcm/pallet-xcm/src/lib.rs @@ -51,7 +51,7 @@ use sp_runtime::{ AccountIdConversion, BadOrigin, BlakeTwo256, BlockNumberProvider, Dispatchable, Hash, Saturating, Zero, }, - Either, RuntimeDebug, + Either, RuntimeDebug, SaturatedConversion, }; use xcm::{latest::QueryResponseInfo, prelude::*}; use xcm_builder::{ @@ -591,6 +591,9 @@ pub mod pallet { /// Too many locations authorized to alias origin. #[codec(index = 25)] TooManyAuthorizedAliases, + /// Expiry block number is in the past. + #[codec(index = 26)] + ExpiresInPast, } impl From for Error { @@ -649,6 +652,15 @@ pub mod pallet { MigrateVersionNotifiers, NotifyCurrentTargets(Option>), MigrateAndNotifyOldTargets, + RemoveExpiredAliasAuthorizations, + } + + /// Entry of an authorized aliaser for a local origin. The aliaser `location` is only authorized + /// until its inner `expiry` block number. + #[derive(Clone, Encode, Decode, Debug, Eq, PartialEq, Ord, PartialOrd, TypeInfo)] + pub(crate) struct OriginAliaser { + pub(crate) location: VersionedLocation, + pub(crate) expiry: Option, } impl Default for VersionMigrationStage { @@ -811,13 +823,14 @@ pub mod pallet { pub(crate) type RecordedXcm = StorageValue<_, Xcm<()>>; /// Map of authorized aliasers of local origins. Each local location can authorize a list of - /// other locations to alias into it. + /// other locations to alias into it. Each aliaser is only valid until its inner `expiry` + /// block number. #[pallet::storage] pub(super) type AuthorizedAliases = StorageMap< _, Blake2_128Concat, VersionedLocation, - BoundedVec, + BoundedVec, ValueQuery, >; @@ -849,7 +862,7 @@ pub mod pallet { if let Some(migration) = CurrentMigration::::get() { // Consume 10% of block at most let max_weight = T::BlockWeights::get().max_block / 10; - let (w, maybe_migration) = Self::check_xcm_version_change(migration, max_weight); + let (w, maybe_migration) = Self::lazy_migration(migration, max_weight); if maybe_migration.is_none() { Self::deposit_event(Event::VersionMigrationFinished { version: XCM_VERSION }); } @@ -1455,6 +1468,7 @@ pub mod pallet { } /// Authorize another `aliaser` location to alias into the local `origin` making this call. + /// The `aliaser` is only authorized until the provided `expiry` block number. /// /// Usually useful to allow your local account to be aliased into from a remote location /// also under your control (like your account on another chain). @@ -1466,20 +1480,42 @@ pub mod pallet { pub fn add_authorized_alias( origin: OriginFor, aliaser: Box, + expires: Option, ) -> DispatchResult { let origin: Location = T::ExecuteXcmOrigin::ensure_origin(origin)?; let aliaser: Location = (*aliaser).try_into().map_err(|()| Error::::BadVersion)?; - tracing::debug!(target: "xcm::pallet_xcm::add_authorized_alias", ?origin, ?aliaser); + tracing::debug!(target: "xcm::pallet_xcm::add_authorized_alias", ?origin, ?aliaser, ?expires); ensure!(origin != aliaser, Error::::BadLocation); + if let Some(expiry) = expires { + ensure!( + expiry > frame_system::Pallet::::block_number().saturated_into::(), + Error::::ExpiresInPast + ); + } let versioned_origin = VersionedLocation::from(origin); let versioned_aliaser = VersionedLocation::from(aliaser); let mut authorized_aliases = AuthorizedAliases::::get(&versioned_origin); - if !authorized_aliases.contains(&versioned_aliaser) { + if authorized_aliases + .iter_mut() + .find_map(|aliaser| { + // if the aliaser already exists, just update its expiry block + if aliaser.location == versioned_aliaser { + aliaser.expiry = expires; + Some(()) + } else { + None + } + }) + .is_none() + { + // if the aliaser does not yet exist, add it to the list + let aliaser = OriginAliaser { location: versioned_aliaser, expiry: expires }; authorized_aliases - .try_push(versioned_aliaser) + .try_push(aliaser) .map_err(|_| Error::::TooManyAuthorizedAliases)?; - AuthorizedAliases::::insert(&versioned_origin, authorized_aliases); + // todo: hold storage deposit } + AuthorizedAliases::::insert(&versioned_origin, authorized_aliases); Ok(()) } @@ -1498,8 +1534,11 @@ pub mod pallet { let versioned_to_remove = VersionedLocation::from(to_remove); let mut authorized_aliases = AuthorizedAliases::::get(&versioned_origin); let original_length = authorized_aliases.len(); - authorized_aliases.retain(|alias| versioned_to_remove.ne(alias)); - if original_length != authorized_aliases.len() { + authorized_aliases.retain(|alias| versioned_to_remove.ne(&alias.location)); + if authorized_aliases.is_empty() { + // todo: return storage deposit + AuthorizedAliases::::remove(&versioned_origin); + } else if original_length != authorized_aliases.len() { AuthorizedAliases::::insert(&versioned_origin, authorized_aliases); } Ok(()) @@ -2342,7 +2381,7 @@ impl Pallet { /// Will always make progress, and will do its best not to use much more than `weight_cutoff` /// in doing so. - pub(crate) fn check_xcm_version_change( + pub(crate) fn lazy_migration( mut stage: VersionMigrationStage, weight_cutoff: Weight, ) -> (Weight, Option) { @@ -2495,6 +2534,29 @@ impl Pallet { } } } + stage = RemoveExpiredAliasAuthorizations; + } + if stage == RemoveExpiredAliasAuthorizations { + let block_num = frame_system::Pallet::::block_number().saturated_into::(); + let mut writes = 0; + // need to iterate keys and modify map in separate steps to avoid undefined behavior + let keys: Vec = AuthorizedAliases::::iter_keys().collect(); + weight_used.saturating_add(T::DbWeight::get().reads(keys.len() as u64)); + for key in keys { + let mut aliases = AuthorizedAliases::::get(&key); + let old_len = aliases.len(); + aliases.retain(|aliaser| { + aliaser.expiry.map(|expiry| expiry > block_num).unwrap_or(true) + }); + if aliases.is_empty() { + AuthorizedAliases::::remove(&key); + writes = writes + 1; + } else if aliases.len() != old_len { + AuthorizedAliases::::insert(key, aliases); + writes = writes + 1; + } + } + weight_used.saturating_add(T::DbWeight::get().writes(writes)); } (weight_used, None) } @@ -3519,7 +3581,18 @@ impl + Clone, T: Config> ContainsPair for Autho let origin: VersionedLocation = origin.clone().into(); let target: VersionedLocation = target.clone().into(); tracing::trace!(target: "xcm::pallet_xcm::AuthorizedAliasers::contains", ?origin, ?target); - AuthorizedAliases::::get(&target).contains(&origin) + // return true if the `origin` has been explicitly authorized by `target` as aliaser, and + // the authorization has not expired + AuthorizedAliases::::get(&target) + .iter() + .find(|&aliaser| { + let current_block = + frame_system::Pallet::::block_number().saturated_into::(); + let not_expired = + aliaser.expiry.map(|expiry| expiry < current_block).unwrap_or(true); + aliaser.location == origin && not_expired + }) + .is_some() } } diff --git a/polkadot/xcm/pallet-xcm/src/migration.rs b/polkadot/xcm/pallet-xcm/src/migration.rs index fafef2b23d86..82df2870e117 100644 --- a/polkadot/xcm/pallet-xcm/src/migration.rs +++ b/polkadot/xcm/pallet-xcm/src/migration.rs @@ -171,12 +171,14 @@ pub mod data { } /// Implementation of `NeedsMigration` for `AuthorizedAliases` data. - impl> NeedsMigration for (&VersionedLocation, &BoundedVec) { - type MigratedData = (VersionedLocation, BoundedVec); + impl, T: frame_system::Config> NeedsMigration + for (&VersionedLocation, &BoundedVec, PhantomData) + { + type MigratedData = (VersionedLocation, BoundedVec); fn needs_migration(&self, _: XcmVersion) -> bool { self.0.identify_version() < XCM_VERSION || - self.1.iter().any(|alias| alias.identify_version() < XCM_VERSION) + self.1.iter().any(|alias| alias.location.identify_version() < XCM_VERSION) } fn try_migrate(self, _: XcmVersion) -> Result, ()> { @@ -184,6 +186,7 @@ pub mod data { return Ok(None) } + let block_num = frame_system::Pallet::::block_number().saturated_into::(); let key = if self.0.identify_version() < XCM_VERSION { let Ok(converted_key) = self.0.clone().into_version(XCM_VERSION) else { return Err(()) @@ -192,24 +195,19 @@ pub mod data { } else { self.0.clone() }; - let mut aliases = BoundedVec::::new(); + let mut new_aliases = BoundedVec::::new(); for alias in self.1 { - if aliases - .try_push(if alias.identify_version() < XCM_VERSION { - let Ok(new_alias) = alias.clone().into_version(XCM_VERSION) else { - return Err(()) - }; - new_alias - } else { - alias.clone() - }) - .is_err() - { - return Err(()) - }; + // skip expired aliases + if alias.expiry.map(|expiry| expiry <= block_num).unwrap_or(false) { + continue + } + let OriginAliaser { mut location, expiry } = alias.clone(); + if location.identify_version() < XCM_VERSION { + location = location.into_version(XCM_VERSION)?; + } + new_aliases.try_push(OriginAliaser { location, expiry }).map_err(|_| ())?; } - - Ok(Some((key, aliases))) + Ok(Some((key, new_aliases))) } } @@ -370,7 +368,7 @@ pub mod data { // check and migrate `AuthorizedAliases` let aliases_to_migrate = AuthorizedAliases::::iter().filter_map(|(id, data)| { weight.saturating_add(T::DbWeight::get().reads(1)); - match (&id, &data).try_migrate(required_xcm_version) { + match (&id, &data, PhantomData::).try_migrate(required_xcm_version) { Ok(Some((new_id, new_data))) => Some((id, new_id, new_data)), Ok(None) => None, Err(_) => { @@ -394,7 +392,9 @@ pub mod data { "Migrating `AuthorizedAliases`" ); AuthorizedAliases::::remove(old_id); - AuthorizedAliases::::insert(new_id, new_data); + if !new_data.is_empty() { + AuthorizedAliases::::insert(new_id, new_data); + } count = count + 1; } // two writes per key, one to remove old entry, one to write new entry diff --git a/polkadot/xcm/pallet-xcm/src/tests/mod.rs b/polkadot/xcm/pallet-xcm/src/tests/mod.rs index 350530f7711f..9dd42999774f 100644 --- a/polkadot/xcm/pallet-xcm/src/tests/mod.rs +++ b/polkadot/xcm/pallet-xcm/src/tests/mod.rs @@ -1058,7 +1058,7 @@ fn subscription_side_upgrades_work_with_multistage_notify() { let mut counter = 0; while let Some(migration) = maybe_migration.take() { counter += 1; - let (_, m) = XcmPallet::check_xcm_version_change(migration, Weight::zero()); + let (_, m) = XcmPallet::lazy_migration(migration, Weight::zero()); maybe_migration = m; } assert_eq!(counter, 4); @@ -1211,7 +1211,7 @@ fn multistage_migration_works() { let mut weight_used = Weight::zero(); while let Some(migration) = maybe_migration.take() { counter += 1; - let (w, m) = XcmPallet::check_xcm_version_change(migration, Weight::zero()); + let (w, m) = XcmPallet::lazy_migration(migration, Weight::zero()); maybe_migration = m; weight_used.saturating_accrue(w); } From b7ef64ca902d4eb5d67fc823652251ab42134c65 Mon Sep 17 00:00:00 2001 From: Adrian Catangiu Date: Tue, 12 Nov 2024 20:24:06 +0200 Subject: [PATCH 21/40] pallet-xcm: add storage deposit for authorized aliases --- .../asset-hub-westend/src/xcm_config.rs | 21 +- polkadot/xcm/pallet-xcm/src/benchmarking.rs | 30 ++- polkadot/xcm/pallet-xcm/src/lib.rs | 189 ++++++++++++------ polkadot/xcm/pallet-xcm/src/migration.rs | 30 ++- polkadot/xcm/pallet-xcm/src/mock.rs | 19 +- 5 files changed, 194 insertions(+), 95 deletions(-) diff --git a/cumulus/parachains/runtimes/assets/asset-hub-westend/src/xcm_config.rs b/cumulus/parachains/runtimes/assets/asset-hub-westend/src/xcm_config.rs index 647356fd2bec..34aa50bcb029 100644 --- a/cumulus/parachains/runtimes/assets/asset-hub-westend/src/xcm_config.rs +++ b/cumulus/parachains/runtimes/assets/asset-hub-westend/src/xcm_config.rs @@ -15,10 +15,10 @@ use super::{ AccountId, AllPalletsWithSystem, Assets, Authorship, Balance, Balances, BaseDeliveryFee, - CollatorSelection, FeeAssetId, ForeignAssets, ForeignAssetsInstance, ParachainInfo, - ParachainSystem, PolkadotXcm, PoolAssets, Runtime, RuntimeCall, RuntimeEvent, RuntimeOrigin, - ToRococoXcmRouter, TransactionByteFee, TrustBackedAssetsInstance, Uniques, WeightToFee, - XcmpQueue, + CollatorSelection, DepositPerByte, DepositPerItem, FeeAssetId, ForeignAssets, + ForeignAssetsInstance, ParachainInfo, ParachainSystem, PolkadotXcm, PoolAssets, Runtime, + RuntimeCall, RuntimeEvent, RuntimeHoldReason, RuntimeOrigin, ToRococoXcmRouter, + TransactionByteFee, TrustBackedAssetsInstance, Uniques, WeightToFee, XcmpQueue, }; use assets_common::{ matching::{FromSiblingParachain, IsForeignConcreteAsset, ParentLocation}, @@ -27,8 +27,9 @@ use assets_common::{ use frame_support::{ parameter_types, traits::{ + fungible::HoldConsideration, tokens::imbalance::{ResolveAssetTo, ResolveTo}, - ConstU32, Contains, Equals, Everything, PalletInfoAccess, + ConstU32, Contains, Equals, Everything, LinearStoragePrice, PalletInfoAccess, }, }; use frame_system::EnsureRoot; @@ -510,6 +511,10 @@ pub type XcmRouter = WithUniqueTopic<( >, )>; +parameter_types! { + pub const AuthorizeAliasHoldReason: RuntimeHoldReason = RuntimeHoldReason::PolkadotXcm(pallet_xcm::HoldReason::AuthorizeAlias); +} + impl pallet_xcm::Config for Runtime { type RuntimeEvent = RuntimeEvent; type SendXcmOrigin = EnsureXcmOrigin; @@ -538,6 +543,12 @@ impl pallet_xcm::Config for Runtime { type AdminOrigin = EnsureRoot; type MaxRemoteLockConsumers = ConstU32<0>; type RemoteLockConsumerIdentifier = (); + type Consideration = HoldConsideration< + AccountId, + Balances, + AuthorizeAliasHoldReason, + LinearStoragePrice, + >; } impl cumulus_pallet_xcm::Config for Runtime { diff --git a/polkadot/xcm/pallet-xcm/src/benchmarking.rs b/polkadot/xcm/pallet-xcm/src/benchmarking.rs index 0e0f50e7cc7d..77555abfcb2e 100644 --- a/polkadot/xcm/pallet-xcm/src/benchmarking.rs +++ b/polkadot/xcm/pallet-xcm/src/benchmarking.rs @@ -28,7 +28,7 @@ type RuntimeOrigin = ::RuntimeOrigin; pub struct Pallet(crate::Pallet); /// Trait that must be implemented by runtime to be able to benchmark pallet properly. -pub trait Config: crate::Config { +pub trait Config: crate::Config + pallet_balances::Config { /// Helper that ensures successful delivery for extrinsics/benchmarks which need `SendXcm`. type DeliveryHelper: EnsureDelivery; @@ -386,9 +386,16 @@ benchmarks! { }: _>(claim_origin.into(), Box::new(versioned_assets), Box::new(VersionedLocation::from(claim_location))) add_authorized_alias { - let origin = RawOrigin::Root; + let who: T::AccountId = whitelisted_caller(); + let origin = RawOrigin::Signed(who.clone()); let origin_location: VersionedLocation = T::ExecuteXcmOrigin::try_origin(origin.clone().into()) .map_err(|_| BenchmarkError::Override(BenchmarkResult::from_weight(Weight::MAX)))?.into(); + + // Give some multiple of ED + let balance = T::ExistentialDeposit::get() * 10u32.into(); + let _ = + as frame_support::traits::Currency<_>>::make_free_balance_be(&who, balance); + let mut existing_aliases = BoundedVec::::new(); // prepopulate list with `max-1` aliases to benchmark worst case for i in 1..MaxAuthorizedAliases::get() { @@ -396,16 +403,26 @@ benchmarks! { let aliaser = OriginAliaser { location: alias, expiry: None }; existing_aliases.try_push(aliaser).unwrap() } - AuthorizedAliases::::insert(&origin_location, existing_aliases); + let ticket = TicketOf::::new(&who, aliasers_footprint(existing_aliases.len())).unwrap(); + let entry = AuthorizedAliasesEntry { aliasers: existing_aliases, ticket }; + AuthorizedAliases::::insert(&origin_location, entry); + // now benchmark adding new alias let aliaser: VersionedLocation = Location::new(1, [Parachain(1234), AccountId32 { network: None, id: [42_u8; 32] }]).into(); }: _(origin, Box::new(aliaser), None) remove_authorized_alias { - let origin = RawOrigin::Root; + let who: T::AccountId = whitelisted_caller(); + let origin = RawOrigin::Signed(who.clone()); let origin_location: VersionedLocation = T::ExecuteXcmOrigin::try_origin(origin.clone().into()) .map_err(|_| BenchmarkError::Override(BenchmarkResult::from_weight(Weight::MAX)))?.into(); + + // Give some multiple of ED + let balance = T::ExistentialDeposit::get() * 10u32.into(); + let _ = + as frame_support::traits::Currency<_>>::make_free_balance_be(&who, balance); + let mut existing_aliases = BoundedVec::::new(); // prepopulate list with `max` aliases to benchmark worst case for i in 1..MaxAuthorizedAliases::get()+1 { @@ -413,7 +430,10 @@ benchmarks! { let aliaser = OriginAliaser { location: alias, expiry: None }; existing_aliases.try_push(aliaser).unwrap() } - AuthorizedAliases::::insert(&origin_location, existing_aliases); + let ticket = TicketOf::::new(&who, aliasers_footprint(existing_aliases.len())).unwrap(); + let entry = AuthorizedAliasesEntry { aliasers: existing_aliases, ticket }; + AuthorizedAliases::::insert(&origin_location, entry); + // now benchmark removing an alias let aliaser_to_remove: VersionedLocation = Location::new(1, [Parachain(1), AccountId32 { network: None, id: [42_u8; 32] }]).into(); diff --git a/polkadot/xcm/pallet-xcm/src/lib.rs b/polkadot/xcm/pallet-xcm/src/lib.rs index 167c4e20f1c6..7f24d143477d 100644 --- a/polkadot/xcm/pallet-xcm/src/lib.rs +++ b/polkadot/xcm/pallet-xcm/src/lib.rs @@ -38,8 +38,8 @@ use frame_support::{ }, pallet_prelude::*, traits::{ - Contains, ContainsPair, Currency, Defensive, EnsureOrigin, Get, LockableCurrency, - OriginTrait, WithdrawReasons, + Consideration, Contains, ContainsPair, Currency, Defensive, EnsureOrigin, Footprint, Get, + LockableCurrency, OriginTrait, WithdrawReasons, }, PalletId, }; @@ -194,6 +194,24 @@ impl WeightInfo for TestWeightInfo { } } +/// Entry of an authorized aliaser for a local origin. The aliaser `location` is only authorized +/// until its inner `expiry` block number. +#[derive(Clone, Debug, Encode, Decode, MaxEncodedLen, TypeInfo)] +pub(crate) struct OriginAliaser { + pub(crate) location: VersionedLocation, + pub(crate) expiry: Option, +} + +#[derive(Clone, Debug, Encode, Decode, MaxEncodedLen, TypeInfo)] +pub(crate) struct AuthorizedAliasesEntry> { + pub(crate) aliasers: BoundedVec, + pub(crate) ticket: Ticket, +} + +pub(crate) fn aliasers_footprint(aliasers_count: usize) -> Footprint { + Footprint::from_parts(aliasers_count, OriginAliaser::max_encoded_len()) +} + #[frame_support::pallet] pub mod pallet { use super::*; @@ -211,6 +229,7 @@ pub mod pallet { /// support. pub const CurrentXcmVersion: u32 = XCM_VERSION; + #[derive(Debug, TypeInfo)] /// The maximum number of distinct locations allowed as authorized aliases for a local origin. pub const MaxAuthorizedAliases: u32 = 10; } @@ -224,6 +243,7 @@ pub mod pallet { pub type BalanceOf = <::Currency as Currency<::AccountId>>::Balance; + pub type TicketOf = ::Consideration; #[pallet::config] /// The module configuration trait. @@ -238,6 +258,9 @@ pub mod pallet { /// The `Asset` matcher for `Currency`. type CurrencyMatcher: MatchesFungible>; + /// A means of providing some cost while data is stored on-chain. + type Consideration: Consideration; + /// Required origin for sending XCM messages. If successful, it resolves to `Location` /// which exists as an interior location within this chain's XCM context. type SendXcmOrigin: EnsureOrigin<::RuntimeOrigin, Success = Location>; @@ -531,6 +554,13 @@ pub mod pallet { } } + /// A reason for this pallet placing a hold on funds. + #[pallet::composite_enum] + pub enum HoldReason { + /// The funds are held as storage deposit for an authorized alias. + AuthorizeAlias, + } + #[pallet::error] pub enum Error { /// The desired destination was unreachable, generally because there is a no way of routing @@ -615,7 +645,7 @@ pub mod pallet { } /// The status of a query. - #[derive(Clone, Eq, PartialEq, Encode, Decode, RuntimeDebug, TypeInfo)] + #[derive(Clone, Eq, PartialEq, Encode, Decode, RuntimeDebug, TypeInfo, MaxEncodedLen)] pub enum QueryStatus { /// The query was sent but no response has yet been received. Pending { @@ -655,14 +685,6 @@ pub mod pallet { RemoveExpiredAliasAuthorizations, } - /// Entry of an authorized aliaser for a local origin. The aliaser `location` is only authorized - /// until its inner `expiry` block number. - #[derive(Clone, Encode, Decode, Debug, Eq, PartialEq, Ord, PartialOrd, TypeInfo)] - pub(crate) struct OriginAliaser { - pub(crate) location: VersionedLocation, - pub(crate) expiry: Option, - } - impl Default for VersionMigrationStage { fn default() -> Self { Self::MigrateSupportedVersion @@ -830,8 +852,8 @@ pub mod pallet { _, Blake2_128Concat, VersionedLocation, - BoundedVec, - ValueQuery, + AuthorizedAliasesEntry, MaxAuthorizedAliases>, + OptionQuery, >; #[pallet::genesis_config] @@ -1482,40 +1504,47 @@ pub mod pallet { aliaser: Box, expires: Option, ) -> DispatchResult { - let origin: Location = T::ExecuteXcmOrigin::ensure_origin(origin)?; + let signed_origin = ensure_signed(origin.clone())?; + let origin_location: Location = T::ExecuteXcmOrigin::ensure_origin(origin)?; let aliaser: Location = (*aliaser).try_into().map_err(|()| Error::::BadVersion)?; - tracing::debug!(target: "xcm::pallet_xcm::add_authorized_alias", ?origin, ?aliaser, ?expires); - ensure!(origin != aliaser, Error::::BadLocation); + tracing::debug!(target: "xcm::pallet_xcm::add_authorized_alias", ?origin_location, ?aliaser, ?expires); + ensure!(origin_location != aliaser, Error::::BadLocation); if let Some(expiry) = expires { ensure!( expiry > frame_system::Pallet::::block_number().saturated_into::(), Error::::ExpiresInPast ); } - let versioned_origin = VersionedLocation::from(origin); + let versioned_origin = VersionedLocation::from(origin_location); let versioned_aliaser = VersionedLocation::from(aliaser); - let mut authorized_aliases = AuthorizedAliases::::get(&versioned_origin); - if authorized_aliases - .iter_mut() - .find_map(|aliaser| { + + let entry = if let Some(entry) = AuthorizedAliases::::get(&versioned_origin) { + // entry already exists, update it + let (mut aliasers, mut ticket) = (entry.aliasers, entry.ticket); + if let Some(aliaser) = + aliasers.iter_mut().find(|aliaser| aliaser.location == versioned_aliaser) + { // if the aliaser already exists, just update its expiry block - if aliaser.location == versioned_aliaser { - aliaser.expiry = expires; - Some(()) - } else { - None - } - }) - .is_none() - { - // if the aliaser does not yet exist, add it to the list + aliaser.expiry = expires; + } else { + // if it doesn't, we try to add it + let aliaser = OriginAliaser { location: versioned_aliaser, expiry: expires }; + aliasers.try_push(aliaser).map_err(|_| Error::::TooManyAuthorizedAliases)?; + // we try to update the ticket (the storage deposit) + ticket = ticket.update(&signed_origin, aliasers_footprint(aliasers.len()))?; + } + AuthorizedAliasesEntry { aliasers, ticket } + } else { + // add new entry with its first alias + let ticket = TicketOf::::new(&signed_origin, aliasers_footprint(1))?; let aliaser = OriginAliaser { location: versioned_aliaser, expiry: expires }; - authorized_aliases - .try_push(aliaser) - .map_err(|_| Error::::TooManyAuthorizedAliases)?; - // todo: hold storage deposit - } - AuthorizedAliases::::insert(&versioned_origin, authorized_aliases); + let mut aliasers = BoundedVec::::new(); + aliasers.try_push(aliaser).map_err(|_| Error::::TooManyAuthorizedAliases)?; + AuthorizedAliasesEntry { aliasers, ticket } + }; + + // write to storage + AuthorizedAliases::::insert(&versioned_origin, entry); Ok(()) } @@ -1526,20 +1555,28 @@ pub mod pallet { origin: OriginFor, aliaser: Box, ) -> DispatchResult { - let origin: Location = T::ExecuteXcmOrigin::ensure_origin(origin)?; + let signed_origin = ensure_signed(origin.clone())?; + let origin_location: Location = T::ExecuteXcmOrigin::ensure_origin(origin)?; let to_remove: Location = (*aliaser).try_into().map_err(|()| Error::::BadVersion)?; - tracing::debug!(target: "xcm::pallet_xcm::add_authorized_alias", ?origin, ?to_remove); - ensure!(origin != to_remove, Error::::BadLocation); - let versioned_origin = VersionedLocation::from(origin); + tracing::debug!(target: "xcm::pallet_xcm::add_authorized_alias", ?origin_location, ?to_remove); + ensure!(origin_location != to_remove, Error::::BadLocation); + let versioned_origin = VersionedLocation::from(origin_location); let versioned_to_remove = VersionedLocation::from(to_remove); - let mut authorized_aliases = AuthorizedAliases::::get(&versioned_origin); - let original_length = authorized_aliases.len(); - authorized_aliases.retain(|alias| versioned_to_remove.ne(&alias.location)); - if authorized_aliases.is_empty() { - // todo: return storage deposit - AuthorizedAliases::::remove(&versioned_origin); - } else if original_length != authorized_aliases.len() { - AuthorizedAliases::::insert(&versioned_origin, authorized_aliases); + if let Some(entry) = AuthorizedAliases::::get(&versioned_origin) { + let (mut aliasers, mut ticket) = (entry.aliasers, entry.ticket); + let old_len = aliasers.len(); + aliasers.retain(|alias| versioned_to_remove.ne(&alias.location)); + let new_len = aliasers.len(); + if new_len > 0 { + // remove entry altogether and return all storage deposit + ticket.drop(&signed_origin)?; + AuthorizedAliases::::remove(&versioned_origin); + } else if old_len != new_len { + // update aliasers and storage deposit + ticket = ticket.update(&signed_origin, aliasers_footprint(new_len))?; + let entry = AuthorizedAliasesEntry { aliasers, ticket }; + AuthorizedAliases::::insert(&versioned_origin, entry); + } } Ok(()) } @@ -2543,17 +2580,32 @@ impl Pallet { let keys: Vec = AuthorizedAliases::::iter_keys().collect(); weight_used.saturating_add(T::DbWeight::get().reads(keys.len() as u64)); for key in keys { - let mut aliases = AuthorizedAliases::::get(&key); - let old_len = aliases.len(); - aliases.retain(|aliaser| { - aliaser.expiry.map(|expiry| expiry > block_num).unwrap_or(true) - }); - if aliases.is_empty() { - AuthorizedAliases::::remove(&key); - writes = writes + 1; - } else if aliases.len() != old_len { - AuthorizedAliases::::insert(key, aliases); - writes = writes + 1; + if let Some(entry) = AuthorizedAliases::::get(&key) { + let (mut aliases, ticket) = (entry.aliasers, entry.ticket); + let Some(who) = Location::try_from(key.clone()) + .ok() + .and_then(|key| T::SovereignAccountOf::convert_location(&key)) + else { + continue + }; + let old_len = aliases.len(); + aliases.retain(|aliaser| { + aliaser.expiry.map(|expiry| expiry > block_num).unwrap_or(true) + }); + let new_len = aliases.len(); + if new_len > 0 { + // remove entry altogether and return all storage deposit + let _ = ticket.drop(&who); + AuthorizedAliases::::remove(&key); + writes = writes + 2; + } else if old_len != new_len { + // update aliasers and storage deposit + if let Ok(ticket) = ticket.update(&who, aliasers_footprint(new_len)) { + let entry = AuthorizedAliasesEntry { aliasers: aliases, ticket }; + AuthorizedAliases::::insert(&key, entry); + writes = writes + 2; + } + } } } weight_used.saturating_add(T::DbWeight::get().writes(writes)); @@ -3584,15 +3636,20 @@ impl + Clone, T: Config> ContainsPair for Autho // return true if the `origin` has been explicitly authorized by `target` as aliaser, and // the authorization has not expired AuthorizedAliases::::get(&target) - .iter() - .find(|&aliaser| { + .map(|authorized| { let current_block = frame_system::Pallet::::block_number().saturated_into::(); - let not_expired = - aliaser.expiry.map(|expiry| expiry < current_block).unwrap_or(true); - aliaser.location == origin && not_expired + authorized + .aliasers + .iter() + .find(|&aliaser| { + let not_expired = + aliaser.expiry.map(|expiry| expiry < current_block).unwrap_or(true); + not_expired && aliaser.location == origin + }) + .is_some() }) - .is_some() + .unwrap_or(false) } } diff --git a/polkadot/xcm/pallet-xcm/src/migration.rs b/polkadot/xcm/pallet-xcm/src/migration.rs index 82df2870e117..f43719ef9b99 100644 --- a/polkadot/xcm/pallet-xcm/src/migration.rs +++ b/polkadot/xcm/pallet-xcm/src/migration.rs @@ -171,14 +171,17 @@ pub mod data { } /// Implementation of `NeedsMigration` for `AuthorizedAliases` data. - impl, T: frame_system::Config> NeedsMigration - for (&VersionedLocation, &BoundedVec, PhantomData) + impl, T: Config> NeedsMigration + for (&VersionedLocation, AuthorizedAliasesEntry, M>, PhantomData) { - type MigratedData = (VersionedLocation, BoundedVec); + type MigratedData = (VersionedLocation, AuthorizedAliasesEntry, M>); fn needs_migration(&self, _: XcmVersion) -> bool { self.0.identify_version() < XCM_VERSION || - self.1.iter().any(|alias| alias.location.identify_version() < XCM_VERSION) + self.1 + .aliasers + .iter() + .any(|alias| alias.location.identify_version() < XCM_VERSION) } fn try_migrate(self, _: XcmVersion) -> Result, ()> { @@ -186,7 +189,6 @@ pub mod data { return Ok(None) } - let block_num = frame_system::Pallet::::block_number().saturated_into::(); let key = if self.0.identify_version() < XCM_VERSION { let Ok(converted_key) = self.0.clone().into_version(XCM_VERSION) else { return Err(()) @@ -195,19 +197,18 @@ pub mod data { } else { self.0.clone() }; + let mut new_aliases = BoundedVec::::new(); - for alias in self.1 { - // skip expired aliases - if alias.expiry.map(|expiry| expiry <= block_num).unwrap_or(false) { - continue - } + let (aliasers, ticket) = (self.1.aliasers, self.1.ticket); + for alias in aliasers { let OriginAliaser { mut location, expiry } = alias.clone(); if location.identify_version() < XCM_VERSION { location = location.into_version(XCM_VERSION)?; } new_aliases.try_push(OriginAliaser { location, expiry }).map_err(|_| ())?; } - Ok(Some((key, new_aliases))) + + Ok(Some((key, AuthorizedAliasesEntry { aliasers: new_aliases, ticket }))) } } @@ -368,14 +369,13 @@ pub mod data { // check and migrate `AuthorizedAliases` let aliases_to_migrate = AuthorizedAliases::::iter().filter_map(|(id, data)| { weight.saturating_add(T::DbWeight::get().reads(1)); - match (&id, &data, PhantomData::).try_migrate(required_xcm_version) { + match (&id, data, PhantomData::).try_migrate(required_xcm_version) { Ok(Some((new_id, new_data))) => Some((id, new_id, new_data)), Ok(None) => None, Err(_) => { tracing::error!( target: LOG_TARGET, ?id, - ?data, ?required_xcm_version, "`AuthorizedAliases` cannot be migrated!" ); @@ -392,9 +392,7 @@ pub mod data { "Migrating `AuthorizedAliases`" ); AuthorizedAliases::::remove(old_id); - if !new_data.is_empty() { - AuthorizedAliases::::insert(new_id, new_data); - } + AuthorizedAliases::::insert(new_id, new_data); count = count + 1; } // two writes per key, one to remove old entry, one to write new entry diff --git a/polkadot/xcm/pallet-xcm/src/mock.rs b/polkadot/xcm/pallet-xcm/src/mock.rs index 604f1e100e21..e7a756add549 100644 --- a/polkadot/xcm/pallet-xcm/src/mock.rs +++ b/polkadot/xcm/pallet-xcm/src/mock.rs @@ -19,8 +19,8 @@ pub use core::cell::RefCell; use frame_support::{ construct_runtime, derive_impl, parameter_types, traits::{ - AsEnsureOriginWithArg, ConstU128, ConstU32, Contains, Equals, Everything, EverythingBut, - Nothing, + fungible::HoldConsideration, AsEnsureOriginWithArg, ConstU128, ConstU32, Contains, Equals, + Everything, EverythingBut, Footprint, Nothing, }, weights::Weight, }; @@ -28,7 +28,10 @@ use frame_system::EnsureRoot; use polkadot_parachain_primitives::primitives::Id as ParaId; use polkadot_runtime_parachains::origin; use sp_core::H256; -use sp_runtime::{traits::IdentityLookup, AccountId32, BuildStorage}; +use sp_runtime::{ + traits::{Convert, IdentityLookup}, + AccountId32, BuildStorage, +}; use xcm::prelude::*; use xcm_builder::{ AccountId32Aliases, AllowKnownQueryResponses, AllowSubscriptionsFrom, @@ -524,6 +527,14 @@ pub type LocalOriginToLocation = SignedToAccountId32 for ConvertDeposit { + fn convert(a: Footprint) -> u128 { + (a.count * 2 + a.size) as u128 + } } pub struct XcmTeleportFiltered; @@ -558,6 +569,8 @@ impl pallet_xcm::Config for Test { type MaxRemoteLockConsumers = frame_support::traits::ConstU32<0>; type RemoteLockConsumerIdentifier = (); type WeightInfo = TestWeightInfo; + type Consideration = + HoldConsideration; } impl origin::Config for Test {} From 5bde333a41a6e47725602148b7679ed0002b7f67 Mon Sep 17 00:00:00 2001 From: Adrian Catangiu Date: Mon, 13 Jan 2025 17:23:04 +0200 Subject: [PATCH 22/40] fix conflicts --- polkadot/xcm/pallet-xcm/src/benchmarking.rs | 45 +++++++++++++++------ 1 file changed, 33 insertions(+), 12 deletions(-) diff --git a/polkadot/xcm/pallet-xcm/src/benchmarking.rs b/polkadot/xcm/pallet-xcm/src/benchmarking.rs index bbb2c263bd53..0518641bad9e 100644 --- a/polkadot/xcm/pallet-xcm/src/benchmarking.rs +++ b/polkadot/xcm/pallet-xcm/src/benchmarking.rs @@ -597,11 +597,14 @@ mod benchmarks { Ok(()) } - add_authorized_alias { + #[benchmark] + fn add_authorized_alias() -> Result<(), BenchmarkError> { let who: T::AccountId = whitelisted_caller(); let origin = RawOrigin::Signed(who.clone()); - let origin_location: VersionedLocation = T::ExecuteXcmOrigin::try_origin(origin.clone().into()) - .map_err(|_| BenchmarkError::Override(BenchmarkResult::from_weight(Weight::MAX)))?.into(); + let origin_location: VersionedLocation = + T::ExecuteXcmOrigin::try_origin(origin.clone().into()) + .map_err(|_| BenchmarkError::Override(BenchmarkResult::from_weight(Weight::MAX)))? + .into(); // Give some multiple of ED let balance = T::ExistentialDeposit::get() * 10u32.into(); @@ -611,7 +614,9 @@ mod benchmarks { let mut existing_aliases = BoundedVec::::new(); // prepopulate list with `max-1` aliases to benchmark worst case for i in 1..MaxAuthorizedAliases::get() { - let alias = Location::new(1, [Parachain(i), AccountId32 { network: None, id: [42_u8; 32] }]).into(); + let alias = + Location::new(1, [Parachain(i), AccountId32 { network: None, id: [42_u8; 32] }]) + .into(); let aliaser = OriginAliaser { location: alias, expiry: None }; existing_aliases.try_push(aliaser).unwrap() } @@ -621,14 +626,23 @@ mod benchmarks { // now benchmark adding new alias let aliaser: VersionedLocation = - Location::new(1, [Parachain(1234), AccountId32 { network: None, id: [42_u8; 32] }]).into(); - }: _(origin, Box::new(aliaser), None) + Location::new(1, [Parachain(1234), AccountId32 { network: None, id: [42_u8; 32] }]) + .into(); + + #[extrinsic_call] + _(origin, Box::new(aliaser), None); + + Ok(()) + } - remove_authorized_alias { + #[benchmark] + fn remove_authorized_alias() -> Result<(), BenchmarkError> { let who: T::AccountId = whitelisted_caller(); let origin = RawOrigin::Signed(who.clone()); - let origin_location: VersionedLocation = T::ExecuteXcmOrigin::try_origin(origin.clone().into()) - .map_err(|_| BenchmarkError::Override(BenchmarkResult::from_weight(Weight::MAX)))?.into(); + let origin_location: VersionedLocation = + T::ExecuteXcmOrigin::try_origin(origin.clone().into()) + .map_err(|_| BenchmarkError::Override(BenchmarkResult::from_weight(Weight::MAX)))? + .into(); // Give some multiple of ED let balance = T::ExistentialDeposit::get() * 10u32.into(); @@ -637,8 +651,10 @@ mod benchmarks { let mut existing_aliases = BoundedVec::::new(); // prepopulate list with `max` aliases to benchmark worst case - for i in 1..MaxAuthorizedAliases::get()+1 { - let alias = Location::new(1, [Parachain(i), AccountId32 { network: None, id: [42_u8; 32] }]).into(); + for i in 1..MaxAuthorizedAliases::get() + 1 { + let alias = + Location::new(1, [Parachain(i), AccountId32 { network: None, id: [42_u8; 32] }]) + .into(); let aliaser = OriginAliaser { location: alias, expiry: None }; existing_aliases.try_push(aliaser).unwrap() } @@ -649,7 +665,12 @@ mod benchmarks { // now benchmark removing an alias let aliaser_to_remove: VersionedLocation = Location::new(1, [Parachain(1), AccountId32 { network: None, id: [42_u8; 32] }]).into(); - }: _(origin, Box::new(aliaser_to_remove)) + + #[extrinsic_call] + _(origin, Box::new(aliaser_to_remove)); + + Ok(()) + } impl_benchmark_test_suite!( Pallet, From 4ed6e22486965af6b7123286dda8340cf0a15f32 Mon Sep 17 00:00:00 2001 From: Adrian Catangiu Date: Tue, 14 Jan 2025 14:12:19 +0200 Subject: [PATCH 23/40] fix bugs, add tests --- polkadot/xcm/pallet-xcm/src/benchmarking.rs | 4 +- polkadot/xcm/pallet-xcm/src/lib.rs | 40 ++++- polkadot/xcm/pallet-xcm/src/tests/mod.rs | 168 +++++++++++++++++++- 3 files changed, 197 insertions(+), 15 deletions(-) diff --git a/polkadot/xcm/pallet-xcm/src/benchmarking.rs b/polkadot/xcm/pallet-xcm/src/benchmarking.rs index 0518641bad9e..e68f6587f3eb 100644 --- a/polkadot/xcm/pallet-xcm/src/benchmarking.rs +++ b/polkadot/xcm/pallet-xcm/src/benchmarking.rs @@ -607,7 +607,7 @@ mod benchmarks { .into(); // Give some multiple of ED - let balance = T::ExistentialDeposit::get() * 10u32.into(); + let balance = T::ExistentialDeposit::get() * 1000u32.into(); let _ = as frame_support::traits::Currency<_>>::make_free_balance_be(&who, balance); @@ -645,7 +645,7 @@ mod benchmarks { .into(); // Give some multiple of ED - let balance = T::ExistentialDeposit::get() * 10u32.into(); + let balance = T::ExistentialDeposit::get() * 1000u32.into(); let _ = as frame_support::traits::Currency<_>>::make_free_balance_be(&who, balance); diff --git a/polkadot/xcm/pallet-xcm/src/lib.rs b/polkadot/xcm/pallet-xcm/src/lib.rs index ccadfe72da1e..7a2302a25c75 100644 --- a/polkadot/xcm/pallet-xcm/src/lib.rs +++ b/polkadot/xcm/pallet-xcm/src/lib.rs @@ -209,7 +209,9 @@ pub(crate) struct AuthorizedAliasesEntry> { } pub(crate) fn aliasers_footprint(aliasers_count: usize) -> Footprint { - Footprint::from_parts(aliasers_count, OriginAliaser::max_encoded_len()) + let f = Footprint::from_parts(aliasers_count, OriginAliaser::max_encoded_len()); + println!("add_authorized_alias(): footprint {:?}", f); + f } #[frame_support::pallet] @@ -1511,41 +1513,55 @@ pub mod pallet { let origin_location: Location = T::ExecuteXcmOrigin::ensure_origin(origin)?; let aliaser: Location = (*aliaser).try_into().map_err(|()| Error::::BadVersion)?; tracing::debug!(target: "xcm::pallet_xcm::add_authorized_alias", ?origin_location, ?aliaser, ?expires); + println!( + "add_authorized_alias(): origin {:?}, aliaser {:?}, expires {:?}", + origin_location, aliaser, expires + ); ensure!(origin_location != aliaser, Error::::BadLocation); if let Some(expiry) = expires { ensure!( - expiry > frame_system::Pallet::::block_number().saturated_into::(), + expiry > + frame_system::Pallet::::current_block_number().saturated_into::(), Error::::ExpiresInPast ); } let versioned_origin = VersionedLocation::from(origin_location); let versioned_aliaser = VersionedLocation::from(aliaser); + println!("add_authorized_alias(): 1"); let entry = if let Some(entry) = AuthorizedAliases::::get(&versioned_origin) { // entry already exists, update it let (mut aliasers, mut ticket) = (entry.aliasers, entry.ticket); + println!("add_authorized_alias(): 2"); if let Some(aliaser) = aliasers.iter_mut().find(|aliaser| aliaser.location == versioned_aliaser) { // if the aliaser already exists, just update its expiry block aliaser.expiry = expires; + println!("add_authorized_alias(): 3"); } else { // if it doesn't, we try to add it let aliaser = OriginAliaser { location: versioned_aliaser, expiry: expires }; aliasers.try_push(aliaser).map_err(|_| Error::::TooManyAuthorizedAliases)?; + println!("add_authorized_alias(): 4"); // we try to update the ticket (the storage deposit) ticket = ticket.update(&signed_origin, aliasers_footprint(aliasers.len()))?; + println!("add_authorized_alias(): 5"); } AuthorizedAliasesEntry { aliasers, ticket } } else { + println!("add_authorized_alias(): 6"); // add new entry with its first alias let ticket = TicketOf::::new(&signed_origin, aliasers_footprint(1))?; + println!("add_authorized_alias(): 7"); let aliaser = OriginAliaser { location: versioned_aliaser, expiry: expires }; let mut aliasers = BoundedVec::::new(); aliasers.try_push(aliaser).map_err(|_| Error::::TooManyAuthorizedAliases)?; + println!("add_authorized_alias(): 8"); AuthorizedAliasesEntry { aliasers, ticket } }; + println!("add_authorized_alias(): 9"); // write to storage AuthorizedAliases::::insert(&versioned_origin, entry); Ok(()) @@ -1565,20 +1581,31 @@ pub mod pallet { ensure!(origin_location != to_remove, Error::::BadLocation); let versioned_origin = VersionedLocation::from(origin_location); let versioned_to_remove = VersionedLocation::from(to_remove); + println!("remove_authorized_alias(): versioned_origin {:?}", versioned_origin); if let Some(entry) = AuthorizedAliases::::get(&versioned_origin) { let (mut aliasers, mut ticket) = (entry.aliasers, entry.ticket); let old_len = aliasers.len(); + println!( + "remove_authorized_alias(): old aliasers {:?} len {:?}", + aliasers, old_len + ); aliasers.retain(|alias| versioned_to_remove.ne(&alias.location)); let new_len = aliasers.len(); - if new_len > 0 { + println!( + "remove_authorized_alias(): new aliasers {:?} len {:?}", + aliasers, new_len + ); + if aliasers.is_empty() { // remove entry altogether and return all storage deposit ticket.drop(&signed_origin)?; AuthorizedAliases::::remove(&versioned_origin); + println!("remove_authorized_alias(): removed all aliasers and deposit"); } else if old_len != new_len { // update aliasers and storage deposit ticket = ticket.update(&signed_origin, aliasers_footprint(new_len))?; let entry = AuthorizedAliasesEntry { aliasers, ticket }; AuthorizedAliases::::insert(&versioned_origin, entry); + println!("remove_authorized_alias(): updated aliasers and deposit"); } } Ok(()) @@ -1665,7 +1692,7 @@ impl QueryHandler for Pallet { let response = response.into(); Queries::::insert( id, - QueryStatus::Ready { response, at: frame_system::Pallet::::block_number() }, + QueryStatus::Ready { response, at: frame_system::Pallet::::current_block_number() }, ); } } @@ -2584,7 +2611,8 @@ impl Pallet { stage = RemoveExpiredAliasAuthorizations; } if stage == RemoveExpiredAliasAuthorizations { - let block_num = frame_system::Pallet::::block_number().saturated_into::(); + let block_num = + frame_system::Pallet::::current_block_number().saturated_into::(); let mut writes = 0; // need to iterate keys and modify map in separate steps to avoid undefined behavior let keys: Vec = AuthorizedAliases::::iter_keys().collect(); @@ -3648,7 +3676,7 @@ impl + Clone, T: Config> ContainsPair for Autho AuthorizedAliases::::get(&target) .map(|authorized| { let current_block = - frame_system::Pallet::::block_number().saturated_into::(); + frame_system::Pallet::::current_block_number().saturated_into::(); authorized .aliasers .iter() diff --git a/polkadot/xcm/pallet-xcm/src/tests/mod.rs b/polkadot/xcm/pallet-xcm/src/tests/mod.rs index 9dd42999774f..a3d1de629185 100644 --- a/polkadot/xcm/pallet-xcm/src/tests/mod.rs +++ b/polkadot/xcm/pallet-xcm/src/tests/mod.rs @@ -19,22 +19,26 @@ pub(crate) mod assets_transfer; use crate::{ + aliasers_footprint, migration::data::NeedsMigration, mock::*, pallet::{LockedFungibles, RemoteLockedFungibles, SupportedVersion}, - AssetTraps, Config, CurrentMigration, Error, ExecuteControllerWeightInfo, - LatestVersionedLocation, Pallet, Queries, QueryStatus, RecordedXcm, RemoteLockedFungibleRecord, - ShouldRecordXcm, VersionDiscoveryQueue, VersionMigrationStage, VersionNotifiers, - VersionNotifyTargets, WeightInfo, + AssetTraps, AuthorizedAliasers, Config, CurrentMigration, Error, ExecuteControllerWeightInfo, + LatestVersionedLocation, MaxAuthorizedAliases, Pallet, Queries, QueryStatus, RecordedXcm, + RemoteLockedFungibleRecord, ShouldRecordXcm, VersionDiscoveryQueue, VersionMigrationStage, + VersionNotifiers, VersionNotifyTargets, WeightInfo, }; use bounded_collections::BoundedVec; use frame_support::{ assert_err_ignore_postinfo, assert_noop, assert_ok, - traits::{Currency, Hooks}, + traits::{ContainsPair, Currency, Hooks}, weights::Weight, }; use polkadot_parachain_primitives::primitives::Id as ParaId; -use sp_runtime::traits::{AccountIdConversion, BlakeTwo256, Hash}; +use sp_runtime::{ + traits::{AccountIdConversion, BlakeTwo256, BlockNumberProvider, Hash}, + SaturatedConversion, TokenError, +}; use xcm::{latest::QueryResponseInfo, prelude::*}; use xcm_builder::AllowKnownQueryResponses; use xcm_executor::{ @@ -44,7 +48,7 @@ use xcm_executor::{ const ALICE: AccountId = AccountId::new([0u8; 32]); const BOB: AccountId = AccountId::new([1u8; 32]); -const INITIAL_BALANCE: u128 = 100; +const INITIAL_BALANCE: u128 = 1000; const SEND_AMOUNT: u128 = 10; const FEE_AMOUNT: u128 = 2; @@ -395,6 +399,156 @@ fn execute_withdraw_to_deposit_works() { }); } +/// Test XCM authorized aliases. +#[test] +fn authorized_aliases_work() { + let balances = vec![(ALICE, INITIAL_BALANCE)]; + new_test_ext_with_balances(balances).execute_with(|| { + // --- alias is same as origin + let alias: Location = AccountId32 { network: None, id: BOB.into() }.into(); + assert_eq!( + XcmPallet::add_authorized_alias( + RuntimeOrigin::signed(BOB), + Box::new(alias.into()), + None + ), + Err(Error::::BadLocation.into()) + ); + + // --- alias already expired + let alias = Location::here(); + let expires = Some(System::current_block_number().saturated_into::()); + assert_eq!( + XcmPallet::add_authorized_alias( + RuntimeOrigin::signed(BOB), + Box::new(alias.clone().into()), + expires + ), + Err(Error::::ExpiresInPast.into()) + ); + + // --- storage deposit not covered (BOB has no funds) + assert_eq!( + XcmPallet::add_authorized_alias( + RuntimeOrigin::signed(BOB), + Box::new(alias.clone().into()), + None + ), + Err(sp_runtime::DispatchError::Token(TokenError::FundsUnavailable)) + ); + + // --- setting single alias works + let who = ALICE; + let total_balance_before = >::total_balance(&who); + let free_balance = >::free_balance(&who); + assert_eq!(free_balance, total_balance_before); + assert_ok!(XcmPallet::add_authorized_alias( + RuntimeOrigin::signed(who.clone()), + Box::new(alias.clone().into()), + None + )); + let footprint = aliasers_footprint(1); + let deposit = footprint.size + 2 * footprint.count; + let free_balance = >::free_balance(&who); + let total_balance = >::total_balance(&who); + assert_eq!(total_balance, total_balance_before); + assert_eq!(total_balance, free_balance + deposit as u128); + + // --- setting same alias again only updates its expiry + assert_ok!(XcmPallet::add_authorized_alias( + RuntimeOrigin::signed(who.clone()), + Box::new(alias.into()), + Some(100) + )); + // deposit is unchanged + assert_eq!(total_balance - deposit as u128, >::free_balance(&who)); + + // --- setting max number of aliases works + for i in 1..MaxAuthorizedAliases::get() { + let alias = Location::new(0, [Parachain(OTHER_PARA_ID), GeneralIndex(i as u128)]); + assert_ok!(XcmPallet::add_authorized_alias( + RuntimeOrigin::signed(who.clone()), + Box::new(alias.into()), + None + )); + let footprint = aliasers_footprint(i as usize + 1); + let deposit = (footprint.size + 2 * footprint.count) as u128; + assert_eq!(total_balance - deposit, >::free_balance(&who)); + } + + // deposit held for MaxAliases + let footprint = aliasers_footprint(MaxAuthorizedAliases::get() as usize); + let deposit = (footprint.size + 2 * footprint.count) as u128; + assert_eq!(total_balance - deposit, >::free_balance(&who)); + + // --- adding more than max aliases is not allowed + let alias = Location::new( + 0, + [Parachain(OTHER_PARA_ID), GeneralIndex(MaxAuthorizedAliases::get() as u128 + 100)], + ); + assert_eq!( + XcmPallet::add_authorized_alias( + RuntimeOrigin::signed(who.clone()), + Box::new(alias.clone().into()), + None + ), + Err(Error::::TooManyAuthorizedAliases.into()) + ); + + // --- remove one alias + assert_ok!(XcmPallet::remove_authorized_alias( + RuntimeOrigin::signed(who.clone()), + Box::new(Location::here().into()), + )); + // deposit held for MaxAliases - 1 + let footprint = aliasers_footprint(MaxAuthorizedAliases::get() as usize - 1); + let deposit = (footprint.size + 2 * footprint.count) as u128; + assert_eq!(total_balance - deposit, >::free_balance(&who)); + + // --- adding one more is now allowed + assert_ok!(XcmPallet::add_authorized_alias( + RuntimeOrigin::signed(who.clone()), + Box::new(alias.clone().into()), + None + )); + + let target: Location = AccountId32 { network: None, id: who.clone().into() }.into(); + // --- un-authorized alias is correctly filtered/denied + assert!(!AuthorizedAliasers::::contains(&Location::here(), &target)); + // --- authorized alias is correctly allowed + assert!(AuthorizedAliasers::::contains(&alias, &target)); + // --- remove alias then verify no longer allowed + assert_ok!(XcmPallet::remove_authorized_alias( + RuntimeOrigin::signed(who.clone()), + Box::new(alias.clone().into()), + )); + assert!(!AuthorizedAliasers::::contains(&alias, &target)); + + // --- remove nonexistent alias - noop + assert_ok!(XcmPallet::remove_authorized_alias( + RuntimeOrigin::signed(ALICE), + Box::new(Location::parent().into()), + )); + + // --- remove nonexistent alias (BOB has no registered aliases) - noop + assert_ok!(XcmPallet::remove_authorized_alias( + RuntimeOrigin::signed(BOB), + Box::new(Location::parent().into()), + )); + + // --- remove all aliases then verify all deposit is returned + for i in 1..MaxAuthorizedAliases::get() { + let alias = Location::new(0, [Parachain(OTHER_PARA_ID), GeneralIndex(i as u128)]); + assert_ok!(XcmPallet::remove_authorized_alias( + RuntimeOrigin::signed(who.clone()), + Box::new(alias.into()), + )); + } + assert_eq!(total_balance, >::free_balance(&who)); + assert_eq!(total_balance, total_balance_before); + }); +} + /// Test drop/claim assets. #[test] fn trapped_assets_can_be_claimed() { From 8600075e41b044f0c5e09149a3281fffd0318d45 Mon Sep 17 00:00:00 2001 From: Adrian Catangiu Date: Tue, 14 Jan 2025 14:30:44 +0200 Subject: [PATCH 24/40] remove alias auto-prune --- polkadot/xcm/pallet-xcm/src/lib.rs | 40 ------------------------------ 1 file changed, 40 deletions(-) diff --git a/polkadot/xcm/pallet-xcm/src/lib.rs b/polkadot/xcm/pallet-xcm/src/lib.rs index 7a2302a25c75..8a8f1340a0da 100644 --- a/polkadot/xcm/pallet-xcm/src/lib.rs +++ b/polkadot/xcm/pallet-xcm/src/lib.rs @@ -687,7 +687,6 @@ pub mod pallet { MigrateVersionNotifiers, NotifyCurrentTargets(Option>), MigrateAndNotifyOldTargets, - RemoveExpiredAliasAuthorizations, } impl Default for VersionMigrationStage { @@ -2608,45 +2607,6 @@ impl Pallet { } } } - stage = RemoveExpiredAliasAuthorizations; - } - if stage == RemoveExpiredAliasAuthorizations { - let block_num = - frame_system::Pallet::::current_block_number().saturated_into::(); - let mut writes = 0; - // need to iterate keys and modify map in separate steps to avoid undefined behavior - let keys: Vec = AuthorizedAliases::::iter_keys().collect(); - weight_used.saturating_add(T::DbWeight::get().reads(keys.len() as u64)); - for key in keys { - if let Some(entry) = AuthorizedAliases::::get(&key) { - let (mut aliases, ticket) = (entry.aliasers, entry.ticket); - let Some(who) = Location::try_from(key.clone()) - .ok() - .and_then(|key| T::SovereignAccountOf::convert_location(&key)) - else { - continue - }; - let old_len = aliases.len(); - aliases.retain(|aliaser| { - aliaser.expiry.map(|expiry| expiry > block_num).unwrap_or(true) - }); - let new_len = aliases.len(); - if new_len > 0 { - // remove entry altogether and return all storage deposit - let _ = ticket.drop(&who); - AuthorizedAliases::::remove(&key); - writes = writes + 2; - } else if old_len != new_len { - // update aliasers and storage deposit - if let Ok(ticket) = ticket.update(&who, aliasers_footprint(new_len)) { - let entry = AuthorizedAliasesEntry { aliasers: aliases, ticket }; - AuthorizedAliases::::insert(&key, entry); - writes = writes + 2; - } - } - } - } - weight_used.saturating_add(T::DbWeight::get().writes(writes)); } (weight_used, None) } From 795e63ea6e4ff99c1bba5ee0859bdd732b7268ed Mon Sep 17 00:00:00 2001 From: Adrian Catangiu Date: Tue, 14 Jan 2025 15:23:35 +0200 Subject: [PATCH 25/40] define runtime APIs for authorized aliases --- polkadot/xcm/pallet-xcm/src/lib.rs | 131 +++++++++--------- .../src/authorized_aliases.rs | 39 ++++++ polkadot/xcm/xcm-runtime-apis/src/lib.rs | 9 +- .../xcm/xcm-runtime-apis/src/trusted_query.rs | 2 +- 4 files changed, 112 insertions(+), 69 deletions(-) create mode 100644 polkadot/xcm/xcm-runtime-apis/src/authorized_aliases.rs diff --git a/polkadot/xcm/pallet-xcm/src/lib.rs b/polkadot/xcm/pallet-xcm/src/lib.rs index 8a8f1340a0da..af622e3d0be2 100644 --- a/polkadot/xcm/pallet-xcm/src/lib.rs +++ b/polkadot/xcm/pallet-xcm/src/lib.rs @@ -61,13 +61,14 @@ use xcm_builder::{ use xcm_executor::{ traits::{ AssetTransferError, CheckSuspension, ClaimAssets, ConvertLocation, ConvertOrigin, - DropAssets, MatchesFungible, OnResponse, Properties, QueryHandler, QueryResponseStatus, - RecordXcm, TransactAsset, TransferType, VersionChangeNotifier, WeightBounds, - XcmAssetTransfers, + DropAssets, FeeManager, FeeReason, MatchesFungible, OnResponse, Properties, QueryHandler, + QueryResponseStatus, RecordXcm, TransactAsset, TransferType, VersionChangeNotifier, + WeightBounds, XcmAssetTransfers, }, AssetsInHolding, }; use xcm_runtime_apis::{ + authorized_aliases::OriginAliaser, dry_run::{CallDryRunEffects, Error as XcmDryRunApiError, XcmDryRunEffects}, fees::Error as XcmPaymentApiError, trusted_query::Error as TrustedQueryApiError, @@ -75,7 +76,6 @@ use xcm_runtime_apis::{ #[cfg(any(feature = "try-runtime", test))] use sp_runtime::TryRuntimeError; -use xcm_executor::traits::{FeeManager, FeeReason}; pub trait WeightInfo { fn send() -> Weight; @@ -194,24 +194,14 @@ impl WeightInfo for TestWeightInfo { } } -/// Entry of an authorized aliaser for a local origin. The aliaser `location` is only authorized -/// until its inner `expiry` block number. #[derive(Clone, Debug, Encode, Decode, MaxEncodedLen, TypeInfo)] -pub(crate) struct OriginAliaser { - pub(crate) location: VersionedLocation, - pub(crate) expiry: Option, +pub struct AuthorizedAliasesEntry> { + pub aliasers: BoundedVec, + pub ticket: Ticket, } -#[derive(Clone, Debug, Encode, Decode, MaxEncodedLen, TypeInfo)] -pub(crate) struct AuthorizedAliasesEntry> { - pub(crate) aliasers: BoundedVec, - pub(crate) ticket: Ticket, -} - -pub(crate) fn aliasers_footprint(aliasers_count: usize) -> Footprint { - let f = Footprint::from_parts(aliasers_count, OriginAliaser::max_encoded_len()); - println!("add_authorized_alias(): footprint {:?}", f); - f +pub fn aliasers_footprint(aliasers_count: usize) -> Footprint { + Footprint::from_parts(aliasers_count, OriginAliaser::max_encoded_len()) } #[frame_support::pallet] @@ -2795,6 +2785,40 @@ impl Pallet { }) } + /// Given a `destination` and XCM `message`, return assets to be charged as XCM delivery fees. + pub fn query_delivery_fees( + destination: VersionedLocation, + message: VersionedXcm<()>, + ) -> Result { + let result_version = destination.identify_version().max(message.identify_version()); + + let destination: Location = destination + .clone() + .try_into() + .map_err(|e| { + tracing::error!(target: "xcm::pallet_xcm::query_delivery_fees", ?e, ?destination, "Failed to convert versioned destination"); + XcmPaymentApiError::VersionedConversionFailed + })?; + + let message: Xcm<()> = + message.clone().try_into().map_err(|e| { + tracing::error!(target: "xcm::pallet_xcm::query_delivery_fees", ?e, ?message, "Failed to convert versioned message"); + XcmPaymentApiError::VersionedConversionFailed + })?; + + let (_, fees) = validate_send::(destination.clone(), message.clone()).map_err(|error| { + tracing::error!(target: "xcm::pallet_xcm::query_delivery_fees", ?error, ?destination, ?message, "Failed to validate send to destination"); + XcmPaymentApiError::Unroutable + })?; + + VersionedAssets::from(fees) + .into_version(result_version) + .map_err(|e| { + tracing::error!(target: "xcm::pallet_xcm::query_delivery_fees", ?e, ?result_version, "Failed to convert fees into version"); + XcmPaymentApiError::VersionedConversionFailed + }) + } + /// Given an Asset and a Location, returns if the provided location is a trusted reserve for the /// given asset. pub fn is_trusted_reserve( @@ -2846,37 +2870,32 @@ impl Pallet { Ok(::IsTeleporter::contains(&a, &location)) } - pub fn query_delivery_fees( - destination: VersionedLocation, - message: VersionedXcm<()>, - ) -> Result { - let result_version = destination.identify_version().max(message.identify_version()); - - let destination: Location = destination - .clone() - .try_into() - .map_err(|e| { - tracing::error!(target: "xcm::pallet_xcm::query_delivery_fees", ?e, ?destination, "Failed to convert versioned destination"); - XcmPaymentApiError::VersionedConversionFailed - })?; - - let message: Xcm<()> = - message.clone().try_into().map_err(|e| { - tracing::error!(target: "xcm::pallet_xcm::query_delivery_fees", ?e, ?message, "Failed to convert versioned message"); - XcmPaymentApiError::VersionedConversionFailed - })?; - - let (_, fees) = validate_send::(destination.clone(), message.clone()).map_err(|error| { - tracing::error!(target: "xcm::pallet_xcm::query_delivery_fees", ?error, ?destination, ?message, "Failed to validate send to destination"); - XcmPaymentApiError::Unroutable - })?; + /// Returns locations allowed to alias into and act as `target`. + fn authorized_aliasers(target: VersionedLocation) -> Vec { + AuthorizedAliases::::get(&target) + .map(|authorized| authorized.aliasers.into_iter().collect()) + .unwrap_or_default() + } - VersionedAssets::from(fees) - .into_version(result_version) - .map_err(|e| { - tracing::error!(target: "xcm::pallet_xcm::query_delivery_fees", ?e, ?result_version, "Failed to convert fees into version"); - XcmPaymentApiError::VersionedConversionFailed + /// Given an `origin` and a `target`, returns if the `origin` location was added by `target` as + /// an authorized aliaser. + /// + /// Effectively says whether `origin` is allowed to alias into and act as `target`. + pub fn is_authorized_alias(origin: VersionedLocation, target: VersionedLocation) -> bool { + Self::authorized_aliasers(target) + .iter() + .find(|&aliaser| { + aliaser.location == origin && + aliaser + .expiry + .map(|expiry| { + expiry < + frame_system::Pallet::::current_block_number() + .saturated_into::() + }) + .unwrap_or(true) }) + .is_some() } /// Create a new expectation of a query response with the querier being here. @@ -3633,21 +3652,7 @@ impl + Clone, T: Config> ContainsPair for Autho tracing::trace!(target: "xcm::pallet_xcm::AuthorizedAliasers::contains", ?origin, ?target); // return true if the `origin` has been explicitly authorized by `target` as aliaser, and // the authorization has not expired - AuthorizedAliases::::get(&target) - .map(|authorized| { - let current_block = - frame_system::Pallet::::current_block_number().saturated_into::(); - authorized - .aliasers - .iter() - .find(|&aliaser| { - let not_expired = - aliaser.expiry.map(|expiry| expiry < current_block).unwrap_or(true); - not_expired && aliaser.location == origin - }) - .is_some() - }) - .unwrap_or(false) + Pallet::::is_authorized_alias(origin, target) } } diff --git a/polkadot/xcm/xcm-runtime-apis/src/authorized_aliases.rs b/polkadot/xcm/xcm-runtime-apis/src/authorized_aliases.rs new file mode 100644 index 000000000000..1ad4d9dca968 --- /dev/null +++ b/polkadot/xcm/xcm-runtime-apis/src/authorized_aliases.rs @@ -0,0 +1,39 @@ +// Copyright (C) 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 . + +//! Contains runtime APIs for querying XCM authorized aliases. + +use codec::{Decode, Encode}; +use frame_support::pallet_prelude::{MaxEncodedLen, TypeInfo}; +use xcm::VersionedLocation; + +/// Entry of an authorized aliaser for a local origin. The aliaser `location` is only authorized +/// until its inner `expiry` block number. +#[derive(Clone, Debug, Encode, Decode, MaxEncodedLen, TypeInfo)] +pub struct OriginAliaser { + pub location: VersionedLocation, + pub expiry: Option, +} + +sp_api::decl_runtime_apis! { + /// API for querying XCM authorized aliases + pub trait AuthorizedAliasersApi { + /// Returns locations allowed to alias into and act as `target`. + fn authorized_aliasers(target: VersionedLocation) -> Vec; + /// Returns whether `origin` is allowed to alias into and act as `target`. + fn is_authorized_alias(origin: VersionedLocation, target: VersionedLocation) -> bool; + } +} diff --git a/polkadot/xcm/xcm-runtime-apis/src/lib.rs b/polkadot/xcm/xcm-runtime-apis/src/lib.rs index f9a857c7c4ce..3fe591b48b20 100644 --- a/polkadot/xcm/xcm-runtime-apis/src/lib.rs +++ b/polkadot/xcm/xcm-runtime-apis/src/lib.rs @@ -20,17 +20,16 @@ extern crate alloc; +/// Runtime APIs for querying XCM authorized aliases. +pub mod authorized_aliases; /// Exposes runtime APIs for various XCM-related conversions. pub mod conversions; - /// Dry-run API. /// Given an extrinsic or an XCM program, it returns the outcome of its execution. pub mod dry_run; - /// Fee estimation API. /// Given an XCM program, it will return the fees needed to execute it properly or send it. pub mod fees; - -// Exposes runtime API for querying whether a Location is trusted as a reserve or teleporter for a -// given Asset. +/// Exposes runtime API for querying whether a Location is trusted as a reserve or teleporter for a +/// given Asset. pub mod trusted_query; diff --git a/polkadot/xcm/xcm-runtime-apis/src/trusted_query.rs b/polkadot/xcm/xcm-runtime-apis/src/trusted_query.rs index a2e3e1625486..9536f2bf6731 100644 --- a/polkadot/xcm/xcm-runtime-apis/src/trusted_query.rs +++ b/polkadot/xcm/xcm-runtime-apis/src/trusted_query.rs @@ -24,7 +24,7 @@ use xcm::{VersionedAsset, VersionedLocation}; pub type XcmTrustedQueryResult = Result; sp_api::decl_runtime_apis! { - // API for querying trusted reserves and trusted teleporters. + /// API for querying trusted reserves and trusted teleporters. pub trait TrustedQueryApi { /// Returns if the location is a trusted reserve for the asset. /// From 4f35647aff0dc27d9121b3fc408d4780863ff4fa Mon Sep 17 00:00:00 2001 From: Adrian Catangiu Date: Tue, 14 Jan 2025 16:22:16 +0200 Subject: [PATCH 26/40] add events --- polkadot/xcm/pallet-xcm/src/lib.rs | 29 ++++++++++++++++++++++-- polkadot/xcm/pallet-xcm/src/tests/mod.rs | 18 ++++++++++++++- 2 files changed, 44 insertions(+), 3 deletions(-) diff --git a/polkadot/xcm/pallet-xcm/src/lib.rs b/polkadot/xcm/pallet-xcm/src/lib.rs index af622e3d0be2..0c198bd09dc3 100644 --- a/polkadot/xcm/pallet-xcm/src/lib.rs +++ b/polkadot/xcm/pallet-xcm/src/lib.rs @@ -533,6 +533,15 @@ pub mod pallet { AssetsClaimed { hash: H256, origin: Location, assets: VersionedAssets }, /// A XCM version migration finished. VersionMigrationFinished { version: XcmVersion }, + /// An `aliaser` location was authorized by `target` to alias it, authorization valid until + /// `expiry` block number. + AliasAuthorized { + aliaser: VersionedLocation, + target: VersionedLocation, + expiry: Option, + }, + /// `target` removed alias authorization for `aliaser`. + AliasAuthorizationRemoved { aliaser: VersionedLocation, target: VersionedLocation }, } #[pallet::origin] @@ -1530,7 +1539,8 @@ pub mod pallet { println!("add_authorized_alias(): 3"); } else { // if it doesn't, we try to add it - let aliaser = OriginAliaser { location: versioned_aliaser, expiry: expires }; + let aliaser = + OriginAliaser { location: versioned_aliaser.clone(), expiry: expires }; aliasers.try_push(aliaser).map_err(|_| Error::::TooManyAuthorizedAliases)?; println!("add_authorized_alias(): 4"); // we try to update the ticket (the storage deposit) @@ -1543,7 +1553,8 @@ pub mod pallet { // add new entry with its first alias let ticket = TicketOf::::new(&signed_origin, aliasers_footprint(1))?; println!("add_authorized_alias(): 7"); - let aliaser = OriginAliaser { location: versioned_aliaser, expiry: expires }; + let aliaser = + OriginAliaser { location: versioned_aliaser.clone(), expiry: expires }; let mut aliasers = BoundedVec::::new(); aliasers.try_push(aliaser).map_err(|_| Error::::TooManyAuthorizedAliases)?; println!("add_authorized_alias(): 8"); @@ -1553,6 +1564,11 @@ pub mod pallet { println!("add_authorized_alias(): 9"); // write to storage AuthorizedAliases::::insert(&versioned_origin, entry); + Self::deposit_event(Event::AliasAuthorized { + aliaser: versioned_aliaser, + target: versioned_origin, + expiry: expires, + }); Ok(()) } @@ -1589,12 +1605,21 @@ pub mod pallet { ticket.drop(&signed_origin)?; AuthorizedAliases::::remove(&versioned_origin); println!("remove_authorized_alias(): removed all aliasers and deposit"); + + Self::deposit_event(Event::AliasAuthorizationRemoved { + aliaser: versioned_to_remove, + target: versioned_origin, + }); } else if old_len != new_len { // update aliasers and storage deposit ticket = ticket.update(&signed_origin, aliasers_footprint(new_len))?; let entry = AuthorizedAliasesEntry { aliasers, ticket }; AuthorizedAliases::::insert(&versioned_origin, entry); println!("remove_authorized_alias(): updated aliasers and deposit"); + Self::deposit_event(Event::AliasAuthorizationRemoved { + aliaser: versioned_to_remove, + target: versioned_origin, + }); } } Ok(()) diff --git a/polkadot/xcm/pallet-xcm/src/tests/mod.rs b/polkadot/xcm/pallet-xcm/src/tests/mod.rs index a3d1de629185..42fe0ded5dc8 100644 --- a/polkadot/xcm/pallet-xcm/src/tests/mod.rs +++ b/polkadot/xcm/pallet-xcm/src/tests/mod.rs @@ -496,6 +496,7 @@ fn authorized_aliases_work() { ); // --- remove one alias + let target: Location = AccountId32 { network: None, id: who.clone().into() }.into(); assert_ok!(XcmPallet::remove_authorized_alias( RuntimeOrigin::signed(who.clone()), Box::new(Location::here().into()), @@ -504,6 +505,14 @@ fn authorized_aliases_work() { let footprint = aliasers_footprint(MaxAuthorizedAliases::get() as usize - 1); let deposit = (footprint.size + 2 * footprint.count) as u128; assert_eq!(total_balance - deposit, >::free_balance(&who)); + // de-authorization event + assert_eq!( + last_events(1), + vec![RuntimeEvent::XcmPallet(crate::Event::AliasAuthorizationRemoved { + aliaser: Location::here().into(), + target: target.clone().into(), + }),] + ); // --- adding one more is now allowed assert_ok!(XcmPallet::add_authorized_alias( @@ -511,8 +520,15 @@ fn authorized_aliases_work() { Box::new(alias.clone().into()), None )); + assert_eq!( + last_events(1), + vec![RuntimeEvent::XcmPallet(crate::Event::AliasAuthorized { + aliaser: alias.clone().into(), + target: target.clone().into(), + expiry: None, + })] + ); - let target: Location = AccountId32 { network: None, id: who.clone().into() }.into(); // --- un-authorized alias is correctly filtered/denied assert!(!AuthorizedAliasers::::contains(&Location::here(), &target)); // --- authorized alias is correctly allowed From 875c9abd5d0e947956ce67136ca8becba8cc1c68 Mon Sep 17 00:00:00 2001 From: Adrian Catangiu Date: Tue, 14 Jan 2025 18:36:51 +0200 Subject: [PATCH 27/40] tweak prdoc --- prdoc/pr_6336.prdoc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/prdoc/pr_6336.prdoc b/prdoc/pr_6336.prdoc index 5edf7ed01b22..82cbfc1e4478 100644 --- a/prdoc/pr_6336.prdoc +++ b/prdoc/pr_6336.prdoc @@ -24,9 +24,9 @@ doc: crates: - name: pallet-xcm bump: minor - - name: staging-xcm-builder - bump: none - name: xcm-runtime-apis + bump: minor + - name: staging-xcm-builder bump: none - name: westend-runtime bump: none From 327a2e1f88b8b0fdaa4953014b68532416046e0f Mon Sep 17 00:00:00 2001 From: Adrian Catangiu Date: Tue, 14 Jan 2025 18:47:14 +0200 Subject: [PATCH 28/40] remove debug prints --- polkadot/xcm/pallet-xcm/src/lib.rs | 26 -------------------------- 1 file changed, 26 deletions(-) diff --git a/polkadot/xcm/pallet-xcm/src/lib.rs b/polkadot/xcm/pallet-xcm/src/lib.rs index 0c198bd09dc3..3ce1d5f6db0f 100644 --- a/polkadot/xcm/pallet-xcm/src/lib.rs +++ b/polkadot/xcm/pallet-xcm/src/lib.rs @@ -1511,10 +1511,6 @@ pub mod pallet { let origin_location: Location = T::ExecuteXcmOrigin::ensure_origin(origin)?; let aliaser: Location = (*aliaser).try_into().map_err(|()| Error::::BadVersion)?; tracing::debug!(target: "xcm::pallet_xcm::add_authorized_alias", ?origin_location, ?aliaser, ?expires); - println!( - "add_authorized_alias(): origin {:?}, aliaser {:?}, expires {:?}", - origin_location, aliaser, expires - ); ensure!(origin_location != aliaser, Error::::BadLocation); if let Some(expiry) = expires { ensure!( @@ -1525,43 +1521,33 @@ pub mod pallet { } let versioned_origin = VersionedLocation::from(origin_location); let versioned_aliaser = VersionedLocation::from(aliaser); - println!("add_authorized_alias(): 1"); let entry = if let Some(entry) = AuthorizedAliases::::get(&versioned_origin) { // entry already exists, update it let (mut aliasers, mut ticket) = (entry.aliasers, entry.ticket); - println!("add_authorized_alias(): 2"); if let Some(aliaser) = aliasers.iter_mut().find(|aliaser| aliaser.location == versioned_aliaser) { // if the aliaser already exists, just update its expiry block aliaser.expiry = expires; - println!("add_authorized_alias(): 3"); } else { // if it doesn't, we try to add it let aliaser = OriginAliaser { location: versioned_aliaser.clone(), expiry: expires }; aliasers.try_push(aliaser).map_err(|_| Error::::TooManyAuthorizedAliases)?; - println!("add_authorized_alias(): 4"); // we try to update the ticket (the storage deposit) ticket = ticket.update(&signed_origin, aliasers_footprint(aliasers.len()))?; - println!("add_authorized_alias(): 5"); } AuthorizedAliasesEntry { aliasers, ticket } } else { - println!("add_authorized_alias(): 6"); // add new entry with its first alias let ticket = TicketOf::::new(&signed_origin, aliasers_footprint(1))?; - println!("add_authorized_alias(): 7"); let aliaser = OriginAliaser { location: versioned_aliaser.clone(), expiry: expires }; let mut aliasers = BoundedVec::::new(); aliasers.try_push(aliaser).map_err(|_| Error::::TooManyAuthorizedAliases)?; - println!("add_authorized_alias(): 8"); AuthorizedAliasesEntry { aliasers, ticket } }; - - println!("add_authorized_alias(): 9"); // write to storage AuthorizedAliases::::insert(&versioned_origin, entry); Self::deposit_event(Event::AliasAuthorized { @@ -1586,26 +1572,15 @@ pub mod pallet { ensure!(origin_location != to_remove, Error::::BadLocation); let versioned_origin = VersionedLocation::from(origin_location); let versioned_to_remove = VersionedLocation::from(to_remove); - println!("remove_authorized_alias(): versioned_origin {:?}", versioned_origin); if let Some(entry) = AuthorizedAliases::::get(&versioned_origin) { let (mut aliasers, mut ticket) = (entry.aliasers, entry.ticket); let old_len = aliasers.len(); - println!( - "remove_authorized_alias(): old aliasers {:?} len {:?}", - aliasers, old_len - ); aliasers.retain(|alias| versioned_to_remove.ne(&alias.location)); let new_len = aliasers.len(); - println!( - "remove_authorized_alias(): new aliasers {:?} len {:?}", - aliasers, new_len - ); if aliasers.is_empty() { // remove entry altogether and return all storage deposit ticket.drop(&signed_origin)?; AuthorizedAliases::::remove(&versioned_origin); - println!("remove_authorized_alias(): removed all aliasers and deposit"); - Self::deposit_event(Event::AliasAuthorizationRemoved { aliaser: versioned_to_remove, target: versioned_origin, @@ -1615,7 +1590,6 @@ pub mod pallet { ticket = ticket.update(&signed_origin, aliasers_footprint(new_len))?; let entry = AuthorizedAliasesEntry { aliasers, ticket }; AuthorizedAliases::::insert(&versioned_origin, entry); - println!("remove_authorized_alias(): updated aliasers and deposit"); Self::deposit_event(Event::AliasAuthorizationRemoved { aliaser: versioned_to_remove, target: versioned_origin, From af6abe84b5bd2ea4e2baea71b824436a2080e66d Mon Sep 17 00:00:00 2001 From: Adrian Catangiu Date: Tue, 14 Jan 2025 18:49:46 +0200 Subject: [PATCH 29/40] fix import --- polkadot/xcm/xcm-runtime-apis/src/authorized_aliases.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/polkadot/xcm/xcm-runtime-apis/src/authorized_aliases.rs b/polkadot/xcm/xcm-runtime-apis/src/authorized_aliases.rs index 1ad4d9dca968..b7aa82c5fa97 100644 --- a/polkadot/xcm/xcm-runtime-apis/src/authorized_aliases.rs +++ b/polkadot/xcm/xcm-runtime-apis/src/authorized_aliases.rs @@ -16,6 +16,7 @@ //! Contains runtime APIs for querying XCM authorized aliases. +use alloc::vec::Vec; use codec::{Decode, Encode}; use frame_support::pallet_prelude::{MaxEncodedLen, TypeInfo}; use xcm::VersionedLocation; From 29b0c0df5ff5351dee636502ff2cd30f82bae923 Mon Sep 17 00:00:00 2001 From: Adrian Catangiu Date: Tue, 14 Jan 2025 19:46:32 +0200 Subject: [PATCH 30/40] configure runtimes --- Cargo.lock | 1 + .../assets/asset-hub-rococo/src/xcm_config.rs | 31 ++++++++-- .../bridge-hub-rococo/src/xcm_config.rs | 50 +++++++++++----- .../bridge-hub-westend/src/xcm_config.rs | 49 ++++++++++----- .../collectives-westend/src/xcm_config.rs | 43 ++++++++++---- .../coretime-rococo/src/xcm_config.rs | 8 ++- .../coretime-westend/src/xcm_config.rs | 47 +++++++++++---- .../people/people-rococo/src/xcm_config.rs | 1 + .../people/people-westend/src/xcm_config.rs | 46 +++++++++++---- .../runtimes/testing/penpal/Cargo.toml | 1 + .../runtimes/testing/penpal/src/xcm_config.rs | 59 +++++++++++++------ prdoc/pr_6336.prdoc | 2 +- 12 files changed, 253 insertions(+), 85 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 3eab84d5ed16..647c78563efc 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -16711,6 +16711,7 @@ dependencies = [ "staging-xcm-builder 7.0.0", "staging-xcm-executor 7.0.0", "substrate-wasm-builder 17.0.0", + "testnet-parachains-constants 1.0.0", "xcm-runtime-apis 0.1.0", ] diff --git a/cumulus/parachains/runtimes/assets/asset-hub-rococo/src/xcm_config.rs b/cumulus/parachains/runtimes/assets/asset-hub-rococo/src/xcm_config.rs index 99a5b5c61506..53b5918be966 100644 --- a/cumulus/parachains/runtimes/assets/asset-hub-rococo/src/xcm_config.rs +++ b/cumulus/parachains/runtimes/assets/asset-hub-rococo/src/xcm_config.rs @@ -16,9 +16,9 @@ use super::{ AccountId, AllPalletsWithSystem, Assets, Authorship, Balance, Balances, BaseDeliveryFee, CollatorSelection, FeeAssetId, ForeignAssets, ForeignAssetsInstance, ParachainInfo, - ParachainSystem, PolkadotXcm, PoolAssets, Runtime, RuntimeCall, RuntimeEvent, RuntimeOrigin, - ToWestendXcmRouter, TransactionByteFee, TrustBackedAssetsInstance, Uniques, WeightToFee, - XcmpQueue, + ParachainSystem, PolkadotXcm, PoolAssets, Runtime, RuntimeCall, RuntimeEvent, + RuntimeHoldReason, RuntimeOrigin, ToWestendXcmRouter, TransactionByteFee, + TrustBackedAssetsInstance, Uniques, WeightToFee, XcmpQueue, }; use assets_common::{ matching::{FromNetwork, FromSiblingParachain, IsForeignConcreteAsset, ParentLocation}, @@ -27,12 +27,13 @@ use assets_common::{ use frame_support::{ parameter_types, traits::{ + fungible::HoldConsideration, tokens::imbalance::{ResolveAssetTo, ResolveTo}, - ConstU32, Contains, Equals, Everything, PalletInfoAccess, + ConstU32, Contains, Equals, Everything, LinearStoragePrice, PalletInfoAccess, }, }; use frame_system::EnsureRoot; -use pallet_xcm::XcmPassthrough; +use pallet_xcm::{AuthorizedAliasers, XcmPassthrough}; use parachains_common::{ xcm_config::{ AllSiblingSystemParachains, AssetFeeAsExistentialDepositMultiplier, @@ -330,6 +331,12 @@ pub type TrustedTeleporters = ( IsForeignConcreteAsset>>, ); +/// Defines origin aliasing rules for this chain. +/// +/// - Allow any origin to alias into a child sub-location (equivalent to DescendOrigin), +/// - Allow origins explicitly authorized by the alias target location. +pub type TrustedAliasers = (AliasChildLocation, AuthorizedAliasers); + /// Asset converter for pool assets. /// Used to convert one asset to another, when there is a pool available between the two. /// This type thus allows paying fees with any asset as long as there is a pool between said @@ -444,7 +451,7 @@ impl xcm_executor::Config for XcmConfig { type CallDispatcher = RuntimeCall; type SafeCallFilter = Everything; // We allow any origin to alias into a child sub-location (equivalent to DescendOrigin). - type Aliasers = AliasChildLocation; + type Aliasers = TrustedAliasers; type TransactionalProcessor = FrameTransactionalProcessor; type HrmpNewChannelOpenRequestHandler = (); type HrmpChannelAcceptedHandler = (); @@ -479,6 +486,12 @@ pub type XcmRouter = WithUniqueTopic<( SovereignPaidRemoteExporter, )>; +parameter_types! { + pub const DepositPerItem: Balance = crate::deposit(1, 0); + pub const DepositPerByte: Balance = crate::deposit(0, 1); + pub const AuthorizeAliasHoldReason: RuntimeHoldReason = RuntimeHoldReason::PolkadotXcm(pallet_xcm::HoldReason::AuthorizeAlias); +} + impl pallet_xcm::Config for Runtime { type RuntimeEvent = RuntimeEvent; // We want to disallow users sending (arbitrary) XCMs from this chain. @@ -509,6 +522,12 @@ impl pallet_xcm::Config for Runtime { type AdminOrigin = EnsureRoot; type MaxRemoteLockConsumers = ConstU32<0>; type RemoteLockConsumerIdentifier = (); + type Consideration = HoldConsideration< + AccountId, + Balances, + AuthorizeAliasHoldReason, + LinearStoragePrice, + >; } impl cumulus_pallet_xcm::Config for Runtime { diff --git a/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/xcm_config.rs b/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/xcm_config.rs index 828d4b7486f8..df50bb4aadd7 100644 --- a/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/xcm_config.rs +++ b/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/xcm_config.rs @@ -15,19 +15,23 @@ // along with Cumulus. If not, see . use super::{ - AccountId, AllPalletsWithSystem, Balances, BaseDeliveryFee, FeeAssetId, ParachainInfo, - ParachainSystem, PolkadotXcm, Runtime, RuntimeCall, RuntimeEvent, RuntimeOrigin, - TransactionByteFee, WeightToFee, XcmOverBridgeHubWestend, XcmOverRococoBulletin, XcmpQueue, + AccountId, AllPalletsWithSystem, Balance, Balances, BaseDeliveryFee, FeeAssetId, ParachainInfo, + ParachainSystem, PolkadotXcm, Runtime, RuntimeCall, RuntimeEvent, RuntimeHoldReason, + RuntimeOrigin, TransactionByteFee, WeightToFee, XcmOverBridgeHubWestend, XcmOverRococoBulletin, + XcmpQueue, }; use core::marker::PhantomData; use frame_support::{ parameter_types, - traits::{tokens::imbalance::ResolveTo, ConstU32, Contains, Equals, Everything, Nothing}, + traits::{ + fungible::HoldConsideration, tokens::imbalance::ResolveTo, ConstU32, Contains, Equals, + Everything, LinearStoragePrice, Nothing, + }, }; use frame_system::EnsureRoot; use pallet_collator_selection::StakingPotAccountId; -use pallet_xcm::XcmPassthrough; +use pallet_xcm::{AuthorizedAliasers, XcmPassthrough}; use parachains_common::{ xcm_config::{ AllSiblingSystemParachains, ConcreteAssetFromSystem, ParentRelayOrSiblingParachains, @@ -42,14 +46,14 @@ use sp_runtime::traits::AccountIdConversion; use testnet_parachains_constants::rococo::snowbridge::EthereumNetwork; use xcm::latest::{prelude::*, ROCOCO_GENESIS_HASH}; use xcm_builder::{ - AccountId32Aliases, AllowExplicitUnpaidExecutionFrom, AllowHrmpNotificationsFromRelayChain, - AllowKnownQueryResponses, AllowSubscriptionsFrom, AllowTopLevelPaidExecutionFrom, - DenyReserveTransferToRelayChain, DenyThenTry, DescribeAllTerminal, DescribeFamily, - EnsureXcmOrigin, FrameTransactionalProcessor, FungibleAdapter, HandleFee, HashedDescription, - IsConcrete, ParentAsSuperuser, ParentIsPreset, RelayChainAsNative, SendXcmFeeToAccount, - SiblingParachainAsNative, SiblingParachainConvertsVia, SignedAccountId32AsNative, - SignedToAccountId32, SovereignSignedViaLocation, TakeWeightCredit, TrailingSetTopicAsId, - UsingComponents, WeightInfoBounds, WithComputedOrigin, WithUniqueTopic, + AccountId32Aliases, AliasChildLocation, AllowExplicitUnpaidExecutionFrom, + AllowHrmpNotificationsFromRelayChain, AllowKnownQueryResponses, AllowSubscriptionsFrom, + AllowTopLevelPaidExecutionFrom, DenyReserveTransferToRelayChain, DenyThenTry, + DescribeAllTerminal, DescribeFamily, EnsureXcmOrigin, FrameTransactionalProcessor, + FungibleAdapter, HandleFee, HashedDescription, IsConcrete, ParentAsSuperuser, ParentIsPreset, + RelayChainAsNative, SendXcmFeeToAccount, SiblingParachainAsNative, SiblingParachainConvertsVia, + SignedAccountId32AsNative, SignedToAccountId32, SovereignSignedViaLocation, TakeWeightCredit, + TrailingSetTopicAsId, UsingComponents, WeightInfoBounds, WithComputedOrigin, WithUniqueTopic, }; use xcm_executor::{ traits::{FeeManager, FeeReason, FeeReason::Export}, @@ -174,6 +178,12 @@ pub type WaivedLocations = ( /// - NativeToken with the parent Relay Chain and sibling parachains. pub type TrustedTeleporters = ConcreteAssetFromSystem; +/// Defines origin aliasing rules for this chain. +/// +/// - Allow any origin to alias into a child sub-location (equivalent to DescendOrigin), +/// - Allow origins explicitly authorized by the alias target location. +pub type TrustedAliasers = (AliasChildLocation, AuthorizedAliasers); + pub struct XcmConfig; impl xcm_executor::Config for XcmConfig { type RuntimeCall = RuntimeCall; @@ -228,7 +238,7 @@ impl xcm_executor::Config for XcmConfig { type UniversalAliases = Nothing; type CallDispatcher = RuntimeCall; type SafeCallFilter = Everything; - type Aliasers = Nothing; + type Aliasers = TrustedAliasers; type TransactionalProcessor = FrameTransactionalProcessor; type HrmpNewChannelOpenRequestHandler = (); type HrmpChannelAcceptedHandler = (); @@ -252,6 +262,12 @@ pub type XcmRouter = WithUniqueTopic<( XcmpQueue, )>; +parameter_types! { + pub const DepositPerItem: Balance = crate::deposit(1, 0); + pub const DepositPerByte: Balance = crate::deposit(0, 1); + pub const AuthorizeAliasHoldReason: RuntimeHoldReason = RuntimeHoldReason::PolkadotXcm(pallet_xcm::HoldReason::AuthorizeAlias); +} + impl pallet_xcm::Config for Runtime { type RuntimeEvent = RuntimeEvent; type XcmRouter = XcmRouter; @@ -282,6 +298,12 @@ impl pallet_xcm::Config for Runtime { type AdminOrigin = EnsureRoot; type MaxRemoteLockConsumers = ConstU32<0>; type RemoteLockConsumerIdentifier = (); + type Consideration = HoldConsideration< + AccountId, + Balances, + AuthorizeAliasHoldReason, + LinearStoragePrice, + >; } impl cumulus_pallet_xcm::Config for Runtime { diff --git a/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-westend/src/xcm_config.rs b/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-westend/src/xcm_config.rs index f2c32e31aa2a..7762c8b3381f 100644 --- a/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-westend/src/xcm_config.rs +++ b/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-westend/src/xcm_config.rs @@ -15,17 +15,20 @@ // along with Cumulus. If not, see . use super::{ - AccountId, AllPalletsWithSystem, Balances, BaseDeliveryFee, FeeAssetId, ParachainInfo, - ParachainSystem, PolkadotXcm, Runtime, RuntimeCall, RuntimeEvent, RuntimeOrigin, - TransactionByteFee, WeightToFee, XcmOverBridgeHubRococo, XcmpQueue, + AccountId, AllPalletsWithSystem, Balance, Balances, BaseDeliveryFee, FeeAssetId, ParachainInfo, + ParachainSystem, PolkadotXcm, Runtime, RuntimeCall, RuntimeEvent, RuntimeHoldReason, + RuntimeOrigin, TransactionByteFee, WeightToFee, XcmOverBridgeHubRococo, XcmpQueue, }; use frame_support::{ parameter_types, - traits::{tokens::imbalance::ResolveTo, ConstU32, Contains, Equals, Everything, Nothing}, + traits::{ + fungible::HoldConsideration, tokens::imbalance::ResolveTo, ConstU32, Contains, Equals, + Everything, LinearStoragePrice, Nothing, + }, }; use frame_system::EnsureRoot; use pallet_collator_selection::StakingPotAccountId; -use pallet_xcm::XcmPassthrough; +use pallet_xcm::{AuthorizedAliasers, XcmPassthrough}; use parachains_common::{ xcm_config::{ AllSiblingSystemParachains, ConcreteAssetFromSystem, ParentRelayOrSiblingParachains, @@ -41,14 +44,14 @@ use sp_std::marker::PhantomData; use testnet_parachains_constants::westend::snowbridge::EthereumNetwork; use xcm::latest::{prelude::*, WESTEND_GENESIS_HASH}; use xcm_builder::{ - AccountId32Aliases, AllowExplicitUnpaidExecutionFrom, AllowHrmpNotificationsFromRelayChain, - AllowKnownQueryResponses, AllowSubscriptionsFrom, AllowTopLevelPaidExecutionFrom, - DenyReserveTransferToRelayChain, DenyThenTry, DescribeAllTerminal, DescribeFamily, - EnsureXcmOrigin, FrameTransactionalProcessor, FungibleAdapter, HandleFee, HashedDescription, - IsConcrete, ParentAsSuperuser, ParentIsPreset, RelayChainAsNative, SendXcmFeeToAccount, - SiblingParachainAsNative, SiblingParachainConvertsVia, SignedAccountId32AsNative, - SignedToAccountId32, SovereignSignedViaLocation, TakeWeightCredit, TrailingSetTopicAsId, - UsingComponents, WeightInfoBounds, WithComputedOrigin, WithUniqueTopic, + AccountId32Aliases, AliasChildLocation, AllowExplicitUnpaidExecutionFrom, + AllowHrmpNotificationsFromRelayChain, AllowKnownQueryResponses, AllowSubscriptionsFrom, + AllowTopLevelPaidExecutionFrom, DenyReserveTransferToRelayChain, DenyThenTry, + DescribeAllTerminal, DescribeFamily, EnsureXcmOrigin, FrameTransactionalProcessor, + FungibleAdapter, HandleFee, HashedDescription, IsConcrete, ParentAsSuperuser, ParentIsPreset, + RelayChainAsNative, SendXcmFeeToAccount, SiblingParachainAsNative, SiblingParachainConvertsVia, + SignedAccountId32AsNative, SignedToAccountId32, SovereignSignedViaLocation, TakeWeightCredit, + TrailingSetTopicAsId, UsingComponents, WeightInfoBounds, WithComputedOrigin, WithUniqueTopic, }; use xcm_executor::{ traits::{FeeManager, FeeReason, FeeReason::Export}, @@ -171,6 +174,12 @@ pub type WaivedLocations = ( /// - NativeToken with the parent Relay Chain and sibling parachains. pub type TrustedTeleporters = ConcreteAssetFromSystem; +/// Defines origin aliasing rules for this chain. +/// +/// - Allow any origin to alias into a child sub-location (equivalent to DescendOrigin), +/// - Allow origins explicitly authorized by the alias target location. +pub type TrustedAliasers = (AliasChildLocation, AuthorizedAliasers); + pub struct XcmConfig; impl xcm_executor::Config for XcmConfig { type RuntimeCall = RuntimeCall; @@ -222,7 +231,7 @@ impl xcm_executor::Config for XcmConfig { type UniversalAliases = Nothing; type CallDispatcher = RuntimeCall; type SafeCallFilter = Everything; - type Aliasers = Nothing; + type Aliasers = TrustedAliasers; type TransactionalProcessor = FrameTransactionalProcessor; type HrmpNewChannelOpenRequestHandler = (); type HrmpChannelAcceptedHandler = (); @@ -246,6 +255,12 @@ pub type XcmRouter = WithUniqueTopic<( XcmpQueue, )>; +parameter_types! { + pub const DepositPerItem: Balance = crate::deposit(1, 0); + pub const DepositPerByte: Balance = crate::deposit(0, 1); + pub const AuthorizeAliasHoldReason: RuntimeHoldReason = RuntimeHoldReason::PolkadotXcm(pallet_xcm::HoldReason::AuthorizeAlias); +} + impl pallet_xcm::Config for Runtime { type RuntimeEvent = RuntimeEvent; type XcmRouter = XcmRouter; @@ -276,6 +291,12 @@ impl pallet_xcm::Config for Runtime { type AdminOrigin = EnsureRoot; type MaxRemoteLockConsumers = ConstU32<0>; type RemoteLockConsumerIdentifier = (); + type Consideration = HoldConsideration< + AccountId, + Balances, + AuthorizeAliasHoldReason, + LinearStoragePrice, + >; } impl cumulus_pallet_xcm::Config for Runtime { diff --git a/cumulus/parachains/runtimes/collectives/collectives-westend/src/xcm_config.rs b/cumulus/parachains/runtimes/collectives/collectives-westend/src/xcm_config.rs index 6a98e3cbb526..cf9e253b7d84 100644 --- a/cumulus/parachains/runtimes/collectives/collectives-westend/src/xcm_config.rs +++ b/cumulus/parachains/runtimes/collectives/collectives-westend/src/xcm_config.rs @@ -14,17 +14,21 @@ // limitations under the License. use super::{ - AccountId, AllPalletsWithSystem, Balances, BaseDeliveryFee, FeeAssetId, Fellows, ParachainInfo, - ParachainSystem, PolkadotXcm, Runtime, RuntimeCall, RuntimeEvent, RuntimeOrigin, - TransactionByteFee, WeightToFee, WestendTreasuryAccount, XcmpQueue, + AccountId, AllPalletsWithSystem, Balance, Balances, BaseDeliveryFee, FeeAssetId, Fellows, + ParachainInfo, ParachainSystem, PolkadotXcm, Runtime, RuntimeCall, RuntimeEvent, + RuntimeHoldReason, RuntimeOrigin, TransactionByteFee, WeightToFee, WestendTreasuryAccount, + XcmpQueue, }; use frame_support::{ parameter_types, - traits::{tokens::imbalance::ResolveTo, ConstU32, Contains, Equals, Everything, Nothing}, + traits::{ + fungible::HoldConsideration, tokens::imbalance::ResolveTo, ConstU32, Contains, Equals, + Everything, LinearStoragePrice, Nothing, + }, }; use frame_system::EnsureRoot; use pallet_collator_selection::StakingPotAccountId; -use pallet_xcm::XcmPassthrough; +use pallet_xcm::{AuthorizedAliasers, XcmPassthrough}; use parachains_common::xcm_config::{ AllSiblingSystemParachains, ConcreteAssetFromSystem, ParentRelayOrSiblingParachains, RelayOrOtherSystemParachains, @@ -183,12 +187,19 @@ pub type WaivedLocations = ( ); /// Cases where a remote origin is accepted as trusted Teleporter for a given asset: -/// - DOT with the parent Relay Chain and sibling parachains. +/// - WND with the parent Relay Chain and sibling parachains. pub type TrustedTeleporters = ConcreteAssetFromSystem; -/// We allow locations to alias into their own child locations, as well as -/// AssetHub to alias into anything. -pub type Aliasers = (AliasChildLocation, AliasOriginRootUsingFilter); +/// Defines origin aliasing rules for this chain. +/// +/// - Allow any origin to alias into a child sub-location (equivalent to DescendOrigin), +/// - Allow origins explicitly authorized by the alias target location. +/// - Allow AssetHub root to alias into anything. +pub type TrustedAliasers = ( + AliasChildLocation, + AliasOriginRootUsingFilter, + AuthorizedAliasers, +); pub struct XcmConfig; impl xcm_executor::Config for XcmConfig { @@ -230,7 +241,7 @@ impl xcm_executor::Config for XcmConfig { type UniversalAliases = Nothing; type CallDispatcher = RuntimeCall; type SafeCallFilter = Everything; - type Aliasers = Aliasers; + type Aliasers = TrustedAliasers; type TransactionalProcessor = FrameTransactionalProcessor; type HrmpNewChannelOpenRequestHandler = (); type HrmpChannelAcceptedHandler = (); @@ -262,6 +273,12 @@ parameter_types! { /// Type to convert the Fellows origin to a Plurality `Location` value. pub type FellowsToPlurality = OriginToPluralityVoice; +parameter_types! { + pub const DepositPerItem: Balance = crate::deposit(1, 0); + pub const DepositPerByte: Balance = crate::deposit(0, 1); + pub const AuthorizeAliasHoldReason: RuntimeHoldReason = RuntimeHoldReason::PolkadotXcm(pallet_xcm::HoldReason::AuthorizeAlias); +} + impl pallet_xcm::Config for Runtime { type RuntimeEvent = RuntimeEvent; // We only allow the Fellows to send messages. @@ -292,6 +309,12 @@ impl pallet_xcm::Config for Runtime { type AdminOrigin = EnsureRoot; type MaxRemoteLockConsumers = ConstU32<0>; type RemoteLockConsumerIdentifier = (); + type Consideration = HoldConsideration< + AccountId, + Balances, + AuthorizeAliasHoldReason, + LinearStoragePrice, + >; } impl cumulus_pallet_xcm::Config for Runtime { diff --git a/cumulus/parachains/runtimes/coretime/coretime-rococo/src/xcm_config.rs b/cumulus/parachains/runtimes/coretime/coretime-rococo/src/xcm_config.rs index 33ad172962a1..8f0b993963dd 100644 --- a/cumulus/parachains/runtimes/coretime/coretime-rococo/src/xcm_config.rs +++ b/cumulus/parachains/runtimes/coretime/coretime-rococo/src/xcm_config.rs @@ -183,6 +183,10 @@ pub type WaivedLocations = ( Equals, ); +/// Cases where a remote origin is accepted as trusted Teleporter for a given asset: +/// - ROC with the parent Relay Chain and sibling parachains. +pub type TrustedTeleporters = ConcreteAssetFromSystem; + pub struct XcmConfig; impl xcm_executor::Config for XcmConfig { type RuntimeCall = RuntimeCall; @@ -192,8 +196,7 @@ impl xcm_executor::Config for XcmConfig { // Coretime chain does not recognize a reserve location for any asset. Users must teleport ROC // where allowed (e.g. with the Relay Chain). type IsReserve = (); - /// Only allow teleportation of ROC. - type IsTeleporter = ConcreteAssetFromSystem; + type IsTeleporter = TrustedTeleporters; type UniversalLocation = UniversalLocation; type Barrier = Barrier; type Weigher = WeightInfoBounds< @@ -278,6 +281,7 @@ impl pallet_xcm::Config for Runtime { type AdminOrigin = EnsureRoot; type MaxRemoteLockConsumers = ConstU32<0>; type RemoteLockConsumerIdentifier = (); + type Consideration = (); } impl cumulus_pallet_xcm::Config for Runtime { diff --git a/cumulus/parachains/runtimes/coretime/coretime-westend/src/xcm_config.rs b/cumulus/parachains/runtimes/coretime/coretime-westend/src/xcm_config.rs index 8a4879a1506e..e21c6bb807f8 100644 --- a/cumulus/parachains/runtimes/coretime/coretime-westend/src/xcm_config.rs +++ b/cumulus/parachains/runtimes/coretime/coretime-westend/src/xcm_config.rs @@ -15,18 +15,21 @@ // along with Cumulus. If not, see . use super::{ - AccountId, AllPalletsWithSystem, Balances, BaseDeliveryFee, Broker, FeeAssetId, ParachainInfo, - ParachainSystem, PolkadotXcm, Runtime, RuntimeCall, RuntimeEvent, RuntimeOrigin, - TransactionByteFee, WeightToFee, XcmpQueue, + AccountId, AllPalletsWithSystem, Balance, Balances, BaseDeliveryFee, Broker, FeeAssetId, + ParachainInfo, ParachainSystem, PolkadotXcm, Runtime, RuntimeCall, RuntimeEvent, + RuntimeHoldReason, RuntimeOrigin, TransactionByteFee, WeightToFee, XcmpQueue, }; use frame_support::{ pallet_prelude::PalletInfoAccess, parameter_types, - traits::{tokens::imbalance::ResolveTo, ConstU32, Contains, Equals, Everything, Nothing}, + traits::{ + fungible::HoldConsideration, tokens::imbalance::ResolveTo, ConstU32, Contains, Equals, + Everything, LinearStoragePrice, Nothing, + }, }; use frame_system::EnsureRoot; use pallet_collator_selection::StakingPotAccountId; -use pallet_xcm::XcmPassthrough; +use pallet_xcm::{AuthorizedAliasers, XcmPassthrough}; use parachains_common::{ xcm_config::{ AllSiblingSystemParachains, ConcreteAssetFromSystem, ParentRelayOrSiblingParachains, @@ -193,9 +196,20 @@ pub type WaivedLocations = ( Equals, ); -/// We allow locations to alias into their own child locations, as well as -/// AssetHub to alias into anything. -pub type Aliasers = (AliasChildLocation, AliasOriginRootUsingFilter); +/// Cases where a remote origin is accepted as trusted Teleporter for a given asset: +/// - WND with the parent Relay Chain and sibling parachains. +pub type TrustedTeleporters = ConcreteAssetFromSystem; + +/// Defines origin aliasing rules for this chain. +/// +/// - Allow any origin to alias into a child sub-location (equivalent to DescendOrigin), +/// - Allow origins explicitly authorized by the alias target location. +/// - Allow AssetHub root to alias into anything. +pub type TrustedAliasers = ( + AliasChildLocation, + AliasOriginRootUsingFilter, + AuthorizedAliasers, +); pub struct XcmConfig; impl xcm_executor::Config for XcmConfig { @@ -206,8 +220,7 @@ impl xcm_executor::Config for XcmConfig { // Coretime chain does not recognize a reserve location for any asset. Users must teleport ROC // where allowed (e.g. with the Relay Chain). type IsReserve = (); - /// Only allow teleportation of WND. - type IsTeleporter = ConcreteAssetFromSystem; + type IsTeleporter = TrustedTeleporters; type UniversalLocation = UniversalLocation; type Barrier = Barrier; type Weigher = WeightInfoBounds< @@ -238,7 +251,7 @@ impl xcm_executor::Config for XcmConfig { type UniversalAliases = Nothing; type CallDispatcher = RuntimeCall; type SafeCallFilter = Everything; - type Aliasers = Aliasers; + type Aliasers = TrustedAliasers; type TransactionalProcessor = FrameTransactionalProcessor; type HrmpNewChannelOpenRequestHandler = (); type HrmpChannelAcceptedHandler = (); @@ -262,6 +275,12 @@ pub type XcmRouter = WithUniqueTopic<( XcmpQueue, )>; +parameter_types! { + pub const DepositPerItem: Balance = crate::deposit(1, 0); + pub const DepositPerByte: Balance = crate::deposit(0, 1); + pub const AuthorizeAliasHoldReason: RuntimeHoldReason = RuntimeHoldReason::PolkadotXcm(pallet_xcm::HoldReason::AuthorizeAlias); +} + impl pallet_xcm::Config for Runtime { type RuntimeEvent = RuntimeEvent; // We want to disallow users sending (arbitrary) XCM programs from this chain. @@ -292,6 +311,12 @@ impl pallet_xcm::Config for Runtime { type AdminOrigin = EnsureRoot; type MaxRemoteLockConsumers = ConstU32<0>; type RemoteLockConsumerIdentifier = (); + type Consideration = HoldConsideration< + AccountId, + Balances, + AuthorizeAliasHoldReason, + LinearStoragePrice, + >; } impl cumulus_pallet_xcm::Config for Runtime { diff --git a/cumulus/parachains/runtimes/people/people-rococo/src/xcm_config.rs b/cumulus/parachains/runtimes/people/people-rococo/src/xcm_config.rs index 724d87587c6c..6516455f43f3 100644 --- a/cumulus/parachains/runtimes/people/people-rococo/src/xcm_config.rs +++ b/cumulus/parachains/runtimes/people/people-rococo/src/xcm_config.rs @@ -279,6 +279,7 @@ impl pallet_xcm::Config for Runtime { type AdminOrigin = EnsureRoot; type MaxRemoteLockConsumers = ConstU32<0>; type RemoteLockConsumerIdentifier = (); + type Consideration = (); } impl cumulus_pallet_xcm::Config for Runtime { diff --git a/cumulus/parachains/runtimes/people/people-westend/src/xcm_config.rs b/cumulus/parachains/runtimes/people/people-westend/src/xcm_config.rs index 7eaa43c05b20..b2cb083e87a7 100644 --- a/cumulus/parachains/runtimes/people/people-westend/src/xcm_config.rs +++ b/cumulus/parachains/runtimes/people/people-westend/src/xcm_config.rs @@ -14,17 +14,21 @@ // limitations under the License. use super::{ - AccountId, AllPalletsWithSystem, Balances, ParachainInfo, ParachainSystem, PolkadotXcm, - Runtime, RuntimeCall, RuntimeEvent, RuntimeOrigin, WeightToFee, XcmpQueue, + AccountId, AllPalletsWithSystem, Balance, Balances, ParachainInfo, ParachainSystem, + PolkadotXcm, Runtime, RuntimeCall, RuntimeEvent, RuntimeHoldReason, RuntimeOrigin, WeightToFee, + XcmpQueue, }; use crate::{TransactionByteFee, CENTS}; use frame_support::{ parameter_types, - traits::{tokens::imbalance::ResolveTo, ConstU32, Contains, Equals, Everything, Nothing}, + traits::{ + fungible::HoldConsideration, tokens::imbalance::ResolveTo, ConstU32, Contains, Equals, + Everything, LinearStoragePrice, Nothing, + }, }; use frame_system::EnsureRoot; use pallet_collator_selection::StakingPotAccountId; -use pallet_xcm::XcmPassthrough; +use pallet_xcm::{AuthorizedAliasers, XcmPassthrough}; use parachains_common::{ xcm_config::{ AllSiblingSystemParachains, ConcreteAssetFromSystem, ParentRelayOrSiblingParachains, @@ -197,9 +201,20 @@ pub type WaivedLocations = ( LocalPlurality, ); -/// We allow locations to alias into their own child locations, as well as -/// AssetHub to alias into anything. -pub type Aliasers = (AliasChildLocation, AliasOriginRootUsingFilter); +/// Cases where a remote origin is accepted as trusted Teleporter for a given asset: +/// - WND with the parent Relay Chain and sibling parachains. +pub type TrustedTeleporters = ConcreteAssetFromSystem; + +/// Defines origin aliasing rules for this chain. +/// +/// - Allow any origin to alias into a child sub-location (equivalent to DescendOrigin), +/// - Allow origins explicitly authorized by the alias target location. +/// - Allow AssetHub root to alias into anything. +pub type TrustedAliasers = ( + AliasChildLocation, + AliasOriginRootUsingFilter, + AuthorizedAliasers, +); pub struct XcmConfig; impl xcm_executor::Config for XcmConfig { @@ -210,8 +225,7 @@ impl xcm_executor::Config for XcmConfig { // People does not recognize a reserve location for any asset. Users must teleport WND // where allowed (e.g. with the Relay Chain). type IsReserve = (); - /// Only allow teleportation of WND amongst the system. - type IsTeleporter = ConcreteAssetFromSystem; + type IsTeleporter = TrustedTeleporters; type UniversalLocation = UniversalLocation; type Barrier = Barrier; type Weigher = WeightInfoBounds< @@ -242,7 +256,7 @@ impl xcm_executor::Config for XcmConfig { type UniversalAliases = Nothing; type CallDispatcher = RuntimeCall; type SafeCallFilter = Everything; - type Aliasers = Aliasers; + type Aliasers = TrustedAliasers; type TransactionalProcessor = FrameTransactionalProcessor; type HrmpNewChannelOpenRequestHandler = (); type HrmpChannelAcceptedHandler = (); @@ -263,6 +277,12 @@ pub type XcmRouter = WithUniqueTopic<( XcmpQueue, )>; +parameter_types! { + pub const DepositPerItem: Balance = crate::deposit(1, 0); + pub const DepositPerByte: Balance = crate::deposit(0, 1); + pub const AuthorizeAliasHoldReason: RuntimeHoldReason = RuntimeHoldReason::PolkadotXcm(pallet_xcm::HoldReason::AuthorizeAlias); +} + impl pallet_xcm::Config for Runtime { type RuntimeEvent = RuntimeEvent; // We want to disallow users sending (arbitrary) XCMs from this chain. @@ -293,6 +313,12 @@ impl pallet_xcm::Config for Runtime { type AdminOrigin = EnsureRoot; type MaxRemoteLockConsumers = ConstU32<0>; type RemoteLockConsumerIdentifier = (); + type Consideration = HoldConsideration< + AccountId, + Balances, + AuthorizeAliasHoldReason, + LinearStoragePrice, + >; } impl cumulus_pallet_xcm::Config for Runtime { diff --git a/cumulus/parachains/runtimes/testing/penpal/Cargo.toml b/cumulus/parachains/runtimes/testing/penpal/Cargo.toml index 5b17f4f57388..95302f486675 100644 --- a/cumulus/parachains/runtimes/testing/penpal/Cargo.toml +++ b/cumulus/parachains/runtimes/testing/penpal/Cargo.toml @@ -80,6 +80,7 @@ pallet-message-queue = { workspace = true } parachain-info = { workspace = true } parachains-common = { workspace = true } snowbridge-router-primitives = { workspace = true } +testnet-parachains-constants = { features = ["westend"], workspace = true } primitive-types = { version = "0.12.1", default-features = false, features = ["codec", "num-traits", "scale-info"] } diff --git a/cumulus/parachains/runtimes/testing/penpal/src/xcm_config.rs b/cumulus/parachains/runtimes/testing/penpal/src/xcm_config.rs index e2b010c3227d..ac9d0e308c3a 100644 --- a/cumulus/parachains/runtimes/testing/penpal/src/xcm_config.rs +++ b/cumulus/parachains/runtimes/testing/penpal/src/xcm_config.rs @@ -25,8 +25,8 @@ use super::{ AccountId, AllPalletsWithSystem, AssetId as AssetIdPalletAssets, Assets, Authorship, Balance, Balances, CollatorSelection, ForeignAssets, ForeignAssetsInstance, NonZeroIssuance, - ParachainInfo, ParachainSystem, PolkadotXcm, Runtime, RuntimeCall, RuntimeEvent, RuntimeOrigin, - WeightToFee, XcmpQueue, + ParachainInfo, ParachainSystem, PolkadotXcm, Runtime, RuntimeCall, RuntimeEvent, + RuntimeHoldReason, RuntimeOrigin, WeightToFee, XcmpQueue, }; use crate::{BaseDeliveryFee, FeeAssetId, TransactionByteFee}; use assets_common::TrustBackedAssetsAsLocation; @@ -34,30 +34,33 @@ use core::marker::PhantomData; use frame_support::{ parameter_types, traits::{ - tokens::imbalance::ResolveAssetTo, ConstU32, Contains, ContainsPair, Equals, Everything, - EverythingBut, Get, Nothing, PalletInfoAccess, + fungible::HoldConsideration, tokens::imbalance::ResolveAssetTo, ConstU32, Contains, + ContainsPair, Equals, Everything, EverythingBut, Get, LinearStoragePrice, Nothing, + PalletInfoAccess, }, weights::Weight, }; use frame_system::EnsureRoot; -use pallet_xcm::XcmPassthrough; +use pallet_xcm::{AuthorizedAliasers, XcmPassthrough}; use parachains_common::{xcm_config::AssetFeeAsExistentialDepositMultiplier, TREASURY_PALLET_ID}; use polkadot_parachain_primitives::primitives::Sibling; use polkadot_runtime_common::{impls::ToAuthor, xcm_sender::ExponentialPrice}; use snowbridge_router_primitives::inbound::EthereumLocationsConverterFor; use sp_runtime::traits::{AccountIdConversion, ConvertInto, Identity, TryConvertInto}; +use testnet_parachains_constants::westend::currency::deposit; use xcm::latest::{prelude::*, WESTEND_GENESIS_HASH}; use xcm_builder::{ - AccountId32Aliases, AliasOriginRootUsingFilter, AllowHrmpNotificationsFromRelayChain, - AllowKnownQueryResponses, AllowSubscriptionsFrom, AllowTopLevelPaidExecutionFrom, - AsPrefixedGeneralIndex, ConvertedConcreteId, DescribeAllTerminal, DescribeFamily, - EnsureXcmOrigin, FixedWeightBounds, FrameTransactionalProcessor, FungibleAdapter, - FungiblesAdapter, GlobalConsensusParachainConvertsFor, HashedDescription, IsConcrete, - LocalMint, NativeAsset, NoChecking, ParentAsSuperuser, ParentIsPreset, RelayChainAsNative, - SendXcmFeeToAccount, SiblingParachainAsNative, SiblingParachainConvertsVia, - SignedAccountId32AsNative, SignedToAccountId32, SingleAssetExchangeAdapter, - SovereignSignedViaLocation, StartsWith, TakeWeightCredit, TrailingSetTopicAsId, - UsingComponents, WithComputedOrigin, WithUniqueTopic, XcmFeeManagerFromComponents, + AccountId32Aliases, AliasChildLocation, AliasOriginRootUsingFilter, + AllowHrmpNotificationsFromRelayChain, AllowKnownQueryResponses, AllowSubscriptionsFrom, + AllowTopLevelPaidExecutionFrom, AsPrefixedGeneralIndex, ConvertedConcreteId, + DescribeAllTerminal, DescribeFamily, EnsureXcmOrigin, FixedWeightBounds, + FrameTransactionalProcessor, FungibleAdapter, FungiblesAdapter, + GlobalConsensusParachainConvertsFor, HashedDescription, IsConcrete, LocalMint, NativeAsset, + NoChecking, ParentAsSuperuser, ParentIsPreset, RelayChainAsNative, SendXcmFeeToAccount, + SiblingParachainAsNative, SiblingParachainConvertsVia, SignedAccountId32AsNative, + SignedToAccountId32, SingleAssetExchangeAdapter, SovereignSignedViaLocation, StartsWith, + TakeWeightCredit, TrailingSetTopicAsId, UsingComponents, WithComputedOrigin, WithUniqueTopic, + XcmFeeManagerFromComponents, }; use xcm_executor::{traits::JustTry, XcmExecutor}; @@ -337,6 +340,17 @@ pub type TrustedReserves = ( pub type TrustedTeleporters = (AssetFromChain,); +/// Defines origin aliasing rules for this chain. +/// +/// - Allow any origin to alias into a child sub-location (equivalent to DescendOrigin), +/// - Allow origins explicitly authorized by the alias target location. +/// - Allow AssetHub root to alias into anything. +pub type TrustedAliasers = ( + AliasChildLocation, + AliasOriginRootUsingFilter, + AuthorizedAliasers, +); + pub type WaivedLocations = Equals; /// `AssetId`/`Balance` converter for `TrustBackedAssets`. pub type TrustBackedAssetsConvertedConcreteId = @@ -408,8 +422,7 @@ impl xcm_executor::Config for XcmConfig { type UniversalAliases = Nothing; type CallDispatcher = RuntimeCall; type SafeCallFilter = Everything; - // We allow trusted Asset Hub root to alias other locations. - type Aliasers = AliasOriginRootUsingFilter; + type Aliasers = TrustedAliasers; type TransactionalProcessor = FrameTransactionalProcessor; type HrmpNewChannelOpenRequestHandler = (); type HrmpChannelAcceptedHandler = (); @@ -442,6 +455,12 @@ pub type XcmRouter = WithUniqueTopic<( XcmpQueue, )>; +parameter_types! { + pub const DepositPerItem: Balance = deposit(1, 0); + pub const DepositPerByte: Balance = deposit(0, 1); + pub const AuthorizeAliasHoldReason: RuntimeHoldReason = RuntimeHoldReason::PolkadotXcm(pallet_xcm::HoldReason::AuthorizeAlias); +} + impl pallet_xcm::Config for Runtime { type RuntimeEvent = RuntimeEvent; type SendXcmOrigin = EnsureXcmOrigin; @@ -468,6 +487,12 @@ impl pallet_xcm::Config for Runtime { type AdminOrigin = EnsureRoot; type MaxRemoteLockConsumers = ConstU32<0>; type RemoteLockConsumerIdentifier = (); + type Consideration = HoldConsideration< + AccountId, + Balances, + AuthorizeAliasHoldReason, + LinearStoragePrice, + >; } impl cumulus_pallet_xcm::Config for Runtime { diff --git a/prdoc/pr_6336.prdoc b/prdoc/pr_6336.prdoc index 82cbfc1e4478..f02f2aaa8f33 100644 --- a/prdoc/pr_6336.prdoc +++ b/prdoc/pr_6336.prdoc @@ -23,7 +23,7 @@ doc: crates: - name: pallet-xcm - bump: minor + bump: major - name: xcm-runtime-apis bump: minor - name: staging-xcm-builder From 97929135e04c7f2dbd37d40c8265c3b257ebd127 Mon Sep 17 00:00:00 2001 From: Adrian Catangiu Date: Thu, 16 Jan 2025 12:08:58 +0200 Subject: [PATCH 31/40] better configure runtimes --- .../assets/asset-hub-rococo/src/xcm_config.rs | 3 ++- .../asset-hub-westend/src/xcm_config.rs | 3 ++- .../bridge-hub-rococo/src/xcm_config.rs | 3 ++- .../bridge-hub-westend/src/xcm_config.rs | 3 ++- .../collectives-westend/src/xcm_config.rs | 3 ++- .../coretime-rococo/src/xcm_config.rs | 7 +++++-- .../coretime-westend/src/xcm_config.rs | 3 ++- .../people/people-rococo/src/xcm_config.rs | 7 +++++-- .../people/people-westend/src/xcm_config.rs | 3 ++- .../runtimes/testing/penpal/src/xcm_config.rs | 3 ++- polkadot/runtime/rococo/src/xcm_config.rs | 4 +++- polkadot/runtime/westend/src/xcm_config.rs | 4 +++- polkadot/xcm/pallet-xcm/src/lib.rs | 6 +++--- polkadot/xcm/pallet-xcm/src/mock.rs | 2 +- substrate/frame/support/src/traits.rs | 5 +++-- substrate/frame/support/src/traits/storage.rs | 20 ++++++++++++++++++- 16 files changed, 58 insertions(+), 21 deletions(-) diff --git a/cumulus/parachains/runtimes/assets/asset-hub-rococo/src/xcm_config.rs b/cumulus/parachains/runtimes/assets/asset-hub-rococo/src/xcm_config.rs index 53b5918be966..6c64bb90e92b 100644 --- a/cumulus/parachains/runtimes/assets/asset-hub-rococo/src/xcm_config.rs +++ b/cumulus/parachains/runtimes/assets/asset-hub-rococo/src/xcm_config.rs @@ -522,7 +522,8 @@ impl pallet_xcm::Config for Runtime { type AdminOrigin = EnsureRoot; type MaxRemoteLockConsumers = ConstU32<0>; type RemoteLockConsumerIdentifier = (); - type Consideration = HoldConsideration< + // xcm_executor::Config::Aliasers also uses pallet_xcm::AuthorizedAliasers. + type AuthorizedAliasConsideration = HoldConsideration< AccountId, Balances, AuthorizeAliasHoldReason, diff --git a/cumulus/parachains/runtimes/assets/asset-hub-westend/src/xcm_config.rs b/cumulus/parachains/runtimes/assets/asset-hub-westend/src/xcm_config.rs index 34aa50bcb029..2b6263a92d76 100644 --- a/cumulus/parachains/runtimes/assets/asset-hub-westend/src/xcm_config.rs +++ b/cumulus/parachains/runtimes/assets/asset-hub-westend/src/xcm_config.rs @@ -543,7 +543,8 @@ impl pallet_xcm::Config for Runtime { type AdminOrigin = EnsureRoot; type MaxRemoteLockConsumers = ConstU32<0>; type RemoteLockConsumerIdentifier = (); - type Consideration = HoldConsideration< + // xcm_executor::Config::Aliasers also uses pallet_xcm::AuthorizedAliasers. + type AuthorizedAliasConsideration = HoldConsideration< AccountId, Balances, AuthorizeAliasHoldReason, diff --git a/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/xcm_config.rs b/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/xcm_config.rs index df50bb4aadd7..056eefc927e8 100644 --- a/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/xcm_config.rs +++ b/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/xcm_config.rs @@ -298,7 +298,8 @@ impl pallet_xcm::Config for Runtime { type AdminOrigin = EnsureRoot; type MaxRemoteLockConsumers = ConstU32<0>; type RemoteLockConsumerIdentifier = (); - type Consideration = HoldConsideration< + // xcm_executor::Config::Aliasers also uses pallet_xcm::AuthorizedAliasers. + type AuthorizedAliasConsideration = HoldConsideration< AccountId, Balances, AuthorizeAliasHoldReason, diff --git a/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-westend/src/xcm_config.rs b/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-westend/src/xcm_config.rs index 7762c8b3381f..6f9a366c16a5 100644 --- a/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-westend/src/xcm_config.rs +++ b/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-westend/src/xcm_config.rs @@ -291,7 +291,8 @@ impl pallet_xcm::Config for Runtime { type AdminOrigin = EnsureRoot; type MaxRemoteLockConsumers = ConstU32<0>; type RemoteLockConsumerIdentifier = (); - type Consideration = HoldConsideration< + // xcm_executor::Config::Aliasers also uses pallet_xcm::AuthorizedAliasers. + type AuthorizedAliasConsideration = HoldConsideration< AccountId, Balances, AuthorizeAliasHoldReason, diff --git a/cumulus/parachains/runtimes/collectives/collectives-westend/src/xcm_config.rs b/cumulus/parachains/runtimes/collectives/collectives-westend/src/xcm_config.rs index cf9e253b7d84..f9f91a350c34 100644 --- a/cumulus/parachains/runtimes/collectives/collectives-westend/src/xcm_config.rs +++ b/cumulus/parachains/runtimes/collectives/collectives-westend/src/xcm_config.rs @@ -309,7 +309,8 @@ impl pallet_xcm::Config for Runtime { type AdminOrigin = EnsureRoot; type MaxRemoteLockConsumers = ConstU32<0>; type RemoteLockConsumerIdentifier = (); - type Consideration = HoldConsideration< + // xcm_executor::Config::Aliasers also uses pallet_xcm::AuthorizedAliasers. + type AuthorizedAliasConsideration = HoldConsideration< AccountId, Balances, AuthorizeAliasHoldReason, diff --git a/cumulus/parachains/runtimes/coretime/coretime-rococo/src/xcm_config.rs b/cumulus/parachains/runtimes/coretime/coretime-rococo/src/xcm_config.rs index 8f0b993963dd..fe5999d2acfa 100644 --- a/cumulus/parachains/runtimes/coretime/coretime-rococo/src/xcm_config.rs +++ b/cumulus/parachains/runtimes/coretime/coretime-rococo/src/xcm_config.rs @@ -22,7 +22,9 @@ use super::{ use frame_support::{ pallet_prelude::PalletInfoAccess, parameter_types, - traits::{tokens::imbalance::ResolveTo, ConstU32, Contains, Equals, Everything, Nothing}, + traits::{ + tokens::imbalance::ResolveTo, ConstU32, Contains, Disabled, Equals, Everything, Nothing, + }, }; use frame_system::EnsureRoot; use pallet_collator_selection::StakingPotAccountId; @@ -281,7 +283,8 @@ impl pallet_xcm::Config for Runtime { type AdminOrigin = EnsureRoot; type MaxRemoteLockConsumers = ConstU32<0>; type RemoteLockConsumerIdentifier = (); - type Consideration = (); + // Aliasing is disabled: xcm_executor::Config::Aliasers is set to `Nothing`. + type AuthorizedAliasConsideration = Disabled; } impl cumulus_pallet_xcm::Config for Runtime { diff --git a/cumulus/parachains/runtimes/coretime/coretime-westend/src/xcm_config.rs b/cumulus/parachains/runtimes/coretime/coretime-westend/src/xcm_config.rs index e21c6bb807f8..cec0bbb9d2f9 100644 --- a/cumulus/parachains/runtimes/coretime/coretime-westend/src/xcm_config.rs +++ b/cumulus/parachains/runtimes/coretime/coretime-westend/src/xcm_config.rs @@ -311,7 +311,8 @@ impl pallet_xcm::Config for Runtime { type AdminOrigin = EnsureRoot; type MaxRemoteLockConsumers = ConstU32<0>; type RemoteLockConsumerIdentifier = (); - type Consideration = HoldConsideration< + // xcm_executor::Config::Aliasers also uses pallet_xcm::AuthorizedAliasers. + type AuthorizedAliasConsideration = HoldConsideration< AccountId, Balances, AuthorizeAliasHoldReason, diff --git a/cumulus/parachains/runtimes/people/people-rococo/src/xcm_config.rs b/cumulus/parachains/runtimes/people/people-rococo/src/xcm_config.rs index 6516455f43f3..66da4cf6e0d8 100644 --- a/cumulus/parachains/runtimes/people/people-rococo/src/xcm_config.rs +++ b/cumulus/parachains/runtimes/people/people-rococo/src/xcm_config.rs @@ -20,7 +20,9 @@ use super::{ use crate::{TransactionByteFee, CENTS}; use frame_support::{ parameter_types, - traits::{tokens::imbalance::ResolveTo, ConstU32, Contains, Equals, Everything, Nothing}, + traits::{ + tokens::imbalance::ResolveTo, ConstU32, Contains, Disabled, Equals, Everything, Nothing, + }, }; use frame_system::EnsureRoot; use pallet_collator_selection::StakingPotAccountId; @@ -279,7 +281,8 @@ impl pallet_xcm::Config for Runtime { type AdminOrigin = EnsureRoot; type MaxRemoteLockConsumers = ConstU32<0>; type RemoteLockConsumerIdentifier = (); - type Consideration = (); + // Aliasing is disabled: xcm_executor::Config::Aliasers is set to `Nothing`. + type AuthorizedAliasConsideration = Disabled; } impl cumulus_pallet_xcm::Config for Runtime { diff --git a/cumulus/parachains/runtimes/people/people-westend/src/xcm_config.rs b/cumulus/parachains/runtimes/people/people-westend/src/xcm_config.rs index b2cb083e87a7..46fd5d99c129 100644 --- a/cumulus/parachains/runtimes/people/people-westend/src/xcm_config.rs +++ b/cumulus/parachains/runtimes/people/people-westend/src/xcm_config.rs @@ -313,7 +313,8 @@ impl pallet_xcm::Config for Runtime { type AdminOrigin = EnsureRoot; type MaxRemoteLockConsumers = ConstU32<0>; type RemoteLockConsumerIdentifier = (); - type Consideration = HoldConsideration< + // xcm_executor::Config::Aliasers also uses pallet_xcm::AuthorizedAliasers. + type AuthorizedAliasConsideration = HoldConsideration< AccountId, Balances, AuthorizeAliasHoldReason, diff --git a/cumulus/parachains/runtimes/testing/penpal/src/xcm_config.rs b/cumulus/parachains/runtimes/testing/penpal/src/xcm_config.rs index ac9d0e308c3a..a745d784ff5b 100644 --- a/cumulus/parachains/runtimes/testing/penpal/src/xcm_config.rs +++ b/cumulus/parachains/runtimes/testing/penpal/src/xcm_config.rs @@ -487,7 +487,8 @@ impl pallet_xcm::Config for Runtime { type AdminOrigin = EnsureRoot; type MaxRemoteLockConsumers = ConstU32<0>; type RemoteLockConsumerIdentifier = (); - type Consideration = HoldConsideration< + // xcm_executor::Config::Aliasers also uses pallet_xcm::AuthorizedAliasers. + type AuthorizedAliasConsideration = HoldConsideration< AccountId, Balances, AuthorizeAliasHoldReason, diff --git a/polkadot/runtime/rococo/src/xcm_config.rs b/polkadot/runtime/rococo/src/xcm_config.rs index bb77ec0000e5..3e1e996d2976 100644 --- a/polkadot/runtime/rococo/src/xcm_config.rs +++ b/polkadot/runtime/rococo/src/xcm_config.rs @@ -25,7 +25,7 @@ use crate::governance::StakingAdmin; use frame_support::{ parameter_types, - traits::{Contains, Equals, Everything, Nothing}, + traits::{Contains, Disabled, Equals, Everything, Nothing}, weights::Weight, }; use frame_system::EnsureRoot; @@ -287,4 +287,6 @@ impl pallet_xcm::Config for Runtime { type RemoteLockConsumerIdentifier = (); type WeightInfo = crate::weights::pallet_xcm::WeightInfo; type AdminOrigin = EnsureRoot; + // Aliasing is disabled: xcm_executor::Config::Aliasers is set to `Nothing`. + type AuthorizedAliasConsideration = Disabled; } diff --git a/polkadot/runtime/westend/src/xcm_config.rs b/polkadot/runtime/westend/src/xcm_config.rs index d72d8965ac10..a6b40377b8a1 100644 --- a/polkadot/runtime/westend/src/xcm_config.rs +++ b/polkadot/runtime/westend/src/xcm_config.rs @@ -24,7 +24,7 @@ use super::{ use crate::governance::pallet_custom_origins::Treasurer; use frame_support::{ parameter_types, - traits::{Contains, Equals, Everything, Nothing}, + traits::{Contains, Disabled, Equals, Everything, Nothing}, }; use frame_system::EnsureRoot; use pallet_xcm::XcmPassthrough; @@ -308,4 +308,6 @@ impl pallet_xcm::Config for Runtime { type RemoteLockConsumerIdentifier = (); type WeightInfo = crate::weights::pallet_xcm::WeightInfo; type AdminOrigin = EnsureRoot; + // Aliasing is disabled: xcm_executor::Config::Aliasers only allows `AliasChildLocation`. + type AuthorizedAliasConsideration = Disabled; } diff --git a/polkadot/xcm/pallet-xcm/src/lib.rs b/polkadot/xcm/pallet-xcm/src/lib.rs index 3ce1d5f6db0f..3fad224631b8 100644 --- a/polkadot/xcm/pallet-xcm/src/lib.rs +++ b/polkadot/xcm/pallet-xcm/src/lib.rs @@ -235,7 +235,7 @@ pub mod pallet { pub type BalanceOf = <::Currency as Currency<::AccountId>>::Balance; - pub type TicketOf = ::Consideration; + pub type TicketOf = ::AuthorizedAliasConsideration; #[pallet::config] /// The module configuration trait. @@ -250,8 +250,8 @@ pub mod pallet { /// The `Asset` matcher for `Currency`. type CurrencyMatcher: MatchesFungible>; - /// A means of providing some cost while data is stored on-chain. - type Consideration: Consideration; + /// A means of providing some cost while Authorized Aliasers data is stored on-chain. + type AuthorizedAliasConsideration: Consideration; /// Required origin for sending XCM messages. If successful, it resolves to `Location` /// which exists as an interior location within this chain's XCM context. diff --git a/polkadot/xcm/pallet-xcm/src/mock.rs b/polkadot/xcm/pallet-xcm/src/mock.rs index e7a756add549..17b8abf936ae 100644 --- a/polkadot/xcm/pallet-xcm/src/mock.rs +++ b/polkadot/xcm/pallet-xcm/src/mock.rs @@ -569,7 +569,7 @@ impl pallet_xcm::Config for Test { type MaxRemoteLockConsumers = frame_support::traits::ConstU32<0>; type RemoteLockConsumerIdentifier = (); type WeightInfo = TestWeightInfo; - type Consideration = + type AuthorizedAliasConsideration = HoldConsideration; } diff --git a/substrate/frame/support/src/traits.rs b/substrate/frame/support/src/traits.rs index 728426cc84c7..4bc3c4c3b4b0 100644 --- a/substrate/frame/support/src/traits.rs +++ b/substrate/frame/support/src/traits.rs @@ -96,8 +96,9 @@ mod storage; #[cfg(feature = "experimental")] pub use storage::MaybeConsideration; pub use storage::{ - Consideration, Footprint, Incrementable, Instance, LinearStoragePrice, PartialStorageInfoTrait, - StorageInfo, StorageInfoTrait, StorageInstance, TrackedStorageKey, WhitelistedStorageKeys, + Consideration, Disabled, Footprint, Incrementable, Instance, LinearStoragePrice, + PartialStorageInfoTrait, StorageInfo, StorageInfoTrait, StorageInstance, TrackedStorageKey, + WhitelistedStorageKeys, }; mod dispatch; diff --git a/substrate/frame/support/src/traits/storage.rs b/substrate/frame/support/src/traits/storage.rs index 2b8e43707389..8e938911a456 100644 --- a/substrate/frame/support/src/traits/storage.rs +++ b/substrate/frame/support/src/traits/storage.rs @@ -18,8 +18,9 @@ //! Traits for encoding data related to pallet's storage items. use alloc::{collections::btree_set::BTreeSet, vec, vec::Vec}; -use codec::{Encode, FullCodec, MaxEncodedLen}; +use codec::{Decode, Encode, FullCodec, MaxEncodedLen}; use core::marker::PhantomData; +use frame_support::CloneNoBound; use impl_trait_for_tuples::impl_for_tuples; use scale_info::TypeInfo; pub use sp_core::storage::TrackedStorageKey; @@ -200,6 +201,23 @@ where } } +/// Placeholder marking functionality disabled. Useful for disabling various (sub)features. +#[derive(CloneNoBound, Debug, Encode, Eq, Decode, TypeInfo, MaxEncodedLen, PartialEq)] +pub struct Disabled; +impl Consideration for Disabled { + fn new(_: &A, _: F) -> Result { + Err(DispatchError::Other("Disabled")) + } + fn update(self, _: &A, _: F) -> Result { + Err(DispatchError::Other("Disabled")) + } + fn drop(self, _: &A) -> Result<(), DispatchError> { + Ok(()) + } + #[cfg(feature = "runtime-benchmarks")] + fn ensure_successful(_: &A, _: F) {} +} + /// Some sort of cost taken from account temporarily in order to offset the cost to the chain of /// holding some data [`Footprint`] in state. /// From 31b5febe2091dd639568c9f6345705e59859acc7 Mon Sep 17 00:00:00 2001 From: Adrian Catangiu Date: Thu, 16 Jan 2025 13:03:32 +0200 Subject: [PATCH 32/40] implement runtime APIs --- .../assets/asset-hub-rococo/src/lib.rs | 9 +++++ .../assets/asset-hub-westend/src/lib.rs | 27 ++++++++----- .../bridge-hubs/bridge-hub-westend/src/lib.rs | 27 ++++++++----- .../collectives-westend/src/lib.rs | 27 ++++++++----- .../coretime/coretime-westend/src/lib.rs | 27 ++++++++----- .../runtimes/people/people-westend/src/lib.rs | 27 ++++++++----- .../runtimes/testing/penpal/src/lib.rs | 39 ++++++++++++++----- polkadot/xcm/pallet-xcm/src/lib.rs | 2 +- 8 files changed, 130 insertions(+), 55 deletions(-) diff --git a/cumulus/parachains/runtimes/assets/asset-hub-rococo/src/lib.rs b/cumulus/parachains/runtimes/assets/asset-hub-rococo/src/lib.rs index 1db152e39fd9..6edfb9f3fb15 100644 --- a/cumulus/parachains/runtimes/assets/asset-hub-rococo/src/lib.rs +++ b/cumulus/parachains/runtimes/assets/asset-hub-rococo/src/lib.rs @@ -1895,6 +1895,15 @@ impl_runtime_apis! { PolkadotXcm::is_trusted_teleporter(asset, location) } } + + impl xcm_runtime_apis::authorized_aliases::AuthorizedAliasersApi for Runtime { + fn authorized_aliasers(target: VersionedLocation) -> Vec { + PolkadotXcm::authorized_aliasers(target) + } + fn is_authorized_alias(origin: VersionedLocation, target: VersionedLocation) -> bool { + PolkadotXcm::is_authorized_alias(origin, target) + } + } } cumulus_pallet_parachain_system::register_validate_block! { diff --git a/cumulus/parachains/runtimes/assets/asset-hub-westend/src/lib.rs b/cumulus/parachains/runtimes/assets/asset-hub-westend/src/lib.rs index 71cfdc58cceb..7ef131f5381c 100644 --- a/cumulus/parachains/runtimes/assets/asset-hub-westend/src/lib.rs +++ b/cumulus/parachains/runtimes/assets/asset-hub-westend/src/lib.rs @@ -1610,6 +1610,24 @@ impl_runtime_apis! { } } + impl xcm_runtime_apis::trusted_query::TrustedQueryApi for Runtime { + fn is_trusted_reserve(asset: VersionedAsset, location: VersionedLocation) -> xcm_runtime_apis::trusted_query::XcmTrustedQueryResult { + PolkadotXcm::is_trusted_reserve(asset, location) + } + fn is_trusted_teleporter(asset: VersionedAsset, location: VersionedLocation) -> xcm_runtime_apis::trusted_query::XcmTrustedQueryResult { + PolkadotXcm::is_trusted_teleporter(asset, location) + } + } + + impl xcm_runtime_apis::authorized_aliases::AuthorizedAliasersApi for Runtime { + fn authorized_aliasers(target: VersionedLocation) -> Vec { + PolkadotXcm::authorized_aliasers(target) + } + fn is_authorized_alias(origin: VersionedLocation, target: VersionedLocation) -> bool { + PolkadotXcm::is_authorized_alias(origin, target) + } + } + impl pallet_transaction_payment_rpc_runtime_api::TransactionPaymentCallApi for Runtime { @@ -2064,15 +2082,6 @@ impl_runtime_apis! { } } - impl xcm_runtime_apis::trusted_query::TrustedQueryApi for Runtime { - fn is_trusted_reserve(asset: VersionedAsset, location: VersionedLocation) -> xcm_runtime_apis::trusted_query::XcmTrustedQueryResult { - PolkadotXcm::is_trusted_reserve(asset, location) - } - fn is_trusted_teleporter(asset: VersionedAsset, location: VersionedLocation) -> xcm_runtime_apis::trusted_query::XcmTrustedQueryResult { - PolkadotXcm::is_trusted_teleporter(asset, location) - } - } - impl pallet_revive::ReviveApi for Runtime { fn balance(address: H160) -> U256 { diff --git a/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-westend/src/lib.rs b/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-westend/src/lib.rs index 2c2e01b4d21d..baef35734b4b 100644 --- a/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-westend/src/lib.rs +++ b/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-westend/src/lib.rs @@ -835,6 +835,24 @@ impl_runtime_apis! { } } + impl xcm_runtime_apis::trusted_query::TrustedQueryApi for Runtime { + fn is_trusted_reserve(asset: VersionedAsset, location: VersionedLocation) -> xcm_runtime_apis::trusted_query::XcmTrustedQueryResult { + PolkadotXcm::is_trusted_reserve(asset, location) + } + fn is_trusted_teleporter(asset: VersionedAsset, location: VersionedLocation) -> xcm_runtime_apis::trusted_query::XcmTrustedQueryResult { + PolkadotXcm::is_trusted_teleporter(asset, location) + } + } + + impl xcm_runtime_apis::authorized_aliases::AuthorizedAliasersApi for Runtime { + fn authorized_aliasers(target: VersionedLocation) -> Vec { + PolkadotXcm::authorized_aliasers(target) + } + fn is_authorized_alias(origin: VersionedLocation, target: VersionedLocation) -> bool { + PolkadotXcm::is_authorized_alias(origin, target) + } + } + impl cumulus_primitives_core::CollectCollationInfo for Runtime { fn collect_collation_info(header: &::Header) -> cumulus_primitives_core::CollationInfo { ParachainSystem::collect_collation_info(header) @@ -1347,15 +1365,6 @@ impl_runtime_apis! { genesis_config_presets::preset_names() } } - - impl xcm_runtime_apis::trusted_query::TrustedQueryApi for Runtime { - fn is_trusted_reserve(asset: VersionedAsset, location: VersionedLocation) -> xcm_runtime_apis::trusted_query::XcmTrustedQueryResult { - PolkadotXcm::is_trusted_reserve(asset, location) - } - fn is_trusted_teleporter(asset: VersionedAsset, location: VersionedLocation) -> xcm_runtime_apis::trusted_query::XcmTrustedQueryResult { - PolkadotXcm::is_trusted_teleporter(asset, location) - } - } } cumulus_pallet_parachain_system::register_validate_block! { diff --git a/cumulus/parachains/runtimes/collectives/collectives-westend/src/lib.rs b/cumulus/parachains/runtimes/collectives/collectives-westend/src/lib.rs index e9adc4d1eae7..52fe4d1de1a1 100644 --- a/cumulus/parachains/runtimes/collectives/collectives-westend/src/lib.rs +++ b/cumulus/parachains/runtimes/collectives/collectives-westend/src/lib.rs @@ -1020,6 +1020,24 @@ impl_runtime_apis! { } } + impl xcm_runtime_apis::trusted_query::TrustedQueryApi for Runtime { + fn is_trusted_reserve(asset: VersionedAsset, location: VersionedLocation) -> xcm_runtime_apis::trusted_query::XcmTrustedQueryResult { + PolkadotXcm::is_trusted_reserve(asset, location) + } + fn is_trusted_teleporter(asset: VersionedAsset, location: VersionedLocation) -> xcm_runtime_apis::trusted_query::XcmTrustedQueryResult { + PolkadotXcm::is_trusted_teleporter(asset, location) + } + } + + impl xcm_runtime_apis::authorized_aliases::AuthorizedAliasersApi for Runtime { + fn authorized_aliasers(target: VersionedLocation) -> Vec { + PolkadotXcm::authorized_aliasers(target) + } + fn is_authorized_alias(origin: VersionedLocation, target: VersionedLocation) -> bool { + PolkadotXcm::is_authorized_alias(origin, target) + } + } + impl cumulus_primitives_core::CollectCollationInfo for Runtime { fn collect_collation_info(header: &::Header) -> cumulus_primitives_core::CollationInfo { ParachainSystem::collect_collation_info(header) @@ -1173,15 +1191,6 @@ impl_runtime_apis! { genesis_config_presets::preset_names() } } - - impl xcm_runtime_apis::trusted_query::TrustedQueryApi for Runtime { - fn is_trusted_reserve(asset: VersionedAsset, location: VersionedLocation) -> xcm_runtime_apis::trusted_query::XcmTrustedQueryResult { - PolkadotXcm::is_trusted_reserve(asset, location) - } - fn is_trusted_teleporter(asset: VersionedAsset, location: VersionedLocation) -> xcm_runtime_apis::trusted_query::XcmTrustedQueryResult { - PolkadotXcm::is_trusted_teleporter(asset, location) - } - } } cumulus_pallet_parachain_system::register_validate_block! { diff --git a/cumulus/parachains/runtimes/coretime/coretime-westend/src/lib.rs b/cumulus/parachains/runtimes/coretime/coretime-westend/src/lib.rs index 975856b3b6ff..bb1891fac374 100644 --- a/cumulus/parachains/runtimes/coretime/coretime-westend/src/lib.rs +++ b/cumulus/parachains/runtimes/coretime/coretime-westend/src/lib.rs @@ -883,6 +883,24 @@ impl_runtime_apis! { } } + impl xcm_runtime_apis::trusted_query::TrustedQueryApi for Runtime { + fn is_trusted_reserve(asset: VersionedAsset, location: VersionedLocation) -> xcm_runtime_apis::trusted_query::XcmTrustedQueryResult { + PolkadotXcm::is_trusted_reserve(asset, location) + } + fn is_trusted_teleporter(asset: VersionedAsset, location: VersionedLocation) -> xcm_runtime_apis::trusted_query::XcmTrustedQueryResult { + PolkadotXcm::is_trusted_teleporter(asset, location) + } + } + + impl xcm_runtime_apis::authorized_aliases::AuthorizedAliasersApi for Runtime { + fn authorized_aliasers(target: VersionedLocation) -> Vec { + PolkadotXcm::authorized_aliasers(target) + } + fn is_authorized_alias(origin: VersionedLocation, target: VersionedLocation) -> bool { + PolkadotXcm::is_authorized_alias(origin, target) + } + } + impl cumulus_primitives_core::CollectCollationInfo for Runtime { fn collect_collation_info(header: &::Header) -> cumulus_primitives_core::CollationInfo { ParachainSystem::collect_collation_info(header) @@ -1167,15 +1185,6 @@ impl_runtime_apis! { vec![] } } - - impl xcm_runtime_apis::trusted_query::TrustedQueryApi for Runtime { - fn is_trusted_reserve(asset: VersionedAsset, location: VersionedLocation) -> xcm_runtime_apis::trusted_query::XcmTrustedQueryResult { - PolkadotXcm::is_trusted_reserve(asset, location) - } - fn is_trusted_teleporter(asset: VersionedAsset, location: VersionedLocation) -> xcm_runtime_apis::trusted_query::XcmTrustedQueryResult { - PolkadotXcm::is_trusted_teleporter(asset, location) - } - } } cumulus_pallet_parachain_system::register_validate_block! { diff --git a/cumulus/parachains/runtimes/people/people-westend/src/lib.rs b/cumulus/parachains/runtimes/people/people-westend/src/lib.rs index ee6b0db55b91..8ce535a77f39 100644 --- a/cumulus/parachains/runtimes/people/people-westend/src/lib.rs +++ b/cumulus/parachains/runtimes/people/people-westend/src/lib.rs @@ -837,6 +837,24 @@ impl_runtime_apis! { } } + impl xcm_runtime_apis::trusted_query::TrustedQueryApi for Runtime { + fn is_trusted_reserve(asset: VersionedAsset, location: VersionedLocation) -> xcm_runtime_apis::trusted_query::XcmTrustedQueryResult { + PolkadotXcm::is_trusted_reserve(asset, location) + } + fn is_trusted_teleporter(asset: VersionedAsset, location: VersionedLocation) -> xcm_runtime_apis::trusted_query::XcmTrustedQueryResult { + PolkadotXcm::is_trusted_teleporter(asset, location) + } + } + + impl xcm_runtime_apis::authorized_aliases::AuthorizedAliasersApi for Runtime { + fn authorized_aliasers(target: VersionedLocation) -> Vec { + PolkadotXcm::authorized_aliasers(target) + } + fn is_authorized_alias(origin: VersionedLocation, target: VersionedLocation) -> bool { + PolkadotXcm::is_authorized_alias(origin, target) + } + } + impl cumulus_primitives_core::CollectCollationInfo for Runtime { fn collect_collation_info(header: &::Header) -> cumulus_primitives_core::CollationInfo { ParachainSystem::collect_collation_info(header) @@ -1087,15 +1105,6 @@ impl_runtime_apis! { vec![] } } - - impl xcm_runtime_apis::trusted_query::TrustedQueryApi for Runtime { - fn is_trusted_reserve(asset: VersionedAsset, location: VersionedLocation) -> xcm_runtime_apis::trusted_query::XcmTrustedQueryResult { - PolkadotXcm::is_trusted_reserve(asset, location) - } - fn is_trusted_teleporter(asset: VersionedAsset, location: VersionedLocation) -> xcm_runtime_apis::trusted_query::XcmTrustedQueryResult { - PolkadotXcm::is_trusted_teleporter(asset, location) - } - } } cumulus_pallet_parachain_system::register_validate_block! { diff --git a/cumulus/parachains/runtimes/testing/penpal/src/lib.rs b/cumulus/parachains/runtimes/testing/penpal/src/lib.rs index 38ddf3bc1991..19cb869a3947 100644 --- a/cumulus/parachains/runtimes/testing/penpal/src/lib.rs +++ b/cumulus/parachains/runtimes/testing/penpal/src/lib.rs @@ -1082,6 +1082,36 @@ impl_runtime_apis! { } } + impl xcm_runtime_apis::conversions::LocationToAccountApi for Runtime { + fn convert_location(location: VersionedLocation) -> Result< + AccountId, + xcm_runtime_apis::conversions::Error + > { + xcm_runtime_apis::conversions::LocationToAccountHelper::< + AccountId, + xcm_config::LocationToAccountId, + >::convert_location(location) + } + } + + impl xcm_runtime_apis::trusted_query::TrustedQueryApi for Runtime { + fn is_trusted_reserve(asset: VersionedAsset, location: VersionedLocation) -> xcm_runtime_apis::trusted_query::XcmTrustedQueryResult { + PolkadotXcm::is_trusted_reserve(asset, location) + } + fn is_trusted_teleporter(asset: VersionedAsset, location: VersionedLocation) -> xcm_runtime_apis::trusted_query::XcmTrustedQueryResult { + PolkadotXcm::is_trusted_teleporter(asset, location) + } + } + + impl xcm_runtime_apis::authorized_aliases::AuthorizedAliasersApi for Runtime { + fn authorized_aliasers(target: VersionedLocation) -> Vec { + PolkadotXcm::authorized_aliasers(target) + } + fn is_authorized_alias(origin: VersionedLocation, target: VersionedLocation) -> bool { + PolkadotXcm::is_authorized_alias(origin, target) + } + } + #[cfg(feature = "try-runtime")] impl frame_try_runtime::TryRuntime for Runtime { fn on_runtime_upgrade(checks: frame_try_runtime::UpgradeCheckSelect) -> (Weight, Weight) { @@ -1158,15 +1188,6 @@ impl_runtime_apis! { vec![] } } - - impl xcm_runtime_apis::trusted_query::TrustedQueryApi for Runtime { - fn is_trusted_reserve(asset: VersionedAsset, location: VersionedLocation) -> xcm_runtime_apis::trusted_query::XcmTrustedQueryResult { - PolkadotXcm::is_trusted_reserve(asset, location) - } - fn is_trusted_teleporter(asset: VersionedAsset, location: VersionedLocation) -> xcm_runtime_apis::trusted_query::XcmTrustedQueryResult { - PolkadotXcm::is_trusted_teleporter(asset, location) - } - } } cumulus_pallet_parachain_system::register_validate_block! { diff --git a/polkadot/xcm/pallet-xcm/src/lib.rs b/polkadot/xcm/pallet-xcm/src/lib.rs index 3fad224631b8..18578100e83b 100644 --- a/polkadot/xcm/pallet-xcm/src/lib.rs +++ b/polkadot/xcm/pallet-xcm/src/lib.rs @@ -2870,7 +2870,7 @@ impl Pallet { } /// Returns locations allowed to alias into and act as `target`. - fn authorized_aliasers(target: VersionedLocation) -> Vec { + pub fn authorized_aliasers(target: VersionedLocation) -> Vec { AuthorizedAliases::::get(&target) .map(|authorized| authorized.aliasers.into_iter().collect()) .unwrap_or_default() From 825a4b4c992b7104cae06181676f680388de1bb4 Mon Sep 17 00:00:00 2001 From: Adrian Catangiu Date: Thu, 16 Jan 2025 13:17:26 +0200 Subject: [PATCH 33/40] fix test runtimes --- .../parachains/runtimes/testing/rococo-parachain/src/lib.rs | 4 +++- .../cookbook/relay_token_transactor/parachain/xcm_config.rs | 4 +++- .../relay_token_transactor/relay_chain/xcm_config.rs | 4 +++- .../src/asset_exchange/single_asset_adapter/mock.rs | 2 ++ polkadot/xcm/xcm-builder/tests/mock/mod.rs | 4 +++- polkadot/xcm/xcm-simulator/example/src/parachain/mod.rs | 5 ++++- polkadot/xcm/xcm-simulator/example/src/relay_chain/mod.rs | 4 +++- polkadot/xcm/xcm-simulator/fuzzer/src/parachain.rs | 3 ++- polkadot/xcm/xcm-simulator/fuzzer/src/relay_chain.rs | 3 ++- substrate/frame/contracts/mock-network/src/parachain.rs | 6 +++++- substrate/frame/contracts/mock-network/src/relay_chain.rs | 4 +++- substrate/frame/revive/mock-network/src/parachain.rs | 6 +++++- substrate/frame/revive/mock-network/src/relay_chain.rs | 4 +++- templates/parachain/runtime/src/configs/xcm_config.rs | 3 +++ 14 files changed, 44 insertions(+), 12 deletions(-) diff --git a/cumulus/parachains/runtimes/testing/rococo-parachain/src/lib.rs b/cumulus/parachains/runtimes/testing/rococo-parachain/src/lib.rs index a60b8893589c..32f2e6237b68 100644 --- a/cumulus/parachains/runtimes/testing/rococo-parachain/src/lib.rs +++ b/cumulus/parachains/runtimes/testing/rococo-parachain/src/lib.rs @@ -69,7 +69,7 @@ pub use sp_runtime::BuildStorage; pub use sp_runtime::{Perbill, Permill}; use cumulus_primitives_core::{AggregateMessageOrigin, ClaimQueueOffset, CoreSelector, ParaId}; -use frame_support::traits::TransformOrigin; +use frame_support::traits::{Disabled, TransformOrigin}; use parachains_common::{ impls::{AssetsFrom, NonZeroIssuance}, message_queue::{NarrowOriginToSibling, ParaIdToSibling}, @@ -539,6 +539,8 @@ impl pallet_xcm::Config for Runtime { type AdminOrigin = EnsureRoot; type MaxRemoteLockConsumers = ConstU32<0>; type RemoteLockConsumerIdentifier = (); + // Aliasing is disabled: xcm_executor::Config::Aliasers is set to `Nothing`. + type AuthorizedAliasConsideration = Disabled; } impl cumulus_pallet_xcm::Config for Runtime { diff --git a/polkadot/xcm/docs/src/cookbook/relay_token_transactor/parachain/xcm_config.rs b/polkadot/xcm/docs/src/cookbook/relay_token_transactor/parachain/xcm_config.rs index 388849213ad2..5fe35f71d484 100644 --- a/polkadot/xcm/docs/src/cookbook/relay_token_transactor/parachain/xcm_config.rs +++ b/polkadot/xcm/docs/src/cookbook/relay_token_transactor/parachain/xcm_config.rs @@ -19,7 +19,7 @@ use frame::{ deps::frame_system, runtime::prelude::*, - traits::{Everything, Nothing}, + traits::{Disabled, Everything, Nothing}, }; use xcm::latest::prelude::*; use xcm_builder::{ @@ -188,4 +188,6 @@ impl pallet_xcm::Config for Runtime { type RuntimeOrigin = RuntimeOrigin; type RuntimeCall = RuntimeCall; type RuntimeEvent = RuntimeEvent; + // Aliasing is disabled: xcm_executor::Config::Aliasers is set to `Nothing`. + type AuthorizedAliasConsideration = Disabled; } diff --git a/polkadot/xcm/docs/src/cookbook/relay_token_transactor/relay_chain/xcm_config.rs b/polkadot/xcm/docs/src/cookbook/relay_token_transactor/relay_chain/xcm_config.rs index d6b4396f26f4..ac6b48d2d715 100644 --- a/polkadot/xcm/docs/src/cookbook/relay_token_transactor/relay_chain/xcm_config.rs +++ b/polkadot/xcm/docs/src/cookbook/relay_token_transactor/relay_chain/xcm_config.rs @@ -19,7 +19,7 @@ use frame::{ deps::frame_system, runtime::prelude::*, - traits::{Everything, Nothing}, + traits::{Disabled, Everything, Nothing}, }; use xcm::latest::prelude::*; use xcm_builder::{ @@ -162,4 +162,6 @@ impl pallet_xcm::Config for Runtime { type RuntimeOrigin = RuntimeOrigin; type RuntimeCall = RuntimeCall; type RuntimeEvent = RuntimeEvent; + // Aliasing is disabled: xcm_executor::Config::Aliasers is set to `Nothing`. + type AuthorizedAliasConsideration = Disabled; } diff --git a/polkadot/xcm/xcm-builder/src/asset_exchange/single_asset_adapter/mock.rs b/polkadot/xcm/xcm-builder/src/asset_exchange/single_asset_adapter/mock.rs index 2f0287c3c2b7..8bf6acaada31 100644 --- a/polkadot/xcm/xcm-builder/src/asset_exchange/single_asset_adapter/mock.rs +++ b/polkadot/xcm/xcm-builder/src/asset_exchange/single_asset_adapter/mock.rs @@ -332,6 +332,8 @@ impl pallet_xcm::Config for Runtime { type RuntimeOrigin = RuntimeOrigin; type RuntimeCall = RuntimeCall; type RuntimeEvent = RuntimeEvent; + // Aliasing is disabled: xcm_executor::Config::Aliasers is set to `Nothing`. + type AuthorizedAliasConsideration = Disabled; } pub const INITIAL_BALANCE: Balance = 1_000_000_000; diff --git a/polkadot/xcm/xcm-builder/tests/mock/mod.rs b/polkadot/xcm/xcm-builder/tests/mock/mod.rs index 2a0148d409c5..9001a3fe2d36 100644 --- a/polkadot/xcm/xcm-builder/tests/mock/mod.rs +++ b/polkadot/xcm/xcm-builder/tests/mock/mod.rs @@ -18,7 +18,7 @@ use codec::Encode; use core::cell::RefCell; use frame_support::{ construct_runtime, derive_impl, parameter_types, - traits::{Everything, Nothing}, + traits::{Disabled, Everything, Nothing}, weights::Weight, }; use frame_system::EnsureRoot; @@ -226,6 +226,8 @@ impl pallet_xcm::Config for Runtime { type RemoteLockConsumerIdentifier = (); type WeightInfo = pallet_xcm::TestWeightInfo; type AdminOrigin = EnsureRoot; + // Aliasing is disabled: xcm_executor::Config::Aliasers is set to `Nothing`. + type AuthorizedAliasConsideration = Disabled; } impl origin::Config for Runtime {} diff --git a/polkadot/xcm/xcm-simulator/example/src/parachain/mod.rs b/polkadot/xcm/xcm-simulator/example/src/parachain/mod.rs index bfb455aba3f9..ed7870163d7d 100644 --- a/polkadot/xcm/xcm-simulator/example/src/parachain/mod.rs +++ b/polkadot/xcm/xcm-simulator/example/src/parachain/mod.rs @@ -22,7 +22,9 @@ pub use xcm_config::*; use core::marker::PhantomData; use frame_support::{ construct_runtime, derive_impl, parameter_types, - traits::{ConstU128, ContainsPair, EnsureOrigin, EnsureOriginWithArg, Everything, Nothing}, + traits::{ + ConstU128, ContainsPair, Disabled, EnsureOrigin, EnsureOriginWithArg, Everything, Nothing, + }, weights::{constants::WEIGHT_REF_TIME_PER_SECOND, Weight}, }; use frame_system::EnsureRoot; @@ -166,6 +168,7 @@ impl pallet_xcm::Config for Runtime { type RemoteLockConsumerIdentifier = (); type WeightInfo = pallet_xcm::TestWeightInfo; type AdminOrigin = EnsureRoot; + type AuthorizedAliasConsideration = Disabled; } type Block = frame_system::mocking::MockBlock; diff --git a/polkadot/xcm/xcm-simulator/example/src/relay_chain/mod.rs b/polkadot/xcm/xcm-simulator/example/src/relay_chain/mod.rs index c843f52d41a9..5b09a27e4e74 100644 --- a/polkadot/xcm/xcm-simulator/example/src/relay_chain/mod.rs +++ b/polkadot/xcm/xcm-simulator/example/src/relay_chain/mod.rs @@ -22,7 +22,8 @@ pub use xcm_config::*; use frame_support::{ construct_runtime, derive_impl, parameter_types, traits::{ - AsEnsureOriginWithArg, ConstU128, Everything, Nothing, ProcessMessage, ProcessMessageError, + AsEnsureOriginWithArg, ConstU128, Disabled, Everything, Nothing, ProcessMessage, + ProcessMessageError, }, weights::{Weight, WeightMeter}, }; @@ -119,6 +120,7 @@ impl pallet_xcm::Config for Runtime { type RemoteLockConsumerIdentifier = (); type WeightInfo = pallet_xcm::TestWeightInfo; type AdminOrigin = EnsureRoot; + type AuthorizedAliasConsideration = Disabled; } impl origin::Config for Runtime {} diff --git a/polkadot/xcm/xcm-simulator/fuzzer/src/parachain.rs b/polkadot/xcm/xcm-simulator/fuzzer/src/parachain.rs index fc650ae55a78..89ecc7629748 100644 --- a/polkadot/xcm/xcm-simulator/fuzzer/src/parachain.rs +++ b/polkadot/xcm/xcm-simulator/fuzzer/src/parachain.rs @@ -19,7 +19,7 @@ use codec::{Decode, Encode}; use frame_support::{ construct_runtime, derive_impl, parameter_types, - traits::{Everything, Nothing}, + traits::{Disabled, Everything, Nothing}, weights::{constants::WEIGHT_REF_TIME_PER_SECOND, Weight}, }; @@ -334,6 +334,7 @@ impl pallet_xcm::Config for Runtime { type RemoteLockConsumerIdentifier = (); type WeightInfo = pallet_xcm::TestWeightInfo; type AdminOrigin = EnsureRoot; + type AuthorizedAliasConsideration = Disabled; } construct_runtime!( diff --git a/polkadot/xcm/xcm-simulator/fuzzer/src/relay_chain.rs b/polkadot/xcm/xcm-simulator/fuzzer/src/relay_chain.rs index 58687b478526..a9520e2e51ed 100644 --- a/polkadot/xcm/xcm-simulator/fuzzer/src/relay_chain.rs +++ b/polkadot/xcm/xcm-simulator/fuzzer/src/relay_chain.rs @@ -18,7 +18,7 @@ use frame_support::{ construct_runtime, derive_impl, parameter_types, - traits::{Everything, Nothing, ProcessMessage, ProcessMessageError}, + traits::{Disabled, Everything, Nothing, ProcessMessage, ProcessMessageError}, weights::{Weight, WeightMeter}, }; @@ -179,6 +179,7 @@ impl pallet_xcm::Config for Runtime { type RemoteLockConsumerIdentifier = (); type WeightInfo = pallet_xcm::TestWeightInfo; type AdminOrigin = EnsureRoot; + type AuthorizedAliasConsideration = Disabled; } impl origin::Config for Runtime {} diff --git a/substrate/frame/contracts/mock-network/src/parachain.rs b/substrate/frame/contracts/mock-network/src/parachain.rs index 6edbfb0e7e86..612a17b2e074 100644 --- a/substrate/frame/contracts/mock-network/src/parachain.rs +++ b/substrate/frame/contracts/mock-network/src/parachain.rs @@ -24,7 +24,9 @@ use crate::{ use core::marker::PhantomData; use frame_support::{ construct_runtime, derive_impl, parameter_types, - traits::{AsEnsureOriginWithArg, Contains, ContainsPair, Everything, EverythingBut, Nothing}, + traits::{ + AsEnsureOriginWithArg, Contains, ContainsPair, Disabled, Everything, EverythingBut, Nothing, + }, weights::{ constants::{WEIGHT_PROOF_SIZE_PER_MB, WEIGHT_REF_TIME_PER_SECOND}, Weight, @@ -322,6 +324,8 @@ impl pallet_xcm::Config for Runtime { type RemoteLockConsumerIdentifier = (); type WeightInfo = pallet_xcm::TestWeightInfo; type AdminOrigin = EnsureRoot; + // Aliasing is disabled: xcm_executor::Config::Aliasers is set to `Nothing`. + type AuthorizedAliasConsideration = Disabled; } type Block = frame_system::mocking::MockBlock; diff --git a/substrate/frame/contracts/mock-network/src/relay_chain.rs b/substrate/frame/contracts/mock-network/src/relay_chain.rs index 5fed061f80b4..3568400e12d5 100644 --- a/substrate/frame/contracts/mock-network/src/relay_chain.rs +++ b/substrate/frame/contracts/mock-network/src/relay_chain.rs @@ -18,7 +18,7 @@ use frame_support::{ construct_runtime, derive_impl, parameter_types, - traits::{Contains, Everything, Nothing}, + traits::{Contains, Disabled, Everything, Nothing}, weights::Weight, }; @@ -210,6 +210,8 @@ impl pallet_xcm::Config for Runtime { type RemoteLockConsumerIdentifier = (); type WeightInfo = pallet_xcm::TestWeightInfo; type AdminOrigin = EnsureRoot; + // Aliasing is disabled: xcm_executor::Config::Aliasers is set to `Nothing`. + type AuthorizedAliasConsideration = Disabled; } impl origin::Config for Runtime {} diff --git a/substrate/frame/revive/mock-network/src/parachain.rs b/substrate/frame/revive/mock-network/src/parachain.rs index 26a8fdcada27..422507a8552b 100644 --- a/substrate/frame/revive/mock-network/src/parachain.rs +++ b/substrate/frame/revive/mock-network/src/parachain.rs @@ -24,7 +24,9 @@ use crate::{ use core::marker::PhantomData; use frame_support::{ construct_runtime, derive_impl, parameter_types, - traits::{AsEnsureOriginWithArg, Contains, ContainsPair, Everything, EverythingBut, Nothing}, + traits::{ + AsEnsureOriginWithArg, Contains, ContainsPair, Disabled, Everything, EverythingBut, Nothing, + }, weights::{ constants::{WEIGHT_PROOF_SIZE_PER_MB, WEIGHT_REF_TIME_PER_SECOND}, Weight, @@ -322,6 +324,8 @@ impl pallet_xcm::Config for Runtime { type RemoteLockConsumerIdentifier = (); type WeightInfo = pallet_xcm::TestWeightInfo; type AdminOrigin = EnsureRoot; + // Aliasing is disabled: xcm_executor::Config::Aliasers is set to `Nothing`. + type AuthorizedAliasConsideration = Disabled; } type Block = frame_system::mocking::MockBlock; diff --git a/substrate/frame/revive/mock-network/src/relay_chain.rs b/substrate/frame/revive/mock-network/src/relay_chain.rs index 5fed061f80b4..3568400e12d5 100644 --- a/substrate/frame/revive/mock-network/src/relay_chain.rs +++ b/substrate/frame/revive/mock-network/src/relay_chain.rs @@ -18,7 +18,7 @@ use frame_support::{ construct_runtime, derive_impl, parameter_types, - traits::{Contains, Everything, Nothing}, + traits::{Contains, Disabled, Everything, Nothing}, weights::Weight, }; @@ -210,6 +210,8 @@ impl pallet_xcm::Config for Runtime { type RemoteLockConsumerIdentifier = (); type WeightInfo = pallet_xcm::TestWeightInfo; type AdminOrigin = EnsureRoot; + // Aliasing is disabled: xcm_executor::Config::Aliasers is set to `Nothing`. + type AuthorizedAliasConsideration = Disabled; } impl origin::Config for Runtime {} diff --git a/templates/parachain/runtime/src/configs/xcm_config.rs b/templates/parachain/runtime/src/configs/xcm_config.rs index 09e8e3bfef1b..28388e0da3e0 100644 --- a/templates/parachain/runtime/src/configs/xcm_config.rs +++ b/templates/parachain/runtime/src/configs/xcm_config.rs @@ -16,6 +16,7 @@ use frame_system::EnsureRoot; use pallet_xcm::XcmPassthrough; use polkadot_parachain_primitives::primitives::Sibling; use polkadot_runtime_common::impls::ToAuthor; +use polkadot_sdk::polkadot_sdk_frame::traits::Disabled; use xcm::latest::prelude::*; use xcm_builder::{ AccountId32Aliases, AllowExplicitUnpaidExecutionFrom, AllowTopLevelPaidExecutionFrom, @@ -191,6 +192,8 @@ impl pallet_xcm::Config for Runtime { type AdminOrigin = EnsureRoot; type MaxRemoteLockConsumers = ConstU32<0>; type RemoteLockConsumerIdentifier = (); + // Aliasing is disabled: xcm_executor::Config::Aliasers is set to `Nothing`. + type AuthorizedAliasConsideration = Disabled; } impl cumulus_pallet_xcm::Config for Runtime { From f2869b27ec8a32b27c7fea89798d3dacd4e984f9 Mon Sep 17 00:00:00 2001 From: Adrian Catangiu Date: Thu, 16 Jan 2025 18:57:53 +0200 Subject: [PATCH 34/40] make runtime APIs truly versioned --- .../assets/asset-hub-rococo/src/lib.rs | 10 +- .../assets/asset-hub-westend/src/lib.rs | 10 +- .../bridge-hubs/bridge-hub-westend/src/lib.rs | 10 +- .../collectives-westend/src/lib.rs | 10 +- .../coretime/coretime-westend/src/lib.rs | 10 +- .../runtimes/people/people-westend/src/lib.rs | 10 +- .../runtimes/testing/penpal/src/lib.rs | 10 +- polkadot/xcm/pallet-xcm/src/lib.rs | 112 +++++++++++------- polkadot/xcm/pallet-xcm/src/migration.rs | 21 ++-- polkadot/xcm/src/lib.rs | 17 ++- .../src/authorized_aliases.rs | 12 +- .../xcm/xcm-runtime-apis/src/trusted_query.rs | 2 + 12 files changed, 161 insertions(+), 73 deletions(-) diff --git a/cumulus/parachains/runtimes/assets/asset-hub-rococo/src/lib.rs b/cumulus/parachains/runtimes/assets/asset-hub-rococo/src/lib.rs index 6edfb9f3fb15..37e6f7420f6c 100644 --- a/cumulus/parachains/runtimes/assets/asset-hub-rococo/src/lib.rs +++ b/cumulus/parachains/runtimes/assets/asset-hub-rococo/src/lib.rs @@ -1897,10 +1897,16 @@ impl_runtime_apis! { } impl xcm_runtime_apis::authorized_aliases::AuthorizedAliasersApi for Runtime { - fn authorized_aliasers(target: VersionedLocation) -> Vec { + fn authorized_aliasers(target: VersionedLocation) -> Result< + Vec, + xcm_runtime_apis::authorized_aliases::Error + > { PolkadotXcm::authorized_aliasers(target) } - fn is_authorized_alias(origin: VersionedLocation, target: VersionedLocation) -> bool { + fn is_authorized_alias(origin: VersionedLocation, target: VersionedLocation) -> Result< + bool, + xcm_runtime_apis::authorized_aliases::Error + > { PolkadotXcm::is_authorized_alias(origin, target) } } diff --git a/cumulus/parachains/runtimes/assets/asset-hub-westend/src/lib.rs b/cumulus/parachains/runtimes/assets/asset-hub-westend/src/lib.rs index 7ef131f5381c..a98ea02ae895 100644 --- a/cumulus/parachains/runtimes/assets/asset-hub-westend/src/lib.rs +++ b/cumulus/parachains/runtimes/assets/asset-hub-westend/src/lib.rs @@ -1620,10 +1620,16 @@ impl_runtime_apis! { } impl xcm_runtime_apis::authorized_aliases::AuthorizedAliasersApi for Runtime { - fn authorized_aliasers(target: VersionedLocation) -> Vec { + fn authorized_aliasers(target: VersionedLocation) -> Result< + Vec, + xcm_runtime_apis::authorized_aliases::Error + > { PolkadotXcm::authorized_aliasers(target) } - fn is_authorized_alias(origin: VersionedLocation, target: VersionedLocation) -> bool { + fn is_authorized_alias(origin: VersionedLocation, target: VersionedLocation) -> Result< + bool, + xcm_runtime_apis::authorized_aliases::Error + > { PolkadotXcm::is_authorized_alias(origin, target) } } diff --git a/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-westend/src/lib.rs b/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-westend/src/lib.rs index baef35734b4b..61f6cab9a18d 100644 --- a/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-westend/src/lib.rs +++ b/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-westend/src/lib.rs @@ -845,10 +845,16 @@ impl_runtime_apis! { } impl xcm_runtime_apis::authorized_aliases::AuthorizedAliasersApi for Runtime { - fn authorized_aliasers(target: VersionedLocation) -> Vec { + fn authorized_aliasers(target: VersionedLocation) -> Result< + Vec, + xcm_runtime_apis::authorized_aliases::Error + > { PolkadotXcm::authorized_aliasers(target) } - fn is_authorized_alias(origin: VersionedLocation, target: VersionedLocation) -> bool { + fn is_authorized_alias(origin: VersionedLocation, target: VersionedLocation) -> Result< + bool, + xcm_runtime_apis::authorized_aliases::Error + > { PolkadotXcm::is_authorized_alias(origin, target) } } diff --git a/cumulus/parachains/runtimes/collectives/collectives-westend/src/lib.rs b/cumulus/parachains/runtimes/collectives/collectives-westend/src/lib.rs index 52fe4d1de1a1..ca48a70ef7ab 100644 --- a/cumulus/parachains/runtimes/collectives/collectives-westend/src/lib.rs +++ b/cumulus/parachains/runtimes/collectives/collectives-westend/src/lib.rs @@ -1030,10 +1030,16 @@ impl_runtime_apis! { } impl xcm_runtime_apis::authorized_aliases::AuthorizedAliasersApi for Runtime { - fn authorized_aliasers(target: VersionedLocation) -> Vec { + fn authorized_aliasers(target: VersionedLocation) -> Result< + Vec, + xcm_runtime_apis::authorized_aliases::Error + > { PolkadotXcm::authorized_aliasers(target) } - fn is_authorized_alias(origin: VersionedLocation, target: VersionedLocation) -> bool { + fn is_authorized_alias(origin: VersionedLocation, target: VersionedLocation) -> Result< + bool, + xcm_runtime_apis::authorized_aliases::Error + > { PolkadotXcm::is_authorized_alias(origin, target) } } diff --git a/cumulus/parachains/runtimes/coretime/coretime-westend/src/lib.rs b/cumulus/parachains/runtimes/coretime/coretime-westend/src/lib.rs index bb1891fac374..3170e97ac592 100644 --- a/cumulus/parachains/runtimes/coretime/coretime-westend/src/lib.rs +++ b/cumulus/parachains/runtimes/coretime/coretime-westend/src/lib.rs @@ -893,10 +893,16 @@ impl_runtime_apis! { } impl xcm_runtime_apis::authorized_aliases::AuthorizedAliasersApi for Runtime { - fn authorized_aliasers(target: VersionedLocation) -> Vec { + fn authorized_aliasers(target: VersionedLocation) -> Result< + Vec, + xcm_runtime_apis::authorized_aliases::Error + > { PolkadotXcm::authorized_aliasers(target) } - fn is_authorized_alias(origin: VersionedLocation, target: VersionedLocation) -> bool { + fn is_authorized_alias(origin: VersionedLocation, target: VersionedLocation) -> Result< + bool, + xcm_runtime_apis::authorized_aliases::Error + > { PolkadotXcm::is_authorized_alias(origin, target) } } diff --git a/cumulus/parachains/runtimes/people/people-westend/src/lib.rs b/cumulus/parachains/runtimes/people/people-westend/src/lib.rs index 8ce535a77f39..204e5a8a7c2a 100644 --- a/cumulus/parachains/runtimes/people/people-westend/src/lib.rs +++ b/cumulus/parachains/runtimes/people/people-westend/src/lib.rs @@ -847,10 +847,16 @@ impl_runtime_apis! { } impl xcm_runtime_apis::authorized_aliases::AuthorizedAliasersApi for Runtime { - fn authorized_aliasers(target: VersionedLocation) -> Vec { + fn authorized_aliasers(target: VersionedLocation) -> Result< + Vec, + xcm_runtime_apis::authorized_aliases::Error + > { PolkadotXcm::authorized_aliasers(target) } - fn is_authorized_alias(origin: VersionedLocation, target: VersionedLocation) -> bool { + fn is_authorized_alias(origin: VersionedLocation, target: VersionedLocation) -> Result< + bool, + xcm_runtime_apis::authorized_aliases::Error + > { PolkadotXcm::is_authorized_alias(origin, target) } } diff --git a/cumulus/parachains/runtimes/testing/penpal/src/lib.rs b/cumulus/parachains/runtimes/testing/penpal/src/lib.rs index 19cb869a3947..f3e2c123dca5 100644 --- a/cumulus/parachains/runtimes/testing/penpal/src/lib.rs +++ b/cumulus/parachains/runtimes/testing/penpal/src/lib.rs @@ -1104,10 +1104,16 @@ impl_runtime_apis! { } impl xcm_runtime_apis::authorized_aliases::AuthorizedAliasersApi for Runtime { - fn authorized_aliasers(target: VersionedLocation) -> Vec { + fn authorized_aliasers(target: VersionedLocation) -> Result< + Vec, + xcm_runtime_apis::authorized_aliases::Error + > { PolkadotXcm::authorized_aliasers(target) } - fn is_authorized_alias(origin: VersionedLocation, target: VersionedLocation) -> bool { + fn is_authorized_alias(origin: VersionedLocation, target: VersionedLocation) -> Result< + bool, + xcm_runtime_apis::authorized_aliases::Error + > { PolkadotXcm::is_authorized_alias(origin, target) } } diff --git a/polkadot/xcm/pallet-xcm/src/lib.rs b/polkadot/xcm/pallet-xcm/src/lib.rs index 18578100e83b..0fa2a21311c0 100644 --- a/polkadot/xcm/pallet-xcm/src/lib.rs +++ b/polkadot/xcm/pallet-xcm/src/lib.rs @@ -68,7 +68,7 @@ use xcm_executor::{ AssetsInHolding, }; use xcm_runtime_apis::{ - authorized_aliases::OriginAliaser, + authorized_aliases::{Error as AuthorizedAliasersApiError, OriginAliaser}, dry_run::{CallDryRunEffects, Error as XcmDryRunApiError, XcmDryRunEffects}, fees::Error as XcmPaymentApiError, trusted_query::Error as TrustedQueryApiError, @@ -535,13 +535,9 @@ pub mod pallet { VersionMigrationFinished { version: XcmVersion }, /// An `aliaser` location was authorized by `target` to alias it, authorization valid until /// `expiry` block number. - AliasAuthorized { - aliaser: VersionedLocation, - target: VersionedLocation, - expiry: Option, - }, + AliasAuthorized { aliaser: Location, target: Location, expiry: Option }, /// `target` removed alias authorization for `aliaser`. - AliasAuthorizationRemoved { aliaser: VersionedLocation, target: VersionedLocation }, + AliasAuthorizationRemoved { aliaser: Location, target: Location }, } #[pallet::origin] @@ -1509,9 +1505,10 @@ pub mod pallet { ) -> DispatchResult { let signed_origin = ensure_signed(origin.clone())?; let origin_location: Location = T::ExecuteXcmOrigin::ensure_origin(origin)?; - let aliaser: Location = (*aliaser).try_into().map_err(|()| Error::::BadVersion)?; - tracing::debug!(target: "xcm::pallet_xcm::add_authorized_alias", ?origin_location, ?aliaser, ?expires); - ensure!(origin_location != aliaser, Error::::BadLocation); + let new_aliaser: Location = + (*aliaser).try_into().map_err(|()| Error::::BadVersion)?; + tracing::debug!(target: "xcm::pallet_xcm::add_authorized_alias", ?origin_location, ?new_aliaser, ?expires); + ensure!(origin_location != new_aliaser, Error::::BadLocation); if let Some(expiry) = expires { ensure!( expiry > @@ -1519,9 +1516,8 @@ pub mod pallet { Error::::ExpiresInPast ); } - let versioned_origin = VersionedLocation::from(origin_location); - let versioned_aliaser = VersionedLocation::from(aliaser); - + let versioned_origin = VersionedLocation::from(origin_location.clone()); + let versioned_aliaser = VersionedLocation::from(new_aliaser.clone()); let entry = if let Some(entry) = AuthorizedAliases::::get(&versioned_origin) { // entry already exists, update it let (mut aliasers, mut ticket) = (entry.aliasers, entry.ticket); @@ -1551,8 +1547,8 @@ pub mod pallet { // write to storage AuthorizedAliases::::insert(&versioned_origin, entry); Self::deposit_event(Event::AliasAuthorized { - aliaser: versioned_aliaser, - target: versioned_origin, + aliaser: new_aliaser, + target: origin_location, expiry: expires, }); Ok(()) @@ -1570,8 +1566,9 @@ pub mod pallet { let to_remove: Location = (*aliaser).try_into().map_err(|()| Error::::BadVersion)?; tracing::debug!(target: "xcm::pallet_xcm::add_authorized_alias", ?origin_location, ?to_remove); ensure!(origin_location != to_remove, Error::::BadLocation); - let versioned_origin = VersionedLocation::from(origin_location); - let versioned_to_remove = VersionedLocation::from(to_remove); + // convert to latest versioned + let versioned_origin = VersionedLocation::from(origin_location.clone()); + let versioned_to_remove = VersionedLocation::from(to_remove.clone()); if let Some(entry) = AuthorizedAliases::::get(&versioned_origin) { let (mut aliasers, mut ticket) = (entry.aliasers, entry.ticket); let old_len = aliasers.len(); @@ -1582,8 +1579,8 @@ pub mod pallet { ticket.drop(&signed_origin)?; AuthorizedAliases::::remove(&versioned_origin); Self::deposit_event(Event::AliasAuthorizationRemoved { - aliaser: versioned_to_remove, - target: versioned_origin, + aliaser: to_remove, + target: origin_location, }); } else if old_len != new_len { // update aliasers and storage deposit @@ -1591,8 +1588,8 @@ pub mod pallet { let entry = AuthorizedAliasesEntry { aliasers, ticket }; AuthorizedAliases::::insert(&versioned_origin, entry); Self::deposit_event(Event::AliasAuthorizationRemoved { - aliaser: versioned_to_remove, - target: versioned_origin, + aliaser: to_remove, + target: origin_location, }); } } @@ -2827,8 +2824,7 @@ impl Pallet { let location: Location = location.try_into().map_err(|e| { tracing::debug!( target: "xcm::pallet_xcm::is_trusted_reserve", - "Asset version conversion failed with error: {:?}", - e, + ?e, "Failed to convert versioned location", ); TrustedQueryApiError::VersionedLocationConversionFailed })?; @@ -2836,8 +2832,7 @@ impl Pallet { let a: Asset = asset.try_into().map_err(|e| { tracing::debug!( target: "xcm::pallet_xcm::is_trusted_reserve", - "Location version conversion failed with error: {:?}", - e, + ?e, "Failed to convert versioned asset", ); TrustedQueryApiError::VersionedAssetConversionFailed })?; @@ -2853,16 +2848,14 @@ impl Pallet { let location: Location = location.try_into().map_err(|e| { tracing::debug!( target: "xcm::pallet_xcm::is_trusted_teleporter", - "Asset version conversion failed with error: {:?}", - e, + ?e, "Failed to convert versioned location", ); TrustedQueryApiError::VersionedLocationConversionFailed })?; let a: Asset = asset.try_into().map_err(|e| { tracing::debug!( target: "xcm::pallet_xcm::is_trusted_teleporter", - "Location version conversion failed with error: {:?}", - e, + ?e, "Failed to convert versioned asset", ); TrustedQueryApiError::VersionedAssetConversionFailed })?; @@ -2870,31 +2863,66 @@ impl Pallet { } /// Returns locations allowed to alias into and act as `target`. - pub fn authorized_aliasers(target: VersionedLocation) -> Vec { - AuthorizedAliases::::get(&target) - .map(|authorized| authorized.aliasers.into_iter().collect()) - .unwrap_or_default() + pub fn authorized_aliasers( + target: VersionedLocation, + ) -> Result, AuthorizedAliasersApiError> { + let desired_version = target.identify_version(); + // storage entries are always latest version + let target: VersionedLocation = target.into_version(XCM_VERSION).map_err(|e| { + tracing::debug!( + target: "xcm::pallet_xcm::authorized_aliasers", + ?e, "Failed to convert versioned location", + ); + AuthorizedAliasersApiError::LocationVersionConversionFailed + })?; + Ok(AuthorizedAliases::::get(&target) + .map(|authorized| { + authorized + .aliasers + .into_iter() + .filter_map(|aliaser| { + let OriginAliaser { location, expiry } = aliaser; + location + .into_version(desired_version) + .map(|location| OriginAliaser { location, expiry }) + .ok() + }) + .collect() + }) + .unwrap_or_default()) } /// Given an `origin` and a `target`, returns if the `origin` location was added by `target` as /// an authorized aliaser. /// /// Effectively says whether `origin` is allowed to alias into and act as `target`. - pub fn is_authorized_alias(origin: VersionedLocation, target: VersionedLocation) -> bool { - Self::authorized_aliasers(target) - .iter() - .find(|&aliaser| { + pub fn is_authorized_alias( + origin: VersionedLocation, + target: VersionedLocation, + ) -> Result { + let desired_version = target.identify_version(); + let origin = origin.into_version(desired_version).map_err(|e| { + tracing::debug!( + target: "xcm::pallet_xcm::is_authorized_alias", + ?e, "mismatching origin and target versions", + ); + AuthorizedAliasersApiError::LocationVersionConversionFailed + })?; + Ok(Self::authorized_aliasers(target)? + .into_iter() + .find(|aliaser| { + // `aliasers` and `origin` have already been transformed to `desired_version`, we + // can just directly compare them. aliaser.location == origin && aliaser .expiry .map(|expiry| { - expiry < - frame_system::Pallet::::current_block_number() - .saturated_into::() + frame_system::Pallet::::current_block_number() + .saturated_into::() < expiry }) .unwrap_or(true) }) - .is_some() + .is_some()) } /// Create a new expectation of a query response with the querier being here. @@ -3651,7 +3679,7 @@ impl + Clone, T: Config> ContainsPair for Autho tracing::trace!(target: "xcm::pallet_xcm::AuthorizedAliasers::contains", ?origin, ?target); // return true if the `origin` has been explicitly authorized by `target` as aliaser, and // the authorization has not expired - Pallet::::is_authorized_alias(origin, target) + Pallet::::is_authorized_alias(origin, target).unwrap_or(false) } } diff --git a/polkadot/xcm/pallet-xcm/src/migration.rs b/polkadot/xcm/pallet-xcm/src/migration.rs index f43719ef9b99..194bb1680ec4 100644 --- a/polkadot/xcm/pallet-xcm/src/migration.rs +++ b/polkadot/xcm/pallet-xcm/src/migration.rs @@ -176,21 +176,24 @@ pub mod data { { type MigratedData = (VersionedLocation, AuthorizedAliasesEntry, M>); - fn needs_migration(&self, _: XcmVersion) -> bool { - self.0.identify_version() < XCM_VERSION || + fn needs_migration(&self, required_version: XcmVersion) -> bool { + self.0.identify_version() != required_version || self.1 .aliasers .iter() - .any(|alias| alias.location.identify_version() < XCM_VERSION) + .any(|alias| alias.location.identify_version() != required_version) } - fn try_migrate(self, _: XcmVersion) -> Result, ()> { - if !self.needs_migration(XCM_VERSION) { + fn try_migrate( + self, + required_version: XcmVersion, + ) -> Result, ()> { + if !self.needs_migration(required_version) { return Ok(None) } - let key = if self.0.identify_version() < XCM_VERSION { - let Ok(converted_key) = self.0.clone().into_version(XCM_VERSION) else { + let key = if self.0.identify_version() != required_version { + let Ok(converted_key) = self.0.clone().into_version(required_version) else { return Err(()) }; converted_key @@ -202,8 +205,8 @@ pub mod data { let (aliasers, ticket) = (self.1.aliasers, self.1.ticket); for alias in aliasers { let OriginAliaser { mut location, expiry } = alias.clone(); - if location.identify_version() < XCM_VERSION { - location = location.into_version(XCM_VERSION)?; + if location.identify_version() != required_version { + location = location.into_version(required_version)?; } new_aliases.try_push(OriginAliaser { location, expiry }).map_err(|_| ())?; } diff --git a/polkadot/xcm/src/lib.rs b/polkadot/xcm/src/lib.rs index a41a8e797b0f..319ff2e297ec 100644 --- a/polkadot/xcm/src/lib.rs +++ b/polkadot/xcm/src/lib.rs @@ -138,12 +138,17 @@ macro_rules! versioned_type { } impl IntoVersion for $n { fn into_version(self, n: Version) -> Result { - Ok(match n { - 3 => Self::V3(self.try_into()?), - 4 => Self::V4(self.try_into()?), - 5 => Self::V5(self.try_into()?), - _ => return Err(()), - }) + let version = self.identify_version(); + if version == n { + Ok(self) + } else { + Ok(match n { + 3 => Self::V3(self.try_into()?), + 4 => Self::V4(self.try_into()?), + 5 => Self::V5(self.try_into()?), + _ => return Err(()), + }) + } } } impl From<$v3> for $n { diff --git a/polkadot/xcm/xcm-runtime-apis/src/authorized_aliases.rs b/polkadot/xcm/xcm-runtime-apis/src/authorized_aliases.rs index b7aa82c5fa97..f696b319a5f1 100644 --- a/polkadot/xcm/xcm-runtime-apis/src/authorized_aliases.rs +++ b/polkadot/xcm/xcm-runtime-apis/src/authorized_aliases.rs @@ -33,8 +33,16 @@ sp_api::decl_runtime_apis! { /// API for querying XCM authorized aliases pub trait AuthorizedAliasersApi { /// Returns locations allowed to alias into and act as `target`. - fn authorized_aliasers(target: VersionedLocation) -> Vec; + fn authorized_aliasers(target: VersionedLocation) -> Result, Error>; /// Returns whether `origin` is allowed to alias into and act as `target`. - fn is_authorized_alias(origin: VersionedLocation, target: VersionedLocation) -> bool; + fn is_authorized_alias(origin: VersionedLocation, target: VersionedLocation) -> Result; } } + +/// `AuthorizedAliasersApi` Runtime APIs errors. +#[derive(Copy, Clone, Encode, Decode, Eq, PartialEq, Debug, TypeInfo)] +pub enum Error { + /// Converting a location from one version to another failed. + #[codec(index = 0)] + LocationVersionConversionFailed, +} diff --git a/polkadot/xcm/xcm-runtime-apis/src/trusted_query.rs b/polkadot/xcm/xcm-runtime-apis/src/trusted_query.rs index 9536f2bf6731..ed02ec92b1a4 100644 --- a/polkadot/xcm/xcm-runtime-apis/src/trusted_query.rs +++ b/polkadot/xcm/xcm-runtime-apis/src/trusted_query.rs @@ -44,7 +44,9 @@ sp_api::decl_runtime_apis! { #[derive(Copy, Clone, Encode, Decode, Eq, PartialEq, Debug, TypeInfo)] pub enum Error { /// Converting a versioned Asset structure from one version to another failed. + #[codec(index = 0)] VersionedAssetConversionFailed, /// Converting a versioned Location structure from one version to another failed. + #[codec(index = 1)] VersionedLocationConversionFailed, } From 1d17ef45b51a369966b940065ac5a184650116e0 Mon Sep 17 00:00:00 2001 From: Adrian Catangiu Date: Thu, 16 Jan 2025 19:04:19 +0200 Subject: [PATCH 35/40] fix tests --- .../parachains/runtimes/assets/asset-hub-westend/tests/tests.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/cumulus/parachains/runtimes/assets/asset-hub-westend/tests/tests.rs b/cumulus/parachains/runtimes/assets/asset-hub-westend/tests/tests.rs index 09bb5f332884..8ebb2d59f538 100644 --- a/cumulus/parachains/runtimes/assets/asset-hub-westend/tests/tests.rs +++ b/cumulus/parachains/runtimes/assets/asset-hub-westend/tests/tests.rs @@ -975,6 +975,8 @@ fn authorized_aliases_work() { let alice_on_relay = Location::new(1, AccountId32 { network: None, id: ALICE }); let bob_on_relay = Location::new(1, AccountId32 { network: None, id: [42_u8; 32] }); + assert_ok!(Balances::mint_into(&alice, 2 * UNITS)); + // neither `alice_on_sibling_para`, `alice_on_relay`, `bob_on_relay` are allowed to // alias into `local_alice` for aliaser in [&alice_on_sibling_para, &alice_on_relay, &bob_on_relay] { From 91e283a7691e9c7059956c6637f63585a68c6299 Mon Sep 17 00:00:00 2001 From: Adrian Catangiu Date: Fri, 17 Jan 2025 10:59:45 +0200 Subject: [PATCH 36/40] fix clippy --- polkadot/xcm/pallet-xcm/src/lib.rs | 27 ++++++++++++--------------- 1 file changed, 12 insertions(+), 15 deletions(-) diff --git a/polkadot/xcm/pallet-xcm/src/lib.rs b/polkadot/xcm/pallet-xcm/src/lib.rs index 0fa2a21311c0..998cd1e9f699 100644 --- a/polkadot/xcm/pallet-xcm/src/lib.rs +++ b/polkadot/xcm/pallet-xcm/src/lib.rs @@ -2908,21 +2908,18 @@ impl Pallet { ); AuthorizedAliasersApiError::LocationVersionConversionFailed })?; - Ok(Self::authorized_aliasers(target)? - .into_iter() - .find(|aliaser| { - // `aliasers` and `origin` have already been transformed to `desired_version`, we - // can just directly compare them. - aliaser.location == origin && - aliaser - .expiry - .map(|expiry| { - frame_system::Pallet::::current_block_number() - .saturated_into::() < expiry - }) - .unwrap_or(true) - }) - .is_some()) + Ok(Self::authorized_aliasers(target)?.into_iter().any(|aliaser| { + // `aliasers` and `origin` have already been transformed to `desired_version`, we + // can just directly compare them. + aliaser.location == origin && + aliaser + .expiry + .map(|expiry| { + frame_system::Pallet::::current_block_number().saturated_into::() < + expiry + }) + .unwrap_or(true) + })) } /// Create a new expectation of a query response with the querier being here. From 7056188ae2b6b2781707524641ff42faccbda93d Mon Sep 17 00:00:00 2001 From: Adrian Catangiu Date: Fri, 17 Jan 2025 11:05:14 +0200 Subject: [PATCH 37/40] fix more test runtimes --- .../runtimes/contracts/contracts-rococo/src/xcm_config.rs | 3 ++- polkadot/runtime/test-runtime/src/xcm_config.rs | 4 +++- polkadot/xcm/xcm-builder/src/tests/pay/mock.rs | 3 ++- polkadot/xcm/xcm-runtime-apis/tests/mock.rs | 5 +++-- 4 files changed, 10 insertions(+), 5 deletions(-) diff --git a/cumulus/parachains/runtimes/contracts/contracts-rococo/src/xcm_config.rs b/cumulus/parachains/runtimes/contracts/contracts-rococo/src/xcm_config.rs index 930e83ac84d6..a346b43313a0 100644 --- a/cumulus/parachains/runtimes/contracts/contracts-rococo/src/xcm_config.rs +++ b/cumulus/parachains/runtimes/contracts/contracts-rococo/src/xcm_config.rs @@ -20,7 +20,7 @@ use super::{ use cumulus_primitives_core::AggregateMessageOrigin; use frame_support::{ parameter_types, - traits::{ConstU32, Contains, EitherOfDiverse, Equals, Everything, Nothing}, + traits::{ConstU32, Contains, Disabled, EitherOfDiverse, Equals, Everything, Nothing}, weights::Weight, }; use frame_system::EnsureRoot; @@ -254,6 +254,7 @@ impl pallet_xcm::Config for Runtime { type AdminOrigin = EnsureRoot; type MaxRemoteLockConsumers = ConstU32<0>; type RemoteLockConsumerIdentifier = (); + type AuthorizedAliasConsideration = Disabled; } impl cumulus_pallet_xcm::Config for Runtime { diff --git a/polkadot/runtime/test-runtime/src/xcm_config.rs b/polkadot/runtime/test-runtime/src/xcm_config.rs index b424b9a3ee55..3e9dff328246 100644 --- a/polkadot/runtime/test-runtime/src/xcm_config.rs +++ b/polkadot/runtime/test-runtime/src/xcm_config.rs @@ -16,7 +16,7 @@ use frame_support::{ parameter_types, - traits::{Everything, Get, Nothing}, + traits::{Disabled, Everything, Get, Nothing}, weights::Weight, }; use frame_system::EnsureRoot; @@ -185,4 +185,6 @@ impl pallet_xcm::Config for crate::Runtime { type RemoteLockConsumerIdentifier = (); type WeightInfo = pallet_xcm::TestWeightInfo; type AdminOrigin = EnsureRoot; + // Aliasing is disabled: xcm_executor::Config::Aliasers is set to `Nothing`. + type AuthorizedAliasConsideration = Disabled; } diff --git a/polkadot/xcm/xcm-builder/src/tests/pay/mock.rs b/polkadot/xcm/xcm-builder/src/tests/pay/mock.rs index 3dd41b5dbc0b..caecd7a55793 100644 --- a/polkadot/xcm/xcm-builder/src/tests/pay/mock.rs +++ b/polkadot/xcm/xcm-builder/src/tests/pay/mock.rs @@ -16,7 +16,7 @@ use super::*; -use frame_support::traits::{AsEnsureOriginWithArg, Nothing}; +use frame_support::traits::{AsEnsureOriginWithArg, Disabled, Nothing}; use frame_support::derive_impl; @@ -279,6 +279,7 @@ impl pallet_xcm::Config for Test { type RemoteLockConsumerIdentifier = (); type WeightInfo = pallet_xcm::TestWeightInfo; type AdminOrigin = EnsureRoot; + type AuthorizedAliasConsideration = Disabled; } pub const UNITS: Balance = 1_000_000_000_000; diff --git a/polkadot/xcm/xcm-runtime-apis/tests/mock.rs b/polkadot/xcm/xcm-runtime-apis/tests/mock.rs index ce6040c46883..b27192e6e77f 100644 --- a/polkadot/xcm/xcm-runtime-apis/tests/mock.rs +++ b/polkadot/xcm/xcm-runtime-apis/tests/mock.rs @@ -26,8 +26,8 @@ use frame_support::{ BuildStorage, SaturatedConversion, }, traits::{ - AsEnsureOriginWithArg, ConstU128, ConstU32, Contains, ContainsPair, Everything, Nothing, - OriginTrait, + AsEnsureOriginWithArg, ConstU128, ConstU32, Contains, ContainsPair, Disabled, Everything, + Nothing, OriginTrait, }, weights::WeightToFee as WeightToFeeT, }; @@ -361,6 +361,7 @@ impl pallet_xcm::Config for TestRuntime { type MaxRemoteLockConsumers = ConstU32<0>; type RemoteLockConsumerIdentifier = (); type WeightInfo = TestWeightInfo; + type AuthorizedAliasConsideration = Disabled; } #[allow(dead_code)] From 0a705ca6712b63f6314896c5cc0951899016a09e Mon Sep 17 00:00:00 2001 From: Adrian Catangiu Date: Fri, 17 Jan 2025 11:29:47 +0200 Subject: [PATCH 38/40] fix clippy --- .../src/asset_exchange/single_asset_adapter/mock.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/polkadot/xcm/xcm-builder/src/asset_exchange/single_asset_adapter/mock.rs b/polkadot/xcm/xcm-builder/src/asset_exchange/single_asset_adapter/mock.rs index 8bf6acaada31..c9644a428e6f 100644 --- a/polkadot/xcm/xcm-builder/src/asset_exchange/single_asset_adapter/mock.rs +++ b/polkadot/xcm/xcm-builder/src/asset_exchange/single_asset_adapter/mock.rs @@ -23,7 +23,8 @@ use frame_support::{ fungible::{self, NativeFromLeft, NativeOrWithId}, fungibles::Mutate, tokens::imbalance::ResolveAssetTo, - AsEnsureOriginWithArg, Equals, Everything, Nothing, OriginTrait, PalletInfoAccess, + AsEnsureOriginWithArg, Disabled, Equals, Everything, Nothing, OriginTrait, + PalletInfoAccess, }, PalletId, }; From caff17b0b42727937c07df1a068cd5e7fcf7cf8d Mon Sep 17 00:00:00 2001 From: Adrian Catangiu Date: Fri, 17 Jan 2025 13:19:05 +0200 Subject: [PATCH 39/40] fix toml --- cumulus/parachains/runtimes/testing/penpal/Cargo.toml | 1 + 1 file changed, 1 insertion(+) diff --git a/cumulus/parachains/runtimes/testing/penpal/Cargo.toml b/cumulus/parachains/runtimes/testing/penpal/Cargo.toml index 95302f486675..3fedd527615d 100644 --- a/cumulus/parachains/runtimes/testing/penpal/Cargo.toml +++ b/cumulus/parachains/runtimes/testing/penpal/Cargo.toml @@ -139,6 +139,7 @@ std = [ "sp-transaction-pool/std", "sp-version/std", "substrate-wasm-builder", + "testnet-parachains-constants/std", "xcm-builder/std", "xcm-executor/std", "xcm-runtime-apis/std", From 28b69897f3f2536febda72253a24a74a1110173d Mon Sep 17 00:00:00 2001 From: Adrian Catangiu Date: Fri, 17 Jan 2025 13:19:21 +0200 Subject: [PATCH 40/40] fix benchmarks --- polkadot/xcm/pallet-xcm/src/benchmarking.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/polkadot/xcm/pallet-xcm/src/benchmarking.rs b/polkadot/xcm/pallet-xcm/src/benchmarking.rs index e68f6587f3eb..ba7aed226bbd 100644 --- a/polkadot/xcm/pallet-xcm/src/benchmarking.rs +++ b/polkadot/xcm/pallet-xcm/src/benchmarking.rs @@ -620,7 +620,8 @@ mod benchmarks { let aliaser = OriginAliaser { location: alias, expiry: None }; existing_aliases.try_push(aliaser).unwrap() } - let ticket = TicketOf::::new(&who, aliasers_footprint(existing_aliases.len())).unwrap(); + let ticket = TicketOf::::new(&who, aliasers_footprint(existing_aliases.len())) + .map_err(|_| BenchmarkError::Override(BenchmarkResult::from_weight(Weight::MAX)))?; let entry = AuthorizedAliasesEntry { aliasers: existing_aliases, ticket }; AuthorizedAliases::::insert(&origin_location, entry); @@ -658,7 +659,8 @@ mod benchmarks { let aliaser = OriginAliaser { location: alias, expiry: None }; existing_aliases.try_push(aliaser).unwrap() } - let ticket = TicketOf::::new(&who, aliasers_footprint(existing_aliases.len())).unwrap(); + let ticket = TicketOf::::new(&who, aliasers_footprint(existing_aliases.len())) + .map_err(|_| BenchmarkError::Override(BenchmarkResult::from_weight(Weight::MAX)))?; let entry = AuthorizedAliasesEntry { aliasers: existing_aliases, ticket }; AuthorizedAliases::::insert(&origin_location, entry);