diff --git a/node/client/src/lib.rs b/node/client/src/lib.rs index 1ef0e7f6c022..603392aa2d08 100644 --- a/node/client/src/lib.rs +++ b/node/client/src/lib.rs @@ -129,7 +129,7 @@ pub trait RuntimeApiCollection: + ParachainHost + sp_block_builder::BlockBuilder + frame_system_rpc_runtime_api::AccountNonceApi - + sp_mmr_primitives::MmrApi::Hash, BlockNumber> + + sp_mmr_primitives::MmrApi::Hash, BlockNumber> + pallet_transaction_payment_rpc_runtime_api::TransactionPaymentApi + sp_api::Metadata + sp_offchain::OffchainWorkerApi @@ -150,7 +150,7 @@ where + ParachainHost + sp_block_builder::BlockBuilder + frame_system_rpc_runtime_api::AccountNonceApi - + sp_mmr_primitives::MmrApi::Hash, BlockNumber> + + sp_mmr_primitives::MmrApi::Hash, BlockNumber> + pallet_transaction_payment_rpc_runtime_api::TransactionPaymentApi + sp_api::Metadata + sp_offchain::OffchainWorkerApi @@ -328,7 +328,7 @@ impl UsageProvider for Client { impl sc_client_api::BlockBackend for Client { fn block_body( &self, - hash: ::Hash, + hash: ::Hash, ) -> sp_blockchain::Result::Extrinsic>>> { with_client! { self, @@ -341,7 +341,7 @@ impl sc_client_api::BlockBackend for Client { fn block( &self, - hash: ::Hash, + hash: ::Hash, ) -> sp_blockchain::Result>> { with_client! { self, @@ -352,7 +352,7 @@ impl sc_client_api::BlockBackend for Client { } } - fn block_status(&self, hash: ::Hash) -> sp_blockchain::Result { + fn block_status(&self, hash: ::Hash) -> sp_blockchain::Result { with_client! { self, client, @@ -364,7 +364,7 @@ impl sc_client_api::BlockBackend for Client { fn justifications( &self, - hash: ::Hash, + hash: ::Hash, ) -> sp_blockchain::Result> { with_client! { self, @@ -378,7 +378,7 @@ impl sc_client_api::BlockBackend for Client { fn block_hash( &self, number: NumberFor, - ) -> sp_blockchain::Result::Hash>> { + ) -> sp_blockchain::Result::Hash>> { with_client! { self, client, @@ -390,7 +390,7 @@ impl sc_client_api::BlockBackend for Client { fn indexed_transaction( &self, - id: ::Hash, + id: ::Hash, ) -> sp_blockchain::Result>> { with_client! { self, @@ -403,7 +403,7 @@ impl sc_client_api::BlockBackend for Client { fn block_indexed_body( &self, - id: ::Hash, + id: ::Hash, ) -> sp_blockchain::Result>>> { with_client! { self, @@ -428,7 +428,7 @@ impl sc_client_api::BlockBackend for Client { impl sc_client_api::StorageProvider for Client { fn storage( &self, - hash: ::Hash, + hash: ::Hash, key: &StorageKey, ) -> sp_blockchain::Result> { with_client! { @@ -442,9 +442,9 @@ impl sc_client_api::StorageProvider for Client { fn storage_hash( &self, - hash: ::Hash, + hash: ::Hash, key: &StorageKey, - ) -> sp_blockchain::Result::Hash>> { + ) -> sp_blockchain::Result::Hash>> { with_client! { self, client, @@ -456,7 +456,7 @@ impl sc_client_api::StorageProvider for Client { fn storage_pairs( &self, - hash: ::Hash, + hash: ::Hash, key_prefix: Option<&StorageKey>, start_key: Option<&StorageKey>, ) -> sp_blockchain::Result< @@ -473,7 +473,7 @@ impl sc_client_api::StorageProvider for Client { fn storage_keys( &self, - hash: ::Hash, + hash: ::Hash, prefix: Option<&StorageKey>, start_key: Option<&StorageKey>, ) -> sp_blockchain::Result< @@ -490,7 +490,7 @@ impl sc_client_api::StorageProvider for Client { fn child_storage( &self, - hash: ::Hash, + hash: ::Hash, child_info: &ChildInfo, key: &StorageKey, ) -> sp_blockchain::Result> { @@ -505,7 +505,7 @@ impl sc_client_api::StorageProvider for Client { fn child_storage_keys( &self, - hash: ::Hash, + hash: ::Hash, child_info: ChildInfo, prefix: Option<&StorageKey>, start_key: Option<&StorageKey>, @@ -523,10 +523,10 @@ impl sc_client_api::StorageProvider for Client { fn child_storage_hash( &self, - hash: ::Hash, + hash: ::Hash, child_info: &ChildInfo, key: &StorageKey, - ) -> sp_blockchain::Result::Hash>> { + ) -> sp_blockchain::Result::Hash>> { with_client! { self, client, diff --git a/node/service/src/lib.rs b/node/service/src/lib.rs index c48ae9ea2ff5..70c267ef3b96 100644 --- a/node/service/src/lib.rs +++ b/node/service/src/lib.rs @@ -141,13 +141,13 @@ where /// Obtain the header for a hash. fn header( &self, - hash: ::Hash, - ) -> Result::Header>, Error>; + hash: ::Hash, + ) -> Result::Header>, Error>; /// Obtain the block number for a hash. fn number( &self, - hash: ::Hash, - ) -> Result::Header as HeaderT>::Number>, Error>; + hash: ::Hash, + ) -> Result::Header as HeaderT>::Number>, Error>; } impl HeaderProvider for T @@ -158,13 +158,13 @@ where fn header( &self, hash: Block::Hash, - ) -> sp_blockchain::Result::Header>> { + ) -> sp_blockchain::Result::Header>> { >::header(self, hash) } fn number( &self, hash: Block::Hash, - ) -> sp_blockchain::Result::Header as HeaderT>::Number>> { + ) -> sp_blockchain::Result::Header as HeaderT>::Number>> { >::number(self, hash) } } @@ -620,7 +620,7 @@ pub struct NewFull { pub task_manager: TaskManager, pub client: C, pub overseer_handle: Option, - pub network: Arc::Hash>>, + pub network: Arc::Hash>>, pub sync_service: Arc>, pub rpc_handlers: RpcHandlers, pub backend: Arc, diff --git a/node/test/client/src/block_builder.rs b/node/test/client/src/block_builder.rs index 33b01d018d04..fe2108036d64 100644 --- a/node/test/client/src/block_builder.rs +++ b/node/test/client/src/block_builder.rs @@ -42,7 +42,7 @@ pub trait InitPolkadotBlockBuilder { /// which should be the parent block of the block that is being build. fn init_polkadot_block_builder_at( &self, - hash: ::Hash, + hash: ::Hash, ) -> sc_block_builder::BlockBuilder; } @@ -54,7 +54,7 @@ impl InitPolkadotBlockBuilder for Client { fn init_polkadot_block_builder_at( &self, - hash: ::Hash, + hash: ::Hash, ) -> BlockBuilder { let last_timestamp = self.runtime_api().get_last_timestamp(hash).expect("Get last timestamp"); diff --git a/primitives/src/lib.rs b/primitives/src/lib.rs index 1c8ef1eae73b..31c16c9ccef1 100644 --- a/primitives/src/lib.rs +++ b/primitives/src/lib.rs @@ -43,7 +43,7 @@ pub use v5::{ CollatorId, CollatorSignature, CommittedCandidateReceipt, CompactStatement, ConsensusLog, CoreIndex, CoreOccupied, CoreState, DisputeState, DisputeStatement, DisputeStatementSet, DownwardMessage, EncodeAs, ExecutorParam, ExecutorParams, ExecutorParamsHash, - ExplicitDisputeStatement, GroupIndex, GroupRotationInfo, Hash, HashT, HeadData, Header, + ExplicitDisputeStatement, GroupIndex, GroupRotationInfo, Hash, HashT, HeadData, HrmpChannelId, Id, InboundDownwardMessage, InboundHrmpMessage, IndexedVec, InherentData, InvalidDisputeStatementKind, Moment, MultiDisputeStatementSet, Nonce, OccupiedCore, OccupiedCoreAssumption, OutboundHrmpMessage, ParathreadClaim, ParathreadEntry, diff --git a/roadmap/implementers-guide/src/runtime/configuration.md b/roadmap/implementers-guide/src/runtime/configuration.md index 96d63faccedd..9acfdaae2bc7 100644 --- a/roadmap/implementers-guide/src/runtime/configuration.md +++ b/roadmap/implementers-guide/src/runtime/configuration.md @@ -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, /// 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)) -> DispatchResult +fn schedule_config_update(updater: impl FnOnce(&mut HostConfiguration>)) -> DispatchResult ``` ## Entry-points diff --git a/roadmap/implementers-guide/src/runtime/paras.md b/roadmap/implementers-guide/src/runtime/paras.md index a9e99c8993bf..5a3bda69bd82 100644 --- a/roadmap/implementers-guide/src/runtime/paras.md +++ b/roadmap/implementers-guide/src/runtime/paras.md @@ -197,12 +197,12 @@ UpgradeRestrictionSignal: map hasher(twox_64_concat) ParaId => Option; +UpgradeCooldowns: Vec<(ParaId, frame_system::BlockNumberOf)>; /// 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. /// /// Ordered ascending by block number. -UpcomingUpgrades: Vec<(ParaId, T::BlockNumber)>; +UpcomingUpgrades: Vec<(ParaId, frame_system::BlockNumberOf)>; /// The actions to perform during the start of a specific session index. ActionsQueue: map SessionIndex => Vec; /// Upcoming paras instantiation arguments. diff --git a/rpc/src/lib.rs b/rpc/src/lib.rs index c08e28799c54..2f0ba95f247e 100644 --- a/rpc/src/lib.rs +++ b/rpc/src/lib.rs @@ -105,7 +105,7 @@ where + Sync + 'static, C::Api: frame_rpc_system::AccountNonceApi, - C::Api: mmr_rpc::MmrRuntimeApi::Hash, BlockNumber>, + C::Api: mmr_rpc::MmrRuntimeApi::Hash, BlockNumber>, C::Api: pallet_transaction_payment_rpc::TransactionPaymentRuntimeApi, C::Api: BabeApi, C::Api: BlockBuilder, diff --git a/runtime/common/src/assigned_slots.rs b/runtime/common/src/assigned_slots.rs index f2da950d0b16..891d095f2617 100644 --- a/runtime/common/src/assigned_slots.rs +++ b/runtime/common/src/assigned_slots.rs @@ -67,11 +67,11 @@ pub struct ParachainTemporarySlot { pub lease_count: u32, } -type BalanceOf = <<::Leaser as Leaser<::BlockNumber>>::Currency as Currency< +type BalanceOf = <<::Leaser as Leaser>>::Currency as Currency< ::AccountId, >>::Balance; type LeasePeriodOf = - <::Leaser as Leaser<::BlockNumber>>::LeasePeriod; + <::Leaser as Leaser>>::LeasePeriod; #[frame_support::pallet] pub mod pallet { @@ -91,9 +91,9 @@ pub mod pallet { /// The type representing the leasing system. type Leaser: Leaser< - Self::BlockNumber, + frame_system::BlockNumberOf, AccountId = Self::AccountId, - LeasePeriod = Self::BlockNumber, + LeasePeriod = frame_system::BlockNumberOf, >; /// The number of lease periods a permanent parachain slot lasts. @@ -182,7 +182,7 @@ pub mod pallet { #[pallet::hooks] impl Hooks> for Pallet { - fn on_initialize(n: T::BlockNumber) -> Weight { + fn on_initialize(n: frame_system::BlockNumberOf) -> 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 +213,14 @@ pub mod pallet { Error::::SlotAlreadyAssigned ); - let current_lease_period: T::BlockNumber = Self::current_lease_period_index(); + let current_lease_period: frame_system::BlockNumberOf = 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) + frame_system::BlockNumberOf::::from(2u32) .saturating_mul(T::PermanentSlotLeasePeriodLength::get().into()) ) ), @@ -276,14 +276,14 @@ pub mod pallet { Error::::SlotAlreadyAssigned ); - let current_lease_period: T::BlockNumber = Self::current_lease_period_index(); + let current_lease_period: frame_system::BlockNumberOf = 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) + frame_system::BlockNumberOf::::from(2u32) .saturating_mul(T::TemporarySlotLeasePeriodLength::get().into()) ) ), @@ -548,7 +548,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, @@ -561,13 +561,10 @@ mod tests { }; type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic; - type Block = frame_system::mocking::MockBlock; + type Block = frame_system::mocking::MockBlockU32; frame_support::construct_runtime!( - pub enum Test where - Block = Block, - NodeBlock = Block, - UncheckedExtrinsic = UncheckedExtrinsic, + pub enum Test { System: frame_system::{Pallet, Call, Config, Storage, Event}, Balances: pallet_balances::{Pallet, Call, Storage, Config, Event}, @@ -597,12 +594,11 @@ 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; - type Header = Header; + type Block = Block; type RuntimeEvent = RuntimeEvent; type BlockHashCount = BlockHashCount; type DbWeight = (); diff --git a/runtime/common/src/auctions.rs b/runtime/common/src/auctions.rs index 05ef6ad59bf0..bb0c67cab972 100644 --- a/runtime/common/src/auctions.rs +++ b/runtime/common/src/auctions.rs @@ -35,8 +35,8 @@ use sp_runtime::traits::{CheckedSub, One, Saturating, Zero}; use sp_std::{mem::swap, prelude::*}; type CurrencyOf = - <::Leaser as Leaser<::BlockNumber>>::Currency; -type BalanceOf = <<::Leaser as Leaser<::BlockNumber>>::Currency as Currency< + <::Leaser as Leaser>>::Currency; +type BalanceOf = <<::Leaser as Leaser>>::Currency as Currency< ::AccountId, >>::Balance; @@ -67,7 +67,7 @@ impl WeightInfo for TestWeightInfo { pub type AuctionIndex = u32; type LeasePeriodOf = - <::Leaser as Leaser<::BlockNumber>>::LeasePeriod; + <::Leaser as Leaser>>::LeasePeriod; // Winning data type. This encodes the top bidders of each range together with their bid. type WinningData = [Option<(::AccountId, ParaId, BalanceOf)>; @@ -94,9 +94,9 @@ pub mod pallet { /// The type representing the leasing system. type Leaser: Leaser< - Self::BlockNumber, + frame_system::BlockNumberOf, AccountId = Self::AccountId, - LeasePeriod = Self::BlockNumber, + LeasePeriod = frame_system::BlockNumberOf, >; /// The parachain registrar type. @@ -104,16 +104,16 @@ pub mod pallet { /// The number of blocks over which an auction may be retroactively ended. #[pallet::constant] - type EndingPeriod: Get; + type EndingPeriod: Get>; /// The length of each sample to take during the ending period. /// /// `EndingPeriod` / `SampleLength` = Total # of Samples #[pallet::constant] - type SampleLength: Get; + type SampleLength: Get>; /// Something that provides randomness in the runtime. - type Randomness: Randomness; + type Randomness: Randomness>; /// The origin which may initiate auctions. type InitiateOrigin: EnsureOrigin; @@ -130,7 +130,7 @@ pub mod pallet { AuctionStarted { auction_index: AuctionIndex, lease_period: LeasePeriodOf, - ending: T::BlockNumber, + ending: frame_system::BlockNumberOf, }, /// An auction ended. All funds become unreserved. AuctionClosed { auction_index: AuctionIndex }, @@ -151,7 +151,7 @@ pub mod pallet { last_slot: LeasePeriodOf, }, /// 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: frame_system::BlockNumberOf }, } #[pallet::error] @@ -184,7 +184,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 = StorageValue<_, (LeasePeriodOf, T::BlockNumber)>; + pub type AuctionInfo = StorageValue<_, (LeasePeriodOf, frame_system::BlockNumberOf)>; /// Amounts currently reserved in the accounts of the bidders currently winning /// (sub-)ranges. @@ -198,7 +198,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 = StorageMap<_, Twox64Concat, T::BlockNumber, WinningData>; + pub type Winning = StorageMap<_, Twox64Concat, frame_system::BlockNumberOf, WinningData>; #[pallet::extra_constants] impl Pallet { @@ -215,7 +215,7 @@ pub mod pallet { #[pallet::hooks] impl Hooks> for Pallet { - fn on_initialize(n: T::BlockNumber) -> Weight { + fn on_initialize(n: frame_system::BlockNumberOf) -> 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 +256,7 @@ pub mod pallet { #[pallet::weight((T::WeightInfo::new_auction(), DispatchClass::Operational))] pub fn new_auction( origin: OriginFor, - #[pallet::compact] duration: T::BlockNumber, + #[pallet::compact] duration: frame_system::BlockNumberOf, #[pallet::compact] lease_period_index: LeasePeriodOf, ) -> DispatchResult { T::InitiateOrigin::ensure_origin(origin)?; @@ -313,20 +313,20 @@ pub mod pallet { } } -impl Auctioneer for Pallet { +impl Auctioneer> for Pallet { type AccountId = T::AccountId; - type LeasePeriod = T::BlockNumber; + type LeasePeriod = frame_system::BlockNumberOf; type Currency = CurrencyOf; fn new_auction( - duration: T::BlockNumber, + duration: frame_system::BlockNumberOf, lease_period_index: LeasePeriodOf, ) -> 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 { + fn auction_status(now: frame_system::BlockNumberOf) -> AuctionStatus> { let early_end = match AuctionInfo::::get() { Some((_, early_end)) => early_end, None => return AuctionStatus::NotStarted, @@ -359,12 +359,12 @@ impl Auctioneer for Pallet { Self::handle_bid(bidder, para, AuctionCounter::::get(), first_slot, last_slot, amount) } - fn lease_period_index(b: T::BlockNumber) -> Option<(Self::LeasePeriod, bool)> { + fn lease_period_index(b: frame_system::BlockNumberOf) -> 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() -> (frame_system::BlockNumberOf, frame_system::BlockNumberOf) { T::Leaser::lease_period_length() } @@ -383,7 +383,7 @@ impl Pallet { /// 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: frame_system::BlockNumberOf, lease_period_index: LeasePeriodOf, ) -> DispatchResult { let maybe_auction = AuctionInfo::::get(); @@ -530,7 +530,7 @@ impl Pallet { /// /// 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, LeasePeriodOf)> { + fn check_auction_end(now: frame_system::BlockNumberOf) -> Option<(WinningData, LeasePeriodOf)> { if let Some((lease_period_index, early_end)) = AuctionInfo::::get() { let ending_period = T::EndingPeriod::get(); let late_end = early_end.saturating_add(ending_period); @@ -542,7 +542,7 @@ impl Pallet { if late_end <= known_since { // Our random seed was known only after the auction ended. Good to use. - let raw_offset_block_number = ::decode( + let raw_offset_block_number = >::decode( &mut raw_offset.as_ref(), ) .expect("secure hashes should always be bigger than the block number; qed"); @@ -683,19 +683,15 @@ 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}; use std::{cell::RefCell, collections::BTreeMap}; - type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic; - type Block = frame_system::mocking::MockBlock; + type Block = frame_system::mocking::MockBlockU32; frame_support::construct_runtime!( - pub enum Test where - Block = Block, - NodeBlock = Block, - UncheckedExtrinsic = UncheckedExtrinsic, + pub enum Test { System: frame_system::{Pallet, Call, Config, Storage, Event}, Balances: pallet_balances::{Pallet, Call, Storage, Config, Event}, @@ -714,12 +710,11 @@ 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; - type Header = Header; + type Block = Block; type RuntimeEvent = RuntimeEvent; type BlockHashCount = BlockHashCount; type Version = (); @@ -1797,7 +1792,7 @@ mod benchmarking { where_clause { where T: pallet_babe::Config + paras::Config } new_auction { - let duration = T::BlockNumber::max_value(); + let duration = frame_system::BlockNumberOf::::max_value(); let lease_period_index = LeasePeriodOf::::max_value(); let origin = T::InitiateOrigin::try_successful_origin().map_err(|_| BenchmarkError::Weightless)?; @@ -1806,7 +1801,7 @@ mod benchmarking { assert_last_event::(Event::::AuctionStarted { auction_index: AuctionCounter::::get(), lease_period: LeasePeriodOf::::max_value(), - ending: T::BlockNumber::max_value(), + ending: frame_system::BlockNumberOf::::max_value(), }.into()); } @@ -1817,7 +1812,7 @@ mod benchmarking { frame_system::Pallet::::set_block_number(offset + One::one()); // Create a new auction - let duration = T::BlockNumber::max_value(); + let duration = frame_system::BlockNumberOf::::max_value(); let lease_period_index = LeasePeriodOf::::zero(); let origin = T::InitiateOrigin::try_successful_origin() .expect("InitiateOrigin has no successful origin required for the benchmark"); @@ -1874,7 +1869,7 @@ mod benchmarking { frame_system::Pallet::::set_block_number(offset + One::one()); // Create a new auction - let duration: T::BlockNumber = lease_length / 2u32.into(); + let duration: frame_system::BlockNumberOf = lease_length / 2u32.into(); let lease_period_index = LeasePeriodOf::::zero(); let now = frame_system::Pallet::::block_number(); let origin = T::InitiateOrigin::try_successful_origin() @@ -1883,14 +1878,14 @@ mod benchmarking { fill_winners::(lease_period_index); - for winner in Winning::::get(T::BlockNumber::from(0u32)).unwrap().iter() { + for winner in Winning::::get(frame_system::BlockNumberOf::::from(0u32)).unwrap().iter() { assert!(winner.is_some()); } - let winning_data = Winning::::get(T::BlockNumber::from(0u32)).unwrap(); + let winning_data = Winning::::get(frame_system::BlockNumberOf::::from(0u32)).unwrap(); // Make winning map full for i in 0u32 .. (T::EndingPeriod::get() / T::SampleLength::get()).saturated_into() { - Winning::::insert(T::BlockNumber::from(i), winning_data.clone()); + Winning::::insert(frame_system::BlockNumberOf::::from(i), winning_data.clone()); } // Move ahead to the block we want to initialize @@ -1919,7 +1914,7 @@ mod benchmarking { frame_system::Pallet::::set_block_number(offset + One::one()); // Create a new auction - let duration: T::BlockNumber = lease_length / 2u32.into(); + let duration: frame_system::BlockNumberOf = lease_length / 2u32.into(); let lease_period_index = LeasePeriodOf::::zero(); let now = frame_system::Pallet::::block_number(); let origin = T::InitiateOrigin::try_successful_origin() @@ -1928,14 +1923,14 @@ mod benchmarking { fill_winners::(lease_period_index); - let winning_data = Winning::::get(T::BlockNumber::from(0u32)).unwrap(); + let winning_data = Winning::::get(frame_system::BlockNumberOf::::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::::insert(T::BlockNumber::from(i), winning_data.clone()); + Winning::::insert(frame_system::BlockNumberOf::::from(i), winning_data.clone()); } assert!(AuctionInfo::::get().is_some()); }: _(RawOrigin::Root) diff --git a/runtime/common/src/claims.rs b/runtime/common/src/claims.rs index 9715bad556a1..cc9eac7447ca 100644 --- a/runtime/common/src/claims.rs +++ b/runtime/common/src/claims.rs @@ -171,7 +171,7 @@ pub mod pallet { pub trait Config: frame_system::Config { /// The overarching event type. type RuntimeEvent: From> + IsType<::RuntimeEvent>; - type VestingSchedule: VestingSchedule; + type VestingSchedule: VestingSchedule>; #[pallet::constant] type Prefix: Get<&'static [u8]>; type MoveClaimOrigin: EnsureOrigin; @@ -217,7 +217,7 @@ pub mod pallet { #[pallet::storage] #[pallet::getter(fn vesting)] pub(super) type Vesting = - StorageMap<_, Identity, EthereumAddress, (BalanceOf, BalanceOf, T::BlockNumber)>; + StorageMap<_, Identity, EthereumAddress, (BalanceOf, BalanceOf, frame_system::BlockNumberOf)>; /// The statement kind that must be signed, if any. #[pallet::storage] @@ -232,7 +232,7 @@ pub mod pallet { pub struct GenesisConfig { pub claims: Vec<(EthereumAddress, BalanceOf, Option, Option)>, - pub vesting: Vec<(EthereumAddress, (BalanceOf, BalanceOf, T::BlockNumber))>, + pub vesting: Vec<(EthereumAddress, (BalanceOf, BalanceOf, frame_system::BlockNumberOf))>, } #[pallet::genesis_build] @@ -336,7 +336,7 @@ pub mod pallet { origin: OriginFor, who: EthereumAddress, value: BalanceOf, - vesting_schedule: Option<(BalanceOf, BalanceOf, T::BlockNumber)>, + vesting_schedule: Option<(BalanceOf, BalanceOf, frame_system::BlockNumberOf)>, statement: Option, ) -> 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, TokenError, }; - type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic; type Block = frame_system::mocking::MockBlock; frame_support::construct_runtime!( - pub enum Test where - Block = Block, - NodeBlock = Block, - UncheckedExtrinsic = UncheckedExtrinsic, + pub enum Test { System: frame_system::{Pallet, Call, Config, Storage, Event}, Balances: pallet_balances::{Pallet, Call, Storage, Config, Event}, @@ -737,7 +732,7 @@ mod tests { ); parameter_types! { - pub const BlockHashCount: u32 = 250; + pub const BlockHashCount: u64 = 250; } impl frame_system::Config for Test { type BaseCallFilter = frame_support::traits::Everything; @@ -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; - type Header = Header; + type Block = Block; type RuntimeEvent = RuntimeEvent; type BlockHashCount = BlockHashCount; type Version = (); diff --git a/runtime/common/src/crowdloan/mod.rs b/runtime/common/src/crowdloan/mod.rs index 6be608756669..eb8c5e6af868 100644 --- a/runtime/common/src/crowdloan/mod.rs +++ b/runtime/common/src/crowdloan/mod.rs @@ -79,9 +79,9 @@ use sp_runtime::{ use sp_std::vec::Vec; type CurrencyOf = - <::Auctioneer as Auctioneer<::BlockNumber>>::Currency; + <::Auctioneer as Auctioneer>>::Currency; type LeasePeriodOf = <::Auctioneer as Auctioneer< - ::BlockNumber, + frame_system::BlockNumberOf, >>::LeasePeriod; type BalanceOf = as Currency<::AccountId>>::Balance; @@ -216,9 +216,9 @@ pub mod pallet { /// The type representing the auctioning system. type Auctioneer: Auctioneer< - Self::BlockNumber, + frame_system::BlockNumberOf, AccountId = Self::AccountId, - LeasePeriod = Self::BlockNumber, + LeasePeriod = frame_system::BlockNumberOf, >; /// The maximum length for the memo attached to a crowdloan contribution. @@ -235,7 +235,7 @@ pub mod pallet { _, Twox64Concat, ParaId, - FundInfo, T::BlockNumber, LeasePeriodOf>, + FundInfo, frame_system::BlockNumberOf, LeasePeriodOf>, >; /// The funds that have had additional contributions during the last block. This is used @@ -332,7 +332,7 @@ pub mod pallet { #[pallet::hooks] impl Hooks> for Pallet { - fn on_initialize(num: T::BlockNumber) -> frame_support::weights::Weight { + fn on_initialize(num: frame_system::BlockNumberOf) -> 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 +377,7 @@ pub mod pallet { #[pallet::compact] cap: BalanceOf, #[pallet::compact] first_period: LeasePeriodOf, #[pallet::compact] last_period: LeasePeriodOf, - #[pallet::compact] end: T::BlockNumber, + #[pallet::compact] end: frame_system::BlockNumberOf, verifier: Option, ) -> DispatchResult { let depositor = ensure_signed(origin)?; @@ -594,7 +594,7 @@ pub mod pallet { #[pallet::compact] cap: BalanceOf, #[pallet::compact] first_period: LeasePeriodOf, #[pallet::compact] last_period: LeasePeriodOf, - #[pallet::compact] end: T::BlockNumber, + #[pallet::compact] end: frame_system::BlockNumberOf, verifier: Option, ) -> DispatchResult { ensure_root(origin)?; @@ -725,9 +725,9 @@ impl Pallet { /// 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: frame_system::BlockNumberOf, fund_account: &T::AccountId, - fund: &FundInfo, T::BlockNumber, LeasePeriodOf>, + fund: &FundInfo, frame_system::BlockNumberOf, LeasePeriodOf>, ) -> 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 +878,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}, DispatchResult, }; - type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic; type Block = frame_system::mocking::MockBlock; frame_support::construct_runtime!( - pub enum Test where - Block = Block, - NodeBlock = Block, - UncheckedExtrinsic = UncheckedExtrinsic, + pub enum Test { System: frame_system::{Pallet, Call, Config, Storage, Event}, Balances: pallet_balances::{Pallet, Call, Storage, Config, Event}, @@ -912,12 +907,11 @@ 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; - type Header = Header; + type Block = Block; type RuntimeEvent = RuntimeEvent; type BlockHashCount = BlockHashCount; type Version = (); @@ -1968,7 +1962,7 @@ mod benchmarking { assert_eq!(event, &system_event); } - fn create_fund(id: u32, end: T::BlockNumber) -> ParaId { + fn create_fund(id: u32, end: frame_system::BlockNumberOf) -> ParaId { let cap = BalanceOf::::max_value(); let (_, offset) = T::Auctioneer::lease_period_length(); // Set to the very beginning of lease period index 0. @@ -2088,7 +2082,7 @@ mod benchmarking { let caller: T::AccountId = whitelisted_caller(); let contributor = account("contributor", 0, 0); contribute_fund::(&contributor, fund_index); - frame_system::Pallet::::set_block_number(T::BlockNumber::max_value()); + frame_system::Pallet::::set_block_number(frame_system::BlockNumberOf::::max_value()); }: _(RawOrigin::Signed(caller), contributor.clone(), fund_index) verify { assert_last_event::(Event::::Withdrew { who: contributor, fund_index, amount: T::MinContribution::get() }.into()); @@ -2108,7 +2102,7 @@ mod benchmarking { } let caller: T::AccountId = whitelisted_caller(); - frame_system::Pallet::::set_block_number(T::BlockNumber::max_value()); + frame_system::Pallet::::set_block_number(frame_system::BlockNumberOf::::max_value()); }: _(RawOrigin::Signed(caller), fund_index) verify { assert_last_event::(Event::::AllRefunded { para_id: fund_index }.into()); @@ -2119,7 +2113,7 @@ mod benchmarking { let end = lpl + offset; let fund_index = create_fund::(1337, end); let caller: T::AccountId = whitelisted_caller(); - frame_system::Pallet::::set_block_number(T::BlockNumber::max_value()); + frame_system::Pallet::::set_block_number(frame_system::BlockNumberOf::::max_value()); }: _(RawOrigin::Signed(caller.clone()), fund_index) verify { assert_last_event::(Event::::Dissolved { para_id: fund_index }.into()); diff --git a/runtime/common/src/impls.rs b/runtime/common/src/impls.rs index b827b8c34103..5ea6e0468423 100644 --- a/runtime/common/src/impls.rs +++ b/runtime/common/src/impls.rs @@ -112,20 +112,15 @@ mod tests { use primitives::AccountId; use sp_core::{ConstU64, H256}; use sp_runtime::{ - testing::Header, traits::{BlakeTwo256, IdentityLookup}, Perbill, }; - type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic; - type Block = frame_system::mocking::MockBlock; + type Block = frame_system::mocking::MockBlockU32; 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, Storage, Event}, Authorship: pallet_authorship::{Pallet, Storage}, @@ -135,7 +130,7 @@ mod tests { ); parameter_types! { - pub const BlockHashCount: u64 = 250; + pub const BlockHashCount: u32 = 250; pub BlockWeights: limits::BlockWeights = limits::BlockWeights::builder() .base_block(Weight::from_parts(10, 0)) .for_class(DispatchClass::all(), |weight| { @@ -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; - type Header = Header; + type Block = Block; type RuntimeEvent = RuntimeEvent; type BlockHashCount = BlockHashCount; type BlockLength = BlockLength; diff --git a/runtime/common/src/integration_tests.rs b/runtime/common/src/integration_tests.rs index cf879e6bb182..0a05a5b9b4cc 100644 --- a/runtime/common/src/integration_tests.rs +++ b/runtime/common/src/integration_tests.rs @@ -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; -type Block = frame_system::mocking::MockBlock; +type Block = frame_system::mocking::MockBlockU32; 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, Storage, Event}, @@ -120,12 +117,11 @@ 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; - type Header = Header; + type Block = Block; type RuntimeEvent = RuntimeEvent; type BlockHashCount = BlockHashCount; type Version = (); diff --git a/runtime/common/src/mock.rs b/runtime/common/src/mock.rs index 06cc7771dede..6a5cf05e24db 100644 --- a/runtime/common/src/mock.rs +++ b/runtime/common/src/mock.rs @@ -192,7 +192,7 @@ impl Registrar for TestRegistrar { } impl TestRegistrar { - pub fn operations() -> Vec<(ParaId, T::BlockNumber, bool)> { + pub fn operations() -> Vec<(ParaId, frame_system::BlockNumberOf, bool)> { OPERATIONS .with(|x| x.borrow().iter().map(|(p, b, c)| (*p, (*b).into(), *c)).collect::>()) } diff --git a/runtime/common/src/paras_registrar.rs b/runtime/common/src/paras_registrar.rs index 284decff46a5..5a0300747d42 100644 --- a/runtime/common/src/paras_registrar.rs +++ b/runtime/common/src/paras_registrar.rs @@ -665,7 +665,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; @@ -678,13 +678,10 @@ mod tests { use sp_std::collections::btree_map::BTreeMap; type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic; - type Block = frame_system::mocking::MockBlock; + type Block = frame_system::mocking::MockBlockU32; frame_support::construct_runtime!( - pub enum Test where - Block = Block, - NodeBlock = Block, - UncheckedExtrinsic = UncheckedExtrinsic, + pub enum Test { System: frame_system::{Pallet, Call, Config, Storage, Event}, Balances: pallet_balances::{Pallet, Call, Storage, Config, Event}, @@ -718,12 +715,11 @@ 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; - type Header = Header; + type Block = Block; type RuntimeEvent = RuntimeEvent; type BlockHashCount = BlockHashCount; type DbWeight = (); diff --git a/runtime/common/src/purchase.rs b/runtime/common/src/purchase.rs index e2864b262779..03740332e7b3 100644 --- a/runtime/common/src/purchase.rs +++ b/runtime/common/src/purchase.rs @@ -105,7 +105,7 @@ pub mod pallet { /// Vesting Pallet type VestingSchedule: VestingSchedule< Self::AccountId, - Moment = Self::BlockNumber, + Moment = frame_system::BlockNumberOf, 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: frame_system::BlockNumberOf }, } #[pallet::error] @@ -182,7 +182,7 @@ pub mod pallet { // The block where all locked dots will unlock. #[pallet::storage] - pub(super) type UnlockBlock = StorageValue<_, T::BlockNumber, ValueQuery>; + pub(super) type UnlockBlock = StorageValue<_, frame_system::BlockNumberOf, ValueQuery>; #[pallet::hooks] impl Hooks> for Pallet {} @@ -403,7 +403,7 @@ pub mod pallet { #[pallet::weight(T::DbWeight::get().writes(1))] pub fn set_unlock_block( origin: OriginFor, - unlock_block: T::BlockNumber, + unlock_block: frame_system::BlockNumberOf, ) -> 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, MultiSignature, }; - type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic; type Block = frame_system::mocking::MockBlock; frame_support::construct_runtime!( - pub enum Test where - Block = Block, - NodeBlock = Block, - UncheckedExtrinsic = UncheckedExtrinsic, + pub enum Test { System: frame_system::{Pallet, Call, Config, Storage, Event}, Balances: pallet_balances::{Pallet, Call, Storage, Config, Event}, @@ -510,7 +505,7 @@ mod tests { type AccountId = AccountId32; parameter_types! { - pub const BlockHashCount: u32 = 250; + pub const BlockHashCount: u64 = 250; } impl frame_system::Config for Test { type BaseCallFilter = frame_support::traits::Everything; @@ -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; - type Header = Header; + type Block = Block; type RuntimeEvent = RuntimeEvent; type BlockHashCount = BlockHashCount; type Version = (); diff --git a/runtime/common/src/slots/mod.rs b/runtime/common/src/slots/mod.rs index 202062fd7ce9..6928f548f5db 100644 --- a/runtime/common/src/slots/mod.rs +++ b/runtime/common/src/slots/mod.rs @@ -37,7 +37,7 @@ use sp_std::prelude::*; type BalanceOf = <::Currency as Currency<::AccountId>>::Balance; -type LeasePeriodOf = ::BlockNumber; +type LeasePeriodOf = frame_system::BlockNumberOf; 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; + type LeasePeriod: Get>; /// The number of blocks to offset each lease period by. #[pallet::constant] - type LeaseOffset: Get; + type LeaseOffset: Get>; /// The origin which may forcibly create or clear leases. Root can always do this. type ForceOrigin: EnsureOrigin<::RuntimeOrigin>; @@ -145,7 +145,7 @@ pub mod pallet { #[pallet::hooks] impl Hooks> for Pallet { - fn on_initialize(n: T::BlockNumber) -> Weight { + fn on_initialize(n: frame_system::BlockNumberOf) -> 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 crate::traits::OnSwap for Pallet { } } -impl Leaser for Pallet { +impl Leaser> for Pallet { type AccountId = T::AccountId; - type LeasePeriod = T::BlockNumber; + type LeasePeriod = frame_system::BlockNumberOf; type Currency = T::Currency; fn lease_out( @@ -442,11 +442,11 @@ impl Leaser for Pallet { } #[cfg(any(feature = "runtime-benchmarks", test))] - fn lease_period_length() -> (T::BlockNumber, T::BlockNumber) { + fn lease_period_length() -> (frame_system::BlockNumberOf, frame_system::BlockNumberOf) { (T::LeasePeriod::get(), T::LeaseOffset::get()) } - fn lease_period_index(b: T::BlockNumber) -> Option<(Self::LeasePeriod, bool)> { + fn lease_period_index(b: frame_system::BlockNumberOf) -> 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,18 +505,14 @@ 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}; - type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic; - type Block = frame_system::mocking::MockBlock; + type Block = frame_system::mocking::MockBlockU32; frame_support::construct_runtime!( - pub enum Test where - Block = Block, - NodeBlock = Block, - UncheckedExtrinsic = UncheckedExtrinsic, + pub enum Test { System: frame_system::{Pallet, Call, Config, Storage, Event}, Balances: pallet_balances::{Pallet, Call, Storage, Config, Event}, @@ -534,12 +530,11 @@ 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; - type Header = Header; + type Block = Block; type RuntimeEvent = RuntimeEvent; type BlockHashCount = BlockHashCount; type DbWeight = (); diff --git a/runtime/common/src/xcm_sender.rs b/runtime/common/src/xcm_sender.rs index 3654c44010e9..ef94272f0fd0 100644 --- a/runtime/common/src/xcm_sender.rs +++ b/runtime/common/src/xcm_sender.rs @@ -72,12 +72,12 @@ pub struct ChildParachainRouter(PhantomData<(T, W, P)>); impl SendXcm for ChildParachainRouter { - type Ticket = (HostConfiguration, ParaId, Vec); + type Ticket = (HostConfiguration>, ParaId, Vec); fn validate( dest: &mut Option, msg: &mut Option>, - ) -> SendResult<(HostConfiguration, ParaId, Vec)> { + ) -> SendResult<(HostConfiguration>, ParaId, Vec)> { let d = dest.take().ok_or(MissingArgument)?; let id = if let MultiLocation { parents: 0, interior: X1(Parachain(id)) } = &d { *id @@ -99,7 +99,7 @@ impl, ParaId, Vec), + (config, para, blob): (HostConfiguration>, ParaId, Vec), ) -> Result { let hash = sp_io::hashing::blake2_256(&blob[..]); >::queue_downward_message(&config, para, blob) diff --git a/runtime/kusama/src/lib.rs b/runtime/kusama/src/lib.rs index 88d6b613f92f..5349e8c6bf91 100644 --- a/runtime/kusama/src/lib.rs +++ b/runtime/kusama/src/lib.rs @@ -176,12 +176,11 @@ impl frame_system::Config for Runtime { type RuntimeOrigin = RuntimeOrigin; type RuntimeCall = RuntimeCall; type Index = Nonce; - type BlockNumber = BlockNumber; type Hash = Hash; type Hashing = BlakeTwo256; type AccountId = AccountId; type Lookup = AccountIdLookup; - type Header = generic::Header; + type Block = Block; type RuntimeEvent = RuntimeEvent; type BlockHashCount = BlockHashCount; type DbWeight = RocksDbWeight; @@ -1340,10 +1339,7 @@ impl pallet_nomination_pools::Config for Runtime { } construct_runtime! { - pub enum Runtime where - Block = Block, - NodeBlock = primitives::Block, - UncheckedExtrinsic = UncheckedExtrinsic + pub enum Runtime { // Basic stuff; balances is uncallable initially. System: frame_system::{Pallet, Call, Storage, Config, Event} = 0, @@ -1663,7 +1659,7 @@ sp_api::impl_runtime_apis! { Executive::execute_block(block); } - fn initialize_block(header: &::Header) { + fn initialize_block(header: &::Header) { Executive::initialize_block(header) } } @@ -1687,7 +1683,7 @@ sp_api::impl_runtime_apis! { Executive::apply_extrinsic(extrinsic) } - fn finalize_block() -> ::Header { + fn finalize_block() -> ::Header { Executive::finalize_block() } @@ -1707,14 +1703,14 @@ sp_api::impl_runtime_apis! { fn validate_transaction( source: TransactionSource, tx: ::Extrinsic, - block_hash: ::Hash, + block_hash: ::Hash, ) -> TransactionValidity { Executive::validate_transaction(source, tx, block_hash) } } impl offchain_primitives::OffchainWorkerApi for Runtime { - fn offchain_worker(header: &::Header) { + fn offchain_worker(header: &::Header) { Executive::offchain_worker(header) } } @@ -1923,7 +1919,7 @@ sp_api::impl_runtime_apis! { fn submit_report_equivocation_unsigned_extrinsic( equivocation_proof: fg_primitives::EquivocationProof< - ::Hash, + ::Hash, sp_runtime::traits::NumberFor, >, key_owner_proof: fg_primitives::OpaqueKeyOwnershipProof, @@ -1985,7 +1981,7 @@ sp_api::impl_runtime_apis! { } fn submit_report_equivocation_unsigned_extrinsic( - equivocation_proof: babe_primitives::EquivocationProof<::Header>, + equivocation_proof: babe_primitives::EquivocationProof<::Header>, key_owner_proof: babe_primitives::OpaqueKeyOwnershipProof, ) -> Option<()> { let key_owner_proof = key_owner_proof.decode()?; diff --git a/runtime/parachains/src/builder.rs b/runtime/parachains/src/builder.rs index f9908e30ad03..0731ae87a52b 100644 --- a/runtime/parachains/src/builder.rs +++ b/runtime/parachains/src/builder.rs @@ -69,7 +69,7 @@ pub(crate) struct BenchBuilder { /// Active validators. Validators should be declared prior to all other setup. validators: Option>, /// Starting block number; we expect it to get incremented on session setup. - block_number: T::BlockNumber, + block_number: frame_system::BlockNumberOf, /// Starting session; we expect it to get incremented on session setup. session: SessionIndex, /// Session we want the scenario to take place in. We will roll to this session. @@ -97,9 +97,9 @@ pub(crate) struct BenchBuilder { /// Paras inherent `enter` benchmark scenario. #[cfg(any(feature = "runtime-benchmarks", test))] pub(crate) struct Bench { - pub(crate) data: ParachainsInherentData, + pub(crate) data: ParachainsInherentData>, pub(crate) _session: u32, - pub(crate) _block_number: T::BlockNumber, + pub(crate) _block_number: frame_system::BlockNumberOf, } impl BenchBuilder { @@ -150,8 +150,8 @@ impl BenchBuilder { } /// Mock header. - pub(crate) fn header(block_number: T::BlockNumber) -> T::Header { - T::Header::new( + pub(crate) fn header(block_number: frame_system::BlockNumberOf) -> frame_system::HeaderOf { + frame_system::HeaderOf::::new( block_number, // `block_number`, Default::default(), // `extrinsics_root`, Default::default(), // `storage_root`, @@ -260,8 +260,8 @@ impl BenchBuilder { core_idx: CoreIndex, candidate_hash: CandidateHash, availability_votes: BitVec, - ) -> inclusion::CandidatePendingAvailability { - inclusion::CandidatePendingAvailability::::new( + ) -> inclusion::CandidatePendingAvailability> { + inclusion::CandidatePendingAvailability::>::new( core_idx, // core candidate_hash, // hash Self::candidate_descriptor_mock(), // candidate descriptor @@ -405,7 +405,7 @@ impl BenchBuilder { Self::run_to_block(block); } - let block_number = ::BlockNumber::from(block); + let block_number = frame_system::BlockNumberOf::::from(block); let header = Self::header(block_number.clone()); frame_system::Pallet::::reset_events(); @@ -523,7 +523,7 @@ impl BenchBuilder { // candidate receipt. paras::Pallet::::heads_insert(¶_id, head_data.clone()); - let mut past_code_meta = paras::ParaPastCodeMeta::::default(); + let mut past_code_meta = paras::ParaPastCodeMeta::>::default(); past_code_meta.note_replacement(0u32.into(), 0u32.into()); let group_validators = scheduler::Pallet::::group_validators(group_idx).unwrap(); diff --git a/runtime/parachains/src/configuration.rs b/runtime/parachains/src/configuration.rs index 5317c18f8962..6dc3d57b7112 100644 --- a/runtime/parachains/src/configuration.rs +++ b/runtime/parachains/src/configuration.rs @@ -510,7 +510,7 @@ pub mod pallet { #[pallet::storage] #[pallet::getter(fn config)] pub(crate) type ActiveConfig = - StorageValue<_, HostConfiguration, ValueQuery>; + StorageValue<_, HostConfiguration>, ValueQuery>; /// Pending configuration changes. /// @@ -521,7 +521,7 @@ pub mod pallet { /// 2 items: for the next session and for the `scheduled_session`. #[pallet::storage] pub(crate) type PendingConfigs = - StorageValue<_, Vec<(SessionIndex, HostConfiguration)>, ValueQuery>; + StorageValue<_, Vec<(SessionIndex, HostConfiguration>)>, ValueQuery>; /// If this is set, then the configuration setters will bypass the consistency checks. This /// is meant to be used only as the last resort. @@ -531,7 +531,7 @@ pub mod pallet { #[pallet::genesis_config] #[derive(DefaultNoBound)] pub struct GenesisConfig { - pub config: HostConfiguration, + pub config: HostConfiguration>, } #[pallet::genesis_build] @@ -552,7 +552,7 @@ pub mod pallet { ))] pub fn set_validation_upgrade_cooldown( origin: OriginFor, - new: T::BlockNumber, + new: frame_system::BlockNumberOf, ) -> DispatchResult { ensure_root(origin)?; Self::schedule_config_update(|config| { @@ -568,7 +568,7 @@ pub mod pallet { ))] pub fn set_validation_upgrade_delay( origin: OriginFor, - new: T::BlockNumber, + new: frame_system::BlockNumberOf, ) -> DispatchResult { ensure_root(origin)?; Self::schedule_config_update(|config| { @@ -584,7 +584,7 @@ pub mod pallet { ))] pub fn set_code_retention_period( origin: OriginFor, - new: T::BlockNumber, + new: frame_system::BlockNumberOf, ) -> DispatchResult { ensure_root(origin)?; Self::schedule_config_update(|config| { @@ -665,7 +665,7 @@ pub mod pallet { ))] pub fn set_group_rotation_frequency( origin: OriginFor, - new: T::BlockNumber, + new: frame_system::BlockNumberOf, ) -> DispatchResult { ensure_root(origin)?; Self::schedule_config_update(|config| { @@ -681,7 +681,7 @@ pub mod pallet { ))] pub fn set_chain_availability_period( origin: OriginFor, - new: T::BlockNumber, + new: frame_system::BlockNumberOf, ) -> DispatchResult { ensure_root(origin)?; Self::schedule_config_update(|config| { @@ -697,7 +697,7 @@ pub mod pallet { ))] pub fn set_thread_availability_period( origin: OriginFor, - new: T::BlockNumber, + new: frame_system::BlockNumberOf, ) -> DispatchResult { ensure_root(origin)?; Self::schedule_config_update(|config| { @@ -768,7 +768,7 @@ pub mod pallet { ))] pub fn set_dispute_post_conclusion_acceptance_period( origin: OriginFor, - new: T::BlockNumber, + new: frame_system::BlockNumberOf, ) -> DispatchResult { ensure_root(origin)?; Self::schedule_config_update(|config| { @@ -1108,7 +1108,7 @@ pub mod pallet { ))] pub fn set_minimum_validation_upgrade_delay( origin: OriginFor, - new: T::BlockNumber, + new: frame_system::BlockNumberOf, ) -> DispatchResult { ensure_root(origin)?; Self::schedule_config_update(|config| { @@ -1183,7 +1183,7 @@ pub struct SessionChangeOutcome { impl 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: frame_system::BlockNumberOf) -> Weight { Weight::zero() } @@ -1197,7 +1197,7 @@ impl Pallet { /// be the same. pub(crate) fn initializer_on_new_session( session_index: &SessionIndex, - ) -> SessionChangeOutcome { + ) -> SessionChangeOutcome> { let pending_configs = >::get(); let prev_config = ActiveConfig::::get(); @@ -1238,7 +1238,7 @@ impl Pallet { /// 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 /// been running without them. - pub fn force_set_active_config(config: HostConfiguration) { + pub fn force_set_active_config(config: HostConfiguration>) { ActiveConfig::::set(config); } @@ -1258,7 +1258,7 @@ impl Pallet { // the sake of essentially avoiding an indirect call. Doesn't worth it. #[inline(never)] pub(crate) fn schedule_config_update( - updater: impl FnOnce(&mut HostConfiguration), + updater: impl FnOnce(&mut HostConfiguration>), ) -> DispatchResult { let mut pending_configs = >::get(); diff --git a/runtime/parachains/src/disputes.rs b/runtime/parachains/src/disputes.rs index 3e96c25a26c2..26790b09de5d 100644 --- a/runtime/parachains/src/disputes.rs +++ b/runtime/parachains/src/disputes.rs @@ -298,9 +298,9 @@ impl DisputesHandler for () { fn initializer_on_new_session(_notification: &SessionChangeNotification) {} } -impl DisputesHandler for pallet::Pallet +impl DisputesHandler> for pallet::Pallet where - T::BlockNumber: Ord, + frame_system::BlockNumberOf: Ord, { fn is_frozen() -> bool { pallet::Pallet::::is_frozen() @@ -308,7 +308,7 @@ where fn filter_dispute_data( set: DisputeStatementSet, - post_conclusion_acceptance_period: T::BlockNumber, + post_conclusion_acceptance_period: frame_system::BlockNumberOf, ) -> Option { pallet::Pallet::::filter_dispute_data(&set, post_conclusion_acceptance_period) .filter_statement_set(set) @@ -323,7 +323,7 @@ where fn note_included( session: SessionIndex, candidate_hash: CandidateHash, - included_in: T::BlockNumber, + included_in: frame_system::BlockNumberOf, ) { pallet::Pallet::::note_included(session, candidate_hash, included_in) } @@ -331,7 +331,7 @@ where fn included_state( session: SessionIndex, candidate_hash: CandidateHash, - ) -> Option { + ) -> Option> { pallet::Pallet::::included_state(session, candidate_hash) } @@ -339,7 +339,7 @@ where pallet::Pallet::::concluded_invalid(session, candidate_hash) } - fn initializer_initialize(now: T::BlockNumber) -> Weight { + fn initializer_initialize(now: frame_system::BlockNumberOf) -> Weight { pallet::Pallet::::initializer_initialize(now) } @@ -347,7 +347,7 @@ where pallet::Pallet::::initializer_finalize() } - fn initializer_on_new_session(notification: &SessionChangeNotification) { + fn initializer_on_new_session(notification: &SessionChangeNotification>) { pallet::Pallet::::initializer_on_new_session(notification) } } @@ -373,7 +373,7 @@ pub mod pallet { pub trait Config: frame_system::Config + configuration::Config + session_info::Config { type RuntimeEvent: From> + IsType<::RuntimeEvent>; type RewardValidators: RewardValidators; - type SlashingHandler: SlashingHandler; + type SlashingHandler: SlashingHandler>; /// Weight information for extrinsics in this pallet. type WeightInfo: WeightInfo; @@ -400,7 +400,7 @@ pub mod pallet { SessionIndex, Blake2_128Concat, CandidateHash, - DisputeState, + DisputeState>, >; /// Backing votes stored for each dispute. @@ -424,7 +424,7 @@ pub mod pallet { SessionIndex, Blake2_128Concat, CandidateHash, - T::BlockNumber, + frame_system::BlockNumberOf, >; /// 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. #[pallet::storage] #[pallet::getter(fn last_valid_block)] - pub(super) type Frozen = StorageValue<_, Option, ValueQuery>; + pub(super) type Frozen = StorageValue<_, Option>, ValueQuery>; #[pallet::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 /// 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. - Revert(T::BlockNumber), + Revert(frame_system::BlockNumberOf), } #[pallet::error] @@ -854,7 +854,7 @@ impl StatementSetFilter { impl Pallet { /// Called by the initializer to initialize the disputes module. - pub(crate) fn initializer_initialize(_now: T::BlockNumber) -> Weight { + pub(crate) fn initializer_initialize(_now: frame_system::BlockNumberOf) -> Weight { Weight::zero() } @@ -863,7 +863,7 @@ impl Pallet { /// Called by the initializer to note a new session in the disputes pallet. pub(crate) fn initializer_on_new_session( - notification: &SessionChangeNotification, + notification: &SessionChangeNotification>, ) { let config = >::config(); @@ -937,7 +937,7 @@ impl Pallet { // Disputes without enough votes to get confirmed are also filtered out. fn filter_dispute_data( set: &DisputeStatementSet, - post_conclusion_acceptance_period: ::BlockNumber, + post_conclusion_acceptance_period: frame_system::BlockNumberOf, ) -> StatementSetFilter { let mut filter = StatementSetFilter::RemoveIndices(Vec::new()); @@ -1048,7 +1048,7 @@ impl Pallet { /// dispute is fresh. fn process_checked_dispute_data( set: &CheckedDisputeStatementSet, - dispute_post_conclusion_acceptance_period: T::BlockNumber, + dispute_post_conclusion_acceptance_period: frame_system::BlockNumberOf, ) -> Result { // Dispute statement sets on any dispute which concluded // before this point are to be rejected. @@ -1189,14 +1189,14 @@ impl Pallet { } #[allow(unused)] - pub(crate) fn disputes() -> Vec<(SessionIndex, CandidateHash, DisputeState)> { + pub(crate) fn disputes() -> Vec<(SessionIndex, CandidateHash, DisputeState>)> { >::iter().collect() } pub(crate) fn note_included( session: SessionIndex, candidate_hash: CandidateHash, - included_in: T::BlockNumber, + included_in: frame_system::BlockNumberOf, ) { if included_in.is_zero() { return @@ -1216,7 +1216,7 @@ impl Pallet { pub(crate) fn included_state( session: SessionIndex, candidate_hash: CandidateHash, - ) -> Option { + ) -> Option> { >::get(session, candidate_hash) } @@ -1231,7 +1231,7 @@ impl Pallet { Self::last_valid_block().is_some() } - pub(crate) fn revert_and_freeze(revert_to: T::BlockNumber) { + pub(crate) fn revert_and_freeze(revert_to: frame_system::BlockNumberOf) { if Self::last_valid_block().map_or(true, |last| last > revert_to) { Frozen::::set(Some(revert_to)); diff --git a/runtime/parachains/src/disputes/slashing.rs b/runtime/parachains/src/disputes/slashing.rs index ac6f89019388..d690f162c20d 100644 --- a/runtime/parachains/src/disputes/slashing.rs +++ b/runtime/parachains/src/disputes/slashing.rs @@ -270,7 +270,7 @@ where } } -impl disputes::SlashingHandler for SlashValidatorsForDisputes> +impl disputes::SlashingHandler> for SlashValidatorsForDisputes> where T: Config>, { @@ -294,7 +294,7 @@ where // NOTE: changing that requires modifying `do_punish` implementation } - fn initializer_initialize(now: T::BlockNumber) -> Weight { + fn initializer_initialize(now: frame_system::BlockNumberOf) -> Weight { Pallet::::initializer_initialize(now) } @@ -529,7 +529,7 @@ pub mod pallet { impl Pallet { /// Called by the initializer to initialize the disputes slashing module. - fn initializer_initialize(_now: T::BlockNumber) -> Weight { + fn initializer_initialize(_now: frame_system::BlockNumberOf) -> Weight { Weight::zero() } diff --git a/runtime/parachains/src/disputes/slashing/benchmarking.rs b/runtime/parachains/src/disputes/slashing/benchmarking.rs index 4debc41d3306..cae0360ac9a1 100644 --- a/runtime/parachains/src/disputes/slashing/benchmarking.rs +++ b/runtime/parachains/src/disputes/slashing/benchmarking.rs @@ -70,13 +70,13 @@ where .expect("session::set_keys should work"); } - pallet_session::Pallet::::on_initialize(T::BlockNumber::one()); - initializer::Pallet::::on_initialize(T::BlockNumber::one()); + pallet_session::Pallet::::on_initialize(frame_system::BlockNumberOf::::one()); + initializer::Pallet::::on_initialize(frame_system::BlockNumberOf::::one()); // skip sessions until the new validator set is enacted while pallet_session::Pallet::::validators().len() < n as usize { pallet_session::Pallet::::rotate_session(); } - initializer::Pallet::::on_finalize(T::BlockNumber::one()); + initializer::Pallet::::on_finalize(frame_system::BlockNumberOf::::one()); let session_index = crate::shared::Pallet::::session_index(); let session_info = crate::session_info::Pallet::::session_info(session_index); @@ -86,9 +86,9 @@ where let key_owner_proof = pallet_session::historical::Pallet::::prove(key).unwrap(); // rotate a session to make sure `key_owner_proof` is historical - initializer::Pallet::::on_initialize(T::BlockNumber::one()); + initializer::Pallet::::on_initialize(frame_system::BlockNumberOf::::one()); pallet_session::Pallet::::rotate_session(); - initializer::Pallet::::on_finalize(T::BlockNumber::one()); + initializer::Pallet::::on_finalize(frame_system::BlockNumberOf::::one()); let idx = crate::shared::Pallet::::session_index(); assert!( diff --git a/runtime/parachains/src/disputes/tests.rs b/runtime/parachains/src/disputes/tests.rs index eaf1bde12353..d96999c98151 100644 --- a/runtime/parachains/src/disputes/tests.rs +++ b/runtime/parachains/src/disputes/tests.rs @@ -2055,7 +2055,7 @@ fn deduplication_and_sorting_works() { let disputes_orig = disputes.clone(); as DisputesHandler< - ::BlockNumber, + frame_system::BlockNumberOf >>::deduplicate_and_sort_dispute_data(&mut disputes).unwrap_err(); // assert ordering of local only disputes, and at the same time, and being free of duplicates @@ -2083,7 +2083,7 @@ fn apply_filter_all>( let mut acc = Vec::::new(); for dispute_statement in sets { - if let Some(checked) = as DisputesHandler<::BlockNumber>>::filter_dispute_data( + if let Some(checked) = as DisputesHandler>>::filter_dispute_data( dispute_statement, post_conclusion_acceptance_period, ) { @@ -2159,7 +2159,7 @@ fn filter_removes_duplicates_within_set() { let post_conclusion_acceptance_period = 10; let statements = as DisputesHandler< - ::BlockNumber, + frame_system::BlockNumberOf >>::filter_dispute_data(statements, post_conclusion_acceptance_period); assert_eq!( @@ -2446,7 +2446,7 @@ fn filter_removes_duplicate_statements_sets() { // `Err(())` indicates presence of duplicates assert!( as DisputesHandler< - ::BlockNumber, + frame_system::BlockNumberOf >>::deduplicate_and_sort_dispute_data(&mut sets) .is_err()); diff --git a/runtime/parachains/src/dmp.rs b/runtime/parachains/src/dmp.rs index 5244406fcce4..9256d1bbcf23 100644 --- a/runtime/parachains/src/dmp.rs +++ b/runtime/parachains/src/dmp.rs @@ -121,7 +121,7 @@ pub mod pallet { _, Twox64Concat, ParaId, - Vec>, + Vec>>, ValueQuery, >; @@ -150,7 +150,7 @@ pub mod pallet { /// Routines and getters related to downward message passing. impl Pallet { /// Block initialization logic, called by initializer. - pub(crate) fn initializer_initialize(_now: T::BlockNumber) -> Weight { + pub(crate) fn initializer_initialize(_now: frame_system::BlockNumberOf) -> Weight { Weight::zero() } @@ -159,7 +159,7 @@ impl Pallet { /// Called by the initializer to note that a new session has started. pub(crate) fn initializer_on_new_session( - _notification: &initializer::SessionChangeNotification, + _notification: &initializer::SessionChangeNotification>, outgoing_paras: &[ParaId], ) { Self::perform_outgoing_para_cleanup(outgoing_paras); @@ -183,7 +183,7 @@ impl Pallet { /// 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. pub fn can_queue_downward_message( - config: &HostConfiguration, + config: &HostConfiguration>, para: &ParaId, msg: &DownwardMessage, ) -> Result<(), QueueDownwardMessageError> { @@ -209,7 +209,7 @@ impl Pallet { /// to a dangling storage. If the caller cannot statically prove that the recipient exists /// then the caller should perform a runtime check. pub fn queue_downward_message( - config: &HostConfiguration, + config: &HostConfiguration>, para: ParaId, msg: DownwardMessage, ) -> Result<(), QueueDownwardMessageError> { @@ -316,7 +316,7 @@ impl Pallet { /// Returns the downward message queue contents for the given para. /// /// The most recent messages are the latest in the vector. - pub(crate) fn dmq_contents(recipient: ParaId) -> Vec> { + pub(crate) fn dmq_contents(recipient: ParaId) -> Vec>> { DownwardMessageQueues::::get(&recipient) } diff --git a/runtime/parachains/src/hrmp.rs b/runtime/parachains/src/hrmp.rs index ee725da37f1f..582454667744 100644 --- a/runtime/parachains/src/hrmp.rs +++ b/runtime/parachains/src/hrmp.rs @@ -369,7 +369,7 @@ pub mod pallet { /// Invariant: /// - each para `P` used here as a key should satisfy `Paras::is_valid_para(P)` within a session. #[pallet::storage] - pub type HrmpWatermarks = StorageMap<_, Twox64Concat, ParaId, T::BlockNumber>; + pub type HrmpWatermarks = StorageMap<_, Twox64Concat, ParaId, frame_system::BlockNumberOf>; /// HRMP channel data associated with each para. /// Invariant: @@ -407,7 +407,7 @@ pub mod pallet { _, Twox64Concat, HrmpChannelId, - Vec>, + Vec>>, ValueQuery, >; @@ -419,7 +419,7 @@ pub mod pallet { /// same block number. #[pallet::storage] pub type HrmpChannelDigests = - StorageMap<_, Twox64Concat, ParaId, Vec<(T::BlockNumber, Vec)>, ValueQuery>; + StorageMap<_, Twox64Concat, ParaId, Vec<(frame_system::BlockNumberOf, Vec)>, ValueQuery>; /// Preopen the given HRMP channels. /// @@ -641,7 +641,7 @@ fn preopen_hrmp_channel( /// Routines and getters related to HRMP. impl Pallet { /// Block initialization logic, called by initializer. - pub(crate) fn initializer_initialize(_now: T::BlockNumber) -> Weight { + pub(crate) fn initializer_initialize(_now: frame_system::BlockNumberOf) -> Weight { Weight::zero() } @@ -650,7 +650,7 @@ impl Pallet { /// Called by the initializer to note that a new session has started. pub(crate) fn initializer_on_new_session( - notification: &initializer::SessionChangeNotification, + notification: &initializer::SessionChangeNotification>, outgoing_paras: &[ParaId], ) -> Weight { let w1 = Self::perform_outgoing_para_cleanup(¬ification.prev_config, outgoing_paras); @@ -667,7 +667,7 @@ impl Pallet { /// Iterate over all paras that were noted for offboarding and remove all the data /// associated with them. fn perform_outgoing_para_cleanup( - config: &HostConfiguration, + config: &HostConfiguration>, outgoing: &[ParaId], ) -> Weight { let mut w = Self::clean_open_channel_requests(config, outgoing); @@ -692,7 +692,7 @@ impl Pallet { // // This will also perform the refunds for the counterparty if it doesn't offboard. pub(crate) fn clean_open_channel_requests( - config: &HostConfiguration, + config: &HostConfiguration>, outgoing: &[ParaId], ) -> Weight { // First collect all the channel ids of the open requests in which there is at least one @@ -768,7 +768,7 @@ impl Pallet { /// /// - prune the stale requests /// - enact the confirmed requests - fn process_hrmp_open_channel_requests(config: &HostConfiguration) { + fn process_hrmp_open_channel_requests(config: &HostConfiguration>) { let mut open_req_channels = HrmpOpenChannelRequestsList::::get(); if open_req_channels.is_empty() { return @@ -876,9 +876,9 @@ impl Pallet { /// Check that the candidate of the given recipient controls the HRMP watermark properly. pub(crate) fn check_hrmp_watermark( recipient: ParaId, - relay_chain_parent_number: T::BlockNumber, - new_hrmp_watermark: T::BlockNumber, - ) -> Result<(), HrmpWatermarkAcceptanceErr> { + relay_chain_parent_number: frame_system::BlockNumberOf, + new_hrmp_watermark: frame_system::BlockNumberOf, + ) -> Result<(), HrmpWatermarkAcceptanceErr>> { // First, check where the watermark CANNOT legally land. // // (a) For ensuring that messages are eventually processed, we require each parablock's @@ -924,7 +924,7 @@ impl Pallet { } pub(crate) fn check_outbound_hrmp( - config: &HostConfiguration, + config: &HostConfiguration>, sender: ParaId, out_hrmp_msgs: &[OutboundHrmpMessage], ) -> Result<(), OutboundHrmpAcceptanceErr> { @@ -987,7 +987,7 @@ impl Pallet { Ok(()) } - pub(crate) fn prune_hrmp(recipient: ParaId, new_hrmp_watermark: T::BlockNumber) -> Weight { + pub(crate) fn prune_hrmp(recipient: ParaId, new_hrmp_watermark: frame_system::BlockNumberOf) -> Weight { let mut weight = Weight::zero(); // sift through the incoming messages digest to collect the paras that sent at least one @@ -1372,7 +1372,7 @@ impl Pallet { /// messages in them are also included. pub(crate) fn inbound_hrmp_channels_contents( recipient: ParaId, - ) -> BTreeMap>> { + ) -> BTreeMap>>> { let sender_set = HrmpIngressChannelsIndex::::get(&recipient); let mut inbound_hrmp_channels_contents = BTreeMap::new(); diff --git a/runtime/parachains/src/inclusion/mod.rs b/runtime/parachains/src/inclusion/mod.rs index 3815aa45a4b1..3f9c93be6de0 100644 --- a/runtime/parachains/src/inclusion/mod.rs +++ b/runtime/parachains/src/inclusion/mod.rs @@ -270,7 +270,7 @@ pub mod pallet { + configuration::Config { type RuntimeEvent: From> + IsType<::RuntimeEvent>; - type DisputesHandler: disputes::DisputesHandler; + type DisputesHandler: disputes::DisputesHandler>; type RewardValidators: RewardValidators; /// The system message queue. @@ -365,12 +365,12 @@ pub mod pallet { /// The latest bitfield for each validator, referred to by their index in the validator set. #[pallet::storage] pub(crate) type AvailabilityBitfields = - StorageMap<_, Twox64Concat, ValidatorIndex, AvailabilityBitfieldRecord>; + StorageMap<_, Twox64Concat, ValidatorIndex, AvailabilityBitfieldRecord>>; /// Candidates pending availability by `ParaId`. #[pallet::storage] pub(crate) type PendingAvailability = - StorageMap<_, Twox64Concat, ParaId, CandidatePendingAvailability>; + StorageMap<_, Twox64Concat, ParaId, CandidatePendingAvailability>>; /// The commitments of candidates pending availability, by `ParaId`. #[pallet::storage] @@ -450,7 +450,7 @@ impl fmt::Debug for UmpAcceptanceCheckErr { impl Pallet { /// Block initialization logic, called by initializer. - pub(crate) fn initializer_initialize(_now: T::BlockNumber) -> Weight { + pub(crate) fn initializer_initialize(_now: frame_system::BlockNumberOf) -> Weight { Weight::zero() } @@ -459,7 +459,7 @@ impl Pallet { /// Handle an incoming session change. pub(crate) fn initializer_on_new_session( - _notification: &crate::initializer::SessionChangeNotification, + _notification: &crate::initializer::SessionChangeNotification>, outgoing_paras: &[ParaId], ) { // unlike most drain methods, drained elements are not cleared on `Drop` of the iterator @@ -832,7 +832,7 @@ impl Pallet { &validation_outputs.new_validation_code, validation_outputs.processed_downward_messages, &validation_outputs.upward_messages, - T::BlockNumber::from(validation_outputs.hrmp_watermark), + frame_system::BlockNumberOf::::from(validation_outputs.hrmp_watermark), &validation_outputs.horizontal_messages, ) .is_err() @@ -849,7 +849,7 @@ impl Pallet { } fn enact_candidate( - relay_parent_number: T::BlockNumber, + relay_parent_number: frame_system::BlockNumberOf, receipt: CommittedCandidateReceipt, backers: BitVec, availability_votes: BitVec, @@ -898,7 +898,7 @@ impl Pallet { )); weight.saturating_accrue(>::prune_hrmp( receipt.descriptor.para_id, - T::BlockNumber::from(commitments.hrmp_watermark), + frame_system::BlockNumberOf::::from(commitments.hrmp_watermark), )); weight.saturating_accrue(>::queue_outbound_hrmp( receipt.descriptor.para_id, @@ -921,7 +921,7 @@ impl Pallet { /// Check that all the upward messages sent by a candidate pass the acceptance criteria. pub(crate) fn check_upward_messages( - config: &HostConfiguration, + config: &HostConfiguration>, para: ParaId, upward_messages: &[UpwardMessage], ) -> Result<(), UmpAcceptanceCheckErr> { @@ -1020,7 +1020,7 @@ impl Pallet { /// /// Returns a vector of cleaned-up core IDs. pub(crate) fn collect_pending( - pred: impl Fn(CoreIndex, T::BlockNumber) -> bool, + pred: impl Fn(CoreIndex, frame_system::BlockNumberOf) -> bool, ) -> Vec { let mut cleaned_up_ids = Vec::new(); let mut cleaned_up_cores = Vec::new(); @@ -1115,7 +1115,7 @@ impl Pallet { /// para provided, if any. pub(crate) fn pending_availability( para: ParaId, - ) -> Option> { + ) -> Option>> { >::get(¶) } } @@ -1162,9 +1162,9 @@ impl OnQueueChanged for Pallet { /// A collection of data required for checking a candidate. pub(crate) struct CandidateCheckContext { - config: configuration::HostConfiguration, - now: T::BlockNumber, - relay_parent_number: T::BlockNumber, + config: configuration::HostConfiguration>, + now: frame_system::BlockNumberOf, + relay_parent_number: frame_system::BlockNumberOf, } /// An error indicating that creating Persisted Validation Data failed @@ -1172,7 +1172,7 @@ pub(crate) struct CandidateCheckContext { pub(crate) struct FailedToCreatePVD; impl CandidateCheckContext { - pub(crate) fn new(now: T::BlockNumber, relay_parent_number: T::BlockNumber) -> Self { + pub(crate) fn new(now: frame_system::BlockNumberOf, relay_parent_number: frame_system::BlockNumberOf) -> Self { Self { config: >::config(), now, relay_parent_number } } @@ -1244,7 +1244,7 @@ impl CandidateCheckContext { &backed_candidate.candidate.commitments.new_validation_code, backed_candidate.candidate.commitments.processed_downward_messages, &backed_candidate.candidate.commitments.upward_messages, - T::BlockNumber::from(backed_candidate.candidate.commitments.hrmp_watermark), + frame_system::BlockNumberOf::::from(backed_candidate.candidate.commitments.hrmp_watermark), &backed_candidate.candidate.commitments.horizontal_messages, ) { log::debug!( @@ -1267,9 +1267,9 @@ impl CandidateCheckContext { new_validation_code: &Option, processed_downward_messages: u32, upward_messages: &[primitives::UpwardMessage], - hrmp_watermark: T::BlockNumber, + hrmp_watermark: frame_system::BlockNumberOf, horizontal_messages: &[primitives::OutboundHrmpMessage], - ) -> Result<(), AcceptanceCheckErr> { + ) -> Result<(), AcceptanceCheckErr>> { ensure!( head_data.0.len() <= self.config.max_head_data_size as _, AcceptanceCheckErr::HeadDataTooLarge, diff --git a/runtime/parachains/src/initializer.rs b/runtime/parachains/src/initializer.rs index 338392b6e060..610d2ccee1e9 100644 --- a/runtime/parachains/src/initializer.rs +++ b/runtime/parachains/src/initializer.rs @@ -116,7 +116,7 @@ pub mod pallet { + hrmp::Config { /// A randomness beacon. - type Randomness: Randomness; + type Randomness: Randomness>; /// An origin which is allowed to force updates to parachains. type ForceOrigin: EnsureOrigin<::RuntimeOrigin>; /// Weight information for extrinsics in this pallet. @@ -147,7 +147,7 @@ pub mod pallet { #[pallet::hooks] impl Hooks> for Pallet { - fn on_initialize(now: T::BlockNumber) -> Weight { + fn on_initialize(now: frame_system::BlockNumberOf) -> Weight { // The other modules are initialized in this order: // - Configuration // - Paras @@ -174,7 +174,7 @@ pub mod pallet { total_weight } - fn on_finalize(now: T::BlockNumber) { + fn on_finalize(now: frame_system::BlockNumberOf) { // reverse initialization order. hrmp::Pallet::::initializer_finalize(); dmp::Pallet::::initializer_finalize(); diff --git a/runtime/parachains/src/mock.rs b/runtime/parachains/src/mock.rs index 2c975f682948..48aed85c699b 100644 --- a/runtime/parachains/src/mock.rs +++ b/runtime/parachains/src/mock.rs @@ -35,7 +35,7 @@ use frame_support::{ use frame_support_test::TestRandomness; use parity_scale_codec::Decode; use primitives::{ - AuthorityDiscoveryId, Balance, BlockNumber, CandidateHash, Header, Moment, SessionIndex, + AuthorityDiscoveryId, Balance, BlockNumber, CandidateHash, Moment, SessionIndex, UpwardMessage, ValidationCode, ValidatorIndex, }; use sp_core::{ConstU32, H256}; @@ -48,13 +48,10 @@ use sp_runtime::{ use std::{cell::RefCell, collections::HashMap}; type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic; -type Block = frame_system::mocking::MockBlock; +type Block = frame_system::mocking::MockBlockU32; frame_support::construct_runtime!( - pub enum Test where - Block = Block, - NodeBlock = Block, - UncheckedExtrinsic = UncheckedExtrinsic, + pub enum Test { System: frame_system, Balances: pallet_balances, @@ -101,12 +98,11 @@ 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 = u64; type Lookup = IdentityLookup; - type Header = Header; + type Block = Block; type RuntimeEvent = RuntimeEvent; type BlockHashCount = BlockHashCount; type Version = (); diff --git a/runtime/parachains/src/paras/benchmarking.rs b/runtime/parachains/src/paras/benchmarking.rs index 8faf8d67f7fd..52a00e426a8c 100644 --- a/runtime/parachains/src/paras/benchmarking.rs +++ b/runtime/parachains/src/paras/benchmarking.rs @@ -44,7 +44,7 @@ fn generate_disordered_pruning() { for i in 0..SAMPLE_SIZE { let id = ParaId::from(i); - let block_number = T::BlockNumber::from(1000u32); + let block_number = frame_system::BlockNumberOf::::from(1000u32); needs_pruning.push((id, block_number)); } @@ -57,7 +57,7 @@ pub(crate) fn generate_disordered_upgrades() { for i in 0..SAMPLE_SIZE { let id = ParaId::from(i); - let block_number = T::BlockNumber::from(1000u32); + let block_number = frame_system::BlockNumberOf::::from(1000u32); upgrades.push((id, block_number)); cooldowns.push((id, block_number)); } @@ -103,7 +103,7 @@ benchmarks! { let c in 1 .. MAX_CODE_SIZE; let new_code = ValidationCode(vec![0; c as usize]); let para_id = ParaId::from(c as u32); - let block = T::BlockNumber::from(c); + let block = frame_system::BlockNumberOf::::from(c); generate_disordered_upgrades::(); }: _(RawOrigin::Root, para_id, new_code, block) verify { @@ -118,7 +118,7 @@ benchmarks! { // schedule an expired code upgrade for this `para_id` so that force_note_new_head would use // the worst possible code path let expired = frame_system::Pallet::::block_number().saturating_sub(One::one()); - let config = HostConfiguration::::default(); + let config = HostConfiguration::>::default(); generate_disordered_pruning::(); Pallet::::schedule_code_upgrade(para_id, ValidationCode(vec![0]), expired, &config); }: _(RawOrigin::Root, para_id, new_head) diff --git a/runtime/parachains/src/paras/mod.rs b/runtime/parachains/src/paras/mod.rs index 8c8eabf9d2e9..bc7cdfcbb23b 100644 --- a/runtime/parachains/src/paras/mod.rs +++ b/runtime/parachains/src/paras/mod.rs @@ -550,7 +550,7 @@ pub mod pallet { #[pallet::constant] type UnsignedPriority: Get; - type NextSessionRotation: EstimateNextSessionRotation; + type NextSessionRotation: EstimateNextSessionRotation>; /// Retrieve how many UMP messages are enqueued for this para-chain. /// @@ -623,7 +623,7 @@ pub mod pallet { _, Twox64Concat, ValidationCodeHash, - PvfCheckActiveVoteState, + PvfCheckActiveVoteState>, OptionQuery, >; @@ -662,7 +662,7 @@ pub mod pallet { /// Corresponding code can be retrieved with [`CodeByHash`]. #[pallet::storage] pub(super) type PastCodeHash = - StorageMap<_, Twox64Concat, (ParaId, T::BlockNumber), ValidationCodeHash>; + StorageMap<_, Twox64Concat, (ParaId, frame_system::BlockNumberOf), ValidationCodeHash>; /// 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 @@ -670,7 +670,7 @@ pub mod pallet { #[pallet::storage] #[pallet::getter(fn past_code_meta)] pub(super) type PastCodeMeta = - StorageMap<_, Twox64Concat, ParaId, ParaPastCodeMeta, ValueQuery>; + StorageMap<_, Twox64Concat, ParaId, ParaPastCodeMeta>, ValueQuery>; /// 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 @@ -680,7 +680,7 @@ pub mod pallet { /// Multiple entries for a single para are permitted. Ordered ascending by block number. #[pallet::storage] pub(super) type PastCodePruning = - StorageValue<_, Vec<(ParaId, T::BlockNumber)>, ValueQuery>; + StorageValue<_, Vec<(ParaId, frame_system::BlockNumberOf)>, ValueQuery>; /// 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 @@ -688,7 +688,7 @@ pub mod pallet { #[pallet::storage] #[pallet::getter(fn future_code_upgrade_at)] pub(super) type FutureCodeUpgrades = - StorageMap<_, Twox64Concat, ParaId, T::BlockNumber>; + StorageMap<_, Twox64Concat, ParaId, frame_system::BlockNumberOf>; /// The actual future code hash of a para. /// @@ -728,7 +728,7 @@ pub mod pallet { /// Ordered ascending by block number. #[pallet::storage] pub(super) type UpgradeCooldowns = - StorageValue<_, Vec<(ParaId, T::BlockNumber)>, ValueQuery>; + StorageValue<_, Vec<(ParaId, frame_system::BlockNumberOf)>, ValueQuery>; /// 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. @@ -736,7 +736,7 @@ pub mod pallet { /// Ordered ascending by block number. #[pallet::storage] pub(super) type UpcomingUpgrades = - StorageValue<_, Vec<(ParaId, T::BlockNumber)>, ValueQuery>; + StorageValue<_, Vec<(ParaId, frame_system::BlockNumberOf)>, ValueQuery>; /// The actions to perform during the start of a specific session index. #[pallet::storage] @@ -836,7 +836,7 @@ pub mod pallet { origin: OriginFor, para: ParaId, new_code: ValidationCode, - relay_parent_number: T::BlockNumber, + relay_parent_number: frame_system::BlockNumberOf, ) -> DispatchResult { ensure_root(origin)?; let config = configuration::Pallet::::config(); @@ -1143,13 +1143,13 @@ impl 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: frame_system::BlockNumberOf) -> Weight { let weight = Self::prune_old_code(now); weight + Self::process_scheduled_upgrade_changes(now) } /// Called by the initializer to finalize the paras pallet. - pub(crate) fn initializer_finalize(now: T::BlockNumber) { + pub(crate) fn initializer_finalize(now: frame_system::BlockNumberOf) { Self::process_scheduled_upgrade_cooldowns(now); } @@ -1157,7 +1157,7 @@ impl Pallet { /// /// Returns the list of outgoing paras from the actions queue. pub(crate) fn initializer_on_new_session( - notification: &SessionChangeNotification, + notification: &SessionChangeNotification>, ) -> Vec { let outgoing_paras = Self::apply_actions_queue(notification.session_index); Self::groom_ongoing_pvf_votes(¬ification.new_config, notification.validators.len()); @@ -1273,8 +1273,8 @@ impl Pallet { // (i.e. number of `relay_parent` in the receipt) fn note_past_code( id: ParaId, - at: T::BlockNumber, - now: T::BlockNumber, + at: frame_system::BlockNumberOf, + now: frame_system::BlockNumberOf, old_code_hash: ValidationCodeHash, ) -> Weight { PastCodeMeta::::mutate(&id, |past_meta| { @@ -1296,7 +1296,7 @@ impl Pallet { // looks at old code metadata, compares them to the current acceptance window, and prunes those // that are too old. - fn prune_old_code(now: T::BlockNumber) -> Weight { + fn prune_old_code(now: frame_system::BlockNumberOf) -> Weight { let config = configuration::Pallet::::config(); let code_retention_period = config.code_retention_period; if now <= code_retention_period { @@ -1308,7 +1308,7 @@ impl Pallet { let pruning_height = now - (code_retention_period + One::one()); let pruning_tasks_done = - PastCodePruning::::mutate(|pruning_tasks: &mut Vec<(_, T::BlockNumber)>| { + PastCodePruning::::mutate(|pruning_tasks: &mut Vec<(_, frame_system::BlockNumberOf)>| { let (pruning_tasks_done, pruning_tasks_to_do) = { // find all past code that has just exited the pruning window. let up_to_idx = @@ -1356,11 +1356,11 @@ impl Pallet { /// 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 /// for the `initializer_finalize` function. - fn process_scheduled_upgrade_changes(now: T::BlockNumber) -> Weight { + fn process_scheduled_upgrade_changes(now: frame_system::BlockNumberOf) -> Weight { // account weight for `UpcomingUpgrades::mutate`. let mut weight = T::DbWeight::get().reads_writes(1, 1); let upgrades_signaled = UpcomingUpgrades::::mutate( - |upcoming_upgrades: &mut Vec<(ParaId, T::BlockNumber)>| { + |upcoming_upgrades: &mut Vec<(ParaId, frame_system::BlockNumberOf)>| { let num = upcoming_upgrades.iter().take_while(|&(_, at)| at <= &now).count(); for (para, _) in upcoming_upgrades.drain(..num) { UpgradeGoAheadSignal::::insert(¶, UpgradeGoAhead::GoAhead); @@ -1387,8 +1387,8 @@ impl Pallet { /// Actually perform unsetting the expired upgrade restrictions. /// /// See `process_scheduled_upgrade_changes` for more details. - fn process_scheduled_upgrade_cooldowns(now: T::BlockNumber) { - UpgradeCooldowns::::mutate(|upgrade_cooldowns: &mut Vec<(ParaId, T::BlockNumber)>| { + fn process_scheduled_upgrade_cooldowns(now: frame_system::BlockNumberOf) { + UpgradeCooldowns::::mutate(|upgrade_cooldowns: &mut Vec<(ParaId, frame_system::BlockNumberOf)>| { for &(para, _) in upgrade_cooldowns.iter().take_while(|&(_, at)| at <= &now) { UpgradeRestrictionSignal::::remove(¶); } @@ -1398,7 +1398,7 @@ impl Pallet { /// Goes over all PVF votes in progress, reinitializes ballots, increments ages and prunes the /// active votes that reached their time-to-live. fn groom_ongoing_pvf_votes( - cfg: &configuration::HostConfiguration, + cfg: &configuration::HostConfiguration>, new_n_validators: usize, ) -> Weight { let mut weight = T::DbWeight::get().reads(1); @@ -1448,11 +1448,11 @@ impl Pallet { } fn enact_pvf_accepted( - now: T::BlockNumber, + now: frame_system::BlockNumberOf, code_hash: &ValidationCodeHash, - causes: &[PvfCheckCause], + causes: &[PvfCheckCause>], sessions_observed: SessionIndex, - cfg: &configuration::HostConfiguration, + cfg: &configuration::HostConfiguration>, ) -> Weight { let mut weight = Weight::zero(); for cause in causes { @@ -1495,9 +1495,9 @@ impl Pallet { fn proceed_with_upgrade( id: ParaId, code_hash: &ValidationCodeHash, - now: T::BlockNumber, - relay_parent_number: T::BlockNumber, - cfg: &configuration::HostConfiguration, + now: frame_system::BlockNumberOf, + relay_parent_number: frame_system::BlockNumberOf, + cfg: &configuration::HostConfiguration>, ) -> Weight { let mut weight = Weight::zero(); @@ -1537,7 +1537,7 @@ impl Pallet { fn enact_pvf_rejected( code_hash: &ValidationCodeHash, - causes: Vec>, + causes: Vec>>, ) -> Weight { let mut weight = Weight::zero(); @@ -1758,8 +1758,8 @@ impl Pallet { pub(crate) fn schedule_code_upgrade( id: ParaId, new_code: ValidationCode, - relay_parent_number: T::BlockNumber, - cfg: &configuration::HostConfiguration, + relay_parent_number: frame_system::BlockNumberOf, + cfg: &configuration::HostConfiguration>, ) -> Weight { let mut weight = T::DbWeight::get().reads(1); @@ -1832,10 +1832,10 @@ impl Pallet { /// /// Unconditionally increases the reference count for the passed `code`. fn kick_off_pvf_check( - cause: PvfCheckCause, + cause: PvfCheckCause>, code_hash: ValidationCodeHash, code: ValidationCode, - cfg: &configuration::HostConfiguration, + cfg: &configuration::HostConfiguration>, ) -> Weight { let mut weight = Weight::zero(); @@ -1904,7 +1904,7 @@ impl Pallet { pub(crate) fn note_new_head( id: ParaId, new_head: HeadData, - execution_context: T::BlockNumber, + execution_context: frame_system::BlockNumberOf, ) -> Weight { Heads::::insert(&id, new_head); diff --git a/runtime/parachains/src/paras_inherent/mod.rs b/runtime/parachains/src/paras_inherent/mod.rs index f20af3ba7d64..8c4e6c3c85da 100644 --- a/runtime/parachains/src/paras_inherent/mod.rs +++ b/runtime/parachains/src/paras_inherent/mod.rs @@ -191,11 +191,11 @@ pub mod pallet { #[pallet::hooks] impl Hooks> for Pallet { - fn on_initialize(_: T::BlockNumber) -> Weight { + fn on_initialize(_: frame_system::BlockNumberOf) -> Weight { T::DbWeight::get().reads_writes(1, 1) // in `on_finalize`. } - fn on_finalize(_: T::BlockNumber) { + fn on_finalize(_: frame_system::BlockNumberOf) { if Included::::take().is_none() { panic!("Bitfields and heads must be included every block"); } @@ -262,7 +262,7 @@ pub mod pallet { ))] pub fn enter( origin: OriginFor, - data: ParachainsInherentData, + data: ParachainsInherentData>, ) -> DispatchResultWithPostInfo { ensure_none(origin)?; @@ -277,7 +277,7 @@ pub mod pallet { impl Pallet { /// 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. - fn create_inherent_inner(data: &InherentData) -> Option> { + fn create_inherent_inner(data: &InherentData) -> Option>> { let parachains_inherent_data = match data.get_data(&Self::INHERENT_IDENTIFIER) { Ok(Some(d)) => d, Ok(None) => return None, @@ -307,9 +307,9 @@ impl Pallet { /// Returns: Result containing processed inherent data and weight, the processed inherent would /// consume. fn process_inherent_data( - data: ParachainsInherentData, + data: ParachainsInherentData>, ) -> sp_std::result::Result< - (ParachainsInherentData, PostDispatchInfo), + (ParachainsInherentData>, PostDispatchInfo), DispatchErrorWithPostInfo, > { #[cfg(feature = "runtime-metrics")] @@ -530,7 +530,7 @@ impl Pallet { // Process backed candidates according to scheduled cores. let parent_storage_root = *parent_header.state_root(); - let inclusion::ProcessedCandidates::<::Hash> { + let inclusion::ProcessedCandidates::< as HeaderT>::Hash> { core_indices: occupied, candidate_receipt_with_backing_validator_indices, } = >::process_candidates( diff --git a/runtime/parachains/src/runtime_api_impl/v5.rs b/runtime/parachains/src/runtime_api_impl/v5.rs index 72425995b4b0..cf4cf20944c5 100644 --- a/runtime/parachains/src/runtime_api_impl/v5.rs +++ b/runtime/parachains/src/runtime_api_impl/v5.rs @@ -39,7 +39,7 @@ pub fn validators() -> Vec { /// Implementation for the `validator_groups` function of the runtime API. pub fn validator_groups( -) -> (Vec>, GroupRotationInfo) { +) -> (Vec>, GroupRotationInfo>) { let now = >::block_number() + One::one(); let groups = >::validator_groups(); @@ -49,7 +49,7 @@ pub fn validator_groups( } /// Implementation for the `availability_cores` function of the runtime API. -pub fn availability_cores() -> Vec> { +pub fn availability_cores() -> Vec>> { let cores = >::availability_cores(); let parachains = >::parachains(); let config = >::config(); @@ -176,7 +176,7 @@ pub fn availability_cores() -> Vec( -) -> (::BlockNumber, ::Hash) { +) -> (frame_system::BlockNumberOf, ::Hash) { use parity_scale_codec::Decode as _; let state_version = >::runtime_version().state_version(); let relay_parent_number = >::block_number(); @@ -214,7 +214,7 @@ where pub fn persisted_validation_data( para_id: ParaId, assumption: OccupiedCoreAssumption, -) -> Option> { +) -> Option>> { let (relay_parent_number, relay_parent_storage_root) = current_relay_parent::(); with_assumption::(para_id, assumption, || { crate::util::make_persisted_validation_data::( @@ -229,7 +229,7 @@ pub fn persisted_validation_data( pub fn assumed_validation_data( para_id: ParaId, expected_persisted_validation_data_hash: Hash, -) -> Option<(PersistedValidationData, ValidationCodeHash)> { +) -> Option<(PersistedValidationData>, ValidationCodeHash)> { let (relay_parent_number, relay_parent_storage_root) = current_relay_parent::(); // This closure obtains the `persisted_validation_data` for the given `para_id` and matches // its hash against an expected one. @@ -355,14 +355,14 @@ pub fn session_info(index: SessionIndex) -> Option( recipient: ParaId, -) -> Vec> { +) -> Vec>> { >::dmq_contents(recipient) } /// Implementation for the `inbound_hrmp_channels_contents` function of the runtime API. pub fn inbound_hrmp_channels_contents( recipient: ParaId, -) -> BTreeMap>> { +) -> BTreeMap>>> { >::inbound_hrmp_channels_contents(recipient) } @@ -407,7 +407,7 @@ where /// Implementation for `get_session_disputes` function from the runtime API pub fn get_session_disputes( -) -> Vec<(SessionIndex, CandidateHash, DisputeState)> { +) -> Vec<(SessionIndex, CandidateHash, DisputeState>)> { >::disputes() } diff --git a/runtime/parachains/src/scheduler.rs b/runtime/parachains/src/scheduler.rs index 916df1687b9d..3a34e8e8f658 100644 --- a/runtime/parachains/src/scheduler.rs +++ b/runtime/parachains/src/scheduler.rs @@ -208,7 +208,7 @@ pub mod pallet { /// block following the session change, block number of which we save in this storage value. #[pallet::storage] #[pallet::getter(fn session_start_block)] - pub(crate) type SessionStartBlock = StorageValue<_, T::BlockNumber, ValueQuery>; + pub(crate) type SessionStartBlock = StorageValue<_, frame_system::BlockNumberOf, ValueQuery>; /// Currently scheduled cores - free but up to be occupied. /// @@ -224,7 +224,7 @@ pub mod pallet { impl 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: frame_system::BlockNumberOf) -> Weight { Weight::zero() } @@ -233,7 +233,7 @@ impl Pallet { /// Called by the initializer to note that a new session has started. pub(crate) fn initializer_on_new_session( - notification: &SessionChangeNotification, + notification: &SessionChangeNotification>, ) { let SessionChangeNotification { validators, new_config, .. } = notification; let config = new_config; @@ -421,7 +421,7 @@ impl Pallet { /// ascending order by core index. pub(crate) fn schedule( just_freed_cores: impl IntoIterator, - now: T::BlockNumber, + now: frame_system::BlockNumberOf, ) { Self::free_cores(just_freed_cores); @@ -590,7 +590,7 @@ impl Pallet { /// or the block number is less than the session start index. pub(crate) fn group_assigned_to_core( core: CoreIndex, - at: T::BlockNumber, + at: frame_system::BlockNumberOf, ) -> Option { let config = >::config(); let session_start_block = >::get(); @@ -605,11 +605,11 @@ impl Pallet { return None } - let rotations_since_session_start: T::BlockNumber = + let rotations_since_session_start: frame_system::BlockNumberOf = (at - session_start_block) / config.group_rotation_frequency.into(); let rotations_since_session_start = - >::try_into(rotations_since_session_start).unwrap_or(0); + as TryInto>::try_into(rotations_since_session_start).unwrap_or(0); // Error case can only happen if rotations occur only once every u32::max(), // so functionally no difference in behavior. @@ -629,7 +629,7 @@ impl Pallet { /// https://github.com/rust-lang/rust/issues/73226 /// which prevents us from testing the code if using `impl Trait`. pub(crate) fn availability_timeout_predicate( - ) -> Option bool>> { + ) -> Option) -> bool>> { let now = >::block_number(); let config = >::config(); @@ -670,7 +670,7 @@ impl Pallet { } /// Returns a helper for determining group rotation. - pub(crate) fn group_rotation_info(now: T::BlockNumber) -> GroupRotationInfo { + pub(crate) fn group_rotation_info(now: frame_system::BlockNumberOf) -> GroupRotationInfo> { let session_start_block = Self::session_start_block(); let group_rotation_frequency = >::config().group_rotation_frequency; diff --git a/runtime/parachains/src/session_info.rs b/runtime/parachains/src/session_info.rs index 9f47ad0b03d6..20a9398d86f3 100644 --- a/runtime/parachains/src/session_info.rs +++ b/runtime/parachains/src/session_info.rs @@ -125,7 +125,7 @@ impl AuthorityDiscoveryConfig for T { impl Pallet { /// Handle an incoming session change. pub(crate) fn initializer_on_new_session( - notification: &crate::initializer::SessionChangeNotification, + notification: &crate::initializer::SessionChangeNotification>, ) { let config = >::config(); @@ -195,7 +195,7 @@ impl 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: frame_system::BlockNumberOf) -> Weight { Weight::zero() } diff --git a/runtime/parachains/src/shared.rs b/runtime/parachains/src/shared.rs index 686b955175b1..98794e35eb42 100644 --- a/runtime/parachains/src/shared.rs +++ b/runtime/parachains/src/shared.rs @@ -73,7 +73,7 @@ pub mod pallet { impl 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: frame_system::BlockNumberOf) -> Weight { Weight::zero() } @@ -86,7 +86,7 @@ impl Pallet { pub(crate) fn initializer_on_new_session( session_index: SessionIndex, random_seed: [u8; 32], - new_config: &HostConfiguration, + new_config: &HostConfiguration>, all_validators: Vec, ) -> Vec { CurrentSessionIndex::::set(session_index); diff --git a/runtime/parachains/src/util.rs b/runtime/parachains/src/util.rs index bf037b54a99f..a5a48539e286 100644 --- a/runtime/parachains/src/util.rs +++ b/runtime/parachains/src/util.rs @@ -28,9 +28,9 @@ use crate::{configuration, hrmp, paras}; /// This ties together the storage of several modules. pub fn make_persisted_validation_data( para_id: ParaId, - relay_parent_number: T::BlockNumber, + relay_parent_number: frame_system::BlockNumberOf, relay_parent_storage_root: T::Hash, -) -> Option> { +) -> Option>> { let config = >::config(); Some(PersistedValidationData { diff --git a/runtime/polkadot/src/lib.rs b/runtime/polkadot/src/lib.rs index 3ebccf5a94f4..365258702d2e 100644 --- a/runtime/polkadot/src/lib.rs +++ b/runtime/polkadot/src/lib.rs @@ -161,12 +161,11 @@ impl frame_system::Config for Runtime { type RuntimeOrigin = RuntimeOrigin; type RuntimeCall = RuntimeCall; type Index = Nonce; - type BlockNumber = BlockNumber; type Hash = Hash; type Hashing = BlakeTwo256; type AccountId = AccountId; type Lookup = AccountIdLookup; - type Header = generic::Header; + type Block = Block; type RuntimeEvent = RuntimeEvent; type BlockHashCount = BlockHashCount; type DbWeight = RocksDbWeight; @@ -1337,10 +1336,7 @@ impl frame_support::traits::OnRuntimeUpgrade for InitiateNominationPools { } construct_runtime! { - pub enum Runtime where - Block = Block, - NodeBlock = primitives::Block, - UncheckedExtrinsic = UncheckedExtrinsic + pub enum Runtime { // Basic stuff; balances is uncallable initially. System: frame_system::{Pallet, Call, Storage, Config, Event} = 0, @@ -1651,7 +1647,7 @@ sp_api::impl_runtime_apis! { Executive::execute_block(block); } - fn initialize_block(header: &::Header) { + fn initialize_block(header: &::Header) { Executive::initialize_block(header) } } @@ -1675,7 +1671,7 @@ sp_api::impl_runtime_apis! { Executive::apply_extrinsic(extrinsic) } - fn finalize_block() -> ::Header { + fn finalize_block() -> ::Header { Executive::finalize_block() } @@ -1719,14 +1715,14 @@ sp_api::impl_runtime_apis! { fn validate_transaction( source: TransactionSource, tx: ::Extrinsic, - block_hash: ::Hash, + block_hash: ::Hash, ) -> TransactionValidity { Executive::validate_transaction(source, tx, block_hash) } } impl offchain_primitives::OffchainWorkerApi for Runtime { - fn offchain_worker(header: &::Header) { + fn offchain_worker(header: &::Header) { Executive::offchain_worker(header) } } @@ -1935,7 +1931,7 @@ sp_api::impl_runtime_apis! { fn submit_report_equivocation_unsigned_extrinsic( equivocation_proof: fg_primitives::EquivocationProof< - ::Hash, + ::Hash, sp_runtime::traits::NumberFor, >, key_owner_proof: fg_primitives::OpaqueKeyOwnershipProof, @@ -1997,7 +1993,7 @@ sp_api::impl_runtime_apis! { } fn submit_report_equivocation_unsigned_extrinsic( - equivocation_proof: babe_primitives::EquivocationProof<::Header>, + equivocation_proof: babe_primitives::EquivocationProof<::Header>, key_owner_proof: babe_primitives::OpaqueKeyOwnershipProof, ) -> Option<()> { let key_owner_proof = key_owner_proof.decode()?; diff --git a/runtime/rococo/src/lib.rs b/runtime/rococo/src/lib.rs index 68528fa8e7d3..50f21aa729f6 100644 --- a/runtime/rococo/src/lib.rs +++ b/runtime/rococo/src/lib.rs @@ -156,12 +156,11 @@ impl frame_system::Config for Runtime { type RuntimeOrigin = RuntimeOrigin; type RuntimeCall = RuntimeCall; type Index = Nonce; - type BlockNumber = BlockNumber; type Hash = Hash; type Hashing = BlakeTwo256; type AccountId = AccountId; type Lookup = AccountIdLookup; - type Header = generic::Header; + type Block = Block; type RuntimeEvent = RuntimeEvent; type BlockHashCount = BlockHashCount; type Version = Version; @@ -1358,10 +1357,7 @@ impl pallet_sudo::Config for Runtime { } construct_runtime! { - pub enum Runtime where - Block = Block, - NodeBlock = primitives::Block, - UncheckedExtrinsic = UncheckedExtrinsic + pub enum Runtime { // Basic stuff; balances is uncallable initially. System: frame_system::{Pallet, Call, Storage, Config, Event} = 0, @@ -1745,7 +1741,7 @@ sp_api::impl_runtime_apis! { Executive::execute_block(block); } - fn initialize_block(header: &::Header) { + fn initialize_block(header: &::Header) { Executive::initialize_block(header) } } @@ -1769,7 +1765,7 @@ sp_api::impl_runtime_apis! { Executive::apply_extrinsic(extrinsic) } - fn finalize_block() -> ::Header { + fn finalize_block() -> ::Header { Executive::finalize_block() } @@ -1789,14 +1785,14 @@ sp_api::impl_runtime_apis! { fn validate_transaction( source: TransactionSource, tx: ::Extrinsic, - block_hash: ::Hash, + block_hash: ::Hash, ) -> TransactionValidity { Executive::validate_transaction(source, tx, block_hash) } } impl offchain_primitives::OffchainWorkerApi for Runtime { - fn offchain_worker(header: &::Header) { + fn offchain_worker(header: &::Header) { Executive::offchain_worker(header) } } @@ -2030,7 +2026,7 @@ sp_api::impl_runtime_apis! { fn submit_report_equivocation_unsigned_extrinsic( equivocation_proof: fg_primitives::EquivocationProof< - ::Hash, + ::Hash, sp_runtime::traits::NumberFor, >, key_owner_proof: fg_primitives::OpaqueKeyOwnershipProof, @@ -2092,7 +2088,7 @@ sp_api::impl_runtime_apis! { } fn submit_report_equivocation_unsigned_extrinsic( - equivocation_proof: babe_primitives::EquivocationProof<::Header>, + equivocation_proof: babe_primitives::EquivocationProof<::Header>, key_owner_proof: babe_primitives::OpaqueKeyOwnershipProof, ) -> Option<()> { let key_owner_proof = key_owner_proof.decode()?; diff --git a/runtime/test-runtime/src/lib.rs b/runtime/test-runtime/src/lib.rs index 132b8897d87e..f8d80a6e31bc 100644 --- a/runtime/test-runtime/src/lib.rs +++ b/runtime/test-runtime/src/lib.rs @@ -141,12 +141,11 @@ impl frame_system::Config for Runtime { type RuntimeOrigin = RuntimeOrigin; type RuntimeCall = RuntimeCall; type Index = Nonce; - type BlockNumber = BlockNumber; type Hash = HashT; type Hashing = BlakeTwo256; type AccountId = AccountId; type Lookup = Indices; - type Header = generic::Header; + type Block = Block; type RuntimeEvent = RuntimeEvent; type BlockHashCount = BlockHashCount; type Version = Version; @@ -646,10 +645,7 @@ pub mod pallet_test_notifier { } construct_runtime! { - pub enum Runtime where - Block = Block, - NodeBlock = primitives::Block, - UncheckedExtrinsic = UncheckedExtrinsic + pub enum Runtime { // Basic stuff; balances is uncallable initially. System: frame_system::{Pallet, Call, Storage, Config, Event}, @@ -736,7 +732,7 @@ pub type Executive = frame_executive::Executive< /// The payload being signed in transactions. pub type SignedPayload = generic::SignedPayload; -pub type Hash = ::Hash; +pub type Hash = ::Hash; pub type Extrinsic = ::Extrinsic; sp_api::impl_runtime_apis! { @@ -749,7 +745,7 @@ sp_api::impl_runtime_apis! { Executive::execute_block(block); } - fn initialize_block(header: &::Header) { + fn initialize_block(header: &::Header) { Executive::initialize_block(header) } } @@ -773,7 +769,7 @@ sp_api::impl_runtime_apis! { Executive::apply_extrinsic(extrinsic) } - fn finalize_block() -> ::Header { + fn finalize_block() -> ::Header { Executive::finalize_block() } @@ -793,14 +789,14 @@ sp_api::impl_runtime_apis! { fn validate_transaction( source: TransactionSource, tx: ::Extrinsic, - block_hash: ::Hash, + block_hash: ::Hash, ) -> TransactionValidity { Executive::validate_transaction(source, tx, block_hash) } } impl offchain_primitives::OffchainWorkerApi for Runtime { - fn offchain_worker(header: &::Header) { + fn offchain_worker(header: &::Header) { Executive::offchain_worker(header) } } @@ -1012,7 +1008,7 @@ sp_api::impl_runtime_apis! { fn submit_report_equivocation_unsigned_extrinsic( _equivocation_proof: fg_primitives::EquivocationProof< - ::Hash, + ::Hash, sp_runtime::traits::NumberFor, >, _key_owner_proof: fg_primitives::OpaqueKeyOwnershipProof, @@ -1061,7 +1057,7 @@ sp_api::impl_runtime_apis! { } fn submit_report_equivocation_unsigned_extrinsic( - _equivocation_proof: babe_primitives::EquivocationProof<::Header>, + _equivocation_proof: babe_primitives::EquivocationProof<::Header>, _key_owner_proof: babe_primitives::OpaqueKeyOwnershipProof, ) -> Option<()> { None diff --git a/runtime/westend/src/lib.rs b/runtime/westend/src/lib.rs index eb1d25e37014..752d46e67b27 100644 --- a/runtime/westend/src/lib.rs +++ b/runtime/westend/src/lib.rs @@ -151,12 +151,11 @@ impl frame_system::Config for Runtime { type RuntimeOrigin = RuntimeOrigin; type RuntimeCall = RuntimeCall; type Index = Nonce; - type BlockNumber = BlockNumber; type Hash = Hash; type Hashing = BlakeTwo256; type AccountId = AccountId; type Lookup = AccountIdLookup; - type Header = generic::Header; + type Block = Block; type RuntimeEvent = RuntimeEvent; type BlockHashCount = BlockHashCount; type DbWeight = RocksDbWeight; @@ -1141,10 +1140,7 @@ parameter_types! { } construct_runtime! { - pub enum Runtime where - Block = Block, - NodeBlock = primitives::Block, - UncheckedExtrinsic = UncheckedExtrinsic + pub enum Runtime { // Basic stuff; balances is uncallable initially. System: frame_system::{Pallet, Call, Storage, Config, Event} = 0, @@ -1420,7 +1416,7 @@ sp_api::impl_runtime_apis! { Executive::execute_block(block); } - fn initialize_block(header: &::Header) { + fn initialize_block(header: &::Header) { Executive::initialize_block(header) } } @@ -1444,7 +1440,7 @@ sp_api::impl_runtime_apis! { Executive::apply_extrinsic(extrinsic) } - fn finalize_block() -> ::Header { + fn finalize_block() -> ::Header { Executive::finalize_block() } @@ -1464,14 +1460,14 @@ sp_api::impl_runtime_apis! { fn validate_transaction( source: TransactionSource, tx: ::Extrinsic, - block_hash: ::Hash, + block_hash: ::Hash, ) -> TransactionValidity { Executive::validate_transaction(source, tx, block_hash) } } impl offchain_primitives::OffchainWorkerApi for Runtime { - fn offchain_worker(header: &::Header) { + fn offchain_worker(header: &::Header) { Executive::offchain_worker(header) } } @@ -1683,7 +1679,7 @@ sp_api::impl_runtime_apis! { fn submit_report_equivocation_unsigned_extrinsic( equivocation_proof: fg_primitives::EquivocationProof< - ::Hash, + ::Hash, sp_runtime::traits::NumberFor, >, key_owner_proof: fg_primitives::OpaqueKeyOwnershipProof, @@ -1745,7 +1741,7 @@ sp_api::impl_runtime_apis! { } fn submit_report_equivocation_unsigned_extrinsic( - equivocation_proof: babe_primitives::EquivocationProof<::Header>, + equivocation_proof: babe_primitives::EquivocationProof<::Header>, key_owner_proof: babe_primitives::OpaqueKeyOwnershipProof, ) -> Option<()> { let key_owner_proof = key_owner_proof.decode()?; diff --git a/utils/staking-miner/src/monitor.rs b/utils/staking-miner/src/monitor.rs index e578e1c83544..0f28ac0797a7 100644 --- a/utils/staking-miner/src/monitor.rs +++ b/utils/staking-miner/src/monitor.rs @@ -390,7 +390,7 @@ macro_rules! monitor_cmd_for { ($runtime:tt) => { paste::paste! { ); let events = match rpc.get_storage_and_decode::< - Vec::Hash>>, + Vec::Hash>>, >(&key, Some(hash)) .await { Ok(rp) => rp.unwrap_or_default(), diff --git a/xcm/pallet-xcm-benchmarks/src/fungible/mock.rs b/xcm/pallet-xcm-benchmarks/src/fungible/mock.rs index a8b50215e315..27ea9da572bc 100644 --- a/xcm/pallet-xcm-benchmarks/src/fungible/mock.rs +++ b/xcm/pallet-xcm-benchmarks/src/fungible/mock.rs @@ -25,21 +25,16 @@ use frame_support::{ }; use sp_core::H256; use sp_runtime::{ - testing::Header, traits::{BlakeTwo256, IdentityLookup}, }; use xcm::latest::prelude::*; use xcm_builder::{AllowUnpaidExecutionFrom, MintLocation}; -type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic; -type Block = frame_system::mocking::MockBlock; +type Block = frame_system::mocking::MockBlockU32; // For testing the pallet, we construct a mock runtime. frame_support::construct_runtime!( - pub enum Test where - Block = Block, - NodeBlock = Block, - UncheckedExtrinsic = UncheckedExtrinsic, + pub enum Test { System: frame_system::{Pallet, Call, Config, Storage, Event}, Balances: pallet_balances::{Pallet, Call, Storage, Config, Event}, @@ -48,7 +43,7 @@ frame_support::construct_runtime!( ); parameter_types! { - pub const BlockHashCount: u64 = 250; + pub const BlockHashCount: u32 = 250; pub BlockWeights: frame_system::limits::BlockWeights = frame_system::limits::BlockWeights::simple_max(Weight::from_parts(1024, u64::MAX)); } @@ -59,13 +54,12 @@ impl frame_system::Config for Test { type DbWeight = (); type RuntimeOrigin = RuntimeOrigin; type Index = u64; - type BlockNumber = u64; type Hash = H256; type RuntimeCall = RuntimeCall; type Hashing = BlakeTwo256; type AccountId = u64; type Lookup = IdentityLookup; - type Header = Header; + type Block = Block; type RuntimeEvent = RuntimeEvent; type BlockHashCount = BlockHashCount; type Version = (); diff --git a/xcm/pallet-xcm-benchmarks/src/generic/mock.rs b/xcm/pallet-xcm-benchmarks/src/generic/mock.rs index 5c2ca5ca7088..b95df70c631f 100644 --- a/xcm/pallet-xcm-benchmarks/src/generic/mock.rs +++ b/xcm/pallet-xcm-benchmarks/src/generic/mock.rs @@ -25,7 +25,6 @@ use frame_support::{ }; use sp_core::H256; use sp_runtime::{ - testing::Header, traits::{BlakeTwo256, IdentityLookup, TrailingZeroInput}, }; use xcm_builder::{ @@ -37,14 +36,10 @@ use xcm_builder::{ }; use xcm_executor::traits::ConvertOrigin; -type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic; -type Block = frame_system::mocking::MockBlock; +type Block = frame_system::mocking::MockBlockU32; frame_support::construct_runtime!( - pub enum Test where - Block = Block, - NodeBlock = Block, - UncheckedExtrinsic = UncheckedExtrinsic, + pub enum Test { System: frame_system::{Pallet, Call, Config, Storage, Event}, XcmGenericBenchmarks: generic::{Pallet}, @@ -52,7 +47,7 @@ frame_support::construct_runtime!( ); parameter_types! { - pub const BlockHashCount: u64 = 250; + pub const BlockHashCount: u32 = 250; pub BlockWeights: frame_system::limits::BlockWeights = frame_system::limits::BlockWeights::simple_max(Weight::from_parts(1024, u64::MAX)); } @@ -64,13 +59,12 @@ impl frame_system::Config for Test { type DbWeight = (); type RuntimeOrigin = RuntimeOrigin; type Index = u64; - type BlockNumber = u64; type Hash = H256; type RuntimeCall = RuntimeCall; type Hashing = BlakeTwo256; type AccountId = u64; type Lookup = IdentityLookup; - type Header = Header; + type Block = Block; type RuntimeEvent = RuntimeEvent; type BlockHashCount = BlockHashCount; type Version = (); diff --git a/xcm/pallet-xcm/src/lib.rs b/xcm/pallet-xcm/src/lib.rs index c53c9119bbd2..3262c7ecca67 100644 --- a/xcm/pallet-xcm/src/lib.rs +++ b/xcm/pallet-xcm/src/lib.rs @@ -180,7 +180,7 @@ pub mod pallet { /// A lockable currency. // TODO: We should really use a trait which can handle multiple currencies. - type Currency: LockableCurrency; + type Currency: LockableCurrency>; /// The `MultiAsset` matcher for `Currency`. type CurrencyMatcher: MatchesFungible>; @@ -508,7 +508,7 @@ pub mod pallet { #[pallet::storage] #[pallet::getter(fn query)] pub(super) type Queries = - StorageMap<_, Blake2_128Concat, QueryId, QueryStatus, OptionQuery>; + StorageMap<_, Blake2_128Concat, QueryId, QueryStatus>, OptionQuery>; /// The existing asset traps. /// @@ -741,7 +741,7 @@ pub mod pallet { if on_chain_storage_version < 1 { let mut count = 0; - Queries::::translate::, _>(|_key, value| { + Queries::::translate::>, _>(|_key, value| { count += 1; Some(value.into()) }); @@ -1128,14 +1128,14 @@ const MAX_ASSETS_FOR_TRANSFER: usize = 2; impl QueryHandler for Pallet { type QueryId = u64; - type BlockNumber = T::BlockNumber; + type BlockNumber = frame_system::BlockNumberOf; type Error = XcmError; type UniversalLocation = T::UniversalLocation; /// Attempt to create a new query ID and register it as a query that is yet to respond. fn new_query( responder: impl Into, - timeout: T::BlockNumber, + timeout: frame_system::BlockNumberOf, match_querier: impl Into, ) -> Self::QueryId { Self::do_new_query(responder, None, timeout, match_querier).into() @@ -1538,7 +1538,7 @@ impl Pallet { fn do_new_query( responder: impl Into, maybe_notify: Option<(u8, u8)>, - timeout: T::BlockNumber, + timeout: frame_system::BlockNumberOf, match_querier: impl Into, ) -> u64 { QueryCounter::::mutate(|q| { @@ -1583,7 +1583,7 @@ impl Pallet { message: &mut Xcm<()>, responder: impl Into, notify: impl Into<::RuntimeCall>, - timeout: T::BlockNumber, + timeout: frame_system::BlockNumberOf, ) -> Result<(), XcmError> { let responder = responder.into(); let destination = T::UniversalLocation::get() @@ -1603,7 +1603,7 @@ impl Pallet { pub fn new_notify_query( responder: impl Into, notify: impl Into<::RuntimeCall>, - timeout: T::BlockNumber, + timeout: frame_system::BlockNumberOf, match_querier: impl Into, ) -> u64 { let notify = notify.into().using_encoded(|mut bytes| Decode::decode(&mut bytes)).expect( diff --git a/xcm/pallet-xcm/src/mock.rs b/xcm/pallet-xcm/src/mock.rs index 2d3cc385c230..6661a968dd65 100644 --- a/xcm/pallet-xcm/src/mock.rs +++ b/xcm/pallet-xcm/src/mock.rs @@ -24,7 +24,7 @@ use frame_system::EnsureRoot; use polkadot_parachain::primitives::Id as ParaId; use polkadot_runtime_parachains::origin; use sp_core::H256; -use sp_runtime::{testing::Header, traits::IdentityLookup, AccountId32}; +use sp_runtime::{traits::IdentityLookup, AccountId32}; pub use sp_std::{cell::RefCell, fmt::Debug, marker::PhantomData}; use xcm::prelude::*; use xcm_builder::{ @@ -40,8 +40,7 @@ use crate::{self as pallet_xcm, TestWeightInfo}; pub type AccountId = AccountId32; pub type Balance = u128; -type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic; -type Block = frame_system::mocking::MockBlock; +type Block = frame_system::mocking::MockBlockU32; #[frame_support::pallet] pub mod pallet_test_notifier { @@ -132,10 +131,7 @@ pub mod pallet_test_notifier { } construct_runtime!( - pub enum Test where - Block = Block, - NodeBlock = Block, - UncheckedExtrinsic = UncheckedExtrinsic, + pub enum Test { System: frame_system::{Pallet, Call, Storage, Config, Event}, Balances: pallet_balances::{Pallet, Call, Storage, Config, Event}, @@ -198,19 +194,18 @@ impl SendXcm for TestSendXcmErrX8 { } parameter_types! { - pub const BlockHashCount: u64 = 250; + pub const BlockHashCount: u32 = 250; } impl frame_system::Config for Test { type RuntimeOrigin = RuntimeOrigin; type RuntimeCall = RuntimeCall; type Index = u64; - type BlockNumber = u64; type Hash = H256; type Hashing = ::sp_runtime::traits::BlakeTwo256; type AccountId = AccountId; type Lookup = IdentityLookup; - type Header = Header; + type Block = Block; type RuntimeEvent = RuntimeEvent; type BlockHashCount = BlockHashCount; type BlockWeights = (); diff --git a/xcm/xcm-builder/tests/mock/mod.rs b/xcm/xcm-builder/tests/mock/mod.rs index 6c2c8f222add..0b7a240b1486 100644 --- a/xcm/xcm-builder/tests/mock/mod.rs +++ b/xcm/xcm-builder/tests/mock/mod.rs @@ -22,7 +22,7 @@ use frame_support::{ use frame_system::EnsureRoot; use parity_scale_codec::Encode; use primitive_types::H256; -use sp_runtime::{testing::Header, traits::IdentityLookup, AccountId32}; +use sp_runtime::{traits::IdentityLookup, AccountId32}; use sp_std::cell::RefCell; use polkadot_parachain::primitives::Id as ParaId; @@ -71,19 +71,18 @@ pub const UNITS: Balance = 1_000_000_000_000; pub const CENTS: Balance = UNITS / 30_000; parameter_types! { - pub const BlockHashCount: u64 = 250; + pub const BlockHashCount: u32 = 250; } impl frame_system::Config for Runtime { type RuntimeOrigin = RuntimeOrigin; type RuntimeCall = RuntimeCall; type Index = u64; - type BlockNumber = u64; type Hash = H256; type Hashing = ::sp_runtime::traits::BlakeTwo256; type AccountId = AccountId; type Lookup = IdentityLookup; - type Header = Header; + type Block = Block; type RuntimeEvent = RuntimeEvent; type BlockHashCount = BlockHashCount; type BlockWeights = (); @@ -244,14 +243,10 @@ impl pallet_xcm::Config for Runtime { impl origin::Config for Runtime {} -type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic; -type Block = frame_system::mocking::MockBlock; +type Block = frame_system::mocking::MockBlockU32; construct_runtime!( - pub enum Runtime where - Block = Block, - NodeBlock = Block, - UncheckedExtrinsic = UncheckedExtrinsic, + pub enum Runtime { System: frame_system::{Pallet, Call, Storage, Config, Event}, Balances: pallet_balances::{Pallet, Call, Storage, Config, Event}, diff --git a/xcm/xcm-simulator/example/src/parachain.rs b/xcm/xcm-simulator/example/src/parachain.rs index 875904ddecd9..9d67be9dff07 100644 --- a/xcm/xcm-simulator/example/src/parachain.rs +++ b/xcm/xcm-simulator/example/src/parachain.rs @@ -27,7 +27,6 @@ use frame_support::{ use frame_system::EnsureRoot; use sp_core::{ConstU32, H256}; use sp_runtime::{ - testing::Header, traits::{Get, Hash, IdentityLookup}, AccountId32, }; @@ -61,19 +60,18 @@ pub type AccountId = AccountId32; pub type Balance = u128; parameter_types! { - pub const BlockHashCount: u64 = 250; + pub const BlockHashCount: u32 = 250; } impl frame_system::Config for Runtime { type RuntimeOrigin = RuntimeOrigin; type RuntimeCall = RuntimeCall; type Index = u64; - type BlockNumber = u64; type Hash = H256; type Hashing = ::sp_runtime::traits::BlakeTwo256; type AccountId = AccountId; type Lookup = IdentityLookup; - type Header = Header; + type Block = Block; type RuntimeEvent = RuntimeEvent; type BlockHashCount = BlockHashCount; type BlockWeights = (); @@ -449,14 +447,10 @@ impl pallet_xcm::Config for Runtime { type AdminOrigin = EnsureRoot; } -type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic; -type Block = frame_system::mocking::MockBlock; +type Block = frame_system::mocking::MockBlockU32; construct_runtime!( - pub enum Runtime where - Block = Block, - NodeBlock = Block, - UncheckedExtrinsic = UncheckedExtrinsic, + pub enum Runtime { System: frame_system::{Pallet, Call, Storage, Config, Event}, Balances: pallet_balances::{Pallet, Call, Storage, Config, Event}, diff --git a/xcm/xcm-simulator/example/src/relay_chain.rs b/xcm/xcm-simulator/example/src/relay_chain.rs index 6f64249b40fc..7f7390633204 100644 --- a/xcm/xcm-simulator/example/src/relay_chain.rs +++ b/xcm/xcm-simulator/example/src/relay_chain.rs @@ -24,7 +24,7 @@ use frame_support::{ use frame_system::EnsureRoot; 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_runtime_parachains::{ @@ -46,19 +46,18 @@ pub type AccountId = AccountId32; pub type Balance = u128; parameter_types! { - pub const BlockHashCount: u64 = 250; + pub const BlockHashCount: u32 = 250; } impl frame_system::Config for Runtime { type RuntimeOrigin = RuntimeOrigin; type RuntimeCall = RuntimeCall; type Index = u64; - type BlockNumber = u64; type Hash = H256; type Hashing = ::sp_runtime::traits::BlakeTwo256; type AccountId = AccountId; type Lookup = IdentityLookup; - type Header = Header; + type Block = Block; type RuntimeEvent = RuntimeEvent; type BlockHashCount = BlockHashCount; type BlockWeights = (); @@ -239,8 +238,7 @@ parameter_types! { impl origin::Config for Runtime {} -type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic; -type Block = frame_system::mocking::MockBlock; +type Block = frame_system::mocking::MockBlockU32; parameter_types! { /// Amount of weight that can be spent per block to service messages. @@ -283,10 +281,7 @@ impl pallet_message_queue::Config for Runtime { } construct_runtime!( - pub enum Runtime where - Block = Block, - NodeBlock = Block, - UncheckedExtrinsic = UncheckedExtrinsic, + pub enum Runtime { System: frame_system::{Pallet, Call, Storage, Config, Event}, Balances: pallet_balances::{Pallet, Call, Storage, Config, Event}, diff --git a/xcm/xcm-simulator/fuzzer/src/parachain.rs b/xcm/xcm-simulator/fuzzer/src/parachain.rs index 26438f02f45f..cd1ad2ea569d 100644 --- a/xcm/xcm-simulator/fuzzer/src/parachain.rs +++ b/xcm/xcm-simulator/fuzzer/src/parachain.rs @@ -26,7 +26,6 @@ use frame_support::{ use frame_system::EnsureRoot; use sp_core::{ConstU32, H256}; use sp_runtime::{ - testing::Header, traits::{Hash, IdentityLookup}, AccountId32, }; @@ -50,19 +49,18 @@ pub type AccountId = AccountId32; pub type Balance = u128; parameter_types! { - pub const BlockHashCount: u64 = 250; + pub const BlockHashCount: u32 = 250; } impl frame_system::Config for Runtime { type RuntimeOrigin = RuntimeOrigin; type RuntimeCall = RuntimeCall; type Index = u64; - type BlockNumber = u64; type Hash = H256; type Hashing = ::sp_runtime::traits::BlakeTwo256; type AccountId = AccountId; type Lookup = IdentityLookup; - type Header = Header; + type Block = Block; type RuntimeEvent = RuntimeEvent; type BlockHashCount = BlockHashCount; type BlockWeights = (); @@ -347,14 +345,10 @@ impl pallet_xcm::Config for Runtime { type AdminOrigin = EnsureRoot; } -type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic; -type Block = frame_system::mocking::MockBlock; +type Block = frame_system::mocking::MockBlockU32; construct_runtime!( - pub enum Runtime where - Block = Block, - NodeBlock = Block, - UncheckedExtrinsic = UncheckedExtrinsic, + pub enum Runtime { System: frame_system::{Pallet, Call, Storage, Config, Event}, Balances: pallet_balances::{Pallet, Call, Storage, Config, Event}, diff --git a/xcm/xcm-simulator/fuzzer/src/relay_chain.rs b/xcm/xcm-simulator/fuzzer/src/relay_chain.rs index 75b42e300316..4cca6ce5ba4f 100644 --- a/xcm/xcm-simulator/fuzzer/src/relay_chain.rs +++ b/xcm/xcm-simulator/fuzzer/src/relay_chain.rs @@ -24,7 +24,7 @@ use frame_support::{ use frame_system::EnsureRoot; 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_runtime_parachains::{ @@ -45,19 +45,18 @@ pub type AccountId = AccountId32; pub type Balance = u128; parameter_types! { - pub const BlockHashCount: u64 = 250; + pub const BlockHashCount: u32 = 250; } impl frame_system::Config for Runtime { type RuntimeOrigin = RuntimeOrigin; type RuntimeCall = RuntimeCall; type Index = u64; - type BlockNumber = u64; type Hash = H256; type Hashing = ::sp_runtime::traits::BlakeTwo256; type AccountId = AccountId; type Lookup = IdentityLookup; - type Header = Header; + type Block = Block; type RuntimeEvent = RuntimeEvent; type BlockHashCount = BlockHashCount; type BlockWeights = (); @@ -203,8 +202,7 @@ parameter_types! { impl origin::Config for Runtime {} -type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic; -type Block = frame_system::mocking::MockBlock; +type Block = frame_system::mocking::MockBlockU32; parameter_types! { /// Amount of weight that can be spent per block to service messages. @@ -251,10 +249,7 @@ impl pallet_message_queue::Config for Runtime { } construct_runtime!( - pub enum Runtime where - Block = Block, - NodeBlock = Block, - UncheckedExtrinsic = UncheckedExtrinsic, + pub enum Runtime { System: frame_system::{Pallet, Call, Storage, Config, Event}, Balances: pallet_balances::{Pallet, Call, Storage, Config, Event},