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()
}
}
@@ -39,7 +39,7 @@
#![allow(unused_parens)]
#![allow(unused_imports)]
use frame_support::{traits::Get, weights::Weight};
use frame_support::{traits::Get, weights::{RefTimeWeight, Weight}};
use sp_std::marker::PhantomData;
/// Weights for `pallet_xcm_benchmarks::fungible`.
@@ -47,15 +47,15 @@ pub struct WeightInfo<T>(PhantomData<T>);
impl<T: frame_system::Config> WeightInfo<T> {
// Storage: System Account (r:1 w:1)
pub(crate) fn withdraw_asset() -> Weight {
(20_308_000 as Weight)
.saturating_add(T::DbWeight::get().reads(1 as Weight))
.saturating_add(T::DbWeight::get().writes(1 as Weight))
Weight::from_ref_time(20_308_000 as RefTimeWeight)
.saturating_add(T::DbWeight::get().reads(1 as RefTimeWeight))
.saturating_add(T::DbWeight::get().writes(1 as RefTimeWeight))
}
// Storage: System Account (r:2 w:2)
pub(crate) fn transfer_asset() -> Weight {
(32_193_000 as Weight)
.saturating_add(T::DbWeight::get().reads(2 as Weight))
.saturating_add(T::DbWeight::get().writes(2 as Weight))
Weight::from_ref_time(32_193_000 as RefTimeWeight)
.saturating_add(T::DbWeight::get().reads(2 as RefTimeWeight))
.saturating_add(T::DbWeight::get().writes(2 as RefTimeWeight))
}
// Storage: System Account (r:2 w:2)
// Storage: XcmPallet SupportedVersion (r:1 w:0)
@@ -64,25 +64,25 @@ impl<T: frame_system::Config> WeightInfo<T> {
// Storage: Dmp DownwardMessageQueueHeads (r:1 w:1)
// Storage: Dmp DownwardMessageQueues (r:1 w:1)
pub(crate) fn transfer_reserve_asset() -> Weight {
(50_731_000 as Weight)
.saturating_add(T::DbWeight::get().reads(7 as Weight))
.saturating_add(T::DbWeight::get().writes(5 as Weight))
Weight::from_ref_time(50_731_000 as RefTimeWeight)
.saturating_add(T::DbWeight::get().reads(7 as RefTimeWeight))
.saturating_add(T::DbWeight::get().writes(5 as RefTimeWeight))
}
// Storage: Benchmark Override (r:0 w:0)
pub(crate) fn reserve_asset_deposited() -> Weight {
(2_000_000_000_000 as Weight)
Weight::from_ref_time(2_000_000_000_000 as RefTimeWeight)
}
// Storage: System Account (r:1 w:1)
pub(crate) fn receive_teleported_asset() -> Weight {
(19_622_000 as Weight)
.saturating_add(T::DbWeight::get().reads(1 as Weight))
.saturating_add(T::DbWeight::get().writes(1 as Weight))
Weight::from_ref_time(19_622_000 as RefTimeWeight)
.saturating_add(T::DbWeight::get().reads(1 as RefTimeWeight))
.saturating_add(T::DbWeight::get().writes(1 as RefTimeWeight))
}
// Storage: System Account (r:1 w:1)
pub(crate) fn deposit_asset() -> Weight {
(22_433_000 as Weight)
.saturating_add(T::DbWeight::get().reads(1 as Weight))
.saturating_add(T::DbWeight::get().writes(1 as Weight))
Weight::from_ref_time(22_433_000 as RefTimeWeight)
.saturating_add(T::DbWeight::get().reads(1 as RefTimeWeight))
.saturating_add(T::DbWeight::get().writes(1 as RefTimeWeight))
}
// Storage: System Account (r:1 w:1)
// Storage: XcmPallet SupportedVersion (r:1 w:0)
@@ -91,9 +91,9 @@ impl<T: frame_system::Config> WeightInfo<T> {
// Storage: Dmp DownwardMessageQueueHeads (r:1 w:1)
// Storage: Dmp DownwardMessageQueues (r:1 w:1)
pub(crate) fn deposit_reserve_asset() -> Weight {
(41_765_000 as Weight)
.saturating_add(T::DbWeight::get().reads(6 as Weight))
.saturating_add(T::DbWeight::get().writes(4 as Weight))
Weight::from_ref_time(41_765_000 as RefTimeWeight)
.saturating_add(T::DbWeight::get().reads(6 as RefTimeWeight))
.saturating_add(T::DbWeight::get().writes(4 as RefTimeWeight))
}
// Storage: System Account (r:1 w:1)
// Storage: XcmPallet SupportedVersion (r:1 w:0)
@@ -102,8 +102,8 @@ impl<T: frame_system::Config> WeightInfo<T> {
// Storage: Dmp DownwardMessageQueueHeads (r:1 w:1)
// Storage: Dmp DownwardMessageQueues (r:1 w:1)
pub(crate) fn initiate_teleport() -> Weight {
(41_204_000 as Weight)
.saturating_add(T::DbWeight::get().reads(6 as Weight))
.saturating_add(T::DbWeight::get().writes(4 as Weight))
Weight::from_ref_time(41_204_000 as RefTimeWeight)
.saturating_add(T::DbWeight::get().reads(6 as RefTimeWeight))
.saturating_add(T::DbWeight::get().writes(4 as RefTimeWeight))
}
}
@@ -39,7 +39,7 @@
#![allow(unused_parens)]
#![allow(unused_imports)]
use frame_support::{traits::Get, weights::Weight};
use frame_support::{traits::Get, weights::{RefTimeWeight, Weight}};
use sp_std::marker::PhantomData;
/// Weights for `pallet_xcm_benchmarks::generic`.
@@ -51,38 +51,38 @@ impl<T: frame_system::Config> WeightInfo<T> {
// Storage: Dmp DownwardMessageQueueHeads (r:1 w:1)
// Storage: Dmp DownwardMessageQueues (r:1 w:1)
pub(crate) fn query_holding() -> Weight {
(39_278_000 as Weight)
.saturating_add(T::DbWeight::get().reads(5 as Weight))
.saturating_add(T::DbWeight::get().writes(3 as Weight))
Weight::from_ref_time(39_278_000 as RefTimeWeight)
.saturating_add(T::DbWeight::get().reads(5 as RefTimeWeight))
.saturating_add(T::DbWeight::get().writes(3 as RefTimeWeight))
}
pub(crate) fn buy_execution() -> Weight {
(5_922_000 as Weight)
Weight::from_ref_time(5_922_000 as RefTimeWeight)
}
// Storage: XcmPallet Queries (r:1 w:0)
pub(crate) fn query_response() -> Weight {
(20_625_000 as Weight)
.saturating_add(T::DbWeight::get().reads(1 as Weight))
Weight::from_ref_time(20_625_000 as RefTimeWeight)
.saturating_add(T::DbWeight::get().reads(1 as RefTimeWeight))
}
pub(crate) fn transact() -> Weight {
(22_198_000 as Weight)
Weight::from_ref_time(22_198_000 as RefTimeWeight)
}
pub(crate) fn refund_surplus() -> Weight {
(6_122_000 as Weight)
Weight::from_ref_time(6_122_000 as RefTimeWeight)
}
pub(crate) fn set_error_handler() -> Weight {
(5_758_000 as Weight)
Weight::from_ref_time(5_758_000 as RefTimeWeight)
}
pub(crate) fn set_appendix() -> Weight {
(5_764_000 as Weight)
Weight::from_ref_time(5_764_000 as RefTimeWeight)
}
pub(crate) fn clear_error() -> Weight {
(5_679_000 as Weight)
Weight::from_ref_time(5_679_000 as RefTimeWeight)
}
pub(crate) fn descend_origin() -> Weight {
(7_206_000 as Weight)
Weight::from_ref_time(7_206_000 as RefTimeWeight)
}
pub(crate) fn clear_origin() -> Weight {
(5_738_000 as Weight)
Weight::from_ref_time(5_738_000 as RefTimeWeight)
}
// Storage: XcmPallet SupportedVersion (r:1 w:0)
// Storage: XcmPallet VersionDiscoveryQueue (r:1 w:1)
@@ -90,18 +90,18 @@ impl<T: frame_system::Config> WeightInfo<T> {
// Storage: Dmp DownwardMessageQueueHeads (r:1 w:1)
// Storage: Dmp DownwardMessageQueues (r:1 w:1)
pub(crate) fn report_error() -> Weight {
(31_512_000 as Weight)
.saturating_add(T::DbWeight::get().reads(5 as Weight))
.saturating_add(T::DbWeight::get().writes(3 as Weight))
Weight::from_ref_time(31_512_000 as RefTimeWeight)
.saturating_add(T::DbWeight::get().reads(5 as RefTimeWeight))
.saturating_add(T::DbWeight::get().writes(3 as RefTimeWeight))
}
// Storage: XcmPallet AssetTraps (r:1 w:1)
pub(crate) fn claim_asset() -> Weight {
(13_594_000 as Weight)
.saturating_add(T::DbWeight::get().reads(1 as Weight))
.saturating_add(T::DbWeight::get().writes(1 as Weight))
Weight::from_ref_time(13_594_000 as RefTimeWeight)
.saturating_add(T::DbWeight::get().reads(1 as RefTimeWeight))
.saturating_add(T::DbWeight::get().writes(1 as RefTimeWeight))
}
pub(crate) fn trap() -> Weight {
(5_745_000 as Weight)
Weight::from_ref_time(5_745_000 as RefTimeWeight)
}
// Storage: XcmPallet VersionNotifyTargets (r:1 w:1)
// Storage: XcmPallet SupportedVersion (r:1 w:0)
@@ -110,14 +110,14 @@ impl<T: frame_system::Config> WeightInfo<T> {
// Storage: Dmp DownwardMessageQueueHeads (r:1 w:1)
// Storage: Dmp DownwardMessageQueues (r:1 w:1)
pub(crate) fn subscribe_version() -> Weight {
(38_138_000 as Weight)
.saturating_add(T::DbWeight::get().reads(6 as Weight))
.saturating_add(T::DbWeight::get().writes(4 as Weight))
Weight::from_ref_time(38_138_000 as RefTimeWeight)
.saturating_add(T::DbWeight::get().reads(6 as RefTimeWeight))
.saturating_add(T::DbWeight::get().writes(4 as RefTimeWeight))
}
// Storage: XcmPallet VersionNotifyTargets (r:0 w:1)
pub(crate) fn unsubscribe_version() -> Weight {
(9_127_000 as Weight)
.saturating_add(T::DbWeight::get().writes(1 as Weight))
Weight::from_ref_time(9_127_000 as RefTimeWeight)
.saturating_add(T::DbWeight::get().writes(1 as RefTimeWeight))
}
// Storage: XcmPallet SupportedVersion (r:1 w:0)
// Storage: XcmPallet VersionDiscoveryQueue (r:1 w:1)
@@ -125,8 +125,8 @@ impl<T: frame_system::Config> WeightInfo<T> {
// Storage: Dmp DownwardMessageQueueHeads (r:1 w:1)
// Storage: Dmp DownwardMessageQueues (r:1 w:1)
pub(crate) fn initiate_reserve_withdraw() -> Weight {
(41_443_000 as Weight)
.saturating_add(T::DbWeight::get().reads(5 as Weight))
.saturating_add(T::DbWeight::get().writes(3 as Weight))
Weight::from_ref_time(41_443_000 as RefTimeWeight)
.saturating_add(T::DbWeight::get().reads(5 as RefTimeWeight))
.saturating_add(T::DbWeight::get().writes(3 as RefTimeWeight))
}
}