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

* Initial setup

* Adds node block

* Uses UncheckedExtrinsic and removes Where section

* Updates frame_system to use Block

* Adds deprecation warning

* Fixes pallet-timestamp

* Removes Header and BlockNumber

* Addresses review comments

* Addresses review comments

* Adds comment about compiler bug

* Removes where clause

* Refactors code

* Fixes errors in cargo check

* Fixes errors in cargo check

* Fixes warnings in cargo check

* Formatting

* Fixes construct_runtime tests

* Uses import instead of full path for BlockNumber

* Uses import instead of full path for Header

* Formatting

* Fixes construct_runtime tests

* Fixes imports in benchmarks

* Formatting

* Fixes construct_runtime tests

* Formatting

* Minor updates

* Fixes construct_runtime ui tests

* Fixes construct_runtime ui tests with 1.70

* Fixes docs

* Fixes docs

* Adds u128 mock block type

* Fixes split example

* fixes for cumulus

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

* Updates new tests

* Fixes fully-qualified path in few places

* Formatting

* Update frame/examples/default-config/src/lib.rs

Co-authored-by: Juan <juangirini@gmail.com>

* Update frame/support/procedural/src/construct_runtime/mod.rs

Co-authored-by: Juan <juangirini@gmail.com>

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

* Addresses some review comments

* Fixes build

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

* Update frame/democracy/src/lib.rs

Co-authored-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io>

* Update frame/democracy/src/lib.rs

Co-authored-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io>

* Update frame/support/procedural/src/construct_runtime/mod.rs

Co-authored-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io>

* Update frame/support/procedural/src/construct_runtime/mod.rs

Co-authored-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io>

* Addresses review comments

* Updates trait bounds

* Minor fix

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

* Removes unnecessary bound

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

* Updates test

* Fixes build

* Adds a bound for header

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

* Removes where block

* Minor fix

* Minor fix

* Fixes tests

* ".git/.scripts/commands/update-ui/update-ui.sh" 1.70

* Updates test

* Update primitives/runtime/src/traits.rs

Co-authored-by: Bastian Köcher <git@kchr.de>

* Update primitives/runtime/src/traits.rs

Co-authored-by: Bastian Köcher <git@kchr.de>

* Updates doc

* Updates doc

---------

Co-authored-by: command-bot <>
Co-authored-by: Juan <juangirini@gmail.com>
Co-authored-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io>
Co-authored-by: Bastian Köcher <git@kchr.de>
This commit is contained in:
gupnik
2023-07-13 17:31:34 +05:30
committed by GitHub
parent e42a669c50
commit 5e7b27e98c
277 changed files with 2017 additions and 2450 deletions
+10 -13
View File
@@ -186,13 +186,10 @@ pub mod pallet {
<<T as Config>::Currency as FunInspect<<T as frame_system::Config>::AccountId>>::Balance;
type DebtOf<T> =
fungible::Debt<<T as frame_system::Config>::AccountId, <T as Config>::Currency>;
type ReceiptRecordOf<T> = ReceiptRecord<
<T as frame_system::Config>::AccountId,
<T as frame_system::Config>::BlockNumber,
BalanceOf<T>,
>;
type ReceiptRecordOf<T> =
ReceiptRecord<<T as frame_system::Config>::AccountId, BlockNumberFor<T>, BalanceOf<T>>;
type IssuanceInfoOf<T> = IssuanceInfo<BalanceOf<T>>;
type SummaryRecordOf<T> = SummaryRecord<<T as frame_system::Config>::BlockNumber, BalanceOf<T>>;
type SummaryRecordOf<T> = SummaryRecord<BlockNumberFor<T>, BalanceOf<T>>;
type BidOf<T> = Bid<BalanceOf<T>, <T as frame_system::Config>::AccountId>;
type QueueTotalsTypeOf<T> = BoundedVec<(u32, BalanceOf<T>), <T as Config>::QueueCount>;
@@ -275,7 +272,7 @@ pub mod pallet {
/// The base period for the duration queues. This is the common multiple across all
/// supported freezing durations that can be bid upon.
#[pallet::constant]
type BasePeriod: Get<Self::BlockNumber>;
type BasePeriod: Get<BlockNumberFor<Self>>;
/// The minimum amount of funds that may be placed in a bid. Note that this
/// does not actually limit the amount which may be represented in a receipt since bids may
@@ -296,7 +293,7 @@ pub mod pallet {
/// A larger value results in fewer storage hits each block, but a slower period to get to
/// the target.
#[pallet::constant]
type IntakePeriod: Get<Self::BlockNumber>;
type IntakePeriod: Get<BlockNumberFor<Self>>;
/// The maximum amount of bids that can consolidated into receipts in a single intake. A
/// larger value here means less of the block available for transactions should there be a
@@ -306,7 +303,7 @@ pub mod pallet {
/// The maximum proportion which may be thawed and the period over which it is reset.
#[pallet::constant]
type ThawThrottle: Get<(Perquintill, Self::BlockNumber)>;
type ThawThrottle: Get<(Perquintill, BlockNumberFor<Self>)>;
}
#[pallet::pallet]
@@ -413,7 +410,7 @@ pub mod pallet {
/// The identity of the receipt.
index: ReceiptIndex,
/// The block number at which the receipt may be thawed.
expiry: T::BlockNumber,
expiry: BlockNumberFor<T>,
/// The owner of the receipt.
who: T::AccountId,
/// The proportion of the effective total issuance which the receipt represents.
@@ -508,7 +505,7 @@ pub mod pallet {
#[pallet::hooks]
impl<T: Config> Hooks<BlockNumberFor<T>> for Pallet<T> {
fn on_initialize(n: T::BlockNumber) -> Weight {
fn on_initialize(n: BlockNumberFor<T>) -> Weight {
let mut weight_counter =
WeightCounter { used: Weight::zero(), limit: T::MaxIntakeWeight::get() };
if T::IntakePeriod::get().is_zero() || (n % T::IntakePeriod::get()).is_zero() {
@@ -1062,7 +1059,7 @@ pub mod pallet {
pub(crate) fn process_queue(
duration: u32,
now: T::BlockNumber,
now: BlockNumberFor<T>,
our_account: &T::AccountId,
issuance: &IssuanceInfo<BalanceOf<T>>,
max_bids: u32,
@@ -1106,7 +1103,7 @@ pub mod pallet {
pub(crate) fn process_bid(
mut bid: BidOf<T>,
expiry: T::BlockNumber,
expiry: BlockNumberFor<T>,
_our_account: &T::AccountId,
issuance: &IssuanceInfo<BalanceOf<T>>,
remaining: &mut BalanceOf<T>,
+2 -8
View File
@@ -31,22 +31,17 @@ use frame_support::{
use pallet_balances::{Instance1, Instance2};
use sp_core::{ConstU128, H256};
use sp_runtime::{
testing::Header,
traits::{BlakeTwo256, IdentityLookup},
BuildStorage,
};
type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic<Test>;
type Block = frame_system::mocking::MockBlock<Test>;
pub type Balance = u64;
// 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,
Balances: pallet_balances::<Instance1>,
@@ -62,12 +57,11 @@ impl frame_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 = ConstU64<250>;
type DbWeight = ();