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

Fix XCM Teleport Benchmark #4146

Merged
merged 6 commits into from
Oct 27, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion node/network/availability-recovery/src/futures_undead.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
//! futures will still get polled, but will not count towards length. So length will only count
//! futures, which are still considered live.
//!
//! Usecase: If futures take longer than we would like them too, we may be able to request the data
//! Use case: If futures take longer than we would like them too, we may be able to request the data
//! from somewhere else as well. We don't really want to cancel the old future, because maybe it
//! was almost done, thus we would have wasted time with our impatience. By simply making them
//! not count towards length, we can make sure to have enough "live" requests ongoing, while at the
Expand Down
2 changes: 1 addition & 1 deletion runtime/common/src/elections.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ pub type GenesisElectionOf<T> =
/// pallet-election-provider-multi-phase.
pub const MINER_MAX_ITERATIONS: u32 = 10;

/// A source of random balance for the NPoS Solver, which is meant to be run by the offchain worker
/// A source of random balance for the NPoS Solver, which is meant to be run by the off-chain worker
/// election miner.
pub struct OffchainRandomBalancing;
impl frame_support::pallet_prelude::Get<Option<(usize, sp_npos_elections::ExtendedBalance)>>
Expand Down
41 changes: 26 additions & 15 deletions runtime/westend/src/weights/xcm/pallet_xcm_benchmarks_fungible.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
//! Autogenerated weights for `pallet_xcm_benchmarks::fungible`
//!
//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev
//! DATE: 2021-09-17, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]`
//! DATE: 2021-10-25, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]`
//! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("westend-dev"), DB CACHE: 128

// Executed Command:
Expand Down Expand Up @@ -48,48 +48,59 @@ 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 {
(39_691_000 as Weight)
(43_806_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:2 w:2)
pub(crate) fn transfer_asset() -> Weight {
(62_616_000 as Weight)
(68_076_000 as Weight)
.saturating_add(T::DbWeight::get().reads(2 as Weight))
.saturating_add(T::DbWeight::get().writes(2 as Weight))
}
// Storage: System Account (r:2 w:2)
// Storage: XcmPallet SupportedVersion (r:1 w:0)
// Storage: XcmPallet VersionDiscoveryQueue (r:1 w:1)
// Storage: XcmPallet SafeXcmVersion (r:1 w:0)
// Storage: Dmp DownwardMessageQueueHeads (r:1 w:1)
// Storage: Dmp DownwardMessageQueues (r:1 w:1)
pub(crate) fn transfer_reserve_asset() -> Weight {
(86_642_000 as Weight)
.saturating_add(T::DbWeight::get().reads(4 as Weight))
.saturating_add(T::DbWeight::get().writes(4 as Weight))
(99_639_000 as Weight)
.saturating_add(T::DbWeight::get().reads(7 as Weight))
.saturating_add(T::DbWeight::get().writes(5 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 {
(49_745_000 as Weight)
(51_793_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)
// Storage: XcmPallet SupportedVersion (r:1 w:0)
// Storage: XcmPallet VersionDiscoveryQueue (r:1 w:1)
// Storage: XcmPallet SafeXcmVersion (r:1 w:0)
// Storage: Dmp DownwardMessageQueueHeads (r:1 w:1)
// Storage: Dmp DownwardMessageQueues (r:1 w:1)
pub(crate) fn deposit_reserve_asset() -> Weight {
(75_318_000 as Weight)
.saturating_add(T::DbWeight::get().reads(3 as Weight))
.saturating_add(T::DbWeight::get().writes(3 as Weight))
(85_782_000 as Weight)
.saturating_add(T::DbWeight::get().reads(6 as Weight))
.saturating_add(T::DbWeight::get().writes(4 as Weight))
}
// Storage: System Account (r:1 w:1)
// Storage: XcmPallet SupportedVersion (r:1 w:0)
// Storage: XcmPallet VersionDiscoveryQueue (r:1 w:1)
// Storage: XcmPallet SafeXcmVersion (r:1 w:0)
// Storage: Dmp DownwardMessageQueueHeads (r:1 w:1)
// Storage: Dmp DownwardMessageQueues (r:1 w:1)
pub(crate) fn initiate_teleport() -> Weight {
(75_467_000 as Weight)
.saturating_add(T::DbWeight::get().reads(3 as Weight))
.saturating_add(T::DbWeight::get().writes(3 as Weight))
(84_873_000 as Weight)
.saturating_add(T::DbWeight::get().reads(6 as Weight))
.saturating_add(T::DbWeight::get().writes(4 as Weight))
}
}
25 changes: 18 additions & 7 deletions xcm/pallet-xcm-benchmarks/src/fungible/benchmarking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand Down Expand Up @@ -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<T::AccountId>
>::Balance::max_value() / 2u32.into(),
)?;
}

let assets: MultiAssets = vec![ teleportable_asset ].into();

Expand Down
9 changes: 7 additions & 2 deletions xcm/pallet-xcm-benchmarks/src/fungible/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<Ancestry>;
type Barrier = AllowUnpaidExecutionFrom<Everything>;
type Weigher = xcm_builder::FixedWeightBounds<UnitWeightCost, Call, MaxInstructions>;
Expand All @@ -153,12 +153,17 @@ impl crate::Config for Test {
}
}

pub type TrustedTeleporters = (xcm_builder::Case<TeleConcreteFung>,);

parameter_types! {
pub const CheckedAccount: Option<u64> = 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 {
Expand Down
2 changes: 1 addition & 1 deletion xcm/pallet-xcm/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ pub mod pallet {
/// \[ origin location, id, expected location \]
InvalidResponder(MultiLocation, QueryId, Option<MultiLocation>),
/// Expected query response has been received but the expected origin location placed in
/// storate by this runtime previously cannot be decoded. The query remains registered.
/// storage by this runtime previously cannot be decoded. The query remains registered.
///
/// This is unexpected (since a location placed in storage in a previously executing
/// runtime should be readable prior to query timeout) and dangerous since the possibly
Expand Down
2 changes: 1 addition & 1 deletion xcm/pallet-xcm/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -687,7 +687,7 @@ fn subscriber_side_subscription_works() {
});
}

/// We should autosubscribe when we don't know the remote's version.
/// We should auto-subscribe when we don't know the remote's version.
#[test]
fn auto_subscription_works() {
new_test_ext_with_balances(vec![]).execute_with(|| {
Expand Down