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
+183 -183
View File
File diff suppressed because it is too large Load Diff
@@ -56,7 +56,7 @@ pub fn configuration() -> HostConfiguration {
/// ///
/// If there is already a pending update for the current session index + 1, then it won't be touched. Otherwise, /// If there is already a pending update for the current session index + 1, then it won't be touched. Otherwise,
/// that would violate the promise of this function that changes will be applied on the second session change (cur + 2). /// that would violate the promise of this function that changes will be applied on the second session change (cur + 2).
fn schedule_config_update(updater: impl FnOnce(&mut HostConfiguration<T::BlockNumber>)) -> DispatchResult fn schedule_config_update(updater: impl FnOnce(&mut HostConfiguration<BlockNumberFor<T>>)) -> DispatchResult
``` ```
## Entry-points ## Entry-points
@@ -140,6 +140,7 @@ During the transition period, the para object is still considered in its existin
### Storage Layout ### Storage Layout
```rust ```rust
use frame_system::pallet_prelude::BlockNumberFor;
/// All currently active PVF pre-checking votes. /// All currently active PVF pre-checking votes.
/// ///
/// Invariant: /// Invariant:
@@ -197,12 +198,12 @@ UpgradeRestrictionSignal: map hasher(twox_64_concat) ParaId => Option<UpgradeRes
/// The list of parachains that are awaiting for their upgrade restriction to cooldown. /// The list of parachains that are awaiting for their upgrade restriction to cooldown.
/// ///
/// Ordered ascending by block number. /// Ordered ascending by block number.
UpgradeCooldowns: Vec<(ParaId, T::BlockNumber)>; UpgradeCooldowns: Vec<(ParaId, BlockNumberFor<T>)>;
/// The list of upcoming code upgrades. Each item is a pair of which para performs a code /// The list of upcoming code upgrades. Each item is a pair of which para performs a code
/// upgrade and at which relay-chain block it is expected at. /// upgrade and at which relay-chain block it is expected at.
/// ///
/// Ordered ascending by block number. /// Ordered ascending by block number.
UpcomingUpgrades: Vec<(ParaId, T::BlockNumber)>; UpcomingUpgrades: Vec<(ParaId, BlockNumberFor<T>)>;
/// The actions to perform during the start of a specific session index. /// The actions to perform during the start of a specific session index.
ActionsQueue: map SessionIndex => Vec<ParaId>; ActionsQueue: map SessionIndex => Vec<ParaId>;
/// Upcoming paras instantiation arguments. /// Upcoming paras instantiation arguments.
+14 -18
View File
@@ -67,11 +67,10 @@ pub struct ParachainTemporarySlot<AccountId, LeasePeriod> {
pub lease_count: u32, pub lease_count: u32,
} }
type BalanceOf<T> = <<<T as Config>::Leaser as Leaser<<T as frame_system::Config>::BlockNumber>>::Currency as Currency< type BalanceOf<T> = <<<T as Config>::Leaser as Leaser<BlockNumberFor<T>>>::Currency as Currency<
<T as frame_system::Config>::AccountId, <T as frame_system::Config>::AccountId,
>>::Balance; >>::Balance;
type LeasePeriodOf<T> = type LeasePeriodOf<T> = <<T as Config>::Leaser as Leaser<BlockNumberFor<T>>>::LeasePeriod;
<<T as Config>::Leaser as Leaser<<T as frame_system::Config>::BlockNumber>>::LeasePeriod;
#[frame_support::pallet] #[frame_support::pallet]
pub mod pallet { pub mod pallet {
@@ -91,9 +90,9 @@ pub mod pallet {
/// The type representing the leasing system. /// The type representing the leasing system.
type Leaser: Leaser< type Leaser: Leaser<
Self::BlockNumber, BlockNumberFor<Self>,
AccountId = Self::AccountId, AccountId = Self::AccountId,
LeasePeriod = Self::BlockNumber, LeasePeriod = BlockNumberFor<Self>,
>; >;
/// The number of lease periods a permanent parachain slot lasts. /// The number of lease periods a permanent parachain slot lasts.
@@ -182,7 +181,7 @@ pub mod pallet {
#[pallet::hooks] #[pallet::hooks]
impl<T: Config> Hooks<BlockNumberFor<T>> for Pallet<T> { impl<T: Config> Hooks<BlockNumberFor<T>> for Pallet<T> {
fn on_initialize(n: T::BlockNumber) -> Weight { fn on_initialize(n: BlockNumberFor<T>) -> Weight {
if let Some((lease_period, first_block)) = Self::lease_period_index(n) { if let Some((lease_period, first_block)) = Self::lease_period_index(n) {
// If we're beginning a new lease period then handle that. // If we're beginning a new lease period then handle that.
if first_block { if first_block {
@@ -213,14 +212,14 @@ pub mod pallet {
Error::<T>::SlotAlreadyAssigned Error::<T>::SlotAlreadyAssigned
); );
let current_lease_period: T::BlockNumber = Self::current_lease_period_index(); let current_lease_period: BlockNumberFor<T> = Self::current_lease_period_index();
ensure!( ensure!(
!T::Leaser::already_leased( !T::Leaser::already_leased(
id, id,
current_lease_period, current_lease_period,
// Check current lease & next one // Check current lease & next one
current_lease_period.saturating_add( current_lease_period.saturating_add(
T::BlockNumber::from(2u32) BlockNumberFor::<T>::from(2u32)
.saturating_mul(T::PermanentSlotLeasePeriodLength::get().into()) .saturating_mul(T::PermanentSlotLeasePeriodLength::get().into())
) )
), ),
@@ -276,14 +275,14 @@ pub mod pallet {
Error::<T>::SlotAlreadyAssigned Error::<T>::SlotAlreadyAssigned
); );
let current_lease_period: T::BlockNumber = Self::current_lease_period_index(); let current_lease_period: BlockNumberFor<T> = Self::current_lease_period_index();
ensure!( ensure!(
!T::Leaser::already_leased( !T::Leaser::already_leased(
id, id,
current_lease_period, current_lease_period,
// Check current lease & next one // Check current lease & next one
current_lease_period.saturating_add( current_lease_period.saturating_add(
T::BlockNumber::from(2u32) BlockNumberFor::<T>::from(2u32)
.saturating_mul(T::TemporarySlotLeasePeriodLength::get().into()) .saturating_mul(T::TemporarySlotLeasePeriodLength::get().into())
) )
), ),
@@ -548,7 +547,7 @@ mod tests {
use frame_support::{assert_noop, assert_ok, parameter_types}; use frame_support::{assert_noop, assert_ok, parameter_types};
use frame_system::EnsureRoot; use frame_system::EnsureRoot;
use pallet_balances; use pallet_balances;
use primitives::{BlockNumber, Header}; use primitives::BlockNumber;
use runtime_parachains::{ use runtime_parachains::{
configuration as parachains_configuration, paras as parachains_paras, configuration as parachains_configuration, paras as parachains_paras,
shared as parachains_shared, shared as parachains_shared,
@@ -562,13 +561,10 @@ mod tests {
}; };
type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic<Test>; type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic<Test>;
type Block = frame_system::mocking::MockBlock<Test>; type Block = frame_system::mocking::MockBlockU32<Test>;
frame_support::construct_runtime!( frame_support::construct_runtime!(
pub enum Test where pub enum Test
Block = Block,
NodeBlock = Block,
UncheckedExtrinsic = UncheckedExtrinsic,
{ {
System: frame_system::{Pallet, Call, Config<T>, Storage, Event<T>}, System: frame_system::{Pallet, Call, Config<T>, Storage, Event<T>},
Balances: pallet_balances::{Pallet, Call, Storage, Config<T>, Event<T>}, Balances: pallet_balances::{Pallet, Call, Storage, Config<T>, Event<T>},
@@ -598,12 +594,12 @@ mod tests {
type RuntimeOrigin = RuntimeOrigin; type RuntimeOrigin = RuntimeOrigin;
type RuntimeCall = RuntimeCall; type RuntimeCall = RuntimeCall;
type Index = u64; type Index = u64;
type BlockNumber = BlockNumber;
type Hash = H256; type Hash = H256;
type Hashing = BlakeTwo256; type Hashing = BlakeTwo256;
type AccountId = u64; type AccountId = u64;
type Lookup = IdentityLookup<Self::AccountId>; type Lookup = IdentityLookup<Self::AccountId>;
type Header = Header; type Block = Block;
type RuntimeEvent = RuntimeEvent; type RuntimeEvent = RuntimeEvent;
type BlockHashCount = BlockHashCount; type BlockHashCount = BlockHashCount;
type DbWeight = (); type DbWeight = ();
+39 -44
View File
@@ -28,15 +28,15 @@ use frame_support::{
traits::{Currency, Get, Randomness, ReservableCurrency}, traits::{Currency, Get, Randomness, ReservableCurrency},
weights::Weight, weights::Weight,
}; };
use frame_system::pallet_prelude::BlockNumberFor;
pub use pallet::*; pub use pallet::*;
use parity_scale_codec::Decode; use parity_scale_codec::Decode;
use primitives::Id as ParaId; use primitives::Id as ParaId;
use sp_runtime::traits::{CheckedSub, One, Saturating, Zero}; use sp_runtime::traits::{CheckedSub, One, Saturating, Zero};
use sp_std::{mem::swap, prelude::*}; use sp_std::{mem::swap, prelude::*};
type CurrencyOf<T> = type CurrencyOf<T> = <<T as Config>::Leaser as Leaser<BlockNumberFor<T>>>::Currency;
<<T as Config>::Leaser as Leaser<<T as frame_system::Config>::BlockNumber>>::Currency; type BalanceOf<T> = <<<T as Config>::Leaser as Leaser<BlockNumberFor<T>>>::Currency as Currency<
type BalanceOf<T> = <<<T as Config>::Leaser as Leaser<<T as frame_system::Config>::BlockNumber>>::Currency as Currency<
<T as frame_system::Config>::AccountId, <T as frame_system::Config>::AccountId,
>>::Balance; >>::Balance;
@@ -66,8 +66,7 @@ impl WeightInfo for TestWeightInfo {
/// An auction index. We count auctions in this type. /// An auction index. We count auctions in this type.
pub type AuctionIndex = u32; pub type AuctionIndex = u32;
type LeasePeriodOf<T> = type LeasePeriodOf<T> = <<T as Config>::Leaser as Leaser<BlockNumberFor<T>>>::LeasePeriod;
<<T as Config>::Leaser as Leaser<<T as frame_system::Config>::BlockNumber>>::LeasePeriod;
// Winning data type. This encodes the top bidders of each range together with their bid. // Winning data type. This encodes the top bidders of each range together with their bid.
type WinningData<T> = [Option<(<T as frame_system::Config>::AccountId, ParaId, BalanceOf<T>)>; type WinningData<T> = [Option<(<T as frame_system::Config>::AccountId, ParaId, BalanceOf<T>)>;
@@ -94,9 +93,9 @@ pub mod pallet {
/// The type representing the leasing system. /// The type representing the leasing system.
type Leaser: Leaser< type Leaser: Leaser<
Self::BlockNumber, BlockNumberFor<Self>,
AccountId = Self::AccountId, AccountId = Self::AccountId,
LeasePeriod = Self::BlockNumber, LeasePeriod = BlockNumberFor<Self>,
>; >;
/// The parachain registrar type. /// The parachain registrar type.
@@ -104,16 +103,16 @@ pub mod pallet {
/// The number of blocks over which an auction may be retroactively ended. /// The number of blocks over which an auction may be retroactively ended.
#[pallet::constant] #[pallet::constant]
type EndingPeriod: Get<Self::BlockNumber>; type EndingPeriod: Get<BlockNumberFor<Self>>;
/// The length of each sample to take during the ending period. /// The length of each sample to take during the ending period.
/// ///
/// `EndingPeriod` / `SampleLength` = Total # of Samples /// `EndingPeriod` / `SampleLength` = Total # of Samples
#[pallet::constant] #[pallet::constant]
type SampleLength: Get<Self::BlockNumber>; type SampleLength: Get<BlockNumberFor<Self>>;
/// Something that provides randomness in the runtime. /// Something that provides randomness in the runtime.
type Randomness: Randomness<Self::Hash, Self::BlockNumber>; type Randomness: Randomness<Self::Hash, BlockNumberFor<Self>>;
/// The origin which may initiate auctions. /// The origin which may initiate auctions.
type InitiateOrigin: EnsureOrigin<Self::RuntimeOrigin>; type InitiateOrigin: EnsureOrigin<Self::RuntimeOrigin>;
@@ -130,7 +129,7 @@ pub mod pallet {
AuctionStarted { AuctionStarted {
auction_index: AuctionIndex, auction_index: AuctionIndex,
lease_period: LeasePeriodOf<T>, lease_period: LeasePeriodOf<T>,
ending: T::BlockNumber, ending: BlockNumberFor<T>,
}, },
/// An auction ended. All funds become unreserved. /// An auction ended. All funds become unreserved.
AuctionClosed { auction_index: AuctionIndex }, AuctionClosed { auction_index: AuctionIndex },
@@ -151,7 +150,7 @@ pub mod pallet {
last_slot: LeasePeriodOf<T>, last_slot: LeasePeriodOf<T>,
}, },
/// The winning offset was chosen for an auction. This will map into the `Winning` storage map. /// The winning offset was chosen for an auction. This will map into the `Winning` storage map.
WinningOffset { auction_index: AuctionIndex, block_number: T::BlockNumber }, WinningOffset { auction_index: AuctionIndex, block_number: BlockNumberFor<T> },
} }
#[pallet::error] #[pallet::error]
@@ -184,7 +183,7 @@ pub mod pallet {
/// auction will "begin to end", i.e. the first block of the Ending Period of the auction. /// auction will "begin to end", i.e. the first block of the Ending Period of the auction.
#[pallet::storage] #[pallet::storage]
#[pallet::getter(fn auction_info)] #[pallet::getter(fn auction_info)]
pub type AuctionInfo<T: Config> = StorageValue<_, (LeasePeriodOf<T>, T::BlockNumber)>; pub type AuctionInfo<T: Config> = StorageValue<_, (LeasePeriodOf<T>, BlockNumberFor<T>)>;
/// Amounts currently reserved in the accounts of the bidders currently winning /// Amounts currently reserved in the accounts of the bidders currently winning
/// (sub-)ranges. /// (sub-)ranges.
@@ -198,7 +197,7 @@ pub mod pallet {
/// first sample of the ending period is 0; the last is `Sample Size - 1`. /// first sample of the ending period is 0; the last is `Sample Size - 1`.
#[pallet::storage] #[pallet::storage]
#[pallet::getter(fn winning)] #[pallet::getter(fn winning)]
pub type Winning<T: Config> = StorageMap<_, Twox64Concat, T::BlockNumber, WinningData<T>>; pub type Winning<T: Config> = StorageMap<_, Twox64Concat, BlockNumberFor<T>, WinningData<T>>;
#[pallet::extra_constants] #[pallet::extra_constants]
impl<T: Config> Pallet<T> { impl<T: Config> Pallet<T> {
@@ -215,7 +214,7 @@ pub mod pallet {
#[pallet::hooks] #[pallet::hooks]
impl<T: Config> Hooks<BlockNumberFor<T>> for Pallet<T> { 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 = T::DbWeight::get().reads(1); let mut weight = T::DbWeight::get().reads(1);
// If the current auction was in its ending period last block, then ensure that the (sub-)range // If the current auction was in its ending period last block, then ensure that the (sub-)range
@@ -256,7 +255,7 @@ pub mod pallet {
#[pallet::weight((T::WeightInfo::new_auction(), DispatchClass::Operational))] #[pallet::weight((T::WeightInfo::new_auction(), DispatchClass::Operational))]
pub fn new_auction( pub fn new_auction(
origin: OriginFor<T>, origin: OriginFor<T>,
#[pallet::compact] duration: T::BlockNumber, #[pallet::compact] duration: BlockNumberFor<T>,
#[pallet::compact] lease_period_index: LeasePeriodOf<T>, #[pallet::compact] lease_period_index: LeasePeriodOf<T>,
) -> DispatchResult { ) -> DispatchResult {
T::InitiateOrigin::ensure_origin(origin)?; T::InitiateOrigin::ensure_origin(origin)?;
@@ -313,20 +312,20 @@ pub mod pallet {
} }
} }
impl<T: Config> Auctioneer<T::BlockNumber> for Pallet<T> { impl<T: Config> Auctioneer<BlockNumberFor<T>> for Pallet<T> {
type AccountId = T::AccountId; type AccountId = T::AccountId;
type LeasePeriod = T::BlockNumber; type LeasePeriod = BlockNumberFor<T>;
type Currency = CurrencyOf<T>; type Currency = CurrencyOf<T>;
fn new_auction( fn new_auction(
duration: T::BlockNumber, duration: BlockNumberFor<T>,
lease_period_index: LeasePeriodOf<T>, lease_period_index: LeasePeriodOf<T>,
) -> DispatchResult { ) -> DispatchResult {
Self::do_new_auction(duration, lease_period_index) Self::do_new_auction(duration, lease_period_index)
} }
// Returns the status of the auction given the current block number. // Returns the status of the auction given the current block number.
fn auction_status(now: T::BlockNumber) -> AuctionStatus<T::BlockNumber> { fn auction_status(now: BlockNumberFor<T>) -> AuctionStatus<BlockNumberFor<T>> {
let early_end = match AuctionInfo::<T>::get() { let early_end = match AuctionInfo::<T>::get() {
Some((_, early_end)) => early_end, Some((_, early_end)) => early_end,
None => return AuctionStatus::NotStarted, None => return AuctionStatus::NotStarted,
@@ -359,12 +358,12 @@ impl<T: Config> Auctioneer<T::BlockNumber> for Pallet<T> {
Self::handle_bid(bidder, para, AuctionCounter::<T>::get(), first_slot, last_slot, amount) Self::handle_bid(bidder, para, AuctionCounter::<T>::get(), first_slot, last_slot, amount)
} }
fn lease_period_index(b: T::BlockNumber) -> Option<(Self::LeasePeriod, bool)> { fn lease_period_index(b: BlockNumberFor<T>) -> Option<(Self::LeasePeriod, bool)> {
T::Leaser::lease_period_index(b) T::Leaser::lease_period_index(b)
} }
#[cfg(any(feature = "runtime-benchmarks", test))] #[cfg(any(feature = "runtime-benchmarks", test))]
fn lease_period_length() -> (T::BlockNumber, T::BlockNumber) { fn lease_period_length() -> (BlockNumberFor<T>, BlockNumberFor<T>) {
T::Leaser::lease_period_length() T::Leaser::lease_period_length()
} }
@@ -383,7 +382,7 @@ impl<T: Config> Pallet<T> {
/// of this auction and the `lease_period_index` of the initial lease period of the four that /// of this auction and the `lease_period_index` of the initial lease period of the four that
/// are to be auctioned. /// are to be auctioned.
fn do_new_auction( fn do_new_auction(
duration: T::BlockNumber, duration: BlockNumberFor<T>,
lease_period_index: LeasePeriodOf<T>, lease_period_index: LeasePeriodOf<T>,
) -> DispatchResult { ) -> DispatchResult {
let maybe_auction = AuctionInfo::<T>::get(); let maybe_auction = AuctionInfo::<T>::get();
@@ -530,7 +529,7 @@ impl<T: Config> Pallet<T> {
/// ///
/// This mutates the state, cleaning up `AuctionInfo` and `Winning` in the case of an auction /// This mutates the state, cleaning up `AuctionInfo` and `Winning` in the case of an auction
/// ending. An immediately subsequent call with the same argument will always return `None`. /// ending. An immediately subsequent call with the same argument will always return `None`.
fn check_auction_end(now: T::BlockNumber) -> Option<(WinningData<T>, LeasePeriodOf<T>)> { fn check_auction_end(now: BlockNumberFor<T>) -> Option<(WinningData<T>, LeasePeriodOf<T>)> {
if let Some((lease_period_index, early_end)) = AuctionInfo::<T>::get() { if let Some((lease_period_index, early_end)) = AuctionInfo::<T>::get() {
let ending_period = T::EndingPeriod::get(); let ending_period = T::EndingPeriod::get();
let late_end = early_end.saturating_add(ending_period); let late_end = early_end.saturating_add(ending_period);
@@ -542,7 +541,7 @@ impl<T: Config> Pallet<T> {
if late_end <= known_since { if late_end <= known_since {
// Our random seed was known only after the auction ended. Good to use. // Our random seed was known only after the auction ended. Good to use.
let raw_offset_block_number = <T::BlockNumber>::decode( let raw_offset_block_number = <BlockNumberFor<T>>::decode(
&mut raw_offset.as_ref(), &mut raw_offset.as_ref(),
) )
.expect("secure hashes should always be bigger than the block number; qed"); .expect("secure hashes should always be bigger than the block number; qed");
@@ -683,7 +682,7 @@ mod tests {
}; };
use frame_system::{EnsureRoot, EnsureSignedBy}; use frame_system::{EnsureRoot, EnsureSignedBy};
use pallet_balances; use pallet_balances;
use primitives::{BlockNumber, Header, Id as ParaId}; use primitives::{BlockNumber, Id as ParaId};
use sp_core::H256; use sp_core::H256;
use sp_runtime::{ use sp_runtime::{
traits::{BlakeTwo256, IdentityLookup}, traits::{BlakeTwo256, IdentityLookup},
@@ -691,14 +690,10 @@ mod tests {
}; };
use std::{cell::RefCell, collections::BTreeMap}; use std::{cell::RefCell, collections::BTreeMap};
type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic<Test>; type Block = frame_system::mocking::MockBlockU32<Test>;
type Block = frame_system::mocking::MockBlock<Test>;
frame_support::construct_runtime!( frame_support::construct_runtime!(
pub enum Test where pub enum Test
Block = Block,
NodeBlock = Block,
UncheckedExtrinsic = UncheckedExtrinsic,
{ {
System: frame_system::{Pallet, Call, Config<T>, Storage, Event<T>}, System: frame_system::{Pallet, Call, Config<T>, Storage, Event<T>},
Balances: pallet_balances::{Pallet, Call, Storage, Config<T>, Event<T>}, Balances: pallet_balances::{Pallet, Call, Storage, Config<T>, Event<T>},
@@ -717,12 +712,12 @@ mod tests {
type RuntimeOrigin = RuntimeOrigin; type RuntimeOrigin = RuntimeOrigin;
type RuntimeCall = RuntimeCall; type RuntimeCall = RuntimeCall;
type Index = u64; type Index = u64;
type BlockNumber = BlockNumber;
type Hash = H256; type Hash = H256;
type Hashing = BlakeTwo256; type Hashing = BlakeTwo256;
type AccountId = u64; type AccountId = u64;
type Lookup = IdentityLookup<Self::AccountId>; type Lookup = IdentityLookup<Self::AccountId>;
type Header = Header; type Block = Block;
type RuntimeEvent = RuntimeEvent; type RuntimeEvent = RuntimeEvent;
type BlockHashCount = BlockHashCount; type BlockHashCount = BlockHashCount;
type Version = (); type Version = ();
@@ -1800,7 +1795,7 @@ mod benchmarking {
where_clause { where T: pallet_babe::Config + paras::Config } where_clause { where T: pallet_babe::Config + paras::Config }
new_auction { new_auction {
let duration = T::BlockNumber::max_value(); let duration = BlockNumberFor::<T>::max_value();
let lease_period_index = LeasePeriodOf::<T>::max_value(); let lease_period_index = LeasePeriodOf::<T>::max_value();
let origin = let origin =
T::InitiateOrigin::try_successful_origin().map_err(|_| BenchmarkError::Weightless)?; T::InitiateOrigin::try_successful_origin().map_err(|_| BenchmarkError::Weightless)?;
@@ -1809,7 +1804,7 @@ mod benchmarking {
assert_last_event::<T>(Event::<T>::AuctionStarted { assert_last_event::<T>(Event::<T>::AuctionStarted {
auction_index: AuctionCounter::<T>::get(), auction_index: AuctionCounter::<T>::get(),
lease_period: LeasePeriodOf::<T>::max_value(), lease_period: LeasePeriodOf::<T>::max_value(),
ending: T::BlockNumber::max_value(), ending: BlockNumberFor::<T>::max_value(),
}.into()); }.into());
} }
@@ -1820,7 +1815,7 @@ mod benchmarking {
frame_system::Pallet::<T>::set_block_number(offset + One::one()); frame_system::Pallet::<T>::set_block_number(offset + One::one());
// Create a new auction // Create a new auction
let duration = T::BlockNumber::max_value(); let duration = BlockNumberFor::<T>::max_value();
let lease_period_index = LeasePeriodOf::<T>::zero(); let lease_period_index = LeasePeriodOf::<T>::zero();
let origin = T::InitiateOrigin::try_successful_origin() let origin = T::InitiateOrigin::try_successful_origin()
.expect("InitiateOrigin has no successful origin required for the benchmark"); .expect("InitiateOrigin has no successful origin required for the benchmark");
@@ -1877,7 +1872,7 @@ mod benchmarking {
frame_system::Pallet::<T>::set_block_number(offset + One::one()); frame_system::Pallet::<T>::set_block_number(offset + One::one());
// Create a new auction // Create a new auction
let duration: T::BlockNumber = lease_length / 2u32.into(); let duration: BlockNumberFor<T> = lease_length / 2u32.into();
let lease_period_index = LeasePeriodOf::<T>::zero(); let lease_period_index = LeasePeriodOf::<T>::zero();
let now = frame_system::Pallet::<T>::block_number(); let now = frame_system::Pallet::<T>::block_number();
let origin = T::InitiateOrigin::try_successful_origin() let origin = T::InitiateOrigin::try_successful_origin()
@@ -1886,14 +1881,14 @@ mod benchmarking {
fill_winners::<T>(lease_period_index); fill_winners::<T>(lease_period_index);
for winner in Winning::<T>::get(T::BlockNumber::from(0u32)).unwrap().iter() { for winner in Winning::<T>::get(BlockNumberFor::<T>::from(0u32)).unwrap().iter() {
assert!(winner.is_some()); assert!(winner.is_some());
} }
let winning_data = Winning::<T>::get(T::BlockNumber::from(0u32)).unwrap(); let winning_data = Winning::<T>::get(BlockNumberFor::<T>::from(0u32)).unwrap();
// Make winning map full // Make winning map full
for i in 0u32 .. (T::EndingPeriod::get() / T::SampleLength::get()).saturated_into() { for i in 0u32 .. (T::EndingPeriod::get() / T::SampleLength::get()).saturated_into() {
Winning::<T>::insert(T::BlockNumber::from(i), winning_data.clone()); Winning::<T>::insert(BlockNumberFor::<T>::from(i), winning_data.clone());
} }
// Move ahead to the block we want to initialize // Move ahead to the block we want to initialize
@@ -1922,7 +1917,7 @@ mod benchmarking {
frame_system::Pallet::<T>::set_block_number(offset + One::one()); frame_system::Pallet::<T>::set_block_number(offset + One::one());
// Create a new auction // Create a new auction
let duration: T::BlockNumber = lease_length / 2u32.into(); let duration: BlockNumberFor<T> = lease_length / 2u32.into();
let lease_period_index = LeasePeriodOf::<T>::zero(); let lease_period_index = LeasePeriodOf::<T>::zero();
let now = frame_system::Pallet::<T>::block_number(); let now = frame_system::Pallet::<T>::block_number();
let origin = T::InitiateOrigin::try_successful_origin() let origin = T::InitiateOrigin::try_successful_origin()
@@ -1931,14 +1926,14 @@ mod benchmarking {
fill_winners::<T>(lease_period_index); fill_winners::<T>(lease_period_index);
let winning_data = Winning::<T>::get(T::BlockNumber::from(0u32)).unwrap(); let winning_data = Winning::<T>::get(BlockNumberFor::<T>::from(0u32)).unwrap();
for winner in winning_data.iter() { for winner in winning_data.iter() {
assert!(winner.is_some()); assert!(winner.is_some());
} }
// Make winning map full // Make winning map full
for i in 0u32 .. (T::EndingPeriod::get() / T::SampleLength::get()).saturated_into() { for i in 0u32 .. (T::EndingPeriod::get() / T::SampleLength::get()).saturated_into() {
Winning::<T>::insert(T::BlockNumber::from(i), winning_data.clone()); Winning::<T>::insert(BlockNumberFor::<T>::from(i), winning_data.clone());
} }
assert!(AuctionInfo::<T>::get().is_some()); assert!(AuctionInfo::<T>::get().is_some());
}: _(RawOrigin::Root) }: _(RawOrigin::Root)
+6 -12
View File
@@ -171,7 +171,7 @@ pub mod pallet {
pub trait Config: frame_system::Config { pub trait Config: frame_system::Config {
/// The overarching event type. /// The overarching event type.
type RuntimeEvent: From<Event<Self>> + IsType<<Self as frame_system::Config>::RuntimeEvent>; type RuntimeEvent: From<Event<Self>> + IsType<<Self as frame_system::Config>::RuntimeEvent>;
type VestingSchedule: VestingSchedule<Self::AccountId, Moment = Self::BlockNumber>; type VestingSchedule: VestingSchedule<Self::AccountId, Moment = BlockNumberFor<Self>>;
#[pallet::constant] #[pallet::constant]
type Prefix: Get<&'static [u8]>; type Prefix: Get<&'static [u8]>;
type MoveClaimOrigin: EnsureOrigin<Self::RuntimeOrigin>; type MoveClaimOrigin: EnsureOrigin<Self::RuntimeOrigin>;
@@ -217,7 +217,7 @@ pub mod pallet {
#[pallet::storage] #[pallet::storage]
#[pallet::getter(fn vesting)] #[pallet::getter(fn vesting)]
pub(super) type Vesting<T: Config> = pub(super) type Vesting<T: Config> =
StorageMap<_, Identity, EthereumAddress, (BalanceOf<T>, BalanceOf<T>, T::BlockNumber)>; StorageMap<_, Identity, EthereumAddress, (BalanceOf<T>, BalanceOf<T>, BlockNumberFor<T>)>;
/// The statement kind that must be signed, if any. /// The statement kind that must be signed, if any.
#[pallet::storage] #[pallet::storage]
@@ -232,7 +232,7 @@ pub mod pallet {
pub struct GenesisConfig<T: Config> { pub struct GenesisConfig<T: Config> {
pub claims: pub claims:
Vec<(EthereumAddress, BalanceOf<T>, Option<T::AccountId>, Option<StatementKind>)>, Vec<(EthereumAddress, BalanceOf<T>, Option<T::AccountId>, Option<StatementKind>)>,
pub vesting: Vec<(EthereumAddress, (BalanceOf<T>, BalanceOf<T>, T::BlockNumber))>, pub vesting: Vec<(EthereumAddress, (BalanceOf<T>, BalanceOf<T>, BlockNumberFor<T>))>,
} }
#[pallet::genesis_build] #[pallet::genesis_build]
@@ -336,7 +336,7 @@ pub mod pallet {
origin: OriginFor<T>, origin: OriginFor<T>,
who: EthereumAddress, who: EthereumAddress,
value: BalanceOf<T>, value: BalanceOf<T>,
vesting_schedule: Option<(BalanceOf<T>, BalanceOf<T>, T::BlockNumber)>, vesting_schedule: Option<(BalanceOf<T>, BalanceOf<T>, BlockNumberFor<T>)>,
statement: Option<StatementKind>, statement: Option<StatementKind>,
) -> DispatchResult { ) -> DispatchResult {
ensure_root(origin)?; ensure_root(origin)?;
@@ -714,20 +714,15 @@ mod tests {
}; };
use pallet_balances; use pallet_balances;
use sp_runtime::{ use sp_runtime::{
testing::Header,
traits::{BlakeTwo256, Identity, IdentityLookup}, traits::{BlakeTwo256, Identity, IdentityLookup},
transaction_validity::TransactionLongevity, transaction_validity::TransactionLongevity,
BuildStorage, TokenError, BuildStorage, TokenError,
}; };
type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic<Test>;
type Block = frame_system::mocking::MockBlock<Test>; type Block = frame_system::mocking::MockBlock<Test>;
frame_support::construct_runtime!( frame_support::construct_runtime!(
pub enum Test where pub enum Test
Block = Block,
NodeBlock = Block,
UncheckedExtrinsic = UncheckedExtrinsic,
{ {
System: frame_system::{Pallet, Call, Config<T>, Storage, Event<T>}, System: frame_system::{Pallet, Call, Config<T>, Storage, Event<T>},
Balances: pallet_balances::{Pallet, Call, Storage, Config<T>, Event<T>}, Balances: pallet_balances::{Pallet, Call, Storage, Config<T>, Event<T>},
@@ -747,12 +742,11 @@ mod tests {
type RuntimeOrigin = RuntimeOrigin; type RuntimeOrigin = RuntimeOrigin;
type RuntimeCall = RuntimeCall; type RuntimeCall = RuntimeCall;
type Index = u64; type Index = u64;
type BlockNumber = u64;
type Hash = H256; type Hash = H256;
type Hashing = BlakeTwo256; type Hashing = BlakeTwo256;
type AccountId = u64; type AccountId = u64;
type Lookup = IdentityLookup<u64>; type Lookup = IdentityLookup<u64>;
type Header = Header; type Block = Block;
type RuntimeEvent = RuntimeEvent; type RuntimeEvent = RuntimeEvent;
type BlockHashCount = BlockHashCount; type BlockHashCount = BlockHashCount;
type Version = (); type Version = ();
+18 -25
View File
@@ -66,6 +66,7 @@ use frame_support::{
}, },
Identity, PalletId, Identity, PalletId,
}; };
use frame_system::pallet_prelude::BlockNumberFor;
pub use pallet::*; pub use pallet::*;
use parity_scale_codec::{Decode, Encode}; use parity_scale_codec::{Decode, Encode};
use primitives::Id as ParaId; use primitives::Id as ParaId;
@@ -78,11 +79,8 @@ use sp_runtime::{
}; };
use sp_std::vec::Vec; use sp_std::vec::Vec;
type CurrencyOf<T> = type CurrencyOf<T> = <<T as Config>::Auctioneer as Auctioneer<BlockNumberFor<T>>>::Currency;
<<T as Config>::Auctioneer as Auctioneer<<T as frame_system::Config>::BlockNumber>>::Currency; type LeasePeriodOf<T> = <<T as Config>::Auctioneer as Auctioneer<BlockNumberFor<T>>>::LeasePeriod;
type LeasePeriodOf<T> = <<T as Config>::Auctioneer as Auctioneer<
<T as frame_system::Config>::BlockNumber,
>>::LeasePeriod;
type BalanceOf<T> = <CurrencyOf<T> as Currency<<T as frame_system::Config>::AccountId>>::Balance; type BalanceOf<T> = <CurrencyOf<T> as Currency<<T as frame_system::Config>::AccountId>>::Balance;
#[allow(dead_code)] #[allow(dead_code)]
@@ -216,9 +214,9 @@ pub mod pallet {
/// The type representing the auctioning system. /// The type representing the auctioning system.
type Auctioneer: Auctioneer< type Auctioneer: Auctioneer<
Self::BlockNumber, BlockNumberFor<Self>,
AccountId = Self::AccountId, AccountId = Self::AccountId,
LeasePeriod = Self::BlockNumber, LeasePeriod = BlockNumberFor<Self>,
>; >;
/// The maximum length for the memo attached to a crowdloan contribution. /// The maximum length for the memo attached to a crowdloan contribution.
@@ -235,7 +233,7 @@ pub mod pallet {
_, _,
Twox64Concat, Twox64Concat,
ParaId, ParaId,
FundInfo<T::AccountId, BalanceOf<T>, T::BlockNumber, LeasePeriodOf<T>>, FundInfo<T::AccountId, BalanceOf<T>, BlockNumberFor<T>, LeasePeriodOf<T>>,
>; >;
/// The funds that have had additional contributions during the last block. This is used /// The funds that have had additional contributions during the last block. This is used
@@ -332,7 +330,7 @@ pub mod pallet {
#[pallet::hooks] #[pallet::hooks]
impl<T: Config> Hooks<BlockNumberFor<T>> for Pallet<T> { impl<T: Config> Hooks<BlockNumberFor<T>> for Pallet<T> {
fn on_initialize(num: T::BlockNumber) -> frame_support::weights::Weight { fn on_initialize(num: BlockNumberFor<T>) -> frame_support::weights::Weight {
if let Some((sample, sub_sample)) = T::Auctioneer::auction_status(num).is_ending() { if let Some((sample, sub_sample)) = T::Auctioneer::auction_status(num).is_ending() {
// This is the very first block in the ending period // This is the very first block in the ending period
if sample.is_zero() && sub_sample.is_zero() { if sample.is_zero() && sub_sample.is_zero() {
@@ -377,7 +375,7 @@ pub mod pallet {
#[pallet::compact] cap: BalanceOf<T>, #[pallet::compact] cap: BalanceOf<T>,
#[pallet::compact] first_period: LeasePeriodOf<T>, #[pallet::compact] first_period: LeasePeriodOf<T>,
#[pallet::compact] last_period: LeasePeriodOf<T>, #[pallet::compact] last_period: LeasePeriodOf<T>,
#[pallet::compact] end: T::BlockNumber, #[pallet::compact] end: BlockNumberFor<T>,
verifier: Option<MultiSigner>, verifier: Option<MultiSigner>,
) -> DispatchResult { ) -> DispatchResult {
let depositor = ensure_signed(origin)?; let depositor = ensure_signed(origin)?;
@@ -594,7 +592,7 @@ pub mod pallet {
#[pallet::compact] cap: BalanceOf<T>, #[pallet::compact] cap: BalanceOf<T>,
#[pallet::compact] first_period: LeasePeriodOf<T>, #[pallet::compact] first_period: LeasePeriodOf<T>,
#[pallet::compact] last_period: LeasePeriodOf<T>, #[pallet::compact] last_period: LeasePeriodOf<T>,
#[pallet::compact] end: T::BlockNumber, #[pallet::compact] end: BlockNumberFor<T>,
verifier: Option<MultiSigner>, verifier: Option<MultiSigner>,
) -> DispatchResult { ) -> DispatchResult {
ensure_root(origin)?; ensure_root(origin)?;
@@ -725,9 +723,9 @@ impl<T: Config> Pallet<T> {
/// trying to bid for has started already. /// trying to bid for has started already.
/// * And, if the fund has enough free funds to refund full raised amount. /// * And, if the fund has enough free funds to refund full raised amount.
fn ensure_crowdloan_ended( fn ensure_crowdloan_ended(
now: T::BlockNumber, now: BlockNumberFor<T>,
fund_account: &T::AccountId, fund_account: &T::AccountId,
fund: &FundInfo<T::AccountId, BalanceOf<T>, T::BlockNumber, LeasePeriodOf<T>>, fund: &FundInfo<T::AccountId, BalanceOf<T>, BlockNumberFor<T>, LeasePeriodOf<T>>,
) -> sp_runtime::DispatchResult { ) -> sp_runtime::DispatchResult {
// `fund.end` can represent the end of a failed crowdloan or the beginning of retirement // `fund.end` can represent the end of a failed crowdloan or the beginning of retirement
// If the current lease period is past the first period they are trying to bid for, then // If the current lease period is past the first period they are trying to bid for, then
@@ -878,19 +876,14 @@ mod tests {
use ::test_helpers::{dummy_head_data, dummy_validation_code}; use ::test_helpers::{dummy_head_data, dummy_validation_code};
use sp_keystore::{testing::MemoryKeystore, KeystoreExt}; use sp_keystore::{testing::MemoryKeystore, KeystoreExt};
use sp_runtime::{ use sp_runtime::{
testing::Header,
traits::{BlakeTwo256, IdentityLookup, TrailingZeroInput}, traits::{BlakeTwo256, IdentityLookup, TrailingZeroInput},
BuildStorage, DispatchResult, BuildStorage, DispatchResult,
}; };
type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic<Test>;
type Block = frame_system::mocking::MockBlock<Test>; type Block = frame_system::mocking::MockBlock<Test>;
frame_support::construct_runtime!( frame_support::construct_runtime!(
pub enum Test where pub enum Test
Block = Block,
NodeBlock = Block,
UncheckedExtrinsic = UncheckedExtrinsic,
{ {
System: frame_system::{Pallet, Call, Config<T>, Storage, Event<T>}, System: frame_system::{Pallet, Call, Config<T>, Storage, Event<T>},
Balances: pallet_balances::{Pallet, Call, Storage, Config<T>, Event<T>}, Balances: pallet_balances::{Pallet, Call, Storage, Config<T>, Event<T>},
@@ -912,12 +905,12 @@ mod tests {
type RuntimeOrigin = RuntimeOrigin; type RuntimeOrigin = RuntimeOrigin;
type RuntimeCall = RuntimeCall; type RuntimeCall = RuntimeCall;
type Index = u64; type Index = u64;
type BlockNumber = BlockNumber;
type Hash = H256; type Hash = H256;
type Hashing = BlakeTwo256; type Hashing = BlakeTwo256;
type AccountId = u64; type AccountId = u64;
type Lookup = IdentityLookup<Self::AccountId>; type Lookup = IdentityLookup<Self::AccountId>;
type Header = Header; type Block = Block;
type RuntimeEvent = RuntimeEvent; type RuntimeEvent = RuntimeEvent;
type BlockHashCount = BlockHashCount; type BlockHashCount = BlockHashCount;
type Version = (); type Version = ();
@@ -1968,7 +1961,7 @@ mod benchmarking {
assert_eq!(event, &system_event); assert_eq!(event, &system_event);
} }
fn create_fund<T: Config + paras::Config>(id: u32, end: T::BlockNumber) -> ParaId { fn create_fund<T: Config + paras::Config>(id: u32, end: BlockNumberFor<T>) -> ParaId {
let cap = BalanceOf::<T>::max_value(); let cap = BalanceOf::<T>::max_value();
let (_, offset) = T::Auctioneer::lease_period_length(); let (_, offset) = T::Auctioneer::lease_period_length();
// Set to the very beginning of lease period index 0. // Set to the very beginning of lease period index 0.
@@ -2088,7 +2081,7 @@ mod benchmarking {
let caller: T::AccountId = whitelisted_caller(); let caller: T::AccountId = whitelisted_caller();
let contributor = account("contributor", 0, 0); let contributor = account("contributor", 0, 0);
contribute_fund::<T>(&contributor, fund_index); contribute_fund::<T>(&contributor, fund_index);
frame_system::Pallet::<T>::set_block_number(T::BlockNumber::max_value()); frame_system::Pallet::<T>::set_block_number(BlockNumberFor::<T>::max_value());
}: _(RawOrigin::Signed(caller), contributor.clone(), fund_index) }: _(RawOrigin::Signed(caller), contributor.clone(), fund_index)
verify { verify {
assert_last_event::<T>(Event::<T>::Withdrew { who: contributor, fund_index, amount: T::MinContribution::get() }.into()); assert_last_event::<T>(Event::<T>::Withdrew { who: contributor, fund_index, amount: T::MinContribution::get() }.into());
@@ -2108,7 +2101,7 @@ mod benchmarking {
} }
let caller: T::AccountId = whitelisted_caller(); let caller: T::AccountId = whitelisted_caller();
frame_system::Pallet::<T>::set_block_number(T::BlockNumber::max_value()); frame_system::Pallet::<T>::set_block_number(BlockNumberFor::<T>::max_value());
}: _(RawOrigin::Signed(caller), fund_index) }: _(RawOrigin::Signed(caller), fund_index)
verify { verify {
assert_last_event::<T>(Event::<T>::AllRefunded { para_id: fund_index }.into()); assert_last_event::<T>(Event::<T>::AllRefunded { para_id: fund_index }.into());
@@ -2119,7 +2112,7 @@ mod benchmarking {
let end = lpl + offset; let end = lpl + offset;
let fund_index = create_fund::<T>(1337, end); let fund_index = create_fund::<T>(1337, end);
let caller: T::AccountId = whitelisted_caller(); let caller: T::AccountId = whitelisted_caller();
frame_system::Pallet::<T>::set_block_number(T::BlockNumber::max_value()); frame_system::Pallet::<T>::set_block_number(BlockNumberFor::<T>::max_value());
}: _(RawOrigin::Signed(caller.clone()), fund_index) }: _(RawOrigin::Signed(caller.clone()), fund_index)
verify { verify {
assert_last_event::<T>(Event::<T>::Dissolved { para_id: fund_index }.into()); assert_last_event::<T>(Event::<T>::Dissolved { para_id: fund_index }.into());
+2 -8
View File
@@ -112,20 +112,15 @@ mod tests {
use primitives::AccountId; use primitives::AccountId;
use sp_core::{ConstU64, H256}; use sp_core::{ConstU64, H256};
use sp_runtime::{ use sp_runtime::{
testing::Header,
traits::{BlakeTwo256, IdentityLookup}, traits::{BlakeTwo256, IdentityLookup},
BuildStorage, Perbill, BuildStorage, Perbill,
}; };
type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic<Test>;
type Block = frame_system::mocking::MockBlock<Test>; type Block = frame_system::mocking::MockBlock<Test>;
const TEST_ACCOUNT: AccountId = AccountId::new([1; 32]); const TEST_ACCOUNT: AccountId = AccountId::new([1; 32]);
frame_support::construct_runtime!( frame_support::construct_runtime!(
pub enum Test where pub enum Test
Block = Block,
NodeBlock = Block,
UncheckedExtrinsic = UncheckedExtrinsic,
{ {
System: frame_system::{Pallet, Call, Config<T>, Storage, Event<T>}, System: frame_system::{Pallet, Call, Config<T>, Storage, Event<T>},
Authorship: pallet_authorship::{Pallet, Storage}, Authorship: pallet_authorship::{Pallet, Storage},
@@ -153,13 +148,12 @@ mod tests {
type BaseCallFilter = frame_support::traits::Everything; type BaseCallFilter = frame_support::traits::Everything;
type RuntimeOrigin = RuntimeOrigin; type RuntimeOrigin = RuntimeOrigin;
type Index = u64; type Index = u64;
type BlockNumber = u64;
type RuntimeCall = RuntimeCall; type RuntimeCall = RuntimeCall;
type Hash = H256; type Hash = H256;
type Hashing = BlakeTwo256; type Hashing = BlakeTwo256;
type AccountId = AccountId; type AccountId = AccountId;
type Lookup = IdentityLookup<Self::AccountId>; type Lookup = IdentityLookup<Self::AccountId>;
type Header = Header; type Block = Block;
type RuntimeEvent = RuntimeEvent; type RuntimeEvent = RuntimeEvent;
type BlockHashCount = BlockHashCount; type BlockHashCount = BlockHashCount;
type BlockLength = BlockLength; type BlockLength = BlockLength;
@@ -34,7 +34,7 @@ use frame_support_test::TestRandomness;
use frame_system::EnsureRoot; use frame_system::EnsureRoot;
use parity_scale_codec::Encode; use parity_scale_codec::Encode;
use primitives::{ use primitives::{
BlockNumber, HeadData, Header, Id as ParaId, SessionIndex, ValidationCode, LOWEST_PUBLIC_ID, BlockNumber, HeadData, Id as ParaId, SessionIndex, ValidationCode, LOWEST_PUBLIC_ID,
}; };
use runtime_parachains::{ use runtime_parachains::{
configuration, origin, paras, shared, Origin as ParaOrigin, ParaLifecycle, configuration, origin, paras, shared, Origin as ParaOrigin, ParaLifecycle,
@@ -51,7 +51,7 @@ use sp_runtime::{
use sp_std::sync::Arc; use sp_std::sync::Arc;
type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic<Test>; type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic<Test>;
type Block = frame_system::mocking::MockBlock<Test>; type Block = frame_system::mocking::MockBlockU32<Test>;
type AccountId = AccountId32; type AccountId = AccountId32;
type Balance = u32; type Balance = u32;
@@ -70,10 +70,7 @@ fn signed(i: u32) -> RuntimeOrigin {
} }
frame_support::construct_runtime!( frame_support::construct_runtime!(
pub enum Test where pub enum Test
Block = Block,
NodeBlock = Block,
UncheckedExtrinsic = UncheckedExtrinsic,
{ {
// System Stuff // System Stuff
System: frame_system::{Pallet, Call, Config<T>, Storage, Event<T>}, System: frame_system::{Pallet, Call, Config<T>, Storage, Event<T>},
@@ -120,12 +117,12 @@ impl frame_system::Config for Test {
type RuntimeOrigin = RuntimeOrigin; type RuntimeOrigin = RuntimeOrigin;
type RuntimeCall = RuntimeCall; type RuntimeCall = RuntimeCall;
type Index = u64; type Index = u64;
type BlockNumber = BlockNumber;
type Hash = H256; type Hash = H256;
type Hashing = BlakeTwo256; type Hashing = BlakeTwo256;
type AccountId = AccountId; type AccountId = AccountId;
type Lookup = IdentityLookup<AccountId>; type Lookup = IdentityLookup<AccountId>;
type Header = Header; type Block = Block;
type RuntimeEvent = RuntimeEvent; type RuntimeEvent = RuntimeEvent;
type BlockHashCount = BlockHashCount; type BlockHashCount = BlockHashCount;
type Version = (); type Version = ();
+2 -1
View File
@@ -21,6 +21,7 @@ use frame_support::{
dispatch::{DispatchError, DispatchResult}, dispatch::{DispatchError, DispatchResult},
weights::Weight, weights::Weight,
}; };
use frame_system::pallet_prelude::BlockNumberFor;
use parity_scale_codec::{Decode, Encode}; use parity_scale_codec::{Decode, Encode};
use primitives::{HeadData, Id as ParaId, PvfCheckStatement, SessionIndex, ValidationCode}; use primitives::{HeadData, Id as ParaId, PvfCheckStatement, SessionIndex, ValidationCode};
use runtime_parachains::paras; use runtime_parachains::paras;
@@ -192,7 +193,7 @@ impl<T: frame_system::Config> Registrar for TestRegistrar<T> {
} }
impl<T: frame_system::Config> TestRegistrar<T> { impl<T: frame_system::Config> TestRegistrar<T> {
pub fn operations() -> Vec<(ParaId, T::BlockNumber, bool)> { pub fn operations() -> Vec<(ParaId, BlockNumberFor<T>, bool)> {
OPERATIONS OPERATIONS
.with(|x| x.borrow().iter().map(|(p, b, c)| (*p, (*b).into(), *c)).collect::<Vec<_>>()) .with(|x| x.borrow().iter().map(|(p, b, c)| (*p, (*b).into(), *c)).collect::<Vec<_>>())
} }
@@ -667,7 +667,7 @@ mod tests {
}; };
use frame_system::limits; use frame_system::limits;
use pallet_balances::Error as BalancesError; use pallet_balances::Error as BalancesError;
use primitives::{Balance, BlockNumber, Header, SessionIndex}; use primitives::{Balance, BlockNumber, SessionIndex};
use runtime_parachains::{configuration, origin, shared}; use runtime_parachains::{configuration, origin, shared};
use sp_core::H256; use sp_core::H256;
use sp_io::TestExternalities; use sp_io::TestExternalities;
@@ -680,13 +680,10 @@ mod tests {
use sp_std::collections::btree_map::BTreeMap; use sp_std::collections::btree_map::BTreeMap;
type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic<Test>; type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic<Test>;
type Block = frame_system::mocking::MockBlock<Test>; type Block = frame_system::mocking::MockBlockU32<Test>;
frame_support::construct_runtime!( frame_support::construct_runtime!(
pub enum Test where pub enum Test
Block = Block,
NodeBlock = Block,
UncheckedExtrinsic = UncheckedExtrinsic,
{ {
System: frame_system::{Pallet, Call, Config<T>, Storage, Event<T>}, System: frame_system::{Pallet, Call, Config<T>, Storage, Event<T>},
Balances: pallet_balances::{Pallet, Call, Storage, Config<T>, Event<T>}, Balances: pallet_balances::{Pallet, Call, Storage, Config<T>, Event<T>},
@@ -720,12 +717,12 @@ mod tests {
type RuntimeOrigin = RuntimeOrigin; type RuntimeOrigin = RuntimeOrigin;
type RuntimeCall = RuntimeCall; type RuntimeCall = RuntimeCall;
type Index = u64; type Index = u64;
type BlockNumber = BlockNumber;
type Hash = H256; type Hash = H256;
type Hashing = BlakeTwo256; type Hashing = BlakeTwo256;
type AccountId = u64; type AccountId = u64;
type Lookup = IdentityLookup<u64>; type Lookup = IdentityLookup<u64>;
type Header = Header; type Block = Block;
type RuntimeEvent = RuntimeEvent; type RuntimeEvent = RuntimeEvent;
type BlockHashCount = BlockHashCount; type BlockHashCount = BlockHashCount;
type DbWeight = (); type DbWeight = ();
+6 -12
View File
@@ -105,7 +105,7 @@ pub mod pallet {
/// Vesting Pallet /// Vesting Pallet
type VestingSchedule: VestingSchedule< type VestingSchedule: VestingSchedule<
Self::AccountId, Self::AccountId,
Moment = Self::BlockNumber, Moment = BlockNumberFor<Self>,
Currency = Self::Currency, Currency = Self::Currency,
>; >;
@@ -144,7 +144,7 @@ pub mod pallet {
/// A new statement was set. /// A new statement was set.
StatementUpdated, StatementUpdated,
/// A new statement was set. `[block_number]` /// A new statement was set. `[block_number]`
UnlockBlockUpdated { block_number: T::BlockNumber }, UnlockBlockUpdated { block_number: BlockNumberFor<T> },
} }
#[pallet::error] #[pallet::error]
@@ -182,7 +182,7 @@ pub mod pallet {
// The block where all locked dots will unlock. // The block where all locked dots will unlock.
#[pallet::storage] #[pallet::storage]
pub(super) type UnlockBlock<T: Config> = StorageValue<_, T::BlockNumber, ValueQuery>; pub(super) type UnlockBlock<T: Config> = StorageValue<_, BlockNumberFor<T>, ValueQuery>;
#[pallet::hooks] #[pallet::hooks]
impl<T: Config> Hooks<BlockNumberFor<T>> for Pallet<T> {} impl<T: Config> Hooks<BlockNumberFor<T>> for Pallet<T> {}
@@ -403,7 +403,7 @@ pub mod pallet {
#[pallet::weight(T::DbWeight::get().writes(1))] #[pallet::weight(T::DbWeight::get().writes(1))]
pub fn set_unlock_block( pub fn set_unlock_block(
origin: OriginFor<T>, origin: OriginFor<T>,
unlock_block: T::BlockNumber, unlock_block: BlockNumberFor<T>,
) -> DispatchResult { ) -> DispatchResult {
T::ConfigurationOrigin::ensure_origin(origin)?; T::ConfigurationOrigin::ensure_origin(origin)?;
ensure!( ensure!(
@@ -486,19 +486,14 @@ mod tests {
traits::{Currency, WithdrawReasons}, traits::{Currency, WithdrawReasons},
}; };
use sp_runtime::{ use sp_runtime::{
testing::Header,
traits::{BlakeTwo256, Dispatchable, IdentifyAccount, Identity, IdentityLookup, Verify}, traits::{BlakeTwo256, Dispatchable, IdentifyAccount, Identity, IdentityLookup, Verify},
ArithmeticError, BuildStorage, MultiSignature, ArithmeticError, BuildStorage, MultiSignature,
}; };
type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic<Test>;
type Block = frame_system::mocking::MockBlock<Test>; type Block = frame_system::mocking::MockBlock<Test>;
frame_support::construct_runtime!( frame_support::construct_runtime!(
pub enum Test where pub enum Test
Block = Block,
NodeBlock = Block,
UncheckedExtrinsic = UncheckedExtrinsic,
{ {
System: frame_system::{Pallet, Call, Config<T>, Storage, Event<T>}, System: frame_system::{Pallet, Call, Config<T>, Storage, Event<T>},
Balances: pallet_balances::{Pallet, Call, Storage, Config<T>, Event<T>}, Balances: pallet_balances::{Pallet, Call, Storage, Config<T>, Event<T>},
@@ -520,12 +515,11 @@ mod tests {
type RuntimeOrigin = RuntimeOrigin; type RuntimeOrigin = RuntimeOrigin;
type RuntimeCall = RuntimeCall; type RuntimeCall = RuntimeCall;
type Index = u64; type Index = u64;
type BlockNumber = u64;
type Hash = H256; type Hash = H256;
type Hashing = BlakeTwo256; type Hashing = BlakeTwo256;
type AccountId = AccountId; type AccountId = AccountId;
type Lookup = IdentityLookup<AccountId>; type Lookup = IdentityLookup<AccountId>;
type Header = Header; type Block = Block;
type RuntimeEvent = RuntimeEvent; type RuntimeEvent = RuntimeEvent;
type BlockHashCount = BlockHashCount; type BlockHashCount = BlockHashCount;
type Version = (); type Version = ();
+13 -17
View File
@@ -37,7 +37,7 @@ use sp_std::prelude::*;
type BalanceOf<T> = type BalanceOf<T> =
<<T as Config>::Currency as Currency<<T as frame_system::Config>::AccountId>>::Balance; <<T as Config>::Currency as Currency<<T as frame_system::Config>::AccountId>>::Balance;
type LeasePeriodOf<T> = <T as frame_system::Config>::BlockNumber; type LeasePeriodOf<T> = BlockNumberFor<T>;
pub trait WeightInfo { pub trait WeightInfo {
fn force_lease() -> Weight; fn force_lease() -> Weight;
@@ -83,11 +83,11 @@ pub mod pallet {
/// The number of blocks over which a single period lasts. /// The number of blocks over which a single period lasts.
#[pallet::constant] #[pallet::constant]
type LeasePeriod: Get<Self::BlockNumber>; type LeasePeriod: Get<BlockNumberFor<Self>>;
/// The number of blocks to offset each lease period by. /// The number of blocks to offset each lease period by.
#[pallet::constant] #[pallet::constant]
type LeaseOffset: Get<Self::BlockNumber>; type LeaseOffset: Get<BlockNumberFor<Self>>;
/// The origin which may forcibly create or clear leases. Root can always do this. /// The origin which may forcibly create or clear leases. Root can always do this.
type ForceOrigin: EnsureOrigin<<Self as frame_system::Config>::RuntimeOrigin>; type ForceOrigin: EnsureOrigin<<Self as frame_system::Config>::RuntimeOrigin>;
@@ -145,7 +145,7 @@ pub mod pallet {
#[pallet::hooks] #[pallet::hooks]
impl<T: Config> Hooks<BlockNumberFor<T>> for Pallet<T> { impl<T: Config> Hooks<BlockNumberFor<T>> for Pallet<T> {
fn on_initialize(n: T::BlockNumber) -> Weight { fn on_initialize(n: BlockNumberFor<T>) -> Weight {
if let Some((lease_period, first_block)) = Self::lease_period_index(n) { if let Some((lease_period, first_block)) = Self::lease_period_index(n) {
// If we're beginning a new lease period then handle that. // If we're beginning a new lease period then handle that.
if first_block { if first_block {
@@ -333,9 +333,9 @@ impl<T: Config> crate::traits::OnSwap for Pallet<T> {
} }
} }
impl<T: Config> Leaser<T::BlockNumber> for Pallet<T> { impl<T: Config> Leaser<BlockNumberFor<T>> for Pallet<T> {
type AccountId = T::AccountId; type AccountId = T::AccountId;
type LeasePeriod = T::BlockNumber; type LeasePeriod = BlockNumberFor<T>;
type Currency = T::Currency; type Currency = T::Currency;
fn lease_out( fn lease_out(
@@ -442,11 +442,11 @@ impl<T: Config> Leaser<T::BlockNumber> for Pallet<T> {
} }
#[cfg(any(feature = "runtime-benchmarks", test))] #[cfg(any(feature = "runtime-benchmarks", test))]
fn lease_period_length() -> (T::BlockNumber, T::BlockNumber) { fn lease_period_length() -> (BlockNumberFor<T>, BlockNumberFor<T>) {
(T::LeasePeriod::get(), T::LeaseOffset::get()) (T::LeasePeriod::get(), T::LeaseOffset::get())
} }
fn lease_period_index(b: T::BlockNumber) -> Option<(Self::LeasePeriod, bool)> { fn lease_period_index(b: BlockNumberFor<T>) -> Option<(Self::LeasePeriod, bool)> {
// Note that blocks before `LeaseOffset` do not count as any lease period. // Note that blocks before `LeaseOffset` do not count as any lease period.
let offset_block_now = b.checked_sub(&T::LeaseOffset::get())?; let offset_block_now = b.checked_sub(&T::LeaseOffset::get())?;
let lease_period = offset_block_now / T::LeasePeriod::get(); let lease_period = offset_block_now / T::LeasePeriod::get();
@@ -505,21 +505,17 @@ mod tests {
use frame_support::{assert_noop, assert_ok, parameter_types}; use frame_support::{assert_noop, assert_ok, parameter_types};
use frame_system::EnsureRoot; use frame_system::EnsureRoot;
use pallet_balances; use pallet_balances;
use primitives::{BlockNumber, Header}; use primitives::BlockNumber;
use sp_core::H256; use sp_core::H256;
use sp_runtime::{ use sp_runtime::{
traits::{BlakeTwo256, IdentityLookup}, traits::{BlakeTwo256, IdentityLookup},
BuildStorage, BuildStorage,
}; };
type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic<Test>; type Block = frame_system::mocking::MockBlockU32<Test>;
type Block = frame_system::mocking::MockBlock<Test>;
frame_support::construct_runtime!( frame_support::construct_runtime!(
pub enum Test where pub enum Test
Block = Block,
NodeBlock = Block,
UncheckedExtrinsic = UncheckedExtrinsic,
{ {
System: frame_system::{Pallet, Call, Config<T>, Storage, Event<T>}, System: frame_system::{Pallet, Call, Config<T>, Storage, Event<T>},
Balances: pallet_balances::{Pallet, Call, Storage, Config<T>, Event<T>}, Balances: pallet_balances::{Pallet, Call, Storage, Config<T>, Event<T>},
@@ -537,12 +533,12 @@ mod tests {
type RuntimeOrigin = RuntimeOrigin; type RuntimeOrigin = RuntimeOrigin;
type RuntimeCall = RuntimeCall; type RuntimeCall = RuntimeCall;
type Index = u64; type Index = u64;
type BlockNumber = BlockNumber;
type Hash = H256; type Hash = H256;
type Hashing = BlakeTwo256; type Hashing = BlakeTwo256;
type AccountId = u64; type AccountId = u64;
type Lookup = IdentityLookup<Self::AccountId>; type Lookup = IdentityLookup<Self::AccountId>;
type Header = Header; type Block = Block;
type RuntimeEvent = RuntimeEvent; type RuntimeEvent = RuntimeEvent;
type BlockHashCount = BlockHashCount; type BlockHashCount = BlockHashCount;
type DbWeight = (); type DbWeight = ();
+4 -3
View File
@@ -17,6 +17,7 @@
//! XCM sender for relay chain. //! XCM sender for relay chain.
use frame_support::traits::Get; use frame_support::traits::Get;
use frame_system::pallet_prelude::BlockNumberFor;
use parity_scale_codec::Encode; use parity_scale_codec::Encode;
use primitives::Id as ParaId; use primitives::Id as ParaId;
use runtime_parachains::{ use runtime_parachains::{
@@ -72,12 +73,12 @@ pub struct ChildParachainRouter<T, W, P>(PhantomData<(T, W, P)>);
impl<T: configuration::Config + dmp::Config, W: xcm::WrapVersion, P: PriceForParachainDelivery> impl<T: configuration::Config + dmp::Config, W: xcm::WrapVersion, P: PriceForParachainDelivery>
SendXcm for ChildParachainRouter<T, W, P> SendXcm for ChildParachainRouter<T, W, P>
{ {
type Ticket = (HostConfiguration<T::BlockNumber>, ParaId, Vec<u8>); type Ticket = (HostConfiguration<BlockNumberFor<T>>, ParaId, Vec<u8>);
fn validate( fn validate(
dest: &mut Option<MultiLocation>, dest: &mut Option<MultiLocation>,
msg: &mut Option<Xcm<()>>, msg: &mut Option<Xcm<()>>,
) -> SendResult<(HostConfiguration<T::BlockNumber>, ParaId, Vec<u8>)> { ) -> SendResult<(HostConfiguration<BlockNumberFor<T>>, ParaId, Vec<u8>)> {
let d = dest.take().ok_or(MissingArgument)?; let d = dest.take().ok_or(MissingArgument)?;
let id = if let MultiLocation { parents: 0, interior: X1(Parachain(id)) } = &d { let id = if let MultiLocation { parents: 0, interior: X1(Parachain(id)) } = &d {
*id *id
@@ -99,7 +100,7 @@ impl<T: configuration::Config + dmp::Config, W: xcm::WrapVersion, P: PriceForPar
} }
fn deliver( fn deliver(
(config, para, blob): (HostConfiguration<T::BlockNumber>, ParaId, Vec<u8>), (config, para, blob): (HostConfiguration<BlockNumberFor<T>>, ParaId, Vec<u8>),
) -> Result<XcmHash, SendError> { ) -> Result<XcmHash, SendError> {
let hash = sp_io::hashing::blake2_256(&blob[..]); let hash = sp_io::hashing::blake2_256(&blob[..]);
<dmp::Pallet<T>>::queue_downward_message(&config, para, blob) <dmp::Pallet<T>>::queue_downward_message(&config, para, blob)
+3 -6
View File
@@ -176,12 +176,12 @@ impl frame_system::Config for Runtime {
type RuntimeOrigin = RuntimeOrigin; type RuntimeOrigin = RuntimeOrigin;
type RuntimeCall = RuntimeCall; type RuntimeCall = RuntimeCall;
type Index = Nonce; type Index = Nonce;
type BlockNumber = BlockNumber;
type Hash = Hash; type Hash = Hash;
type Hashing = BlakeTwo256; type Hashing = BlakeTwo256;
type AccountId = AccountId; type AccountId = AccountId;
type Lookup = AccountIdLookup<AccountId, ()>; type Lookup = AccountIdLookup<AccountId, ()>;
type Header = generic::Header<BlockNumber, BlakeTwo256>; type Block = Block;
type RuntimeEvent = RuntimeEvent; type RuntimeEvent = RuntimeEvent;
type BlockHashCount = BlockHashCount; type BlockHashCount = BlockHashCount;
type DbWeight = RocksDbWeight; type DbWeight = RocksDbWeight;
@@ -1363,10 +1363,7 @@ impl pallet_state_trie_migration::Config for Runtime {
} }
construct_runtime! { construct_runtime! {
pub enum Runtime where pub enum Runtime
Block = Block,
NodeBlock = primitives::Block,
UncheckedExtrinsic = UncheckedExtrinsic
{ {
// Basic stuff; balances is uncallable initially. // Basic stuff; balances is uncallable initially.
System: frame_system::{Pallet, Call, Storage, Config<T>, Event<T>} = 0, System: frame_system::{Pallet, Call, Storage, Config<T>, Event<T>} = 0,
+10 -9
View File
@@ -22,6 +22,7 @@ use crate::{
}; };
use bitvec::{order::Lsb0 as BitOrderLsb0, vec::BitVec}; use bitvec::{order::Lsb0 as BitOrderLsb0, vec::BitVec};
use frame_support::pallet_prelude::*; use frame_support::pallet_prelude::*;
use frame_system::pallet_prelude::*;
use primitives::{ use primitives::{
collator_signature_payload, AvailabilityBitfield, BackedCandidate, CandidateCommitments, collator_signature_payload, AvailabilityBitfield, BackedCandidate, CandidateCommitments,
CandidateDescriptor, CandidateHash, CollatorId, CollatorSignature, CommittedCandidateReceipt, 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. /// Active validators. Validators should be declared prior to all other setup.
validators: Option<IndexedVec<ValidatorIndex, ValidatorId>>, validators: Option<IndexedVec<ValidatorIndex, ValidatorId>>,
/// Starting block number; we expect it to get incremented on session setup. /// 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. /// Starting session; we expect it to get incremented on session setup.
session: SessionIndex, session: SessionIndex,
/// Session we want the scenario to take place in. We will roll to this session. /// 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. /// Paras inherent `enter` benchmark scenario.
#[cfg(any(feature = "runtime-benchmarks", test))] #[cfg(any(feature = "runtime-benchmarks", test))]
pub(crate) struct Bench<T: paras_inherent::Config> { 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) _session: u32,
pub(crate) _block_number: T::BlockNumber, pub(crate) _block_number: BlockNumberFor<T>,
} }
impl<T: paras_inherent::Config> BenchBuilder<T> { impl<T: paras_inherent::Config> BenchBuilder<T> {
@@ -150,8 +151,8 @@ impl<T: paras_inherent::Config> BenchBuilder<T> {
} }
/// Mock header. /// Mock header.
pub(crate) fn header(block_number: T::BlockNumber) -> T::Header { pub(crate) fn header(block_number: BlockNumberFor<T>) -> HeaderFor<T> {
T::Header::new( HeaderFor::<T>::new(
block_number, // `block_number`, block_number, // `block_number`,
Default::default(), // `extrinsics_root`, Default::default(), // `extrinsics_root`,
Default::default(), // `storage_root`, Default::default(), // `storage_root`,
@@ -260,8 +261,8 @@ impl<T: paras_inherent::Config> BenchBuilder<T> {
core_idx: CoreIndex, core_idx: CoreIndex,
candidate_hash: CandidateHash, candidate_hash: CandidateHash,
availability_votes: BitVec<u8, BitOrderLsb0>, availability_votes: BitVec<u8, BitOrderLsb0>,
) -> inclusion::CandidatePendingAvailability<T::Hash, T::BlockNumber> { ) -> inclusion::CandidatePendingAvailability<T::Hash, BlockNumberFor<T>> {
inclusion::CandidatePendingAvailability::<T::Hash, T::BlockNumber>::new( inclusion::CandidatePendingAvailability::<T::Hash, BlockNumberFor<T>>::new(
core_idx, // core core_idx, // core
candidate_hash, // hash candidate_hash, // hash
Self::candidate_descriptor_mock(), // candidate descriptor Self::candidate_descriptor_mock(), // candidate descriptor
@@ -405,7 +406,7 @@ impl<T: paras_inherent::Config> BenchBuilder<T> {
Self::run_to_block(block); 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()); let header = Self::header(block_number.clone());
frame_system::Pallet::<T>::reset_events(); frame_system::Pallet::<T>::reset_events();
@@ -523,7 +524,7 @@ impl<T: paras_inherent::Config> BenchBuilder<T> {
// candidate receipt. // candidate receipt.
paras::Pallet::<T>::heads_insert(&para_id, head_data.clone()); 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()); past_code_meta.note_replacement(0u32.into(), 0u32.into());
let group_validators = scheduler::Pallet::<T>::group_validators(group_idx).unwrap(); let group_validators = scheduler::Pallet::<T>::group_validators(group_idx).unwrap();
@@ -503,7 +503,7 @@ pub mod pallet {
#[pallet::storage] #[pallet::storage]
#[pallet::getter(fn config)] #[pallet::getter(fn config)]
pub(crate) type ActiveConfig<T: Config> = pub(crate) type ActiveConfig<T: Config> =
StorageValue<_, HostConfiguration<T::BlockNumber>, ValueQuery>; StorageValue<_, HostConfiguration<BlockNumberFor<T>>, ValueQuery>;
/// Pending configuration changes. /// Pending configuration changes.
/// ///
@@ -514,7 +514,7 @@ pub mod pallet {
/// 2 items: for the next session and for the `scheduled_session`. /// 2 items: for the next session and for the `scheduled_session`.
#[pallet::storage] #[pallet::storage]
pub(crate) type PendingConfigs<T: Config> = 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 /// If this is set, then the configuration setters will bypass the consistency checks. This
/// is meant to be used only as the last resort. /// is meant to be used only as the last resort.
@@ -524,7 +524,7 @@ pub mod pallet {
#[pallet::genesis_config] #[pallet::genesis_config]
#[derive(DefaultNoBound)] #[derive(DefaultNoBound)]
pub struct GenesisConfig<T: Config> { pub struct GenesisConfig<T: Config> {
pub config: HostConfiguration<T::BlockNumber>, pub config: HostConfiguration<BlockNumberFor<T>>,
} }
#[pallet::genesis_build] #[pallet::genesis_build]
@@ -545,7 +545,7 @@ pub mod pallet {
))] ))]
pub fn set_validation_upgrade_cooldown( pub fn set_validation_upgrade_cooldown(
origin: OriginFor<T>, origin: OriginFor<T>,
new: T::BlockNumber, new: BlockNumberFor<T>,
) -> DispatchResult { ) -> DispatchResult {
ensure_root(origin)?; ensure_root(origin)?;
Self::schedule_config_update(|config| { Self::schedule_config_update(|config| {
@@ -561,7 +561,7 @@ pub mod pallet {
))] ))]
pub fn set_validation_upgrade_delay( pub fn set_validation_upgrade_delay(
origin: OriginFor<T>, origin: OriginFor<T>,
new: T::BlockNumber, new: BlockNumberFor<T>,
) -> DispatchResult { ) -> DispatchResult {
ensure_root(origin)?; ensure_root(origin)?;
Self::schedule_config_update(|config| { Self::schedule_config_update(|config| {
@@ -577,7 +577,7 @@ pub mod pallet {
))] ))]
pub fn set_code_retention_period( pub fn set_code_retention_period(
origin: OriginFor<T>, origin: OriginFor<T>,
new: T::BlockNumber, new: BlockNumberFor<T>,
) -> DispatchResult { ) -> DispatchResult {
ensure_root(origin)?; ensure_root(origin)?;
Self::schedule_config_update(|config| { Self::schedule_config_update(|config| {
@@ -658,7 +658,7 @@ pub mod pallet {
))] ))]
pub fn set_group_rotation_frequency( pub fn set_group_rotation_frequency(
origin: OriginFor<T>, origin: OriginFor<T>,
new: T::BlockNumber, new: BlockNumberFor<T>,
) -> DispatchResult { ) -> DispatchResult {
ensure_root(origin)?; ensure_root(origin)?;
Self::schedule_config_update(|config| { Self::schedule_config_update(|config| {
@@ -674,7 +674,7 @@ pub mod pallet {
))] ))]
pub fn set_chain_availability_period( pub fn set_chain_availability_period(
origin: OriginFor<T>, origin: OriginFor<T>,
new: T::BlockNumber, new: BlockNumberFor<T>,
) -> DispatchResult { ) -> DispatchResult {
ensure_root(origin)?; ensure_root(origin)?;
Self::schedule_config_update(|config| { Self::schedule_config_update(|config| {
@@ -690,7 +690,7 @@ pub mod pallet {
))] ))]
pub fn set_thread_availability_period( pub fn set_thread_availability_period(
origin: OriginFor<T>, origin: OriginFor<T>,
new: T::BlockNumber, new: BlockNumberFor<T>,
) -> DispatchResult { ) -> DispatchResult {
ensure_root(origin)?; ensure_root(origin)?;
Self::schedule_config_update(|config| { Self::schedule_config_update(|config| {
@@ -761,7 +761,7 @@ pub mod pallet {
))] ))]
pub fn set_dispute_post_conclusion_acceptance_period( pub fn set_dispute_post_conclusion_acceptance_period(
origin: OriginFor<T>, origin: OriginFor<T>,
new: T::BlockNumber, new: BlockNumberFor<T>,
) -> DispatchResult { ) -> DispatchResult {
ensure_root(origin)?; ensure_root(origin)?;
Self::schedule_config_update(|config| { Self::schedule_config_update(|config| {
@@ -1087,7 +1087,7 @@ pub mod pallet {
))] ))]
pub fn set_minimum_validation_upgrade_delay( pub fn set_minimum_validation_upgrade_delay(
origin: OriginFor<T>, origin: OriginFor<T>,
new: T::BlockNumber, new: BlockNumberFor<T>,
) -> DispatchResult { ) -> DispatchResult {
ensure_root(origin)?; ensure_root(origin)?;
Self::schedule_config_update(|config| { Self::schedule_config_update(|config| {
@@ -1162,7 +1162,7 @@ pub struct SessionChangeOutcome<BlockNumber> {
impl<T: Config> Pallet<T> { impl<T: Config> Pallet<T> {
/// Called by the initializer to initialize the configuration pallet. /// 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() Weight::zero()
} }
@@ -1176,7 +1176,7 @@ impl<T: Config> Pallet<T> {
/// be the same. /// be the same.
pub(crate) fn initializer_on_new_session( pub(crate) fn initializer_on_new_session(
session_index: &SessionIndex, session_index: &SessionIndex,
) -> SessionChangeOutcome<T::BlockNumber> { ) -> SessionChangeOutcome<BlockNumberFor<T>> {
let pending_configs = <PendingConfigs<T>>::get(); let pending_configs = <PendingConfigs<T>>::get();
let prev_config = ActiveConfig::<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 /// 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 /// only when enabling parachains runtime pallets for the first time on a chain which has
/// been running without them. /// 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); 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. // the sake of essentially avoiding an indirect call. Doesn't worth it.
#[inline(never)] #[inline(never)]
pub(crate) fn schedule_config_update( pub(crate) fn schedule_config_update(
updater: impl FnOnce(&mut HostConfiguration<T::BlockNumber>), updater: impl FnOnce(&mut HostConfiguration<BlockNumberFor<T>>),
) -> DispatchResult { ) -> DispatchResult {
let mut pending_configs = <PendingConfigs<T>>::get(); let mut pending_configs = <PendingConfigs<T>>::get();
+21 -20
View File
@@ -298,9 +298,9 @@ impl<BlockNumber: Ord> DisputesHandler<BlockNumber> for () {
fn initializer_on_new_session(_notification: &SessionChangeNotification<BlockNumber>) {} fn initializer_on_new_session(_notification: &SessionChangeNotification<BlockNumber>) {}
} }
impl<T: Config> DisputesHandler<T::BlockNumber> for pallet::Pallet<T> impl<T: Config> DisputesHandler<BlockNumberFor<T>> for pallet::Pallet<T>
where where
T::BlockNumber: Ord, BlockNumberFor<T>: Ord,
{ {
fn is_frozen() -> bool { fn is_frozen() -> bool {
pallet::Pallet::<T>::is_frozen() pallet::Pallet::<T>::is_frozen()
@@ -308,7 +308,7 @@ where
fn filter_dispute_data( fn filter_dispute_data(
set: DisputeStatementSet, set: DisputeStatementSet,
post_conclusion_acceptance_period: T::BlockNumber, post_conclusion_acceptance_period: BlockNumberFor<T>,
) -> Option<CheckedDisputeStatementSet> { ) -> Option<CheckedDisputeStatementSet> {
pallet::Pallet::<T>::filter_dispute_data(&set, post_conclusion_acceptance_period) pallet::Pallet::<T>::filter_dispute_data(&set, post_conclusion_acceptance_period)
.filter_statement_set(set) .filter_statement_set(set)
@@ -323,7 +323,7 @@ where
fn note_included( fn note_included(
session: SessionIndex, session: SessionIndex,
candidate_hash: CandidateHash, candidate_hash: CandidateHash,
included_in: T::BlockNumber, included_in: BlockNumberFor<T>,
) { ) {
pallet::Pallet::<T>::note_included(session, candidate_hash, included_in) pallet::Pallet::<T>::note_included(session, candidate_hash, included_in)
} }
@@ -331,7 +331,7 @@ where
fn included_state( fn included_state(
session: SessionIndex, session: SessionIndex,
candidate_hash: CandidateHash, candidate_hash: CandidateHash,
) -> Option<T::BlockNumber> { ) -> Option<BlockNumberFor<T>> {
pallet::Pallet::<T>::included_state(session, candidate_hash) pallet::Pallet::<T>::included_state(session, candidate_hash)
} }
@@ -339,7 +339,7 @@ where
pallet::Pallet::<T>::concluded_invalid(session, candidate_hash) pallet::Pallet::<T>::concluded_invalid(session, candidate_hash)
} }
fn initializer_initialize(now: T::BlockNumber) -> Weight { fn initializer_initialize(now: BlockNumberFor<T>) -> Weight {
pallet::Pallet::<T>::initializer_initialize(now) pallet::Pallet::<T>::initializer_initialize(now)
} }
@@ -347,7 +347,7 @@ where
pallet::Pallet::<T>::initializer_finalize() pallet::Pallet::<T>::initializer_finalize()
} }
fn initializer_on_new_session(notification: &SessionChangeNotification<T::BlockNumber>) { fn initializer_on_new_session(notification: &SessionChangeNotification<BlockNumberFor<T>>) {
pallet::Pallet::<T>::initializer_on_new_session(notification) pallet::Pallet::<T>::initializer_on_new_session(notification)
} }
} }
@@ -373,7 +373,7 @@ pub mod pallet {
pub trait Config: frame_system::Config + configuration::Config + session_info::Config { pub trait Config: frame_system::Config + configuration::Config + session_info::Config {
type RuntimeEvent: From<Event<Self>> + IsType<<Self as frame_system::Config>::RuntimeEvent>; type RuntimeEvent: From<Event<Self>> + IsType<<Self as frame_system::Config>::RuntimeEvent>;
type RewardValidators: RewardValidators; type RewardValidators: RewardValidators;
type SlashingHandler: SlashingHandler<Self::BlockNumber>; type SlashingHandler: SlashingHandler<BlockNumberFor<Self>>;
/// Weight information for extrinsics in this pallet. /// Weight information for extrinsics in this pallet.
type WeightInfo: WeightInfo; type WeightInfo: WeightInfo;
@@ -400,7 +400,7 @@ pub mod pallet {
SessionIndex, SessionIndex,
Blake2_128Concat, Blake2_128Concat,
CandidateHash, CandidateHash,
DisputeState<T::BlockNumber>, DisputeState<BlockNumberFor<T>>,
>; >;
/// Backing votes stored for each dispute. /// Backing votes stored for each dispute.
@@ -424,7 +424,7 @@ pub mod pallet {
SessionIndex, SessionIndex,
Blake2_128Concat, Blake2_128Concat,
CandidateHash, CandidateHash,
T::BlockNumber, BlockNumberFor<T>,
>; >;
/// Whether the chain is frozen. Starts as `None`. When this is `Some`, /// Whether the chain is frozen. Starts as `None`. When this is `Some`,
@@ -433,7 +433,7 @@ pub mod pallet {
/// It can only be set back to `None` by governance intervention. /// It can only be set back to `None` by governance intervention.
#[pallet::storage] #[pallet::storage]
#[pallet::getter(fn last_valid_block)] #[pallet::getter(fn last_valid_block)]
pub(super) type Frozen<T: Config> = StorageValue<_, Option<T::BlockNumber>, ValueQuery>; pub(super) type Frozen<T: Config> = StorageValue<_, Option<BlockNumberFor<T>>, ValueQuery>;
#[pallet::event] #[pallet::event]
#[pallet::generate_deposit(pub fn deposit_event)] #[pallet::generate_deposit(pub fn deposit_event)]
@@ -447,7 +447,7 @@ pub mod pallet {
/// Block authors should no longer build on top of this head and should /// Block authors should no longer build on top of this head and should
/// instead revert the block at the given height. This should be the /// instead revert the block at the given height. This should be the
/// number of the child of the last known valid block in the chain. /// number of the child of the last known valid block in the chain.
Revert(T::BlockNumber), Revert(BlockNumberFor<T>),
} }
#[pallet::error] #[pallet::error]
@@ -854,7 +854,7 @@ impl StatementSetFilter {
impl<T: Config> Pallet<T> { impl<T: Config> Pallet<T> {
/// Called by the initializer to initialize the disputes module. /// Called by the initializer to initialize the disputes module.
pub(crate) fn initializer_initialize(_now: T::BlockNumber) -> Weight { pub(crate) fn initializer_initialize(_now: BlockNumberFor<T>) -> Weight {
Weight::zero() Weight::zero()
} }
@@ -863,7 +863,7 @@ impl<T: Config> Pallet<T> {
/// Called by the initializer to note a new session in the disputes pallet. /// Called by the initializer to note a new session in the disputes pallet.
pub(crate) fn initializer_on_new_session( pub(crate) fn initializer_on_new_session(
notification: &SessionChangeNotification<T::BlockNumber>, notification: &SessionChangeNotification<BlockNumberFor<T>>,
) { ) {
let config = <configuration::Pallet<T>>::config(); let config = <configuration::Pallet<T>>::config();
@@ -937,7 +937,7 @@ impl<T: Config> Pallet<T> {
// Disputes without enough votes to get confirmed are also filtered out. // Disputes without enough votes to get confirmed are also filtered out.
fn filter_dispute_data( fn filter_dispute_data(
set: &DisputeStatementSet, set: &DisputeStatementSet,
post_conclusion_acceptance_period: <T as frame_system::Config>::BlockNumber, post_conclusion_acceptance_period: BlockNumberFor<T>,
) -> StatementSetFilter { ) -> StatementSetFilter {
let mut filter = StatementSetFilter::RemoveIndices(Vec::new()); let mut filter = StatementSetFilter::RemoveIndices(Vec::new());
@@ -1048,7 +1048,7 @@ impl<T: Config> Pallet<T> {
/// dispute is fresh. /// dispute is fresh.
fn process_checked_dispute_data( fn process_checked_dispute_data(
set: &CheckedDisputeStatementSet, set: &CheckedDisputeStatementSet,
dispute_post_conclusion_acceptance_period: T::BlockNumber, dispute_post_conclusion_acceptance_period: BlockNumberFor<T>,
) -> Result<bool, DispatchError> { ) -> Result<bool, DispatchError> {
// Dispute statement sets on any dispute which concluded // Dispute statement sets on any dispute which concluded
// before this point are to be rejected. // before this point are to be rejected.
@@ -1189,14 +1189,15 @@ impl<T: Config> Pallet<T> {
} }
#[allow(unused)] #[allow(unused)]
pub(crate) fn disputes() -> Vec<(SessionIndex, CandidateHash, DisputeState<T::BlockNumber>)> { pub(crate) fn disputes() -> Vec<(SessionIndex, CandidateHash, DisputeState<BlockNumberFor<T>>)>
{
<Disputes<T>>::iter().collect() <Disputes<T>>::iter().collect()
} }
pub(crate) fn note_included( pub(crate) fn note_included(
session: SessionIndex, session: SessionIndex,
candidate_hash: CandidateHash, candidate_hash: CandidateHash,
included_in: T::BlockNumber, included_in: BlockNumberFor<T>,
) { ) {
if included_in.is_zero() { if included_in.is_zero() {
return return
@@ -1216,7 +1217,7 @@ impl<T: Config> Pallet<T> {
pub(crate) fn included_state( pub(crate) fn included_state(
session: SessionIndex, session: SessionIndex,
candidate_hash: CandidateHash, candidate_hash: CandidateHash,
) -> Option<T::BlockNumber> { ) -> Option<BlockNumberFor<T>> {
<Included<T>>::get(session, candidate_hash) <Included<T>>::get(session, candidate_hash)
} }
@@ -1231,7 +1232,7 @@ impl<T: Config> Pallet<T> {
Self::last_valid_block().is_some() Self::last_valid_block().is_some()
} }
pub(crate) fn revert_and_freeze(revert_to: T::BlockNumber) { pub(crate) fn revert_and_freeze(revert_to: BlockNumberFor<T>) {
if Self::last_valid_block().map_or(true, |last| last > revert_to) { if Self::last_valid_block().map_or(true, |last| last > revert_to) {
Frozen::<T>::set(Some(revert_to)); Frozen::<T>::set(Some(revert_to));
@@ -48,6 +48,7 @@ use frame_support::{
traits::{Defensive, Get, KeyOwnerProofSystem, ValidatorSet, ValidatorSetWithIdentification}, traits::{Defensive, Get, KeyOwnerProofSystem, ValidatorSet, ValidatorSetWithIdentification},
weights::Weight, weights::Weight,
}; };
use frame_system::pallet_prelude::BlockNumberFor;
use primitives::{ use primitives::{
vstaging::slashing::{DisputeProof, DisputesTimeSlot, PendingSlashes, SlashingOffenceKind}, vstaging::slashing::{DisputeProof, DisputesTimeSlot, PendingSlashes, SlashingOffenceKind},
@@ -270,7 +271,7 @@ where
} }
} }
impl<T> disputes::SlashingHandler<T::BlockNumber> for SlashValidatorsForDisputes<Pallet<T>> impl<T> disputes::SlashingHandler<BlockNumberFor<T>> for SlashValidatorsForDisputes<Pallet<T>>
where where
T: Config<KeyOwnerIdentification = IdentificationTuple<T>>, T: Config<KeyOwnerIdentification = IdentificationTuple<T>>,
{ {
@@ -294,7 +295,7 @@ where
// NOTE: changing that requires modifying `do_punish` implementation // NOTE: changing that requires modifying `do_punish` implementation
} }
fn initializer_initialize(now: T::BlockNumber) -> Weight { fn initializer_initialize(now: BlockNumberFor<T>) -> Weight {
Pallet::<T>::initializer_initialize(now) Pallet::<T>::initializer_initialize(now)
} }
@@ -529,7 +530,7 @@ pub mod pallet {
impl<T: Config> Pallet<T> { impl<T: Config> Pallet<T> {
/// Called by the initializer to initialize the disputes slashing module. /// Called by the initializer to initialize the disputes slashing module.
fn initializer_initialize(_now: T::BlockNumber) -> Weight { fn initializer_initialize(_now: BlockNumberFor<T>) -> Weight {
Weight::zero() Weight::zero()
} }
@@ -19,7 +19,7 @@ use super::*;
use crate::{disputes::SlashingHandler, initializer, shared}; use crate::{disputes::SlashingHandler, initializer, shared};
use frame_benchmarking::{benchmarks, whitelist_account}; use frame_benchmarking::{benchmarks, whitelist_account};
use frame_support::traits::{OnFinalize, OnInitialize}; use frame_support::traits::{OnFinalize, OnInitialize};
use frame_system::RawOrigin; use frame_system::{pallet_prelude::BlockNumberFor, RawOrigin};
use pallet_staking::testing_utils::create_validators; use pallet_staking::testing_utils::create_validators;
use parity_scale_codec::Decode; use parity_scale_codec::Decode;
use primitives::{Hash, PARACHAIN_KEY_TYPE_ID}; use primitives::{Hash, PARACHAIN_KEY_TYPE_ID};
@@ -70,13 +70,13 @@ where
.expect("session::set_keys should work"); .expect("session::set_keys should work");
} }
pallet_session::Pallet::<T>::on_initialize(T::BlockNumber::one()); pallet_session::Pallet::<T>::on_initialize(BlockNumberFor::<T>::one());
initializer::Pallet::<T>::on_initialize(T::BlockNumber::one()); initializer::Pallet::<T>::on_initialize(BlockNumberFor::<T>::one());
// skip sessions until the new validator set is enacted // skip sessions until the new validator set is enacted
while pallet_session::Pallet::<T>::validators().len() < n as usize { while pallet_session::Pallet::<T>::validators().len() < n as usize {
pallet_session::Pallet::<T>::rotate_session(); pallet_session::Pallet::<T>::rotate_session();
} }
initializer::Pallet::<T>::on_finalize(T::BlockNumber::one()); initializer::Pallet::<T>::on_finalize(BlockNumberFor::<T>::one());
let session_index = crate::shared::Pallet::<T>::session_index(); let session_index = crate::shared::Pallet::<T>::session_index();
let session_info = crate::session_info::Pallet::<T>::session_info(session_index); let session_info = crate::session_info::Pallet::<T>::session_info(session_index);
@@ -86,9 +86,9 @@ where
let key_owner_proof = pallet_session::historical::Pallet::<T>::prove(key).unwrap(); let key_owner_proof = pallet_session::historical::Pallet::<T>::prove(key).unwrap();
// rotate a session to make sure `key_owner_proof` is historical // rotate a session to make sure `key_owner_proof` is historical
initializer::Pallet::<T>::on_initialize(T::BlockNumber::one()); initializer::Pallet::<T>::on_initialize(BlockNumberFor::<T>::one());
pallet_session::Pallet::<T>::rotate_session(); pallet_session::Pallet::<T>::rotate_session();
initializer::Pallet::<T>::on_finalize(T::BlockNumber::one()); initializer::Pallet::<T>::on_finalize(BlockNumberFor::<T>::one());
let idx = crate::shared::Pallet::<T>::session_index(); let idx = crate::shared::Pallet::<T>::session_index();
assert!( assert!(
@@ -28,6 +28,7 @@ use frame_support::{
assert_err, assert_noop, assert_ok, assert_err, assert_noop, assert_ok,
traits::{OnFinalize, OnInitialize}, traits::{OnFinalize, OnInitialize},
}; };
use frame_system::pallet_prelude::BlockNumberFor;
use primitives::BlockNumber; use primitives::BlockNumber;
use sp_core::{crypto::CryptoType, Pair}; use sp_core::{crypto::CryptoType, Pair};
@@ -2054,9 +2055,10 @@ fn deduplication_and_sorting_works() {
let disputes_orig = disputes.clone(); let disputes_orig = disputes.clone();
<Pallet<Test> as DisputesHandler< <Pallet<Test> as DisputesHandler<BlockNumberFor<Test>>>::deduplicate_and_sort_dispute_data(
<Test as frame_system::Config>::BlockNumber, &mut disputes,
>>::deduplicate_and_sort_dispute_data(&mut disputes).unwrap_err(); )
.unwrap_err();
// assert ordering of local only disputes, and at the same time, and being free of duplicates // assert ordering of local only disputes, and at the same time, and being free of duplicates
assert_eq!(disputes_orig.len(), disputes.len() + 1); assert_eq!(disputes_orig.len(), disputes.len() + 1);
@@ -2083,7 +2085,8 @@ fn apply_filter_all<T: Config, I: IntoIterator<Item = DisputeStatementSet>>(
let mut acc = Vec::<CheckedDisputeStatementSet>::new(); let mut acc = Vec::<CheckedDisputeStatementSet>::new();
for dispute_statement in sets { for dispute_statement in sets {
if let Some(checked) = <Pallet<T> as DisputesHandler<<T>::BlockNumber>>::filter_dispute_data( if let Some(checked) =
<Pallet<T> as DisputesHandler<BlockNumberFor<T>>>::filter_dispute_data(
dispute_statement, dispute_statement,
post_conclusion_acceptance_period, post_conclusion_acceptance_period,
) { ) {
@@ -2158,9 +2161,11 @@ fn filter_removes_duplicates_within_set() {
}; };
let post_conclusion_acceptance_period = 10; let post_conclusion_acceptance_period = 10;
let statements = <Pallet<Test> as DisputesHandler< let statements =
<Test as frame_system::Config>::BlockNumber, <Pallet<Test> as DisputesHandler<BlockNumberFor<Test>>>::filter_dispute_data(
>>::filter_dispute_data(statements, post_conclusion_acceptance_period); statements,
post_conclusion_acceptance_period,
);
assert_eq!( assert_eq!(
statements, statements,
@@ -2446,7 +2451,7 @@ fn filter_removes_duplicate_statements_sets() {
// `Err(())` indicates presence of duplicates // `Err(())` indicates presence of duplicates
assert!(<Pallet::<Test> as DisputesHandler< assert!(<Pallet::<Test> as DisputesHandler<
<Test as frame_system::Config>::BlockNumber, BlockNumberFor<Test>,
>>::deduplicate_and_sort_dispute_data(&mut sets) >>::deduplicate_and_sort_dispute_data(&mut sets)
.is_err()); .is_err());
+9 -6
View File
@@ -47,6 +47,7 @@ use crate::{
initializer, FeeTracker, initializer, FeeTracker,
}; };
use frame_support::pallet_prelude::*; use frame_support::pallet_prelude::*;
use frame_system::pallet_prelude::BlockNumberFor;
use primitives::{DownwardMessage, Hash, Id as ParaId, InboundDownwardMessage}; use primitives::{DownwardMessage, Hash, Id as ParaId, InboundDownwardMessage};
use sp_core::MAX_POSSIBLE_ALLOCATION; use sp_core::MAX_POSSIBLE_ALLOCATION;
use sp_runtime::{ use sp_runtime::{
@@ -121,7 +122,7 @@ pub mod pallet {
_, _,
Twox64Concat, Twox64Concat,
ParaId, ParaId,
Vec<InboundDownwardMessage<T::BlockNumber>>, Vec<InboundDownwardMessage<BlockNumberFor<T>>>,
ValueQuery, ValueQuery,
>; >;
@@ -150,7 +151,7 @@ pub mod pallet {
/// Routines and getters related to downward message passing. /// Routines and getters related to downward message passing.
impl<T: Config> Pallet<T> { impl<T: Config> Pallet<T> {
/// Block initialization logic, called by initializer. /// Block initialization logic, called by initializer.
pub(crate) fn initializer_initialize(_now: T::BlockNumber) -> Weight { pub(crate) fn initializer_initialize(_now: BlockNumberFor<T>) -> Weight {
Weight::zero() Weight::zero()
} }
@@ -159,7 +160,7 @@ impl<T: Config> Pallet<T> {
/// Called by the initializer to note that a new session has started. /// Called by the initializer to note that a new session has started.
pub(crate) fn initializer_on_new_session( pub(crate) fn initializer_on_new_session(
_notification: &initializer::SessionChangeNotification<T::BlockNumber>, _notification: &initializer::SessionChangeNotification<BlockNumberFor<T>>,
outgoing_paras: &[ParaId], outgoing_paras: &[ParaId],
) { ) {
Self::perform_outgoing_para_cleanup(outgoing_paras); Self::perform_outgoing_para_cleanup(outgoing_paras);
@@ -183,7 +184,7 @@ impl<T: Config> Pallet<T> {
/// in an error. If this returns `Ok(())` the caller can be certain that a call to /// in an error. If this returns `Ok(())` the caller can be certain that a call to
/// `queue_downward_message` with the same parameters will be successful. /// `queue_downward_message` with the same parameters will be successful.
pub fn can_queue_downward_message( pub fn can_queue_downward_message(
config: &HostConfiguration<T::BlockNumber>, config: &HostConfiguration<BlockNumberFor<T>>,
para: &ParaId, para: &ParaId,
msg: &DownwardMessage, msg: &DownwardMessage,
) -> Result<(), QueueDownwardMessageError> { ) -> Result<(), QueueDownwardMessageError> {
@@ -209,7 +210,7 @@ impl<T: Config> Pallet<T> {
/// to a dangling storage. If the caller cannot statically prove that the recipient exists /// to a dangling storage. If the caller cannot statically prove that the recipient exists
/// then the caller should perform a runtime check. /// then the caller should perform a runtime check.
pub fn queue_downward_message( pub fn queue_downward_message(
config: &HostConfiguration<T::BlockNumber>, config: &HostConfiguration<BlockNumberFor<T>>,
para: ParaId, para: ParaId,
msg: DownwardMessage, msg: DownwardMessage,
) -> Result<(), QueueDownwardMessageError> { ) -> Result<(), QueueDownwardMessageError> {
@@ -316,7 +317,9 @@ impl<T: Config> Pallet<T> {
/// Returns the downward message queue contents for the given para. /// Returns the downward message queue contents for the given para.
/// ///
/// The most recent messages are the latest in the vector. /// The most recent messages are the latest in the vector.
pub(crate) fn dmq_contents(recipient: ParaId) -> Vec<InboundDownwardMessage<T::BlockNumber>> { pub(crate) fn dmq_contents(
recipient: ParaId,
) -> Vec<InboundDownwardMessage<BlockNumberFor<T>>> {
DownwardMessageQueues::<T>::get(&recipient) DownwardMessageQueues::<T>::get(&recipient)
} }
+14 -14
View File
@@ -369,7 +369,7 @@ pub mod pallet {
/// Invariant: /// Invariant:
/// - each para `P` used here as a key should satisfy `Paras::is_valid_para(P)` within a session. /// - each para `P` used here as a key should satisfy `Paras::is_valid_para(P)` within a session.
#[pallet::storage] #[pallet::storage]
pub type HrmpWatermarks<T: Config> = StorageMap<_, Twox64Concat, ParaId, T::BlockNumber>; pub type HrmpWatermarks<T: Config> = StorageMap<_, Twox64Concat, ParaId, BlockNumberFor<T>>;
/// HRMP channel data associated with each para. /// HRMP channel data associated with each para.
/// Invariant: /// Invariant:
@@ -407,7 +407,7 @@ pub mod pallet {
_, _,
Twox64Concat, Twox64Concat,
HrmpChannelId, HrmpChannelId,
Vec<InboundHrmpMessage<T::BlockNumber>>, Vec<InboundHrmpMessage<BlockNumberFor<T>>>,
ValueQuery, ValueQuery,
>; >;
@@ -419,7 +419,7 @@ pub mod pallet {
/// same block number. /// same block number.
#[pallet::storage] #[pallet::storage]
pub type HrmpChannelDigests<T: Config> = pub type HrmpChannelDigests<T: Config> =
StorageMap<_, Twox64Concat, ParaId, Vec<(T::BlockNumber, Vec<ParaId>)>, ValueQuery>; StorageMap<_, Twox64Concat, ParaId, Vec<(BlockNumberFor<T>, Vec<ParaId>)>, ValueQuery>;
/// Preopen the given HRMP channels. /// Preopen the given HRMP channels.
/// ///
@@ -659,7 +659,7 @@ fn preopen_hrmp_channel<T: Config>(
/// Routines and getters related to HRMP. /// Routines and getters related to HRMP.
impl<T: Config> Pallet<T> { impl<T: Config> Pallet<T> {
/// Block initialization logic, called by initializer. /// Block initialization logic, called by initializer.
pub(crate) fn initializer_initialize(_now: T::BlockNumber) -> Weight { pub(crate) fn initializer_initialize(_now: BlockNumberFor<T>) -> Weight {
Weight::zero() Weight::zero()
} }
@@ -668,7 +668,7 @@ impl<T: Config> Pallet<T> {
/// Called by the initializer to note that a new session has started. /// Called by the initializer to note that a new session has started.
pub(crate) fn initializer_on_new_session( pub(crate) fn initializer_on_new_session(
notification: &initializer::SessionChangeNotification<T::BlockNumber>, notification: &initializer::SessionChangeNotification<BlockNumberFor<T>>,
outgoing_paras: &[ParaId], outgoing_paras: &[ParaId],
) -> Weight { ) -> Weight {
let w1 = Self::perform_outgoing_para_cleanup(&notification.prev_config, outgoing_paras); let w1 = Self::perform_outgoing_para_cleanup(&notification.prev_config, outgoing_paras);
@@ -685,7 +685,7 @@ impl<T: Config> Pallet<T> {
/// Iterate over all paras that were noted for offboarding and remove all the data /// Iterate over all paras that were noted for offboarding and remove all the data
/// associated with them. /// associated with them.
fn perform_outgoing_para_cleanup( fn perform_outgoing_para_cleanup(
config: &HostConfiguration<T::BlockNumber>, config: &HostConfiguration<BlockNumberFor<T>>,
outgoing: &[ParaId], outgoing: &[ParaId],
) -> Weight { ) -> Weight {
let mut w = Self::clean_open_channel_requests(config, outgoing); let mut w = Self::clean_open_channel_requests(config, outgoing);
@@ -710,7 +710,7 @@ impl<T: Config> Pallet<T> {
// //
// This will also perform the refunds for the counterparty if it doesn't offboard. // This will also perform the refunds for the counterparty if it doesn't offboard.
pub(crate) fn clean_open_channel_requests( pub(crate) fn clean_open_channel_requests(
config: &HostConfiguration<T::BlockNumber>, config: &HostConfiguration<BlockNumberFor<T>>,
outgoing: &[ParaId], outgoing: &[ParaId],
) -> Weight { ) -> Weight {
// First collect all the channel ids of the open requests in which there is at least one // First collect all the channel ids of the open requests in which there is at least one
@@ -786,7 +786,7 @@ impl<T: Config> Pallet<T> {
/// ///
/// - prune the stale requests /// - prune the stale requests
/// - enact the confirmed requests /// - enact the confirmed requests
fn process_hrmp_open_channel_requests(config: &HostConfiguration<T::BlockNumber>) { fn process_hrmp_open_channel_requests(config: &HostConfiguration<BlockNumberFor<T>>) {
let mut open_req_channels = HrmpOpenChannelRequestsList::<T>::get(); let mut open_req_channels = HrmpOpenChannelRequestsList::<T>::get();
if open_req_channels.is_empty() { if open_req_channels.is_empty() {
return return
@@ -894,9 +894,9 @@ impl<T: Config> Pallet<T> {
/// Check that the candidate of the given recipient controls the HRMP watermark properly. /// Check that the candidate of the given recipient controls the HRMP watermark properly.
pub(crate) fn check_hrmp_watermark( pub(crate) fn check_hrmp_watermark(
recipient: ParaId, recipient: ParaId,
relay_chain_parent_number: T::BlockNumber, relay_chain_parent_number: BlockNumberFor<T>,
new_hrmp_watermark: T::BlockNumber, new_hrmp_watermark: BlockNumberFor<T>,
) -> Result<(), HrmpWatermarkAcceptanceErr<T::BlockNumber>> { ) -> Result<(), HrmpWatermarkAcceptanceErr<BlockNumberFor<T>>> {
// First, check where the watermark CANNOT legally land. // First, check where the watermark CANNOT legally land.
// //
// (a) For ensuring that messages are eventually processed, we require each parablock's // (a) For ensuring that messages are eventually processed, we require each parablock's
@@ -942,7 +942,7 @@ impl<T: Config> Pallet<T> {
} }
pub(crate) fn check_outbound_hrmp( pub(crate) fn check_outbound_hrmp(
config: &HostConfiguration<T::BlockNumber>, config: &HostConfiguration<BlockNumberFor<T>>,
sender: ParaId, sender: ParaId,
out_hrmp_msgs: &[OutboundHrmpMessage<ParaId>], out_hrmp_msgs: &[OutboundHrmpMessage<ParaId>],
) -> Result<(), OutboundHrmpAcceptanceErr> { ) -> Result<(), OutboundHrmpAcceptanceErr> {
@@ -1005,7 +1005,7 @@ impl<T: Config> Pallet<T> {
Ok(()) Ok(())
} }
pub(crate) fn prune_hrmp(recipient: ParaId, new_hrmp_watermark: T::BlockNumber) -> Weight { pub(crate) fn prune_hrmp(recipient: ParaId, new_hrmp_watermark: BlockNumberFor<T>) -> Weight {
let mut weight = Weight::zero(); let mut weight = Weight::zero();
// sift through the incoming messages digest to collect the paras that sent at least one // sift through the incoming messages digest to collect the paras that sent at least one
@@ -1390,7 +1390,7 @@ impl<T: Config> Pallet<T> {
/// messages in them are also included. /// messages in them are also included.
pub(crate) fn inbound_hrmp_channels_contents( pub(crate) fn inbound_hrmp_channels_contents(
recipient: ParaId, recipient: ParaId,
) -> BTreeMap<ParaId, Vec<InboundHrmpMessage<T::BlockNumber>>> { ) -> BTreeMap<ParaId, Vec<InboundHrmpMessage<BlockNumberFor<T>>>> {
let sender_set = HrmpIngressChannelsIndex::<T>::get(&recipient); let sender_set = HrmpIngressChannelsIndex::<T>::get(&recipient);
let mut inbound_hrmp_channels_contents = BTreeMap::new(); let mut inbound_hrmp_channels_contents = BTreeMap::new();
@@ -33,6 +33,7 @@ use frame_support::{
traits::{Defensive, EnqueueMessage}, traits::{Defensive, EnqueueMessage},
BoundedSlice, BoundedSlice,
}; };
use frame_system::pallet_prelude::*;
use pallet_message_queue::OnQueueChanged; use pallet_message_queue::OnQueueChanged;
use parity_scale_codec::{Decode, Encode}; use parity_scale_codec::{Decode, Encode};
use primitives::{ use primitives::{
@@ -270,7 +271,7 @@ pub mod pallet {
+ configuration::Config + configuration::Config
{ {
type RuntimeEvent: From<Event<Self>> + IsType<<Self as frame_system::Config>::RuntimeEvent>; type RuntimeEvent: From<Event<Self>> + IsType<<Self as frame_system::Config>::RuntimeEvent>;
type DisputesHandler: disputes::DisputesHandler<Self::BlockNumber>; type DisputesHandler: disputes::DisputesHandler<BlockNumberFor<Self>>;
type RewardValidators: RewardValidators; type RewardValidators: RewardValidators;
/// The system message queue. /// The system message queue.
@@ -365,12 +366,16 @@ pub mod pallet {
/// The latest bitfield for each validator, referred to by their index in the validator set. /// The latest bitfield for each validator, referred to by their index in the validator set.
#[pallet::storage] #[pallet::storage]
pub(crate) type AvailabilityBitfields<T: Config> = pub(crate) type AvailabilityBitfields<T: Config> =
StorageMap<_, Twox64Concat, ValidatorIndex, AvailabilityBitfieldRecord<T::BlockNumber>>; StorageMap<_, Twox64Concat, ValidatorIndex, AvailabilityBitfieldRecord<BlockNumberFor<T>>>;
/// Candidates pending availability by `ParaId`. /// Candidates pending availability by `ParaId`.
#[pallet::storage] #[pallet::storage]
pub(crate) type PendingAvailability<T: Config> = pub(crate) type PendingAvailability<T: Config> = StorageMap<
StorageMap<_, Twox64Concat, ParaId, CandidatePendingAvailability<T::Hash, T::BlockNumber>>; _,
Twox64Concat,
ParaId,
CandidatePendingAvailability<T::Hash, BlockNumberFor<T>>,
>;
/// The commitments of candidates pending availability, by `ParaId`. /// The commitments of candidates pending availability, by `ParaId`.
#[pallet::storage] #[pallet::storage]
@@ -450,7 +455,7 @@ impl fmt::Debug for UmpAcceptanceCheckErr {
impl<T: Config> Pallet<T> { impl<T: Config> Pallet<T> {
/// Block initialization logic, called by initializer. /// Block initialization logic, called by initializer.
pub(crate) fn initializer_initialize(_now: T::BlockNumber) -> Weight { pub(crate) fn initializer_initialize(_now: BlockNumberFor<T>) -> Weight {
Weight::zero() Weight::zero()
} }
@@ -459,7 +464,7 @@ impl<T: Config> Pallet<T> {
/// Handle an incoming session change. /// Handle an incoming session change.
pub(crate) fn initializer_on_new_session( pub(crate) fn initializer_on_new_session(
_notification: &crate::initializer::SessionChangeNotification<T::BlockNumber>, _notification: &crate::initializer::SessionChangeNotification<BlockNumberFor<T>>,
outgoing_paras: &[ParaId], outgoing_paras: &[ParaId],
) { ) {
// unlike most drain methods, drained elements are not cleared on `Drop` of the iterator // unlike most drain methods, drained elements are not cleared on `Drop` of the iterator
@@ -832,7 +837,7 @@ impl<T: Config> Pallet<T> {
&validation_outputs.new_validation_code, &validation_outputs.new_validation_code,
validation_outputs.processed_downward_messages, validation_outputs.processed_downward_messages,
&validation_outputs.upward_messages, &validation_outputs.upward_messages,
T::BlockNumber::from(validation_outputs.hrmp_watermark), BlockNumberFor::<T>::from(validation_outputs.hrmp_watermark),
&validation_outputs.horizontal_messages, &validation_outputs.horizontal_messages,
) )
.is_err() .is_err()
@@ -849,7 +854,7 @@ impl<T: Config> Pallet<T> {
} }
fn enact_candidate( fn enact_candidate(
relay_parent_number: T::BlockNumber, relay_parent_number: BlockNumberFor<T>,
receipt: CommittedCandidateReceipt<T::Hash>, receipt: CommittedCandidateReceipt<T::Hash>,
backers: BitVec<u8, BitOrderLsb0>, backers: BitVec<u8, BitOrderLsb0>,
availability_votes: BitVec<u8, BitOrderLsb0>, availability_votes: BitVec<u8, BitOrderLsb0>,
@@ -898,7 +903,7 @@ impl<T: Config> Pallet<T> {
)); ));
weight.saturating_accrue(<hrmp::Pallet<T>>::prune_hrmp( weight.saturating_accrue(<hrmp::Pallet<T>>::prune_hrmp(
receipt.descriptor.para_id, receipt.descriptor.para_id,
T::BlockNumber::from(commitments.hrmp_watermark), BlockNumberFor::<T>::from(commitments.hrmp_watermark),
)); ));
weight.saturating_accrue(<hrmp::Pallet<T>>::queue_outbound_hrmp( weight.saturating_accrue(<hrmp::Pallet<T>>::queue_outbound_hrmp(
receipt.descriptor.para_id, receipt.descriptor.para_id,
@@ -921,7 +926,7 @@ impl<T: Config> Pallet<T> {
/// Check that all the upward messages sent by a candidate pass the acceptance criteria. /// Check that all the upward messages sent by a candidate pass the acceptance criteria.
pub(crate) fn check_upward_messages( pub(crate) fn check_upward_messages(
config: &HostConfiguration<T::BlockNumber>, config: &HostConfiguration<BlockNumberFor<T>>,
para: ParaId, para: ParaId,
upward_messages: &[UpwardMessage], upward_messages: &[UpwardMessage],
) -> Result<(), UmpAcceptanceCheckErr> { ) -> Result<(), UmpAcceptanceCheckErr> {
@@ -1020,7 +1025,7 @@ impl<T: Config> Pallet<T> {
/// ///
/// Returns a vector of cleaned-up core IDs. /// Returns a vector of cleaned-up core IDs.
pub(crate) fn collect_pending( pub(crate) fn collect_pending(
pred: impl Fn(CoreIndex, T::BlockNumber) -> bool, pred: impl Fn(CoreIndex, BlockNumberFor<T>) -> bool,
) -> Vec<CoreIndex> { ) -> Vec<CoreIndex> {
let mut cleaned_up_ids = Vec::new(); let mut cleaned_up_ids = Vec::new();
let mut cleaned_up_cores = Vec::new(); let mut cleaned_up_cores = Vec::new();
@@ -1115,7 +1120,7 @@ impl<T: Config> Pallet<T> {
/// para provided, if any. /// para provided, if any.
pub(crate) fn pending_availability( pub(crate) fn pending_availability(
para: ParaId, para: ParaId,
) -> Option<CandidatePendingAvailability<T::Hash, T::BlockNumber>> { ) -> Option<CandidatePendingAvailability<T::Hash, BlockNumberFor<T>>> {
<PendingAvailability<T>>::get(&para) <PendingAvailability<T>>::get(&para)
} }
} }
@@ -1162,9 +1167,9 @@ impl<T: Config> OnQueueChanged<AggregateMessageOrigin> for Pallet<T> {
/// A collection of data required for checking a candidate. /// A collection of data required for checking a candidate.
pub(crate) struct CandidateCheckContext<T: Config> { pub(crate) struct CandidateCheckContext<T: Config> {
config: configuration::HostConfiguration<T::BlockNumber>, config: configuration::HostConfiguration<BlockNumberFor<T>>,
now: T::BlockNumber, now: BlockNumberFor<T>,
relay_parent_number: T::BlockNumber, relay_parent_number: BlockNumberFor<T>,
} }
/// An error indicating that creating Persisted Validation Data failed /// An error indicating that creating Persisted Validation Data failed
@@ -1172,7 +1177,7 @@ pub(crate) struct CandidateCheckContext<T: Config> {
pub(crate) struct FailedToCreatePVD; pub(crate) struct FailedToCreatePVD;
impl<T: Config> CandidateCheckContext<T> { impl<T: Config> CandidateCheckContext<T> {
pub(crate) fn new(now: T::BlockNumber, relay_parent_number: T::BlockNumber) -> Self { pub(crate) fn new(now: BlockNumberFor<T>, relay_parent_number: BlockNumberFor<T>) -> Self {
Self { config: <configuration::Pallet<T>>::config(), now, relay_parent_number } Self { config: <configuration::Pallet<T>>::config(), now, relay_parent_number }
} }
@@ -1244,7 +1249,7 @@ impl<T: Config> CandidateCheckContext<T> {
&backed_candidate.candidate.commitments.new_validation_code, &backed_candidate.candidate.commitments.new_validation_code,
backed_candidate.candidate.commitments.processed_downward_messages, backed_candidate.candidate.commitments.processed_downward_messages,
&backed_candidate.candidate.commitments.upward_messages, &backed_candidate.candidate.commitments.upward_messages,
T::BlockNumber::from(backed_candidate.candidate.commitments.hrmp_watermark), BlockNumberFor::<T>::from(backed_candidate.candidate.commitments.hrmp_watermark),
&backed_candidate.candidate.commitments.horizontal_messages, &backed_candidate.candidate.commitments.horizontal_messages,
) { ) {
log::debug!( log::debug!(
@@ -1267,9 +1272,9 @@ impl<T: Config> CandidateCheckContext<T> {
new_validation_code: &Option<primitives::ValidationCode>, new_validation_code: &Option<primitives::ValidationCode>,
processed_downward_messages: u32, processed_downward_messages: u32,
upward_messages: &[primitives::UpwardMessage], upward_messages: &[primitives::UpwardMessage],
hrmp_watermark: T::BlockNumber, hrmp_watermark: BlockNumberFor<T>,
horizontal_messages: &[primitives::OutboundHrmpMessage<ParaId>], horizontal_messages: &[primitives::OutboundHrmpMessage<ParaId>],
) -> Result<(), AcceptanceCheckErr<T::BlockNumber>> { ) -> Result<(), AcceptanceCheckErr<BlockNumberFor<T>>> {
ensure!( ensure!(
head_data.0.len() <= self.config.max_head_data_size as _, head_data.0.len() <= self.config.max_head_data_size as _,
AcceptanceCheckErr::HeadDataTooLarge, AcceptanceCheckErr::HeadDataTooLarge,
@@ -116,7 +116,7 @@ pub mod pallet {
+ hrmp::Config + hrmp::Config
{ {
/// A randomness beacon. /// A randomness beacon.
type Randomness: Randomness<Self::Hash, Self::BlockNumber>; type Randomness: Randomness<Self::Hash, BlockNumberFor<Self>>;
/// An origin which is allowed to force updates to parachains. /// An origin which is allowed to force updates to parachains.
type ForceOrigin: EnsureOrigin<<Self as frame_system::Config>::RuntimeOrigin>; type ForceOrigin: EnsureOrigin<<Self as frame_system::Config>::RuntimeOrigin>;
/// Weight information for extrinsics in this pallet. /// Weight information for extrinsics in this pallet.
@@ -147,7 +147,7 @@ pub mod pallet {
#[pallet::hooks] #[pallet::hooks]
impl<T: Config> Hooks<BlockNumberFor<T>> for Pallet<T> { impl<T: Config> Hooks<BlockNumberFor<T>> for Pallet<T> {
fn on_initialize(now: T::BlockNumber) -> Weight { fn on_initialize(now: BlockNumberFor<T>) -> Weight {
// The other modules are initialized in this order: // The other modules are initialized in this order:
// - Configuration // - Configuration
// - Paras // - Paras
@@ -174,7 +174,7 @@ pub mod pallet {
total_weight total_weight
} }
fn on_finalize(now: T::BlockNumber) { fn on_finalize(now: BlockNumberFor<T>) {
// reverse initialization order. // reverse initialization order.
hrmp::Pallet::<T>::initializer_finalize(); hrmp::Pallet::<T>::initializer_finalize();
dmp::Pallet::<T>::initializer_finalize(); dmp::Pallet::<T>::initializer_finalize();
+6 -9
View File
@@ -34,8 +34,8 @@ use frame_support::{
use frame_support_test::TestRandomness; use frame_support_test::TestRandomness;
use parity_scale_codec::Decode; use parity_scale_codec::Decode;
use primitives::{ use primitives::{
AuthorityDiscoveryId, Balance, BlockNumber, CandidateHash, Header, Moment, SessionIndex, AuthorityDiscoveryId, Balance, BlockNumber, CandidateHash, Moment, SessionIndex, UpwardMessage,
UpwardMessage, ValidationCode, ValidatorIndex, ValidationCode, ValidatorIndex,
}; };
use sp_core::{ConstU32, H256}; use sp_core::{ConstU32, H256};
use sp_io::TestExternalities; use sp_io::TestExternalities;
@@ -47,13 +47,10 @@ use sp_runtime::{
use std::{cell::RefCell, collections::HashMap}; use std::{cell::RefCell, collections::HashMap};
type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic<Test>; type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic<Test>;
type Block = frame_system::mocking::MockBlock<Test>; type Block = frame_system::mocking::MockBlockU32<Test>;
frame_support::construct_runtime!( frame_support::construct_runtime!(
pub enum Test where pub enum Test
Block = Block,
NodeBlock = Block,
UncheckedExtrinsic = UncheckedExtrinsic,
{ {
System: frame_system, System: frame_system,
Balances: pallet_balances, Balances: pallet_balances,
@@ -100,12 +97,12 @@ impl frame_system::Config for Test {
type RuntimeOrigin = RuntimeOrigin; type RuntimeOrigin = RuntimeOrigin;
type RuntimeCall = RuntimeCall; type RuntimeCall = RuntimeCall;
type Index = u64; type Index = u64;
type BlockNumber = BlockNumber;
type Hash = H256; type Hash = H256;
type Hashing = BlakeTwo256; type Hashing = BlakeTwo256;
type AccountId = u64; type AccountId = u64;
type Lookup = IdentityLookup<u64>; type Lookup = IdentityLookup<u64>;
type Header = Header; type Block = Block;
type RuntimeEvent = RuntimeEvent; type RuntimeEvent = RuntimeEvent;
type BlockHashCount = BlockHashCount; type BlockHashCount = BlockHashCount;
type Version = (); type Version = ();
@@ -17,7 +17,7 @@
use super::*; use super::*;
use crate::configuration::HostConfiguration; use crate::configuration::HostConfiguration;
use frame_benchmarking::benchmarks; use frame_benchmarking::benchmarks;
use frame_system::RawOrigin; use frame_system::{pallet_prelude::BlockNumberFor, RawOrigin};
use primitives::{HeadData, Id as ParaId, ValidationCode, MAX_CODE_SIZE, MAX_HEAD_DATA_SIZE}; use primitives::{HeadData, Id as ParaId, ValidationCode, MAX_CODE_SIZE, MAX_HEAD_DATA_SIZE};
use sp_runtime::traits::{One, Saturating}; use sp_runtime::traits::{One, Saturating};
@@ -44,7 +44,7 @@ fn generate_disordered_pruning<T: Config>() {
for i in 0..SAMPLE_SIZE { for i in 0..SAMPLE_SIZE {
let id = ParaId::from(i); let id = ParaId::from(i);
let block_number = T::BlockNumber::from(1000u32); let block_number = BlockNumberFor::<T>::from(1000u32);
needs_pruning.push((id, block_number)); needs_pruning.push((id, block_number));
} }
@@ -57,7 +57,7 @@ pub(crate) fn generate_disordered_upgrades<T: Config>() {
for i in 0..SAMPLE_SIZE { for i in 0..SAMPLE_SIZE {
let id = ParaId::from(i); let id = ParaId::from(i);
let block_number = T::BlockNumber::from(1000u32); let block_number = BlockNumberFor::<T>::from(1000u32);
upgrades.push((id, block_number)); upgrades.push((id, block_number));
cooldowns.push((id, block_number)); cooldowns.push((id, block_number));
} }
@@ -103,7 +103,7 @@ benchmarks! {
let c in 1 .. MAX_CODE_SIZE; let c in 1 .. MAX_CODE_SIZE;
let new_code = ValidationCode(vec![0; c as usize]); let new_code = ValidationCode(vec![0; c as usize]);
let para_id = ParaId::from(c as u32); let para_id = ParaId::from(c as u32);
let block = T::BlockNumber::from(c); let block = BlockNumberFor::<T>::from(c);
generate_disordered_upgrades::<T>(); generate_disordered_upgrades::<T>();
}: _(RawOrigin::Root, para_id, new_code, block) }: _(RawOrigin::Root, para_id, new_code, block)
verify { verify {
@@ -118,7 +118,7 @@ benchmarks! {
// schedule an expired code upgrade for this `para_id` so that force_note_new_head would use // schedule an expired code upgrade for this `para_id` so that force_note_new_head would use
// the worst possible code path // the worst possible code path
let expired = frame_system::Pallet::<T>::block_number().saturating_sub(One::one()); let expired = frame_system::Pallet::<T>::block_number().saturating_sub(One::one());
let config = HostConfiguration::<T::BlockNumber>::default(); let config = HostConfiguration::<BlockNumberFor<T>>::default();
generate_disordered_pruning::<T>(); generate_disordered_pruning::<T>();
Pallet::<T>::schedule_code_upgrade(para_id, ValidationCode(vec![0]), expired, &config); Pallet::<T>::schedule_code_upgrade(para_id, ValidationCode(vec![0]), expired, &config);
}: _(RawOrigin::Root, para_id, new_head) }: _(RawOrigin::Root, para_id, new_head)
+36 -34
View File
@@ -550,7 +550,7 @@ pub mod pallet {
#[pallet::constant] #[pallet::constant]
type UnsignedPriority: Get<TransactionPriority>; type UnsignedPriority: Get<TransactionPriority>;
type NextSessionRotation: EstimateNextSessionRotation<Self::BlockNumber>; type NextSessionRotation: EstimateNextSessionRotation<BlockNumberFor<Self>>;
/// Retrieve how many UMP messages are enqueued for this para-chain. /// Retrieve how many UMP messages are enqueued for this para-chain.
/// ///
@@ -623,7 +623,7 @@ pub mod pallet {
_, _,
Twox64Concat, Twox64Concat,
ValidationCodeHash, ValidationCodeHash,
PvfCheckActiveVoteState<T::BlockNumber>, PvfCheckActiveVoteState<BlockNumberFor<T>>,
OptionQuery, OptionQuery,
>; >;
@@ -662,7 +662,7 @@ pub mod pallet {
/// Corresponding code can be retrieved with [`CodeByHash`]. /// Corresponding code can be retrieved with [`CodeByHash`].
#[pallet::storage] #[pallet::storage]
pub(super) type PastCodeHash<T: Config> = pub(super) type PastCodeHash<T: Config> =
StorageMap<_, Twox64Concat, (ParaId, T::BlockNumber), ValidationCodeHash>; StorageMap<_, Twox64Concat, (ParaId, BlockNumberFor<T>), ValidationCodeHash>;
/// Past code of parachains. The parachains themselves may not be registered anymore, /// Past code of parachains. The parachains themselves may not be registered anymore,
/// but we also keep their code on-chain for the same amount of time as outdated code /// but we also keep their code on-chain for the same amount of time as outdated code
@@ -670,7 +670,7 @@ pub mod pallet {
#[pallet::storage] #[pallet::storage]
#[pallet::getter(fn past_code_meta)] #[pallet::getter(fn past_code_meta)]
pub(super) type PastCodeMeta<T: Config> = pub(super) type PastCodeMeta<T: Config> =
StorageMap<_, Twox64Concat, ParaId, ParaPastCodeMeta<T::BlockNumber>, ValueQuery>; StorageMap<_, Twox64Concat, ParaId, ParaPastCodeMeta<BlockNumberFor<T>>, ValueQuery>;
/// Which paras have past code that needs pruning and the relay-chain block at which the code was replaced. /// Which paras have past code that needs pruning and the relay-chain block at which the code was replaced.
/// Note that this is the actual height of the included block, not the expected height at which the /// Note that this is the actual height of the included block, not the expected height at which the
@@ -680,7 +680,7 @@ pub mod pallet {
/// Multiple entries for a single para are permitted. Ordered ascending by block number. /// Multiple entries for a single para are permitted. Ordered ascending by block number.
#[pallet::storage] #[pallet::storage]
pub(super) type PastCodePruning<T: Config> = pub(super) type PastCodePruning<T: Config> =
StorageValue<_, Vec<(ParaId, T::BlockNumber)>, ValueQuery>; StorageValue<_, Vec<(ParaId, BlockNumberFor<T>)>, ValueQuery>;
/// The block number at which the planned code change is expected for a para. /// The block number at which the planned code change is expected for a para.
/// The change will be applied after the first parablock for this ID included which executes /// The change will be applied after the first parablock for this ID included which executes
@@ -688,7 +688,7 @@ pub mod pallet {
#[pallet::storage] #[pallet::storage]
#[pallet::getter(fn future_code_upgrade_at)] #[pallet::getter(fn future_code_upgrade_at)]
pub(super) type FutureCodeUpgrades<T: Config> = pub(super) type FutureCodeUpgrades<T: Config> =
StorageMap<_, Twox64Concat, ParaId, T::BlockNumber>; StorageMap<_, Twox64Concat, ParaId, BlockNumberFor<T>>;
/// The actual future code hash of a para. /// The actual future code hash of a para.
/// ///
@@ -728,7 +728,7 @@ pub mod pallet {
/// Ordered ascending by block number. /// Ordered ascending by block number.
#[pallet::storage] #[pallet::storage]
pub(super) type UpgradeCooldowns<T: Config> = pub(super) type UpgradeCooldowns<T: Config> =
StorageValue<_, Vec<(ParaId, T::BlockNumber)>, ValueQuery>; StorageValue<_, Vec<(ParaId, BlockNumberFor<T>)>, ValueQuery>;
/// The list of upcoming code upgrades. Each item is a pair of which para performs a code /// The list of upcoming code upgrades. Each item is a pair of which para performs a code
/// upgrade and at which relay-chain block it is expected at. /// upgrade and at which relay-chain block it is expected at.
@@ -736,7 +736,7 @@ pub mod pallet {
/// Ordered ascending by block number. /// Ordered ascending by block number.
#[pallet::storage] #[pallet::storage]
pub(super) type UpcomingUpgrades<T: Config> = pub(super) type UpcomingUpgrades<T: Config> =
StorageValue<_, Vec<(ParaId, T::BlockNumber)>, ValueQuery>; StorageValue<_, Vec<(ParaId, BlockNumberFor<T>)>, ValueQuery>;
/// The actions to perform during the start of a specific session index. /// The actions to perform during the start of a specific session index.
#[pallet::storage] #[pallet::storage]
@@ -838,7 +838,7 @@ pub mod pallet {
origin: OriginFor<T>, origin: OriginFor<T>,
para: ParaId, para: ParaId,
new_code: ValidationCode, new_code: ValidationCode,
relay_parent_number: T::BlockNumber, relay_parent_number: BlockNumberFor<T>,
) -> DispatchResult { ) -> DispatchResult {
ensure_root(origin)?; ensure_root(origin)?;
let config = configuration::Pallet::<T>::config(); let config = configuration::Pallet::<T>::config();
@@ -1145,13 +1145,13 @@ impl<T: Config> Pallet<T> {
} }
/// Called by the initializer to initialize the paras pallet. /// Called by the initializer to initialize the paras pallet.
pub(crate) fn initializer_initialize(now: T::BlockNumber) -> Weight { pub(crate) fn initializer_initialize(now: BlockNumberFor<T>) -> Weight {
let weight = Self::prune_old_code(now); let weight = Self::prune_old_code(now);
weight + Self::process_scheduled_upgrade_changes(now) weight + Self::process_scheduled_upgrade_changes(now)
} }
/// Called by the initializer to finalize the paras pallet. /// Called by the initializer to finalize the paras pallet.
pub(crate) fn initializer_finalize(now: T::BlockNumber) { pub(crate) fn initializer_finalize(now: BlockNumberFor<T>) {
Self::process_scheduled_upgrade_cooldowns(now); Self::process_scheduled_upgrade_cooldowns(now);
} }
@@ -1159,7 +1159,7 @@ impl<T: Config> Pallet<T> {
/// ///
/// Returns the list of outgoing paras from the actions queue. /// Returns the list of outgoing paras from the actions queue.
pub(crate) fn initializer_on_new_session( pub(crate) fn initializer_on_new_session(
notification: &SessionChangeNotification<T::BlockNumber>, notification: &SessionChangeNotification<BlockNumberFor<T>>,
) -> Vec<ParaId> { ) -> Vec<ParaId> {
let outgoing_paras = Self::apply_actions_queue(notification.session_index); let outgoing_paras = Self::apply_actions_queue(notification.session_index);
Self::groom_ongoing_pvf_votes(&notification.new_config, notification.validators.len()); Self::groom_ongoing_pvf_votes(&notification.new_config, notification.validators.len());
@@ -1275,8 +1275,8 @@ impl<T: Config> Pallet<T> {
// (i.e. number of `relay_parent` in the receipt) // (i.e. number of `relay_parent` in the receipt)
fn note_past_code( fn note_past_code(
id: ParaId, id: ParaId,
at: T::BlockNumber, at: BlockNumberFor<T>,
now: T::BlockNumber, now: BlockNumberFor<T>,
old_code_hash: ValidationCodeHash, old_code_hash: ValidationCodeHash,
) -> Weight { ) -> Weight {
PastCodeMeta::<T>::mutate(&id, |past_meta| { PastCodeMeta::<T>::mutate(&id, |past_meta| {
@@ -1298,7 +1298,7 @@ impl<T: Config> Pallet<T> {
// looks at old code metadata, compares them to the current acceptance window, and prunes those // looks at old code metadata, compares them to the current acceptance window, and prunes those
// that are too old. // that are too old.
fn prune_old_code(now: T::BlockNumber) -> Weight { fn prune_old_code(now: BlockNumberFor<T>) -> Weight {
let config = configuration::Pallet::<T>::config(); let config = configuration::Pallet::<T>::config();
let code_retention_period = config.code_retention_period; let code_retention_period = config.code_retention_period;
if now <= code_retention_period { if now <= code_retention_period {
@@ -1310,7 +1310,7 @@ impl<T: Config> Pallet<T> {
let pruning_height = now - (code_retention_period + One::one()); let pruning_height = now - (code_retention_period + One::one());
let pruning_tasks_done = let pruning_tasks_done =
PastCodePruning::<T>::mutate(|pruning_tasks: &mut Vec<(_, T::BlockNumber)>| { PastCodePruning::<T>::mutate(|pruning_tasks: &mut Vec<(_, BlockNumberFor<T>)>| {
let (pruning_tasks_done, pruning_tasks_to_do) = { let (pruning_tasks_done, pruning_tasks_to_do) = {
// find all past code that has just exited the pruning window. // find all past code that has just exited the pruning window.
let up_to_idx = let up_to_idx =
@@ -1358,11 +1358,11 @@ impl<T: Config> Pallet<T> {
/// the upgrade restriction, that will happen in the `initializer_finalize` function. However, /// the upgrade restriction, that will happen in the `initializer_finalize` function. However,
/// this function does count the number of cooldown timers expired so that we can reserve weight /// this function does count the number of cooldown timers expired so that we can reserve weight
/// for the `initializer_finalize` function. /// for the `initializer_finalize` function.
fn process_scheduled_upgrade_changes(now: T::BlockNumber) -> Weight { fn process_scheduled_upgrade_changes(now: BlockNumberFor<T>) -> Weight {
// account weight for `UpcomingUpgrades::mutate`. // account weight for `UpcomingUpgrades::mutate`.
let mut weight = T::DbWeight::get().reads_writes(1, 1); let mut weight = T::DbWeight::get().reads_writes(1, 1);
let upgrades_signaled = UpcomingUpgrades::<T>::mutate( let upgrades_signaled = UpcomingUpgrades::<T>::mutate(
|upcoming_upgrades: &mut Vec<(ParaId, T::BlockNumber)>| { |upcoming_upgrades: &mut Vec<(ParaId, BlockNumberFor<T>)>| {
let num = upcoming_upgrades.iter().take_while(|&(_, at)| at <= &now).count(); let num = upcoming_upgrades.iter().take_while(|&(_, at)| at <= &now).count();
for (para, _) in upcoming_upgrades.drain(..num) { for (para, _) in upcoming_upgrades.drain(..num) {
UpgradeGoAheadSignal::<T>::insert(&para, UpgradeGoAhead::GoAhead); UpgradeGoAheadSignal::<T>::insert(&para, UpgradeGoAhead::GoAhead);
@@ -1389,8 +1389,9 @@ impl<T: Config> Pallet<T> {
/// Actually perform unsetting the expired upgrade restrictions. /// Actually perform unsetting the expired upgrade restrictions.
/// ///
/// See `process_scheduled_upgrade_changes` for more details. /// See `process_scheduled_upgrade_changes` for more details.
fn process_scheduled_upgrade_cooldowns(now: T::BlockNumber) { fn process_scheduled_upgrade_cooldowns(now: BlockNumberFor<T>) {
UpgradeCooldowns::<T>::mutate(|upgrade_cooldowns: &mut Vec<(ParaId, T::BlockNumber)>| { UpgradeCooldowns::<T>::mutate(
|upgrade_cooldowns: &mut Vec<(ParaId, BlockNumberFor<T>)>| {
// Remove all expired signals and also prune the cooldowns. // Remove all expired signals and also prune the cooldowns.
upgrade_cooldowns.retain(|(para, at)| { upgrade_cooldowns.retain(|(para, at)| {
if at <= &now { if at <= &now {
@@ -1400,13 +1401,14 @@ impl<T: Config> Pallet<T> {
true true
} }
}); });
}); },
);
} }
/// Goes over all PVF votes in progress, reinitializes ballots, increments ages and prunes the /// Goes over all PVF votes in progress, reinitializes ballots, increments ages and prunes the
/// active votes that reached their time-to-live. /// active votes that reached their time-to-live.
fn groom_ongoing_pvf_votes( fn groom_ongoing_pvf_votes(
cfg: &configuration::HostConfiguration<T::BlockNumber>, cfg: &configuration::HostConfiguration<BlockNumberFor<T>>,
new_n_validators: usize, new_n_validators: usize,
) -> Weight { ) -> Weight {
let mut weight = T::DbWeight::get().reads(1); let mut weight = T::DbWeight::get().reads(1);
@@ -1456,11 +1458,11 @@ impl<T: Config> Pallet<T> {
} }
fn enact_pvf_accepted( fn enact_pvf_accepted(
now: T::BlockNumber, now: BlockNumberFor<T>,
code_hash: &ValidationCodeHash, code_hash: &ValidationCodeHash,
causes: &[PvfCheckCause<T::BlockNumber>], causes: &[PvfCheckCause<BlockNumberFor<T>>],
sessions_observed: SessionIndex, sessions_observed: SessionIndex,
cfg: &configuration::HostConfiguration<T::BlockNumber>, cfg: &configuration::HostConfiguration<BlockNumberFor<T>>,
) -> Weight { ) -> Weight {
let mut weight = Weight::zero(); let mut weight = Weight::zero();
for cause in causes { for cause in causes {
@@ -1503,9 +1505,9 @@ impl<T: Config> Pallet<T> {
fn proceed_with_upgrade( fn proceed_with_upgrade(
id: ParaId, id: ParaId,
code_hash: &ValidationCodeHash, code_hash: &ValidationCodeHash,
now: T::BlockNumber, now: BlockNumberFor<T>,
relay_parent_number: T::BlockNumber, relay_parent_number: BlockNumberFor<T>,
cfg: &configuration::HostConfiguration<T::BlockNumber>, cfg: &configuration::HostConfiguration<BlockNumberFor<T>>,
) -> Weight { ) -> Weight {
let mut weight = Weight::zero(); let mut weight = Weight::zero();
@@ -1545,7 +1547,7 @@ impl<T: Config> Pallet<T> {
fn enact_pvf_rejected( fn enact_pvf_rejected(
code_hash: &ValidationCodeHash, code_hash: &ValidationCodeHash,
causes: Vec<PvfCheckCause<T::BlockNumber>>, causes: Vec<PvfCheckCause<BlockNumberFor<T>>>,
) -> Weight { ) -> Weight {
let mut weight = Weight::zero(); let mut weight = Weight::zero();
@@ -1766,8 +1768,8 @@ impl<T: Config> Pallet<T> {
pub(crate) fn schedule_code_upgrade( pub(crate) fn schedule_code_upgrade(
id: ParaId, id: ParaId,
new_code: ValidationCode, new_code: ValidationCode,
relay_parent_number: T::BlockNumber, relay_parent_number: BlockNumberFor<T>,
cfg: &configuration::HostConfiguration<T::BlockNumber>, cfg: &configuration::HostConfiguration<BlockNumberFor<T>>,
) -> Weight { ) -> Weight {
let mut weight = T::DbWeight::get().reads(1); let mut weight = T::DbWeight::get().reads(1);
@@ -1840,10 +1842,10 @@ impl<T: Config> Pallet<T> {
/// ///
/// Unconditionally increases the reference count for the passed `code`. /// Unconditionally increases the reference count for the passed `code`.
fn kick_off_pvf_check( fn kick_off_pvf_check(
cause: PvfCheckCause<T::BlockNumber>, cause: PvfCheckCause<BlockNumberFor<T>>,
code_hash: ValidationCodeHash, code_hash: ValidationCodeHash,
code: ValidationCode, code: ValidationCode,
cfg: &configuration::HostConfiguration<T::BlockNumber>, cfg: &configuration::HostConfiguration<BlockNumberFor<T>>,
) -> Weight { ) -> Weight {
let mut weight = Weight::zero(); let mut weight = Weight::zero();
@@ -1912,7 +1914,7 @@ impl<T: Config> Pallet<T> {
pub(crate) fn note_new_head( pub(crate) fn note_new_head(
id: ParaId, id: ParaId,
new_head: HeadData, new_head: HeadData,
execution_context: T::BlockNumber, execution_context: BlockNumberFor<T>,
) -> Weight { ) -> Weight {
Heads::<T>::insert(&id, new_head); Heads::<T>::insert(&id, new_head);
@@ -191,11 +191,11 @@ pub mod pallet {
#[pallet::hooks] #[pallet::hooks]
impl<T: Config> Hooks<BlockNumberFor<T>> for Pallet<T> { impl<T: Config> Hooks<BlockNumberFor<T>> for Pallet<T> {
fn on_initialize(_: T::BlockNumber) -> Weight { fn on_initialize(_: BlockNumberFor<T>) -> Weight {
T::DbWeight::get().reads_writes(1, 1) // in `on_finalize`. T::DbWeight::get().reads_writes(1, 1) // in `on_finalize`.
} }
fn on_finalize(_: T::BlockNumber) { fn on_finalize(_: BlockNumberFor<T>) {
if Included::<T>::take().is_none() { if Included::<T>::take().is_none() {
panic!("Bitfields and heads must be included every block"); panic!("Bitfields and heads must be included every block");
} }
@@ -262,7 +262,7 @@ pub mod pallet {
))] ))]
pub fn enter( pub fn enter(
origin: OriginFor<T>, origin: OriginFor<T>,
data: ParachainsInherentData<T::Header>, data: ParachainsInherentData<HeaderFor<T>>,
) -> DispatchResultWithPostInfo { ) -> DispatchResultWithPostInfo {
ensure_none(origin)?; ensure_none(origin)?;
@@ -277,7 +277,7 @@ pub mod pallet {
impl<T: Config> Pallet<T> { impl<T: Config> Pallet<T> {
/// Create the `ParachainsInherentData` that gets passed to [`Self::enter`] in [`Self::create_inherent`]. /// Create the `ParachainsInherentData` that gets passed to [`Self::enter`] in [`Self::create_inherent`].
/// This code is pulled out of [`Self::create_inherent`] so it can be unit tested. /// This code is pulled out of [`Self::create_inherent`] so it can be unit tested.
fn create_inherent_inner(data: &InherentData) -> Option<ParachainsInherentData<T::Header>> { fn create_inherent_inner(data: &InherentData) -> Option<ParachainsInherentData<HeaderFor<T>>> {
let parachains_inherent_data = match data.get_data(&Self::INHERENT_IDENTIFIER) { let parachains_inherent_data = match data.get_data(&Self::INHERENT_IDENTIFIER) {
Ok(Some(d)) => d, Ok(Some(d)) => d,
Ok(None) => return None, Ok(None) => return None,
@@ -307,9 +307,9 @@ impl<T: Config> Pallet<T> {
/// Returns: Result containing processed inherent data and weight, the processed inherent would /// Returns: Result containing processed inherent data and weight, the processed inherent would
/// consume. /// consume.
fn process_inherent_data( fn process_inherent_data(
data: ParachainsInherentData<T::Header>, data: ParachainsInherentData<HeaderFor<T>>,
) -> sp_std::result::Result< ) -> sp_std::result::Result<
(ParachainsInherentData<T::Header>, PostDispatchInfo), (ParachainsInherentData<HeaderFor<T>>, PostDispatchInfo),
DispatchErrorWithPostInfo, DispatchErrorWithPostInfo,
> { > {
#[cfg(feature = "runtime-metrics")] #[cfg(feature = "runtime-metrics")]
@@ -530,7 +530,7 @@ impl<T: Config> Pallet<T> {
// Process backed candidates according to scheduled cores. // Process backed candidates according to scheduled cores.
let parent_storage_root = *parent_header.state_root(); let parent_storage_root = *parent_header.state_root();
let inclusion::ProcessedCandidates::<<T::Header as HeaderT>::Hash> { let inclusion::ProcessedCandidates::<<HeaderFor<T> as HeaderT>::Hash> {
core_indices: occupied, core_indices: occupied,
candidate_receipt_with_backing_validator_indices, candidate_receipt_with_backing_validator_indices,
} = <inclusion::Pallet<T>>::process_candidates( } = <inclusion::Pallet<T>>::process_candidates(
@@ -21,6 +21,7 @@ use crate::{
configuration, disputes, dmp, hrmp, inclusion, initializer, paras, paras_inherent, scheduler, configuration, disputes, dmp, hrmp, inclusion, initializer, paras, paras_inherent, scheduler,
session_info, shared, session_info, shared,
}; };
use frame_system::pallet_prelude::*;
use primitives::{ use primitives::{
slashing, AuthorityDiscoveryId, CandidateEvent, CandidateHash, CommittedCandidateReceipt, slashing, AuthorityDiscoveryId, CandidateEvent, CandidateHash, CommittedCandidateReceipt,
CoreIndex, CoreOccupied, CoreState, DisputeState, ExecutorParams, GroupIndex, CoreIndex, CoreOccupied, CoreState, DisputeState, ExecutorParams, GroupIndex,
@@ -39,7 +40,7 @@ pub fn validators<T: initializer::Config>() -> Vec<ValidatorId> {
/// Implementation for the `validator_groups` function of the runtime API. /// Implementation for the `validator_groups` function of the runtime API.
pub fn validator_groups<T: initializer::Config>( pub fn validator_groups<T: initializer::Config>(
) -> (Vec<Vec<ValidatorIndex>>, GroupRotationInfo<T::BlockNumber>) { ) -> (Vec<Vec<ValidatorIndex>>, GroupRotationInfo<BlockNumberFor<T>>) {
let now = <frame_system::Pallet<T>>::block_number() + One::one(); let now = <frame_system::Pallet<T>>::block_number() + One::one();
let groups = <scheduler::Pallet<T>>::validator_groups(); let groups = <scheduler::Pallet<T>>::validator_groups();
@@ -49,7 +50,7 @@ pub fn validator_groups<T: initializer::Config>(
} }
/// Implementation for the `availability_cores` function of the runtime API. /// Implementation for the `availability_cores` function of the runtime API.
pub fn availability_cores<T: initializer::Config>() -> Vec<CoreState<T::Hash, T::BlockNumber>> { pub fn availability_cores<T: initializer::Config>() -> Vec<CoreState<T::Hash, BlockNumberFor<T>>> {
let cores = <scheduler::Pallet<T>>::availability_cores(); let cores = <scheduler::Pallet<T>>::availability_cores();
let parachains = <paras::Pallet<T>>::parachains(); let parachains = <paras::Pallet<T>>::parachains();
let config = <configuration::Pallet<T>>::config(); let config = <configuration::Pallet<T>>::config();
@@ -176,7 +177,7 @@ pub fn availability_cores<T: initializer::Config>() -> Vec<CoreState<T::Hash, T:
/// Returns current block number being processed and the corresponding root hash. /// Returns current block number being processed and the corresponding root hash.
fn current_relay_parent<T: frame_system::Config>( fn current_relay_parent<T: frame_system::Config>(
) -> (<T as frame_system::Config>::BlockNumber, <T as frame_system::Config>::Hash) { ) -> (BlockNumberFor<T>, <T as frame_system::Config>::Hash) {
use parity_scale_codec::Decode as _; use parity_scale_codec::Decode as _;
let state_version = <frame_system::Pallet<T>>::runtime_version().state_version(); let state_version = <frame_system::Pallet<T>>::runtime_version().state_version();
let relay_parent_number = <frame_system::Pallet<T>>::block_number(); let relay_parent_number = <frame_system::Pallet<T>>::block_number();
@@ -214,7 +215,7 @@ where
pub fn persisted_validation_data<T: initializer::Config>( pub fn persisted_validation_data<T: initializer::Config>(
para_id: ParaId, para_id: ParaId,
assumption: OccupiedCoreAssumption, assumption: OccupiedCoreAssumption,
) -> Option<PersistedValidationData<T::Hash, T::BlockNumber>> { ) -> Option<PersistedValidationData<T::Hash, BlockNumberFor<T>>> {
let (relay_parent_number, relay_parent_storage_root) = current_relay_parent::<T>(); let (relay_parent_number, relay_parent_storage_root) = current_relay_parent::<T>();
with_assumption::<T, _, _>(para_id, assumption, || { with_assumption::<T, _, _>(para_id, assumption, || {
crate::util::make_persisted_validation_data::<T>( crate::util::make_persisted_validation_data::<T>(
@@ -229,7 +230,7 @@ pub fn persisted_validation_data<T: initializer::Config>(
pub fn assumed_validation_data<T: initializer::Config>( pub fn assumed_validation_data<T: initializer::Config>(
para_id: ParaId, para_id: ParaId,
expected_persisted_validation_data_hash: Hash, expected_persisted_validation_data_hash: Hash,
) -> Option<(PersistedValidationData<T::Hash, T::BlockNumber>, ValidationCodeHash)> { ) -> Option<(PersistedValidationData<T::Hash, BlockNumberFor<T>>, ValidationCodeHash)> {
let (relay_parent_number, relay_parent_storage_root) = current_relay_parent::<T>(); let (relay_parent_number, relay_parent_storage_root) = current_relay_parent::<T>();
// This closure obtains the `persisted_validation_data` for the given `para_id` and matches // This closure obtains the `persisted_validation_data` for the given `para_id` and matches
// its hash against an expected one. // its hash against an expected one.
@@ -355,14 +356,14 @@ pub fn session_info<T: session_info::Config>(index: SessionIndex) -> Option<Sess
/// Implementation for the `dmq_contents` function of the runtime API. /// Implementation for the `dmq_contents` function of the runtime API.
pub fn dmq_contents<T: dmp::Config>( pub fn dmq_contents<T: dmp::Config>(
recipient: ParaId, recipient: ParaId,
) -> Vec<InboundDownwardMessage<T::BlockNumber>> { ) -> Vec<InboundDownwardMessage<BlockNumberFor<T>>> {
<dmp::Pallet<T>>::dmq_contents(recipient) <dmp::Pallet<T>>::dmq_contents(recipient)
} }
/// Implementation for the `inbound_hrmp_channels_contents` function of the runtime API. /// Implementation for the `inbound_hrmp_channels_contents` function of the runtime API.
pub fn inbound_hrmp_channels_contents<T: hrmp::Config>( pub fn inbound_hrmp_channels_contents<T: hrmp::Config>(
recipient: ParaId, recipient: ParaId,
) -> BTreeMap<ParaId, Vec<InboundHrmpMessage<T::BlockNumber>>> { ) -> BTreeMap<ParaId, Vec<InboundHrmpMessage<BlockNumberFor<T>>>> {
<hrmp::Pallet<T>>::inbound_hrmp_channels_contents(recipient) <hrmp::Pallet<T>>::inbound_hrmp_channels_contents(recipient)
} }
@@ -407,7 +408,7 @@ where
/// Implementation for `get_session_disputes` function from the runtime API /// Implementation for `get_session_disputes` function from the runtime API
pub fn get_session_disputes<T: disputes::Config>( pub fn get_session_disputes<T: disputes::Config>(
) -> Vec<(SessionIndex, CandidateHash, DisputeState<T::BlockNumber>)> { ) -> Vec<(SessionIndex, CandidateHash, DisputeState<BlockNumberFor<T>>)> {
<disputes::Pallet<T>>::disputes() <disputes::Pallet<T>>::disputes()
} }
+13 -9
View File
@@ -36,6 +36,7 @@
//! over time. //! over time.
use frame_support::pallet_prelude::*; use frame_support::pallet_prelude::*;
use frame_system::pallet_prelude::BlockNumberFor;
use primitives::{ use primitives::{
CollatorId, CoreIndex, CoreOccupied, GroupIndex, GroupRotationInfo, Id as ParaId, CollatorId, CoreIndex, CoreOccupied, GroupIndex, GroupRotationInfo, Id as ParaId,
ParathreadClaim, ParathreadEntry, ScheduledCore, ValidatorIndex, 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. /// block following the session change, block number of which we save in this storage value.
#[pallet::storage] #[pallet::storage]
#[pallet::getter(fn session_start_block)] #[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. /// Currently scheduled cores - free but up to be occupied.
/// ///
@@ -224,7 +225,7 @@ pub mod pallet {
impl<T: Config> Pallet<T> { impl<T: Config> Pallet<T> {
/// Called by the initializer to initialize the scheduler pallet. /// 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() Weight::zero()
} }
@@ -233,7 +234,7 @@ impl<T: Config> Pallet<T> {
/// Called by the initializer to note that a new session has started. /// Called by the initializer to note that a new session has started.
pub(crate) fn initializer_on_new_session( pub(crate) fn initializer_on_new_session(
notification: &SessionChangeNotification<T::BlockNumber>, notification: &SessionChangeNotification<BlockNumberFor<T>>,
) { ) {
let SessionChangeNotification { validators, new_config, .. } = notification; let SessionChangeNotification { validators, new_config, .. } = notification;
let config = new_config; let config = new_config;
@@ -421,7 +422,7 @@ impl<T: Config> Pallet<T> {
/// ascending order by core index. /// ascending order by core index.
pub(crate) fn schedule( pub(crate) fn schedule(
just_freed_cores: impl IntoIterator<Item = (CoreIndex, FreedReason)>, just_freed_cores: impl IntoIterator<Item = (CoreIndex, FreedReason)>,
now: T::BlockNumber, now: BlockNumberFor<T>,
) { ) {
Self::free_cores(just_freed_cores); 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. /// or the block number is less than the session start index.
pub(crate) fn group_assigned_to_core( pub(crate) fn group_assigned_to_core(
core: CoreIndex, core: CoreIndex,
at: T::BlockNumber, at: BlockNumberFor<T>,
) -> Option<GroupIndex> { ) -> Option<GroupIndex> {
let config = <configuration::Pallet<T>>::config(); let config = <configuration::Pallet<T>>::config();
let session_start_block = <SessionStartBlock<T>>::get(); let session_start_block = <SessionStartBlock<T>>::get();
@@ -605,11 +606,12 @@ impl<T: Config> Pallet<T> {
return None 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(); (at - session_start_block) / config.group_rotation_frequency.into();
let rotations_since_session_start = 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(), // Error case can only happen if rotations occur only once every u32::max(),
// so functionally no difference in behavior. // so functionally no difference in behavior.
@@ -629,7 +631,7 @@ impl<T: Config> Pallet<T> {
/// https://github.com/rust-lang/rust/issues/73226 /// https://github.com/rust-lang/rust/issues/73226
/// which prevents us from testing the code if using `impl Trait`. /// which prevents us from testing the code if using `impl Trait`.
pub(crate) fn availability_timeout_predicate( 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 now = <frame_system::Pallet<T>>::block_number();
let config = <configuration::Pallet<T>>::config(); let config = <configuration::Pallet<T>>::config();
@@ -670,7 +672,9 @@ impl<T: Config> Pallet<T> {
} }
/// Returns a helper for determining group rotation. /// 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 session_start_block = Self::session_start_block();
let group_rotation_frequency = let group_rotation_frequency =
<configuration::Pallet<T>>::config().group_rotation_frequency; <configuration::Pallet<T>>::config().group_rotation_frequency;
@@ -27,6 +27,7 @@ use frame_support::{
pallet_prelude::*, pallet_prelude::*,
traits::{OneSessionHandler, ValidatorSet, ValidatorSetWithIdentification}, traits::{OneSessionHandler, ValidatorSet, ValidatorSetWithIdentification},
}; };
use frame_system::pallet_prelude::BlockNumberFor;
use primitives::{AssignmentId, AuthorityDiscoveryId, ExecutorParams, SessionIndex, SessionInfo}; use primitives::{AssignmentId, AuthorityDiscoveryId, ExecutorParams, SessionIndex, SessionInfo};
use sp_std::vec::Vec; use sp_std::vec::Vec;
@@ -125,7 +126,7 @@ impl<T: pallet_authority_discovery::Config> AuthorityDiscoveryConfig for T {
impl<T: Config> Pallet<T> { impl<T: Config> Pallet<T> {
/// Handle an incoming session change. /// Handle an incoming session change.
pub(crate) fn initializer_on_new_session( pub(crate) fn initializer_on_new_session(
notification: &crate::initializer::SessionChangeNotification<T::BlockNumber>, notification: &crate::initializer::SessionChangeNotification<BlockNumberFor<T>>,
) { ) {
let config = <configuration::Pallet<T>>::config(); let config = <configuration::Pallet<T>>::config();
@@ -195,7 +196,7 @@ impl<T: Config> Pallet<T> {
} }
/// Called by the initializer to initialize the session info pallet. /// Called by the initializer to initialize the session info pallet.
pub(crate) fn initializer_initialize(_now: T::BlockNumber) -> Weight { pub(crate) fn initializer_initialize(_now: BlockNumberFor<T>) -> Weight {
Weight::zero() Weight::zero()
} }
+3 -2
View File
@@ -20,6 +20,7 @@
//! dependent on any of the other pallets. //! dependent on any of the other pallets.
use frame_support::pallet_prelude::*; use frame_support::pallet_prelude::*;
use frame_system::pallet_prelude::BlockNumberFor;
use primitives::{SessionIndex, ValidatorId, ValidatorIndex}; use primitives::{SessionIndex, ValidatorId, ValidatorIndex};
use sp_std::vec::Vec; use sp_std::vec::Vec;
@@ -73,7 +74,7 @@ pub mod pallet {
impl<T: Config> Pallet<T> { impl<T: Config> Pallet<T> {
/// Called by the initializer to initialize the configuration pallet. /// 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() Weight::zero()
} }
@@ -86,7 +87,7 @@ impl<T: Config> Pallet<T> {
pub(crate) fn initializer_on_new_session( pub(crate) fn initializer_on_new_session(
session_index: SessionIndex, session_index: SessionIndex,
random_seed: [u8; 32], random_seed: [u8; 32],
new_config: &HostConfiguration<T::BlockNumber>, new_config: &HostConfiguration<BlockNumberFor<T>>,
all_validators: Vec<ValidatorId>, all_validators: Vec<ValidatorId>,
) -> Vec<ValidatorId> { ) -> Vec<ValidatorId> {
CurrentSessionIndex::<T>::set(session_index); CurrentSessionIndex::<T>::set(session_index);
+3 -2
View File
@@ -17,6 +17,7 @@
//! Utilities that don't belong to any particular module but may draw //! Utilities that don't belong to any particular module but may draw
//! on all modules. //! on all modules.
use frame_system::pallet_prelude::BlockNumberFor;
use primitives::{Id as ParaId, PersistedValidationData, ValidatorIndex}; use primitives::{Id as ParaId, PersistedValidationData, ValidatorIndex};
use sp_std::{collections::btree_set::BTreeSet, vec::Vec}; use sp_std::{collections::btree_set::BTreeSet, vec::Vec};
@@ -28,9 +29,9 @@ use crate::{configuration, hrmp, paras};
/// This ties together the storage of several modules. /// This ties together the storage of several modules.
pub fn make_persisted_validation_data<T: paras::Config + hrmp::Config>( pub fn make_persisted_validation_data<T: paras::Config + hrmp::Config>(
para_id: ParaId, para_id: ParaId,
relay_parent_number: T::BlockNumber, relay_parent_number: BlockNumberFor<T>,
relay_parent_storage_root: T::Hash, relay_parent_storage_root: T::Hash,
) -> Option<PersistedValidationData<T::Hash, T::BlockNumber>> { ) -> Option<PersistedValidationData<T::Hash, BlockNumberFor<T>>> {
let config = <configuration::Pallet<T>>::config(); let config = <configuration::Pallet<T>>::config();
Some(PersistedValidationData { Some(PersistedValidationData {
+3 -6
View File
@@ -161,12 +161,12 @@ impl frame_system::Config for Runtime {
type RuntimeOrigin = RuntimeOrigin; type RuntimeOrigin = RuntimeOrigin;
type RuntimeCall = RuntimeCall; type RuntimeCall = RuntimeCall;
type Index = Nonce; type Index = Nonce;
type BlockNumber = BlockNumber;
type Hash = Hash; type Hash = Hash;
type Hashing = BlakeTwo256; type Hashing = BlakeTwo256;
type AccountId = AccountId; type AccountId = AccountId;
type Lookup = AccountIdLookup<AccountId, ()>; type Lookup = AccountIdLookup<AccountId, ()>;
type Header = generic::Header<BlockNumber, BlakeTwo256>; type Block = Block;
type RuntimeEvent = RuntimeEvent; type RuntimeEvent = RuntimeEvent;
type BlockHashCount = BlockHashCount; type BlockHashCount = BlockHashCount;
type DbWeight = RocksDbWeight; type DbWeight = RocksDbWeight;
@@ -1340,10 +1340,7 @@ impl frame_support::traits::OnRuntimeUpgrade for InitiateNominationPools {
} }
construct_runtime! { construct_runtime! {
pub enum Runtime where pub enum Runtime
Block = Block,
NodeBlock = primitives::Block,
UncheckedExtrinsic = UncheckedExtrinsic
{ {
// Basic stuff; balances is uncallable initially. // Basic stuff; balances is uncallable initially.
System: frame_system::{Pallet, Call, Storage, Config<T>, Event<T>} = 0, System: frame_system::{Pallet, Call, Storage, Config<T>, Event<T>} = 0,
+3 -6
View File
@@ -156,12 +156,12 @@ impl frame_system::Config for Runtime {
type RuntimeOrigin = RuntimeOrigin; type RuntimeOrigin = RuntimeOrigin;
type RuntimeCall = RuntimeCall; type RuntimeCall = RuntimeCall;
type Index = Nonce; type Index = Nonce;
type BlockNumber = BlockNumber;
type Hash = Hash; type Hash = Hash;
type Hashing = BlakeTwo256; type Hashing = BlakeTwo256;
type AccountId = AccountId; type AccountId = AccountId;
type Lookup = AccountIdLookup<AccountId, ()>; type Lookup = AccountIdLookup<AccountId, ()>;
type Header = generic::Header<BlockNumber, BlakeTwo256>; type Block = Block;
type RuntimeEvent = RuntimeEvent; type RuntimeEvent = RuntimeEvent;
type BlockHashCount = BlockHashCount; type BlockHashCount = BlockHashCount;
type Version = Version; type Version = Version;
@@ -1359,10 +1359,7 @@ impl pallet_sudo::Config for Runtime {
} }
construct_runtime! { construct_runtime! {
pub enum Runtime where pub enum Runtime
Block = Block,
NodeBlock = primitives::Block,
UncheckedExtrinsic = UncheckedExtrinsic
{ {
// Basic stuff; balances is uncallable initially. // Basic stuff; balances is uncallable initially.
System: frame_system::{Pallet, Call, Storage, Config<T>, Event<T>} = 0, System: frame_system::{Pallet, Call, Storage, Config<T>, Event<T>} = 0,
+3 -6
View File
@@ -141,12 +141,12 @@ impl frame_system::Config for Runtime {
type RuntimeOrigin = RuntimeOrigin; type RuntimeOrigin = RuntimeOrigin;
type RuntimeCall = RuntimeCall; type RuntimeCall = RuntimeCall;
type Index = Nonce; type Index = Nonce;
type BlockNumber = BlockNumber;
type Hash = HashT; type Hash = HashT;
type Hashing = BlakeTwo256; type Hashing = BlakeTwo256;
type AccountId = AccountId; type AccountId = AccountId;
type Lookup = Indices; type Lookup = Indices;
type Header = generic::Header<BlockNumber, BlakeTwo256>; type Block = Block;
type RuntimeEvent = RuntimeEvent; type RuntimeEvent = RuntimeEvent;
type BlockHashCount = BlockHashCount; type BlockHashCount = BlockHashCount;
type Version = Version; type Version = Version;
@@ -646,10 +646,7 @@ pub mod pallet_test_notifier {
} }
construct_runtime! { construct_runtime! {
pub enum Runtime where pub enum Runtime
Block = Block,
NodeBlock = primitives::Block,
UncheckedExtrinsic = UncheckedExtrinsic
{ {
// Basic stuff; balances is uncallable initially. // Basic stuff; balances is uncallable initially.
System: frame_system::{Pallet, Call, Storage, Config<T>, Event<T>}, System: frame_system::{Pallet, Call, Storage, Config<T>, Event<T>},
+3 -6
View File
@@ -151,12 +151,12 @@ impl frame_system::Config for Runtime {
type RuntimeOrigin = RuntimeOrigin; type RuntimeOrigin = RuntimeOrigin;
type RuntimeCall = RuntimeCall; type RuntimeCall = RuntimeCall;
type Index = Nonce; type Index = Nonce;
type BlockNumber = BlockNumber;
type Hash = Hash; type Hash = Hash;
type Hashing = BlakeTwo256; type Hashing = BlakeTwo256;
type AccountId = AccountId; type AccountId = AccountId;
type Lookup = AccountIdLookup<AccountId, ()>; type Lookup = AccountIdLookup<AccountId, ()>;
type Header = generic::Header<BlockNumber, BlakeTwo256>; type Block = Block;
type RuntimeEvent = RuntimeEvent; type RuntimeEvent = RuntimeEvent;
type BlockHashCount = BlockHashCount; type BlockHashCount = BlockHashCount;
type DbWeight = RocksDbWeight; type DbWeight = RocksDbWeight;
@@ -1144,10 +1144,7 @@ parameter_types! {
} }
construct_runtime! { construct_runtime! {
pub enum Runtime where pub enum Runtime
Block = Block,
NodeBlock = primitives::Block,
UncheckedExtrinsic = UncheckedExtrinsic
{ {
// Basic stuff; balances is uncallable initially. // Basic stuff; balances is uncallable initially.
System: frame_system::{Pallet, Call, Storage, Config<T>, Event<T>} = 0, System: frame_system::{Pallet, Call, Storage, Config<T>, Event<T>} = 0,
@@ -24,22 +24,15 @@ use frame_support::{
weights::Weight, weights::Weight,
}; };
use sp_core::H256; use sp_core::H256;
use sp_runtime::{ use sp_runtime::traits::{BlakeTwo256, IdentityLookup};
testing::Header,
traits::{BlakeTwo256, IdentityLookup},
};
use xcm::latest::prelude::*; use xcm::latest::prelude::*;
use xcm_builder::{AllowUnpaidExecutionFrom, MintLocation}; use xcm_builder::{AllowUnpaidExecutionFrom, MintLocation};
type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic<Test>;
type Block = frame_system::mocking::MockBlock<Test>; type Block = frame_system::mocking::MockBlock<Test>;
// For testing the pallet, we construct a mock runtime. // For testing the pallet, we construct a mock runtime.
frame_support::construct_runtime!( frame_support::construct_runtime!(
pub enum Test where pub enum Test
Block = Block,
NodeBlock = Block,
UncheckedExtrinsic = UncheckedExtrinsic,
{ {
System: frame_system::{Pallet, Call, Config<T>, Storage, Event<T>}, System: frame_system::{Pallet, Call, Config<T>, Storage, Event<T>},
Balances: pallet_balances::{Pallet, Call, Storage, Config<T>, Event<T>}, Balances: pallet_balances::{Pallet, Call, Storage, Config<T>, Event<T>},
@@ -59,13 +52,12 @@ impl frame_system::Config for Test {
type DbWeight = (); type DbWeight = ();
type RuntimeOrigin = RuntimeOrigin; type RuntimeOrigin = RuntimeOrigin;
type Index = u64; type Index = u64;
type BlockNumber = u64;
type Hash = H256; type Hash = H256;
type RuntimeCall = RuntimeCall; type RuntimeCall = RuntimeCall;
type Hashing = BlakeTwo256; type Hashing = BlakeTwo256;
type AccountId = u64; type AccountId = u64;
type Lookup = IdentityLookup<Self::AccountId>; type Lookup = IdentityLookup<Self::AccountId>;
type Header = Header; type Block = Block;
type RuntimeEvent = RuntimeEvent; type RuntimeEvent = RuntimeEvent;
type BlockHashCount = BlockHashCount; type BlockHashCount = BlockHashCount;
type Version = (); type Version = ();
@@ -24,10 +24,7 @@ use frame_support::{
weights::Weight, weights::Weight,
}; };
use sp_core::H256; use sp_core::H256;
use sp_runtime::{ use sp_runtime::traits::{BlakeTwo256, IdentityLookup, TrailingZeroInput};
testing::Header,
traits::{BlakeTwo256, IdentityLookup, TrailingZeroInput},
};
use xcm_builder::{ use xcm_builder::{
test_utils::{ test_utils::{
Assets, TestAssetExchanger, TestAssetLocker, TestAssetTrap, TestSubscriptionService, Assets, TestAssetExchanger, TestAssetLocker, TestAssetTrap, TestSubscriptionService,
@@ -37,14 +34,10 @@ use xcm_builder::{
}; };
use xcm_executor::traits::ConvertOrigin; use xcm_executor::traits::ConvertOrigin;
type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic<Test>;
type Block = frame_system::mocking::MockBlock<Test>; type Block = frame_system::mocking::MockBlock<Test>;
frame_support::construct_runtime!( frame_support::construct_runtime!(
pub enum Test where pub enum Test
Block = Block,
NodeBlock = Block,
UncheckedExtrinsic = UncheckedExtrinsic,
{ {
System: frame_system::{Pallet, Call, Config<T>, Storage, Event<T>}, System: frame_system::{Pallet, Call, Config<T>, Storage, Event<T>},
XcmGenericBenchmarks: generic::{Pallet}, XcmGenericBenchmarks: generic::{Pallet},
@@ -64,13 +57,12 @@ impl frame_system::Config for Test {
type DbWeight = (); type DbWeight = ();
type RuntimeOrigin = RuntimeOrigin; type RuntimeOrigin = RuntimeOrigin;
type Index = u64; type Index = u64;
type BlockNumber = u64;
type Hash = H256; type Hash = H256;
type RuntimeCall = RuntimeCall; type RuntimeCall = RuntimeCall;
type Hashing = BlakeTwo256; type Hashing = BlakeTwo256;
type AccountId = u64; type AccountId = u64;
type Lookup = IdentityLookup<Self::AccountId>; type Lookup = IdentityLookup<Self::AccountId>;
type Header = Header; type Block = Block;
type RuntimeEvent = RuntimeEvent; type RuntimeEvent = RuntimeEvent;
type BlockHashCount = BlockHashCount; type BlockHashCount = BlockHashCount;
type Version = (); type Version = ();
+8 -8
View File
@@ -180,7 +180,7 @@ pub mod pallet {
/// A lockable currency. /// A lockable currency.
// TODO: We should really use a trait which can handle multiple currencies. // TODO: We should really use a trait which can handle multiple currencies.
type Currency: LockableCurrency<Self::AccountId, Moment = Self::BlockNumber>; type Currency: LockableCurrency<Self::AccountId, Moment = BlockNumberFor<Self>>;
/// The `MultiAsset` matcher for `Currency`. /// The `MultiAsset` matcher for `Currency`.
type CurrencyMatcher: MatchesFungible<BalanceOf<Self>>; type CurrencyMatcher: MatchesFungible<BalanceOf<Self>>;
@@ -508,7 +508,7 @@ pub mod pallet {
#[pallet::storage] #[pallet::storage]
#[pallet::getter(fn query)] #[pallet::getter(fn query)]
pub(super) type Queries<T: Config> = pub(super) type Queries<T: Config> =
StorageMap<_, Blake2_128Concat, QueryId, QueryStatus<T::BlockNumber>, OptionQuery>; StorageMap<_, Blake2_128Concat, QueryId, QueryStatus<BlockNumberFor<T>>, OptionQuery>;
/// The existing asset traps. /// The existing asset traps.
/// ///
@@ -743,7 +743,7 @@ pub mod pallet {
if on_chain_storage_version < 1 { if on_chain_storage_version < 1 {
let mut count = 0; let mut count = 0;
Queries::<T>::translate::<QueryStatusV0<T::BlockNumber>, _>(|_key, value| { Queries::<T>::translate::<QueryStatusV0<BlockNumberFor<T>>, _>(|_key, value| {
count += 1; count += 1;
Some(value.into()) Some(value.into())
}); });
@@ -1130,14 +1130,14 @@ const MAX_ASSETS_FOR_TRANSFER: usize = 2;
impl<T: Config> QueryHandler for Pallet<T> { impl<T: Config> QueryHandler for Pallet<T> {
type QueryId = u64; type QueryId = u64;
type BlockNumber = T::BlockNumber; type BlockNumber = BlockNumberFor<T>;
type Error = XcmError; type Error = XcmError;
type UniversalLocation = T::UniversalLocation; type UniversalLocation = T::UniversalLocation;
/// Attempt to create a new query ID and register it as a query that is yet to respond. /// Attempt to create a new query ID and register it as a query that is yet to respond.
fn new_query( fn new_query(
responder: impl Into<MultiLocation>, responder: impl Into<MultiLocation>,
timeout: T::BlockNumber, timeout: BlockNumberFor<T>,
match_querier: impl Into<MultiLocation>, match_querier: impl Into<MultiLocation>,
) -> Self::QueryId { ) -> Self::QueryId {
Self::do_new_query(responder, None, timeout, match_querier).into() Self::do_new_query(responder, None, timeout, match_querier).into()
@@ -1540,7 +1540,7 @@ impl<T: Config> Pallet<T> {
fn do_new_query( fn do_new_query(
responder: impl Into<MultiLocation>, responder: impl Into<MultiLocation>,
maybe_notify: Option<(u8, u8)>, maybe_notify: Option<(u8, u8)>,
timeout: T::BlockNumber, timeout: BlockNumberFor<T>,
match_querier: impl Into<MultiLocation>, match_querier: impl Into<MultiLocation>,
) -> u64 { ) -> u64 {
QueryCounter::<T>::mutate(|q| { QueryCounter::<T>::mutate(|q| {
@@ -1585,7 +1585,7 @@ impl<T: Config> Pallet<T> {
message: &mut Xcm<()>, message: &mut Xcm<()>,
responder: impl Into<MultiLocation>, responder: impl Into<MultiLocation>,
notify: impl Into<<T as Config>::RuntimeCall>, notify: impl Into<<T as Config>::RuntimeCall>,
timeout: T::BlockNumber, timeout: BlockNumberFor<T>,
) -> Result<(), XcmError> { ) -> Result<(), XcmError> {
let responder = responder.into(); let responder = responder.into();
let destination = T::UniversalLocation::get() let destination = T::UniversalLocation::get()
@@ -1605,7 +1605,7 @@ impl<T: Config> Pallet<T> {
pub fn new_notify_query( pub fn new_notify_query(
responder: impl Into<MultiLocation>, responder: impl Into<MultiLocation>,
notify: impl Into<<T as Config>::RuntimeCall>, notify: impl Into<<T as Config>::RuntimeCall>,
timeout: T::BlockNumber, timeout: BlockNumberFor<T>,
match_querier: impl Into<MultiLocation>, match_querier: impl Into<MultiLocation>,
) -> u64 { ) -> u64 {
let notify = notify.into().using_encoded(|mut bytes| Decode::decode(&mut bytes)).expect( let notify = notify.into().using_encoded(|mut bytes| Decode::decode(&mut bytes)).expect(
+3 -8
View File
@@ -24,7 +24,7 @@ use frame_system::EnsureRoot;
use polkadot_parachain::primitives::Id as ParaId; use polkadot_parachain::primitives::Id as ParaId;
use polkadot_runtime_parachains::origin; use polkadot_runtime_parachains::origin;
use sp_core::H256; use sp_core::H256;
use sp_runtime::{testing::Header, traits::IdentityLookup, AccountId32, BuildStorage}; use sp_runtime::{traits::IdentityLookup, AccountId32, BuildStorage};
pub use sp_std::{cell::RefCell, fmt::Debug, marker::PhantomData}; pub use sp_std::{cell::RefCell, fmt::Debug, marker::PhantomData};
use xcm::prelude::*; use xcm::prelude::*;
use xcm_builder::{ use xcm_builder::{
@@ -40,7 +40,6 @@ use crate::{self as pallet_xcm, TestWeightInfo};
pub type AccountId = AccountId32; pub type AccountId = AccountId32;
pub type Balance = u128; pub type Balance = u128;
type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic<Test>;
type Block = frame_system::mocking::MockBlock<Test>; type Block = frame_system::mocking::MockBlock<Test>;
#[frame_support::pallet] #[frame_support::pallet]
@@ -132,10 +131,7 @@ pub mod pallet_test_notifier {
} }
construct_runtime!( construct_runtime!(
pub enum Test where pub enum Test
Block = Block,
NodeBlock = Block,
UncheckedExtrinsic = UncheckedExtrinsic,
{ {
System: frame_system::{Pallet, Call, Storage, Config<T>, Event<T>}, System: frame_system::{Pallet, Call, Storage, Config<T>, Event<T>},
Balances: pallet_balances::{Pallet, Call, Storage, Config<T>, Event<T>}, Balances: pallet_balances::{Pallet, Call, Storage, Config<T>, Event<T>},
@@ -205,12 +201,11 @@ impl frame_system::Config for Test {
type RuntimeOrigin = RuntimeOrigin; type RuntimeOrigin = RuntimeOrigin;
type RuntimeCall = RuntimeCall; type RuntimeCall = RuntimeCall;
type Index = u64; type Index = u64;
type BlockNumber = u64;
type Hash = H256; type Hash = H256;
type Hashing = ::sp_runtime::traits::BlakeTwo256; type Hashing = ::sp_runtime::traits::BlakeTwo256;
type AccountId = AccountId; type AccountId = AccountId;
type Lookup = IdentityLookup<Self::AccountId>; type Lookup = IdentityLookup<Self::AccountId>;
type Header = Header; type Block = Block;
type RuntimeEvent = RuntimeEvent; type RuntimeEvent = RuntimeEvent;
type BlockHashCount = BlockHashCount; type BlockHashCount = BlockHashCount;
type BlockWeights = (); type BlockWeights = ();
+3 -8
View File
@@ -22,7 +22,7 @@ use frame_support::{
use frame_system::EnsureRoot; use frame_system::EnsureRoot;
use parity_scale_codec::Encode; use parity_scale_codec::Encode;
use primitive_types::H256; use primitive_types::H256;
use sp_runtime::{testing::Header, traits::IdentityLookup, AccountId32, BuildStorage}; use sp_runtime::{traits::IdentityLookup, AccountId32, BuildStorage};
use sp_std::cell::RefCell; use sp_std::cell::RefCell;
use polkadot_parachain::primitives::Id as ParaId; use polkadot_parachain::primitives::Id as ParaId;
@@ -78,12 +78,11 @@ impl frame_system::Config for Runtime {
type RuntimeOrigin = RuntimeOrigin; type RuntimeOrigin = RuntimeOrigin;
type RuntimeCall = RuntimeCall; type RuntimeCall = RuntimeCall;
type Index = u64; type Index = u64;
type BlockNumber = u64;
type Hash = H256; type Hash = H256;
type Hashing = ::sp_runtime::traits::BlakeTwo256; type Hashing = ::sp_runtime::traits::BlakeTwo256;
type AccountId = AccountId; type AccountId = AccountId;
type Lookup = IdentityLookup<Self::AccountId>; type Lookup = IdentityLookup<Self::AccountId>;
type Header = Header; type Block = Block;
type RuntimeEvent = RuntimeEvent; type RuntimeEvent = RuntimeEvent;
type BlockHashCount = BlockHashCount; type BlockHashCount = BlockHashCount;
type BlockWeights = (); type BlockWeights = ();
@@ -244,14 +243,10 @@ impl pallet_xcm::Config for Runtime {
impl origin::Config for Runtime {} impl origin::Config for Runtime {}
type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic<Runtime>;
type Block = frame_system::mocking::MockBlock<Runtime>; type Block = frame_system::mocking::MockBlock<Runtime>;
construct_runtime!( construct_runtime!(
pub enum Runtime where pub enum Runtime
Block = Block,
NodeBlock = Block,
UncheckedExtrinsic = UncheckedExtrinsic,
{ {
System: frame_system::{Pallet, Call, Storage, Config<T>, Event<T>}, System: frame_system::{Pallet, Call, Storage, Config<T>, Event<T>},
Balances: pallet_balances::{Pallet, Call, Storage, Config<T>, Event<T>}, Balances: pallet_balances::{Pallet, Call, Storage, Config<T>, Event<T>},
@@ -27,7 +27,6 @@ use frame_support::{
use frame_system::EnsureRoot; use frame_system::EnsureRoot;
use sp_core::{ConstU32, H256}; use sp_core::{ConstU32, H256};
use sp_runtime::{ use sp_runtime::{
testing::Header,
traits::{Get, Hash, IdentityLookup}, traits::{Get, Hash, IdentityLookup},
AccountId32, AccountId32,
}; };
@@ -68,12 +67,11 @@ impl frame_system::Config for Runtime {
type RuntimeOrigin = RuntimeOrigin; type RuntimeOrigin = RuntimeOrigin;
type RuntimeCall = RuntimeCall; type RuntimeCall = RuntimeCall;
type Index = u64; type Index = u64;
type BlockNumber = u64;
type Hash = H256; type Hash = H256;
type Hashing = ::sp_runtime::traits::BlakeTwo256; type Hashing = ::sp_runtime::traits::BlakeTwo256;
type AccountId = AccountId; type AccountId = AccountId;
type Lookup = IdentityLookup<Self::AccountId>; type Lookup = IdentityLookup<Self::AccountId>;
type Header = Header; type Block = Block;
type RuntimeEvent = RuntimeEvent; type RuntimeEvent = RuntimeEvent;
type BlockHashCount = BlockHashCount; type BlockHashCount = BlockHashCount;
type BlockWeights = (); type BlockWeights = ();
@@ -449,14 +447,10 @@ impl pallet_xcm::Config for Runtime {
type AdminOrigin = EnsureRoot<AccountId>; type AdminOrigin = EnsureRoot<AccountId>;
} }
type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic<Runtime>;
type Block = frame_system::mocking::MockBlock<Runtime>; type Block = frame_system::mocking::MockBlock<Runtime>;
construct_runtime!( construct_runtime!(
pub enum Runtime where pub enum Runtime
Block = Block,
NodeBlock = Block,
UncheckedExtrinsic = UncheckedExtrinsic,
{ {
System: frame_system::{Pallet, Call, Storage, Config<T>, Event<T>}, System: frame_system::{Pallet, Call, Storage, Config<T>, Event<T>},
Balances: pallet_balances::{Pallet, Call, Storage, Config<T>, Event<T>}, Balances: pallet_balances::{Pallet, Call, Storage, Config<T>, Event<T>},
@@ -24,7 +24,7 @@ use frame_support::{
use frame_system::EnsureRoot; use frame_system::EnsureRoot;
use sp_core::{ConstU32, H256}; use sp_core::{ConstU32, H256};
use sp_runtime::{testing::Header, traits::IdentityLookup, AccountId32}; use sp_runtime::{traits::IdentityLookup, AccountId32};
use polkadot_parachain::primitives::Id as ParaId; use polkadot_parachain::primitives::Id as ParaId;
use polkadot_runtime_parachains::{ use polkadot_runtime_parachains::{
@@ -53,12 +53,11 @@ impl frame_system::Config for Runtime {
type RuntimeOrigin = RuntimeOrigin; type RuntimeOrigin = RuntimeOrigin;
type RuntimeCall = RuntimeCall; type RuntimeCall = RuntimeCall;
type Index = u64; type Index = u64;
type BlockNumber = u64;
type Hash = H256; type Hash = H256;
type Hashing = ::sp_runtime::traits::BlakeTwo256; type Hashing = ::sp_runtime::traits::BlakeTwo256;
type AccountId = AccountId; type AccountId = AccountId;
type Lookup = IdentityLookup<Self::AccountId>; type Lookup = IdentityLookup<Self::AccountId>;
type Header = Header; type Block = Block;
type RuntimeEvent = RuntimeEvent; type RuntimeEvent = RuntimeEvent;
type BlockHashCount = BlockHashCount; type BlockHashCount = BlockHashCount;
type BlockWeights = (); type BlockWeights = ();
@@ -239,7 +238,6 @@ parameter_types! {
impl origin::Config for Runtime {} impl origin::Config for Runtime {}
type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic<Runtime>;
type Block = frame_system::mocking::MockBlock<Runtime>; type Block = frame_system::mocking::MockBlock<Runtime>;
parameter_types! { parameter_types! {
@@ -284,10 +282,7 @@ impl pallet_message_queue::Config for Runtime {
} }
construct_runtime!( construct_runtime!(
pub enum Runtime where pub enum Runtime
Block = Block,
NodeBlock = Block,
UncheckedExtrinsic = UncheckedExtrinsic,
{ {
System: frame_system::{Pallet, Call, Storage, Config<T>, Event<T>}, System: frame_system::{Pallet, Call, Storage, Config<T>, Event<T>},
Balances: pallet_balances::{Pallet, Call, Storage, Config<T>, Event<T>}, Balances: pallet_balances::{Pallet, Call, Storage, Config<T>, Event<T>},
@@ -26,7 +26,6 @@ use frame_support::{
use frame_system::EnsureRoot; use frame_system::EnsureRoot;
use sp_core::{ConstU32, H256}; use sp_core::{ConstU32, H256};
use sp_runtime::{ use sp_runtime::{
testing::Header,
traits::{Hash, IdentityLookup}, traits::{Hash, IdentityLookup},
AccountId32, AccountId32,
}; };
@@ -57,12 +56,11 @@ impl frame_system::Config for Runtime {
type RuntimeOrigin = RuntimeOrigin; type RuntimeOrigin = RuntimeOrigin;
type RuntimeCall = RuntimeCall; type RuntimeCall = RuntimeCall;
type Index = u64; type Index = u64;
type BlockNumber = u64;
type Hash = H256; type Hash = H256;
type Hashing = ::sp_runtime::traits::BlakeTwo256; type Hashing = ::sp_runtime::traits::BlakeTwo256;
type AccountId = AccountId; type AccountId = AccountId;
type Lookup = IdentityLookup<Self::AccountId>; type Lookup = IdentityLookup<Self::AccountId>;
type Header = Header; type Block = Block;
type RuntimeEvent = RuntimeEvent; type RuntimeEvent = RuntimeEvent;
type BlockHashCount = BlockHashCount; type BlockHashCount = BlockHashCount;
type BlockWeights = (); type BlockWeights = ();
@@ -347,14 +345,10 @@ impl pallet_xcm::Config for Runtime {
type AdminOrigin = EnsureRoot<AccountId>; type AdminOrigin = EnsureRoot<AccountId>;
} }
type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic<Runtime>;
type Block = frame_system::mocking::MockBlock<Runtime>; type Block = frame_system::mocking::MockBlock<Runtime>;
construct_runtime!( construct_runtime!(
pub enum Runtime where pub enum Runtime
Block = Block,
NodeBlock = Block,
UncheckedExtrinsic = UncheckedExtrinsic,
{ {
System: frame_system::{Pallet, Call, Storage, Config<T>, Event<T>}, System: frame_system::{Pallet, Call, Storage, Config<T>, Event<T>},
Balances: pallet_balances::{Pallet, Call, Storage, Config<T>, Event<T>}, Balances: pallet_balances::{Pallet, Call, Storage, Config<T>, Event<T>},
@@ -24,7 +24,7 @@ use frame_support::{
use frame_system::EnsureRoot; use frame_system::EnsureRoot;
use sp_core::{ConstU32, H256}; use sp_core::{ConstU32, H256};
use sp_runtime::{testing::Header, traits::IdentityLookup, AccountId32}; use sp_runtime::{traits::IdentityLookup, AccountId32};
use polkadot_parachain::primitives::Id as ParaId; use polkadot_parachain::primitives::Id as ParaId;
use polkadot_runtime_parachains::{ use polkadot_runtime_parachains::{
@@ -52,12 +52,11 @@ impl frame_system::Config for Runtime {
type RuntimeOrigin = RuntimeOrigin; type RuntimeOrigin = RuntimeOrigin;
type RuntimeCall = RuntimeCall; type RuntimeCall = RuntimeCall;
type Index = u64; type Index = u64;
type BlockNumber = u64;
type Hash = H256; type Hash = H256;
type Hashing = ::sp_runtime::traits::BlakeTwo256; type Hashing = ::sp_runtime::traits::BlakeTwo256;
type AccountId = AccountId; type AccountId = AccountId;
type Lookup = IdentityLookup<Self::AccountId>; type Lookup = IdentityLookup<Self::AccountId>;
type Header = Header; type Block = Block;
type RuntimeEvent = RuntimeEvent; type RuntimeEvent = RuntimeEvent;
type BlockHashCount = BlockHashCount; type BlockHashCount = BlockHashCount;
type BlockWeights = (); type BlockWeights = ();
@@ -203,7 +202,6 @@ parameter_types! {
impl origin::Config for Runtime {} impl origin::Config for Runtime {}
type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic<Runtime>;
type Block = frame_system::mocking::MockBlock<Runtime>; type Block = frame_system::mocking::MockBlock<Runtime>;
parameter_types! { parameter_types! {
@@ -252,10 +250,7 @@ impl pallet_message_queue::Config for Runtime {
} }
construct_runtime!( construct_runtime!(
pub enum Runtime where pub enum Runtime
Block = Block,
NodeBlock = Block,
UncheckedExtrinsic = UncheckedExtrinsic,
{ {
System: frame_system::{Pallet, Call, Storage, Config<T>, Event<T>}, System: frame_system::{Pallet, Call, Storage, Config<T>, Event<T>},
Balances: pallet_balances::{Pallet, Call, Storage, Config<T>, Event<T>}, Balances: pallet_balances::{Pallet, Call, Storage, Config<T>, Event<T>},