mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-05-30 22:11:02 +00:00
Moves Block to frame_system instead of construct_runtime and removes Header and BlockNumber (#7431)
* Companion for substrate * Minor update * Formatting * Fixes for cumulus * Fixes tests in polkadot-runtime-parachains * Minor update * Removes unused import * Fixes tests in polkadot-runtime-common * Minor fix * Update roadmap/implementers-guide/src/runtime/configuration.md Co-authored-by: ordian <write@reusable.software> * ".git/.scripts/commands/fmt/fmt.sh" * update lockfile for {"substrate"} --------- Co-authored-by: ordian <write@reusable.software> Co-authored-by: command-bot <>
This commit is contained in:
@@ -36,6 +36,7 @@
|
||||
//! over time.
|
||||
|
||||
use frame_support::pallet_prelude::*;
|
||||
use frame_system::pallet_prelude::BlockNumberFor;
|
||||
use primitives::{
|
||||
CollatorId, CoreIndex, CoreOccupied, GroupIndex, GroupRotationInfo, Id as ParaId,
|
||||
ParathreadClaim, ParathreadEntry, ScheduledCore, ValidatorIndex,
|
||||
@@ -208,7 +209,7 @@ pub mod pallet {
|
||||
/// block following the session change, block number of which we save in this storage value.
|
||||
#[pallet::storage]
|
||||
#[pallet::getter(fn session_start_block)]
|
||||
pub(crate) type SessionStartBlock<T: Config> = StorageValue<_, T::BlockNumber, ValueQuery>;
|
||||
pub(crate) type SessionStartBlock<T: Config> = StorageValue<_, BlockNumberFor<T>, ValueQuery>;
|
||||
|
||||
/// Currently scheduled cores - free but up to be occupied.
|
||||
///
|
||||
@@ -224,7 +225,7 @@ pub mod pallet {
|
||||
|
||||
impl<T: Config> Pallet<T> {
|
||||
/// Called by the initializer to initialize the scheduler pallet.
|
||||
pub(crate) fn initializer_initialize(_now: T::BlockNumber) -> Weight {
|
||||
pub(crate) fn initializer_initialize(_now: BlockNumberFor<T>) -> Weight {
|
||||
Weight::zero()
|
||||
}
|
||||
|
||||
@@ -233,7 +234,7 @@ impl<T: Config> Pallet<T> {
|
||||
|
||||
/// Called by the initializer to note that a new session has started.
|
||||
pub(crate) fn initializer_on_new_session(
|
||||
notification: &SessionChangeNotification<T::BlockNumber>,
|
||||
notification: &SessionChangeNotification<BlockNumberFor<T>>,
|
||||
) {
|
||||
let SessionChangeNotification { validators, new_config, .. } = notification;
|
||||
let config = new_config;
|
||||
@@ -421,7 +422,7 @@ impl<T: Config> Pallet<T> {
|
||||
/// ascending order by core index.
|
||||
pub(crate) fn schedule(
|
||||
just_freed_cores: impl IntoIterator<Item = (CoreIndex, FreedReason)>,
|
||||
now: T::BlockNumber,
|
||||
now: BlockNumberFor<T>,
|
||||
) {
|
||||
Self::free_cores(just_freed_cores);
|
||||
|
||||
@@ -590,7 +591,7 @@ impl<T: Config> Pallet<T> {
|
||||
/// or the block number is less than the session start index.
|
||||
pub(crate) fn group_assigned_to_core(
|
||||
core: CoreIndex,
|
||||
at: T::BlockNumber,
|
||||
at: BlockNumberFor<T>,
|
||||
) -> Option<GroupIndex> {
|
||||
let config = <configuration::Pallet<T>>::config();
|
||||
let session_start_block = <SessionStartBlock<T>>::get();
|
||||
@@ -605,11 +606,12 @@ impl<T: Config> Pallet<T> {
|
||||
return None
|
||||
}
|
||||
|
||||
let rotations_since_session_start: T::BlockNumber =
|
||||
let rotations_since_session_start: BlockNumberFor<T> =
|
||||
(at - session_start_block) / config.group_rotation_frequency.into();
|
||||
|
||||
let rotations_since_session_start =
|
||||
<T::BlockNumber as TryInto<u32>>::try_into(rotations_since_session_start).unwrap_or(0);
|
||||
<BlockNumberFor<T> as TryInto<u32>>::try_into(rotations_since_session_start)
|
||||
.unwrap_or(0);
|
||||
// Error case can only happen if rotations occur only once every u32::max(),
|
||||
// so functionally no difference in behavior.
|
||||
|
||||
@@ -629,7 +631,7 @@ impl<T: Config> Pallet<T> {
|
||||
/// https://github.com/rust-lang/rust/issues/73226
|
||||
/// which prevents us from testing the code if using `impl Trait`.
|
||||
pub(crate) fn availability_timeout_predicate(
|
||||
) -> Option<Box<dyn Fn(CoreIndex, T::BlockNumber) -> bool>> {
|
||||
) -> Option<Box<dyn Fn(CoreIndex, BlockNumberFor<T>) -> bool>> {
|
||||
let now = <frame_system::Pallet<T>>::block_number();
|
||||
let config = <configuration::Pallet<T>>::config();
|
||||
|
||||
@@ -670,7 +672,9 @@ impl<T: Config> Pallet<T> {
|
||||
}
|
||||
|
||||
/// Returns a helper for determining group rotation.
|
||||
pub(crate) fn group_rotation_info(now: T::BlockNumber) -> GroupRotationInfo<T::BlockNumber> {
|
||||
pub(crate) fn group_rotation_info(
|
||||
now: BlockNumberFor<T>,
|
||||
) -> GroupRotationInfo<BlockNumberFor<T>> {
|
||||
let session_start_block = Self::session_start_block();
|
||||
let group_rotation_frequency =
|
||||
<configuration::Pallet<T>>::config().group_rotation_frequency;
|
||||
|
||||
Reference in New Issue
Block a user