mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-13 18:41:05 +00:00
Coretime Feature branch (relay chain) (#1694)
Also fixes: https://github.com/paritytech/polkadot-sdk/issues/1417 - [x] CoreIndex -> AssignmentProvider mapping will be able to change any time. - [x] Implement - [x] Provide Migrations - [x] Add and fix tests - [x] Implement bulk assigner logic - [x] bulk assigner tests - [x] Port over current assigner to use bulk designer (+ share on-demand with bulk): top-level assigner has core ranges: legacy, bulk - [x] Adjust migrations to reflect new assigner structure - [x] Move migration code to Assignment code directly and make it recursive (make it possible to skip releases) -> follow up ticket. - [x] Test migrations - [x] Add migration PR to runtimes repo -> follow up ticket. - [x] Wire up with actual UMP messages - [x] Write PR docs --------- Co-authored-by: eskimor <eskimor@no-such-url.com> Co-authored-by: Bradley Olson <34992650+BradleyOlson64@users.noreply.github.com> Co-authored-by: BradleyOlson64 <lotrftw9@gmail.com> Co-authored-by: Anton Vilhelm Ásgeirsson <antonva@users.noreply.github.com> Co-authored-by: antonva <anton.asgeirsson@parity.io> Co-authored-by: Bastian Köcher <git@kchr.de> Co-authored-by: Marcin S. <marcin@realemail.net> Co-authored-by: Bastian Köcher <info@kchr.de> Co-authored-by: command-bot <>
This commit is contained in:
@@ -31,6 +31,7 @@ use primitives::{
|
||||
OccupiedCoreAssumption, PersistedValidationData, ScrapedOnChainVotes, SessionInfo, Signature,
|
||||
ValidationCode, ValidationCodeHash, ValidatorId, ValidatorIndex, PARACHAIN_KEY_TYPE_ID,
|
||||
};
|
||||
use rococo_runtime_constants::system_parachain::BROKER_ID;
|
||||
use runtime_common::{
|
||||
assigned_slots, auctions, claims, crowdloan, identity_migrator, impl_runtime_weights,
|
||||
impls::{
|
||||
@@ -43,9 +44,10 @@ use scale_info::TypeInfo;
|
||||
use sp_std::{cmp::Ordering, collections::btree_map::BTreeMap, prelude::*};
|
||||
|
||||
use runtime_parachains::{
|
||||
assigner as parachains_assigner, assigner_on_demand as parachains_assigner_on_demand,
|
||||
assigner_coretime as parachains_assigner_coretime,
|
||||
assigner_on_demand as parachains_assigner_on_demand,
|
||||
assigner_parachains as parachains_assigner_parachains,
|
||||
configuration as parachains_configuration, disputes as parachains_disputes,
|
||||
configuration as parachains_configuration, coretime, disputes as parachains_disputes,
|
||||
disputes::slashing as parachains_slashing,
|
||||
dmp as parachains_dmp, hrmp as parachains_hrmp, inclusion as parachains_inclusion,
|
||||
inclusion::{AggregateMessageOrigin, UmpQueueId},
|
||||
@@ -150,7 +152,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion {
|
||||
spec_name: create_runtime_str!("rococo"),
|
||||
impl_name: create_runtime_str!("parity-rococo-v2.0"),
|
||||
authoring_version: 0,
|
||||
spec_version: 1_005_000,
|
||||
spec_version: 1_005_001,
|
||||
impl_version: 0,
|
||||
apis: RUNTIME_API_VERSIONS,
|
||||
transaction_version: 24,
|
||||
@@ -935,6 +937,7 @@ impl parachains_paras::Config for Runtime {
|
||||
type QueueFootprinter = ParaInclusion;
|
||||
type NextSessionRotation = Babe;
|
||||
type OnNewHead = Registrar;
|
||||
type AssignCoretime = CoretimeAssignmentProvider;
|
||||
}
|
||||
|
||||
parameter_types! {
|
||||
@@ -1001,7 +1004,22 @@ impl parachains_paras_inherent::Config for Runtime {
|
||||
}
|
||||
|
||||
impl parachains_scheduler::Config for Runtime {
|
||||
type AssignmentProvider = ParaAssignmentProvider;
|
||||
// If you change this, make sure the `Assignment` type of the new provider is binary compatible,
|
||||
// otherwise provide a migration.
|
||||
type AssignmentProvider = CoretimeAssignmentProvider;
|
||||
}
|
||||
|
||||
parameter_types! {
|
||||
pub const BrokerId: u32 = BROKER_ID;
|
||||
}
|
||||
|
||||
impl coretime::Config for Runtime {
|
||||
type RuntimeOrigin = RuntimeOrigin;
|
||||
type RuntimeEvent = RuntimeEvent;
|
||||
type Currency = Balances;
|
||||
type BrokerId = BrokerId;
|
||||
type WeightInfo = weights::runtime_parachains_coretime::WeightInfo<Runtime>;
|
||||
type SendXcm = crate::xcm_config::XcmRouter;
|
||||
}
|
||||
|
||||
parameter_types! {
|
||||
@@ -1017,15 +1035,13 @@ impl parachains_assigner_on_demand::Config for Runtime {
|
||||
|
||||
impl parachains_assigner_parachains::Config for Runtime {}
|
||||
|
||||
impl parachains_assigner::Config for Runtime {
|
||||
type OnDemandAssignmentProvider = OnDemandAssignmentProvider;
|
||||
type ParachainsAssignmentProvider = ParachainsAssignmentProvider;
|
||||
}
|
||||
impl parachains_assigner_coretime::Config for Runtime {}
|
||||
|
||||
impl parachains_initializer::Config for Runtime {
|
||||
type Randomness = pallet_babe::RandomnessFromOneEpochAgo<Runtime>;
|
||||
type ForceOrigin = EnsureRoot<AccountId>;
|
||||
type WeightInfo = weights::runtime_parachains_initializer::WeightInfo<Runtime>;
|
||||
type CoretimeOnNewSession = Coretime;
|
||||
}
|
||||
|
||||
impl parachains_disputes::Config for Runtime {
|
||||
@@ -1405,15 +1421,16 @@ construct_runtime! {
|
||||
ParasDisputes: parachains_disputes::{Pallet, Call, Storage, Event<T>} = 62,
|
||||
ParasSlashing: parachains_slashing::{Pallet, Call, Storage, ValidateUnsigned} = 63,
|
||||
MessageQueue: pallet_message_queue::{Pallet, Call, Storage, Event<T>} = 64,
|
||||
ParaAssignmentProvider: parachains_assigner::{Pallet, Storage} = 65,
|
||||
OnDemandAssignmentProvider: parachains_assigner_on_demand::{Pallet, Call, Storage, Event<T>} = 66,
|
||||
ParachainsAssignmentProvider: parachains_assigner_parachains::{Pallet} = 67,
|
||||
CoretimeAssignmentProvider: parachains_assigner_coretime::{Pallet, Storage} = 68,
|
||||
|
||||
// Parachain Onboarding Pallets. Start indices at 70 to leave room.
|
||||
Registrar: paras_registrar::{Pallet, Call, Storage, Event<T>, Config<T>} = 70,
|
||||
Slots: slots::{Pallet, Call, Storage, Event<T>} = 71,
|
||||
Auctions: auctions::{Pallet, Call, Storage, Event<T>} = 72,
|
||||
Crowdloan: crowdloan::{Pallet, Call, Storage, Event<T>} = 73,
|
||||
Coretime: coretime::{Pallet, Call, Event<T>} = 74,
|
||||
|
||||
// Pallet for sending XCM.
|
||||
XcmPallet: pallet_xcm::{Pallet, Call, Storage, Event<T>, Origin, Config<T>} = 99,
|
||||
@@ -1477,9 +1494,39 @@ pub mod migrations {
|
||||
|
||||
use frame_support::traits::LockIdentifier;
|
||||
use frame_system::pallet_prelude::BlockNumberFor;
|
||||
use sp_arithmetic::traits::Zero;
|
||||
#[cfg(feature = "try-runtime")]
|
||||
use sp_core::crypto::ByteArray;
|
||||
|
||||
pub struct GetLegacyLeaseImpl;
|
||||
impl coretime::migration::GetLegacyLease<BlockNumber> for GetLegacyLeaseImpl {
|
||||
fn get_parachain_lease_in_blocks(para: ParaId) -> Option<BlockNumber> {
|
||||
let now = frame_system::Pallet::<Runtime>::block_number();
|
||||
let mut leases = slots::Pallet::<Runtime>::lease(para).into_iter();
|
||||
let initial_sum = if let Some(Some(_)) = leases.next() {
|
||||
let (_, progress) =
|
||||
slots::Pallet::<Runtime>::lease_period_index_plus_progress(now)?;
|
||||
LeasePeriod::get().saturating_sub(progress)
|
||||
} else {
|
||||
// The parachain lease did not yet start
|
||||
Zero::zero()
|
||||
};
|
||||
log::trace!(
|
||||
target: "coretime-migration",
|
||||
"Getting lease info for para {:?}:\n LEASE_PERIOD: {:?}, initial_sum: {:?}, number of leases: {:?}",
|
||||
para,
|
||||
LeasePeriod::get(),
|
||||
initial_sum,
|
||||
slots::Pallet::<Runtime>::lease(para).len(),
|
||||
);
|
||||
|
||||
Some(leases.into_iter().fold(initial_sum, |sum, lease| {
|
||||
// If the parachain lease did not yet start, we ignore them by multiplying by `0`.
|
||||
sum + LeasePeriod::get() * lease.map_or(0, |_| 1)
|
||||
}))
|
||||
}
|
||||
}
|
||||
|
||||
parameter_types! {
|
||||
pub const DemocracyPalletName: &'static str = "Democracy";
|
||||
pub const CouncilPalletName: &'static str = "Council";
|
||||
@@ -1602,7 +1649,7 @@ pub mod migrations {
|
||||
pallet_society::migrations::MigrateToV2<Runtime, (), ()>,
|
||||
parachains_configuration::migration::v7::MigrateToV7<Runtime>,
|
||||
assigned_slots::migration::v1::MigrateToV1<Runtime>,
|
||||
parachains_scheduler::migration::v1::MigrateToV1<Runtime>,
|
||||
parachains_scheduler::migration::MigrateV1ToV2<Runtime>,
|
||||
parachains_configuration::migration::v8::MigrateToV8<Runtime>,
|
||||
parachains_configuration::migration::v9::MigrateToV9<Runtime>,
|
||||
paras_registrar::migration::MigrateToV1<Runtime, ()>,
|
||||
@@ -1633,6 +1680,8 @@ pub mod migrations {
|
||||
// Remove `im-online` pallet on-chain storage
|
||||
frame_support::migrations::RemovePallet<ImOnlinePalletName, <Runtime as frame_system::Config>::DbWeight>,
|
||||
parachains_configuration::migration::v11::MigrateToV11<Runtime>,
|
||||
// This needs to come after the `parachains_configuration` above as we are reading the configuration.
|
||||
coretime::migration::MigrateToCoretime<Runtime, crate::xcm_config::XcmRouter, GetLegacyLeaseImpl>,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1681,6 +1730,7 @@ mod benches {
|
||||
// the that path resolves correctly in the generated file.
|
||||
[runtime_common::assigned_slots, AssignedSlots]
|
||||
[runtime_common::auctions, Auctions]
|
||||
[runtime_common::coretime, Coretime]
|
||||
[runtime_common::crowdloan, Crowdloan]
|
||||
[runtime_common::claims, Claims]
|
||||
[runtime_common::identity_migrator, IdentityMigrator]
|
||||
|
||||
@@ -51,6 +51,7 @@ pub mod runtime_common_paras_registrar;
|
||||
pub mod runtime_common_slots;
|
||||
pub mod runtime_parachains_assigner_on_demand;
|
||||
pub mod runtime_parachains_configuration;
|
||||
pub mod runtime_parachains_coretime;
|
||||
pub mod runtime_parachains_disputes;
|
||||
pub mod runtime_parachains_hrmp;
|
||||
pub mod runtime_parachains_inclusion;
|
||||
|
||||
@@ -0,0 +1,73 @@
|
||||
// Copyright (C) Parity Technologies (UK) Ltd.
|
||||
// This file is part of Polkadot.
|
||||
|
||||
// Polkadot is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
|
||||
// Polkadot is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Polkadot. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
//! Autogenerated weights for `runtime_parachains::coretime`
|
||||
//!
|
||||
//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev
|
||||
//! DATE: 2023-12-01, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]`
|
||||
//! WORST CASE MAP SIZE: `1000000`
|
||||
//! HOSTNAME: `runner-r43aesjn-project-674-concurrent-0`, CPU: `Intel(R) Xeon(R) CPU @ 2.60GHz`
|
||||
//! WASM-EXECUTION: `Compiled`, CHAIN: `Some("rococo-dev")`, DB CACHE: 1024
|
||||
|
||||
// Executed Command:
|
||||
// target/production/polkadot
|
||||
// benchmark
|
||||
// pallet
|
||||
// --steps=50
|
||||
// --repeat=20
|
||||
// --extrinsic=*
|
||||
// --wasm-execution=compiled
|
||||
// --heap-pages=4096
|
||||
// --json-file=/builds/parity/mirrors/polkadot-sdk/.git/.artifacts/bench.json
|
||||
// --pallet=runtime_common::coretime
|
||||
// --chain=rococo-dev
|
||||
// --header=./polkadot/file_header.txt
|
||||
// --output=./polkadot/runtime/rococo/src/weights/
|
||||
|
||||
#![cfg_attr(rustfmt, rustfmt_skip)]
|
||||
#![allow(unused_parens)]
|
||||
#![allow(unused_imports)]
|
||||
#![allow(missing_docs)]
|
||||
|
||||
use frame_support::{traits::Get, weights::Weight};
|
||||
use core::marker::PhantomData;
|
||||
|
||||
use runtime_parachains::configuration::{self, WeightInfo as ConfigWeightInfo};
|
||||
|
||||
/// Weight functions for `runtime_common::coretime`.
|
||||
pub struct WeightInfo<T>(PhantomData<T>);
|
||||
impl<T: frame_system::Config + configuration::Config> runtime_parachains::coretime::WeightInfo for WeightInfo<T> {
|
||||
fn request_core_count() -> Weight {
|
||||
<T as configuration::Config>::WeightInfo::set_config_with_u32()
|
||||
}
|
||||
/// Storage: `CoreTimeAssignmentProvider::CoreDescriptors` (r:1 w:1)
|
||||
/// Proof: `CoreTimeAssignmentProvider::CoreDescriptors` (`max_values`: None, `max_size`: None, mode: `Measured`)
|
||||
/// Storage: `CoreTimeAssignmentProvider::CoreSchedules` (r:0 w:1)
|
||||
/// Proof: `CoreTimeAssignmentProvider::CoreSchedules` (`max_values`: None, `max_size`: None, mode: `Measured`)
|
||||
/// The range of component `s` is `[1, 100]`.
|
||||
fn assign_core(s: u32, ) -> Weight {
|
||||
// Proof Size summary in bytes:
|
||||
// Measured: `76`
|
||||
// Estimated: `3541`
|
||||
// Minimum execution time: 6_275_000 picoseconds.
|
||||
Weight::from_parts(6_883_543, 0)
|
||||
.saturating_add(Weight::from_parts(0, 3541))
|
||||
// Standard Error: 202
|
||||
.saturating_add(Weight::from_parts(15_028, 0).saturating_mul(s.into()))
|
||||
.saturating_add(T::DbWeight::get().reads(1))
|
||||
.saturating_add(T::DbWeight::get().writes(2))
|
||||
}
|
||||
}
|
||||
@@ -120,6 +120,7 @@ parameter_types! {
|
||||
pub const Contracts: MultiLocation = Parachain(CONTRACTS_ID).into_location();
|
||||
pub const Encointer: MultiLocation = Parachain(ENCOINTER_ID).into_location();
|
||||
pub const BridgeHub: MultiLocation = Parachain(BRIDGE_HUB_ID).into_location();
|
||||
pub const Broker: MultiLocation = Parachain(BROKER_ID).into_location();
|
||||
pub const Tick: MultiLocation = Parachain(100).into_location();
|
||||
pub const Trick: MultiLocation = Parachain(110).into_location();
|
||||
pub const Track: MultiLocation = Parachain(120).into_location();
|
||||
@@ -130,6 +131,7 @@ parameter_types! {
|
||||
pub const RocForContracts: (MultiAssetFilter, MultiLocation) = (Roc::get(), Contracts::get());
|
||||
pub const RocForEncointer: (MultiAssetFilter, MultiLocation) = (Roc::get(), Encointer::get());
|
||||
pub const RocForBridgeHub: (MultiAssetFilter, MultiLocation) = (Roc::get(), BridgeHub::get());
|
||||
pub const RocForBroker: (MultiAssetFilter, MultiLocation) = (Roc::get(), Broker::get());
|
||||
pub const MaxInstructions: u32 = 100;
|
||||
pub const MaxAssetsIntoHolding: u32 = 64;
|
||||
}
|
||||
@@ -141,6 +143,7 @@ pub type TrustedTeleporters = (
|
||||
xcm_builder::Case<RocForContracts>,
|
||||
xcm_builder::Case<RocForEncointer>,
|
||||
xcm_builder::Case<RocForBridgeHub>,
|
||||
xcm_builder::Case<RocForBroker>,
|
||||
);
|
||||
|
||||
match_types! {
|
||||
|
||||
Reference in New Issue
Block a user