mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-14 12:11:09 +00:00
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:
@@ -67,11 +67,10 @@ pub struct ParachainTemporarySlot<AccountId, LeasePeriod> {
|
||||
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,
|
||||
>>::Balance;
|
||||
type LeasePeriodOf<T> =
|
||||
<<T as Config>::Leaser as Leaser<<T as frame_system::Config>::BlockNumber>>::LeasePeriod;
|
||||
type LeasePeriodOf<T> = <<T as Config>::Leaser as Leaser<BlockNumberFor<T>>>::LeasePeriod;
|
||||
|
||||
#[frame_support::pallet]
|
||||
pub mod pallet {
|
||||
@@ -91,9 +90,9 @@ pub mod pallet {
|
||||
|
||||
/// The type representing the leasing system.
|
||||
type Leaser: Leaser<
|
||||
Self::BlockNumber,
|
||||
BlockNumberFor<Self>,
|
||||
AccountId = Self::AccountId,
|
||||
LeasePeriod = Self::BlockNumber,
|
||||
LeasePeriod = BlockNumberFor<Self>,
|
||||
>;
|
||||
|
||||
/// The number of lease periods a permanent parachain slot lasts.
|
||||
@@ -182,7 +181,7 @@ pub mod pallet {
|
||||
|
||||
#[pallet::hooks]
|
||||
impl<T: Config> Hooks<BlockNumberFor<T>> for Pallet<T> {
|
||||
fn on_initialize(n: T::BlockNumber) -> Weight {
|
||||
fn on_initialize(n: BlockNumberFor<T>) -> Weight {
|
||||
if let Some((lease_period, first_block)) = Self::lease_period_index(n) {
|
||||
// If we're beginning a new lease period then handle that.
|
||||
if first_block {
|
||||
@@ -213,14 +212,14 @@ pub mod pallet {
|
||||
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!(
|
||||
!T::Leaser::already_leased(
|
||||
id,
|
||||
current_lease_period,
|
||||
// Check current lease & next one
|
||||
current_lease_period.saturating_add(
|
||||
T::BlockNumber::from(2u32)
|
||||
BlockNumberFor::<T>::from(2u32)
|
||||
.saturating_mul(T::PermanentSlotLeasePeriodLength::get().into())
|
||||
)
|
||||
),
|
||||
@@ -276,14 +275,14 @@ pub mod pallet {
|
||||
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!(
|
||||
!T::Leaser::already_leased(
|
||||
id,
|
||||
current_lease_period,
|
||||
// Check current lease & next one
|
||||
current_lease_period.saturating_add(
|
||||
T::BlockNumber::from(2u32)
|
||||
BlockNumberFor::<T>::from(2u32)
|
||||
.saturating_mul(T::TemporarySlotLeasePeriodLength::get().into())
|
||||
)
|
||||
),
|
||||
@@ -548,7 +547,7 @@ mod tests {
|
||||
use frame_support::{assert_noop, assert_ok, parameter_types};
|
||||
use frame_system::EnsureRoot;
|
||||
use pallet_balances;
|
||||
use primitives::{BlockNumber, Header};
|
||||
use primitives::BlockNumber;
|
||||
use runtime_parachains::{
|
||||
configuration as parachains_configuration, paras as parachains_paras,
|
||||
shared as parachains_shared,
|
||||
@@ -562,13 +561,10 @@ mod tests {
|
||||
};
|
||||
|
||||
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!(
|
||||
pub enum Test where
|
||||
Block = Block,
|
||||
NodeBlock = Block,
|
||||
UncheckedExtrinsic = UncheckedExtrinsic,
|
||||
pub enum Test
|
||||
{
|
||||
System: frame_system::{Pallet, Call, Config<T>, Storage, Event<T>},
|
||||
Balances: pallet_balances::{Pallet, Call, Storage, Config<T>, Event<T>},
|
||||
@@ -598,12 +594,12 @@ mod tests {
|
||||
type RuntimeOrigin = RuntimeOrigin;
|
||||
type RuntimeCall = RuntimeCall;
|
||||
type Index = u64;
|
||||
type BlockNumber = BlockNumber;
|
||||
|
||||
type Hash = H256;
|
||||
type Hashing = BlakeTwo256;
|
||||
type AccountId = u64;
|
||||
type Lookup = IdentityLookup<Self::AccountId>;
|
||||
type Header = Header;
|
||||
type Block = Block;
|
||||
type RuntimeEvent = RuntimeEvent;
|
||||
type BlockHashCount = BlockHashCount;
|
||||
type DbWeight = ();
|
||||
|
||||
@@ -28,15 +28,15 @@ use frame_support::{
|
||||
traits::{Currency, Get, Randomness, ReservableCurrency},
|
||||
weights::Weight,
|
||||
};
|
||||
use frame_system::pallet_prelude::BlockNumberFor;
|
||||
pub use pallet::*;
|
||||
use parity_scale_codec::Decode;
|
||||
use primitives::Id as ParaId;
|
||||
use sp_runtime::traits::{CheckedSub, One, Saturating, Zero};
|
||||
use sp_std::{mem::swap, prelude::*};
|
||||
|
||||
type CurrencyOf<T> =
|
||||
<<T as Config>::Leaser as Leaser<<T as frame_system::Config>::BlockNumber>>::Currency;
|
||||
type BalanceOf<T> = <<<T as Config>::Leaser as Leaser<<T as frame_system::Config>::BlockNumber>>::Currency as Currency<
|
||||
type CurrencyOf<T> = <<T as Config>::Leaser as Leaser<BlockNumberFor<T>>>::Currency;
|
||||
type BalanceOf<T> = <<<T as Config>::Leaser as Leaser<BlockNumberFor<T>>>::Currency as Currency<
|
||||
<T as frame_system::Config>::AccountId,
|
||||
>>::Balance;
|
||||
|
||||
@@ -66,8 +66,7 @@ impl WeightInfo for TestWeightInfo {
|
||||
/// An auction index. We count auctions in this type.
|
||||
pub type AuctionIndex = u32;
|
||||
|
||||
type LeasePeriodOf<T> =
|
||||
<<T as Config>::Leaser as Leaser<<T as frame_system::Config>::BlockNumber>>::LeasePeriod;
|
||||
type LeasePeriodOf<T> = <<T as Config>::Leaser as Leaser<BlockNumberFor<T>>>::LeasePeriod;
|
||||
|
||||
// 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>)>;
|
||||
@@ -94,9 +93,9 @@ pub mod pallet {
|
||||
|
||||
/// The type representing the leasing system.
|
||||
type Leaser: Leaser<
|
||||
Self::BlockNumber,
|
||||
BlockNumberFor<Self>,
|
||||
AccountId = Self::AccountId,
|
||||
LeasePeriod = Self::BlockNumber,
|
||||
LeasePeriod = BlockNumberFor<Self>,
|
||||
>;
|
||||
|
||||
/// The parachain registrar type.
|
||||
@@ -104,16 +103,16 @@ pub mod pallet {
|
||||
|
||||
/// The number of blocks over which an auction may be retroactively ended.
|
||||
#[pallet::constant]
|
||||
type EndingPeriod: Get<Self::BlockNumber>;
|
||||
type EndingPeriod: Get<BlockNumberFor<Self>>;
|
||||
|
||||
/// The length of each sample to take during the ending period.
|
||||
///
|
||||
/// `EndingPeriod` / `SampleLength` = Total # of Samples
|
||||
#[pallet::constant]
|
||||
type SampleLength: Get<Self::BlockNumber>;
|
||||
type SampleLength: Get<BlockNumberFor<Self>>;
|
||||
|
||||
/// 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.
|
||||
type InitiateOrigin: EnsureOrigin<Self::RuntimeOrigin>;
|
||||
@@ -130,7 +129,7 @@ pub mod pallet {
|
||||
AuctionStarted {
|
||||
auction_index: AuctionIndex,
|
||||
lease_period: LeasePeriodOf<T>,
|
||||
ending: T::BlockNumber,
|
||||
ending: BlockNumberFor<T>,
|
||||
},
|
||||
/// An auction ended. All funds become unreserved.
|
||||
AuctionClosed { auction_index: AuctionIndex },
|
||||
@@ -151,7 +150,7 @@ pub mod pallet {
|
||||
last_slot: LeasePeriodOf<T>,
|
||||
},
|
||||
/// 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]
|
||||
@@ -184,7 +183,7 @@ pub mod pallet {
|
||||
/// auction will "begin to end", i.e. the first block of the Ending Period of the auction.
|
||||
#[pallet::storage]
|
||||
#[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
|
||||
/// (sub-)ranges.
|
||||
@@ -198,7 +197,7 @@ pub mod pallet {
|
||||
/// first sample of the ending period is 0; the last is `Sample Size - 1`.
|
||||
#[pallet::storage]
|
||||
#[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]
|
||||
impl<T: Config> Pallet<T> {
|
||||
@@ -215,7 +214,7 @@ pub mod pallet {
|
||||
|
||||
#[pallet::hooks]
|
||||
impl<T: Config> Hooks<BlockNumberFor<T>> for Pallet<T> {
|
||||
fn on_initialize(n: T::BlockNumber) -> Weight {
|
||||
fn on_initialize(n: BlockNumberFor<T>) -> Weight {
|
||||
let mut weight = T::DbWeight::get().reads(1);
|
||||
|
||||
// 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))]
|
||||
pub fn new_auction(
|
||||
origin: OriginFor<T>,
|
||||
#[pallet::compact] duration: T::BlockNumber,
|
||||
#[pallet::compact] duration: BlockNumberFor<T>,
|
||||
#[pallet::compact] lease_period_index: LeasePeriodOf<T>,
|
||||
) -> DispatchResult {
|
||||
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 LeasePeriod = T::BlockNumber;
|
||||
type LeasePeriod = BlockNumberFor<T>;
|
||||
type Currency = CurrencyOf<T>;
|
||||
|
||||
fn new_auction(
|
||||
duration: T::BlockNumber,
|
||||
duration: BlockNumberFor<T>,
|
||||
lease_period_index: LeasePeriodOf<T>,
|
||||
) -> DispatchResult {
|
||||
Self::do_new_auction(duration, lease_period_index)
|
||||
}
|
||||
|
||||
// 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() {
|
||||
Some((_, early_end)) => early_end,
|
||||
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)
|
||||
}
|
||||
|
||||
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)
|
||||
}
|
||||
|
||||
#[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()
|
||||
}
|
||||
|
||||
@@ -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
|
||||
/// are to be auctioned.
|
||||
fn do_new_auction(
|
||||
duration: T::BlockNumber,
|
||||
duration: BlockNumberFor<T>,
|
||||
lease_period_index: LeasePeriodOf<T>,
|
||||
) -> DispatchResult {
|
||||
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
|
||||
/// 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() {
|
||||
let ending_period = T::EndingPeriod::get();
|
||||
let late_end = early_end.saturating_add(ending_period);
|
||||
@@ -542,7 +541,7 @@ impl<T: Config> Pallet<T> {
|
||||
|
||||
if late_end <= known_since {
|
||||
// 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(),
|
||||
)
|
||||
.expect("secure hashes should always be bigger than the block number; qed");
|
||||
@@ -683,7 +682,7 @@ mod tests {
|
||||
};
|
||||
use frame_system::{EnsureRoot, EnsureSignedBy};
|
||||
use pallet_balances;
|
||||
use primitives::{BlockNumber, Header, Id as ParaId};
|
||||
use primitives::{BlockNumber, Id as ParaId};
|
||||
use sp_core::H256;
|
||||
use sp_runtime::{
|
||||
traits::{BlakeTwo256, IdentityLookup},
|
||||
@@ -691,14 +690,10 @@ mod tests {
|
||||
};
|
||||
use std::{cell::RefCell, collections::BTreeMap};
|
||||
|
||||
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!(
|
||||
pub enum Test where
|
||||
Block = Block,
|
||||
NodeBlock = Block,
|
||||
UncheckedExtrinsic = UncheckedExtrinsic,
|
||||
pub enum Test
|
||||
{
|
||||
System: frame_system::{Pallet, Call, Config<T>, Storage, Event<T>},
|
||||
Balances: pallet_balances::{Pallet, Call, Storage, Config<T>, Event<T>},
|
||||
@@ -717,12 +712,12 @@ mod tests {
|
||||
type RuntimeOrigin = RuntimeOrigin;
|
||||
type RuntimeCall = RuntimeCall;
|
||||
type Index = u64;
|
||||
type BlockNumber = BlockNumber;
|
||||
|
||||
type Hash = H256;
|
||||
type Hashing = BlakeTwo256;
|
||||
type AccountId = u64;
|
||||
type Lookup = IdentityLookup<Self::AccountId>;
|
||||
type Header = Header;
|
||||
type Block = Block;
|
||||
type RuntimeEvent = RuntimeEvent;
|
||||
type BlockHashCount = BlockHashCount;
|
||||
type Version = ();
|
||||
@@ -1800,7 +1795,7 @@ mod benchmarking {
|
||||
where_clause { where T: pallet_babe::Config + paras::Config }
|
||||
|
||||
new_auction {
|
||||
let duration = T::BlockNumber::max_value();
|
||||
let duration = BlockNumberFor::<T>::max_value();
|
||||
let lease_period_index = LeasePeriodOf::<T>::max_value();
|
||||
let origin =
|
||||
T::InitiateOrigin::try_successful_origin().map_err(|_| BenchmarkError::Weightless)?;
|
||||
@@ -1809,7 +1804,7 @@ mod benchmarking {
|
||||
assert_last_event::<T>(Event::<T>::AuctionStarted {
|
||||
auction_index: AuctionCounter::<T>::get(),
|
||||
lease_period: LeasePeriodOf::<T>::max_value(),
|
||||
ending: T::BlockNumber::max_value(),
|
||||
ending: BlockNumberFor::<T>::max_value(),
|
||||
}.into());
|
||||
}
|
||||
|
||||
@@ -1820,7 +1815,7 @@ mod benchmarking {
|
||||
frame_system::Pallet::<T>::set_block_number(offset + One::one());
|
||||
|
||||
// Create a new auction
|
||||
let duration = T::BlockNumber::max_value();
|
||||
let duration = BlockNumberFor::<T>::max_value();
|
||||
let lease_period_index = LeasePeriodOf::<T>::zero();
|
||||
let origin = T::InitiateOrigin::try_successful_origin()
|
||||
.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());
|
||||
|
||||
// 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 now = frame_system::Pallet::<T>::block_number();
|
||||
let origin = T::InitiateOrigin::try_successful_origin()
|
||||
@@ -1886,14 +1881,14 @@ mod benchmarking {
|
||||
|
||||
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());
|
||||
}
|
||||
|
||||
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
|
||||
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
|
||||
@@ -1922,7 +1917,7 @@ mod benchmarking {
|
||||
frame_system::Pallet::<T>::set_block_number(offset + One::one());
|
||||
|
||||
// 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 now = frame_system::Pallet::<T>::block_number();
|
||||
let origin = T::InitiateOrigin::try_successful_origin()
|
||||
@@ -1931,14 +1926,14 @@ mod benchmarking {
|
||||
|
||||
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() {
|
||||
assert!(winner.is_some());
|
||||
}
|
||||
|
||||
// Make winning map full
|
||||
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());
|
||||
}: _(RawOrigin::Root)
|
||||
|
||||
@@ -171,7 +171,7 @@ pub mod pallet {
|
||||
pub trait Config: frame_system::Config {
|
||||
/// The overarching event type.
|
||||
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]
|
||||
type Prefix: Get<&'static [u8]>;
|
||||
type MoveClaimOrigin: EnsureOrigin<Self::RuntimeOrigin>;
|
||||
@@ -217,7 +217,7 @@ pub mod pallet {
|
||||
#[pallet::storage]
|
||||
#[pallet::getter(fn vesting)]
|
||||
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.
|
||||
#[pallet::storage]
|
||||
@@ -232,7 +232,7 @@ pub mod pallet {
|
||||
pub struct GenesisConfig<T: Config> {
|
||||
pub claims:
|
||||
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]
|
||||
@@ -336,7 +336,7 @@ pub mod pallet {
|
||||
origin: OriginFor<T>,
|
||||
who: EthereumAddress,
|
||||
value: BalanceOf<T>,
|
||||
vesting_schedule: Option<(BalanceOf<T>, BalanceOf<T>, T::BlockNumber)>,
|
||||
vesting_schedule: Option<(BalanceOf<T>, BalanceOf<T>, BlockNumberFor<T>)>,
|
||||
statement: Option<StatementKind>,
|
||||
) -> DispatchResult {
|
||||
ensure_root(origin)?;
|
||||
@@ -714,20 +714,15 @@ mod tests {
|
||||
};
|
||||
use pallet_balances;
|
||||
use sp_runtime::{
|
||||
testing::Header,
|
||||
traits::{BlakeTwo256, Identity, IdentityLookup},
|
||||
transaction_validity::TransactionLongevity,
|
||||
BuildStorage, TokenError,
|
||||
};
|
||||
|
||||
type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic<Test>;
|
||||
type Block = frame_system::mocking::MockBlock<Test>;
|
||||
|
||||
frame_support::construct_runtime!(
|
||||
pub enum Test where
|
||||
Block = Block,
|
||||
NodeBlock = Block,
|
||||
UncheckedExtrinsic = UncheckedExtrinsic,
|
||||
pub enum Test
|
||||
{
|
||||
System: frame_system::{Pallet, Call, Config<T>, Storage, Event<T>},
|
||||
Balances: pallet_balances::{Pallet, Call, Storage, Config<T>, Event<T>},
|
||||
@@ -747,12 +742,11 @@ mod tests {
|
||||
type RuntimeOrigin = RuntimeOrigin;
|
||||
type RuntimeCall = RuntimeCall;
|
||||
type Index = u64;
|
||||
type BlockNumber = u64;
|
||||
type Hash = H256;
|
||||
type Hashing = BlakeTwo256;
|
||||
type AccountId = u64;
|
||||
type Lookup = IdentityLookup<u64>;
|
||||
type Header = Header;
|
||||
type Block = Block;
|
||||
type RuntimeEvent = RuntimeEvent;
|
||||
type BlockHashCount = BlockHashCount;
|
||||
type Version = ();
|
||||
|
||||
@@ -66,6 +66,7 @@ use frame_support::{
|
||||
},
|
||||
Identity, PalletId,
|
||||
};
|
||||
use frame_system::pallet_prelude::BlockNumberFor;
|
||||
pub use pallet::*;
|
||||
use parity_scale_codec::{Decode, Encode};
|
||||
use primitives::Id as ParaId;
|
||||
@@ -78,11 +79,8 @@ use sp_runtime::{
|
||||
};
|
||||
use sp_std::vec::Vec;
|
||||
|
||||
type CurrencyOf<T> =
|
||||
<<T as Config>::Auctioneer as Auctioneer<<T as frame_system::Config>::BlockNumber>>::Currency;
|
||||
type LeasePeriodOf<T> = <<T as Config>::Auctioneer as Auctioneer<
|
||||
<T as frame_system::Config>::BlockNumber,
|
||||
>>::LeasePeriod;
|
||||
type CurrencyOf<T> = <<T as Config>::Auctioneer as Auctioneer<BlockNumberFor<T>>>::Currency;
|
||||
type LeasePeriodOf<T> = <<T as Config>::Auctioneer as Auctioneer<BlockNumberFor<T>>>::LeasePeriod;
|
||||
type BalanceOf<T> = <CurrencyOf<T> as Currency<<T as frame_system::Config>::AccountId>>::Balance;
|
||||
|
||||
#[allow(dead_code)]
|
||||
@@ -216,9 +214,9 @@ pub mod pallet {
|
||||
|
||||
/// The type representing the auctioning system.
|
||||
type Auctioneer: Auctioneer<
|
||||
Self::BlockNumber,
|
||||
BlockNumberFor<Self>,
|
||||
AccountId = Self::AccountId,
|
||||
LeasePeriod = Self::BlockNumber,
|
||||
LeasePeriod = BlockNumberFor<Self>,
|
||||
>;
|
||||
|
||||
/// The maximum length for the memo attached to a crowdloan contribution.
|
||||
@@ -235,7 +233,7 @@ pub mod pallet {
|
||||
_,
|
||||
Twox64Concat,
|
||||
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
|
||||
@@ -332,7 +330,7 @@ pub mod pallet {
|
||||
|
||||
#[pallet::hooks]
|
||||
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() {
|
||||
// This is the very first block in the ending period
|
||||
if sample.is_zero() && sub_sample.is_zero() {
|
||||
@@ -377,7 +375,7 @@ pub mod pallet {
|
||||
#[pallet::compact] cap: BalanceOf<T>,
|
||||
#[pallet::compact] first_period: LeasePeriodOf<T>,
|
||||
#[pallet::compact] last_period: LeasePeriodOf<T>,
|
||||
#[pallet::compact] end: T::BlockNumber,
|
||||
#[pallet::compact] end: BlockNumberFor<T>,
|
||||
verifier: Option<MultiSigner>,
|
||||
) -> DispatchResult {
|
||||
let depositor = ensure_signed(origin)?;
|
||||
@@ -594,7 +592,7 @@ pub mod pallet {
|
||||
#[pallet::compact] cap: BalanceOf<T>,
|
||||
#[pallet::compact] first_period: LeasePeriodOf<T>,
|
||||
#[pallet::compact] last_period: LeasePeriodOf<T>,
|
||||
#[pallet::compact] end: T::BlockNumber,
|
||||
#[pallet::compact] end: BlockNumberFor<T>,
|
||||
verifier: Option<MultiSigner>,
|
||||
) -> DispatchResult {
|
||||
ensure_root(origin)?;
|
||||
@@ -725,9 +723,9 @@ impl<T: Config> Pallet<T> {
|
||||
/// trying to bid for has started already.
|
||||
/// * And, if the fund has enough free funds to refund full raised amount.
|
||||
fn ensure_crowdloan_ended(
|
||||
now: T::BlockNumber,
|
||||
now: BlockNumberFor<T>,
|
||||
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 {
|
||||
// `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
|
||||
@@ -878,19 +876,14 @@ mod tests {
|
||||
use ::test_helpers::{dummy_head_data, dummy_validation_code};
|
||||
use sp_keystore::{testing::MemoryKeystore, KeystoreExt};
|
||||
use sp_runtime::{
|
||||
testing::Header,
|
||||
traits::{BlakeTwo256, IdentityLookup, TrailingZeroInput},
|
||||
BuildStorage, DispatchResult,
|
||||
};
|
||||
|
||||
type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic<Test>;
|
||||
type Block = frame_system::mocking::MockBlock<Test>;
|
||||
|
||||
frame_support::construct_runtime!(
|
||||
pub enum Test where
|
||||
Block = Block,
|
||||
NodeBlock = Block,
|
||||
UncheckedExtrinsic = UncheckedExtrinsic,
|
||||
pub enum Test
|
||||
{
|
||||
System: frame_system::{Pallet, Call, Config<T>, Storage, Event<T>},
|
||||
Balances: pallet_balances::{Pallet, Call, Storage, Config<T>, Event<T>},
|
||||
@@ -912,12 +905,12 @@ mod tests {
|
||||
type RuntimeOrigin = RuntimeOrigin;
|
||||
type RuntimeCall = RuntimeCall;
|
||||
type Index = u64;
|
||||
type BlockNumber = BlockNumber;
|
||||
|
||||
type Hash = H256;
|
||||
type Hashing = BlakeTwo256;
|
||||
type AccountId = u64;
|
||||
type Lookup = IdentityLookup<Self::AccountId>;
|
||||
type Header = Header;
|
||||
type Block = Block;
|
||||
type RuntimeEvent = RuntimeEvent;
|
||||
type BlockHashCount = BlockHashCount;
|
||||
type Version = ();
|
||||
@@ -1968,7 +1961,7 @@ mod benchmarking {
|
||||
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 (_, offset) = T::Auctioneer::lease_period_length();
|
||||
// Set to the very beginning of lease period index 0.
|
||||
@@ -2088,7 +2081,7 @@ mod benchmarking {
|
||||
let caller: T::AccountId = whitelisted_caller();
|
||||
let contributor = account("contributor", 0, 0);
|
||||
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)
|
||||
verify {
|
||||
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();
|
||||
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)
|
||||
verify {
|
||||
assert_last_event::<T>(Event::<T>::AllRefunded { para_id: fund_index }.into());
|
||||
@@ -2119,7 +2112,7 @@ mod benchmarking {
|
||||
let end = lpl + offset;
|
||||
let fund_index = create_fund::<T>(1337, end);
|
||||
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)
|
||||
verify {
|
||||
assert_last_event::<T>(Event::<T>::Dissolved { para_id: fund_index }.into());
|
||||
|
||||
@@ -112,20 +112,15 @@ mod tests {
|
||||
use primitives::AccountId;
|
||||
use sp_core::{ConstU64, H256};
|
||||
use sp_runtime::{
|
||||
testing::Header,
|
||||
traits::{BlakeTwo256, IdentityLookup},
|
||||
BuildStorage, Perbill,
|
||||
};
|
||||
|
||||
type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic<Test>;
|
||||
type Block = frame_system::mocking::MockBlock<Test>;
|
||||
const TEST_ACCOUNT: AccountId = AccountId::new([1; 32]);
|
||||
|
||||
frame_support::construct_runtime!(
|
||||
pub enum Test where
|
||||
Block = Block,
|
||||
NodeBlock = Block,
|
||||
UncheckedExtrinsic = UncheckedExtrinsic,
|
||||
pub enum Test
|
||||
{
|
||||
System: frame_system::{Pallet, Call, Config<T>, Storage, Event<T>},
|
||||
Authorship: pallet_authorship::{Pallet, Storage},
|
||||
@@ -153,13 +148,12 @@ mod tests {
|
||||
type BaseCallFilter = frame_support::traits::Everything;
|
||||
type RuntimeOrigin = RuntimeOrigin;
|
||||
type Index = u64;
|
||||
type BlockNumber = u64;
|
||||
type RuntimeCall = RuntimeCall;
|
||||
type Hash = H256;
|
||||
type Hashing = BlakeTwo256;
|
||||
type AccountId = AccountId;
|
||||
type Lookup = IdentityLookup<Self::AccountId>;
|
||||
type Header = Header;
|
||||
type Block = Block;
|
||||
type RuntimeEvent = RuntimeEvent;
|
||||
type BlockHashCount = BlockHashCount;
|
||||
type BlockLength = BlockLength;
|
||||
|
||||
@@ -34,7 +34,7 @@ use frame_support_test::TestRandomness;
|
||||
use frame_system::EnsureRoot;
|
||||
use parity_scale_codec::Encode;
|
||||
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::{
|
||||
configuration, origin, paras, shared, Origin as ParaOrigin, ParaLifecycle,
|
||||
@@ -51,7 +51,7 @@ use sp_runtime::{
|
||||
use sp_std::sync::Arc;
|
||||
|
||||
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 Balance = u32;
|
||||
@@ -70,10 +70,7 @@ fn signed(i: u32) -> RuntimeOrigin {
|
||||
}
|
||||
|
||||
frame_support::construct_runtime!(
|
||||
pub enum Test where
|
||||
Block = Block,
|
||||
NodeBlock = Block,
|
||||
UncheckedExtrinsic = UncheckedExtrinsic,
|
||||
pub enum Test
|
||||
{
|
||||
// System Stuff
|
||||
System: frame_system::{Pallet, Call, Config<T>, Storage, Event<T>},
|
||||
@@ -120,12 +117,12 @@ impl frame_system::Config for Test {
|
||||
type RuntimeOrigin = RuntimeOrigin;
|
||||
type RuntimeCall = RuntimeCall;
|
||||
type Index = u64;
|
||||
type BlockNumber = BlockNumber;
|
||||
|
||||
type Hash = H256;
|
||||
type Hashing = BlakeTwo256;
|
||||
type AccountId = AccountId;
|
||||
type Lookup = IdentityLookup<AccountId>;
|
||||
type Header = Header;
|
||||
type Block = Block;
|
||||
type RuntimeEvent = RuntimeEvent;
|
||||
type BlockHashCount = BlockHashCount;
|
||||
type Version = ();
|
||||
|
||||
@@ -21,6 +21,7 @@ use frame_support::{
|
||||
dispatch::{DispatchError, DispatchResult},
|
||||
weights::Weight,
|
||||
};
|
||||
use frame_system::pallet_prelude::BlockNumberFor;
|
||||
use parity_scale_codec::{Decode, Encode};
|
||||
use primitives::{HeadData, Id as ParaId, PvfCheckStatement, SessionIndex, ValidationCode};
|
||||
use runtime_parachains::paras;
|
||||
@@ -192,7 +193,7 @@ impl<T: frame_system::Config> Registrar for 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
|
||||
.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 pallet_balances::Error as BalancesError;
|
||||
use primitives::{Balance, BlockNumber, Header, SessionIndex};
|
||||
use primitives::{Balance, BlockNumber, SessionIndex};
|
||||
use runtime_parachains::{configuration, origin, shared};
|
||||
use sp_core::H256;
|
||||
use sp_io::TestExternalities;
|
||||
@@ -680,13 +680,10 @@ mod tests {
|
||||
use sp_std::collections::btree_map::BTreeMap;
|
||||
|
||||
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!(
|
||||
pub enum Test where
|
||||
Block = Block,
|
||||
NodeBlock = Block,
|
||||
UncheckedExtrinsic = UncheckedExtrinsic,
|
||||
pub enum Test
|
||||
{
|
||||
System: frame_system::{Pallet, Call, Config<T>, Storage, Event<T>},
|
||||
Balances: pallet_balances::{Pallet, Call, Storage, Config<T>, Event<T>},
|
||||
@@ -720,12 +717,12 @@ mod tests {
|
||||
type RuntimeOrigin = RuntimeOrigin;
|
||||
type RuntimeCall = RuntimeCall;
|
||||
type Index = u64;
|
||||
type BlockNumber = BlockNumber;
|
||||
|
||||
type Hash = H256;
|
||||
type Hashing = BlakeTwo256;
|
||||
type AccountId = u64;
|
||||
type Lookup = IdentityLookup<u64>;
|
||||
type Header = Header;
|
||||
type Block = Block;
|
||||
type RuntimeEvent = RuntimeEvent;
|
||||
type BlockHashCount = BlockHashCount;
|
||||
type DbWeight = ();
|
||||
|
||||
@@ -105,7 +105,7 @@ pub mod pallet {
|
||||
/// Vesting Pallet
|
||||
type VestingSchedule: VestingSchedule<
|
||||
Self::AccountId,
|
||||
Moment = Self::BlockNumber,
|
||||
Moment = BlockNumberFor<Self>,
|
||||
Currency = Self::Currency,
|
||||
>;
|
||||
|
||||
@@ -144,7 +144,7 @@ pub mod pallet {
|
||||
/// A new statement was set.
|
||||
StatementUpdated,
|
||||
/// A new statement was set. `[block_number]`
|
||||
UnlockBlockUpdated { block_number: T::BlockNumber },
|
||||
UnlockBlockUpdated { block_number: BlockNumberFor<T> },
|
||||
}
|
||||
|
||||
#[pallet::error]
|
||||
@@ -182,7 +182,7 @@ pub mod pallet {
|
||||
|
||||
// The block where all locked dots will unlock.
|
||||
#[pallet::storage]
|
||||
pub(super) type UnlockBlock<T: Config> = StorageValue<_, T::BlockNumber, ValueQuery>;
|
||||
pub(super) type UnlockBlock<T: Config> = StorageValue<_, BlockNumberFor<T>, ValueQuery>;
|
||||
|
||||
#[pallet::hooks]
|
||||
impl<T: Config> Hooks<BlockNumberFor<T>> for Pallet<T> {}
|
||||
@@ -403,7 +403,7 @@ pub mod pallet {
|
||||
#[pallet::weight(T::DbWeight::get().writes(1))]
|
||||
pub fn set_unlock_block(
|
||||
origin: OriginFor<T>,
|
||||
unlock_block: T::BlockNumber,
|
||||
unlock_block: BlockNumberFor<T>,
|
||||
) -> DispatchResult {
|
||||
T::ConfigurationOrigin::ensure_origin(origin)?;
|
||||
ensure!(
|
||||
@@ -486,19 +486,14 @@ mod tests {
|
||||
traits::{Currency, WithdrawReasons},
|
||||
};
|
||||
use sp_runtime::{
|
||||
testing::Header,
|
||||
traits::{BlakeTwo256, Dispatchable, IdentifyAccount, Identity, IdentityLookup, Verify},
|
||||
ArithmeticError, BuildStorage, MultiSignature,
|
||||
};
|
||||
|
||||
type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic<Test>;
|
||||
type Block = frame_system::mocking::MockBlock<Test>;
|
||||
|
||||
frame_support::construct_runtime!(
|
||||
pub enum Test where
|
||||
Block = Block,
|
||||
NodeBlock = Block,
|
||||
UncheckedExtrinsic = UncheckedExtrinsic,
|
||||
pub enum Test
|
||||
{
|
||||
System: frame_system::{Pallet, Call, Config<T>, Storage, Event<T>},
|
||||
Balances: pallet_balances::{Pallet, Call, Storage, Config<T>, Event<T>},
|
||||
@@ -520,12 +515,11 @@ mod tests {
|
||||
type RuntimeOrigin = RuntimeOrigin;
|
||||
type RuntimeCall = RuntimeCall;
|
||||
type Index = u64;
|
||||
type BlockNumber = u64;
|
||||
type Hash = H256;
|
||||
type Hashing = BlakeTwo256;
|
||||
type AccountId = AccountId;
|
||||
type Lookup = IdentityLookup<AccountId>;
|
||||
type Header = Header;
|
||||
type Block = Block;
|
||||
type RuntimeEvent = RuntimeEvent;
|
||||
type BlockHashCount = BlockHashCount;
|
||||
type Version = ();
|
||||
|
||||
@@ -37,7 +37,7 @@ use sp_std::prelude::*;
|
||||
|
||||
type BalanceOf<T> =
|
||||
<<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 {
|
||||
fn force_lease() -> Weight;
|
||||
@@ -83,11 +83,11 @@ pub mod pallet {
|
||||
|
||||
/// The number of blocks over which a single period lasts.
|
||||
#[pallet::constant]
|
||||
type LeasePeriod: Get<Self::BlockNumber>;
|
||||
type LeasePeriod: Get<BlockNumberFor<Self>>;
|
||||
|
||||
/// The number of blocks to offset each lease period by.
|
||||
#[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.
|
||||
type ForceOrigin: EnsureOrigin<<Self as frame_system::Config>::RuntimeOrigin>;
|
||||
@@ -145,7 +145,7 @@ pub mod pallet {
|
||||
|
||||
#[pallet::hooks]
|
||||
impl<T: Config> Hooks<BlockNumberFor<T>> for Pallet<T> {
|
||||
fn on_initialize(n: T::BlockNumber) -> Weight {
|
||||
fn on_initialize(n: BlockNumberFor<T>) -> Weight {
|
||||
if let Some((lease_period, first_block)) = Self::lease_period_index(n) {
|
||||
// If we're beginning a new lease period then handle that.
|
||||
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 LeasePeriod = T::BlockNumber;
|
||||
type LeasePeriod = BlockNumberFor<T>;
|
||||
type Currency = T::Currency;
|
||||
|
||||
fn lease_out(
|
||||
@@ -442,11 +442,11 @@ impl<T: Config> Leaser<T::BlockNumber> for Pallet<T> {
|
||||
}
|
||||
|
||||
#[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())
|
||||
}
|
||||
|
||||
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.
|
||||
let offset_block_now = b.checked_sub(&T::LeaseOffset::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_system::EnsureRoot;
|
||||
use pallet_balances;
|
||||
use primitives::{BlockNumber, Header};
|
||||
use primitives::BlockNumber;
|
||||
use sp_core::H256;
|
||||
use sp_runtime::{
|
||||
traits::{BlakeTwo256, IdentityLookup},
|
||||
BuildStorage,
|
||||
};
|
||||
|
||||
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!(
|
||||
pub enum Test where
|
||||
Block = Block,
|
||||
NodeBlock = Block,
|
||||
UncheckedExtrinsic = UncheckedExtrinsic,
|
||||
pub enum Test
|
||||
{
|
||||
System: frame_system::{Pallet, Call, Config<T>, Storage, Event<T>},
|
||||
Balances: pallet_balances::{Pallet, Call, Storage, Config<T>, Event<T>},
|
||||
@@ -537,12 +533,12 @@ mod tests {
|
||||
type RuntimeOrigin = RuntimeOrigin;
|
||||
type RuntimeCall = RuntimeCall;
|
||||
type Index = u64;
|
||||
type BlockNumber = BlockNumber;
|
||||
|
||||
type Hash = H256;
|
||||
type Hashing = BlakeTwo256;
|
||||
type AccountId = u64;
|
||||
type Lookup = IdentityLookup<Self::AccountId>;
|
||||
type Header = Header;
|
||||
type Block = Block;
|
||||
type RuntimeEvent = RuntimeEvent;
|
||||
type BlockHashCount = BlockHashCount;
|
||||
type DbWeight = ();
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
//! XCM sender for relay chain.
|
||||
|
||||
use frame_support::traits::Get;
|
||||
use frame_system::pallet_prelude::BlockNumberFor;
|
||||
use parity_scale_codec::Encode;
|
||||
use primitives::Id as ParaId;
|
||||
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>
|
||||
SendXcm for ChildParachainRouter<T, W, P>
|
||||
{
|
||||
type Ticket = (HostConfiguration<T::BlockNumber>, ParaId, Vec<u8>);
|
||||
type Ticket = (HostConfiguration<BlockNumberFor<T>>, ParaId, Vec<u8>);
|
||||
|
||||
fn validate(
|
||||
dest: &mut Option<MultiLocation>,
|
||||
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 id = if let MultiLocation { parents: 0, interior: X1(Parachain(id)) } = &d {
|
||||
*id
|
||||
@@ -99,7 +100,7 @@ impl<T: configuration::Config + dmp::Config, W: xcm::WrapVersion, P: PriceForPar
|
||||
}
|
||||
|
||||
fn deliver(
|
||||
(config, para, blob): (HostConfiguration<T::BlockNumber>, ParaId, Vec<u8>),
|
||||
(config, para, blob): (HostConfiguration<BlockNumberFor<T>>, ParaId, Vec<u8>),
|
||||
) -> Result<XcmHash, SendError> {
|
||||
let hash = sp_io::hashing::blake2_256(&blob[..]);
|
||||
<dmp::Pallet<T>>::queue_downward_message(&config, para, blob)
|
||||
|
||||
Reference in New Issue
Block a user