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

Commit c35a2e3

Browse files
authored
Fix XCM Weights on Westend (#4066)
* found issue * fix up * remove printlns
1 parent 53cd9a6 commit c35a2e3

2 files changed

Lines changed: 22 additions & 2 deletions

File tree

runtime/westend/src/tests.rs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,3 +49,21 @@ fn call_size() {
4949
If the limit is too strong, maybe consider increase the limit to 300.",
5050
);
5151
}
52+
53+
#[test]
54+
fn sanity_check_teleport_assets_weight() {
55+
// This test sanity checks that at least 50 teleports can exist in a block.
56+
// Usually when XCM runs into an issue, it will return a weight of `Weight::MAX`,
57+
// so this test will certainly ensure that this problem does not occur.
58+
use frame_support::dispatch::GetDispatchInfo;
59+
let weight = pallet_xcm::Call::<Runtime>::teleport_assets {
60+
dest: Box::new(xcm::VersionedMultiLocation::V1(MultiLocation::here())),
61+
beneficiary: Box::new(xcm::VersionedMultiLocation::V1(MultiLocation::here())),
62+
assets: Box::new((Concrete(MultiLocation::here()), Fungible(200_000)).into()),
63+
fee_asset_item: 0,
64+
}
65+
.get_dispatch_info()
66+
.weight;
67+
68+
assert!(weight * 50 < BlockWeights::get().max_block);
69+
}

runtime/westend/src/weights/xcm/mod.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,9 @@ trait WeighMultiAssets {
3131
fn weigh_multi_assets(&self, balances_weight: Weight) -> Weight;
3232
}
3333

34-
// TODO wild case
34+
// Westend only knows about one asset, the balances pallet.
35+
const MAX_ASSETS: u32 = 1;
36+
3537
impl WeighMultiAssets for MultiAssetFilter {
3638
fn weigh_multi_assets(&self, balances_weight: Weight) -> Weight {
3739
match self {
@@ -44,7 +46,7 @@ impl WeighMultiAssets for MultiAssetFilter {
4446
AssetTypes::Unknown => Weight::MAX,
4547
})
4648
.fold(0, |acc, x| acc.saturating_add(x)),
47-
_ => Weight::MAX,
49+
Self::Wild(_) => (MAX_ASSETS as Weight).saturating_mul(balances_weight),
4850
}
4951
}
5052
}

0 commit comments

Comments
 (0)