Skip to content

Commit

Permalink
Coretime chain: allow region transfers (#483)
Browse files Browse the repository at this point in the history
The benchmark code was left blank even though the Region transactor is
included in both Polkadot and Kusama:
[link](https://github.com/Szegoo/runtimes/blob/b483d370034fbdc6a2c5978e7ba5ea55fcb2defb/system-parachains/coretime/coretime-kusama/src/xcm_config.rs#L97).

Because of this, it is not possible to perform cross-chain transfers of
regions since the weight is set to the maximum value:
[weight](https://github.com/Szegoo/runtimes/blob/b483d370034fbdc6a2c5978e7ba5ea55fcb2defb/system-parachains/coretime/coretime-kusama/src/weights/pallet_xcm.rs#L100)

---------

Co-authored-by: Bastian Köcher <[email protected]>
  • Loading branch information
Szegoo and bkchr authored Feb 3, 2025
1 parent 76d1fa6 commit e2aa32a
Show file tree
Hide file tree
Showing 3 changed files with 86 additions and 18 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).

- Fix missing Encointer democracy pallet hook needed for enactment ([polkadot-fellows/runtimes/pull/508](https://github.com/polkadot-fellows/runtimes/pull/508))
- Improve benchmark configuration: fix storage whitelist in benchmarks ([polkadot-fellows/runtimes/pull/525](https://github.com/polkadot-fellows/runtimes/pull/525))
- Coretime chain: allow cross-chain region transfers ([polkadot-fellows/runtimes/pull/483](https://github.com/polkadot-fellows/runtimes/pull/483))
- Unstake the last remaining corrupt ledger ([polkadot-fellows/runtimes/pull/538](https://github.com/polkadot-fellows/runtimes/pull/538))
- Disallow `add_sub` and `set_subs` from `NonTransfer` proxy type in people chain runtimes ([polkadot-fellows/runtimes#518](https://github.com/polkadot-fellows/runtimes/pull/518))

Expand Down
52 changes: 43 additions & 9 deletions system-parachains/coretime/coretime-kusama/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -914,6 +914,7 @@ impl_runtime_apis! {
) -> Result<Vec<frame_benchmarking::BenchmarkBatch>, sp_runtime::RuntimeString> {
use frame_benchmarking::{Benchmarking, BenchmarkBatch, BenchmarkError};
use sp_storage::TrackedStorageKey;
use pallet_broker::CoreMask;

use frame_system_benchmarking::Pallet as SystemBench;
impl frame_system_benchmarking::Config for Runtime {
Expand All @@ -938,15 +939,25 @@ impl_runtime_apis! {
KsmRelayLocation::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<
type DeliveryHelper = (
cumulus_primitives_utility::ToParentDeliveryHelper<
xcm_config::XcmConfig,
ExistentialDepositAsset,
PriceForParentDelivery,
>;
>,
polkadot_runtime_common::xcm_sender::ToParachainDeliveryHelper<
xcm_config::XcmConfig,
ExistentialDepositAsset,
PriceForSiblingParachainDelivery,
RandomParaId,
ParachainSystem,
>
);

fn reachable_dest() -> Option<Location> {
Some(Parent.into())
Expand All @@ -964,8 +975,21 @@ impl_runtime_apis! {
}

fn reserve_transferable_asset_and_dest() -> Option<(Asset, Location)> {
// Reserve transfers are disabled
None
// Coretime chain can reserve transfer regions to some random parachain.

// Properties of a mock region:
let core = 0;
let begin = 0;
let end = 42;

let region_id = pallet_broker::Pallet::<Runtime>::issue(core, begin, CoreMask::complete(), end, None, None);
Some((
Asset {
fun: NonFungible(Index(region_id.into())),
id: AssetId(xcm_config::BrokerPalletLocation::get())
},
ParentThen(Parachain(RandomParaId::get().into()).into()).into(),
))
}

fn get_asset() -> Asset {
Expand All @@ -978,11 +1002,21 @@ impl_runtime_apis! {

impl pallet_xcm_benchmarks::Config for Runtime {
type XcmConfig = xcm_config::XcmConfig;
type DeliveryHelper = cumulus_primitives_utility::ToParentDeliveryHelper<
xcm_config::XcmConfig,
ExistentialDepositAsset,
PriceForParentDelivery,
>;
type DeliveryHelper = (
cumulus_primitives_utility::ToParentDeliveryHelper<
xcm_config::XcmConfig,
ExistentialDepositAsset,
PriceForParentDelivery,
>,
polkadot_runtime_common::xcm_sender::ToParachainDeliveryHelper<
xcm_config::XcmConfig,
ExistentialDepositAsset,
PriceForSiblingParachainDelivery,
RandomParaId,
ParachainSystem,
>
);

type AccountIdConverter = xcm_config::LocationToAccountId;
fn valid_destination() -> Result<Location, BenchmarkError> {
Ok(KsmRelayLocation::get())
Expand Down
51 changes: 42 additions & 9 deletions system-parachains/coretime/coretime-polkadot/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -903,6 +903,7 @@ impl_runtime_apis! {
use frame_benchmarking::{Benchmarking, BenchmarkBatch, BenchmarkError};
use frame_support::traits::WhitelistedStorageKeys;
use sp_storage::TrackedStorageKey;
use pallet_broker::CoreMask;

use frame_system_benchmarking::Pallet as SystemBench;
impl frame_system_benchmarking::Config for Runtime {
Expand All @@ -927,15 +928,25 @@ impl_runtime_apis! {
DotRelayLocation::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<
type DeliveryHelper = (
cumulus_primitives_utility::ToParentDeliveryHelper<
xcm_config::XcmConfig,
ExistentialDepositAsset,
PriceForParentDelivery,
>;
>,
polkadot_runtime_common::xcm_sender::ToParachainDeliveryHelper<
xcm_config::XcmConfig,
ExistentialDepositAsset,
PriceForSiblingParachainDelivery,
RandomParaId,
ParachainSystem,
>
);

fn reachable_dest() -> Option<Location> {
Some(Parent.into())
Expand All @@ -953,8 +964,21 @@ impl_runtime_apis! {
}

fn reserve_transferable_asset_and_dest() -> Option<(Asset, Location)> {
// Reserve transfers are disabled
None
// Coretime chain can reserve transfer regions to some random parachain.

// Properties of a mock region:
let core = 0;
let begin = 0;
let end = 42;

let region_id = pallet_broker::Pallet::<Runtime>::issue(core, begin, CoreMask::complete(), end, None, None);
Some((
Asset {
fun: NonFungible(Index(region_id.into())),
id: AssetId(xcm_config::BrokerPalletLocation::get())
},
ParentThen(Parachain(RandomParaId::get().into()).into()).into(),
))
}

fn get_asset() -> Asset {
Expand All @@ -967,11 +991,20 @@ impl_runtime_apis! {

impl pallet_xcm_benchmarks::Config for Runtime {
type XcmConfig = xcm_config::XcmConfig;
type DeliveryHelper = cumulus_primitives_utility::ToParentDeliveryHelper<
xcm_config::XcmConfig,
ExistentialDepositAsset,
PriceForParentDelivery,
>;
type DeliveryHelper = (
cumulus_primitives_utility::ToParentDeliveryHelper<
xcm_config::XcmConfig,
ExistentialDepositAsset,
PriceForParentDelivery,
>,
polkadot_runtime_common::xcm_sender::ToParachainDeliveryHelper<
xcm_config::XcmConfig,
ExistentialDepositAsset,
PriceForSiblingParachainDelivery,
RandomParaId,
ParachainSystem,
>
);
type AccountIdConverter = xcm_config::LocationToAccountId;
fn valid_destination() -> Result<Location, BenchmarkError> {
Ok(DotRelayLocation::get())
Expand Down

0 comments on commit e2aa32a

Please sign in to comment.