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 3 commits into
base: master
Choose a base branch
from
Open
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
52 changes: 26 additions & 26 deletions cumulus/parachains/runtimes/assets/asset-hub-westend/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -825,7 +825,7 @@ impl cumulus_pallet_aura_ext::Config for Runtime {}

parameter_types! {
/// The asset ID for the asset that we use to pay for message delivery fees.
pub FeeAssetId: AssetId = AssetId(xcm_config::WestendLocation::get());
pub FeeAssetId: AssetId = AssetId(xcm_config::AssetHubWestend::get());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no change here, WestendLocation means Location { parents: 1, interior: Here } which represents relaychain native token from the parachain's perspective, which is WND (or DOT for Polkadot, KSM for Kusama...).

Suggested change
pub FeeAssetId: AssetId = AssetId(xcm_config::AssetHubWestend::get());
pub FeeAssetId: AssetId = AssetId(xcm_config::WestendLocation::get());

/// The base fee for the message delivery fees.
pub const BaseDeliveryFee: u128 = CENTS.saturating_mul(3);
}
Expand Down Expand Up @@ -1499,7 +1499,7 @@ impl_runtime_apis! {
fn metadata_versions() -> alloc::vec::Vec<u32> {
Runtime::metadata_versions()
}
}
};

impl sp_block_builder::BlockBuilder<Block> for Runtime {
fn apply_extrinsic(extrinsic: <Block as BlockT>::Extrinsic) -> ApplyExtrinsicResult {
Expand Down 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,14 +1870,15 @@ impl_runtime_apis! {
}

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

parameter_types! {
pub ExistentialDepositAsset: Option<Asset> = Some((
WestendLocation::get(),
AssetHubWestend::get(),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
AssetHubWestend::get(),
WestendLocation::get(),

ExistentialDeposit::get()
).into());
pub const RandomParaId: ParaId = ParaId::new(43211234);
pub const SiblingAssetHubId: ParaId = ParaId::new(AssetHubId::get());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AssetHub does not know any other sibling AssetHub, RandomParaId is good here

Suggested change
pub const SiblingAssetHubId: ParaId = ParaId::new(AssetHubId::get());
pub const RandomParaId: ParaId = ParaId::new(43211234);
pub RandomParaLocation: Location = ParentThen(Parachain(RandomParaId::get().into()).into()).into();

}

use pallet_xcm::benchmarking::Pallet as PalletXcmExtrinsicsBenchmark;
Expand All @@ -1893,34 +1893,34 @@ impl_runtime_apis! {
xcm_config::XcmConfig,
ExistentialDepositAsset,
PriceForSiblingParachainDelivery,
RandomParaId,
SiblingAssetHubId,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
SiblingAssetHubId,
RandomParaId,

ParachainSystem,
>
);

fn reachable_dest() -> Option<Location> {
Some(Parent.into())
Some(AssetHubWestend::get())
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please, everywhere where you changed Location (location and not assetId) Parent to AssetHubWestend, you need to change Parent tot RandomParaLocation

Suggested change
Some(AssetHubWestend::get())
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(AssetHubWestend::get())
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

watch out, here Parent.into() is used in the context of AssetId, so change it better tot WestendLocation

Suggested change
id: AssetId(AssetHubWestend::get())
id: AssetId(WestendLocation::get())

},
Parent.into(),
AssetHubWestend::get(),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
AssetHubWestend::get(),
RandomParaLocation::get(),

))
}

fn reserve_transferable_asset_and_dest() -> Option<(Asset, Location)> {
Some((
Asset {
fun: Fungible(ExistentialDeposit::get()),
id: AssetId(Parent.into())
id: AssetId(AssetHubWestend::get())
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
id: AssetId(AssetHubWestend::get())
id: AssetId(WestendLocation::get())

},
// AH can reserve transfer native token to some random parachain.
ParentThen(Parachain(RandomParaId::get().into()).into()).into(),
AssetHubWestend::get(),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
AssetHubWestend::get(),
RandomParaLocation::get(),

))
}

