mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-21 07:31:03 +00:00
Moves Block to frame_system instead of construct_runtime and removes Header and BlockNumber (#14437)
* Initial setup * Adds node block * Uses UncheckedExtrinsic and removes Where section * Updates frame_system to use Block * Adds deprecation warning * Fixes pallet-timestamp * Removes Header and BlockNumber * Addresses review comments * Addresses review comments * Adds comment about compiler bug * Removes where clause * Refactors code * Fixes errors in cargo check * Fixes errors in cargo check * Fixes warnings in cargo check * Formatting * Fixes construct_runtime tests * Uses import instead of full path for BlockNumber * Uses import instead of full path for Header * Formatting * Fixes construct_runtime tests * Fixes imports in benchmarks * Formatting * Fixes construct_runtime tests * Formatting * Minor updates * Fixes construct_runtime ui tests * Fixes construct_runtime ui tests with 1.70 * Fixes docs * Fixes docs * Adds u128 mock block type * Fixes split example * fixes for cumulus * ".git/.scripts/commands/fmt/fmt.sh" * Updates new tests * Fixes fully-qualified path in few places * Formatting * Update frame/examples/default-config/src/lib.rs Co-authored-by: Juan <juangirini@gmail.com> * Update frame/support/procedural/src/construct_runtime/mod.rs Co-authored-by: Juan <juangirini@gmail.com> * ".git/.scripts/commands/fmt/fmt.sh" * Addresses some review comments * Fixes build * ".git/.scripts/commands/fmt/fmt.sh" * Update frame/democracy/src/lib.rs Co-authored-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * Update frame/democracy/src/lib.rs Co-authored-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * Update frame/support/procedural/src/construct_runtime/mod.rs Co-authored-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * Update frame/support/procedural/src/construct_runtime/mod.rs Co-authored-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * Addresses review comments * Updates trait bounds * Minor fix * ".git/.scripts/commands/fmt/fmt.sh" * Removes unnecessary bound * ".git/.scripts/commands/fmt/fmt.sh" * Updates test * Fixes build * Adds a bound for header * ".git/.scripts/commands/fmt/fmt.sh" * Removes where block * Minor fix * Minor fix * Fixes tests * ".git/.scripts/commands/update-ui/update-ui.sh" 1.70 * Updates test * Update primitives/runtime/src/traits.rs Co-authored-by: Bastian Köcher <git@kchr.de> * Update primitives/runtime/src/traits.rs Co-authored-by: Bastian Köcher <git@kchr.de> * Updates doc * Updates doc --------- Co-authored-by: command-bot <> Co-authored-by: Juan <juangirini@gmail.com> Co-authored-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> Co-authored-by: Bastian Köcher <git@kchr.de>
This commit is contained in:
@@ -77,6 +77,7 @@ use frame_support::{
|
||||
},
|
||||
BoundedVec,
|
||||
};
|
||||
use frame_system::pallet_prelude::BlockNumberFor;
|
||||
use scale_info::TypeInfo;
|
||||
use sp_runtime::{
|
||||
traits::{AtLeast32BitUnsigned, Bounded, Dispatchable, One, Saturating, Zero},
|
||||
@@ -161,8 +162,8 @@ pub mod pallet {
|
||||
/// Weight information for extrinsics in this pallet.
|
||||
type WeightInfo: WeightInfo;
|
||||
/// The Scheduler.
|
||||
type Scheduler: ScheduleAnon<Self::BlockNumber, CallOf<Self, I>, PalletsOriginOf<Self>>
|
||||
+ ScheduleNamed<Self::BlockNumber, CallOf<Self, I>, PalletsOriginOf<Self>>;
|
||||
type Scheduler: ScheduleAnon<BlockNumberFor<Self>, CallOf<Self, I>, PalletsOriginOf<Self>>
|
||||
+ ScheduleNamed<BlockNumberFor<Self>, CallOf<Self, I>, PalletsOriginOf<Self>>;
|
||||
/// Currency type for this pallet.
|
||||
type Currency: ReservableCurrency<Self::AccountId>;
|
||||
// Origins and unbalances.
|
||||
@@ -201,25 +202,25 @@ pub mod pallet {
|
||||
/// The number of blocks after submission that a referendum must begin being decided by.
|
||||
/// Once this passes, then anyone may cancel the referendum.
|
||||
#[pallet::constant]
|
||||
type UndecidingTimeout: Get<Self::BlockNumber>;
|
||||
type UndecidingTimeout: Get<BlockNumberFor<Self>>;
|
||||
|
||||
/// Quantization level for the referendum wakeup scheduler. A higher number will result in
|
||||
/// fewer storage reads/writes needed for smaller voters, but also result in delays to the
|
||||
/// automatic referendum status changes. Explicit servicing instructions are unaffected.
|
||||
#[pallet::constant]
|
||||
type AlarmInterval: Get<Self::BlockNumber>;
|
||||
type AlarmInterval: Get<BlockNumberFor<Self>>;
|
||||
|
||||
// The other stuff.
|
||||
/// Information concerning the different referendum tracks.
|
||||
#[pallet::constant]
|
||||
type Tracks: Get<
|
||||
Vec<(
|
||||
<Self::Tracks as TracksInfo<BalanceOf<Self, I>, Self::BlockNumber>>::Id,
|
||||
TrackInfo<BalanceOf<Self, I>, Self::BlockNumber>,
|
||||
<Self::Tracks as TracksInfo<BalanceOf<Self, I>, BlockNumberFor<Self>>>::Id,
|
||||
TrackInfo<BalanceOf<Self, I>, BlockNumberFor<Self>>,
|
||||
)>,
|
||||
> + TracksInfo<
|
||||
BalanceOf<Self, I>,
|
||||
Self::BlockNumber,
|
||||
BlockNumberFor<Self>,
|
||||
RuntimeOrigin = <Self::RuntimeOrigin as OriginTrait>::PalletsOrigin,
|
||||
>;
|
||||
|
||||
@@ -432,7 +433,7 @@ pub mod pallet {
|
||||
origin: OriginFor<T>,
|
||||
proposal_origin: Box<PalletsOriginOf<T>>,
|
||||
proposal: BoundedCallOf<T, I>,
|
||||
enactment_moment: DispatchTime<T::BlockNumber>,
|
||||
enactment_moment: DispatchTime<BlockNumberFor<T>>,
|
||||
) -> DispatchResult {
|
||||
let proposal_origin = *proposal_origin;
|
||||
let who = T::SubmitOrigin::ensure_origin(origin, &proposal_origin)?;
|
||||
@@ -704,7 +705,7 @@ pub mod pallet {
|
||||
impl<T: Config<I>, I: 'static> Polling<T::Tally> for Pallet<T, I> {
|
||||
type Index = ReferendumIndex;
|
||||
type Votes = VotesOf<T, I>;
|
||||
type Moment = T::BlockNumber;
|
||||
type Moment = BlockNumberFor<T>;
|
||||
type Class = TrackIdOf<T, I>;
|
||||
|
||||
fn classes() -> Vec<Self::Class> {
|
||||
@@ -713,7 +714,7 @@ impl<T: Config<I>, I: 'static> Polling<T::Tally> for Pallet<T, I> {
|
||||
|
||||
fn access_poll<R>(
|
||||
index: Self::Index,
|
||||
f: impl FnOnce(PollStatus<&mut T::Tally, T::BlockNumber, TrackIdOf<T, I>>) -> R,
|
||||
f: impl FnOnce(PollStatus<&mut T::Tally, BlockNumberFor<T>, TrackIdOf<T, I>>) -> R,
|
||||
) -> R {
|
||||
match ReferendumInfoFor::<T, I>::get(index) {
|
||||
Some(ReferendumInfo::Ongoing(mut status)) => {
|
||||
@@ -732,7 +733,7 @@ impl<T: Config<I>, I: 'static> Polling<T::Tally> for Pallet<T, I> {
|
||||
fn try_access_poll<R>(
|
||||
index: Self::Index,
|
||||
f: impl FnOnce(
|
||||
PollStatus<&mut T::Tally, T::BlockNumber, TrackIdOf<T, I>>,
|
||||
PollStatus<&mut T::Tally, BlockNumberFor<T>, TrackIdOf<T, I>>,
|
||||
) -> Result<R, DispatchError>,
|
||||
) -> Result<R, DispatchError> {
|
||||
match ReferendumInfoFor::<T, I>::get(index) {
|
||||
@@ -849,7 +850,7 @@ impl<T: Config<I>, I: 'static> Pallet<T, I> {
|
||||
fn schedule_enactment(
|
||||
index: ReferendumIndex,
|
||||
track: &TrackInfoOf<T, I>,
|
||||
desired: DispatchTime<T::BlockNumber>,
|
||||
desired: DispatchTime<BlockNumberFor<T>>,
|
||||
origin: PalletsOriginOf<T>,
|
||||
call: BoundedCallOf<T, I>,
|
||||
) {
|
||||
@@ -871,8 +872,8 @@ impl<T: Config<I>, I: 'static> Pallet<T, I> {
|
||||
/// Set an alarm to dispatch `call` at block number `when`.
|
||||
fn set_alarm(
|
||||
call: BoundedCallOf<T, I>,
|
||||
when: T::BlockNumber,
|
||||
) -> Option<(T::BlockNumber, ScheduleAddressOf<T, I>)> {
|
||||
when: BlockNumberFor<T>,
|
||||
) -> Option<(BlockNumberFor<T>, ScheduleAddressOf<T, I>)> {
|
||||
let alarm_interval = T::AlarmInterval::get().max(One::one());
|
||||
// Alarm must go off no earlier than `when`.
|
||||
// This rounds `when` upwards to the next multiple of `alarm_interval`.
|
||||
@@ -905,9 +906,9 @@ impl<T: Config<I>, I: 'static> Pallet<T, I> {
|
||||
fn begin_deciding(
|
||||
status: &mut ReferendumStatusOf<T, I>,
|
||||
index: ReferendumIndex,
|
||||
now: T::BlockNumber,
|
||||
now: BlockNumberFor<T>,
|
||||
track: &TrackInfoOf<T, I>,
|
||||
) -> (Option<T::BlockNumber>, BeginDecidingBranch) {
|
||||
) -> (Option<BlockNumberFor<T>>, BeginDecidingBranch) {
|
||||
let is_passing = Self::is_passing(
|
||||
&status.tally,
|
||||
Zero::zero(),
|
||||
@@ -943,11 +944,11 @@ impl<T: Config<I>, I: 'static> Pallet<T, I> {
|
||||
///
|
||||
/// If `None`, then it is queued and should be nudged automatically as the queue gets drained.
|
||||
fn ready_for_deciding(
|
||||
now: T::BlockNumber,
|
||||
now: BlockNumberFor<T>,
|
||||
track: &TrackInfoOf<T, I>,
|
||||
index: ReferendumIndex,
|
||||
status: &mut ReferendumStatusOf<T, I>,
|
||||
) -> (Option<T::BlockNumber>, ServiceBranch) {
|
||||
) -> (Option<BlockNumberFor<T>>, ServiceBranch) {
|
||||
let deciding_count = DecidingCount::<T, I>::get(status.track);
|
||||
if deciding_count < track.max_deciding {
|
||||
// Begin deciding.
|
||||
@@ -1004,7 +1005,7 @@ impl<T: Config<I>, I: 'static> Pallet<T, I> {
|
||||
fn ensure_alarm_at(
|
||||
status: &mut ReferendumStatusOf<T, I>,
|
||||
index: ReferendumIndex,
|
||||
alarm: T::BlockNumber,
|
||||
alarm: BlockNumberFor<T>,
|
||||
) -> bool {
|
||||
if status.alarm.as_ref().map_or(true, |&(when, _)| when != alarm) {
|
||||
// Either no alarm or one that was different
|
||||
@@ -1049,7 +1050,7 @@ impl<T: Config<I>, I: 'static> Pallet<T, I> {
|
||||
/// `TrackQueue`. Basically this happens when a referendum is in the deciding queue and receives
|
||||
/// a vote, or when it moves into the deciding queue.
|
||||
fn service_referendum(
|
||||
now: T::BlockNumber,
|
||||
now: BlockNumberFor<T>,
|
||||
index: ReferendumIndex,
|
||||
mut status: ReferendumStatusOf<T, I>,
|
||||
) -> (ReferendumInfoOf<T, I>, bool, ServiceBranch) {
|
||||
@@ -1061,7 +1062,7 @@ impl<T: Config<I>, I: 'static> Pallet<T, I> {
|
||||
};
|
||||
// Default the alarm to the end of the world.
|
||||
let timeout = status.submitted + T::UndecidingTimeout::get();
|
||||
let mut alarm = T::BlockNumber::max_value();
|
||||
let mut alarm = BlockNumberFor::<T>::max_value();
|
||||
let branch;
|
||||
match &mut status.deciding {
|
||||
None => {
|
||||
@@ -1192,7 +1193,7 @@ impl<T: Config<I>, I: 'static> Pallet<T, I> {
|
||||
},
|
||||
}
|
||||
|
||||
let dirty_alarm = if alarm < T::BlockNumber::max_value() {
|
||||
let dirty_alarm = if alarm < BlockNumberFor::<T>::max_value() {
|
||||
Self::ensure_alarm_at(&mut status, index, alarm)
|
||||
} else {
|
||||
Self::ensure_no_alarm(&mut status)
|
||||
@@ -1207,7 +1208,7 @@ impl<T: Config<I>, I: 'static> Pallet<T, I> {
|
||||
tally: &T::Tally,
|
||||
track_id: TrackIdOf<T, I>,
|
||||
track: &TrackInfoOf<T, I>,
|
||||
) -> T::BlockNumber {
|
||||
) -> BlockNumberFor<T> {
|
||||
deciding.confirming.unwrap_or_else(|| {
|
||||
// Set alarm to the point where the current voting would make it pass.
|
||||
let approval = tally.approval(track_id);
|
||||
@@ -1266,8 +1267,8 @@ impl<T: Config<I>, I: 'static> Pallet<T, I> {
|
||||
/// `approval_needed`.
|
||||
fn is_passing(
|
||||
tally: &T::Tally,
|
||||
elapsed: T::BlockNumber,
|
||||
period: T::BlockNumber,
|
||||
elapsed: BlockNumberFor<T>,
|
||||
period: BlockNumberFor<T>,
|
||||
support_needed: &Curve,
|
||||
approval_needed: &Curve,
|
||||
id: TrackIdOf<T, I>,
|
||||
|
||||
Reference in New Issue
Block a user