mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-04-28 03:58:04 +00:00
[Enhancement] Use XCM V3 for initiate_teleport weight calc (#2102)
* [Enhancement] Use XCM V3 for initiate_teleport weight calc * deref * replicate in all the runtimes * fmt * better handling for AllOf * fmt * small type fix * replicate the fix for all runtimes --------- Co-authored-by: parity-processbot <>
This commit is contained in:
@@ -17,7 +17,7 @@
|
||||
mod pallet_xcm_benchmarks_fungible;
|
||||
mod pallet_xcm_benchmarks_generic;
|
||||
|
||||
use crate::Runtime;
|
||||
use crate::{xcm_config::MaxAssetsIntoHolding, Runtime};
|
||||
use frame_support::weights::Weight;
|
||||
use pallet_xcm_benchmarks_fungible::WeightInfo as XcmFungibleWeight;
|
||||
use pallet_xcm_benchmarks_generic::WeightInfo as XcmGeneric;
|
||||
@@ -35,7 +35,18 @@ impl WeighMultiAssets for MultiAssetFilter {
|
||||
match self {
|
||||
Self::Definite(assets) =>
|
||||
weight.saturating_mul(assets.inner().into_iter().count() as u64),
|
||||
Self::Wild(_) => weight.saturating_mul(MAX_ASSETS as u64),
|
||||
Self::Wild(asset) => match asset {
|
||||
All => weight.saturating_mul(MAX_ASSETS as u64),
|
||||
AllOf { fun, .. } => match fun {
|
||||
WildFungibility::Fungible => weight,
|
||||
// Magic number 2 has to do with the fact that we could have up to 2 times
|
||||
// MaxAssetsIntoHolding in the worst-case scenario.
|
||||
WildFungibility::NonFungible =>
|
||||
weight.saturating_mul((MaxAssetsIntoHolding::get() * 2) as u64),
|
||||
},
|
||||
AllCounted(count) => weight.saturating_mul(*count as u64),
|
||||
AllOfCounted { count, .. } => weight.saturating_mul(*count as u64),
|
||||
},
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -138,10 +149,7 @@ impl<Call> XcmWeightInfo<Call> for StatemineXcmWeight<Call> {
|
||||
_dest: &MultiLocation,
|
||||
_xcm: &Xcm<()>,
|
||||
) -> Weight {
|
||||
// Hardcoded till the XCM pallet is fixed
|
||||
let hardcoded_weight = Weight::from_ref_time(200_000_000 as u64);
|
||||
let weight = assets.weigh_multi_assets(XcmFungibleWeight::<Runtime>::initiate_teleport());
|
||||
hardcoded_weight.min(weight)
|
||||
assets.weigh_multi_assets(XcmFungibleWeight::<Runtime>::initiate_teleport())
|
||||
}
|
||||
fn report_holding(_response_info: &QueryResponseInfo, _assets: &MultiAssetFilter) -> Weight {
|
||||
XcmGeneric::<Runtime>::report_holding()
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
mod pallet_xcm_benchmarks_fungible;
|
||||
mod pallet_xcm_benchmarks_generic;
|
||||
|
||||
use crate::Runtime;
|
||||
use crate::{xcm_config::MaxAssetsIntoHolding, Runtime};
|
||||
use frame_support::weights::Weight;
|
||||
use pallet_xcm_benchmarks_fungible::WeightInfo as XcmFungibleWeight;
|
||||
use pallet_xcm_benchmarks_generic::WeightInfo as XcmGeneric;
|
||||
@@ -35,7 +35,18 @@ impl WeighMultiAssets for MultiAssetFilter {
|
||||
match self {
|
||||
Self::Definite(assets) =>
|
||||
weight.saturating_mul(assets.inner().into_iter().count() as u64),
|
||||
Self::Wild(_) => weight.saturating_mul(MAX_ASSETS as u64),
|
||||
Self::Wild(asset) => match asset {
|
||||
All => weight.saturating_mul(MAX_ASSETS as u64),
|
||||
AllOf { fun, .. } => match fun {
|
||||
WildFungibility::Fungible => weight,
|
||||
// Magic number 2 has to do with the fact that we could have up to 2 times
|
||||
// MaxAssetsIntoHolding in the worst-case scenario.
|
||||
WildFungibility::NonFungible =>
|
||||
weight.saturating_mul((MaxAssetsIntoHolding::get() * 2) as u64),
|
||||
},
|
||||
AllCounted(count) => weight.saturating_mul(*count as u64),
|
||||
AllOfCounted { count, .. } => weight.saturating_mul(*count as u64),
|
||||
},
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -138,10 +149,7 @@ impl<Call> XcmWeightInfo<Call> for StatemintXcmWeight<Call> {
|
||||
_dest: &MultiLocation,
|
||||
_xcm: &Xcm<()>,
|
||||
) -> Weight {
|
||||
// Hardcoded till the XCM pallet is fixed
|
||||
let hardcoded_weight = Weight::from_ref_time(200_000_000 as u64);
|
||||
let weight = assets.weigh_multi_assets(XcmFungibleWeight::<Runtime>::initiate_teleport());
|
||||
hardcoded_weight.min(weight)
|
||||
assets.weigh_multi_assets(XcmFungibleWeight::<Runtime>::initiate_teleport())
|
||||
}
|
||||
fn report_holding(_response_info: &QueryResponseInfo, _assets: &MultiAssetFilter) -> Weight {
|
||||
XcmGeneric::<Runtime>::report_holding()
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
mod pallet_xcm_benchmarks_fungible;
|
||||
mod pallet_xcm_benchmarks_generic;
|
||||
|
||||
use crate::Runtime;
|
||||
use crate::{xcm_config::MaxAssetsIntoHolding, Runtime};
|
||||
use frame_support::weights::Weight;
|
||||
use pallet_xcm_benchmarks_fungible::WeightInfo as XcmFungibleWeight;
|
||||
use pallet_xcm_benchmarks_generic::WeightInfo as XcmGeneric;
|
||||
@@ -35,7 +35,18 @@ impl WeighMultiAssets for MultiAssetFilter {
|
||||
match self {
|
||||
Self::Definite(assets) =>
|
||||
weight.saturating_mul(assets.inner().into_iter().count() as u64),
|
||||
Self::Wild(_) => weight.saturating_mul(MAX_ASSETS as u64),
|
||||
Self::Wild(asset) => match asset {
|
||||
All => weight.saturating_mul(MAX_ASSETS as u64),
|
||||
AllOf { fun, .. } => match fun {
|
||||
WildFungibility::Fungible => weight,
|
||||
// Magic number 2 has to do with the fact that we could have up to 2 times
|
||||
// MaxAssetsIntoHolding in the worst-case scenario.
|
||||
WildFungibility::NonFungible =>
|
||||
weight.saturating_mul((MaxAssetsIntoHolding::get() * 2) as u64),
|
||||
},
|
||||
AllCounted(count) => weight.saturating_mul(*count as u64),
|
||||
AllOfCounted { count, .. } => weight.saturating_mul(*count as u64),
|
||||
},
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -138,10 +149,7 @@ impl<Call> XcmWeightInfo<Call> for WestmintXcmWeight<Call> {
|
||||
_dest: &MultiLocation,
|
||||
_xcm: &Xcm<()>,
|
||||
) -> Weight {
|
||||
// Hardcoded till the XCM pallet is fixed
|
||||
let hardcoded_weight = Weight::from_ref_time(200_000_000 as u64);
|
||||
let weight = assets.weigh_multi_assets(XcmFungibleWeight::<Runtime>::initiate_teleport());
|
||||
hardcoded_weight.min(weight)
|
||||
assets.weigh_multi_assets(XcmFungibleWeight::<Runtime>::initiate_teleport())
|
||||
}
|
||||
fn report_holding(_response_info: &QueryResponseInfo, _assets: &MultiAssetFilter) -> Weight {
|
||||
XcmGeneric::<Runtime>::report_holding()
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
mod pallet_xcm_benchmarks_fungible;
|
||||
mod pallet_xcm_benchmarks_generic;
|
||||
|
||||
use crate::Runtime;
|
||||
use crate::{xcm_config::MaxAssetsIntoHolding, Runtime};
|
||||
use frame_support::weights::Weight;
|
||||
use pallet_xcm_benchmarks_fungible::WeightInfo as XcmFungibleWeight;
|
||||
use pallet_xcm_benchmarks_generic::WeightInfo as XcmGeneric;
|
||||
@@ -35,7 +35,18 @@ impl WeighMultiAssets for MultiAssetFilter {
|
||||
match self {
|
||||
Self::Definite(assets) =>
|
||||
weight.saturating_mul(assets.inner().into_iter().count() as u64),
|
||||
Self::Wild(_) => weight.saturating_mul(MAX_ASSETS as u64),
|
||||
Self::Wild(asset) => match asset {
|
||||
All => weight.saturating_mul(MAX_ASSETS as u64),
|
||||
AllOf { fun, .. } => match fun {
|
||||
WildFungibility::Fungible => weight,
|
||||
// Magic number 2 has to do with the fact that we could have up to 2 times
|
||||
// MaxAssetsIntoHolding in the worst-case scenario.
|
||||
WildFungibility::NonFungible =>
|
||||
weight.saturating_mul((MaxAssetsIntoHolding::get() * 2) as u64),
|
||||
},
|
||||
AllCounted(count) => weight.saturating_mul(*count as u64),
|
||||
AllOfCounted { count, .. } => weight.saturating_mul(*count as u64),
|
||||
},
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -138,10 +149,7 @@ impl<Call> XcmWeightInfo<Call> for BridgeHubKusamaXcmWeight<Call> {
|
||||
_dest: &MultiLocation,
|
||||
_xcm: &Xcm<()>,
|
||||
) -> Weight {
|
||||
// Hardcoded till the XCM pallet is fixed
|
||||
let hardcoded_weight = Weight::from_ref_time(200_000_000 as u64);
|
||||
let weight = assets.weigh_multi_assets(XcmFungibleWeight::<Runtime>::initiate_teleport());
|
||||
hardcoded_weight.min(weight)
|
||||
assets.weigh_multi_assets(XcmFungibleWeight::<Runtime>::initiate_teleport())
|
||||
}
|
||||
fn report_holding(_response_info: &QueryResponseInfo, _assets: &MultiAssetFilter) -> Weight {
|
||||
XcmGeneric::<Runtime>::report_holding()
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
mod pallet_xcm_benchmarks_fungible;
|
||||
mod pallet_xcm_benchmarks_generic;
|
||||
|
||||
use crate::Runtime;
|
||||
use crate::{xcm_config::MaxAssetsIntoHolding, Runtime};
|
||||
use frame_support::weights::Weight;
|
||||
use pallet_xcm_benchmarks_fungible::WeightInfo as XcmFungibleWeight;
|
||||
use pallet_xcm_benchmarks_generic::WeightInfo as XcmGeneric;
|
||||
@@ -35,7 +35,18 @@ impl WeighMultiAssets for MultiAssetFilter {
|
||||
match self {
|
||||
Self::Definite(assets) =>
|
||||
weight.saturating_mul(assets.inner().into_iter().count() as u64),
|
||||
Self::Wild(_) => weight.saturating_mul(MAX_ASSETS as u64),
|
||||
Self::Wild(asset) => match asset {
|
||||
All => weight.saturating_mul(MAX_ASSETS as u64),
|
||||
AllOf { fun, .. } => match fun {
|
||||
WildFungibility::Fungible => weight,
|
||||
// Magic number 2 has to do with the fact that we could have up to 2 times
|
||||
// MaxAssetsIntoHolding in the worst-case scenario.
|
||||
WildFungibility::NonFungible =>
|
||||
weight.saturating_mul((MaxAssetsIntoHolding::get() * 2) as u64),
|
||||
},
|
||||
AllCounted(count) => weight.saturating_mul(*count as u64),
|
||||
AllOfCounted { count, .. } => weight.saturating_mul(*count as u64),
|
||||
},
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
mod pallet_xcm_benchmarks_fungible;
|
||||
mod pallet_xcm_benchmarks_generic;
|
||||
|
||||
use crate::Runtime;
|
||||
use crate::{xcm_config::MaxAssetsIntoHolding, Runtime};
|
||||
use frame_support::weights::Weight;
|
||||
use pallet_xcm_benchmarks_fungible::WeightInfo as XcmFungibleWeight;
|
||||
use pallet_xcm_benchmarks_generic::WeightInfo as XcmGeneric;
|
||||
@@ -35,7 +35,18 @@ impl WeighMultiAssets for MultiAssetFilter {
|
||||
match self {
|
||||
Self::Definite(assets) =>
|
||||
weight.saturating_mul(assets.inner().into_iter().count() as u64),
|
||||
Self::Wild(_) => weight.saturating_mul(MAX_ASSETS as u64),
|
||||
Self::Wild(asset) => match asset {
|
||||
All => weight.saturating_mul(MAX_ASSETS as u64),
|
||||
AllOf { fun, .. } => match fun {
|
||||
WildFungibility::Fungible => weight,
|
||||
// Magic number 2 has to do with the fact that we could have up to 2 times
|
||||
// MaxAssetsIntoHolding in the worst-case scenario.
|
||||
WildFungibility::NonFungible =>
|
||||
weight.saturating_mul((MaxAssetsIntoHolding::get() * 2) as u64),
|
||||
},
|
||||
AllCounted(count) => weight.saturating_mul(*count as u64),
|
||||
AllOfCounted { count, .. } => weight.saturating_mul(*count as u64),
|
||||
},
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -138,10 +149,7 @@ impl<Call> XcmWeightInfo<Call> for BridgeHubRococoXcmWeight<Call> {
|
||||
_dest: &MultiLocation,
|
||||
_xcm: &Xcm<()>,
|
||||
) -> Weight {
|
||||
// Hardcoded till the XCM pallet is fixed
|
||||
let hardcoded_weight = Weight::from_ref_time(200_000_000 as u64);
|
||||
let weight = assets.weigh_multi_assets(XcmFungibleWeight::<Runtime>::initiate_teleport());
|
||||
hardcoded_weight.min(weight)
|
||||
assets.weigh_multi_assets(XcmFungibleWeight::<Runtime>::initiate_teleport())
|
||||
}
|
||||
fn report_holding(_response_info: &QueryResponseInfo, _assets: &MultiAssetFilter) -> Weight {
|
||||
XcmGeneric::<Runtime>::report_holding()
|
||||
|
||||
Reference in New Issue
Block a user