Expand All @@ -1929,10 +1929,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 = AssetHubWestend::get();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
let dest = AssetHubWestend::get();
let dest = RandomParaLocation::get();


let fee_amount = EXISTENTIAL_DEPOSIT;
let fee_asset: Asset = (Location::parent(), fee_amount).into();
let fee_asset: Asset = (AssetHubWestend::get(), fee_amount).into();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
let fee_asset: Asset = (AssetHubWestend::get(), 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 +1975,7 @@ impl_runtime_apis! {

fn get_asset() -> Asset {
Asset {
id: AssetId(Location::parent()),
id: AssetId(AssetHubWestend::get()),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
id: AssetId(AssetHubWestend::get()),
id: AssetId(WestendLocation::get()),

fun: Fungible(ExistentialDeposit::get()),
}
}
Expand Down Expand Up @@ -2015,19 +2015,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,
SiblingAssetHubId,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
SiblingAssetHubId,
RandomParaId,

ParachainSystem
>;
fn valid_destination() -> Result<Location, BenchmarkError> {
Ok(WestendLocation::get())
Ok(AssetHubWestend::get())
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Ok(AssetHubWestend::get())
Ok(RandomParaLocation::get())

}
fn worst_case_holding(depositable_count: u32) -> XcmAssets {
// A mix of fungible, non-fungible, and concrete assets.
Expand All @@ -2042,7 +2043,7 @@ impl_runtime_apis! {
}
})
.chain(core::iter::once(Asset { id: AssetId(Here.into()), fun: Fungible(u128::MAX) }))
.chain(core::iter::once(Asset { id: AssetId(WestendLocation::get()), fun: Fungible(1_000_000 * UNITS) }))
.chain(core::iter::once(Asset { id: AssetId(AssetHubWestend::get()), fun: Fungible(1_000_000 * UNITS) }))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
.chain(core::iter::once(Asset { id: AssetId(AssetHubWestend::get()), fun: Fungible(1_000_000 * UNITS) }))
.chain(core::iter::once(Asset { id: AssetId(WestendLocation::get()), fun: Fungible(1_000_000 * UNITS) }))

.chain((0..holding_non_fungibles).map(|i| Asset {
id: AssetId(GeneralIndex(i as u128).into()),
fun: NonFungible(asset_instance_from(i)),
Expand All @@ -2054,8 +2055,8 @@ impl_runtime_apis! {

parameter_types! {
pub const TrustedTeleporter: Option<(Location, Asset)> = Some((
WestendLocation::get(),
Asset { fun: Fungible(UNITS), id: AssetId(WestendLocation::get()) },
AssetHubWestend::get(),
Asset { fun: Fungible(UNITS), id: AssetId(AssetHubWestend::get()) },
Comment on lines +2058 to +2059
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we want to simulate scenario, where RandomParaLocation can teleport us native token aka WND aka WestendLocation

Suggested change
AssetHubWestend::get(),
Asset { fun: Fungible(UNITS), id: AssetId(AssetHubWestend::get()) },
RandomParaLocation::get(),
Asset { fun: Fungible(UNITS), id: AssetId(WestendLocation::get()) },

));
pub const CheckedAccount: Option<(AccountId, xcm_builder::MintLocation)> = None;
// AssetHubWestend trusts AssetHubRococo as reserve for ROCs
Expand Down Expand Up @@ -2183,8 +2184,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
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,8 @@ use xcm_executor::XcmExecutor;

parameter_types! {
pub const RootLocation: Location = Location::here();
pub const AssetHubId: u32 = 1000;
pub const AssetHubWestend: Location = Parachain(AssetHubId::get()).into();
Comment on lines +67 to +68
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
pub const AssetHubId: u32 = 1000;
pub const AssetHubWestend: Location = Parachain(AssetHubId::get()).into();

pub const WestendLocation: Location = Location::parent();
pub const GovernanceLocation: Location = Location::parent();
pub const RelayNetwork: Option<NetworkId> = Some(NetworkId::ByGenesis(WESTEND_GENESIS_HASH));
Expand Down
Loading