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:
gupnik
2023-07-13 18:07:50 +05:30
committed by GitHub
parent bfaec080cc
commit 2802414473
47 changed files with 562 additions and 643 deletions
@@ -503,7 +503,7 @@ pub mod pallet {
#[pallet::storage]
#[pallet::getter(fn config)]
pub(crate) type ActiveConfig<T: Config> =
StorageValue<_, HostConfiguration<T::BlockNumber>, ValueQuery>;
StorageValue<_, HostConfiguration<BlockNumberFor<T>>, ValueQuery>;
/// Pending configuration changes.
///
@@ -514,7 +514,7 @@ pub mod pallet {
/// 2 items: for the next session and for the `scheduled_session`.
#[pallet::storage]
pub(crate) type PendingConfigs<T: Config> =
StorageValue<_, Vec<(SessionIndex, HostConfiguration<T::BlockNumber>)>, ValueQuery>;
StorageValue<_, Vec<(SessionIndex, HostConfiguration<BlockNumberFor<T>>)>, ValueQuery>;
/// If this is set, then the configuration setters will bypass the consistency checks. This
/// is meant to be used only as the last resort.
@@ -524,7 +524,7 @@ pub mod pallet {
#[pallet::genesis_config]
#[derive(DefaultNoBound)]
pub struct GenesisConfig<T: Config> {
pub config: HostConfiguration<T::BlockNumber>,
pub config: HostConfiguration<BlockNumberFor<T>>,
}
#[pallet::genesis_build]
@@ -545,7 +545,7 @@ pub mod pallet {
))]
pub fn set_validation_upgrade_cooldown(
origin: OriginFor<T>,
new: T::BlockNumber,
new: BlockNumberFor<T>,
) -> DispatchResult {
ensure_root(origin)?;
Self::schedule_config_update(|config| {
@@ -561,7 +561,7 @@ pub mod pallet {
))]
pub fn set_validation_upgrade_delay(
origin: OriginFor<T>,
new: T::BlockNumber,
new: BlockNumberFor<T>,
) -> DispatchResult {
ensure_root(origin)?;
Self::schedule_config_update(|config| {
@@ -577,7 +577,7 @@ pub mod pallet {
))]
pub fn set_code_retention_period(
origin: OriginFor<T>,
new: T::BlockNumber,
new: BlockNumberFor<T>,
) -> DispatchResult {
ensure_root(origin)?;
Self::schedule_config_update(|config| {
@@ -658,7 +658,7 @@ pub mod pallet {
))]
pub fn set_group_rotation_frequency(
origin: OriginFor<T>,
new: T::BlockNumber,
new: BlockNumberFor<T>,
) -> DispatchResult {
ensure_root(origin)?;
Self::schedule_config_update(|config| {
@@ -674,7 +674,7 @@ pub mod pallet {
))]
pub fn set_chain_availability_period(
origin: OriginFor<T>,
new: T::BlockNumber,
new: BlockNumberFor<T>,
) -> DispatchResult {
ensure_root(origin)?;
Self::schedule_config_update(|config| {
@@ -690,7 +690,7 @@ pub mod pallet {
))]
pub fn set_thread_availability_period(
origin: OriginFor<T>,
new: T::BlockNumber,
new: BlockNumberFor<T>,
) -> DispatchResult {
ensure_root(origin)?;
Self::schedule_config_update(|config| {
@@ -761,7 +761,7 @@ pub mod pallet {
))]
pub fn set_dispute_post_conclusion_acceptance_period(
origin: OriginFor<T>,
new: T::BlockNumber,
new: BlockNumberFor<T>,
) -> DispatchResult {
ensure_root(origin)?;
Self::schedule_config_update(|config| {
@@ -1087,7 +1087,7 @@ pub mod pallet {
))]
pub fn set_minimum_validation_upgrade_delay(
origin: OriginFor<T>,
new: T::BlockNumber,
new: BlockNumberFor<T>,
) -> DispatchResult {
ensure_root(origin)?;
Self::schedule_config_update(|config| {
@@ -1162,7 +1162,7 @@ pub struct SessionChangeOutcome<BlockNumber> {
impl<T: Config> Pallet<T> {
/// Called by the initializer to initialize the configuration pallet.
pub(crate) fn initializer_initialize(_now: T::BlockNumber) -> Weight {
pub(crate) fn initializer_initialize(_now: BlockNumberFor<T>) -> Weight {
Weight::zero()
}
@@ -1176,7 +1176,7 @@ impl<T: Config> Pallet<T> {
/// be the same.
pub(crate) fn initializer_on_new_session(
session_index: &SessionIndex,
) -> SessionChangeOutcome<T::BlockNumber> {
) -> SessionChangeOutcome<BlockNumberFor<T>> {
let pending_configs = <PendingConfigs<T>>::get();
let prev_config = ActiveConfig::<T>::get();
@@ -1217,7 +1217,7 @@ impl<T: Config> Pallet<T> {
/// Forcibly set the active config. This should be used with extreme care, and typically
/// only when enabling parachains runtime pallets for the first time on a chain which has
/// been running without them.
pub fn force_set_active_config(config: HostConfiguration<T::BlockNumber>) {
pub fn force_set_active_config(config: HostConfiguration<BlockNumberFor<T>>) {
ActiveConfig::<T>::set(config);
}
@@ -1237,7 +1237,7 @@ impl<T: Config> Pallet<T> {
// the sake of essentially avoiding an indirect call. Doesn't worth it.
#[inline(never)]
pub(crate) fn schedule_config_update(
updater: impl FnOnce(&mut HostConfiguration<T::BlockNumber>),
updater: impl FnOnce(&mut HostConfiguration<BlockNumberFor<T>>),
) -> DispatchResult {
let mut pending_configs = <PendingConfigs<T>>::get();