Companion for Weight v1.5 (#5943)

* fix to latest substrate pr

* update weights

* cargo build -p polkadot-runtime-parachains

* fix xcm-builder

* fix import

* fix a bunch

* fix a bunch of weight stuff

* kusama compile

* unused

* builds

* maybe fix

* cargo test -p polkadot-runtime-parachains

* xcm simulator example

* fix tests

* xcm sim fuzz

* fix runtime tests

* remove unused

* fix integration tests

* scalar div

* update lockfile for {"substrate"}

Co-authored-by: parity-processbot <>
This commit is contained in:
Shawn Tabrizi
2022-08-31 12:59:39 +01:00
committed by GitHub
parent 138aae0a22
commit 28e94d97dd
231 changed files with 4577 additions and 4514 deletions
+65 -57
View File
@@ -4,7 +4,10 @@ mod pallet_xcm_benchmarks_generic;
use crate::Runtime;
use frame_support::weights::Weight;
use sp_std::prelude::*;
use xcm::{latest::prelude::*, DoubleEncoded};
use xcm::{
latest::{prelude::*, Weight as XCMWeight},
DoubleEncoded,
};
use pallet_xcm_benchmarks_fungible::WeightInfo as XcmBalancesWeight;
use pallet_xcm_benchmarks_generic::WeightInfo as XcmGeneric;
@@ -28,15 +31,15 @@ impl From<&MultiAsset> for AssetTypes {
}
trait WeighMultiAssets {
fn weigh_multi_assets(&self, balances_weight: Weight) -> Weight;
fn weigh_multi_assets(&self, balances_weight: Weight) -> XCMWeight;
}
// Westend only knows about one asset, the balances pallet.
const MAX_ASSETS: u32 = 1;
impl WeighMultiAssets for MultiAssetFilter {
fn weigh_multi_assets(&self, balances_weight: Weight) -> Weight {
match self {
fn weigh_multi_assets(&self, balances_weight: Weight) -> XCMWeight {
let weight = match self {
Self::Definite(assets) => assets
.inner()
.into_iter()
@@ -45,91 +48,96 @@ impl WeighMultiAssets for MultiAssetFilter {
AssetTypes::Balances => balances_weight,
AssetTypes::Unknown => Weight::MAX,
})
.fold(0, |acc, x| acc.saturating_add(x)),
Self::Wild(_) => (MAX_ASSETS as Weight).saturating_mul(balances_weight),
}
.fold(Weight::new(), |acc, x| acc.saturating_add(x)),
Self::Wild(_) => balances_weight.scalar_saturating_mul(MAX_ASSETS as u64),
};
weight.ref_time()
}
}
impl WeighMultiAssets for MultiAssets {
fn weigh_multi_assets(&self, balances_weight: Weight) -> Weight {
self.inner()
fn weigh_multi_assets(&self, balances_weight: Weight) -> XCMWeight {
let weight = self
.inner()
.into_iter()
.map(|m| <AssetTypes as From<&MultiAsset>>::from(m))
.map(|t| match t {
AssetTypes::Balances => balances_weight,
AssetTypes::Unknown => Weight::MAX,
})
.fold(0, |acc, x| acc.saturating_add(x))
.fold(Weight::new(), |acc, x| acc.saturating_add(x));
weight.ref_time()
}
}
pub struct WestendXcmWeight<Call>(core::marker::PhantomData<Call>);
impl<Call> XcmWeightInfo<Call> for WestendXcmWeight<Call> {
fn withdraw_asset(assets: &MultiAssets) -> Weight {
fn withdraw_asset(assets: &MultiAssets) -> XCMWeight {
assets.weigh_multi_assets(XcmBalancesWeight::<Runtime>::withdraw_asset())
}
fn reserve_asset_deposited(assets: &MultiAssets) -> Weight {
fn reserve_asset_deposited(assets: &MultiAssets) -> XCMWeight {
assets.weigh_multi_assets(XcmBalancesWeight::<Runtime>::reserve_asset_deposited())
}
fn receive_teleported_asset(assets: &MultiAssets) -> Weight {
fn receive_teleported_asset(assets: &MultiAssets) -> XCMWeight {
assets.weigh_multi_assets(XcmBalancesWeight::<Runtime>::receive_teleported_asset())
}
fn query_response(_query_id: &u64, _response: &Response, _max_weight: &u64) -> Weight {
XcmGeneric::<Runtime>::query_response()
fn query_response(_query_id: &u64, _response: &Response, _max_weight: &u64) -> XCMWeight {
XcmGeneric::<Runtime>::query_response().ref_time()
}
fn transfer_asset(assets: &MultiAssets, _dest: &MultiLocation) -> Weight {
fn transfer_asset(assets: &MultiAssets, _dest: &MultiLocation) -> XCMWeight {
assets.weigh_multi_assets(XcmBalancesWeight::<Runtime>::transfer_asset())
}
fn transfer_reserve_asset(
assets: &MultiAssets,
_dest: &MultiLocation,
_xcm: &Xcm<()>,
) -> Weight {
) -> XCMWeight {
assets.weigh_multi_assets(XcmBalancesWeight::<Runtime>::transfer_reserve_asset())
}
fn transact(
_origin_type: &OriginKind,
_require_weight_at_most: &u64,
_call: &DoubleEncoded<Call>,
) -> Weight {
XcmGeneric::<Runtime>::transact()
) -> XCMWeight {
XcmGeneric::<Runtime>::transact().ref_time()
}
fn hrmp_new_channel_open_request(
_sender: &u32,
_max_message_size: &u32,
_max_capacity: &u32,
) -> Weight {
) -> XCMWeight {
// XCM Executor does not currently support HRMP channel operations
Weight::MAX
Weight::MAX.ref_time()
}
fn hrmp_channel_accepted(_recipient: &u32) -> Weight {
fn hrmp_channel_accepted(_recipient: &u32) -> XCMWeight {
// XCM Executor does not currently support HRMP channel operations
Weight::MAX
Weight::MAX.ref_time()
}
fn hrmp_channel_closing(_initiator: &u32, _sender: &u32, _recipient: &u32) -> Weight {
fn hrmp_channel_closing(_initiator: &u32, _sender: &u32, _recipient: &u32) -> XCMWeight {
// XCM Executor does not currently support HRMP channel operations
Weight::MAX
Weight::MAX.ref_time()
}
fn clear_origin() -> Weight {
XcmGeneric::<Runtime>::clear_origin()
fn clear_origin() -> XCMWeight {
XcmGeneric::<Runtime>::clear_origin().ref_time()
}
fn descend_origin(_who: &InteriorMultiLocation) -> Weight {
XcmGeneric::<Runtime>::descend_origin()
fn descend_origin(_who: &InteriorMultiLocation) -> XCMWeight {
XcmGeneric::<Runtime>::descend_origin().ref_time()
}
fn report_error(
_query_id: &QueryId,
_dest: &MultiLocation,
_max_response_weight: &u64,
) -> Weight {
XcmGeneric::<Runtime>::report_error()
) -> XCMWeight {
XcmGeneric::<Runtime>::report_error().ref_time()
}
fn deposit_asset(
assets: &MultiAssetFilter,
_max_assets: &u32, // TODO use max assets?
_dest: &MultiLocation,
) -> Weight {
) -> XCMWeight {
assets.weigh_multi_assets(XcmBalancesWeight::<Runtime>::deposit_asset())
}
fn deposit_reserve_asset(
@@ -137,24 +145,24 @@ impl<Call> XcmWeightInfo<Call> for WestendXcmWeight<Call> {
_max_assets: &u32, // TODO use max assets?
_dest: &MultiLocation,
_xcm: &Xcm<()>,
) -> Weight {
) -> XCMWeight {
assets.weigh_multi_assets(XcmBalancesWeight::<Runtime>::deposit_reserve_asset())
}
fn exchange_asset(_give: &MultiAssetFilter, _receive: &MultiAssets) -> Weight {
Weight::MAX // todo fix
fn exchange_asset(_give: &MultiAssetFilter, _receive: &MultiAssets) -> XCMWeight {
Weight::MAX.ref_time() // todo fix
}
fn initiate_reserve_withdraw(
assets: &MultiAssetFilter,
_reserve: &MultiLocation,
_xcm: &Xcm<()>,
) -> Weight {
) -> XCMWeight {
assets.weigh_multi_assets(XcmGeneric::<Runtime>::initiate_reserve_withdraw())
}
fn initiate_teleport(
assets: &MultiAssetFilter,
_dest: &MultiLocation,
_xcm: &Xcm<()>,
) -> Weight {
) -> XCMWeight {
assets.weigh_multi_assets(XcmBalancesWeight::<Runtime>::initiate_teleport())
}
fn query_holding(
@@ -162,34 +170,34 @@ impl<Call> XcmWeightInfo<Call> for WestendXcmWeight<Call> {
_dest: &MultiLocation,
_assets: &MultiAssetFilter,
_max_response_weight: &u64,
) -> Weight {
XcmGeneric::<Runtime>::query_holding()
) -> XCMWeight {
XcmGeneric::<Runtime>::query_holding().ref_time()
}
fn buy_execution(_fees: &MultiAsset, _weight_limit: &WeightLimit) -> Weight {
XcmGeneric::<Runtime>::buy_execution()
fn buy_execution(_fees: &MultiAsset, _weight_limit: &WeightLimit) -> XCMWeight {
XcmGeneric::<Runtime>::buy_execution().ref_time()
}
fn refund_surplus() -> Weight {
XcmGeneric::<Runtime>::refund_surplus()
fn refund_surplus() -> XCMWeight {
XcmGeneric::<Runtime>::refund_surplus().ref_time()
}
fn set_error_handler(_xcm: &Xcm<Call>) -> Weight {
XcmGeneric::<Runtime>::set_error_handler()
fn set_error_handler(_xcm: &Xcm<Call>) -> XCMWeight {
XcmGeneric::<Runtime>::set_error_handler().ref_time()
}
fn set_appendix(_xcm: &Xcm<Call>) -> Weight {
XcmGeneric::<Runtime>::set_appendix()
fn set_appendix(_xcm: &Xcm<Call>) -> XCMWeight {
XcmGeneric::<Runtime>::set_appendix().ref_time()
}
fn clear_error() -> Weight {
XcmGeneric::<Runtime>::clear_error()
fn clear_error() -> XCMWeight {
XcmGeneric::<Runtime>::clear_error().ref_time()
}
fn claim_asset(_assets: &MultiAssets, _ticket: &MultiLocation) -> Weight {
XcmGeneric::<Runtime>::claim_asset()
fn claim_asset(_assets: &MultiAssets, _ticket: &MultiLocation) -> XCMWeight {
XcmGeneric::<Runtime>::claim_asset().ref_time()
}
fn trap(_code: &u64) -> Weight {
XcmGeneric::<Runtime>::trap()
fn trap(_code: &u64) -> XCMWeight {
XcmGeneric::<Runtime>::trap().ref_time()
}
fn subscribe_version(_query_id: &QueryId, _max_response_weight: &u64) -> Weight {
XcmGeneric::<Runtime>::subscribe_version()
fn subscribe_version(_query_id: &QueryId, _max_response_weight: &u64) -> XCMWeight {
XcmGeneric::<Runtime>::subscribe_version().ref_time()
}
fn unsubscribe_version() -> Weight {
XcmGeneric::<Runtime>::unsubscribe_version()
fn unsubscribe_version() -> XCMWeight {
XcmGeneric::<Runtime>::unsubscribe_version().ref_time()
}
}