diff --git a/runtime/kusama/src/lib.rs b/runtime/kusama/src/lib.rs index a33e35f591d9..dcc70022d836 100644 --- a/runtime/kusama/src/lib.rs +++ b/runtime/kusama/src/lib.rs @@ -49,9 +49,7 @@ use authority_discovery_primitives::AuthorityId as AuthorityDiscoveryId; use beefy_primitives::crypto::AuthorityId as BeefyId; use frame_support::{ construct_runtime, parameter_types, - traits::{ - Contains, Everything, InstanceFilter, KeyOwnerProofSystem, LockIdentifier, Nothing, - }, + traits::{Contains, Everything, InstanceFilter, KeyOwnerProofSystem, LockIdentifier, Nothing}, weights::Weight, PalletId, RuntimeDebug, }; diff --git a/runtime/westend/src/weights/xcm/pallet_xcm_benchmarks_fungible.rs b/runtime/westend/src/weights/xcm/pallet_xcm_benchmarks_fungible.rs index 869c1bca408f..0ae066a1074f 100644 --- a/runtime/westend/src/weights/xcm/pallet_xcm_benchmarks_fungible.rs +++ b/runtime/westend/src/weights/xcm/pallet_xcm_benchmarks_fungible.rs @@ -66,9 +66,11 @@ impl WeightInfo { .saturating_add(T::DbWeight::get().reads(4 as Weight)) .saturating_add(T::DbWeight::get().writes(4 as Weight)) } - // Storage: Benchmark Override (r:0 w:0) + // Storage: System Account (r:1 w:1) pub(crate) fn receive_teleported_asset() -> Weight { - (2_000_000_000_000 as Weight) + (38_670_000 as Weight) + .saturating_add(T::DbWeight::get().reads(1 as Weight)) + .saturating_add(T::DbWeight::get().writes(1 as Weight)) } // Storage: System Account (r:1 w:1) pub(crate) fn deposit_asset() -> Weight { diff --git a/xcm/pallet-xcm-benchmarks/src/fungible/benchmarking.rs b/xcm/pallet-xcm-benchmarks/src/fungible/benchmarking.rs index 3a71d771c11d..9e2083704254 100644 --- a/xcm/pallet-xcm-benchmarks/src/fungible/benchmarking.rs +++ b/xcm/pallet-xcm-benchmarks/src/fungible/benchmarking.rs @@ -17,8 +17,11 @@ use super::*; use crate::{account_and_location, new_executor, worst_case_holding, AssetTransactorOf, XcmCallOf}; use frame_benchmarking::{benchmarks_instance_pallet, BenchmarkError, BenchmarkResult}; -use frame_support::{pallet_prelude::Get, traits::fungible::Inspect}; -use sp_runtime::traits::Zero; +use frame_support::{ + pallet_prelude::Get, + traits::fungible::{Inspect, Mutate}, +}; +use sp_runtime::traits::{Bounded, Zero}; use sp_std::{convert::TryInto, prelude::*, vec}; use xcm::latest::prelude::*; use xcm_executor::traits::{Convert, TransactAsset}; @@ -106,11 +109,19 @@ benchmarks_instance_pallet! { receive_teleported_asset { // If there is no trusted teleporter, then we skip this benchmark. - let (trusted_teleporter, teleportable_asset) = T::TrustedTeleporter::get().ok_or( - BenchmarkError::Override( - BenchmarkResult::from_weight(T::BlockWeights::get().max_block) - ) - )?; + let (trusted_teleporter, teleportable_asset) = T::TrustedTeleporter::get() + .ok_or(BenchmarkError::Skip)?; + + if let Some(checked_account) = T::CheckedAccount::get() { + T::TransactAsset::mint_into( + &checked_account, + < + T::TransactAsset + as + Inspect + >::Balance::max_value() / 2u32.into(), + )?; + } let assets: MultiAssets = vec![ teleportable_asset ].into(); diff --git a/xcm/pallet-xcm-benchmarks/src/fungible/mock.rs b/xcm/pallet-xcm-benchmarks/src/fungible/mock.rs index 8666dc6caa4d..fb5f3059561b 100644 --- a/xcm/pallet-xcm-benchmarks/src/fungible/mock.rs +++ b/xcm/pallet-xcm-benchmarks/src/fungible/mock.rs @@ -131,7 +131,7 @@ impl xcm_executor::Config for XcmConfig { type AssetTransactor = AssetTransactor; type OriginConverter = (); type IsReserve = (); - type IsTeleporter = (); + type IsTeleporter = TrustedTeleporters; type LocationInverter = xcm_builder::LocationInverter; type Barrier = AllowUnpaidExecutionFrom; type Weigher = xcm_builder::FixedWeightBounds; @@ -153,12 +153,17 @@ impl crate::Config for Test { } } +pub type TrustedTeleporters = (xcm_builder::Case,); + parameter_types! { pub const CheckedAccount: Option = Some(100); + pub const ChildTeleporter: MultiLocation = Parachain(1000).into(); pub const TrustedTeleporter: Option<(MultiLocation, MultiAsset)> = Some(( - X1(OnlyChild).into(), + ChildTeleporter::get(), MultiAsset { id: Concrete(Here.into()), fun: Fungible(100) }, )); + pub const TeleConcreteFung: (MultiAssetFilter, MultiLocation) = + (Wild(AllOf { fun: WildFungible, id: Concrete(Here.into()) }), ChildTeleporter::get()); } impl xcm_balances_benchmark::Config for Test {