Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[pallet-xcm] Adjust benchmarks (teleport_assets/reserve_transfer_assets) not relying on ED #3464

Merged
merged 7 commits into from
Feb 26, 2024
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
3 changes: 1 addition & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions cumulus/pallets/parachain-system/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ sp-version = { path = "../../../substrate/primitives/version", default-features
# Polkadot
polkadot-parachain-primitives = { path = "../../../polkadot/parachain", default-features = false, features = ["wasm-api"] }
polkadot-runtime-parachains = { path = "../../../polkadot/runtime/parachains", default-features = false }
polkadot-runtime-common = { path = "../../../polkadot/runtime/common", default-features = false, optional = true }
xcm = { package = "staging-xcm", path = "../../../polkadot/xcm", default-features = false }

# Cumulus
Expand Down Expand Up @@ -79,6 +80,7 @@ std = [
"log/std",
"pallet-message-queue/std",
"polkadot-parachain-primitives/std",
"polkadot-runtime-common/std",
"polkadot-runtime-parachains/std",
"scale-info/std",
"sp-core/std",
Expand All @@ -102,6 +104,7 @@ runtime-benchmarks = [
"frame-system/runtime-benchmarks",
"pallet-message-queue/runtime-benchmarks",
"polkadot-parachain-primitives/runtime-benchmarks",
"polkadot-runtime-common/runtime-benchmarks",
"polkadot-runtime-parachains/runtime-benchmarks",
"sp-runtime/runtime-benchmarks",
]
Expand Down
9 changes: 9 additions & 0 deletions cumulus/pallets/parachain-system/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1610,6 +1610,15 @@ impl<T: Config> UpwardMessageSender for Pallet<T> {
}
}

#[cfg(feature = "runtime-benchmarks")]
impl<T: Config> polkadot_runtime_common::xcm_sender::EnsureForParachain for Pallet<T> {
fn ensure(para_id: ParaId) {
if let ChannelStatus::Closed = Self::get_channel_status(para_id) {
Self::open_outbound_hrmp_channel_for_benchmarks_or_tests(para_id)
}
}
}

/// Something that can check the inherents of a block.
#[cfg_attr(
feature = "parameterized-consensus-hook",
Expand Down
42 changes: 27 additions & 15 deletions cumulus/parachains/runtimes/assets/asset-hub-rococo/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1355,8 +1355,31 @@ impl_runtime_apis! {
Config as XcmBridgeHubRouterConfig,
};

parameter_types! {
pub ExistentialDepositAsset: Option<Asset> = Some((
TokenLocation::get(),
ExistentialDeposit::get()
).into());
pub const RandomParaId: ParaId = ParaId::new(43211234);
}

use pallet_xcm::benchmarking::Pallet as PalletXcmExtrinsicsBenchmark;
impl pallet_xcm::benchmarking::Config for Runtime {
type DeliveryHelper = (
cumulus_primitives_utility::ToParentDeliveryHelper<
xcm_config::XcmConfig,
ExistentialDepositAsset,
xcm_config::PriceForParentDelivery,
>,
polkadot_runtime_common::xcm_sender::ToParachainDeliveryHelper<
xcm_config::XcmConfig,
ExistentialDepositAsset,
PriceForSiblingParachainDelivery,
RandomParaId,
ParachainSystem,
>
);

fn reachable_dest() -> Option<Location> {
Some(Parent.into())
}
Expand All @@ -1365,25 +1388,21 @@ impl_runtime_apis! {
// Relay/native token can be teleported between AH and Relay.
Some((
Asset {
fun: Fungible(EXISTENTIAL_DEPOSIT),
fun: Fungible(ExistentialDeposit::get()),
id: AssetId(Parent.into())
},
bkontur marked this conversation as resolved.
Show resolved Hide resolved
Parent.into(),
))
}

fn reserve_transferable_asset_and_dest() -> Option<(Asset, Location)> {
// AH can reserve transfer native token to some random parachain.
let random_para_id = 43211234;
ParachainSystem::open_outbound_hrmp_channel_for_benchmarks_or_tests(
random_para_id.into()
);
Some((
Asset {
fun: Fungible(EXISTENTIAL_DEPOSIT),
fun: Fungible(ExistentialDeposit::get()),
id: AssetId(Parent.into())
},
bkontur marked this conversation as resolved.
Show resolved Hide resolved
ParentThen(Parachain(random_para_id).into()).into(),
// AH can reserve transfer native token to some random parachain.
ParentThen(Parachain(RandomParaId::get().into()).into()).into(),
))
}

Expand Down Expand Up @@ -1469,13 +1488,6 @@ impl_runtime_apis! {
use xcm_config::{TokenLocation, MaxAssetsIntoHolding};
use pallet_xcm_benchmarks::asset_instance_from;

parameter_types! {
pub ExistentialDepositAsset: Option<Asset> = Some((
TokenLocation::get(),
ExistentialDeposit::get()
).into());
}

impl pallet_xcm_benchmarks::Config for Runtime {
type XcmConfig = xcm_config::XcmConfig;
type AccountIdConverter = xcm_config::LocationToAccountId;
Expand Down
42 changes: 27 additions & 15 deletions cumulus/parachains/runtimes/assets/asset-hub-westend/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1427,8 +1427,31 @@ impl_runtime_apis! {
use cumulus_pallet_session_benchmarking::Pallet as SessionBench;
impl cumulus_pallet_session_benchmarking::Config for Runtime {}

parameter_types! {
pub ExistentialDepositAsset: Option<Asset> = Some((
WestendLocation::get(),
ExistentialDeposit::get()
).into());
pub const RandomParaId: ParaId = ParaId::new(43211234);
}

use pallet_xcm::benchmarking::Pallet as PalletXcmExtrinsicsBenchmark;
impl pallet_xcm::benchmarking::Config for Runtime {
type DeliveryHelper = (
cumulus_primitives_utility::ToParentDeliveryHelper<
xcm_config::XcmConfig,
ExistentialDepositAsset,
xcm_config::PriceForParentDelivery,
>,
polkadot_runtime_common::xcm_sender::ToParachainDeliveryHelper<
xcm_config::XcmConfig,
ExistentialDepositAsset,
PriceForSiblingParachainDelivery,
RandomParaId,
ParachainSystem,
>
);

fn reachable_dest() -> Option<Location> {
Some(Parent.into())
}
Expand All @@ -1437,25 +1460,21 @@ impl_runtime_apis! {
// Relay/native token can be teleported between AH and Relay.
Some((
Asset {
fun: Fungible(EXISTENTIAL_DEPOSIT),
fun: Fungible(ExistentialDeposit::get()),
id: AssetId(Parent.into())
},
Parent.into(),
))
}

fn reserve_transferable_asset_and_dest() -> Option<(Asset, Location)> {
// AH can reserve transfer native token to some random parachain.
let random_para_id = 43211234;
ParachainSystem::open_outbound_hrmp_channel_for_benchmarks_or_tests(
random_para_id.into()
);
Some((
Asset {
fun: Fungible(EXISTENTIAL_DEPOSIT),
fun: Fungible(ExistentialDeposit::get()),
id: AssetId(Parent.into())
},
ParentThen(Parachain(random_para_id).into()).into(),
// AH can reserve transfer native token to some random parachain.
ParentThen(Parachain(RandomParaId::get().into()).into()).into(),
))
}

Expand Down Expand Up @@ -1546,13 +1565,6 @@ impl_runtime_apis! {
use xcm_config::{MaxAssetsIntoHolding, WestendLocation};
use pallet_xcm_benchmarks::asset_instance_from;

parameter_types! {
pub ExistentialDepositAsset: Option<Asset> = Some((
WestendLocation::get(),
ExistentialDeposit::get()
).into());
}

impl pallet_xcm_benchmarks::Config for Runtime {
type XcmConfig = xcm_config::XcmConfig;
type AccountIdConverter = xcm_config::LocationToAccountId;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1109,6 +1109,12 @@ impl_runtime_apis! {

use pallet_xcm::benchmarking::Pallet as PalletXcmExtrinsicsBenchmark;
impl pallet_xcm::benchmarking::Config for Runtime {
type DeliveryHelper = cumulus_primitives_utility::ToParentDeliveryHelper<
xcm_config::XcmConfig,
ExistentialDepositAsset,
xcm_config::PriceForParentDelivery,
>;

fn reachable_dest() -> Option<Location> {
Some(Parent.into())
}
Expand All @@ -1117,7 +1123,7 @@ impl_runtime_apis! {
// Relay/native token can be teleported between BH and Relay.
Some((
Asset {
fun: Fungible(EXISTENTIAL_DEPOSIT),
fun: Fungible(ExistentialDeposit::get()),
id: AssetId(Parent.into())
},
Parent.into(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -806,6 +806,12 @@ impl_runtime_apis! {

use pallet_xcm::benchmarking::Pallet as PalletXcmExtrinsicsBenchmark;
impl pallet_xcm::benchmarking::Config for Runtime {
type DeliveryHelper = cumulus_primitives_utility::ToParentDeliveryHelper<
xcm_config::XcmConfig,
ExistentialDepositAsset,
xcm_config::PriceForParentDelivery,
>;

fn reachable_dest() -> Option<Location> {
Some(Parent.into())
}
Expand All @@ -814,7 +820,7 @@ impl_runtime_apis! {
// Relay/native token can be teleported between BH and Relay.
Some((
Asset {
fun: Fungible(EXISTENTIAL_DEPOSIT),
fun: Fungible(ExistentialDeposit::get()),
id: AssetId(Parent.into())
},
Parent.into(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -986,8 +986,21 @@ impl_runtime_apis! {
use cumulus_pallet_session_benchmarking::Pallet as SessionBench;
impl cumulus_pallet_session_benchmarking::Config for Runtime {}

parameter_types! {
pub ExistentialDepositAsset: Option<Asset> = Some((
xcm_config::WndLocation::get(),
ExistentialDeposit::get()
).into());
}

use pallet_xcm::benchmarking::Pallet as PalletXcmExtrinsicsBenchmark;
impl pallet_xcm::benchmarking::Config for Runtime {
type DeliveryHelper = cumulus_primitives_utility::ToParentDeliveryHelper<
xcm_config::XcmConfig,
ExistentialDepositAsset,
xcm_config::PriceForParentDelivery,
>;

fn reachable_dest() -> Option<Location> {
Some(Parent.into())
}
Expand All @@ -996,7 +1009,7 @@ impl_runtime_apis! {
// Relay/native token can be teleported between Collectives and Relay.
Some((
Asset {
fun: Fungible(EXISTENTIAL_DEPOSIT),
fun: Fungible(ExistentialDeposit::get()),
id: AssetId(Parent.into())
}.into(),
Parent.into(),
Expand Down
23 changes: 20 additions & 3 deletions cumulus/parachains/runtimes/contracts/contracts-rococo/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ use frame_support::{
dispatch::DispatchClass,
genesis_builder_helper::{build_config, create_default_config},
parameter_types,
traits::{ConstBool, ConstU128, ConstU16, ConstU32, ConstU64, ConstU8},
traits::{ConstBool, ConstU16, ConstU32, ConstU64, ConstU8},
weights::{ConstantMultiplier, Weight},
PalletId,
};
Expand Down Expand Up @@ -205,14 +205,18 @@ impl pallet_authorship::Config for Runtime {
type EventHandler = (CollatorSelection,);
}

parameter_types! {
pub const ExistentialDeposit: Balance = EXISTENTIAL_DEPOSIT;
}

impl pallet_balances::Config for Runtime {
type MaxLocks = ConstU32<50>;
/// The type for recording an account's balance.
type Balance = Balance;
/// The ubiquitous event type.
type RuntimeEvent = RuntimeEvent;
type DustRemoval = ();
type ExistentialDeposit = ConstU128<EXISTENTIAL_DEPOSIT>;
type ExistentialDeposit = ExistentialDeposit;
type AccountStore = System;
type WeightInfo = pallet_balances::weights::SubstrateWeight<Runtime>;
type MaxReserves = ConstU32<50>;
Expand Down Expand Up @@ -713,9 +717,22 @@ impl_runtime_apis! {
use cumulus_pallet_session_benchmarking::Pallet as SessionBench;
impl cumulus_pallet_session_benchmarking::Config for Runtime {}

parameter_types! {
pub ExistentialDepositAsset: Option<Asset> = Some((
xcm_config::RelayLocation::get(),
ExistentialDeposit::get()
).into());
}

use xcm::latest::prelude::*;
use pallet_xcm::benchmarking::Pallet as PalletXcmExtrinsicsBenchmark;
impl pallet_xcm::benchmarking::Config for Runtime {
type DeliveryHelper = cumulus_primitives_utility::ToParentDeliveryHelper<
xcm_config::XcmConfig,
ExistentialDepositAsset,
xcm_config::PriceForParentDelivery,
>;

fn reachable_dest() -> Option<Location> {
Some(Parent.into())
}
Expand All @@ -724,7 +741,7 @@ impl_runtime_apis! {
// Relay/native token can be teleported between Contracts-System-Para and Relay.
Some((
Asset {
fun: Fungible(EXISTENTIAL_DEPOSIT),
fun: Fungible(ExistentialDeposit::get()),
id: AssetId(Parent.into())
},
Parent.into(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -715,6 +715,12 @@ impl_runtime_apis! {

use pallet_xcm::benchmarking::Pallet as PalletXcmExtrinsicsBenchmark;
impl pallet_xcm::benchmarking::Config for Runtime {
type DeliveryHelper = cumulus_primitives_utility::ToParentDeliveryHelper<
xcm_config::XcmConfig,
ExistentialDepositAsset,
xcm_config::PriceForParentDelivery,
>;

fn reachable_dest() -> Option<Location> {
Some(Parent.into())
}
Expand All @@ -723,7 +729,7 @@ impl_runtime_apis! {
// Relay/native token can be teleported between AH and Relay.
Some((
Asset {
fun: Fungible(EXISTENTIAL_DEPOSIT),
fun: Fungible(ExistentialDeposit::get()),
id: AssetId(Parent.into())
},
Parent.into(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -706,6 +706,12 @@ impl_runtime_apis! {

use pallet_xcm::benchmarking::Pallet as PalletXcmExtrinsicsBenchmark;
impl pallet_xcm::benchmarking::Config for Runtime {
type DeliveryHelper = cumulus_primitives_utility::ToParentDeliveryHelper<
xcm_config::XcmConfig,
ExistentialDepositAsset,
xcm_config::PriceForParentDelivery,
>;

fn reachable_dest() -> Option<Location> {
Some(Parent.into())
}
Expand All @@ -714,7 +720,7 @@ impl_runtime_apis! {
// Relay/native token can be teleported between AH and Relay.
Some((
Asset {
fun: Fungible(EXISTENTIAL_DEPOSIT),
fun: Fungible(ExistentialDeposit::get()),
id: AssetId(Parent.into())
},
Parent.into(),
Expand Down
Loading
Loading