Skip to content
This repository was archived by the owner on Nov 15, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from 2 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: 2 additions & 0 deletions runtime/kusama/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1956,6 +1956,7 @@ sp_api::impl_runtime_apis! {
Statemine::get(),
MultiAsset { fun: Fungible(1 * UNITS), id: Concrete(KsmLocation::get()) },
));
pub const TrackBalances: bool = true;
}

impl pallet_xcm_benchmarks::fungible::Config for Runtime {
Expand All @@ -1964,6 +1965,7 @@ sp_api::impl_runtime_apis! {
type CheckedAccount = CheckAccount;
type TrustedTeleporter = TrustedTeleporter;
type TrustedReserve = TrustedReserve;
type TrackBalances = TrackBalances;

fn get_multi_asset() -> MultiAsset {
MultiAsset {
Expand Down
2 changes: 2 additions & 0 deletions runtime/westend/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1670,6 +1670,7 @@ sp_api::impl_runtime_apis! {
Westmint::get(),
MultiAsset { fun: Fungible(1 * UNITS), id: Concrete(WndLocation::get()) },
));
pub const TrackBalances: bool = true;
}

impl pallet_xcm_benchmarks::fungible::Config for Runtime {
Expand All @@ -1678,6 +1679,7 @@ sp_api::impl_runtime_apis! {
type CheckedAccount = xcm_config::CheckAccount;
type TrustedTeleporter = TrustedTeleporter;
type TrustedReserve = TrustedReserve;
type TrackBalances = TrackBalances;

fn get_multi_asset() -> MultiAsset {
MultiAsset {
Expand Down
2 changes: 1 addition & 1 deletion xcm/pallet-xcm-benchmarks/src/fungible/benchmarking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ benchmarks_instance_pallet! {
}: {
executor.execute(xcm)?;
} verify {
if let Some(checked_account) = T::CheckedAccount::get() {
if T::TrackBalances::get() && let Some(checked_account) = T::CheckedAccount::get() {
// teleport checked account should have received some asset.
assert!(!T::TransactAsset::balance(&checked_account).is_zero());
}
Expand Down
2 changes: 2 additions & 0 deletions xcm/pallet-xcm-benchmarks/src/fungible/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,7 @@ parameter_types! {
ChildTeleporter::get(),
MultiAsset { id: Concrete(Here.into()), fun: Fungible(100) },
));
pub const TrackaBalances: bool = true;
pub const TeleConcreteFung: (MultiAssetFilter, MultiLocation) =
(Wild(AllOf { fun: WildFungible, id: Concrete(Here.into()) }), ChildTeleporter::get());
pub const RsrvConcreteFung: (MultiAssetFilter, MultiLocation) =
Expand All @@ -183,6 +184,7 @@ impl xcm_balances_benchmark::Config for Test {
type CheckedAccount = CheckedAccount;
type TrustedTeleporter = TrustedTeleporter;
type TrustedReserve = TrustedReserve;
type TrackBalances = TrackaBalances;

fn get_multi_asset() -> MultiAsset {
let amount =
Expand Down
3 changes: 3 additions & 0 deletions xcm/pallet-xcm-benchmarks/src/fungible/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@ pub mod pallet {

/// Give me a fungible asset that your asset transactor is going to accept.
fn get_multi_asset() -> xcm::latest::MultiAsset;

/// Disable tracking teleports of balances
type TrackBalances: Get<bool>;
}

#[pallet::pallet]
Expand Down
20 changes: 0 additions & 20 deletions xcm/pallet-xcm-benchmarks/src/generic/benchmarking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,26 +70,6 @@ benchmarks! {

}

// Worst case scenario for this benchmark is a large number of assets to
// filter through the reserve.
reserve_asset_deposited {
const MAX_ASSETS: u32 = 100; // TODO when executor has a built in limit, use it here. #4426
let mut executor = new_executor::<T>(Default::default());
let assets = (0..MAX_ASSETS).map(|i| MultiAsset {
id: Abstract(i.encode()),
fun: Fungible(i as u128),

}).collect::<vec::Vec<_>>();
let multiassets: MultiAssets = assets.into();

let instruction = Instruction::ReserveAssetDeposited(multiassets.clone());
let xcm = Xcm(vec![instruction]);
}: {
executor.execute(xcm).map_err(|_| BenchmarkError::Skip)?;
} verify {
assert_eq!(executor.holding, multiassets.into());
}

query_response {
let mut executor = new_executor::<T>(Default::default());
let (query_id, response) = T::worst_case_response();
Expand Down