Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

Commit

Permalink
Revert "[Enhancement] Use XCM V3 for initiate_teleport weight calc (#…
Browse files Browse the repository at this point in the history
…2102)"

This reverts commit 8230ec4.
  • Loading branch information
EgorPopelyaev committed Mar 28, 2023
1 parent 747ebd3 commit 83dbea9
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 83 deletions.
20 changes: 6 additions & 14 deletions parachains/runtimes/assets/statemine/src/weights/xcm/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
mod pallet_xcm_benchmarks_fungible;
mod pallet_xcm_benchmarks_generic;

use crate::{xcm_config::MaxAssetsIntoHolding, Runtime};
use crate::Runtime;
use frame_support::weights::Weight;
use pallet_xcm_benchmarks_fungible::WeightInfo as XcmFungibleWeight;
use pallet_xcm_benchmarks_generic::WeightInfo as XcmGeneric;
Expand All @@ -35,18 +35,7 @@ impl WeighMultiAssets for MultiAssetFilter {
match self {
Self::Definite(assets) =>
weight.saturating_mul(assets.inner().into_iter().count() as u64),
Self::Wild(asset) => match asset {
All => weight.saturating_mul(MAX_ASSETS),
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(MAX_ASSETS.min(*count as u64)),
AllOfCounted { count, .. } => weight.saturating_mul(MAX_ASSETS.min(*count as u64)),
},
Self::Wild(_) => weight.saturating_mul(MAX_ASSETS as u64),
}
}
}
Expand Down Expand Up @@ -149,7 +138,10 @@ impl<Call> XcmWeightInfo<Call> for StatemineXcmWeight<Call> {
_dest: &MultiLocation,
_xcm: &Xcm<()>,
) -> Weight {
assets.weigh_multi_assets(XcmFungibleWeight::<Runtime>::initiate_teleport())
// 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)
}
fn report_holding(_response_info: &QueryResponseInfo, _assets: &MultiAssetFilter) -> Weight {
XcmGeneric::<Runtime>::report_holding()
Expand Down
20 changes: 6 additions & 14 deletions parachains/runtimes/assets/statemint/src/weights/xcm/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
mod pallet_xcm_benchmarks_fungible;
mod pallet_xcm_benchmarks_generic;

use crate::{xcm_config::MaxAssetsIntoHolding, Runtime};
use crate::Runtime;
use frame_support::weights::Weight;
use pallet_xcm_benchmarks_fungible::WeightInfo as XcmFungibleWeight;
use pallet_xcm_benchmarks_generic::WeightInfo as XcmGeneric;
Expand All @@ -35,18 +35,7 @@ impl WeighMultiAssets for MultiAssetFilter {
match self {
Self::Definite(assets) =>
weight.saturating_mul(assets.inner().into_iter().count() as u64),
Self::Wild(asset) => match asset {
All => weight.saturating_mul(MAX_ASSETS),
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(MAX_ASSETS.min(*count as u64)),
AllOfCounted { count, .. } => weight.saturating_mul(MAX_ASSETS.min(*count as u64)),
},
Self::Wild(_) => weight.saturating_mul(MAX_ASSETS as u64),
}
}
}
Expand Down Expand Up @@ -149,7 +138,10 @@ impl<Call> XcmWeightInfo<Call> for StatemintXcmWeight<Call> {
_dest: &MultiLocation,
_xcm: &Xcm<()>,
) -> Weight {
assets.weigh_multi_assets(XcmFungibleWeight::<Runtime>::initiate_teleport())
// 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)
}
fn report_holding(_response_info: &QueryResponseInfo, _assets: &MultiAssetFilter) -> Weight {
XcmGeneric::<Runtime>::report_holding()
Expand Down
20 changes: 6 additions & 14 deletions parachains/runtimes/assets/westmint/src/weights/xcm/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
mod pallet_xcm_benchmarks_fungible;
mod pallet_xcm_benchmarks_generic;

use crate::{xcm_config::MaxAssetsIntoHolding, Runtime};
use crate::Runtime;
use frame_support::weights::Weight;
use pallet_xcm_benchmarks_fungible::WeightInfo as XcmFungibleWeight;
use pallet_xcm_benchmarks_generic::WeightInfo as XcmGeneric;
Expand All @@ -35,18 +35,7 @@ impl WeighMultiAssets for MultiAssetFilter {
match self {
Self::Definite(assets) =>
weight.saturating_mul(assets.inner().into_iter().count() as u64),
Self::Wild(asset) => match asset {
All => weight.saturating_mul(MAX_ASSETS),
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(MAX_ASSETS.min(*count as u64)),
AllOfCounted { count, .. } => weight.saturating_mul(MAX_ASSETS.min(*count as u64)),
},
Self::Wild(_) => weight.saturating_mul(MAX_ASSETS as u64),
}
}
}
Expand Down Expand Up @@ -149,7 +138,10 @@ impl<Call> XcmWeightInfo<Call> for WestmintXcmWeight<Call> {
_dest: &MultiLocation,
_xcm: &Xcm<()>,
) -> Weight {
assets.weigh_multi_assets(XcmFungibleWeight::<Runtime>::initiate_teleport())
// 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)
}
fn report_holding(_response_info: &QueryResponseInfo, _assets: &MultiAssetFilter) -> Weight {
XcmGeneric::<Runtime>::report_holding()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
mod pallet_xcm_benchmarks_fungible;
mod pallet_xcm_benchmarks_generic;

use crate::{xcm_config::MaxAssetsIntoHolding, Runtime};
use crate::Runtime;
use frame_support::weights::Weight;
use pallet_xcm_benchmarks_fungible::WeightInfo as XcmFungibleWeight;
use pallet_xcm_benchmarks_generic::WeightInfo as XcmGeneric;
Expand All @@ -35,18 +35,7 @@ impl WeighMultiAssets for MultiAssetFilter {
match self {
Self::Definite(assets) =>
weight.saturating_mul(assets.inner().into_iter().count() as u64),
Self::Wild(asset) => match asset {
All => weight.saturating_mul(MAX_ASSETS),
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(MAX_ASSETS.min(*count as u64)),
AllOfCounted { count, .. } => weight.saturating_mul(MAX_ASSETS.min(*count as u64)),
},
Self::Wild(_) => weight.saturating_mul(MAX_ASSETS as u64),
}
}
}
Expand Down Expand Up @@ -149,7 +138,10 @@ impl<Call> XcmWeightInfo<Call> for BridgeHubKusamaXcmWeight<Call> {
_dest: &MultiLocation,
_xcm: &Xcm<()>,
) -> Weight {
assets.weigh_multi_assets(XcmFungibleWeight::<Runtime>::initiate_teleport())
// 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)
}
fn report_holding(_response_info: &QueryResponseInfo, _assets: &MultiAssetFilter) -> Weight {
XcmGeneric::<Runtime>::report_holding()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
mod pallet_xcm_benchmarks_fungible;
mod pallet_xcm_benchmarks_generic;

use crate::{xcm_config::MaxAssetsIntoHolding, Runtime};
use crate::Runtime;
use frame_support::weights::Weight;
use pallet_xcm_benchmarks_fungible::WeightInfo as XcmFungibleWeight;
use pallet_xcm_benchmarks_generic::WeightInfo as XcmGeneric;
Expand All @@ -35,18 +35,7 @@ impl WeighMultiAssets for MultiAssetFilter {
match self {
Self::Definite(assets) =>
weight.saturating_mul(assets.inner().into_iter().count() as u64),
Self::Wild(asset) => match asset {
All => weight.saturating_mul(MAX_ASSETS),
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(MAX_ASSETS.min(*count as u64)),
AllOfCounted { count, .. } => weight.saturating_mul(MAX_ASSETS.min(*count as u64)),
},
Self::Wild(_) => weight.saturating_mul(MAX_ASSETS as u64),
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
mod pallet_xcm_benchmarks_fungible;
mod pallet_xcm_benchmarks_generic;

use crate::{xcm_config::MaxAssetsIntoHolding, Runtime};
use crate::Runtime;
use frame_support::weights::Weight;
use pallet_xcm_benchmarks_fungible::WeightInfo as XcmFungibleWeight;
use pallet_xcm_benchmarks_generic::WeightInfo as XcmGeneric;
Expand All @@ -35,18 +35,7 @@ impl WeighMultiAssets for MultiAssetFilter {
match self {
Self::Definite(assets) =>
weight.saturating_mul(assets.inner().into_iter().count() as u64),
Self::Wild(asset) => match asset {
All => weight.saturating_mul(MAX_ASSETS),
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(MAX_ASSETS.min(*count as u64)),
AllOfCounted { count, .. } => weight.saturating_mul(MAX_ASSETS.min(*count as u64)),
},
Self::Wild(_) => weight.saturating_mul(MAX_ASSETS as u64),
}
}
}
Expand Down Expand Up @@ -149,7 +138,10 @@ impl<Call> XcmWeightInfo<Call> for BridgeHubRococoXcmWeight<Call> {
_dest: &MultiLocation,
_xcm: &Xcm<()>,
) -> Weight {
assets.weigh_multi_assets(XcmFungibleWeight::<Runtime>::initiate_teleport())
// 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)
}
fn report_holding(_response_info: &QueryResponseInfo, _assets: &MultiAssetFilter) -> Weight {
XcmGeneric::<Runtime>::report_holding()
Expand Down

0 comments on commit 83dbea9

Please sign in to comment.