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

Commit 269fb07

Browse files
[Revert] Use XCM V3 for initiate_teleport weight calc #2102 (#2394) (#2402)
* Revert "[Enhancement] Use XCM V3 for initiate_teleport weight calc (#2102)" This reverts commit 8230ec4. * updating weight format * We expect to pay 1bn+ for a teleport at the current weights. * The test isn't needed and hardcoded scale is hand to maintain. * remove unused imports --------- Co-authored-by: Giles Cope <gilescope@gmail.com>
1 parent 564aca6 commit 269fb07

File tree

9 files changed

+40
-120
lines changed

9 files changed

+40
-120
lines changed

parachains/runtimes/assets/statemine/src/weights/xcm/mod.rs

+6-14
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
mod pallet_xcm_benchmarks_fungible;
1818
mod pallet_xcm_benchmarks_generic;
1919

20-
use crate::{xcm_config::MaxAssetsIntoHolding, Runtime};
20+
use crate::Runtime;
2121
use frame_support::weights::Weight;
2222
use pallet_xcm_benchmarks_fungible::WeightInfo as XcmFungibleWeight;
2323
use pallet_xcm_benchmarks_generic::WeightInfo as XcmGeneric;
@@ -35,18 +35,7 @@ impl WeighMultiAssets for MultiAssetFilter {
3535
match self {
3636
Self::Definite(assets) =>
3737
weight.saturating_mul(assets.inner().into_iter().count() as u64),
38-
Self::Wild(asset) => match asset {
39-
All => weight.saturating_mul(MAX_ASSETS),
40-
AllOf { fun, .. } => match fun {
41-
WildFungibility::Fungible => weight,
42-
// Magic number 2 has to do with the fact that we could have up to 2 times
43-
// MaxAssetsIntoHolding in the worst-case scenario.
44-
WildFungibility::NonFungible =>
45-
weight.saturating_mul((MaxAssetsIntoHolding::get() * 2) as u64),
46-
},
47-
AllCounted(count) => weight.saturating_mul(MAX_ASSETS.min(*count as u64)),
48-
AllOfCounted { count, .. } => weight.saturating_mul(MAX_ASSETS.min(*count as u64)),
49-
},
38+
Self::Wild(_) => weight.saturating_mul(MAX_ASSETS as u64),
5039
}
5140
}
5241
}
@@ -149,7 +138,10 @@ impl<Call> XcmWeightInfo<Call> for StatemineXcmWeight<Call> {
149138
_dest: &MultiLocation,
150139
_xcm: &Xcm<()>,
151140
) -> Weight {
152-
assets.weigh_multi_assets(XcmFungibleWeight::<Runtime>::initiate_teleport())
141+
// Hardcoded till the XCM pallet is fixed
142+
let hardcoded_weight = Weight::from_parts(200_000_000 as u64, 0);
143+
let weight = assets.weigh_multi_assets(XcmFungibleWeight::<Runtime>::initiate_teleport());
144+
hardcoded_weight.min(weight)
153145
}
154146
fn report_holding(_response_info: &QueryResponseInfo, _assets: &MultiAssetFilter) -> Weight {
155147
XcmGeneric::<Runtime>::report_holding()

parachains/runtimes/assets/statemine/tests/tests.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -448,7 +448,7 @@ fn receive_teleported_asset_works() {
448448
id: Concrete(MultiLocation { parents: 1, interior: Here }),
449449
fun: Fungible(10000000000000),
450450
},
451-
weight_limit: Limited(Weight::from_parts(303531000, 65536)),
451+
weight_limit: Limited(Weight::from_parts(1303531000, 65536)),
452452
},
453453
DepositAsset {
454454
assets: Wild(AllCounted(1)),

parachains/runtimes/assets/statemint/src/weights/xcm/mod.rs

+6-14
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
mod pallet_xcm_benchmarks_fungible;
1818
mod pallet_xcm_benchmarks_generic;
1919

20-
use crate::{xcm_config::MaxAssetsIntoHolding, Runtime};
20+
use crate::Runtime;
2121
use frame_support::weights::Weight;
2222
use pallet_xcm_benchmarks_fungible::WeightInfo as XcmFungibleWeight;
2323
use pallet_xcm_benchmarks_generic::WeightInfo as XcmGeneric;
@@ -35,18 +35,7 @@ impl WeighMultiAssets for MultiAssetFilter {
3535
match self {
3636
Self::Definite(assets) =>
3737
weight.saturating_mul(assets.inner().into_iter().count() as u64),
38-
Self::Wild(asset) => match asset {
39-
All => weight.saturating_mul(MAX_ASSETS),
40-
AllOf { fun, .. } => match fun {
41-
WildFungibility::Fungible => weight,
42-
// Magic number 2 has to do with the fact that we could have up to 2 times
43-
// MaxAssetsIntoHolding in the worst-case scenario.
44-
WildFungibility::NonFungible =>
45-
weight.saturating_mul((MaxAssetsIntoHolding::get() * 2) as u64),
46-
},
47-
AllCounted(count) => weight.saturating_mul(MAX_ASSETS.min(*count as u64)),
48-
AllOfCounted { count, .. } => weight.saturating_mul(MAX_ASSETS.min(*count as u64)),
49-
},
38+
Self::Wild(_) => weight.saturating_mul(MAX_ASSETS as u64),
5039
}
5140
}
5241
}
@@ -149,7 +138,10 @@ impl<Call> XcmWeightInfo<Call> for StatemintXcmWeight<Call> {
149138
_dest: &MultiLocation,
150139
_xcm: &Xcm<()>,
151140
) -> Weight {
152-
assets.weigh_multi_assets(XcmFungibleWeight::<Runtime>::initiate_teleport())
141+
// Hardcoded till the XCM pallet is fixed
142+
let hardcoded_weight = Weight::from_parts(200_000_000 as u64, 0);
143+
let weight = assets.weigh_multi_assets(XcmFungibleWeight::<Runtime>::initiate_teleport());
144+
hardcoded_weight.min(weight)
153145
}
154146
fn report_holding(_response_info: &QueryResponseInfo, _assets: &MultiAssetFilter) -> Weight {
155147
XcmGeneric::<Runtime>::report_holding()

parachains/runtimes/assets/statemint/tests/tests.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -460,7 +460,7 @@ fn receive_teleported_asset_works() {
460460
id: Concrete(MultiLocation { parents: 1, interior: Here }),
461461
fun: Fungible(10000000000000),
462462
},
463-
weight_limit: Limited(Weight::from_parts(303531000, 65536)),
463+
weight_limit: Limited(Weight::from_parts(1303531000, 65536)),
464464
},
465465
DepositAsset {
466466
assets: Wild(AllCounted(1)),

parachains/runtimes/assets/westmint/src/weights/xcm/mod.rs

+6-14
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
mod pallet_xcm_benchmarks_fungible;
1818
mod pallet_xcm_benchmarks_generic;
1919

20-
use crate::{xcm_config::MaxAssetsIntoHolding, Runtime};
20+
use crate::Runtime;
2121
use frame_support::weights::Weight;
2222
use pallet_xcm_benchmarks_fungible::WeightInfo as XcmFungibleWeight;
2323
use pallet_xcm_benchmarks_generic::WeightInfo as XcmGeneric;
@@ -35,18 +35,7 @@ impl WeighMultiAssets for MultiAssetFilter {
3535
match self {
3636
Self::Definite(assets) =>
3737
weight.saturating_mul(assets.inner().into_iter().count() as u64),
38-
Self::Wild(asset) => match asset {
39-
All => weight.saturating_mul(MAX_ASSETS),
40-
AllOf { fun, .. } => match fun {
41-
WildFungibility::Fungible => weight,
42-
// Magic number 2 has to do with the fact that we could have up to 2 times
43-
// MaxAssetsIntoHolding in the worst-case scenario.
44-
WildFungibility::NonFungible =>
45-
weight.saturating_mul((MaxAssetsIntoHolding::get() * 2) as u64),
46-
},
47-
AllCounted(count) => weight.saturating_mul(MAX_ASSETS.min(*count as u64)),
48-
AllOfCounted { count, .. } => weight.saturating_mul(MAX_ASSETS.min(*count as u64)),
49-
},
38+
Self::Wild(_) => weight.saturating_mul(MAX_ASSETS as u64),
5039
}
5140
}
5241
}
@@ -149,7 +138,10 @@ impl<Call> XcmWeightInfo<Call> for WestmintXcmWeight<Call> {
149138
_dest: &MultiLocation,
150139
_xcm: &Xcm<()>,
151140
) -> Weight {
152-
assets.weigh_multi_assets(XcmFungibleWeight::<Runtime>::initiate_teleport())
141+
// Hardcoded till the XCM pallet is fixed
142+
let hardcoded_weight = Weight::from_parts(200_000_000 as u64, 0);
143+
let weight = assets.weigh_multi_assets(XcmFungibleWeight::<Runtime>::initiate_teleport());
144+
hardcoded_weight.min(weight)
153145
}
154146
fn report_holding(_response_info: &QueryResponseInfo, _assets: &MultiAssetFilter) -> Weight {
155147
XcmGeneric::<Runtime>::report_holding()

parachains/runtimes/assets/westmint/tests/tests.rs

+6-35
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,20 @@
11
use asset_test_utils::{ExtBuilder, RuntimeHelper};
2-
use codec::{DecodeLimit, Encode};
2+
use codec::Encode;
33
use cumulus_primitives_utility::ChargeWeightInFungibles;
44
use frame_support::{
55
assert_noop, assert_ok, sp_io,
66
weights::{Weight, WeightToFee as WeightToFeeT},
77
};
88
use parachains_common::{AccountId, AuraId, Balance};
9+
use westmint_runtime::xcm_config::{
10+
AssetFeeAsExistentialDepositMultiplierFeeCharger, WestendLocation,
11+
};
912
pub use westmint_runtime::{
1013
constants::fee::WeightToFee,
1114
xcm_config::{TrustBackedAssetsPalletLocation, XcmConfig},
1215
Assets, Balances, ExistentialDeposit, ReservedDmpWeight, Runtime, SessionKeys, System,
1316
};
14-
use westmint_runtime::{
15-
xcm_config::{AssetFeeAsExistentialDepositMultiplierFeeCharger, WestendLocation},
16-
RuntimeCall,
17-
};
18-
use xcm::{latest::prelude::*, VersionedXcm, MAX_XCM_DECODE_DEPTH};
17+
use xcm::latest::prelude::*;
1918
use xcm_executor::{
2019
traits::{Convert, WeightTrader},
2120
XcmExecutor,
@@ -448,7 +447,7 @@ fn receive_teleported_asset_works() {
448447
id: Concrete(MultiLocation { parents: 1, interior: Here }),
449448
fun: Fungible(10000000000000),
450449
},
451-
weight_limit: Limited(Weight::from_parts(303531000, 65536)),
450+
weight_limit: Limited(Weight::from_parts(1303531000, 65536)),
452451
},
453452
DepositAsset {
454453
assets: Wild(AllCounted(1)),
@@ -473,31 +472,3 @@ fn receive_teleported_asset_works() {
473472
assert_eq!(outcome.ensure_complete(), Ok(()));
474473
})
475474
}
476-
477-
#[test]
478-
fn plain_receive_teleported_asset_works() {
479-
ExtBuilder::<Runtime>::default()
480-
.with_collators(vec![AccountId::from(ALICE)])
481-
.with_session_keys(vec![(
482-
AccountId::from(ALICE),
483-
AccountId::from(ALICE),
484-
SessionKeys { aura: AuraId::from(sp_core::sr25519::Public::from_raw(ALICE)) },
485-
)])
486-
.build()
487-
.execute_with(|| {
488-
let data = hex_literal::hex!("02100204000100000b00a0724e18090a13000100000b00a0724e180901e20f5e480d010004000101001299557001f55815d3fcb53c74463acb0cf6d14d4639b340982c60877f384609").to_vec();
489-
let message_id = sp_io::hashing::blake2_256(&data);
490-
491-
let maybe_msg = VersionedXcm::<RuntimeCall>::decode_all_with_depth_limit(
492-
MAX_XCM_DECODE_DEPTH,
493-
&mut data.as_ref(),
494-
)
495-
.map(xcm::v3::Xcm::<RuntimeCall>::try_from).expect("failed").expect("failed");
496-
497-
let weight_limit = ReservedDmpWeight::get();
498-
499-
let outcome =
500-
XcmExecutor::<XcmConfig>::execute_xcm(Parent, maybe_msg, message_id, weight_limit);
501-
assert_eq!(outcome.ensure_complete(), Ok(()));
502-
})
503-
}

