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

Switch runtimes benchmarking for delivering to sibling parachains instead of Parent #7321

Open
wants to merge 22 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
94b6732
switch destination Parent to AH
EleisonC Jan 23, 2025
81eeb4f
fix fee assetID
EleisonC Jan 23, 2025
b09562a
Merge branch 'master' into testnet-sibling-parachains-benchmarking-setup
EleisonC Jan 23, 2025
a4e2471
Update cumulus/parachains/runtimes/assets/asset-hub-westend/src/lib.rs
EleisonC Jan 27, 2025
24fc618
Update cumulus/parachains/runtimes/assets/asset-hub-westend/src/lib.rs
EleisonC Jan 27, 2025
c0124ca
Update cumulus/parachains/runtimes/assets/asset-hub-westend/src/lib.rs
EleisonC Jan 27, 2025
3be121b
Update cumulus/parachains/runtimes/assets/asset-hub-westend/src/lib.rs
EleisonC Jan 27, 2025
501f0f4
Update cumulus/parachains/runtimes/assets/asset-hub-westend/src/lib.rs
EleisonC Jan 27, 2025
5016e26
Update cumulus/parachains/runtimes/assets/asset-hub-westend/src/lib.rs
EleisonC Jan 27, 2025
f1cc6ff
Update cumulus/parachains/runtimes/assets/asset-hub-westend/src/lib.rs
EleisonC Jan 27, 2025
f73588f
Update cumulus/parachains/runtimes/assets/asset-hub-westend/src/lib.rs
EleisonC Jan 27, 2025
a7b9156
Update cumulus/parachains/runtimes/assets/asset-hub-westend/src/lib.rs
EleisonC Jan 27, 2025
1d54c60
Update cumulus/parachains/runtimes/assets/asset-hub-westend/src/lib.rs
EleisonC Jan 27, 2025
e50332c
Update cumulus/parachains/runtimes/assets/asset-hub-westend/src/lib.rs
EleisonC Jan 27, 2025
4df3a83
Update cumulus/parachains/runtimes/assets/asset-hub-westend/src/lib.rs
EleisonC Jan 27, 2025
3ea101a
Update cumulus/parachains/runtimes/assets/asset-hub-westend/src/lib.rs
EleisonC Jan 27, 2025
7c2d109
Update cumulus/parachains/runtimes/assets/asset-hub-westend/src/lib.rs
EleisonC Jan 27, 2025
07ba775
Update cumulus/parachains/runtimes/assets/asset-hub-westend/src/lib.rs
EleisonC Jan 27, 2025
41993ac
Update cumulus/parachains/runtimes/assets/asset-hub-westend/src/lib.rs
EleisonC Jan 27, 2025
5df1895
Update cumulus/parachains/runtimes/assets/asset-hub-westend/src/xcm_c…
EleisonC Jan 27, 2025
04ba860
refactor to ToParachainDeliveryHelper
EleisonC Jan 27, 2025
7617aa6
refactor asset-hub-rococo
EleisonC Jan 27, 2025
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
44 changes: 20 additions & 24 deletions cumulus/parachains/runtimes/assets/asset-hub-rococo/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1712,48 +1712,42 @@ impl_runtime_apis! {
ExistentialDeposit::get()
).into());
pub const RandomParaId: ParaId = ParaId::new(43211234);
pub RandomParaLocation: Location = ParentThen(Parachain(RandomParaId::get().into()).into()).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,
>,
polkadot_runtime_common::xcm_sender::ToParachainDeliveryHelper<
type DeliveryHelper = polkadot_runtime_common::xcm_sender::ToParachainDeliveryHelper<
xcm_config::XcmConfig,
ExistentialDepositAsset,
PriceForSiblingParachainDelivery,
RandomParaId,
ParachainSystem,
>
);
>;

fn reachable_dest() -> Option<Location> {
Some(Parent.into())
Some(RandomParaLocation::get())
}

fn teleportable_asset_and_dest() -> Option<(Asset, Location)> {
// Relay/native token can be teleported between AH and Relay.
Some((
Asset {
fun: Fungible(ExistentialDeposit::get()),
id: AssetId(Parent.into())
id: AssetId(TokenLocation::get())
},
Parent.into(),
RandomParaLocation::get(),
))
}

