Moves Block to frame_system instead of construct_runtime and removes Header and BlockNumber (#2790)

* Fixes

* Removes unused import

* Uses Block and removes BlockNumber/Header from Chain

* Fixes bridges

* Fixes

* Removes unused import

* Fixes build

* Uses correct RelayBlock

* Minor fix

* Fixes glutton-kusama

* Uses correct RelayBlock

* Minor fix

* Fixes benchmark for pallet-bridge-parachains

* Adds appropriate constraints

* Minor fixes

* Removes unused import

* Fixes integrity tests

* Minor fixes

* Updates trait bounds

* Uses custom bound for AsPrimitive

* Fixes trait bounds

* Revert "Fixes trait bounds"

This reverts commit 0b0f42f583f3a616a88afe45fcd06d31e7d9a06f.

* Revert "Uses custom bound for AsPrimitive"

This reverts commit 838e5281adf8b6e9632a2abb9cd550db4ae24126.

* No AsPrimitive trait bound for now

* Removes bounds on Number

* update lockfile for {"substrate", "polkadot"}

* Formatting

* ".git/.scripts/commands/fmt/fmt.sh"

* Minor fix

---------

Co-authored-by: parity-processbot <>
This commit is contained in:
gupnik
2023-07-13 19:00:28 +05:30
committed by GitHub
parent 49145bdd9b
commit 24d6e46ad0
54 changed files with 449 additions and 633 deletions
@@ -28,7 +28,7 @@ use frame_support::{
dispatch::DispatchResult,
traits::{Currency, EnsureOrigin, Get, ReservableCurrency},
};
use frame_system::{EventRecord, RawOrigin};
use frame_system::{pallet_prelude::BlockNumberFor, EventRecord, RawOrigin};
use pallet_authorship::EventHandler;
use pallet_session::{self as session, SessionManager};
use sp_std::prelude::*;
@@ -289,7 +289,7 @@ benchmarks! {
T::Currency::minimum_balance() * 4u32.into(),
);
let author = account("author", 0, SEED);
let new_block: T::BlockNumber = 10u32.into();
let new_block: BlockNumberFor<T> = 10u32.into();
frame_system::Pallet::<T>::set_block_number(new_block);
assert!(T::Currency::free_balance(&author) == 0u32.into());
@@ -312,8 +312,8 @@ benchmarks! {
register_validators::<T>(c);
register_candidates::<T>(c);
let new_block: T::BlockNumber = 1800u32.into();
let zero_block: T::BlockNumber = 0u32.into();
let new_block: BlockNumberFor<T> = 1800u32.into();
let zero_block: BlockNumberFor<T> = 0u32.into();
let candidates = <Candidates<T>>::get();
let non_removals = c.saturating_sub(r);
@@ -143,7 +143,7 @@ pub mod pallet {
type MaxInvulnerables: Get<u32>;
// Will be kicked if block is not produced in threshold.
type KickThreshold: Get<Self::BlockNumber>;
type KickThreshold: Get<BlockNumberFor<Self>>;
/// A stable ID for a validator.
type ValidatorId: Member + Parameter;
@@ -195,7 +195,7 @@ pub mod pallet {
#[pallet::storage]
#[pallet::getter(fn last_authored_block)]
pub type LastAuthoredBlock<T: Config> =
StorageMap<_, Twox64Concat, T::AccountId, T::BlockNumber, ValueQuery>;
StorageMap<_, Twox64Concat, T::AccountId, BlockNumberFor<T>, ValueQuery>;
/// Desired number of candidates.
///
@@ -648,7 +648,7 @@ pub mod pallet {
/// Keep track of number of authored blocks per authority, uncles are counted as well since
/// they're a valid proof of being online.
impl<T: Config + pallet_authorship::Config>
pallet_authorship::EventHandler<T::AccountId, T::BlockNumber> for Pallet<T>
pallet_authorship::EventHandler<T::AccountId, BlockNumberFor<T>> for Pallet<T>
{
fn note_author(author: T::AccountId) {
let pot = Self::account_id();
@@ -24,20 +24,16 @@ use frame_system as system;
use frame_system::EnsureSignedBy;
use sp_core::H256;
use sp_runtime::{
testing::{Header, UintAuthorityId},
testing::UintAuthorityId,
traits::{BlakeTwo256, IdentityLookup, OpaqueKeys},
BuildStorage, RuntimeAppPublic,
};
type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic<Test>;
type Block = frame_system::mocking::MockBlock<Test>;
// Configure a mock runtime to test the pallet.
frame_support::construct_runtime!(
pub enum Test where
Block = Block,
NodeBlock = Block,
UncheckedExtrinsic = UncheckedExtrinsic,
pub enum Test
{
System: frame_system,
Timestamp: pallet_timestamp,
@@ -62,12 +58,11 @@ impl system::Config for Test {
type RuntimeOrigin = RuntimeOrigin;
type RuntimeCall = RuntimeCall;
type Index = u64;
type BlockNumber = u64;
type Hash = H256;
type Hashing = BlakeTwo256;
type AccountId = u64;
type Lookup = IdentityLookup<Self::AccountId>;
type Header = Header;
type Block = Block;
type RuntimeEvent = RuntimeEvent;
type BlockHashCount = BlockHashCount;
type Version = ();