parachains/runtimes/bridge-hubs/bridge-hub-kusama/src/weights/xcm/mod.rs

+6-14
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
mod pallet_xcm_benchmarks_fungible;
1818
mod pallet_xcm_benchmarks_generic;
1919

20-
use crate::{xcm_config::MaxAssetsIntoHolding, Runtime};
20+
use crate::Runtime;
2121
use frame_support::weights::Weight;
2222
use pallet_xcm_benchmarks_fungible::WeightInfo as XcmFungibleWeight;
2323
use pallet_xcm_benchmarks_generic::WeightInfo as XcmGeneric;
@@ -35,18 +35,7 @@ impl WeighMultiAssets for MultiAssetFilter {
3535
match self {
3636
Self::Definite(assets) =>
3737
weight.saturating_mul(assets.inner().into_iter().count() as u64),
38-
Self::Wild(asset) => match asset {
39-
All => weight.saturating_mul(MAX_ASSETS),
40-
AllOf { fun, .. } => match fun {
41-
WildFungibility::Fungible => weight,
42-
// Magic number 2 has to do with the fact that we could have up to 2 times
43-
// MaxAssetsIntoHolding in the worst-case scenario.
44-
WildFungibility::NonFungible =>
45-
weight.saturating_mul((MaxAssetsIntoHolding::get() * 2) as u64),
46-
},
47-
AllCounted(count) => weight.saturating_mul(MAX_ASSETS.min(*count as u64)),
48-
AllOfCounted { count, .. } => weight.saturating_mul(MAX_ASSETS.min(*count as u64)),
49-
},
38+
Self::Wild(_) => weight.saturating_mul(MAX_ASSETS as u64),
5039
}
5140
}
5241
}
@@ -149,7 +138,10 @@ impl<Call> XcmWeightInfo<Call> for BridgeHubKusamaXcmWeight<Call> {
149138
_dest: &MultiLocation,
150139
_xcm: &Xcm<()>,
151140
) -> Weight {
152-
assets.weigh_multi_assets(XcmFungibleWeight::<Runtime>::initiate_teleport())
141+
// Hardcoded till the XCM pallet is fixed
142+
let hardcoded_weight = Weight::from_parts(200_000_000 as u64, 0);
143+
let weight = assets.weigh_multi_assets(XcmFungibleWeight::<Runtime>::initiate_teleport());
144+
hardcoded_weight.min(weight)
153145
}
154146
fn report_holding(_response_info: &QueryResponseInfo, _assets: &MultiAssetFilter) -> Weight {
155147
XcmGeneric::<Runtime>::report_holding()

parachains/runtimes/bridge-hubs/bridge-hub-polkadot/src/weights/xcm/mod.rs

+2-13
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
mod pallet_xcm_benchmarks_fungible;
1818
mod pallet_xcm_benchmarks_generic;
1919

20-
use crate::{xcm_config::MaxAssetsIntoHolding, Runtime};
20+
use crate::Runtime;
2121
use frame_support::weights::Weight;
2222
use pallet_xcm_benchmarks_fungible::WeightInfo as XcmFungibleWeight;
2323
use pallet_xcm_benchmarks_generic::WeightInfo as XcmGeneric;
@@ -35,18 +35,7 @@ impl WeighMultiAssets for MultiAssetFilter {
3535
match self {
3636
Self::Definite(assets) =>
3737
weight.saturating_mul(assets.inner().into_iter().count() as u64),
38-
Self::Wild(asset) => match asset {
39-
All => weight.saturating_mul(MAX_ASSETS),
40-
AllOf { fun, .. } => match fun {
41-
WildFungibility::Fungible => weight,
42-
// Magic number 2 has to do with the fact that we could have up to 2 times
43-
// MaxAssetsIntoHolding in the worst-case scenario.
44-
WildFungibility::NonFungible =>
45-
weight.saturating_mul((MaxAssetsIntoHolding::get() * 2) as u64),
46-
},
47-
AllCounted(count) => weight.saturating_mul(MAX_ASSETS.min(*count as u64)),
48-
AllOfCounted { count, .. } => weight.saturating_mul(MAX_ASSETS.min(*count as u64)),
49-
},
38+
Self::Wild(_) => weight.saturating_mul(MAX_ASSETS as u64),
5039
}
5140
}
5241
}

parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/weights/xcm/mod.rs

+6-14
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
mod pallet_xcm_benchmarks_fungible;
1818
mod pallet_xcm_benchmarks_generic;
1919

20-
use crate::{xcm_config::MaxAssetsIntoHolding, Runtime};
20+
use crate::Runtime;
2121
use frame_support::weights::Weight;
2222
use pallet_xcm_benchmarks_fungible::WeightInfo as XcmFungibleWeight;
2323
use pallet_xcm_benchmarks_generic::WeightInfo as XcmGeneric;
@@ -35,18 +35,7 @@ impl WeighMultiAssets for MultiAssetFilter {
3535
match self {
3636
Self::Definite(assets) =>
3737
weight.saturating_mul(assets.inner().into_iter().count() as u64),
38-
Self::Wild(asset) => match asset {
39-
All => weight.saturating_mul(MAX_ASSETS),
40-
AllOf { fun, .. } => match fun {
41-
WildFungibility::Fungible => weight,
42-
// Magic number 2 has to do with the fact that we could have up to 2 times
43-
// MaxAssetsIntoHolding in the worst-case scenario.
44-
WildFungibility::NonFungible =>
45-
weight.saturating_mul((MaxAssetsIntoHolding::get() * 2) as u64),
46-
},
47-
AllCounted(count) => weight.saturating_mul(MAX_ASSETS.min(*count as u64)),
48-
AllOfCounted { count, .. } => weight.saturating_mul(MAX_ASSETS.min(*count as u64)),
49-
},
38+
Self::Wild(_) => weight.saturating_mul(MAX_ASSETS as u64),
5039
}
5140
}
5241
}
@@ -149,7 +138,10 @@ impl<Call> XcmWeightInfo<Call> for BridgeHubRococoXcmWeight<Call> {
149138
_dest: &MultiLocation,
150139
_xcm: &Xcm<()>,
151140
) -> Weight {
152-
assets.weigh_multi_assets(XcmFungibleWeight::<Runtime>::initiate_teleport())
141+
// Hardcoded till the XCM pallet is fixed
142+
let hardcoded_weight = Weight::from_parts(200_000_000 as u64, 0);
143+
let weight = assets.weigh_multi_assets(XcmFungibleWeight::<Runtime>::initiate_teleport());
144+
hardcoded_weight.min(weight)
153145
}
154146
fn report_holding(_response_info: &QueryResponseInfo, _assets: &MultiAssetFilter) -> Weight {
155147
XcmGeneric::<Runtime>::report_holding()

0 commit comments

Comments
 (0)