fn reserve_transferable_asset_and_dest() -> Option<(Asset, Location)> {
Some((
Asset {
fun: Fungible(ExistentialDeposit::get()),
id: AssetId(Parent.into())
id: AssetId(TokenLocation::get())
},
// AH can reserve transfer native token to some random parachain.
ParentThen(Parachain(RandomParaId::get().into()).into()).into(),
RandomParaLocation::get(),
))
}

Expand All @@ -1762,10 +1756,10 @@ impl_runtime_apis! {
// Transfer to Relay some local AH asset (local-reserve-transfer) while paying
// fees using teleported native token.
// (We don't care that Relay doesn't accept incoming unknown AH local asset)
let dest = Parent.into();
let dest = RandomParaLocation::get();

let fee_amount = EXISTENTIAL_DEPOSIT;
let fee_asset: Asset = (Location::parent(), fee_amount).into();
let fee_asset: Asset = (TokenLocation::get(), fee_amount).into();

let who = frame_benchmarking::whitelisted_caller();
// Give some multiple of the existential deposit
Expand Down Expand Up @@ -1808,7 +1802,7 @@ impl_runtime_apis! {

fn get_asset() -> Asset {
Asset {
id: AssetId(Location::parent()),
id: AssetId(TokenLocation::get()),
fun: Fungible(ExistentialDeposit::get()),
}
}
Expand Down Expand Up @@ -1849,13 +1843,15 @@ impl_runtime_apis! {
impl pallet_xcm_benchmarks::Config for Runtime {
type XcmConfig = xcm_config::XcmConfig;
type AccountIdConverter = xcm_config::LocationToAccountId;
type DeliveryHelper = cumulus_primitives_utility::ToParentDeliveryHelper<
xcm_config::XcmConfig,
ExistentialDepositAsset,
xcm_config::PriceForParentDelivery,
>;
type DeliveryHelper = polkadot_runtime_common::xcm_sender::ToParachainDeliveryHelper<
xcm_config::XcmConfig,
ExistentialDepositAsset,
PriceForSiblingParachainDelivery,
RandomParaId,
ParachainSystem,
>;
fn valid_destination() -> Result<Location, BenchmarkError> {
Ok(TokenLocation::get())
Ok(RandomParaLocation::get())
}
fn worst_case_holding(depositable_count: u32) -> XcmAssets {
// A mix of fungible, non-fungible, and concrete assets.
Expand All @@ -1882,7 +1878,7 @@ impl_runtime_apis! {

parameter_types! {
pub const TrustedTeleporter: Option<(Location, Asset)> = Some((
TokenLocation::get(),
RandomParaLocation::get(),
Asset { fun: Fungible(UNITS), id: AssetId(TokenLocation::get()) },
));
pub const CheckedAccount: Option<(AccountId, xcm_builder::MintLocation)> = None;
Expand Down
50 changes: 22 additions & 28 deletions cumulus/parachains/runtimes/assets/asset-hub-westend/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1856,7 +1856,6 @@ impl_runtime_apis! {
) -> Result<Vec<frame_benchmarking::BenchmarkBatch>, alloc::string::String> {
use frame_benchmarking::{Benchmarking, BenchmarkBatch, BenchmarkError};
use sp_storage::TrackedStorageKey;

use frame_system_benchmarking::Pallet as SystemBench;
use frame_system_benchmarking::extensions::Pallet as SystemExtensionsBench;
impl frame_system_benchmarking::Config for Runtime {
Expand All @@ -1871,6 +1870,7 @@ impl_runtime_apis! {
}

use cumulus_pallet_session_benchmarking::Pallet as SessionBench;
use xcm_config::{MaxAssetsIntoHolding, WestendLocation};
impl cumulus_pallet_session_benchmarking::Config for Runtime {}

parameter_types! {
Expand All @@ -1879,48 +1879,42 @@ impl_runtime_apis! {
ExistentialDeposit::get()
).into());
pub const RandomParaId: ParaId = ParaId::new(43211234);
pub RandomParaLocation: Location = ParentThen(Parachain(RandomParaId::get().into()).into()).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,
>,
polkadot_runtime_common::xcm_sender::ToParachainDeliveryHelper<
type DeliveryHelper = polkadot_runtime_common::xcm_sender::ToParachainDeliveryHelper<
xcm_config::XcmConfig,
ExistentialDepositAsset,
PriceForSiblingParachainDelivery,
RandomParaId,
ParachainSystem,
>
);
>;

fn reachable_dest() -> Option<Location> {
Some(Parent.into())
Some(RandomParaLocation::get())
}

fn teleportable_asset_and_dest() -> Option<(Asset, Location)> {
// Relay/native token can be teleported between AH and Relay.
Some((
Asset {
fun: Fungible(ExistentialDeposit::get()),
id: AssetId(Parent.into())
id: AssetId(WestendLocation::get())
},
Parent.into(),
RandomParaLocation::get(),
))
}

fn reserve_transferable_asset_and_dest() -> Option<(Asset, Location)> {
Some((
Asset {
fun: Fungible(ExistentialDeposit::get()),
id: AssetId(Parent.into())
id: AssetId(WestendLocation::get())
},
// AH can reserve transfer native token to some random parachain.
ParentThen(Parachain(RandomParaId::get().into()).into()).into(),
RandomParaLocation::get(),
))
}

Expand All @@ -1929,10 +1923,10 @@ impl_runtime_apis! {
// Transfer to Relay some local AH asset (local-reserve-transfer) while paying
// fees using teleported native token.
// (We don't care that Relay doesn't accept incoming unknown AH local asset)
let dest = Parent.into();
let dest = RandomParaLocation::get();

let fee_amount = EXISTENTIAL_DEPOSIT;
let fee_asset: Asset = (Location::parent(), fee_amount).into();
let fee_asset: Asset = (WestendLocation::get(), fee_amount).into();

let who = frame_benchmarking::whitelisted_caller();
// Give some multiple of the existential deposit
Expand Down Expand Up @@ -1975,7 +1969,7 @@ impl_runtime_apis! {

fn get_asset() -> Asset {
Asset {
id: AssetId(Location::parent()),
id: AssetId(WestendLocation::get()),
fun: Fungible(ExistentialDeposit::get()),
}
}
Expand Down Expand Up @@ -2015,19 +2009,20 @@ impl_runtime_apis! {
}
}

use xcm_config::{MaxAssetsIntoHolding, WestendLocation};
use pallet_xcm_benchmarks::asset_instance_from;

impl pallet_xcm_benchmarks::Config for Runtime {
type XcmConfig = xcm_config::XcmConfig;
type AccountIdConverter = xcm_config::LocationToAccountId;
type DeliveryHelper = cumulus_primitives_utility::ToParentDeliveryHelper<
xcm_config::XcmConfig,
ExistentialDepositAsset,
xcm_config::PriceForParentDelivery,
>;
type DeliveryHelper = polkadot_runtime_common::xcm_sender::ToParachainDeliveryHelper<
xcm_config::XcmConfig,
ExistentialDepositAsset,
PriceForSiblingParachainDelivery,
RandomParaId,
ParachainSystem
>;
fn valid_destination() -> Result<Location, BenchmarkError> {
Ok(WestendLocation::get())
Ok(RandomParaLocation::get())
}
fn worst_case_holding(depositable_count: u32) -> XcmAssets {
// A mix of fungible, non-fungible, and concrete assets.
Expand All @@ -2054,7 +2049,7 @@ impl_runtime_apis! {

parameter_types! {
pub const TrustedTeleporter: Option<(Location, Asset)> = Some((
WestendLocation::get(),
RandomParaLocation::get(),
Asset { fun: Fungible(UNITS), id: AssetId(WestendLocation::get()) },
));
pub const CheckedAccount: Option<(AccountId, xcm_builder::MintLocation)> = None;
Expand Down Expand Up @@ -2183,8 +2178,7 @@ impl_runtime_apis! {
}
}

impl pallet_revive::ReviveApi<Block, AccountId, Balance, Nonce, BlockNumber> for Runtime
{
impl pallet_revive::ReviveApi<Block, AccountId, Balance, Nonce, BlockNumber> for Runtime {
fn balance(address: H160) -> U256 {
Revive::evm_balance(&address)
}
Expand Down
Loading