mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-15 18:31:05 +00:00
Migrate parachain swaps to Coretime (#3714)
This PR notifies broker pallet for any parachain slot swaps performed on the relay chain. This is achieved by registering an `OnSwap` for the the `coretime` pallet. The hook sends XCM message to the broker chain and invokes a new extrinsic `swap_leases` which updates `Leases` storage item (which keeps the legacy parachain leases). I made two assumptions in this PR: 1. [`Leases`](https://github.com/paritytech/polkadot-sdk/blob/4987d7982461e2e5ffe219cdf71ec697284cea7c/substrate/frame/broker/src/lib.rs#L120) in `broker` pallet and [`Leases`](https://github.com/paritytech/polkadot-sdk/blob/4987d7982461e2e5ffe219cdf71ec697284cea7c/polkadot/runtime/common/src/slots/mod.rs#L118) in `slots` pallet are in sync. 2. `swap_leases` extrinsic from `broker` pallet can be triggered only by root or by the XCM message from the relay chain. If not - the extrinsic will generate an error and do nothing. As a side effect from the changes `OnSwap` trait is moved from runtime/common/traits.rs to runtime/parachains. Otherwise it is not accessible from `broker` pallet. Closes https://github.com/paritytech/polkadot-sdk/issues/3552 TODOs: - [x] Weights - [x] Tests --------- Co-authored-by: command-bot <> Co-authored-by: eskimor <eskimor@users.noreply.github.com> Co-authored-by: Bastian Köcher <git@kchr.de>
This commit is contained in:
committed by
GitHub
parent
fd79b3b08a
commit
90234543f3
@@ -38,7 +38,7 @@ use runtime_common::{
|
||||
LocatableAssetConverter, ToAuthor, VersionedLocatableAsset, VersionedLocationConverter,
|
||||
},
|
||||
paras_registrar, paras_sudo_wrapper, prod_or_fast, slots,
|
||||
traits::Leaser,
|
||||
traits::{Leaser, OnSwap},
|
||||
BlockHashCount, BlockLength, SlowAdjustingFeeUpdate,
|
||||
};
|
||||
use scale_info::TypeInfo;
|
||||
@@ -1078,7 +1078,7 @@ impl paras_registrar::Config for Runtime {
|
||||
type RuntimeOrigin = RuntimeOrigin;
|
||||
type RuntimeEvent = RuntimeEvent;
|
||||
type Currency = Balances;
|
||||
type OnSwap = (Crowdloan, Slots);
|
||||
type OnSwap = (Crowdloan, Slots, SwapLeases);
|
||||
type ParaDeposit = ParaDeposit;
|
||||
type DataDepositPerByte = DataDepositPerByte;
|
||||
type WeightInfo = weights::runtime_common_paras_registrar::WeightInfo<Runtime>;
|
||||
@@ -1306,6 +1306,14 @@ impl pallet_asset_rate::Config for Runtime {
|
||||
type BenchmarkHelper = runtime_common::impls::benchmarks::AssetRateArguments;
|
||||
}
|
||||
|
||||
// Notify `coretime` pallet when a lease swap occurs
|
||||
pub struct SwapLeases;
|
||||
impl OnSwap for SwapLeases {
|
||||
fn on_swap(one: ParaId, other: ParaId) {
|
||||
coretime::Pallet::<Runtime>::on_legacy_lease_swap(one, other);
|
||||
}
|
||||
}
|
||||
|
||||
construct_runtime! {
|
||||
pub enum Runtime
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user