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
+10 -9
View File
@@ -22,6 +22,7 @@ use crate::{
};
use bitvec::{order::Lsb0 as BitOrderLsb0, vec::BitVec};
use frame_support::pallet_prelude::*;
use frame_system::pallet_prelude::*;
use primitives::{
collator_signature_payload, AvailabilityBitfield, BackedCandidate, CandidateCommitments,
CandidateDescriptor, CandidateHash, CollatorId, CollatorSignature, CommittedCandidateReceipt,
@@ -69,7 +70,7 @@ pub(crate) struct BenchBuilder<T: paras_inherent::Config> {
/// Active validators. Validators should be declared prior to all other setup.
validators: Option<IndexedVec<ValidatorIndex, ValidatorId>>,
/// Starting block number; we expect it to get incremented on session setup.
block_number: T::BlockNumber,
block_number: BlockNumberFor<T>,
/// Starting session; we expect it to get incremented on session setup.
session: SessionIndex,
/// Session we want the scenario to take place in. We will roll to this session.
@@ -97,9 +98,9 @@ pub(crate) struct BenchBuilder<T: paras_inherent::Config> {
/// Paras inherent `enter` benchmark scenario.
#[cfg(any(feature = "runtime-benchmarks", test))]
pub(crate) struct Bench<T: paras_inherent::Config> {
pub(crate) data: ParachainsInherentData<T::Header>,
pub(crate) data: ParachainsInherentData<HeaderFor<T>>,
pub(crate) _session: u32,
pub(crate) _block_number: T::BlockNumber,
pub(crate) _block_number: BlockNumberFor<T>,
}
impl<T: paras_inherent::Config> BenchBuilder<T> {
@@ -150,8 +151,8 @@ impl<T: paras_inherent::Config> BenchBuilder<T> {
}
/// Mock header.
pub(crate) fn header(block_number: T::BlockNumber) -> T::Header {
T::Header::new(
pub(crate) fn header(block_number: BlockNumberFor<T>) -> HeaderFor<T> {
HeaderFor::<T>::new(
block_number, // `block_number`,
Default::default(), // `extrinsics_root`,
Default::default(), // `storage_root`,
@@ -260,8 +261,8 @@ impl<T: paras_inherent::Config> BenchBuilder<T> {
core_idx: CoreIndex,
candidate_hash: CandidateHash,
availability_votes: BitVec<u8, BitOrderLsb0>,
) -> inclusion::CandidatePendingAvailability<T::Hash, T::BlockNumber> {
inclusion::CandidatePendingAvailability::<T::Hash, T::BlockNumber>::new(
) -> inclusion::CandidatePendingAvailability<T::Hash, BlockNumberFor<T>> {
inclusion::CandidatePendingAvailability::<T::Hash, BlockNumberFor<T>>::new(
core_idx, // core
candidate_hash, // hash
Self::candidate_descriptor_mock(), // candidate descriptor
@@ -405,7 +406,7 @@ impl<T: paras_inherent::Config> BenchBuilder<T> {
Self::run_to_block(block);
}
let block_number = <T as frame_system::Config>::BlockNumber::from(block);
let block_number = BlockNumberFor::<T>::from(block);
let header = Self::header(block_number.clone());
frame_system::Pallet::<T>::reset_events();
@@ -523,7 +524,7 @@ impl<T: paras_inherent::Config> BenchBuilder<T> {
// candidate receipt.
paras::Pallet::<T>::heads_insert(&para_id, head_data.clone());
let mut past_code_meta = paras::ParaPastCodeMeta::<T::BlockNumber>::default();
let mut past_code_meta = paras::ParaPastCodeMeta::<BlockNumberFor<T>>::default();
past_code_meta.note_replacement(0u32.into(), 0u32.into());
let group_validators = scheduler::Pallet::<T>::group_validators(group_idx).unwrap();