Replace 'Module' with 'Pallet' in construct_runtime macro (#8372)

* Use 'Pallet' struct in construct_runtime.

* Fix genesis and metadata macro.

* Fix 'Pallet' type alias.

* Replace 'Module' with 'Pallet' for all construct_runtime use cases.

* Replace more deprecated 'Module' struct.

* Bring back AllModules and AllPalletsWithSystem type, but deprecate them.

* Replace deprecated 'Module' struct from merge master.

* Minor fix.

* Fix UI tests.

* Revert UI override in derive_no_bound.

* Fix more deprecated 'Module' use from master branch.

* Fix more deprecated 'Module' use from master branch.
This commit is contained in:
Shaun Wang
2021-03-18 21:50:08 +13:00
committed by GitHub
parent 05f24931a9
commit 2e5522444a
157 changed files with 881 additions and 864 deletions
@@ -16,8 +16,8 @@ frame_support::construct_runtime!(
NodeBlock = Block, NodeBlock = Block,
UncheckedExtrinsic = UncheckedExtrinsic, UncheckedExtrinsic = UncheckedExtrinsic,
{ {
System: frame_system::{Module, Call, Config, Storage, Event<T>}, System: frame_system::{Pallet, Call, Config, Storage, Event<T>},
TemplateModule: pallet_template::{Module, Call, Storage, Event<T>}, TemplateModule: pallet_template::{Pallet, Call, Storage, Event<T>},
} }
); );
+11 -11
View File
@@ -270,16 +270,16 @@ construct_runtime!(
NodeBlock = opaque::Block, NodeBlock = opaque::Block,
UncheckedExtrinsic = UncheckedExtrinsic UncheckedExtrinsic = UncheckedExtrinsic
{ {
System: frame_system::{Module, Call, Config, Storage, Event<T>}, System: frame_system::{Pallet, Call, Config, Storage, Event<T>},
RandomnessCollectiveFlip: pallet_randomness_collective_flip::{Module, Call, Storage}, RandomnessCollectiveFlip: pallet_randomness_collective_flip::{Pallet, Call, Storage},
Timestamp: pallet_timestamp::{Module, Call, Storage, Inherent}, Timestamp: pallet_timestamp::{Pallet, Call, Storage, Inherent},
Aura: pallet_aura::{Module, Config<T>}, Aura: pallet_aura::{Pallet, Config<T>},
Grandpa: pallet_grandpa::{Module, Call, Storage, Config, Event}, Grandpa: pallet_grandpa::{Pallet, Call, Storage, Config, Event},
Balances: pallet_balances::{Module, Call, Storage, Config<T>, Event<T>}, Balances: pallet_balances::{Pallet, Call, Storage, Config<T>, Event<T>},
TransactionPayment: pallet_transaction_payment::{Module, Storage}, TransactionPayment: pallet_transaction_payment::{Pallet, Storage},
Sudo: pallet_sudo::{Module, Call, Config<T>, Storage, Event<T>}, Sudo: pallet_sudo::{Pallet, Call, Config<T>, Storage, Event<T>},
// Include the custom logic from the template pallet in the runtime. // Include the custom logic from the template pallet in the runtime.
TemplateModule: template::{Module, Call, Storage, Event<T>}, TemplateModule: template::{Pallet, Call, Storage, Event<T>},
} }
); );
@@ -313,7 +313,7 @@ pub type Executive = frame_executive::Executive<
Block, Block,
frame_system::ChainContext<Runtime>, frame_system::ChainContext<Runtime>,
Runtime, Runtime,
AllModules, AllPallets,
>; >;
impl_runtime_apis! { impl_runtime_apis! {
@@ -453,7 +453,7 @@ impl_runtime_apis! {
) -> Result<Vec<frame_benchmarking::BenchmarkBatch>, sp_runtime::RuntimeString> { ) -> Result<Vec<frame_benchmarking::BenchmarkBatch>, sp_runtime::RuntimeString> {
use frame_benchmarking::{Benchmarking, BenchmarkBatch, add_benchmark, TrackedStorageKey}; use frame_benchmarking::{Benchmarking, BenchmarkBatch, add_benchmark, TrackedStorageKey};
use frame_system_benchmarking::Module as SystemBench; use frame_system_benchmarking::Pallet as SystemBench;
impl frame_system_benchmarking::Config for Runtime {} impl frame_system_benchmarking::Config for Runtime {}
let whitelist: Vec<TrackedStorageKey> = vec![ let whitelist: Vec<TrackedStorageKey> = vec![
+2 -2
View File
@@ -600,13 +600,13 @@ fn deploying_wasm_contract_should_work() {
let transfer_code = wat::parse_str(CODE_TRANSFER).unwrap(); let transfer_code = wat::parse_str(CODE_TRANSFER).unwrap();
let transfer_ch = <Runtime as frame_system::Config>::Hashing::hash(&transfer_code); let transfer_ch = <Runtime as frame_system::Config>::Hashing::hash(&transfer_code);
let addr = pallet_contracts::Module::<Runtime>::contract_address( let addr = pallet_contracts::Pallet::<Runtime>::contract_address(
&charlie(), &charlie(),
&transfer_ch, &transfer_ch,
&[], &[],
); );
let subsistence = pallet_contracts::Module::<Runtime>::subsistence_threshold(); let subsistence = pallet_contracts::Pallet::<Runtime>::subsistence_threshold();
let time = 42 * 1000; let time = 42 * 1000;
let b = construct_block( let b = construct_block(
+44 -44
View File
@@ -379,7 +379,7 @@ impl pallet_balances::Config for Runtime {
type DustRemoval = (); type DustRemoval = ();
type Event = Event; type Event = Event;
type ExistentialDeposit = ExistentialDeposit; type ExistentialDeposit = ExistentialDeposit;
type AccountStore = frame_system::Module<Runtime>; type AccountStore = frame_system::Pallet<Runtime>;
type WeightInfo = pallet_balances::weights::SubstrateWeight<Runtime>; type WeightInfo = pallet_balances::weights::SubstrateWeight<Runtime>;
} }
@@ -1005,7 +1005,7 @@ impl pallet_mmr::Config for Runtime {
const INDEXING_PREFIX: &'static [u8] = b"mmr"; const INDEXING_PREFIX: &'static [u8] = b"mmr";
type Hashing = <Runtime as frame_system::Config>::Hashing; type Hashing = <Runtime as frame_system::Config>::Hashing;
type Hash = <Runtime as frame_system::Config>::Hash; type Hash = <Runtime as frame_system::Config>::Hash;
type LeafData = frame_system::Module<Self>; type LeafData = frame_system::Pallet<Self>;
type OnNewRoot = (); type OnNewRoot = ();
type WeightInfo = (); type WeightInfo = ();
} }
@@ -1086,44 +1086,44 @@ construct_runtime!(
NodeBlock = node_primitives::Block, NodeBlock = node_primitives::Block,
UncheckedExtrinsic = UncheckedExtrinsic UncheckedExtrinsic = UncheckedExtrinsic
{ {
System: frame_system::{Module, Call, Config, Storage, Event<T>}, System: frame_system::{Pallet, Call, Config, Storage, Event<T>},
Utility: pallet_utility::{Module, Call, Event}, Utility: pallet_utility::{Pallet, Call, Event},
Babe: pallet_babe::{Module, Call, Storage, Config, ValidateUnsigned}, Babe: pallet_babe::{Pallet, Call, Storage, Config, ValidateUnsigned},
Timestamp: pallet_timestamp::{Module, Call, Storage, Inherent}, Timestamp: pallet_timestamp::{Pallet, Call, Storage, Inherent},
Authorship: pallet_authorship::{Module, Call, Storage, Inherent}, Authorship: pallet_authorship::{Pallet, Call, Storage, Inherent},
Indices: pallet_indices::{Module, Call, Storage, Config<T>, Event<T>}, Indices: pallet_indices::{Pallet, Call, Storage, Config<T>, Event<T>},
Balances: pallet_balances::{Module, Call, Storage, Config<T>, Event<T>}, Balances: pallet_balances::{Pallet, Call, Storage, Config<T>, Event<T>},
TransactionPayment: pallet_transaction_payment::{Module, Storage}, TransactionPayment: pallet_transaction_payment::{Pallet, Storage},
ElectionProviderMultiPhase: pallet_election_provider_multi_phase::{Module, Call, Storage, Event<T>, ValidateUnsigned}, ElectionProviderMultiPhase: pallet_election_provider_multi_phase::{Pallet, Call, Storage, Event<T>, ValidateUnsigned},
Staking: pallet_staking::{Module, Call, Config<T>, Storage, Event<T>, ValidateUnsigned}, Staking: pallet_staking::{Pallet, Call, Config<T>, Storage, Event<T>, ValidateUnsigned},
Session: pallet_session::{Module, Call, Storage, Event, Config<T>}, Session: pallet_session::{Pallet, Call, Storage, Event, Config<T>},
Democracy: pallet_democracy::{Module, Call, Storage, Config, Event<T>}, Democracy: pallet_democracy::{Pallet, Call, Storage, Config, Event<T>},
Council: pallet_collective::<Instance1>::{Module, Call, Storage, Origin<T>, Event<T>, Config<T>}, Council: pallet_collective::<Instance1>::{Pallet, Call, Storage, Origin<T>, Event<T>, Config<T>},
TechnicalCommittee: pallet_collective::<Instance2>::{Module, Call, Storage, Origin<T>, Event<T>, Config<T>}, TechnicalCommittee: pallet_collective::<Instance2>::{Pallet, Call, Storage, Origin<T>, Event<T>, Config<T>},
Elections: pallet_elections_phragmen::{Module, Call, Storage, Event<T>, Config<T>}, Elections: pallet_elections_phragmen::{Pallet, Call, Storage, Event<T>, Config<T>},
TechnicalMembership: pallet_membership::<Instance1>::{Module, Call, Storage, Event<T>, Config<T>}, TechnicalMembership: pallet_membership::<Instance1>::{Pallet, Call, Storage, Event<T>, Config<T>},
Grandpa: pallet_grandpa::{Module, Call, Storage, Config, Event, ValidateUnsigned}, Grandpa: pallet_grandpa::{Pallet, Call, Storage, Config, Event, ValidateUnsigned},
Treasury: pallet_treasury::{Module, Call, Storage, Config, Event<T>}, Treasury: pallet_treasury::{Pallet, Call, Storage, Config, Event<T>},
Contracts: pallet_contracts::{Module, Call, Config<T>, Storage, Event<T>}, Contracts: pallet_contracts::{Pallet, Call, Config<T>, Storage, Event<T>},
Sudo: pallet_sudo::{Module, Call, Config<T>, Storage, Event<T>}, Sudo: pallet_sudo::{Pallet, Call, Config<T>, Storage, Event<T>},
ImOnline: pallet_im_online::{Module, Call, Storage, Event<T>, ValidateUnsigned, Config<T>}, ImOnline: pallet_im_online::{Pallet, Call, Storage, Event<T>, ValidateUnsigned, Config<T>},
AuthorityDiscovery: pallet_authority_discovery::{Module, Call, Config}, AuthorityDiscovery: pallet_authority_discovery::{Pallet, Call, Config},
Offences: pallet_offences::{Module, Call, Storage, Event}, Offences: pallet_offences::{Pallet, Call, Storage, Event},
Historical: pallet_session_historical::{Module}, Historical: pallet_session_historical::{Pallet},
RandomnessCollectiveFlip: pallet_randomness_collective_flip::{Module, Call, Storage}, RandomnessCollectiveFlip: pallet_randomness_collective_flip::{Pallet, Call, Storage},
Identity: pallet_identity::{Module, Call, Storage, Event<T>}, Identity: pallet_identity::{Pallet, Call, Storage, Event<T>},
Society: pallet_society::{Module, Call, Storage, Event<T>, Config<T>}, Society: pallet_society::{Pallet, Call, Storage, Event<T>, Config<T>},
Recovery: pallet_recovery::{Module, Call, Storage, Event<T>}, Recovery: pallet_recovery::{Pallet, Call, Storage, Event<T>},
Vesting: pallet_vesting::{Module, Call, Storage, Event<T>, Config<T>}, Vesting: pallet_vesting::{Pallet, Call, Storage, Event<T>, Config<T>},
Scheduler: pallet_scheduler::{Module, Call, Storage, Event<T>}, Scheduler: pallet_scheduler::{Pallet, Call, Storage, Event<T>},
Proxy: pallet_proxy::{Module, Call, Storage, Event<T>}, Proxy: pallet_proxy::{Pallet, Call, Storage, Event<T>},
Multisig: pallet_multisig::{Module, Call, Storage, Event<T>}, Multisig: pallet_multisig::{Pallet, Call, Storage, Event<T>},
Bounties: pallet_bounties::{Module, Call, Storage, Event<T>}, Bounties: pallet_bounties::{Pallet, Call, Storage, Event<T>},
Tips: pallet_tips::{Module, Call, Storage, Event<T>}, Tips: pallet_tips::{Pallet, Call, Storage, Event<T>},
Assets: pallet_assets::{Module, Call, Storage, Event<T>}, Assets: pallet_assets::{Pallet, Call, Storage, Event<T>},
Mmr: pallet_mmr::{Module, Storage}, Mmr: pallet_mmr::{Pallet, Storage},
Lottery: pallet_lottery::{Module, Call, Storage, Event<T>}, Lottery: pallet_lottery::{Pallet, Call, Storage, Event<T>},
Gilt: pallet_gilt::{Module, Call, Storage, Event<T>, Config}, Gilt: pallet_gilt::{Pallet, Call, Storage, Event<T>, Config},
} }
); );
@@ -1163,7 +1163,7 @@ pub type Executive = frame_executive::Executive<
Block, Block,
frame_system::ChainContext<Runtime>, frame_system::ChainContext<Runtime>,
Runtime, Runtime,
AllModules, AllPallets,
(), (),
>; >;
@@ -1435,9 +1435,9 @@ impl_runtime_apis! {
// Trying to add benchmarks directly to the Session Pallet caused cyclic dependency // Trying to add benchmarks directly to the Session Pallet caused cyclic dependency
// issues. To get around that, we separated the Session benchmarks into its own crate, // issues. To get around that, we separated the Session benchmarks into its own crate,
// which is why we need these two lines below. // which is why we need these two lines below.
use pallet_session_benchmarking::Module as SessionBench; use pallet_session_benchmarking::Pallet as SessionBench;
use pallet_offences_benchmarking::Module as OffencesBench; use pallet_offences_benchmarking::Pallet as OffencesBench;
use frame_system_benchmarking::Module as SystemBench; use frame_system_benchmarking::Pallet as SystemBench;
impl pallet_session_benchmarking::Config for Runtime {} impl pallet_session_benchmarking::Config for Runtime {}
impl pallet_offences_benchmarking::Config for Runtime {} impl pallet_offences_benchmarking::Config for Runtime {}
+3 -3
View File
@@ -29,7 +29,7 @@ use frame_benchmarking::{
use frame_support::traits::Get; use frame_support::traits::Get;
use frame_support::{traits::EnsureOrigin, dispatch::UnfilteredDispatchable}; use frame_support::{traits::EnsureOrigin, dispatch::UnfilteredDispatchable};
use crate::Module as Assets; use crate::Pallet as Assets;
const SEED: u32 = 0; const SEED: u32 = 0;
@@ -120,7 +120,7 @@ fn add_approvals<T: Config>(minter: T::AccountId, n: u32) {
} }
fn assert_last_event<T: Config>(generic_event: <T as Config>::Event) { fn assert_last_event<T: Config>(generic_event: <T as Config>::Event) {
let events = frame_system::Module::<T>::events(); let events = frame_system::Pallet::<T>::events();
let system_event: <T as frame_system::Config>::Event = generic_event.into(); let system_event: <T as frame_system::Config>::Event = generic_event.into();
// compare to the last event record // compare to the last event record
let frame_system::EventRecord { event, .. } = &events[events.len() - 1]; let frame_system::EventRecord { event, .. } = &events[events.len() - 1];
@@ -193,7 +193,7 @@ benchmarks! {
let target_lookup = T::Lookup::unlookup(target.clone()); let target_lookup = T::Lookup::unlookup(target.clone());
}: _(SystemOrigin::Signed(caller.clone()), Default::default(), target_lookup, amount) }: _(SystemOrigin::Signed(caller.clone()), Default::default(), target_lookup, amount)
verify { verify {
assert!(frame_system::Module::<T>::account_exists(&caller)); assert!(frame_system::Pallet::<T>::account_exists(&caller));
assert_last_event::<T>(Event::Transferred(Default::default(), caller, target, amount).into()); assert_last_event::<T>(Event::Transferred(Default::default(), caller, target, amount).into());
} }
+4 -4
View File
@@ -1375,11 +1375,11 @@ impl<T: Config> Pallet<T> {
) -> Result<bool, DispatchError> { ) -> Result<bool, DispatchError> {
let accounts = d.accounts.checked_add(1).ok_or(Error::<T>::Overflow)?; let accounts = d.accounts.checked_add(1).ok_or(Error::<T>::Overflow)?;
let is_sufficient = if d.is_sufficient { let is_sufficient = if d.is_sufficient {
frame_system::Module::<T>::inc_sufficients(who); frame_system::Pallet::<T>::inc_sufficients(who);
d.sufficients += 1; d.sufficients += 1;
true true
} else { } else {
frame_system::Module::<T>::inc_consumers(who).map_err(|_| Error::<T>::NoProvider)?; frame_system::Pallet::<T>::inc_consumers(who).map_err(|_| Error::<T>::NoProvider)?;
false false
}; };
d.accounts = accounts; d.accounts = accounts;
@@ -1393,9 +1393,9 @@ impl<T: Config> Pallet<T> {
) { ) {
if sufficient { if sufficient {
d.sufficients = d.sufficients.saturating_sub(1); d.sufficients = d.sufficients.saturating_sub(1);
frame_system::Module::<T>::dec_sufficients(who); frame_system::Pallet::<T>::dec_sufficients(who);
} else { } else {
frame_system::Module::<T>::dec_consumers(who); frame_system::Pallet::<T>::dec_consumers(who);
} }
d.accounts = d.accounts.saturating_sub(1); d.accounts = d.accounts.saturating_sub(1);
} }
+3 -3
View File
@@ -33,9 +33,9 @@ construct_runtime!(
NodeBlock = Block, NodeBlock = Block,
UncheckedExtrinsic = UncheckedExtrinsic, UncheckedExtrinsic = UncheckedExtrinsic,
{ {
System: frame_system::{Module, Call, Config, Storage, Event<T>}, System: frame_system::{Pallet, Call, Config, Storage, Event<T>},
Balances: pallet_balances::{Module, Call, Storage, Config<T>, Event<T>}, Balances: pallet_balances::{Pallet, Call, Storage, Config<T>, Event<T>},
Assets: pallet_assets::{Module, Call, Storage, Event<T>}, Assets: pallet_assets::{Pallet, Call, Storage, Event<T>},
} }
); );
+1 -1
View File
@@ -23,7 +23,7 @@ use frame_support::{assert_ok, assert_noop, traits::Currency};
use pallet_balances::Error as BalancesError; use pallet_balances::Error as BalancesError;
fn last_event() -> mock::Event { fn last_event() -> mock::Event {
frame_system::Module::<Test>::events().pop().expect("Event expected").event frame_system::Pallet::<Test>::events().pop().expect("Event expected").event
} }
#[test] #[test]
+2 -2
View File
@@ -237,7 +237,7 @@ decl_module! {
let swap = PendingSwap { let swap = PendingSwap {
source, source,
action, action,
end_block: frame_system::Module::<T>::block_number() + duration, end_block: frame_system::Pallet::<T>::block_number() + duration,
}; };
PendingSwaps::<T>::insert(target.clone(), hashed_proof.clone(), swap.clone()); PendingSwaps::<T>::insert(target.clone(), hashed_proof.clone(), swap.clone());
@@ -307,7 +307,7 @@ decl_module! {
Error::<T>::SourceMismatch, Error::<T>::SourceMismatch,
); );
ensure!( ensure!(
frame_system::Module::<T>::block_number() >= swap.end_block, frame_system::Pallet::<T>::block_number() >= swap.end_block,
Error::<T>::DurationNotPassed, Error::<T>::DurationNotPassed,
); );
+3 -3
View File
@@ -19,9 +19,9 @@ frame_support::construct_runtime!(
NodeBlock = Block, NodeBlock = Block,
UncheckedExtrinsic = UncheckedExtrinsic, UncheckedExtrinsic = UncheckedExtrinsic,
{ {
System: frame_system::{Module, Call, Config, Storage, Event<T>}, System: frame_system::{Pallet, Call, Config, Storage, Event<T>},
Balances: pallet_balances::{Module, Call, Storage, Config<T>, Event<T>}, Balances: pallet_balances::{Pallet, Call, Storage, Config<T>, Event<T>},
AtomicSwap: pallet_atomic_swap::{Module, Call, Event<T>}, AtomicSwap: pallet_atomic_swap::{Pallet, Call, Event<T>},
} }
); );
+2 -2
View File
@@ -130,7 +130,7 @@ impl<T: Config> Pallet<T> {
AURA_ENGINE_ID, AURA_ENGINE_ID,
ConsensusLog::AuthoritiesChange(new).encode() ConsensusLog::AuthoritiesChange(new).encode()
); );
<frame_system::Module<T>>::deposit_log(log.into()); <frame_system::Pallet<T>>::deposit_log(log.into());
} }
fn initialize_authorities(authorities: &[T::AuthorityId]) { fn initialize_authorities(authorities: &[T::AuthorityId]) {
@@ -194,7 +194,7 @@ impl<T: Config> OneSessionHandler<T::AccountId> for Pallet<T> {
ConsensusLog::<T::AuthorityId>::OnDisabled(i as AuthorityIndex).encode(), ConsensusLog::<T::AuthorityId>::OnDisabled(i as AuthorityIndex).encode(),
); );
<frame_system::Module<T>>::deposit_log(log.into()); <frame_system::Pallet<T>>::deposit_log(log.into());
} }
} }
+3 -3
View File
@@ -34,9 +34,9 @@ frame_support::construct_runtime!(
NodeBlock = Block, NodeBlock = Block,
UncheckedExtrinsic = UncheckedExtrinsic, UncheckedExtrinsic = UncheckedExtrinsic,
{ {
System: frame_system::{Module, Call, Config, Storage, Event<T>}, System: frame_system::{Pallet, Call, Config, Storage, Event<T>},
Timestamp: pallet_timestamp::{Module, Call, Storage, Inherent}, Timestamp: pallet_timestamp::{Pallet, Call, Storage, Inherent},
Aura: pallet_aura::{Module, Call, Storage, Config<T>}, Aura: pallet_aura::{Pallet, Call, Storage, Config<T>},
} }
); );
@@ -136,9 +136,9 @@ mod tests {
NodeBlock = Block, NodeBlock = Block,
UncheckedExtrinsic = UncheckedExtrinsic, UncheckedExtrinsic = UncheckedExtrinsic,
{ {
System: frame_system::{Module, Call, Config, Storage, Event<T>}, System: frame_system::{Pallet, Call, Config, Storage, Event<T>},
Session: pallet_session::{Module, Call, Storage, Event, Config<T>}, Session: pallet_session::{Pallet, Call, Storage, Event, Config<T>},
AuthorityDiscovery: pallet_authority_discovery::{Module, Call, Config}, AuthorityDiscovery: pallet_authority_discovery::{Pallet, Call, Config},
} }
); );
+7 -7
View File
@@ -234,7 +234,7 @@ impl<T: Config> Module<T> {
return author; return author;
} }
let digest = <frame_system::Module<T>>::digest(); let digest = <frame_system::Pallet<T>>::digest();
let pre_runtime_digests = digest.logs.iter().filter_map(|d| d.as_pre_runtime()); let pre_runtime_digests = digest.logs.iter().filter_map(|d| d.as_pre_runtime());
if let Some(author) = T::FindAuthor::find_author(pre_runtime_digests) { if let Some(author) = T::FindAuthor::find_author(pre_runtime_digests) {
<Self as Store>::Author::put(&author); <Self as Store>::Author::put(&author);
@@ -245,7 +245,7 @@ impl<T: Config> Module<T> {
} }
fn verify_and_import_uncles(new_uncles: Vec<T::Header>) -> dispatch::DispatchResult { fn verify_and_import_uncles(new_uncles: Vec<T::Header>) -> dispatch::DispatchResult {
let now = <frame_system::Module<T>>::block_number(); let now = <frame_system::Pallet<T>>::block_number();
let mut uncles = <Self as Store>::Uncles::get(); let mut uncles = <Self as Store>::Uncles::get();
uncles.push(UncleEntryItem::InclusionHeight(now)); uncles.push(UncleEntryItem::InclusionHeight(now));
@@ -278,7 +278,7 @@ impl<T: Config> Module<T> {
accumulator: &mut <T::FilterUncle as FilterUncle<T::Header, T::AccountId>>::Accumulator, accumulator: &mut <T::FilterUncle as FilterUncle<T::Header, T::AccountId>>::Accumulator,
) -> Result<Option<T::AccountId>, dispatch::DispatchError> ) -> Result<Option<T::AccountId>, dispatch::DispatchError>
{ {
let now = <frame_system::Module<T>>::block_number(); let now = <frame_system::Pallet<T>>::block_number();
let (minimum_height, maximum_height) = { let (minimum_height, maximum_height) = {
let uncle_generations = T::UncleGenerations::get(); let uncle_generations = T::UncleGenerations::get();
@@ -303,7 +303,7 @@ impl<T: Config> Module<T> {
{ {
let parent_number = uncle.number().clone() - One::one(); let parent_number = uncle.number().clone() - One::one();
let parent_hash = <frame_system::Module<T>>::block_hash(&parent_number); let parent_hash = <frame_system::Pallet<T>>::block_hash(&parent_number);
if &parent_hash != uncle.parent_hash() { if &parent_hash != uncle.parent_hash() {
return Err(Error::<T>::InvalidUncleParent.into()); return Err(Error::<T>::InvalidUncleParent.into());
} }
@@ -314,7 +314,7 @@ impl<T: Config> Module<T> {
} }
let duplicate = existing_uncles.into_iter().find(|h| **h == hash).is_some(); let duplicate = existing_uncles.into_iter().find(|h| **h == hash).is_some();
let in_chain = <frame_system::Module<T>>::block_hash(uncle.number()) == hash; let in_chain = <frame_system::Pallet<T>>::block_hash(uncle.number()) == hash;
if duplicate || in_chain { if duplicate || in_chain {
return Err(Error::<T>::UncleAlreadyIncluded.into()) return Err(Error::<T>::UncleAlreadyIncluded.into())
@@ -413,8 +413,8 @@ mod tests {
NodeBlock = Block, NodeBlock = Block,
UncheckedExtrinsic = UncheckedExtrinsic, UncheckedExtrinsic = UncheckedExtrinsic,
{ {
System: frame_system::{Module, Call, Config, Storage, Event<T>}, System: frame_system::{Pallet, Call, Config, Storage, Event<T>},
Authorship: pallet_authorship::{Module, Call, Storage, Inherent}, Authorship: pallet_authorship::{Pallet, Call, Storage, Inherent},
} }
); );
+1 -1
View File
@@ -536,7 +536,7 @@ impl<T: Config> Pallet<T> {
// Update the start blocks of the previous and new current epoch. // Update the start blocks of the previous and new current epoch.
<EpochStart<T>>::mutate(|(previous_epoch_start_block, current_epoch_start_block)| { <EpochStart<T>>::mutate(|(previous_epoch_start_block, current_epoch_start_block)| {
*previous_epoch_start_block = sp_std::mem::take(current_epoch_start_block); *previous_epoch_start_block = sp_std::mem::take(current_epoch_start_block);
*current_epoch_start_block = <frame_system::Module<T>>::block_number(); *current_epoch_start_block = <frame_system::Pallet<T>>::block_number();
}); });
// After we update the current epoch, we signal the *next* epoch change // After we update the current epoch, we signal the *next* epoch change
+10 -10
View File
@@ -51,14 +51,14 @@ frame_support::construct_runtime!(
NodeBlock = Block, NodeBlock = Block,
UncheckedExtrinsic = UncheckedExtrinsic, UncheckedExtrinsic = UncheckedExtrinsic,
{ {
System: frame_system::{Module, Call, Config, Storage, Event<T>}, System: frame_system::{Pallet, Call, Config, Storage, Event<T>},
Balances: pallet_balances::{Module, Call, Storage, Config<T>, Event<T>}, Balances: pallet_balances::{Pallet, Call, Storage, Config<T>, Event<T>},
Historical: pallet_session_historical::{Module}, Historical: pallet_session_historical::{Pallet},
Offences: pallet_offences::{Module, Call, Storage, Event}, Offences: pallet_offences::{Pallet, Call, Storage, Event},
Babe: pallet_babe::{Module, Call, Storage, Config, ValidateUnsigned}, Babe: pallet_babe::{Pallet, Call, Storage, Config, ValidateUnsigned},
Staking: pallet_staking::{Module, Call, Storage, Config<T>, Event<T>}, Staking: pallet_staking::{Pallet, Call, Storage, Config<T>, Event<T>},
Session: pallet_session::{Module, Call, Storage, Event, Config<T>}, Session: pallet_session::{Pallet, Call, Storage, Event, Config<T>},
Timestamp: pallet_timestamp::{Module, Call, Storage, Inherent}, Timestamp: pallet_timestamp::{Pallet, Call, Storage, Inherent},
} }
); );
@@ -104,7 +104,7 @@ where
impl_opaque_keys! { impl_opaque_keys! {
pub struct MockSessionKeys { pub struct MockSessionKeys {
pub babe_authority: super::Module<Test>, pub babe_authority: super::Pallet<Test>,
} }
} }
@@ -204,7 +204,7 @@ impl pallet_staking::Config for Test {
type SlashDeferDuration = SlashDeferDuration; type SlashDeferDuration = SlashDeferDuration;
type SlashCancelOrigin = frame_system::EnsureRoot<Self::AccountId>; type SlashCancelOrigin = frame_system::EnsureRoot<Self::AccountId>;
type SessionInterface = Self; type SessionInterface = Self;
type UnixTime = pallet_timestamp::Module<Test>; type UnixTime = pallet_timestamp::Pallet<Test>;
type EraPayout = pallet_staking::ConvertCurve<RewardCurve>; type EraPayout = pallet_staking::ConvertCurve<RewardCurve>;
type MaxNominatorRewardedPerValidator = MaxNominatorRewardedPerValidator; type MaxNominatorRewardedPerValidator = MaxNominatorRewardedPerValidator;
type NextNewSession = Session; type NextNewSession = Session;
+1 -1
View File
@@ -143,6 +143,6 @@ impl<T: Config> RandomnessT<Option<T::Hash>, T::BlockNumber> for CurrentBlockRan
T::Hashing::hash(&subject[..]) T::Hashing::hash(&subject[..])
}); });
(random, <frame_system::Module<T>>::block_number()) (random, <frame_system::Pallet<T>>::block_number())
} }
} }
+1 -1
View File
@@ -25,7 +25,7 @@ use frame_system::RawOrigin;
use frame_benchmarking::{benchmarks_instance_pallet, account, whitelisted_caller, impl_benchmark_test_suite}; use frame_benchmarking::{benchmarks_instance_pallet, account, whitelisted_caller, impl_benchmark_test_suite};
use sp_runtime::traits::Bounded; use sp_runtime::traits::Bounded;
use crate::Module as Balances; use crate::Pallet as Balances;
const SEED: u32 = 0; const SEED: u32 = 0;
// existential deposit multiplier // existential deposit multiplier
+1 -1
View File
@@ -624,7 +624,7 @@ pub struct DustCleaner<T: Config<I>, I: 'static = ()>(Option<(T::AccountId, Nega
impl<T: Config<I>, I: 'static> Drop for DustCleaner<T, I> { impl<T: Config<I>, I: 'static> Drop for DustCleaner<T, I> {
fn drop(&mut self) { fn drop(&mut self) {
if let Some((who, dust)) = self.0.take() { if let Some((who, dust)) = self.0.take() {
Module::<T, I>::deposit_event(Event::DustLost(who, dust.peek())); Pallet::<T, I>::deposit_event(Event::DustLost(who, dust.peek()));
T::DustRemoval::on_unbalanced(dust); T::DustRemoval::on_unbalanced(dust);
} }
} }
+1 -1
View File
@@ -55,7 +55,7 @@ macro_rules! decl_tests {
} }
fn last_event() -> Event { fn last_event() -> Event {
system::Module::<Test>::events().pop().expect("Event expected").event system::Pallet::<Test>::events().pop().expect("Event expected").event
} }
#[test] #[test]
@@ -30,7 +30,7 @@ use frame_support::weights::{Weight, DispatchInfo, IdentityFee};
use pallet_transaction_payment::CurrencyAdapter; use pallet_transaction_payment::CurrencyAdapter;
use crate::{ use crate::{
self as pallet_balances, self as pallet_balances,
Module, Config, decl_tests, Pallet, Config, decl_tests,
}; };
type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic<Test>; type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic<Test>;
type Block = frame_system::mocking::MockBlock<Test>; type Block = frame_system::mocking::MockBlock<Test>;
@@ -41,8 +41,8 @@ frame_support::construct_runtime!(
NodeBlock = Block, NodeBlock = Block,
UncheckedExtrinsic = UncheckedExtrinsic, UncheckedExtrinsic = UncheckedExtrinsic,
{ {
System: frame_system::{Module, Call, Config, Storage, Event<T>}, System: frame_system::{Pallet, Call, Config, Storage, Event<T>},
Balances: pallet_balances::{Module, Call, Storage, Config<T>, Event<T>}, Balances: pallet_balances::{Pallet, Call, Storage, Config<T>, Event<T>},
} }
); );
@@ -80,7 +80,7 @@ parameter_types! {
pub const TransactionByteFee: u64 = 1; pub const TransactionByteFee: u64 = 1;
} }
impl pallet_transaction_payment::Config for Test { impl pallet_transaction_payment::Config for Test {
type OnChargeTransaction = CurrencyAdapter<Module<Test>, ()>; type OnChargeTransaction = CurrencyAdapter<Pallet<Test>, ()>;
type TransactionByteFee = TransactionByteFee; type TransactionByteFee = TransactionByteFee;
type WeightToFee = IdentityFee<u64>; type WeightToFee = IdentityFee<u64>;
type FeeMultiplierUpdate = (); type FeeMultiplierUpdate = ();
+4 -4
View File
@@ -30,7 +30,7 @@ use frame_support::traits::StorageMapShim;
use frame_support::weights::{Weight, DispatchInfo, IdentityFee}; use frame_support::weights::{Weight, DispatchInfo, IdentityFee};
use crate::{ use crate::{
self as pallet_balances, self as pallet_balances,
Module, Config, decl_tests, Pallet, Config, decl_tests,
}; };
use pallet_transaction_payment::CurrencyAdapter; use pallet_transaction_payment::CurrencyAdapter;
@@ -43,8 +43,8 @@ frame_support::construct_runtime!(
NodeBlock = Block, NodeBlock = Block,
UncheckedExtrinsic = UncheckedExtrinsic, UncheckedExtrinsic = UncheckedExtrinsic,
{ {
System: frame_system::{Module, Call, Config, Storage, Event<T>}, System: frame_system::{Pallet, Call, Config, Storage, Event<T>},
Balances: pallet_balances::{Module, Call, Storage, Config<T>, Event<T>}, Balances: pallet_balances::{Pallet, Call, Storage, Config<T>, Event<T>},
} }
); );
@@ -82,7 +82,7 @@ parameter_types! {
pub const TransactionByteFee: u64 = 1; pub const TransactionByteFee: u64 = 1;
} }
impl pallet_transaction_payment::Config for Test { impl pallet_transaction_payment::Config for Test {
type OnChargeTransaction = CurrencyAdapter<Module<Test>, ()>; type OnChargeTransaction = CurrencyAdapter<Pallet<Test>, ()>;
type TransactionByteFee = TransactionByteFee; type TransactionByteFee = TransactionByteFee;
type WeightToFee = IdentityFee<u64>; type WeightToFee = IdentityFee<u64>;
type FeeMultiplierUpdate = (); type FeeMultiplierUpdate = ();
@@ -30,7 +30,7 @@ use frame_support::traits::StorageMapShim;
use frame_support::weights::{IdentityFee}; use frame_support::weights::{IdentityFee};
use crate::{ use crate::{
self as pallet_balances, self as pallet_balances,
Module, Config, Pallet, Config,
}; };
use pallet_transaction_payment::CurrencyAdapter; use pallet_transaction_payment::CurrencyAdapter;
@@ -47,7 +47,7 @@ type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic<Test>;
type Block = frame_system::mocking::MockBlock<Test>; type Block = frame_system::mocking::MockBlock<Test>;
fn last_event() -> Event { fn last_event() -> Event {
system::Module::<Test>::events().pop().expect("Event expected").event system::Pallet::<Test>::events().pop().expect("Event expected").event
} }
frame_support::construct_runtime!( frame_support::construct_runtime!(
@@ -56,8 +56,8 @@ frame_support::construct_runtime!(
NodeBlock = Block, NodeBlock = Block,
UncheckedExtrinsic = UncheckedExtrinsic, UncheckedExtrinsic = UncheckedExtrinsic,
{ {
System: frame_system::{Module, Call, Config, Storage, Event<T>}, System: frame_system::{Pallet, Call, Config, Storage, Event<T>},
Balances: pallet_balances::{Module, Call, Storage, Config<T>, Event<T>}, Balances: pallet_balances::{Pallet, Call, Storage, Config<T>, Event<T>},
} }
); );
@@ -95,7 +95,7 @@ parameter_types! {
pub const TransactionByteFee: u64 = 1; pub const TransactionByteFee: u64 = 1;
} }
impl pallet_transaction_payment::Config for Test { impl pallet_transaction_payment::Config for Test {
type OnChargeTransaction = CurrencyAdapter<Module<Test>, ()>; type OnChargeTransaction = CurrencyAdapter<Pallet<Test>, ()>;
type TransactionByteFee = TransactionByteFee; type TransactionByteFee = TransactionByteFee;
type WeightToFee = IdentityFee<u64>; type WeightToFee = IdentityFee<u64>;
type FeeMultiplierUpdate = (); type FeeMultiplierUpdate = ();
+9 -9
View File
@@ -676,7 +676,7 @@ macro_rules! impl_benchmark {
( $( $name_extra:ident ),* ) ( $( $name_extra:ident ),* )
) => { ) => {
impl<T: Config $(<$instance>, $instance: $instance_bound )? > impl<T: Config $(<$instance>, $instance: $instance_bound )? >
$crate::Benchmarking<$crate::BenchmarkResults> for Module<T $(, $instance)? > $crate::Benchmarking<$crate::BenchmarkResults> for Pallet<T $(, $instance)? >
where T: frame_system::Config, $( $where_clause )* where T: frame_system::Config, $( $where_clause )*
{ {
fn benchmarks(extra: bool) -> $crate::Vec<&'static [u8]> { fn benchmarks(extra: bool) -> $crate::Vec<&'static [u8]> {
@@ -744,8 +744,8 @@ macro_rules! impl_benchmark {
>::instance(&selected_benchmark, c, verify)?; >::instance(&selected_benchmark, c, verify)?;
// Set the block number to at least 1 so events are deposited. // Set the block number to at least 1 so events are deposited.
if $crate::Zero::is_zero(&frame_system::Module::<T>::block_number()) { if $crate::Zero::is_zero(&frame_system::Pallet::<T>::block_number()) {
frame_system::Module::<T>::set_block_number(1u32.into()); frame_system::Pallet::<T>::set_block_number(1u32.into());
} }
// Commit the externalities to the database, flushing the DB cache. // Commit the externalities to the database, flushing the DB cache.
@@ -915,8 +915,8 @@ macro_rules! impl_benchmark_test {
>::instance(&selected_benchmark, &c, true)?; >::instance(&selected_benchmark, &c, true)?;
// Set the block number to at least 1 so events are deposited. // Set the block number to at least 1 so events are deposited.
if $crate::Zero::is_zero(&frame_system::Module::<T>::block_number()) { if $crate::Zero::is_zero(&frame_system::Pallet::<T>::block_number()) {
frame_system::Module::<T>::set_block_number(1u32.into()); frame_system::Pallet::<T>::set_block_number(1u32.into());
} }
// Run execution + verification // Run execution + verification
@@ -961,7 +961,7 @@ macro_rules! impl_benchmark_test {
/// When called in `pallet_example` as /// When called in `pallet_example` as
/// ///
/// ```rust,ignore /// ```rust,ignore
/// impl_benchmark_test_suite!(Module, crate::tests::new_test_ext(), crate::tests::Test); /// impl_benchmark_test_suite!(Pallet, crate::tests::new_test_ext(), crate::tests::Test);
/// ``` /// ```
/// ///
/// It expands to the equivalent of: /// It expands to the equivalent of:
@@ -1019,11 +1019,11 @@ macro_rules! impl_benchmark_test {
/// } /// }
/// ///
/// mod tests { /// mod tests {
/// // because of macro syntax limitations, neither Module nor benches can be paths, but both have /// // because of macro syntax limitations, neither Pallet nor benches can be paths, but both have
/// // to be idents in the scope of `impl_benchmark_test_suite`. /// // to be idents in the scope of `impl_benchmark_test_suite`.
/// use crate::{benches, Module}; /// use crate::{benches, Pallet};
/// ///
/// impl_benchmark_test_suite!(Module, new_test_ext(), Test, benchmarks_path = benches); /// impl_benchmark_test_suite!(Pallet, new_test_ext(), Test, benchmarks_path = benches);
/// ///
/// // new_test_ext and the Test item are defined later in this module /// // new_test_ext and the Test item are defined later in this module
/// } /// }
+3 -3
View File
@@ -76,8 +76,8 @@ frame_support::construct_runtime!(
NodeBlock = Block, NodeBlock = Block,
UncheckedExtrinsic = UncheckedExtrinsic, UncheckedExtrinsic = UncheckedExtrinsic,
{ {
System: frame_system::{Module, Call, Config, Storage, Event<T>}, System: frame_system::{Pallet, Call, Config, Storage, Event<T>},
TestPallet: pallet_test::{Module, Call, Storage}, TestPallet: pallet_test::{Pallet, Call, Storage},
} }
); );
@@ -133,7 +133,7 @@ mod benchmarks {
use crate::{BenchmarkingSetup, BenchmarkParameter, account}; use crate::{BenchmarkingSetup, BenchmarkParameter, account};
// Additional used internally by the benchmark macro. // Additional used internally by the benchmark macro.
use super::pallet_test::{Call, Config, Module}; use super::pallet_test::{Call, Config, Pallet};
crate::benchmarks!{ crate::benchmarks!{
where_clause { where_clause {
+3 -3
View File
@@ -84,7 +84,7 @@ fn setup_pot_account<T: Config>() {
} }
fn assert_last_event<T: Config>(generic_event: <T as Config>::Event) { fn assert_last_event<T: Config>(generic_event: <T as Config>::Event) {
let events = frame_system::Module::<T>::events(); let events = frame_system::Pallet::<T>::events();
let system_event: <T as frame_system::Config>::Event = generic_event.into(); let system_event: <T as frame_system::Config>::Event = generic_event.into();
// compare to the last event record // compare to the last event record
let EventRecord { event, .. } = &events[events.len() - 1]; let EventRecord { event, .. } = &events[events.len() - 1];
@@ -122,7 +122,7 @@ benchmarks! {
let (curator_lookup, bounty_id) = create_bounty::<T>()?; let (curator_lookup, bounty_id) = create_bounty::<T>()?;
Bounties::<T>::on_initialize(T::BlockNumber::zero()); Bounties::<T>::on_initialize(T::BlockNumber::zero());
let bounty_id = BountyCount::get() - 1; let bounty_id = BountyCount::get() - 1;
frame_system::Module::<T>::set_block_number(T::BountyUpdatePeriod::get() + 1u32.into()); frame_system::Pallet::<T>::set_block_number(T::BountyUpdatePeriod::get() + 1u32.into());
let caller = whitelisted_caller(); let caller = whitelisted_caller();
}: _(RawOrigin::Signed(caller), bounty_id) }: _(RawOrigin::Signed(caller), bounty_id)
@@ -159,7 +159,7 @@ benchmarks! {
let beneficiary = T::Lookup::unlookup(beneficiary_account.clone()); let beneficiary = T::Lookup::unlookup(beneficiary_account.clone());
Bounties::<T>::award_bounty(RawOrigin::Signed(curator.clone()).into(), bounty_id, beneficiary)?; Bounties::<T>::award_bounty(RawOrigin::Signed(curator.clone()).into(), bounty_id, beneficiary)?;
frame_system::Module::<T>::set_block_number(T::BountyDepositPayoutDelay::get()); frame_system::Pallet::<T>::set_block_number(T::BountyDepositPayoutDelay::get());
ensure!(T::Currency::free_balance(&beneficiary_account).is_zero(), "Beneficiary already has balance"); ensure!(T::Currency::free_balance(&beneficiary_account).is_zero(), "Beneficiary already has balance");
}: _(RawOrigin::Signed(curator), bounty_id) }: _(RawOrigin::Signed(curator), bounty_id)
+5 -5
View File
@@ -424,7 +424,7 @@ decl_module! {
// If the sender is not the curator, and the curator is inactive, // If the sender is not the curator, and the curator is inactive,
// slash the curator. // slash the curator.
if sender != *curator { if sender != *curator {
let block_number = system::Module::<T>::block_number(); let block_number = system::Pallet::<T>::block_number();
if *update_due < block_number { if *update_due < block_number {
slash_curator(curator, &mut bounty.curator_deposit); slash_curator(curator, &mut bounty.curator_deposit);
// Continue to change bounty status below... // Continue to change bounty status below...
@@ -479,7 +479,7 @@ decl_module! {
T::Currency::reserve(curator, deposit)?; T::Currency::reserve(curator, deposit)?;
bounty.curator_deposit = deposit; bounty.curator_deposit = deposit;
let update_due = system::Module::<T>::block_number() + T::BountyUpdatePeriod::get(); let update_due = system::Pallet::<T>::block_number() + T::BountyUpdatePeriod::get();
bounty.status = BountyStatus::Active { curator: curator.clone(), update_due }; bounty.status = BountyStatus::Active { curator: curator.clone(), update_due };
Ok(()) Ok(())
@@ -518,7 +518,7 @@ decl_module! {
bounty.status = BountyStatus::PendingPayout { bounty.status = BountyStatus::PendingPayout {
curator: signer, curator: signer,
beneficiary: beneficiary.clone(), beneficiary: beneficiary.clone(),
unlock_at: system::Module::<T>::block_number() + T::BountyDepositPayoutDelay::get(), unlock_at: system::Pallet::<T>::block_number() + T::BountyDepositPayoutDelay::get(),
}; };
Ok(()) Ok(())
@@ -543,7 +543,7 @@ decl_module! {
Bounties::<T>::try_mutate_exists(bounty_id, |maybe_bounty| -> DispatchResult { Bounties::<T>::try_mutate_exists(bounty_id, |maybe_bounty| -> DispatchResult {
let bounty = maybe_bounty.take().ok_or(Error::<T>::InvalidIndex)?; let bounty = maybe_bounty.take().ok_or(Error::<T>::InvalidIndex)?;
if let BountyStatus::PendingPayout { curator, beneficiary, unlock_at } = bounty.status { if let BountyStatus::PendingPayout { curator, beneficiary, unlock_at } = bounty.status {
ensure!(system::Module::<T>::block_number() >= unlock_at, Error::<T>::Premature); ensure!(system::Pallet::<T>::block_number() >= unlock_at, Error::<T>::Premature);
let bounty_account = Self::bounty_account_id(bounty_id); let bounty_account = Self::bounty_account_id(bounty_id);
let balance = T::Currency::free_balance(&bounty_account); let balance = T::Currency::free_balance(&bounty_account);
let fee = bounty.fee.min(balance); // just to be safe let fee = bounty.fee.min(balance); // just to be safe
@@ -649,7 +649,7 @@ decl_module! {
match bounty.status { match bounty.status {
BountyStatus::Active { ref curator, ref mut update_due } => { BountyStatus::Active { ref curator, ref mut update_due } => {
ensure!(*curator == signer, Error::<T>::RequireCurator); ensure!(*curator == signer, Error::<T>::RequireCurator);
*update_due = (system::Module::<T>::block_number() + T::BountyUpdatePeriod::get()).max(*update_due); *update_due = (system::Pallet::<T>::block_number() + T::BountyUpdatePeriod::get()).max(*update_due);
}, },
_ => return Err(Error::<T>::UnexpectedStatus.into()), _ => return Err(Error::<T>::UnexpectedStatus.into()),
} }
+5 -5
View File
@@ -43,10 +43,10 @@ frame_support::construct_runtime!(
NodeBlock = Block, NodeBlock = Block,
UncheckedExtrinsic = UncheckedExtrinsic, UncheckedExtrinsic = UncheckedExtrinsic,
{ {
System: frame_system::{Module, Call, Config, Storage, Event<T>}, System: frame_system::{Pallet, Call, Config, Storage, Event<T>},
Balances: pallet_balances::{Module, Call, Storage, Config<T>, Event<T>}, Balances: pallet_balances::{Pallet, Call, Storage, Config<T>, Event<T>},
Bounties: pallet_bounties::{Module, Call, Storage, Event<T>}, Bounties: pallet_bounties::{Pallet, Call, Storage, Event<T>},
Treasury: pallet_treasury::{Module, Call, Storage, Config, Event<T>}, Treasury: pallet_treasury::{Pallet, Call, Storage, Config, Event<T>},
} }
); );
@@ -107,7 +107,7 @@ parameter_types! {
// impl pallet_treasury::Config for Test { // impl pallet_treasury::Config for Test {
impl pallet_treasury::Config for Test { impl pallet_treasury::Config for Test {
type ModuleId = TreasuryModuleId; type ModuleId = TreasuryModuleId;
type Currency = pallet_balances::Module<Test>; type Currency = pallet_balances::Pallet<Test>;
type ApproveOrigin = frame_system::EnsureRoot<u128>; type ApproveOrigin = frame_system::EnsureRoot<u128>;
type RejectOrigin = frame_system::EnsureRoot<u128>; type RejectOrigin = frame_system::EnsureRoot<u128>;
type Event = Event; type Event = Event;
@@ -31,7 +31,7 @@ use sp_runtime::traits::Bounded;
use sp_std::mem::size_of; use sp_std::mem::size_of;
use frame_system::Call as SystemCall; use frame_system::Call as SystemCall;
use frame_system::Module as System; use frame_system::Pallet as System;
use crate::Module as Collective; use crate::Module as Collective;
const SEED: u32 = 0; const SEED: u32 = 0;
+6 -6
View File
@@ -472,7 +472,7 @@ decl_module! {
let index = Self::proposal_count(); let index = Self::proposal_count();
<ProposalCount<I>>::mutate(|i| *i += 1); <ProposalCount<I>>::mutate(|i| *i += 1);
<ProposalOf<T, I>>::insert(proposal_hash, *proposal); <ProposalOf<T, I>>::insert(proposal_hash, *proposal);
let end = system::Module::<T>::block_number() + T::MotionDuration::get(); let end = system::Pallet::<T>::block_number() + T::MotionDuration::get();
let votes = Votes { index, threshold, ayes: vec![who.clone()], nays: vec![], end }; let votes = Votes { index, threshold, ayes: vec![who.clone()], nays: vec![], end };
<Voting<T, I>>::insert(proposal_hash, votes); <Voting<T, I>>::insert(proposal_hash, votes);
@@ -647,7 +647,7 @@ decl_module! {
} }
// Only allow actual closing of the proposal after the voting period has ended. // Only allow actual closing of the proposal after the voting period has ended.
ensure!(system::Module::<T>::block_number() >= voting.end, Error::<T, I>::TooEarly); ensure!(system::Pallet::<T>::block_number() >= voting.end, Error::<T, I>::TooEarly);
let prime_vote = Self::prime().map(|who| voting.ayes.iter().any(|a| a == &who)); let prime_vote = Self::prime().map(|who| voting.ayes.iter().any(|a| a == &who));
@@ -1045,10 +1045,10 @@ mod tests {
NodeBlock = Block, NodeBlock = Block,
UncheckedExtrinsic = UncheckedExtrinsic UncheckedExtrinsic = UncheckedExtrinsic
{ {
System: system::{Module, Call, Event<T>}, System: system::{Pallet, Call, Event<T>},
Collective: collective::<Instance1>::{Module, Call, Event<T>, Origin<T>, Config<T>}, Collective: collective::<Instance1>::{Pallet, Call, Event<T>, Origin<T>, Config<T>},
CollectiveMajority: collective::<Instance2>::{Module, Call, Event<T>, Origin<T>, Config<T>}, CollectiveMajority: collective::<Instance2>::{Pallet, Call, Event<T>, Origin<T>, Config<T>},
DefaultCollective: collective::{Module, Call, Event<T>, Origin<T>, Config<T>}, DefaultCollective: collective::{Pallet, Call, Event<T>, Origin<T>, Config<T>},
} }
); );
+1 -1
View File
@@ -176,7 +176,7 @@ Before a call or instantiate can be performed the execution context must be init
For the first call or instantiation in the handling of an extrinsic, this involves two calls: For the first call or instantiation in the handling of an extrinsic, this involves two calls:
1. `<timestamp::Module<T>>::now()` 1. `<timestamp::Module<T>>::now()`
2. `<system::Module<T>>::block_number()` 2. `<system::Pallet<T>>::block_number()`
The complexity of initialization depends on the complexity of these functions. In the current The complexity of initialization depends on the complexity of these functions. In the current
implementation they just involve a DB read. implementation they just involve a DB read.
@@ -25,7 +25,7 @@
//! compiles it down into a `WasmModule` that can be used as a contract's code. //! compiles it down into a `WasmModule` that can be used as a contract's code.
use crate::Config; use crate::Config;
use crate::Module as Contracts; use crate::Pallet as Contracts;
use parity_wasm::elements::{ use parity_wasm::elements::{
Instruction, Instructions, FuncBody, ValueType, BlockType, Section, CustomSection, Instruction, Instructions, FuncBody, ValueType, BlockType, Section, CustomSection,
@@ -23,7 +23,7 @@ mod code;
mod sandbox; mod sandbox;
use crate::{ use crate::{
*, Module as Contracts, *, Pallet as Contracts,
exec::StorageKey, exec::StorageKey,
rent::Rent, rent::Rent,
schedule::{API_BENCHMARK_BATCH_SIZE, INSTR_BENCHMARK_BATCH_SIZE}, schedule::{API_BENCHMARK_BATCH_SIZE, INSTR_BENCHMARK_BATCH_SIZE},
@@ -37,7 +37,7 @@ use self::{
sandbox::Sandbox, sandbox::Sandbox,
}; };
use frame_benchmarking::{benchmarks, account, whitelisted_caller, impl_benchmark_test_suite}; use frame_benchmarking::{benchmarks, account, whitelisted_caller, impl_benchmark_test_suite};
use frame_system::{Module as System, RawOrigin}; use frame_system::{Pallet as System, RawOrigin};
use parity_wasm::elements::{Instruction, ValueType, BlockType}; use parity_wasm::elements::{Instruction, ValueType, BlockType};
use sp_runtime::traits::{Hash, Bounded, Zero}; use sp_runtime::traits::{Hash, Bounded, Zero};
use sp_std::{default::Default, convert::{TryInto}, vec::Vec, vec}; use sp_std::{default::Default, convert::{TryInto}, vec::Vec, vec};
+4 -4
View File
@@ -16,7 +16,7 @@
// limitations under the License. // limitations under the License.
use crate::{ use crate::{
CodeHash, Event, Config, Module as Contracts, CodeHash, Event, Config, Pallet as Contracts,
TrieId, BalanceOf, ContractInfo, gas::GasMeter, rent::Rent, storage::{self, Storage}, TrieId, BalanceOf, ContractInfo, gas::GasMeter, rent::Rent, storage::{self, Storage},
Error, ContractInfoOf, Schedule, AliveContractInfo, Error, ContractInfoOf, Schedule, AliveContractInfo,
}; };
@@ -384,7 +384,7 @@ where
depth: 0, depth: 0,
schedule, schedule,
timestamp: T::Time::now(), timestamp: T::Time::now(),
block_number: <frame_system::Module<T>>::block_number(), block_number: <frame_system::Pallet<T>>::block_number(),
_phantom: Default::default(), _phantom: Default::default(),
} }
} }
@@ -909,7 +909,7 @@ fn deposit_event<T: Config>(
topics: Vec<T::Hash>, topics: Vec<T::Hash>,
event: Event<T>, event: Event<T>,
) { ) {
<frame_system::Module<T>>::deposit_event_indexed( <frame_system::Pallet<T>>::deposit_event_indexed(
&*topics, &*topics,
<T as Config>::Event::from(event).into(), <T as Config>::Event::from(event).into(),
) )
@@ -961,7 +961,7 @@ mod tests {
} }
fn events() -> Vec<Event<Test>> { fn events() -> Vec<Event<Test>> {
<frame_system::Module<Test>>::events() <frame_system::Pallet<Test>>::events()
.into_iter() .into_iter()
.filter_map(|meta| match meta.event { .filter_map(|meta| match meta.event {
MetaEvent::pallet_contracts(contract_event) => Some(contract_event), MetaEvent::pallet_contracts(contract_event) => Some(contract_event),
+9 -9
View File
@@ -15,7 +15,7 @@
// See the License for the specific language governing permissions and // See the License for the specific language governing permissions and
// limitations under the License. // limitations under the License.
//! # Contract Module //! # Contract Pallet
//! //!
//! The Contract module provides functionality for the runtime to deploy and execute WebAssembly smart-contracts. //! The Contract module provides functionality for the runtime to deploy and execute WebAssembly smart-contracts.
//! //!
@@ -124,7 +124,7 @@ use frame_support::{
traits::{OnUnbalanced, Currency, Get, Time, Randomness}, traits::{OnUnbalanced, Currency, Get, Time, Randomness},
weights::{Weight, PostDispatchInfo, WithPostDispatchInfo}, weights::{Weight, PostDispatchInfo, WithPostDispatchInfo},
}; };
use frame_system::Module as System; use frame_system::Pallet as System;
use pallet_contracts_primitives::{ use pallet_contracts_primitives::{
RentProjectionResult, GetStorageResult, ContractAccessError, ContractExecResult, RentProjectionResult, GetStorageResult, ContractAccessError, ContractExecResult,
}; };
@@ -290,7 +290,7 @@ pub mod pallet {
schedule: Schedule<T> schedule: Schedule<T>
) -> DispatchResultWithPostInfo { ) -> DispatchResultWithPostInfo {
ensure_root(origin)?; ensure_root(origin)?;
if <Module<T>>::current_schedule().version > schedule.version { if <Pallet<T>>::current_schedule().version > schedule.version {
Err(Error::<T>::InvalidScheduleVersion)? Err(Error::<T>::InvalidScheduleVersion)?
} }
Self::deposit_event(Event::ScheduleUpdated(schedule.version)); Self::deposit_event(Event::ScheduleUpdated(schedule.version));
@@ -316,7 +316,7 @@ pub mod pallet {
let origin = ensure_signed(origin)?; let origin = ensure_signed(origin)?;
let dest = T::Lookup::lookup(dest)?; let dest = T::Lookup::lookup(dest)?;
let mut gas_meter = GasMeter::new(gas_limit); let mut gas_meter = GasMeter::new(gas_limit);
let schedule = <Module<T>>::current_schedule(); let schedule = <Pallet<T>>::current_schedule();
let mut ctx = ExecutionContext::<T, PrefabWasmModule<T>>::top_level(origin, &schedule); let mut ctx = ExecutionContext::<T, PrefabWasmModule<T>>::top_level(origin, &schedule);
let (result, code_len) = match ctx.call(dest, value, &mut gas_meter, data) { let (result, code_len) = match ctx.call(dest, value, &mut gas_meter, data) {
Ok((output, len)) => (Ok(output), len), Ok((output, len)) => (Ok(output), len),
@@ -365,7 +365,7 @@ pub mod pallet {
let code_len = code.len() as u32; let code_len = code.len() as u32;
ensure!(code_len <= T::MaxCodeSize::get(), Error::<T>::CodeTooLarge); ensure!(code_len <= T::MaxCodeSize::get(), Error::<T>::CodeTooLarge);
let mut gas_meter = GasMeter::new(gas_limit); let mut gas_meter = GasMeter::new(gas_limit);
let schedule = <Module<T>>::current_schedule(); let schedule = <Pallet<T>>::current_schedule();
let executable = PrefabWasmModule::from_code(code, &schedule)?; let executable = PrefabWasmModule::from_code(code, &schedule)?;
let code_len = executable.code_len(); let code_len = executable.code_len();
ensure!(code_len <= T::MaxCodeSize::get(), Error::<T>::CodeTooLarge); ensure!(code_len <= T::MaxCodeSize::get(), Error::<T>::CodeTooLarge);
@@ -397,7 +397,7 @@ pub mod pallet {
) -> DispatchResultWithPostInfo { ) -> DispatchResultWithPostInfo {
let origin = ensure_signed(origin)?; let origin = ensure_signed(origin)?;
let mut gas_meter = GasMeter::new(gas_limit); let mut gas_meter = GasMeter::new(gas_limit);
let schedule = <Module<T>>::current_schedule(); let schedule = <Pallet<T>>::current_schedule();
let executable = PrefabWasmModule::from_storage(code_hash, &schedule, &mut gas_meter)?; let executable = PrefabWasmModule::from_storage(code_hash, &schedule, &mut gas_meter)?;
let mut ctx = ExecutionContext::<T, PrefabWasmModule<T>>::top_level(origin, &schedule); let mut ctx = ExecutionContext::<T, PrefabWasmModule<T>>::top_level(origin, &schedule);
let code_len = executable.code_len(); let code_len = executable.code_len();
@@ -665,7 +665,7 @@ pub mod pallet {
} }
} }
impl<T: Config> Module<T> impl<T: Config> Pallet<T>
where where
T::AccountId: UncheckedFrom<T::Hash> + AsRef<[u8]>, T::AccountId: UncheckedFrom<T::Hash> + AsRef<[u8]>,
{ {
@@ -683,7 +683,7 @@ where
input_data: Vec<u8>, input_data: Vec<u8>,
) -> ContractExecResult { ) -> ContractExecResult {
let mut gas_meter = GasMeter::new(gas_limit); let mut gas_meter = GasMeter::new(gas_limit);
let schedule = <Module<T>>::current_schedule(); let schedule = <Pallet<T>>::current_schedule();
let mut ctx = ExecutionContext::<T, PrefabWasmModule<T>>::top_level(origin, &schedule); let mut ctx = ExecutionContext::<T, PrefabWasmModule<T>>::top_level(origin, &schedule);
let result = ctx.call(dest, value, &mut gas_meter, input_data); let result = ctx.call(dest, value, &mut gas_meter, input_data);
let gas_consumed = gas_meter.gas_spent(); let gas_consumed = gas_meter.gas_spent();
@@ -746,7 +746,7 @@ where
/// Store code for benchmarks which does not check nor instrument the code. /// Store code for benchmarks which does not check nor instrument the code.
#[cfg(feature = "runtime-benchmarks")] #[cfg(feature = "runtime-benchmarks")]
fn store_code_raw(code: Vec<u8>) -> frame_support::dispatch::DispatchResult { fn store_code_raw(code: Vec<u8>) -> frame_support::dispatch::DispatchResult {
let schedule = <Module<T>>::current_schedule(); let schedule = <Pallet<T>>::current_schedule();
PrefabWasmModule::store_code_unchecked(code, &schedule)?; PrefabWasmModule::store_code_unchecked(code, &schedule)?;
Ok(()) Ok(())
} }
+7 -7
View File
@@ -18,7 +18,7 @@
//! A module responsible for computing the right amount of weight and charging it. //! A module responsible for computing the right amount of weight and charging it.
use crate::{ use crate::{
AliveContractInfo, BalanceOf, ContractInfo, ContractInfoOf, Module, Event, AliveContractInfo, BalanceOf, ContractInfo, ContractInfoOf, Pallet, Event,
TombstoneContractInfo, Config, CodeHash, Error, TombstoneContractInfo, Config, CodeHash, Error,
storage::Storage, wasm::PrefabWasmModule, exec::Executable, storage::Storage, wasm::PrefabWasmModule, exec::Executable,
}; };
@@ -124,7 +124,7 @@ where
free_balance: &BalanceOf<T>, free_balance: &BalanceOf<T>,
contract: &AliveContractInfo<T>, contract: &AliveContractInfo<T>,
) -> Option<BalanceOf<T>> { ) -> Option<BalanceOf<T>> {
let subsistence_threshold = Module::<T>::subsistence_threshold(); let subsistence_threshold = Pallet::<T>::subsistence_threshold();
// Reserved balance contributes towards the subsistence threshold to stay consistent // Reserved balance contributes towards the subsistence threshold to stay consistent
// with the existential deposit where the reserved balance is also counted. // with the existential deposit where the reserved balance is also counted.
if *total_balance < subsistence_threshold { if *total_balance < subsistence_threshold {
@@ -268,7 +268,7 @@ where
let tombstone_info = ContractInfo::Tombstone(tombstone); let tombstone_info = ContractInfo::Tombstone(tombstone);
<ContractInfoOf<T>>::insert(account, &tombstone_info); <ContractInfoOf<T>>::insert(account, &tombstone_info);
code.drop_from_storage(); code.drop_from_storage();
<Module<T>>::deposit_event(Event::Evicted(account.clone())); <Pallet<T>>::deposit_event(Event::Evicted(account.clone()));
Ok(None) Ok(None)
} }
(Verdict::Evict { amount: _ }, None) => { (Verdict::Evict { amount: _ }, None) => {
@@ -298,7 +298,7 @@ where
contract: AliveContractInfo<T>, contract: AliveContractInfo<T>,
code_size: u32, code_size: u32,
) -> Result<Option<AliveContractInfo<T>>, DispatchError> { ) -> Result<Option<AliveContractInfo<T>>, DispatchError> {
let current_block_number = <frame_system::Module<T>>::block_number(); let current_block_number = <frame_system::Pallet<T>>::block_number();
let verdict = Self::consider_case( let verdict = Self::consider_case(
account, account,
current_block_number, current_block_number,
@@ -333,7 +333,7 @@ where
}; };
let module = PrefabWasmModule::<T>::from_storage_noinstr(contract.code_hash)?; let module = PrefabWasmModule::<T>::from_storage_noinstr(contract.code_hash)?;
let code_len = module.code_len(); let code_len = module.code_len();
let current_block_number = <frame_system::Module<T>>::block_number(); let current_block_number = <frame_system::Pallet<T>>::block_number();
let verdict = Self::consider_case( let verdict = Self::consider_case(
account, account,
current_block_number, current_block_number,
@@ -384,7 +384,7 @@ where
let module = PrefabWasmModule::from_storage_noinstr(alive_contract_info.code_hash) let module = PrefabWasmModule::from_storage_noinstr(alive_contract_info.code_hash)
.map_err(|_| IsTombstone)?; .map_err(|_| IsTombstone)?;
let code_size = module.occupied_storage(); let code_size = module.occupied_storage();
let current_block_number = <frame_system::Module<T>>::block_number(); let current_block_number = <frame_system::Pallet<T>>::block_number();
let verdict = Self::consider_case( let verdict = Self::consider_case(
account, account,
current_block_number, current_block_number,
@@ -465,7 +465,7 @@ where
let child_trie_info = origin_contract.child_trie_info(); let child_trie_info = origin_contract.child_trie_info();
let current_block = <frame_system::Module<T>>::block_number(); let current_block = <frame_system::Pallet<T>>::block_number();
if origin_contract.last_write == Some(current_block) { if origin_contract.last_write == Some(current_block) {
return Err((Error::<T>::InvalidContractOrigin.into(), 0, 0)); return Err((Error::<T>::InvalidContractOrigin.into(), 0, 0));
+2 -2
View File
@@ -117,7 +117,7 @@ where
.and_then(|val| val.checked_add(new_value_len)) .and_then(|val| val.checked_add(new_value_len))
.ok_or_else(|| Error::<T>::StorageExhausted)?; .ok_or_else(|| Error::<T>::StorageExhausted)?;
new_info.last_write = Some(<frame_system::Module<T>>::block_number()); new_info.last_write = Some(<frame_system::Pallet<T>>::block_number());
<ContractInfoOf<T>>::insert(&account, ContractInfo::Alive(new_info)); <ContractInfoOf<T>>::insert(&account, ContractInfo::Alive(new_info));
// Finally, perform the change on the storage. // Finally, perform the change on the storage.
@@ -176,7 +176,7 @@ where
// We want to charge rent for the first block in advance. Therefore we // We want to charge rent for the first block in advance. Therefore we
// treat the contract as if it was created in the last block and then // treat the contract as if it was created in the last block and then
// charge rent for it during instantiation. // charge rent for it during instantiation.
<frame_system::Module<T>>::block_number().saturating_sub(1u32.into()), <frame_system::Pallet<T>>::block_number().saturating_sub(1u32.into()),
rent_allowance: <BalanceOf<T>>::max_value(), rent_allowance: <BalanceOf<T>>::max_value(),
rent_payed: <BalanceOf<T>>::zero(), rent_payed: <BalanceOf<T>>::zero(),
pair_count: 0, pair_count: 0,
+25 -25
View File
@@ -16,7 +16,7 @@
// limitations under the License. // limitations under the License.
use crate::{ use crate::{
BalanceOf, ContractInfo, ContractInfoOf, Module, BalanceOf, ContractInfo, ContractInfoOf, Pallet,
RawAliveContractInfo, Config, Schedule, RawAliveContractInfo, Config, Schedule,
Error, storage::Storage, Error, storage::Storage,
chain_extension::{ chain_extension::{
@@ -57,11 +57,11 @@ frame_support::construct_runtime!(
NodeBlock = Block, NodeBlock = Block,
UncheckedExtrinsic = UncheckedExtrinsic, UncheckedExtrinsic = UncheckedExtrinsic,
{ {
System: frame_system::{Module, Call, Config, Storage, Event<T>}, System: frame_system::{Pallet, Call, Config, Storage, Event<T>},
Balances: pallet_balances::{Module, Call, Storage, Config<T>, Event<T>}, Balances: pallet_balances::{Pallet, Call, Storage, Config<T>, Event<T>},
Timestamp: pallet_timestamp::{Module, Call, Storage, Inherent}, Timestamp: pallet_timestamp::{Pallet, Call, Storage, Inherent},
Randomness: pallet_randomness_collective_flip::{Module, Call, Storage}, Randomness: pallet_randomness_collective_flip::{Pallet, Call, Storage},
Contracts: pallet_contracts::{Module, Call, Config<T>, Storage, Event<T>}, Contracts: pallet_contracts::{Pallet, Call, Config<T>, Storage, Event<T>},
} }
); );
@@ -72,7 +72,7 @@ pub mod test_utils {
ContractInfoOf, CodeHash, ContractInfoOf, CodeHash,
storage::Storage, storage::Storage,
exec::{StorageKey, AccountIdOf}, exec::{StorageKey, AccountIdOf},
Module as Contracts, Pallet as Contracts,
}; };
use frame_support::traits::Currency; use frame_support::traits::Currency;
@@ -457,7 +457,7 @@ fn instantiate_and_call_and_deposit_event() {
.build() .build()
.execute_with(|| { .execute_with(|| {
let _ = Balances::deposit_creating(&ALICE, 1_000_000); let _ = Balances::deposit_creating(&ALICE, 1_000_000);
let subsistence = Module::<Test>::subsistence_threshold(); let subsistence = Pallet::<Test>::subsistence_threshold();
// Check at the end to get hash on error easily // Check at the end to get hash on error easily
let creation = Contracts::instantiate_with_code( let creation = Contracts::instantiate_with_code(
@@ -572,7 +572,7 @@ fn deposit_event_max_value_limit() {
#[test] #[test]
fn run_out_of_gas() { fn run_out_of_gas() {
let (wasm, code_hash) = compile_module::<Test>("run_out_of_gas").unwrap(); let (wasm, code_hash) = compile_module::<Test>("run_out_of_gas").unwrap();
let subsistence = Module::<Test>::subsistence_threshold(); let subsistence = Pallet::<Test>::subsistence_threshold();
ExtBuilder::default() ExtBuilder::default()
.existential_deposit(50) .existential_deposit(50)
@@ -908,7 +908,7 @@ fn removals(trigger_call: impl Fn(AccountIdOf<Test>) -> bool) {
.unwrap().get_alive().unwrap().rent_allowance; .unwrap().get_alive().unwrap().rent_allowance;
let balance = Balances::free_balance(&addr); let balance = Balances::free_balance(&addr);
let subsistence_threshold = Module::<Test>::subsistence_threshold(); let subsistence_threshold = Pallet::<Test>::subsistence_threshold();
// Trigger rent must have no effect // Trigger rent must have no effect
assert!(!trigger_call(addr.clone())); assert!(!trigger_call(addr.clone()));
@@ -997,7 +997,7 @@ fn removals(trigger_call: impl Fn(AccountIdOf<Test>) -> bool) {
.build() .build()
.execute_with(|| { .execute_with(|| {
// Create // Create
let subsistence_threshold = Module::<Test>::subsistence_threshold(); let subsistence_threshold = Pallet::<Test>::subsistence_threshold();
let _ = Balances::deposit_creating(&ALICE, subsistence_threshold * 1000); let _ = Balances::deposit_creating(&ALICE, subsistence_threshold * 1000);
assert_ok!(Contracts::instantiate_with_code( assert_ok!(Contracts::instantiate_with_code(
Origin::signed(ALICE), Origin::signed(ALICE),
@@ -1878,7 +1878,7 @@ fn crypto_hashes() {
// We offset data in the contract tables by 1. // We offset data in the contract tables by 1.
let mut params = vec![(n + 1) as u8]; let mut params = vec![(n + 1) as u8];
params.extend_from_slice(input); params.extend_from_slice(input);
let result = <Module<Test>>::bare_call( let result = <Pallet<Test>>::bare_call(
ALICE, ALICE,
addr.clone(), addr.clone(),
0, 0,
@@ -1896,7 +1896,7 @@ fn crypto_hashes() {
fn transfer_return_code() { fn transfer_return_code() {
let (wasm, code_hash) = compile_module::<Test>("transfer_return_code").unwrap(); let (wasm, code_hash) = compile_module::<Test>("transfer_return_code").unwrap();
ExtBuilder::default().existential_deposit(50).build().execute_with(|| { ExtBuilder::default().existential_deposit(50).build().execute_with(|| {
let subsistence = Module::<Test>::subsistence_threshold(); let subsistence = Pallet::<Test>::subsistence_threshold();
let _ = Balances::deposit_creating(&ALICE, 1000 * subsistence); let _ = Balances::deposit_creating(&ALICE, 1000 * subsistence);
assert_ok!( assert_ok!(
@@ -1943,7 +1943,7 @@ fn call_return_code() {
let (caller_code, caller_hash) = compile_module::<Test>("call_return_code").unwrap(); let (caller_code, caller_hash) = compile_module::<Test>("call_return_code").unwrap();
let (callee_code, callee_hash) = compile_module::<Test>("ok_trap_revert").unwrap(); let (callee_code, callee_hash) = compile_module::<Test>("ok_trap_revert").unwrap();
ExtBuilder::default().existential_deposit(50).build().execute_with(|| { ExtBuilder::default().existential_deposit(50).build().execute_with(|| {
let subsistence = Module::<Test>::subsistence_threshold(); let subsistence = Pallet::<Test>::subsistence_threshold();
let _ = Balances::deposit_creating(&ALICE, 1000 * subsistence); let _ = Balances::deposit_creating(&ALICE, 1000 * subsistence);
let _ = Balances::deposit_creating(&CHARLIE, 1000 * subsistence); let _ = Balances::deposit_creating(&CHARLIE, 1000 * subsistence);
@@ -2036,7 +2036,7 @@ fn instantiate_return_code() {
let (caller_code, caller_hash) = compile_module::<Test>("instantiate_return_code").unwrap(); let (caller_code, caller_hash) = compile_module::<Test>("instantiate_return_code").unwrap();
let (callee_code, callee_hash) = compile_module::<Test>("ok_trap_revert").unwrap(); let (callee_code, callee_hash) = compile_module::<Test>("ok_trap_revert").unwrap();
ExtBuilder::default().existential_deposit(50).build().execute_with(|| { ExtBuilder::default().existential_deposit(50).build().execute_with(|| {
let subsistence = Module::<Test>::subsistence_threshold(); let subsistence = Pallet::<Test>::subsistence_threshold();
let _ = Balances::deposit_creating(&ALICE, 1000 * subsistence); let _ = Balances::deposit_creating(&ALICE, 1000 * subsistence);
let _ = Balances::deposit_creating(&CHARLIE, 1000 * subsistence); let _ = Balances::deposit_creating(&CHARLIE, 1000 * subsistence);
let callee_hash = callee_hash.as_ref().to_vec(); let callee_hash = callee_hash.as_ref().to_vec();
@@ -2127,7 +2127,7 @@ fn instantiate_return_code() {
fn disabled_chain_extension_wont_deploy() { fn disabled_chain_extension_wont_deploy() {
let (code, _hash) = compile_module::<Test>("chain_extension").unwrap(); let (code, _hash) = compile_module::<Test>("chain_extension").unwrap();
ExtBuilder::default().existential_deposit(50).build().execute_with(|| { ExtBuilder::default().existential_deposit(50).build().execute_with(|| {
let subsistence = Module::<Test>::subsistence_threshold(); let subsistence = Pallet::<Test>::subsistence_threshold();
let _ = Balances::deposit_creating(&ALICE, 1000 * subsistence); let _ = Balances::deposit_creating(&ALICE, 1000 * subsistence);
TestExtension::disable(); TestExtension::disable();
assert_err_ignore_postinfo!( assert_err_ignore_postinfo!(
@@ -2148,7 +2148,7 @@ fn disabled_chain_extension_wont_deploy() {
fn disabled_chain_extension_errors_on_call() { fn disabled_chain_extension_errors_on_call() {
let (code, hash) = compile_module::<Test>("chain_extension").unwrap(); let (code, hash) = compile_module::<Test>("chain_extension").unwrap();
ExtBuilder::default().existential_deposit(50).build().execute_with(|| { ExtBuilder::default().existential_deposit(50).build().execute_with(|| {
let subsistence = Module::<Test>::subsistence_threshold(); let subsistence = Pallet::<Test>::subsistence_threshold();
let _ = Balances::deposit_creating(&ALICE, 1000 * subsistence); let _ = Balances::deposit_creating(&ALICE, 1000 * subsistence);
assert_ok!( assert_ok!(
Contracts::instantiate_with_code( Contracts::instantiate_with_code(
@@ -2179,7 +2179,7 @@ fn disabled_chain_extension_errors_on_call() {
fn chain_extension_works() { fn chain_extension_works() {
let (code, hash) = compile_module::<Test>("chain_extension").unwrap(); let (code, hash) = compile_module::<Test>("chain_extension").unwrap();
ExtBuilder::default().existential_deposit(50).build().execute_with(|| { ExtBuilder::default().existential_deposit(50).build().execute_with(|| {
let subsistence = Module::<Test>::subsistence_threshold(); let subsistence = Pallet::<Test>::subsistence_threshold();
let _ = Balances::deposit_creating(&ALICE, 1000 * subsistence); let _ = Balances::deposit_creating(&ALICE, 1000 * subsistence);
assert_ok!( assert_ok!(
Contracts::instantiate_with_code( Contracts::instantiate_with_code(
@@ -2248,7 +2248,7 @@ fn chain_extension_works() {
fn lazy_removal_works() { fn lazy_removal_works() {
let (code, hash) = compile_module::<Test>("self_destruct").unwrap(); let (code, hash) = compile_module::<Test>("self_destruct").unwrap();
ExtBuilder::default().existential_deposit(50).build().execute_with(|| { ExtBuilder::default().existential_deposit(50).build().execute_with(|| {
let subsistence = Module::<Test>::subsistence_threshold(); let subsistence = Pallet::<Test>::subsistence_threshold();
let _ = Balances::deposit_creating(&ALICE, 1000 * subsistence); let _ = Balances::deposit_creating(&ALICE, 1000 * subsistence);
assert_ok!( assert_ok!(
@@ -2308,7 +2308,7 @@ fn lazy_removal_partial_remove_works() {
let mut ext = ExtBuilder::default().existential_deposit(50).build(); let mut ext = ExtBuilder::default().existential_deposit(50).build();
let trie = ext.execute_with(|| { let trie = ext.execute_with(|| {
let subsistence = Module::<Test>::subsistence_threshold(); let subsistence = Pallet::<Test>::subsistence_threshold();
let _ = Balances::deposit_creating(&ALICE, 1000 * subsistence); let _ = Balances::deposit_creating(&ALICE, 1000 * subsistence);
assert_ok!( assert_ok!(
@@ -2389,7 +2389,7 @@ fn lazy_removal_partial_remove_works() {
fn lazy_removal_does_no_run_on_full_block() { fn lazy_removal_does_no_run_on_full_block() {
let (code, hash) = compile_module::<Test>("self_destruct").unwrap(); let (code, hash) = compile_module::<Test>("self_destruct").unwrap();
ExtBuilder::default().existential_deposit(50).build().execute_with(|| { ExtBuilder::default().existential_deposit(50).build().execute_with(|| {
let subsistence = Module::<Test>::subsistence_threshold(); let subsistence = Pallet::<Test>::subsistence_threshold();
let _ = Balances::deposit_creating(&ALICE, 1000 * subsistence); let _ = Balances::deposit_creating(&ALICE, 1000 * subsistence);
assert_ok!( assert_ok!(
@@ -2473,7 +2473,7 @@ fn lazy_removal_does_no_run_on_full_block() {
fn lazy_removal_does_not_use_all_weight() { fn lazy_removal_does_not_use_all_weight() {
let (code, hash) = compile_module::<Test>("self_destruct").unwrap(); let (code, hash) = compile_module::<Test>("self_destruct").unwrap();
ExtBuilder::default().existential_deposit(50).build().execute_with(|| { ExtBuilder::default().existential_deposit(50).build().execute_with(|| {
let subsistence = Module::<Test>::subsistence_threshold(); let subsistence = Pallet::<Test>::subsistence_threshold();
let _ = Balances::deposit_creating(&ALICE, 1000 * subsistence); let _ = Balances::deposit_creating(&ALICE, 1000 * subsistence);
assert_ok!( assert_ok!(
@@ -2543,7 +2543,7 @@ fn lazy_removal_does_not_use_all_weight() {
fn deletion_queue_full() { fn deletion_queue_full() {
let (code, hash) = compile_module::<Test>("self_destruct").unwrap(); let (code, hash) = compile_module::<Test>("self_destruct").unwrap();
ExtBuilder::default().existential_deposit(50).build().execute_with(|| { ExtBuilder::default().existential_deposit(50).build().execute_with(|| {
let subsistence = Module::<Test>::subsistence_threshold(); let subsistence = Pallet::<Test>::subsistence_threshold();
let _ = Balances::deposit_creating(&ALICE, 1000 * subsistence); let _ = Balances::deposit_creating(&ALICE, 1000 * subsistence);
assert_ok!( assert_ok!(
@@ -2669,7 +2669,7 @@ fn refcounter() {
let (wasm, code_hash) = compile_module::<Test>("self_destruct").unwrap(); let (wasm, code_hash) = compile_module::<Test>("self_destruct").unwrap();
ExtBuilder::default().existential_deposit(50).build().execute_with(|| { ExtBuilder::default().existential_deposit(50).build().execute_with(|| {
let _ = Balances::deposit_creating(&ALICE, 1_000_000); let _ = Balances::deposit_creating(&ALICE, 1_000_000);
let subsistence = Module::<Test>::subsistence_threshold(); let subsistence = Pallet::<Test>::subsistence_threshold();
// Create two contracts with the same code and check that they do in fact share it. // Create two contracts with the same code and check that they do in fact share it.
assert_ok!(Contracts::instantiate_with_code( assert_ok!(Contracts::instantiate_with_code(
@@ -2741,7 +2741,7 @@ fn reinstrument_does_charge() {
let (wasm, code_hash) = compile_module::<Test>("return_with_data").unwrap(); let (wasm, code_hash) = compile_module::<Test>("return_with_data").unwrap();
ExtBuilder::default().existential_deposit(50).build().execute_with(|| { ExtBuilder::default().existential_deposit(50).build().execute_with(|| {
let _ = Balances::deposit_creating(&ALICE, 1_000_000); let _ = Balances::deposit_creating(&ALICE, 1_000_000);
let subsistence = Module::<Test>::subsistence_threshold(); let subsistence = Pallet::<Test>::subsistence_threshold();
let zero = 0u32.to_le_bytes().encode(); let zero = 0u32.to_le_bytes().encode();
let code_len = wasm.len() as u32; let code_len = wasm.len() as u32;
@@ -29,7 +29,7 @@
use crate::{ use crate::{
CodeHash, CodeStorage, PristineCode, Schedule, Config, Error, Weight, CodeHash, CodeStorage, PristineCode, Schedule, Config, Error, Weight,
wasm::{prepare, PrefabWasmModule}, Module as Contracts, Event, wasm::{prepare, PrefabWasmModule}, Pallet as Contracts, Event,
gas::{GasMeter, Token}, gas::{GasMeter, Token},
weights::WeightInfo, weights::WeightInfo,
}; };
+1 -1
View File
@@ -245,7 +245,7 @@ where
mod tests { mod tests {
use super::*; use super::*;
use crate::{ use crate::{
CodeHash, BalanceOf, Error, Module as Contracts, CodeHash, BalanceOf, Error, Pallet as Contracts,
exec::{Ext, StorageKey, AccountIdOf, Executable, RentParams}, exec::{Ext, StorageKey, AccountIdOf, Executable, RentParams},
gas::GasMeter, gas::GasMeter,
tests::{Test, Call, ALICE, BOB}, tests::{Test, Call, ALICE, BOB},
@@ -24,10 +24,10 @@ use frame_support::{
IterableStorageMap, IterableStorageMap,
traits::{Currency, Get, EnsureOrigin, OnInitialize, UnfilteredDispatchable, schedule::DispatchTime}, traits::{Currency, Get, EnsureOrigin, OnInitialize, UnfilteredDispatchable, schedule::DispatchTime},
}; };
use frame_system::{RawOrigin, Module as System, self, EventRecord}; use frame_system::{RawOrigin, Pallet as System, self, EventRecord};
use sp_runtime::traits::{Bounded, One}; use sp_runtime::traits::{Bounded, One};
use crate::Module as Democracy; use crate::Pallet as Democracy;
const SEED: u32 = 0; const SEED: u32 = 0;
const MAX_REFERENDUMS: u32 = 99; const MAX_REFERENDUMS: u32 = 99;
+11 -11
View File
@@ -596,7 +596,7 @@ decl_module! {
if let Some((until, _)) = <Blacklist<T>>::get(proposal_hash) { if let Some((until, _)) = <Blacklist<T>>::get(proposal_hash) {
ensure!( ensure!(
<frame_system::Module<T>>::block_number() >= until, <frame_system::Pallet<T>>::block_number() >= until,
Error::<T>::ProposalBlacklisted, Error::<T>::ProposalBlacklisted,
); );
} }
@@ -688,7 +688,7 @@ decl_module! {
ensure!(!<NextExternal<T>>::exists(), Error::<T>::DuplicateProposal); ensure!(!<NextExternal<T>>::exists(), Error::<T>::DuplicateProposal);
if let Some((until, _)) = <Blacklist<T>>::get(proposal_hash) { if let Some((until, _)) = <Blacklist<T>>::get(proposal_hash) {
ensure!( ensure!(
<frame_system::Module<T>>::block_number() >= until, <frame_system::Pallet<T>>::block_number() >= until,
Error::<T>::ProposalBlacklisted, Error::<T>::ProposalBlacklisted,
); );
} }
@@ -776,7 +776,7 @@ decl_module! {
ensure!(proposal_hash == e_proposal_hash, Error::<T>::InvalidHash); ensure!(proposal_hash == e_proposal_hash, Error::<T>::InvalidHash);
<NextExternal<T>>::kill(); <NextExternal<T>>::kill();
let now = <frame_system::Module<T>>::block_number(); let now = <frame_system::Pallet<T>>::block_number();
Self::inject_referendum(now + voting_period, proposal_hash, threshold, delay); Self::inject_referendum(now + voting_period, proposal_hash, threshold, delay);
} }
@@ -806,7 +806,7 @@ decl_module! {
.err().ok_or(Error::<T>::AlreadyVetoed)?; .err().ok_or(Error::<T>::AlreadyVetoed)?;
existing_vetoers.insert(insert_position, who.clone()); existing_vetoers.insert(insert_position, who.clone());
let until = <frame_system::Module<T>>::block_number() + T::CooloffPeriod::get(); let until = <frame_system::Pallet<T>>::block_number() + T::CooloffPeriod::get();
<Blacklist<T>>::insert(&proposal_hash, (until, existing_vetoers)); <Blacklist<T>>::insert(&proposal_hash, (until, existing_vetoers));
Self::deposit_event(RawEvent::Vetoed(who, proposal_hash, until)); Self::deposit_event(RawEvent::Vetoed(who, proposal_hash, until));
@@ -1004,7 +1004,7 @@ decl_module! {
_ => None, _ => None,
}).ok_or(Error::<T>::PreimageMissing)?; }).ok_or(Error::<T>::PreimageMissing)?;
let now = <frame_system::Module<T>>::block_number(); let now = <frame_system::Pallet<T>>::block_number();
let (voting, enactment) = (T::VotingPeriod::get(), T::EnactmentPeriod::get()); let (voting, enactment) = (T::VotingPeriod::get(), T::EnactmentPeriod::get());
let additional = if who == provider { Zero::zero() } else { enactment }; let additional = if who == provider { Zero::zero() } else { enactment };
ensure!(now >= since + voting + additional, Error::<T>::TooEarly); ensure!(now >= since + voting + additional, Error::<T>::TooEarly);
@@ -1209,7 +1209,7 @@ impl<T: Config> Module<T> {
delay: T::BlockNumber delay: T::BlockNumber
) -> ReferendumIndex { ) -> ReferendumIndex {
<Module<T>>::inject_referendum( <Module<T>>::inject_referendum(
<frame_system::Module<T>>::block_number() + T::VotingPeriod::get(), <frame_system::Pallet<T>>::block_number() + T::VotingPeriod::get(),
proposal_hash, proposal_hash,
threshold, threshold,
delay delay
@@ -1308,7 +1308,7 @@ impl<T: Config> Module<T> {
Some(ReferendumInfo::Finished{end, approved}) => Some(ReferendumInfo::Finished{end, approved}) =>
if let Some((lock_periods, balance)) = votes[i].1.locked_if(approved) { if let Some((lock_periods, balance)) = votes[i].1.locked_if(approved) {
let unlock_at = end + T::EnactmentPeriod::get() * lock_periods.into(); let unlock_at = end + T::EnactmentPeriod::get() * lock_periods.into();
let now = system::Module::<T>::block_number(); let now = system::Pallet::<T>::block_number();
if now < unlock_at { if now < unlock_at {
ensure!(matches!(scope, UnvoteScope::Any), Error::<T>::NoPermission); ensure!(matches!(scope, UnvoteScope::Any), Error::<T>::NoPermission);
prior.accumulate(unlock_at, balance) prior.accumulate(unlock_at, balance)
@@ -1435,7 +1435,7 @@ impl<T: Config> Module<T> {
} => { } => {
// remove any delegation votes to our current target. // remove any delegation votes to our current target.
let votes = Self::reduce_upstream_delegation(&target, conviction.votes(balance)); let votes = Self::reduce_upstream_delegation(&target, conviction.votes(balance));
let now = system::Module::<T>::block_number(); let now = system::Pallet::<T>::block_number();
let lock_periods = conviction.lock_periods().into(); let lock_periods = conviction.lock_periods().into();
prior.accumulate(now + T::EnactmentPeriod::get() * lock_periods, balance); prior.accumulate(now + T::EnactmentPeriod::get() * lock_periods, balance);
voting.set_common(delegations, prior); voting.set_common(delegations, prior);
@@ -1455,7 +1455,7 @@ impl<T: Config> Module<T> {
/// a security hole) but may be reduced from what they are currently. /// a security hole) but may be reduced from what they are currently.
fn update_lock(who: &T::AccountId) { fn update_lock(who: &T::AccountId) {
let lock_needed = VotingOf::<T>::mutate(who, |voting| { let lock_needed = VotingOf::<T>::mutate(who, |voting| {
voting.rejig(system::Module::<T>::block_number()); voting.rejig(system::Pallet::<T>::block_number());
voting.locked_balance() voting.locked_balance()
}); });
if lock_needed.is_zero() { if lock_needed.is_zero() {
@@ -1716,7 +1716,7 @@ impl<T: Config> Module<T> {
.saturating_mul(T::PreimageByteDeposit::get()); .saturating_mul(T::PreimageByteDeposit::get());
T::Currency::reserve(&who, deposit)?; T::Currency::reserve(&who, deposit)?;
let now = <frame_system::Module<T>>::block_number(); let now = <frame_system::Pallet<T>>::block_number();
let a = PreimageStatus::Available { let a = PreimageStatus::Available {
data: encoded_proposal, data: encoded_proposal,
provider: who.clone(), provider: who.clone(),
@@ -1738,7 +1738,7 @@ impl<T: Config> Module<T> {
let status = Preimages::<T>::get(&proposal_hash).ok_or(Error::<T>::NotImminent)?; let status = Preimages::<T>::get(&proposal_hash).ok_or(Error::<T>::NotImminent)?;
let expiry = status.to_missing_expiry().ok_or(Error::<T>::DuplicatePreimage)?; let expiry = status.to_missing_expiry().ok_or(Error::<T>::DuplicatePreimage)?;
let now = <frame_system::Module<T>>::block_number(); let now = <frame_system::Pallet<T>>::block_number();
let free = <BalanceOf<T>>::zero(); let free = <BalanceOf<T>>::zero();
let a = PreimageStatus::Available { let a = PreimageStatus::Available {
data: encoded_proposal, data: encoded_proposal,
+5 -5
View File
@@ -60,10 +60,10 @@ frame_support::construct_runtime!(
NodeBlock = Block, NodeBlock = Block,
UncheckedExtrinsic = UncheckedExtrinsic, UncheckedExtrinsic = UncheckedExtrinsic,
{ {
System: frame_system::{Module, Call, Config, Storage, Event<T>}, System: frame_system::{Pallet, Call, Config, Storage, Event<T>},
Balances: pallet_balances::{Module, Call, Storage, Config<T>, Event<T>}, Balances: pallet_balances::{Pallet, Call, Storage, Config<T>, Event<T>},
Scheduler: pallet_scheduler::{Module, Call, Storage, Config, Event<T>}, Scheduler: pallet_scheduler::{Pallet, Call, Storage, Config, Event<T>},
Democracy: pallet_democracy::{Module, Call, Storage, Config, Event<T>}, Democracy: pallet_democracy::{Pallet, Call, Storage, Config, Event<T>},
} }
); );
@@ -161,7 +161,7 @@ impl Contains<u64> for OneToFive {
impl Config for Test { impl Config for Test {
type Proposal = Call; type Proposal = Call;
type Event = Event; type Event = Event;
type Currency = pallet_balances::Module<Self>; type Currency = pallet_balances::Pallet<Self>;
type EnactmentPeriod = EnactmentPeriod; type EnactmentPeriod = EnactmentPeriod;
type LaunchPeriod = LaunchPeriod; type LaunchPeriod = LaunchPeriod;
type VotingPeriod = VotingPeriod; type VotingPeriod = VotingPeriod;
@@ -18,7 +18,7 @@
//! Two phase election pallet benchmarking. //! Two phase election pallet benchmarking.
use super::*; use super::*;
use crate::Module as MultiPhase; use crate::Pallet as MultiPhase;
use frame_benchmarking::impl_benchmark_test_suite; use frame_benchmarking::impl_benchmark_test_suite;
use frame_support::{assert_ok, traits::OnInitialize}; use frame_support::{assert_ok, traits::OnInitialize};
use frame_system::RawOrigin; use frame_system::RawOrigin;
@@ -25,7 +25,7 @@ macro_rules! log {
($level:tt, $pattern:expr $(, $values:expr)* $(,)?) => { ($level:tt, $pattern:expr $(, $values:expr)* $(,)?) => {
log::$level!( log::$level!(
target: $crate::LOG_TARGET, target: $crate::LOG_TARGET,
concat!("[#{:?}] 🗳 ", $pattern), <frame_system::Module<T>>::block_number() $(, $values)* concat!("[#{:?}] 🗳 ", $pattern), <frame_system::Pallet<T>>::block_number() $(, $values)*
) )
}; };
} }
@@ -52,9 +52,9 @@ frame_support::construct_runtime!(
NodeBlock = Block, NodeBlock = Block,
UncheckedExtrinsic = UncheckedExtrinsic UncheckedExtrinsic = UncheckedExtrinsic
{ {
System: frame_system::{Module, Call, Event<T>, Config}, System: frame_system::{Pallet, Call, Event<T>, Config},
Balances: pallet_balances::{Module, Call, Event<T>, Config<T>}, Balances: pallet_balances::{Pallet, Call, Event<T>, Config<T>},
MultiPhase: multi_phase::{Module, Call, Event<T>}, MultiPhase: multi_phase::{Pallet, Call, Event<T>},
} }
); );
@@ -1096,7 +1096,7 @@ mod tests {
type Event = Event; type Event = Event;
type DustRemoval = (); type DustRemoval = ();
type ExistentialDeposit = ExistentialDeposit; type ExistentialDeposit = ExistentialDeposit;
type AccountStore = frame_system::Module<Test>; type AccountStore = frame_system::Pallet<Test>;
type MaxLocks = (); type MaxLocks = ();
type WeightInfo = (); type WeightInfo = ();
} }
@@ -1187,9 +1187,9 @@ mod tests {
NodeBlock = Block, NodeBlock = Block,
UncheckedExtrinsic = UncheckedExtrinsic UncheckedExtrinsic = UncheckedExtrinsic
{ {
System: frame_system::{Module, Call, Event<T>}, System: frame_system::{Pallet, Call, Event<T>},
Balances: pallet_balances::{Module, Call, Event<T>, Config<T>}, Balances: pallet_balances::{Pallet, Call, Event<T>, Config<T>},
Elections: elections_phragmen::{Module, Call, Event<T>, Config<T>}, Elections: elections_phragmen::{Pallet, Call, Event<T>, Config<T>},
} }
); );
+3 -3
View File
@@ -759,7 +759,7 @@ impl<T: Config> Module<T> {
// if there's a tally in progress, then next tally can begin immediately afterwards // if there's a tally in progress, then next tally can begin immediately afterwards
(tally_end, c.len() - leavers.len() + comers as usize, comers) (tally_end, c.len() - leavers.len() + comers as usize, comers)
} else { } else {
(<frame_system::Module<T>>::block_number(), c.len(), 0) (<frame_system::Pallet<T>>::block_number(), c.len(), 0)
}; };
if count < desired_seats as usize { if count < desired_seats as usize {
Some(next_possible) Some(next_possible)
@@ -914,7 +914,7 @@ impl<T: Config> Module<T> {
fn start_tally() { fn start_tally() {
let members = Self::members(); let members = Self::members();
let desired_seats = Self::desired_seats() as usize; let desired_seats = Self::desired_seats() as usize;
let number = <frame_system::Module<T>>::block_number(); let number = <frame_system::Pallet<T>>::block_number();
let expiring = let expiring =
members.iter().take_while(|i| i.1 <= number).map(|i| i.0.clone()).collect::<Vec<_>>(); members.iter().take_while(|i| i.1 <= number).map(|i| i.0.clone()).collect::<Vec<_>>();
let retaining_seats = members.len() - expiring.len(); let retaining_seats = members.len() - expiring.len();
@@ -942,7 +942,7 @@ impl<T: Config> Module<T> {
.ok_or("finalize can only be called after a tally is started.")?; .ok_or("finalize can only be called after a tally is started.")?;
let leaderboard: Vec<(BalanceOf<T>, T::AccountId)> = <Leaderboard<T>>::take() let leaderboard: Vec<(BalanceOf<T>, T::AccountId)> = <Leaderboard<T>>::take()
.unwrap_or_default(); .unwrap_or_default();
let new_expiry = <frame_system::Module<T>>::block_number() + Self::term_duration(); let new_expiry = <frame_system::Pallet<T>>::block_number() + Self::term_duration();
// return bond to winners. // return bond to winners.
let candidacy_bond = T::CandidacyBond::get(); let candidacy_bond = T::CandidacyBond::get();
+3 -3
View File
@@ -135,9 +135,9 @@ frame_support::construct_runtime!(
NodeBlock = Block, NodeBlock = Block,
UncheckedExtrinsic = UncheckedExtrinsic UncheckedExtrinsic = UncheckedExtrinsic
{ {
System: system::{Module, Call, Event<T>}, System: system::{Pallet, Call, Event<T>},
Balances: pallet_balances::{Module, Call, Event<T>, Config<T>}, Balances: pallet_balances::{Pallet, Call, Event<T>, Config<T>},
Elections: elections::{Module, Call, Event<T>, Config<T>}, Elections: elections::{Pallet, Call, Event<T>, Config<T>},
} }
); );
@@ -49,8 +49,8 @@ frame_support::construct_runtime!(
NodeBlock = Block, NodeBlock = Block,
UncheckedExtrinsic = UncheckedExtrinsic, UncheckedExtrinsic = UncheckedExtrinsic,
{ {
System: frame_system::{Module, Call, Config, Storage, Event<T>}, System: frame_system::{Pallet, Call, Config, Storage, Event<T>},
Example: example_offchain_worker::{Module, Call, Storage, Event<T>, ValidateUnsigned}, Example: example_offchain_worker::{Pallet, Call, Storage, Event<T>, ValidateUnsigned},
} }
); );
@@ -33,8 +33,8 @@ frame_support::construct_runtime!(
NodeBlock = Block, NodeBlock = Block,
UncheckedExtrinsic = UncheckedExtrinsic, UncheckedExtrinsic = UncheckedExtrinsic,
{ {
System: frame_system::{Module, Call, Config, Storage, Event<T>}, System: frame_system::{Pallet, Call, Config, Storage, Event<T>},
Example: pallet_example_parallel::{Module, Call, Storage}, Example: pallet_example_parallel::{Pallet, Call, Storage},
} }
); );
+3 -3
View File
@@ -758,9 +758,9 @@ mod tests {
NodeBlock = Block, NodeBlock = Block,
UncheckedExtrinsic = UncheckedExtrinsic, UncheckedExtrinsic = UncheckedExtrinsic,
{ {
System: frame_system::{Module, Call, Config, Storage, Event<T>}, System: frame_system::{Pallet, Call, Config, Storage, Event<T>},
Balances: pallet_balances::{Module, Call, Storage, Config<T>, Event<T>}, Balances: pallet_balances::{Pallet, Call, Storage, Config<T>, Event<T>},
Example: pallet_example::{Module, Call, Storage, Config<T>, Event<T>}, Example: pallet_example::{Pallet, Call, Storage, Config<T>, Event<T>},
} }
); );
+2 -2
View File
@@ -35,7 +35,7 @@ The default Substrate node template declares the [`Executive`](https://docs.rs/f
```rust ```rust
# #
/// Executive: handles dispatch to the various modules. /// Executive: handles dispatch to the various modules.
pub type Executive = executive::Executive<Runtime, Block, Context, Runtime, AllModules>; pub type Executive = executive::Executive<Runtime, Block, Context, Runtime, AllPallets>;
``` ```
### Custom `OnRuntimeUpgrade` logic ### Custom `OnRuntimeUpgrade` logic
@@ -54,7 +54,7 @@ impl frame_support::traits::OnRuntimeUpgrade for CustomOnRuntimeUpgrade {
} }
} }
pub type Executive = executive::Executive<Runtime, Block, Context, Runtime, AllModules, CustomOnRuntimeUpgrade>; pub type Executive = executive::Executive<Runtime, Block, Context, Runtime, AllPallets, CustomOnRuntimeUpgrade>;
``` ```
License: Apache-2.0 License: Apache-2.0
+64 -64
View File
@@ -59,7 +59,7 @@
//! # type Context = frame_system::ChainContext<Runtime>; //! # type Context = frame_system::ChainContext<Runtime>;
//! # pub type Block = generic::Block<Header, UncheckedExtrinsic>; //! # pub type Block = generic::Block<Header, UncheckedExtrinsic>;
//! # pub type Balances = u64; //! # pub type Balances = u64;
//! # pub type AllModules = u64; //! # pub type AllPallets = u64;
//! # pub enum Runtime {}; //! # pub enum Runtime {};
//! # use sp_runtime::transaction_validity::{ //! # use sp_runtime::transaction_validity::{
//! # TransactionValidity, UnknownTransaction, TransactionSource, //! # TransactionValidity, UnknownTransaction, TransactionSource,
@@ -73,7 +73,7 @@
//! # } //! # }
//! # } //! # }
//! /// Executive: handles dispatch to the various modules. //! /// Executive: handles dispatch to the various modules.
//! pub type Executive = executive::Executive<Runtime, Block, Context, Runtime, AllModules>; //! pub type Executive = executive::Executive<Runtime, Block, Context, Runtime, AllPallets>;
//! ``` //! ```
//! //!
//! ### Custom `OnRuntimeUpgrade` logic //! ### Custom `OnRuntimeUpgrade` logic
@@ -90,7 +90,7 @@
//! # type Context = frame_system::ChainContext<Runtime>; //! # type Context = frame_system::ChainContext<Runtime>;
//! # pub type Block = generic::Block<Header, UncheckedExtrinsic>; //! # pub type Block = generic::Block<Header, UncheckedExtrinsic>;
//! # pub type Balances = u64; //! # pub type Balances = u64;
//! # pub type AllModules = u64; //! # pub type AllPallets = u64;
//! # pub enum Runtime {}; //! # pub enum Runtime {};
//! # use sp_runtime::transaction_validity::{ //! # use sp_runtime::transaction_validity::{
//! # TransactionValidity, UnknownTransaction, TransactionSource, //! # TransactionValidity, UnknownTransaction, TransactionSource,
@@ -111,7 +111,7 @@
//! } //! }
//! } //! }
//! //!
//! pub type Executive = executive::Executive<Runtime, Block, Context, Runtime, AllModules, CustomOnRuntimeUpgrade>; //! pub type Executive = executive::Executive<Runtime, Block, Context, Runtime, AllPallets, CustomOnRuntimeUpgrade>;
//! ``` //! ```
#![cfg_attr(not(feature = "std"), no_std)] #![cfg_attr(not(feature = "std"), no_std)]
@@ -144,12 +144,12 @@ pub type OriginOf<E, C> = <CallOf<E, C> as Dispatchable>::Origin;
/// - `Block`: The block type of the runtime /// - `Block`: The block type of the runtime
/// - `Context`: The context that is used when checking an extrinsic. /// - `Context`: The context that is used when checking an extrinsic.
/// - `UnsignedValidator`: The unsigned transaction validator of the runtime. /// - `UnsignedValidator`: The unsigned transaction validator of the runtime.
/// - `AllModules`: Tuple that contains all modules. Will be used to call e.g. `on_initialize`. /// - `AllPallets`: Tuple that contains all modules. Will be used to call e.g. `on_initialize`.
/// - `OnRuntimeUpgrade`: Custom logic that should be called after a runtime upgrade. Modules are /// - `OnRuntimeUpgrade`: Custom logic that should be called after a runtime upgrade. Modules are
/// already called by `AllModules`. It will be called before all modules will /// already called by `AllPallets`. It will be called before all modules will
/// be called. /// be called.
pub struct Executive<System, Block, Context, UnsignedValidator, AllModules, OnRuntimeUpgrade = ()>( pub struct Executive<System, Block, Context, UnsignedValidator, AllPallets, OnRuntimeUpgrade = ()>(
PhantomData<(System, Block, Context, UnsignedValidator, AllModules, OnRuntimeUpgrade)> PhantomData<(System, Block, Context, UnsignedValidator, AllPallets, OnRuntimeUpgrade)>
); );
impl< impl<
@@ -157,7 +157,7 @@ impl<
Block: traits::Block<Header=System::Header, Hash=System::Hash>, Block: traits::Block<Header=System::Header, Hash=System::Hash>,
Context: Default, Context: Default,
UnsignedValidator, UnsignedValidator,
AllModules: AllPallets:
OnRuntimeUpgrade + OnRuntimeUpgrade +
OnInitialize<System::BlockNumber> + OnInitialize<System::BlockNumber> +
OnIdle<System::BlockNumber> + OnIdle<System::BlockNumber> +
@@ -165,7 +165,7 @@ impl<
OffchainWorker<System::BlockNumber>, OffchainWorker<System::BlockNumber>,
COnRuntimeUpgrade: OnRuntimeUpgrade, COnRuntimeUpgrade: OnRuntimeUpgrade,
> ExecuteBlock<Block> for > ExecuteBlock<Block> for
Executive<System, Block, Context, UnsignedValidator, AllModules, COnRuntimeUpgrade> Executive<System, Block, Context, UnsignedValidator, AllPallets, COnRuntimeUpgrade>
where where
Block::Extrinsic: Checkable<Context> + Codec, Block::Extrinsic: Checkable<Context> + Codec,
CheckedOf<Block::Extrinsic, Context>: CheckedOf<Block::Extrinsic, Context>:
@@ -176,7 +176,7 @@ where
UnsignedValidator: ValidateUnsigned<Call=CallOf<Block::Extrinsic, Context>>, UnsignedValidator: ValidateUnsigned<Call=CallOf<Block::Extrinsic, Context>>,
{ {
fn execute_block(block: Block) { fn execute_block(block: Block) {
Executive::<System, Block, Context, UnsignedValidator, AllModules>::execute_block(block); Executive::<System, Block, Context, UnsignedValidator, AllPallets>::execute_block(block);
} }
} }
@@ -185,13 +185,13 @@ impl<
Block: traits::Block<Header = System::Header, Hash = System::Hash>, Block: traits::Block<Header = System::Header, Hash = System::Hash>,
Context: Default, Context: Default,
UnsignedValidator, UnsignedValidator,
AllModules: OnRuntimeUpgrade AllPallets: OnRuntimeUpgrade
+ OnInitialize<System::BlockNumber> + OnInitialize<System::BlockNumber>
+ OnIdle<System::BlockNumber> + OnIdle<System::BlockNumber>
+ OnFinalize<System::BlockNumber> + OnFinalize<System::BlockNumber>
+ OffchainWorker<System::BlockNumber>, + OffchainWorker<System::BlockNumber>,
COnRuntimeUpgrade: OnRuntimeUpgrade, COnRuntimeUpgrade: OnRuntimeUpgrade,
> Executive<System, Block, Context, UnsignedValidator, AllModules, COnRuntimeUpgrade> > Executive<System, Block, Context, UnsignedValidator, AllPallets, COnRuntimeUpgrade>
where where
Block::Extrinsic: Checkable<Context> + Codec, Block::Extrinsic: Checkable<Context> + Codec,
CheckedOf<Block::Extrinsic, Context>: Applyable + GetDispatchInfo, CheckedOf<Block::Extrinsic, Context>: Applyable + GetDispatchInfo,
@@ -204,10 +204,10 @@ where
pub fn execute_on_runtime_upgrade() -> frame_support::weights::Weight { pub fn execute_on_runtime_upgrade() -> frame_support::weights::Weight {
let mut weight = 0; let mut weight = 0;
weight = weight.saturating_add( weight = weight.saturating_add(
<frame_system::Module<System> as OnRuntimeUpgrade>::on_runtime_upgrade(), <frame_system::Pallet<System> as OnRuntimeUpgrade>::on_runtime_upgrade(),
); );
weight = weight.saturating_add(COnRuntimeUpgrade::on_runtime_upgrade()); weight = weight.saturating_add(COnRuntimeUpgrade::on_runtime_upgrade());
weight = weight.saturating_add(<AllModules as OnRuntimeUpgrade>::on_runtime_upgrade()); weight = weight.saturating_add(<AllPallets as OnRuntimeUpgrade>::on_runtime_upgrade());
weight weight
} }
@@ -218,7 +218,7 @@ where
#[cfg(feature = "try-runtime")] #[cfg(feature = "try-runtime")]
pub fn try_runtime_upgrade() -> Result<frame_support::weights::Weight, &'static str> { pub fn try_runtime_upgrade() -> Result<frame_support::weights::Weight, &'static str> {
< <
(frame_system::Module::<System>, COnRuntimeUpgrade, AllModules) (frame_system::Pallet::<System>, COnRuntimeUpgrade, AllPallets)
as as
OnRuntimeUpgrade OnRuntimeUpgrade
>::pre_upgrade()?; >::pre_upgrade()?;
@@ -226,7 +226,7 @@ where
let weight = Self::execute_on_runtime_upgrade(); let weight = Self::execute_on_runtime_upgrade();
< <
(frame_system::Module::<System>, COnRuntimeUpgrade, AllModules) (frame_system::Pallet::<System>, COnRuntimeUpgrade, AllPallets)
as as
OnRuntimeUpgrade OnRuntimeUpgrade
>::post_upgrade()?; >::post_upgrade()?;
@@ -265,24 +265,24 @@ where
if Self::runtime_upgraded() { if Self::runtime_upgraded() {
weight = weight.saturating_add(Self::execute_on_runtime_upgrade()); weight = weight.saturating_add(Self::execute_on_runtime_upgrade());
} }
<frame_system::Module<System>>::initialize( <frame_system::Pallet<System>>::initialize(
block_number, block_number,
parent_hash, parent_hash,
digest, digest,
frame_system::InitKind::Full, frame_system::InitKind::Full,
); );
weight = weight.saturating_add( weight = weight.saturating_add(
<frame_system::Module<System> as OnInitialize<System::BlockNumber>>::on_initialize(*block_number) <frame_system::Pallet<System> as OnInitialize<System::BlockNumber>>::on_initialize(*block_number)
); );
weight = weight.saturating_add( weight = weight.saturating_add(
<AllModules as OnInitialize<System::BlockNumber>>::on_initialize(*block_number) <AllPallets as OnInitialize<System::BlockNumber>>::on_initialize(*block_number)
); );
weight = weight.saturating_add( weight = weight.saturating_add(
<System::BlockWeights as frame_support::traits::Get<_>>::get().base_block <System::BlockWeights as frame_support::traits::Get<_>>::get().base_block
); );
<frame_system::Module::<System>>::register_extra_weight_unchecked(weight, DispatchClass::Mandatory); <frame_system::Pallet::<System>>::register_extra_weight_unchecked(weight, DispatchClass::Mandatory);
frame_system::Module::<System>::note_finished_initialize(); frame_system::Pallet::<System>::note_finished_initialize();
} }
/// Returns if the runtime was upgraded since the last time this function was called. /// Returns if the runtime was upgraded since the last time this function was called.
@@ -308,7 +308,7 @@ where
let n = header.number().clone(); let n = header.number().clone();
assert!( assert!(
n > System::BlockNumber::zero() n > System::BlockNumber::zero()
&& <frame_system::Module<System>>::block_hash(n - System::BlockNumber::one()) == *header.parent_hash(), && <frame_system::Pallet<System>>::block_hash(n - System::BlockNumber::one()) == *header.parent_hash(),
"Parent hash should be valid.", "Parent hash should be valid.",
); );
} }
@@ -350,7 +350,7 @@ where
}); });
// post-extrinsics book-keeping // post-extrinsics book-keeping
<frame_system::Module<System>>::note_finished_extrinsics(); <frame_system::Pallet<System>>::note_finished_extrinsics();
Self::idle_and_finalize_hook(block_number); Self::idle_and_finalize_hook(block_number);
} }
@@ -360,36 +360,36 @@ where
pub fn finalize_block() -> System::Header { pub fn finalize_block() -> System::Header {
sp_io::init_tracing(); sp_io::init_tracing();
sp_tracing::enter_span!( sp_tracing::Level::TRACE, "finalize_block" ); sp_tracing::enter_span!( sp_tracing::Level::TRACE, "finalize_block" );
<frame_system::Module<System>>::note_finished_extrinsics(); <frame_system::Pallet<System>>::note_finished_extrinsics();
let block_number = <frame_system::Module<System>>::block_number(); let block_number = <frame_system::Pallet<System>>::block_number();
Self::idle_and_finalize_hook(block_number); Self::idle_and_finalize_hook(block_number);
<frame_system::Module<System>>::finalize() <frame_system::Pallet<System>>::finalize()
} }
fn idle_and_finalize_hook(block_number: NumberFor<Block>) { fn idle_and_finalize_hook(block_number: NumberFor<Block>) {
let weight = <frame_system::Module<System>>::block_weight(); let weight = <frame_system::Pallet<System>>::block_weight();
let max_weight = <System::BlockWeights as frame_support::traits::Get<_>>::get().max_block; let max_weight = <System::BlockWeights as frame_support::traits::Get<_>>::get().max_block;
let mut remaining_weight = max_weight.saturating_sub(weight.total()); let mut remaining_weight = max_weight.saturating_sub(weight.total());
if remaining_weight > 0 { if remaining_weight > 0 {
let mut used_weight = let mut used_weight =
<frame_system::Module<System> as OnIdle<System::BlockNumber>>::on_idle( <frame_system::Pallet<System> as OnIdle<System::BlockNumber>>::on_idle(
block_number, block_number,
remaining_weight remaining_weight
); );
remaining_weight = remaining_weight.saturating_sub(used_weight); remaining_weight = remaining_weight.saturating_sub(used_weight);
used_weight = <AllModules as OnIdle<System::BlockNumber>>::on_idle( used_weight = <AllPallets as OnIdle<System::BlockNumber>>::on_idle(
block_number, block_number,
remaining_weight remaining_weight
) )
.saturating_add(used_weight); .saturating_add(used_weight);
<frame_system::Module::<System>>::register_extra_weight_unchecked(used_weight, DispatchClass::Mandatory); <frame_system::Pallet::<System>>::register_extra_weight_unchecked(used_weight, DispatchClass::Mandatory);
} }
<frame_system::Module<System> as OnFinalize<System::BlockNumber>>::on_finalize(block_number); <frame_system::Pallet<System> as OnFinalize<System::BlockNumber>>::on_finalize(block_number);
<AllModules as OnFinalize<System::BlockNumber>>::on_finalize(block_number); <AllPallets as OnFinalize<System::BlockNumber>>::on_finalize(block_number);
} }
/// Apply extrinsic outside of the block execution function. /// Apply extrinsic outside of the block execution function.
@@ -419,7 +419,7 @@ where
// We don't need to make sure to `note_extrinsic` only after we know it's going to be // We don't need to make sure to `note_extrinsic` only after we know it's going to be
// executed to prevent it from leaking in storage since at this point, it will either // executed to prevent it from leaking in storage since at this point, it will either
// execute or panic (and revert storage changes). // execute or panic (and revert storage changes).
<frame_system::Module<System>>::note_extrinsic(to_note); <frame_system::Pallet<System>>::note_extrinsic(to_note);
// AUDIT: Under no circumstances may this function panic from here onwards. // AUDIT: Under no circumstances may this function panic from here onwards.
@@ -427,7 +427,7 @@ where
let dispatch_info = xt.get_dispatch_info(); let dispatch_info = xt.get_dispatch_info();
let r = Applyable::apply::<UnsignedValidator>(xt, &dispatch_info, encoded_len)?; let r = Applyable::apply::<UnsignedValidator>(xt, &dispatch_info, encoded_len)?;
<frame_system::Module<System>>::note_applied_extrinsic(&r, dispatch_info); <frame_system::Pallet<System>>::note_applied_extrinsic(&r, dispatch_info);
Ok(r.map(|_| ()).map_err(|e| e.error)) Ok(r.map(|_| ()).map_err(|e| e.error))
} }
@@ -435,7 +435,7 @@ where
fn final_checks(header: &System::Header) { fn final_checks(header: &System::Header) {
sp_tracing::enter_span!(sp_tracing::Level::TRACE, "final_checks"); sp_tracing::enter_span!(sp_tracing::Level::TRACE, "final_checks");
// remove temporaries // remove temporaries
let new_header = <frame_system::Module<System>>::finalize(); let new_header = <frame_system::Pallet<System>>::finalize();
// check digest // check digest
assert_eq!( assert_eq!(
@@ -499,7 +499,7 @@ where
// OffchainWorker RuntimeApi should skip initialization. // OffchainWorker RuntimeApi should skip initialization.
let digests = header.digest().clone(); let digests = header.digest().clone();
<frame_system::Module<System>>::initialize( <frame_system::Pallet<System>>::initialize(
header.number(), header.number(),
header.parent_hash(), header.parent_hash(),
&digests, &digests,
@@ -511,7 +511,7 @@ where
// as well. // as well.
frame_system::BlockHash::<System>::insert(header.number(), header.hash()); frame_system::BlockHash::<System>::insert(header.number(), header.hash());
<AllModules as OffchainWorker<System::BlockNumber>>::offchain_worker(*header.number()) <AllPallets as OffchainWorker<System::BlockNumber>>::offchain_worker(*header.number())
} }
} }
@@ -628,9 +628,9 @@ mod tests {
NodeBlock = TestBlock, NodeBlock = TestBlock,
UncheckedExtrinsic = TestUncheckedExtrinsic UncheckedExtrinsic = TestUncheckedExtrinsic
{ {
System: frame_system::{Module, Call, Config, Storage, Event<T>}, System: frame_system::{Pallet, Call, Config, Storage, Event<T>},
Balances: pallet_balances::{Module, Call, Storage, Config<T>, Event<T>}, Balances: pallet_balances::{Pallet, Call, Storage, Config<T>, Event<T>},
Custom: custom::{Module, Call, ValidateUnsigned}, Custom: custom::{Pallet, Call, ValidateUnsigned},
} }
); );
@@ -741,7 +741,7 @@ mod tests {
Block<TestXt>, Block<TestXt>,
ChainContext<Runtime>, ChainContext<Runtime>,
Runtime, Runtime,
AllModules, AllPallets,
CustomOnRuntimeUpgrade CustomOnRuntimeUpgrade
>; >;
@@ -780,8 +780,8 @@ mod tests {
)); ));
let r = Executive::apply_extrinsic(xt); let r = Executive::apply_extrinsic(xt);
assert!(r.is_ok()); assert!(r.is_ok());
assert_eq!(<pallet_balances::Module<Runtime>>::total_balance(&1), 142 - fee); assert_eq!(<pallet_balances::Pallet<Runtime>>::total_balance(&1), 142 - fee);
assert_eq!(<pallet_balances::Module<Runtime>>::total_balance(&2), 69); assert_eq!(<pallet_balances::Pallet<Runtime>>::total_balance(&2), 69);
}); });
} }
@@ -857,7 +857,7 @@ mod tests {
Digest::default(), Digest::default(),
)); ));
assert!(Executive::apply_extrinsic(xt).is_err()); assert!(Executive::apply_extrinsic(xt).is_err());
assert_eq!(<frame_system::Module<Runtime>>::extrinsic_index(), Some(0)); assert_eq!(<frame_system::Pallet<Runtime>>::extrinsic_index(), Some(0));
}); });
} }
@@ -883,7 +883,7 @@ mod tests {
Digest::default(), Digest::default(),
)); ));
// Base block execution weight + `on_initialize` weight from the custom module. // Base block execution weight + `on_initialize` weight from the custom module.
assert_eq!(<frame_system::Module<Runtime>>::block_weight().total(), base_block_weight); assert_eq!(<frame_system::Pallet<Runtime>>::block_weight().total(), base_block_weight);
for nonce in 0..=num_to_exhaust_block { for nonce in 0..=num_to_exhaust_block {
let xt = TestXt::new( let xt = TestXt::new(
@@ -893,11 +893,11 @@ mod tests {
if nonce != num_to_exhaust_block { if nonce != num_to_exhaust_block {
assert!(res.is_ok()); assert!(res.is_ok());
assert_eq!( assert_eq!(
<frame_system::Module<Runtime>>::block_weight().total(), <frame_system::Pallet<Runtime>>::block_weight().total(),
//--------------------- on_initialize + block_execution + extrinsic_base weight //--------------------- on_initialize + block_execution + extrinsic_base weight
(encoded_len + 5) * (nonce + 1) + base_block_weight, (encoded_len + 5) * (nonce + 1) + base_block_weight,
); );
assert_eq!(<frame_system::Module<Runtime>>::extrinsic_index(), Some(nonce as u32 + 1)); assert_eq!(<frame_system::Pallet<Runtime>>::extrinsic_index(), Some(nonce as u32 + 1));
} else { } else {
assert_eq!(res, Err(InvalidTransaction::ExhaustsResources.into())); assert_eq!(res, Err(InvalidTransaction::ExhaustsResources.into()));
} }
@@ -924,8 +924,8 @@ mod tests {
Digest::default(), Digest::default(),
)); ));
assert_eq!(<frame_system::Module<Runtime>>::block_weight().total(), base_block_weight); assert_eq!(<frame_system::Pallet<Runtime>>::block_weight().total(), base_block_weight);
assert_eq!(<frame_system::Module<Runtime>>::all_extrinsics_len(), 0); assert_eq!(<frame_system::Pallet<Runtime>>::all_extrinsics_len(), 0);
assert!(Executive::apply_extrinsic(xt.clone()).unwrap().is_ok()); assert!(Executive::apply_extrinsic(xt.clone()).unwrap().is_ok());
assert!(Executive::apply_extrinsic(x1.clone()).unwrap().is_ok()); assert!(Executive::apply_extrinsic(x1.clone()).unwrap().is_ok());
@@ -935,14 +935,14 @@ mod tests {
let extrinsic_weight = len as Weight + <Runtime as frame_system::Config>::BlockWeights let extrinsic_weight = len as Weight + <Runtime as frame_system::Config>::BlockWeights
::get().get(DispatchClass::Normal).base_extrinsic; ::get().get(DispatchClass::Normal).base_extrinsic;
assert_eq!( assert_eq!(
<frame_system::Module<Runtime>>::block_weight().total(), <frame_system::Pallet<Runtime>>::block_weight().total(),
base_block_weight + 3 * extrinsic_weight, base_block_weight + 3 * extrinsic_weight,
); );
assert_eq!(<frame_system::Module<Runtime>>::all_extrinsics_len(), 3 * len); assert_eq!(<frame_system::Pallet<Runtime>>::all_extrinsics_len(), 3 * len);
let _ = <frame_system::Module<Runtime>>::finalize(); let _ = <frame_system::Pallet<Runtime>>::finalize();
// All extrinsics length cleaned on `System::finalize` // All extrinsics length cleaned on `System::finalize`
assert_eq!(<frame_system::Module<Runtime>>::all_extrinsics_len(), 0); assert_eq!(<frame_system::Pallet<Runtime>>::all_extrinsics_len(), 0);
// New Block // New Block
Executive::initialize_block(&Header::new( Executive::initialize_block(&Header::new(
@@ -954,7 +954,7 @@ mod tests {
)); ));
// Block weight cleaned up on `System::initialize` // Block weight cleaned up on `System::initialize`
assert_eq!(<frame_system::Module<Runtime>>::block_weight().total(), base_block_weight); assert_eq!(<frame_system::Pallet<Runtime>>::block_weight().total(), base_block_weight);
}); });
} }
@@ -989,7 +989,7 @@ mod tests {
let execute_with_lock = |lock: WithdrawReasons| { let execute_with_lock = |lock: WithdrawReasons| {
let mut t = new_test_ext(1); let mut t = new_test_ext(1);
t.execute_with(|| { t.execute_with(|| {
<pallet_balances::Module<Runtime> as LockableCurrency<Balance>>::set_lock( <pallet_balances::Pallet<Runtime> as LockableCurrency<Balance>>::set_lock(
id, id,
&1, &1,
110, 110,
@@ -1017,13 +1017,13 @@ mod tests {
if lock == WithdrawReasons::except(WithdrawReasons::TRANSACTION_PAYMENT) { if lock == WithdrawReasons::except(WithdrawReasons::TRANSACTION_PAYMENT) {
assert!(Executive::apply_extrinsic(xt).unwrap().is_ok()); assert!(Executive::apply_extrinsic(xt).unwrap().is_ok());
// tx fee has been deducted. // tx fee has been deducted.
assert_eq!(<pallet_balances::Module<Runtime>>::total_balance(&1), 111 - fee); assert_eq!(<pallet_balances::Pallet<Runtime>>::total_balance(&1), 111 - fee);
} else { } else {
assert_eq!( assert_eq!(
Executive::apply_extrinsic(xt), Executive::apply_extrinsic(xt),
Err(InvalidTransaction::Payment.into()), Err(InvalidTransaction::Payment.into()),
); );
assert_eq!(<pallet_balances::Module<Runtime>>::total_balance(&1), 111); assert_eq!(<pallet_balances::Pallet<Runtime>>::total_balance(&1), 111);
} }
}); });
}; };
@@ -1041,7 +1041,7 @@ mod tests {
// NOTE: might need updates over time if new weights are introduced. // NOTE: might need updates over time if new weights are introduced.
// For now it only accounts for the base block execution weight and // For now it only accounts for the base block execution weight and
// the `on_initialize` weight defined in the custom test module. // the `on_initialize` weight defined in the custom test module.
assert_eq!(<frame_system::Module<Runtime>>::block_weight().total(), 175 + 175 + 10); assert_eq!(<frame_system::Pallet<Runtime>>::block_weight().total(), 175 + 175 + 10);
}) })
} }
@@ -1159,16 +1159,16 @@ mod tests {
)); ));
// All weights that show up in the `initialize_block_impl` // All weights that show up in the `initialize_block_impl`
let frame_system_upgrade_weight = frame_system::Module::<Runtime>::on_runtime_upgrade(); let frame_system_upgrade_weight = frame_system::Pallet::<Runtime>::on_runtime_upgrade();
let custom_runtime_upgrade_weight = CustomOnRuntimeUpgrade::on_runtime_upgrade(); let custom_runtime_upgrade_weight = CustomOnRuntimeUpgrade::on_runtime_upgrade();
let runtime_upgrade_weight = <AllModules as OnRuntimeUpgrade>::on_runtime_upgrade(); let runtime_upgrade_weight = <AllPallets as OnRuntimeUpgrade>::on_runtime_upgrade();
let frame_system_on_initialize_weight = frame_system::Module::<Runtime>::on_initialize(block_number); let frame_system_on_initialize_weight = frame_system::Pallet::<Runtime>::on_initialize(block_number);
let on_initialize_weight = <AllModules as OnInitialize<u64>>::on_initialize(block_number); let on_initialize_weight = <AllPallets as OnInitialize<u64>>::on_initialize(block_number);
let base_block_weight = <Runtime as frame_system::Config>::BlockWeights::get().base_block; let base_block_weight = <Runtime as frame_system::Config>::BlockWeights::get().base_block;
// Weights are recorded correctly // Weights are recorded correctly
assert_eq!( assert_eq!(
frame_system::Module::<Runtime>::block_weight().total(), frame_system::Pallet::<Runtime>::block_weight().total(),
frame_system_upgrade_weight + frame_system_upgrade_weight +
custom_runtime_upgrade_weight + custom_runtime_upgrade_weight +
runtime_upgrade_weight + runtime_upgrade_weight +
+2 -2
View File
@@ -446,7 +446,7 @@ pub mod pallet {
let gilt = Active::<T>::get(index).ok_or(Error::<T>::Unknown)?; let gilt = Active::<T>::get(index).ok_or(Error::<T>::Unknown)?;
// If found, check the owner is `who`. // If found, check the owner is `who`.
ensure!(gilt.who == who, Error::<T>::NotOwner); ensure!(gilt.who == who, Error::<T>::NotOwner);
let now = frame_system::Module::<T>::block_number(); let now = frame_system::Pallet::<T>::block_number();
ensure!(now >= gilt.expiry, Error::<T>::NotExpired); ensure!(now >= gilt.expiry, Error::<T>::NotExpired);
// Remove it // Remove it
Active::<T>::remove(index); Active::<T>::remove(index);
@@ -562,7 +562,7 @@ pub mod pallet {
let mut remaining = amount; let mut remaining = amount;
let mut bids_taken = 0; let mut bids_taken = 0;
let mut queues_hit = 0; let mut queues_hit = 0;
let now = frame_system::Module::<T>::block_number(); let now = frame_system::Pallet::<T>::block_number();
ActiveTotal::<T>::mutate(|totals| { ActiveTotal::<T>::mutate(|totals| {
QueueTotals::<T>::mutate(|qs| { QueueTotals::<T>::mutate(|qs| {
+3 -3
View File
@@ -36,9 +36,9 @@ frame_support::construct_runtime!(
NodeBlock = Block, NodeBlock = Block,
UncheckedExtrinsic = UncheckedExtrinsic, UncheckedExtrinsic = UncheckedExtrinsic,
{ {
System: frame_system::{Module, Call, Config, Storage, Event<T>}, System: frame_system::{Pallet, Call, Config, Storage, Event<T>},
Balances: pallet_balances::{Module, Call, Config<T>, Storage, Event<T>}, Balances: pallet_balances::{Pallet, Call, Config<T>, Storage, Event<T>},
Gilt: pallet_gilt::{Module, Call, Config, Storage, Event<T>}, Gilt: pallet_gilt::{Pallet, Call, Config, Storage, Event<T>},
} }
); );
+4 -4
View File
@@ -390,7 +390,7 @@ impl<T: Config> Module<T> {
/// Cannot be done when already paused. /// Cannot be done when already paused.
pub fn schedule_pause(in_blocks: T::BlockNumber) -> DispatchResult { pub fn schedule_pause(in_blocks: T::BlockNumber) -> DispatchResult {
if let StoredState::Live = <State<T>>::get() { if let StoredState::Live = <State<T>>::get() {
let scheduled_at = <frame_system::Module<T>>::block_number(); let scheduled_at = <frame_system::Pallet<T>>::block_number();
<State<T>>::put(StoredState::PendingPause { <State<T>>::put(StoredState::PendingPause {
delay: in_blocks, delay: in_blocks,
scheduled_at, scheduled_at,
@@ -405,7 +405,7 @@ impl<T: Config> Module<T> {
/// Schedule a resume of GRANDPA after pausing. /// Schedule a resume of GRANDPA after pausing.
pub fn schedule_resume(in_blocks: T::BlockNumber) -> DispatchResult { pub fn schedule_resume(in_blocks: T::BlockNumber) -> DispatchResult {
if let StoredState::Paused = <State<T>>::get() { if let StoredState::Paused = <State<T>>::get() {
let scheduled_at = <frame_system::Module<T>>::block_number(); let scheduled_at = <frame_system::Pallet<T>>::block_number();
<State<T>>::put(StoredState::PendingResume { <State<T>>::put(StoredState::PendingResume {
delay: in_blocks, delay: in_blocks,
scheduled_at, scheduled_at,
@@ -437,7 +437,7 @@ impl<T: Config> Module<T> {
forced: Option<T::BlockNumber>, forced: Option<T::BlockNumber>,
) -> DispatchResult { ) -> DispatchResult {
if !<PendingChange<T>>::exists() { if !<PendingChange<T>>::exists() {
let scheduled_at = <frame_system::Module<T>>::block_number(); let scheduled_at = <frame_system::Pallet<T>>::block_number();
if let Some(_) = forced { if let Some(_) = forced {
if Self::next_forced().map_or(false, |next| next > scheduled_at) { if Self::next_forced().map_or(false, |next| next > scheduled_at) {
@@ -465,7 +465,7 @@ impl<T: Config> Module<T> {
/// Deposit one of this module's logs. /// Deposit one of this module's logs.
fn deposit_log(log: ConsensusLog<T::BlockNumber>) { fn deposit_log(log: ConsensusLog<T::BlockNumber>) {
let log: DigestItem<T::Hash> = DigestItem::Consensus(GRANDPA_ENGINE_ID, log.encode()); let log: DigestItem<T::Hash> = DigestItem::Consensus(GRANDPA_ENGINE_ID, log.encode());
<frame_system::Module<T>>::deposit_log(log.into()); <frame_system::Pallet<T>>::deposit_log(log.into());
} }
// Perform module initialization, abstracted so that it can be called either through genesis // Perform module initialization, abstracted so that it can be called either through genesis
+9 -9
View File
@@ -51,14 +51,14 @@ frame_support::construct_runtime!(
NodeBlock = Block, NodeBlock = Block,
UncheckedExtrinsic = UncheckedExtrinsic, UncheckedExtrinsic = UncheckedExtrinsic,
{ {
System: frame_system::{Module, Call, Config, Storage, Event<T>}, System: frame_system::{Pallet, Call, Config, Storage, Event<T>},
Timestamp: pallet_timestamp::{Module, Call, Storage, Inherent}, Timestamp: pallet_timestamp::{Pallet, Call, Storage, Inherent},
Balances: pallet_balances::{Module, Call, Storage, Config<T>, Event<T>}, Balances: pallet_balances::{Pallet, Call, Storage, Config<T>, Event<T>},
Staking: pallet_staking::{Module, Call, Config<T>, Storage, Event<T>, ValidateUnsigned}, Staking: pallet_staking::{Pallet, Call, Config<T>, Storage, Event<T>, ValidateUnsigned},
Session: pallet_session::{Module, Call, Storage, Event, Config<T>}, Session: pallet_session::{Pallet, Call, Storage, Event, Config<T>},
Grandpa: pallet_grandpa::{Module, Call, Storage, Config, Event, ValidateUnsigned}, Grandpa: pallet_grandpa::{Pallet, Call, Storage, Config, Event, ValidateUnsigned},
Offences: pallet_offences::{Module, Call, Storage, Event}, Offences: pallet_offences::{Pallet, Call, Storage, Event},
Historical: pallet_session_historical::{Module}, Historical: pallet_session_historical::{Pallet},
} }
); );
@@ -210,7 +210,7 @@ impl pallet_staking::Config for Test {
type SlashDeferDuration = SlashDeferDuration; type SlashDeferDuration = SlashDeferDuration;
type SlashCancelOrigin = frame_system::EnsureRoot<Self::AccountId>; type SlashCancelOrigin = frame_system::EnsureRoot<Self::AccountId>;
type SessionInterface = Self; type SessionInterface = Self;
type UnixTime = pallet_timestamp::Module<Test>; type UnixTime = pallet_timestamp::Pallet<Test>;
type EraPayout = pallet_staking::ConvertCurve<RewardCurve>; type EraPayout = pallet_staking::ConvertCurve<RewardCurve>;
type MaxNominatorRewardedPerValidator = MaxNominatorRewardedPerValidator; type MaxNominatorRewardedPerValidator = MaxNominatorRewardedPerValidator;
type NextNewSession = Session; type NextNewSession = Session;
+2 -2
View File
@@ -25,12 +25,12 @@ use frame_system::{EventRecord, RawOrigin};
use frame_benchmarking::{benchmarks, account, whitelisted_caller, impl_benchmark_test_suite}; use frame_benchmarking::{benchmarks, account, whitelisted_caller, impl_benchmark_test_suite};
use sp_runtime::traits::Bounded; use sp_runtime::traits::Bounded;
use crate::Module as Identity; use crate::Pallet as Identity;
const SEED: u32 = 0; const SEED: u32 = 0;
fn assert_last_event<T: Config>(generic_event: <T as Config>::Event) { fn assert_last_event<T: Config>(generic_event: <T as Config>::Event) {
let events = frame_system::Module::<T>::events(); let events = frame_system::Pallet::<T>::events();
let system_event: <T as frame_system::Config>::Event = generic_event.into(); let system_event: <T as frame_system::Config>::Event = generic_event.into();
// compare to the last event record // compare to the last event record
let EventRecord { event, .. } = &events[events.len() - 1]; let EventRecord { event, .. } = &events[events.len() - 1];
+3 -3
View File
@@ -37,9 +37,9 @@ frame_support::construct_runtime!(
NodeBlock = Block, NodeBlock = Block,
UncheckedExtrinsic = UncheckedExtrinsic, UncheckedExtrinsic = UncheckedExtrinsic,
{ {
System: frame_system::{Module, Call, Config, Storage, Event<T>}, System: frame_system::{Pallet, Call, Config, Storage, Event<T>},
Balances: pallet_balances::{Module, Call, Storage, Config<T>, Event<T>}, Balances: pallet_balances::{Pallet, Call, Storage, Config<T>, Event<T>},
Identity: pallet_identity::{Module, Call, Storage, Event<T>}, Identity: pallet_identity::{Pallet, Call, Storage, Event<T>},
} }
); );
+1 -1
View File
@@ -668,7 +668,7 @@ impl<T: Config> OneSessionHandler<T::AccountId> for Module<T> {
// Tell the offchain worker to start making the next session's heartbeats. // Tell the offchain worker to start making the next session's heartbeats.
// Since we consider producing blocks as being online, // Since we consider producing blocks as being online,
// the heartbeat is deferred a bit to prevent spamming. // the heartbeat is deferred a bit to prevent spamming.
let block_number = <frame_system::Module<T>>::block_number(); let block_number = <frame_system::Pallet<T>>::block_number();
let half_session = T::NextSessionRotation::average_session_length() / 2u32.into(); let half_session = T::NextSessionRotation::average_session_length() / 2u32.into();
<HeartbeatAfter<T>>::put(block_number + half_session); <HeartbeatAfter<T>>::put(block_number + half_session);
+4 -4
View File
@@ -44,10 +44,10 @@ frame_support::construct_runtime!(
NodeBlock = Block, NodeBlock = Block,
UncheckedExtrinsic = UncheckedExtrinsic, UncheckedExtrinsic = UncheckedExtrinsic,
{ {
System: frame_system::{Module, Call, Config, Storage, Event<T>}, System: frame_system::{Pallet, Call, Config, Storage, Event<T>},
Session: pallet_session::{Module, Call, Storage, Event, Config<T>}, Session: pallet_session::{Pallet, Call, Storage, Event, Config<T>},
ImOnline: imonline::{Module, Call, Storage, Config<T>, Event<T>}, ImOnline: imonline::{Pallet, Call, Storage, Config<T>, Event<T>},
Historical: pallet_session_historical::{Module}, Historical: pallet_session_historical::{Pallet},
} }
); );
+3 -3
View File
@@ -33,9 +33,9 @@ frame_support::construct_runtime!(
NodeBlock = Block, NodeBlock = Block,
UncheckedExtrinsic = UncheckedExtrinsic, UncheckedExtrinsic = UncheckedExtrinsic,
{ {
System: frame_system::{Module, Call, Config, Storage, Event<T>}, System: frame_system::{Pallet, Call, Config, Storage, Event<T>},
Balances: pallet_balances::{Module, Call, Storage, Config<T>, Event<T>}, Balances: pallet_balances::{Pallet, Call, Storage, Config<T>, Event<T>},
Indices: pallet_indices::{Module, Call, Storage, Config<T>, Event<T>}, Indices: pallet_indices::{Pallet, Call, Storage, Config<T>, Event<T>},
} }
); );
+2 -2
View File
@@ -277,7 +277,7 @@ decl_module! {
ensure!(lottery.is_none(), Error::<T>::InProgress); ensure!(lottery.is_none(), Error::<T>::InProgress);
let index = LotteryIndex::get(); let index = LotteryIndex::get();
let new_index = index.checked_add(1).ok_or(Error::<T>::Overflow)?; let new_index = index.checked_add(1).ok_or(Error::<T>::Overflow)?;
let start = frame_system::Module::<T>::block_number(); let start = frame_system::Pallet::<T>::block_number();
// Use new_index to more easily track everything with the current state. // Use new_index to more easily track everything with the current state.
*lottery = Some(LotteryConfig { *lottery = Some(LotteryConfig {
price, price,
@@ -392,7 +392,7 @@ impl<T: Config> Module<T> {
fn do_buy_ticket(caller: &T::AccountId, call: &<T as Config>::Call) -> DispatchResult { fn do_buy_ticket(caller: &T::AccountId, call: &<T as Config>::Call) -> DispatchResult {
// Check the call is valid lottery // Check the call is valid lottery
let config = Lottery::<T>::get().ok_or(Error::<T>::NotConfigured)?; let config = Lottery::<T>::get().ok_or(Error::<T>::NotConfigured)?;
let block_number = frame_system::Module::<T>::block_number(); let block_number = frame_system::Pallet::<T>::block_number();
ensure!(block_number < config.start.saturating_add(config.length), Error::<T>::AlreadyEnded); ensure!(block_number < config.start.saturating_add(config.length), Error::<T>::AlreadyEnded);
ensure!(T::ValidateCall::validate_call(call), Error::<T>::InvalidCall); ensure!(T::ValidateCall::validate_call(call), Error::<T>::InvalidCall);
let call_index = Self::call_to_index(call)?; let call_index = Self::call_to_index(call)?;
+3 -3
View File
@@ -42,9 +42,9 @@ frame_support::construct_runtime!(
NodeBlock = Block, NodeBlock = Block,
UncheckedExtrinsic = UncheckedExtrinsic, UncheckedExtrinsic = UncheckedExtrinsic,
{ {
System: frame_system::{Module, Call, Config, Storage, Event<T>}, System: frame_system::{Pallet, Call, Config, Storage, Event<T>},
Balances: pallet_balances::{Module, Call, Storage, Config<T>, Event<T>}, Balances: pallet_balances::{Pallet, Call, Storage, Config<T>, Event<T>},
Lottery: pallet_lottery::{Module, Call, Storage, Event<T>}, Lottery: pallet_lottery::{Pallet, Call, Storage, Event<T>},
} }
); );
+2 -2
View File
@@ -293,8 +293,8 @@ mod tests {
NodeBlock = Block, NodeBlock = Block,
UncheckedExtrinsic = UncheckedExtrinsic, UncheckedExtrinsic = UncheckedExtrinsic,
{ {
System: frame_system::{Module, Call, Config, Storage, Event<T>}, System: frame_system::{Pallet, Call, Config, Storage, Event<T>},
Membership: pallet_membership::{Module, Call, Storage, Config<T>, Event<T>}, Membership: pallet_membership::{Pallet, Call, Storage, Config<T>, Event<T>},
} }
); );
@@ -51,10 +51,10 @@ impl LeafDataProvider for () {
/// so that any point in time in the future we can receive a proof about some past /// so that any point in time in the future we can receive a proof about some past
/// blocks without using excessive on-chain storage. /// blocks without using excessive on-chain storage.
/// ///
/// Hence we implement the [LeafDataProvider] for [frame_system::Module]. Since the /// Hence we implement the [LeafDataProvider] for [frame_system::Pallet]. Since the
/// current block hash is not available (since the block is not finished yet), /// current block hash is not available (since the block is not finished yet),
/// we use the `parent_hash` here along with parent block number. /// we use the `parent_hash` here along with parent block number.
impl<T: frame_system::Config> LeafDataProvider for frame_system::Module<T> { impl<T: frame_system::Config> LeafDataProvider for frame_system::Pallet<T> {
type LeafData = ( type LeafData = (
<T as frame_system::Config>::BlockNumber, <T as frame_system::Config>::BlockNumber,
<T as frame_system::Config>::Hash <T as frame_system::Config>::Hash
@@ -40,8 +40,8 @@ frame_support::construct_runtime!(
NodeBlock = Block, NodeBlock = Block,
UncheckedExtrinsic = UncheckedExtrinsic, UncheckedExtrinsic = UncheckedExtrinsic,
{ {
System: frame_system::{Module, Call, Config, Storage, Event<T>}, System: frame_system::{Pallet, Call, Config, Storage, Event<T>},
MMR: pallet_mmr::{Module, Call, Storage}, MMR: pallet_mmr::{Pallet, Call, Storage},
} }
); );
@@ -78,7 +78,7 @@ impl Config for Test {
type Hashing = Keccak256; type Hashing = Keccak256;
type Hash = H256; type Hash = H256;
type LeafData = Compact<Keccak256, (frame_system::Module<Test>, LeafData)>; type LeafData = Compact<Keccak256, (frame_system::Pallet<Test>, LeafData)>;
type OnNewRoot = (); type OnNewRoot = ();
type WeightInfo = (); type WeightInfo = ();
} }
@@ -39,11 +39,11 @@ fn register_offchain_ext(ext: &mut sp_io::TestExternalities) {
} }
fn new_block() -> u64 { fn new_block() -> u64 {
let number = frame_system::Module::<Test>::block_number() + 1; let number = frame_system::Pallet::<Test>::block_number() + 1;
let hash = H256::repeat_byte(number as u8); let hash = H256::repeat_byte(number as u8);
LEAF_DATA.with(|r| r.borrow_mut().a = number); LEAF_DATA.with(|r| r.borrow_mut().a = number);
frame_system::Module::<Test>::initialize( frame_system::Pallet::<Test>::initialize(
&number, &number,
&hash, &hash,
&Default::default(), &Default::default(),
+2 -2
View File
@@ -638,8 +638,8 @@ impl<T: Config> Module<T> {
/// The current `Timepoint`. /// The current `Timepoint`.
pub fn timepoint() -> Timepoint<T::BlockNumber> { pub fn timepoint() -> Timepoint<T::BlockNumber> {
Timepoint { Timepoint {
height: <system::Module<T>>::block_number(), height: <system::Pallet<T>>::block_number(),
index: <system::Module<T>>::extrinsic_index().unwrap_or_default(), index: <system::Pallet<T>>::extrinsic_index().unwrap_or_default(),
} }
} }
+4 -4
View File
@@ -37,9 +37,9 @@ frame_support::construct_runtime!(
NodeBlock = Block, NodeBlock = Block,
UncheckedExtrinsic = UncheckedExtrinsic, UncheckedExtrinsic = UncheckedExtrinsic,
{ {
System: frame_system::{Module, Call, Config, Storage, Event<T>}, System: frame_system::{Pallet, Call, Config, Storage, Event<T>},
Balances: pallet_balances::{Module, Call, Storage, Config<T>, Event<T>}, Balances: pallet_balances::{Pallet, Call, Storage, Config<T>, Event<T>},
Multisig: pallet_multisig::{Module, Call, Storage, Event<T>}, Multisig: pallet_multisig::{Pallet, Call, Storage, Event<T>},
} }
); );
@@ -124,7 +124,7 @@ pub fn new_test_ext() -> sp_io::TestExternalities {
} }
fn last_event() -> Event { fn last_event() -> Event {
system::Module::<Test>::events().pop().map(|e| e.event).expect("Event expected") system::Pallet::<Test>::events().pop().map(|e| e.event).expect("Event expected")
} }
fn expect_event<E: Into<Event>>(e: E) { fn expect_event<E: Into<Event>>(e: E) {
+3 -3
View File
@@ -257,9 +257,9 @@ mod tests {
NodeBlock = Block, NodeBlock = Block,
UncheckedExtrinsic = UncheckedExtrinsic, UncheckedExtrinsic = UncheckedExtrinsic,
{ {
System: frame_system::{Module, Call, Config, Storage, Event<T>}, System: frame_system::{Pallet, Call, Config, Storage, Event<T>},
Balances: pallet_balances::{Module, Call, Storage, Config<T>, Event<T>}, Balances: pallet_balances::{Pallet, Call, Storage, Config<T>, Event<T>},
Nicks: pallet_nicks::{Module, Call, Storage, Event<T>}, Nicks: pallet_nicks::{Pallet, Call, Storage, Event<T>},
} }
); );
@@ -37,9 +37,9 @@ frame_support::construct_runtime!(
NodeBlock = Block, NodeBlock = Block,
UncheckedExtrinsic = UncheckedExtrinsic, UncheckedExtrinsic = UncheckedExtrinsic,
{ {
System: frame_system::{Module, Call, Config, Storage, Event<T>}, System: frame_system::{Pallet, Call, Config, Storage, Event<T>},
NodeAuthorization: pallet_node_authorization::{ NodeAuthorization: pallet_node_authorization::{
Module, Call, Storage, Config<T>, Event<T>, Pallet, Call, Storage, Config<T>, Event<T>,
}, },
} }
); );
@@ -356,7 +356,7 @@ fn get_authorized_nodes_works() {
BTreeSet::from_iter(vec![test_node(5), test_node(15), test_node(25)]) BTreeSet::from_iter(vec![test_node(5), test_node(15), test_node(25)])
); );
let mut authorized_nodes = Module::<Test>::get_authorized_nodes(&test_node(20)); let mut authorized_nodes = Pallet::<Test>::get_authorized_nodes(&test_node(20));
authorized_nodes.sort(); authorized_nodes.sort();
assert_eq!( assert_eq!(
authorized_nodes, authorized_nodes,
@@ -24,7 +24,7 @@ mod mock;
use sp_std::prelude::*; use sp_std::prelude::*;
use sp_std::vec; use sp_std::vec;
use frame_system::{RawOrigin, Module as System, Config as SystemConfig}; use frame_system::{RawOrigin, Pallet as System, Config as SystemConfig};
use frame_benchmarking::{benchmarks, account, impl_benchmark_test_suite}; use frame_benchmarking::{benchmarks, account, impl_benchmark_test_suite};
use frame_support::traits::{Currency, OnInitialize, ValidatorSet, ValidatorSetWithIdentification}; use frame_support::traits::{Currency, OnInitialize, ValidatorSet, ValidatorSetWithIdentification};
@@ -50,7 +50,7 @@ const MAX_OFFENDERS: u32 = 100;
const MAX_NOMINATORS: u32 = 100; const MAX_NOMINATORS: u32 = 100;
const MAX_DEFERRED_OFFENCES: u32 = 100; const MAX_DEFERRED_OFFENCES: u32 = 100;
pub struct Module<T: Config>(Offences<T>); pub struct Pallet<T: Config>(Offences<T>);
pub trait Config: pub trait Config:
SessionConfig SessionConfig
@@ -421,7 +421,7 @@ benchmarks! {
} }
impl_benchmark_test_suite!( impl_benchmark_test_suite!(
Module, Pallet,
crate::mock::new_test_ext(), crate::mock::new_test_ext(),
crate::mock::Test, crate::mock::Test,
); );
@@ -159,7 +159,7 @@ impl onchain::Config for Test {
impl pallet_staking::Config for Test { impl pallet_staking::Config for Test {
type Currency = Balances; type Currency = Balances;
type UnixTime = pallet_timestamp::Module<Self>; type UnixTime = pallet_timestamp::Pallet<Self>;
type CurrencyToVote = frame_support::traits::SaturatingCurrencyToVote; type CurrencyToVote = frame_support::traits::SaturatingCurrencyToVote;
type RewardRemainder = (); type RewardRemainder = ();
type Event = Event; type Event = Event;
@@ -220,13 +220,13 @@ frame_support::construct_runtime!(
NodeBlock = Block, NodeBlock = Block,
UncheckedExtrinsic = UncheckedExtrinsic UncheckedExtrinsic = UncheckedExtrinsic
{ {
System: system::{Module, Call, Event<T>}, System: system::{Pallet, Call, Event<T>},
Balances: pallet_balances::{Module, Call, Storage, Config<T>, Event<T>}, Balances: pallet_balances::{Pallet, Call, Storage, Config<T>, Event<T>},
Staking: pallet_staking::{Module, Call, Config<T>, Storage, Event<T>, ValidateUnsigned}, Staking: pallet_staking::{Pallet, Call, Config<T>, Storage, Event<T>, ValidateUnsigned},
Session: pallet_session::{Module, Call, Storage, Event, Config<T>}, Session: pallet_session::{Pallet, Call, Storage, Event, Config<T>},
ImOnline: pallet_im_online::{Module, Call, Storage, Event<T>, ValidateUnsigned, Config<T>}, ImOnline: pallet_im_online::{Pallet, Call, Storage, Event<T>, ValidateUnsigned, Config<T>},
Offences: pallet_offences::{Module, Call, Storage, Event}, Offences: pallet_offences::{Pallet, Call, Storage, Event},
Historical: pallet_session_historical::{Module}, Historical: pallet_session_historical::{Pallet},
} }
); );
+2 -2
View File
@@ -91,8 +91,8 @@ frame_support::construct_runtime!(
NodeBlock = Block, NodeBlock = Block,
UncheckedExtrinsic = UncheckedExtrinsic, UncheckedExtrinsic = UncheckedExtrinsic,
{ {
System: frame_system::{Module, Call, Config, Storage, Event<T>}, System: frame_system::{Pallet, Call, Config, Storage, Event<T>},
Offences: offences::{Module, Call, Storage, Event}, Offences: offences::{Pallet, Call, Storage, Event},
} }
); );
+7 -7
View File
@@ -23,12 +23,12 @@ use super::*;
use frame_system::{RawOrigin, EventRecord}; use frame_system::{RawOrigin, EventRecord};
use frame_benchmarking::{benchmarks, account, whitelisted_caller, impl_benchmark_test_suite}; use frame_benchmarking::{benchmarks, account, whitelisted_caller, impl_benchmark_test_suite};
use sp_runtime::traits::Bounded; use sp_runtime::traits::Bounded;
use crate::Module as Proxy; use crate::Pallet as Proxy;
const SEED: u32 = 0; const SEED: u32 = 0;
fn assert_last_event<T: Config>(generic_event: <T as Config>::Event) { fn assert_last_event<T: Config>(generic_event: <T as Config>::Event) {
let events = frame_system::Module::<T>::events(); let events = frame_system::Pallet::<T>::events();
let system_event: <T as frame_system::Config>::Event = generic_event.into(); let system_event: <T as frame_system::Config>::Event = generic_event.into();
// compare to the last event record // compare to the last event record
let EventRecord { event, .. } = &events[events.len() - 1]; let EventRecord { event, .. } = &events[events.len() - 1];
@@ -219,7 +219,7 @@ benchmarks! {
0 0
) )
verify { verify {
let anon_account = Module::<T>::anonymous_account(&caller, &T::ProxyType::default(), 0, None); let anon_account = Pallet::<T>::anonymous_account(&caller, &T::ProxyType::default(), 0, None);
assert_last_event::<T>(Event::AnonymousCreated( assert_last_event::<T>(Event::AnonymousCreated(
anon_account, anon_account,
caller, caller,
@@ -233,15 +233,15 @@ benchmarks! {
let caller: T::AccountId = whitelisted_caller(); let caller: T::AccountId = whitelisted_caller();
T::Currency::make_free_balance_be(&caller, BalanceOf::<T>::max_value()); T::Currency::make_free_balance_be(&caller, BalanceOf::<T>::max_value());
Module::<T>::anonymous( Pallet::<T>::anonymous(
RawOrigin::Signed(whitelisted_caller()).into(), RawOrigin::Signed(whitelisted_caller()).into(),
T::ProxyType::default(), T::ProxyType::default(),
T::BlockNumber::zero(), T::BlockNumber::zero(),
0 0
)?; )?;
let height = system::Module::<T>::block_number(); let height = system::Pallet::<T>::block_number();
let ext_index = system::Module::<T>::extrinsic_index().unwrap_or(0); let ext_index = system::Pallet::<T>::extrinsic_index().unwrap_or(0);
let anon = Module::<T>::anonymous_account(&caller, &T::ProxyType::default(), 0, None); let anon = Pallet::<T>::anonymous_account(&caller, &T::ProxyType::default(), 0, None);
add_proxies::<T>(p, Some(anon.clone()))?; add_proxies::<T>(p, Some(anon.clone()))?;
ensure!(Proxies::<T>::contains_key(&anon), "anon proxy not created"); ensure!(Proxies::<T>::contains_key(&anon), "anon proxy not created");
+5 -5
View File
@@ -394,7 +394,7 @@ pub mod pallet {
let announcement = Announcement { let announcement = Announcement {
real: real.clone(), real: real.clone(),
call_hash: call_hash.clone(), call_hash: call_hash.clone(),
height: system::Module::<T>::block_number(), height: system::Pallet::<T>::block_number(),
}; };
Announcements::<T>::try_mutate(&who, |(ref mut pending, ref mut deposit)| { Announcements::<T>::try_mutate(&who, |(ref mut pending, ref mut deposit)| {
@@ -510,7 +510,7 @@ pub mod pallet {
let def = Self::find_proxy(&real, &delegate, force_proxy_type)?; let def = Self::find_proxy(&real, &delegate, force_proxy_type)?;
let call_hash = T::CallHasher::hash_of(&call); let call_hash = T::CallHasher::hash_of(&call);
let now = system::Module::<T>::block_number(); let now = system::Pallet::<T>::block_number();
Self::edit_announcements(&delegate, |ann| Self::edit_announcements(&delegate, |ann|
ann.real != real || ann.call_hash != call_hash || now.saturating_sub(ann.height) < def.delay ann.real != real || ann.call_hash != call_hash || now.saturating_sub(ann.height) < def.delay
).map_err(|_| Error::<T>::Unannounced)?; ).map_err(|_| Error::<T>::Unannounced)?;
@@ -584,7 +584,7 @@ pub mod pallet {
} }
impl<T: Config> Module<T> { impl<T: Config> Pallet<T> {
/// Calculate the address of an anonymous account. /// Calculate the address of an anonymous account.
/// ///
@@ -604,8 +604,8 @@ impl<T: Config> Module<T> {
maybe_when: Option<(T::BlockNumber, u32)>, maybe_when: Option<(T::BlockNumber, u32)>,
) -> T::AccountId { ) -> T::AccountId {
let (height, ext_index) = maybe_when.unwrap_or_else(|| ( let (height, ext_index) = maybe_when.unwrap_or_else(|| (
system::Module::<T>::block_number(), system::Pallet::<T>::block_number(),
system::Module::<T>::extrinsic_index().unwrap_or_default() system::Pallet::<T>::extrinsic_index().unwrap_or_default()
)); ));
let entropy = (b"modlpy/proxy____", who, height, ext_index, proxy_type, index) let entropy = (b"modlpy/proxy____", who, height, ext_index, proxy_type, index)
.using_encoded(blake2_256); .using_encoded(blake2_256);
+8 -8
View File
@@ -38,10 +38,10 @@ frame_support::construct_runtime!(
NodeBlock = Block, NodeBlock = Block,
UncheckedExtrinsic = UncheckedExtrinsic, UncheckedExtrinsic = UncheckedExtrinsic,
{ {
System: frame_system::{Module, Call, Config, Storage, Event<T>}, System: frame_system::{Pallet, Call, Config, Storage, Event<T>},
Balances: pallet_balances::{Module, Call, Storage, Config<T>, Event<T>}, Balances: pallet_balances::{Pallet, Call, Storage, Config<T>, Event<T>},
Proxy: proxy::{Module, Call, Storage, Event<T>}, Proxy: proxy::{Pallet, Call, Storage, Event<T>},
Utility: pallet_utility::{Module, Call, Event}, Utility: pallet_utility::{Pallet, Call, Event},
} }
); );
@@ -164,7 +164,7 @@ pub fn new_test_ext() -> sp_io::TestExternalities {
} }
fn last_event() -> Event { fn last_event() -> Event {
system::Module::<Test>::events().pop().expect("Event expected").event system::Pallet::<Test>::events().pop().expect("Event expected").event
} }
fn expect_event<E: Into<Event>>(e: E) { fn expect_event<E: Into<Event>>(e: E) {
@@ -172,7 +172,7 @@ fn expect_event<E: Into<Event>>(e: E) {
} }
fn last_events(n: usize) -> Vec<Event> { fn last_events(n: usize) -> Vec<Event> {
system::Module::<Test>::events().into_iter().rev().take(n).rev().map(|e| e.event).collect() system::Pallet::<Test>::events().into_iter().rev().take(n).rev().map(|e| e.event).collect()
} }
fn expect_events(e: Vec<Event>) { fn expect_events(e: Vec<Event>) {
@@ -271,7 +271,7 @@ fn delayed_requires_pre_announcement() {
assert_noop!(Proxy::proxy_announced(Origin::signed(0), 2, 1, None, call.clone()), e); assert_noop!(Proxy::proxy_announced(Origin::signed(0), 2, 1, None, call.clone()), e);
let call_hash = BlakeTwo256::hash_of(&call); let call_hash = BlakeTwo256::hash_of(&call);
assert_ok!(Proxy::announce(Origin::signed(2), 1, call_hash)); assert_ok!(Proxy::announce(Origin::signed(2), 1, call_hash));
system::Module::<Test>::set_block_number(2); system::Pallet::<Test>::set_block_number(2);
assert_ok!(Proxy::proxy_announced(Origin::signed(0), 2, 1, None, call.clone())); assert_ok!(Proxy::proxy_announced(Origin::signed(0), 2, 1, None, call.clone()));
}); });
} }
@@ -289,7 +289,7 @@ fn proxy_announced_removes_announcement_and_returns_deposit() {
let e = Error::<Test>::Unannounced; let e = Error::<Test>::Unannounced;
assert_noop!(Proxy::proxy_announced(Origin::signed(0), 3, 1, None, call.clone()), e); assert_noop!(Proxy::proxy_announced(Origin::signed(0), 3, 1, None, call.clone()), e);
system::Module::<Test>::set_block_number(2); system::Pallet::<Test>::set_block_number(2);
assert_ok!(Proxy::proxy_announced(Origin::signed(0), 3, 1, None, call.clone())); assert_ok!(Proxy::proxy_announced(Origin::signed(0), 3, 1, None, call.clone()));
assert_eq!(Announcements::<Test>::get(3), (vec![Announcement { assert_eq!(Announcements::<Test>::get(3), (vec![Announcement {
real: 2, real: 2,
@@ -76,7 +76,7 @@ fn block_number_to_index<T: Config>(block_number: T::BlockNumber) -> usize {
decl_module! { decl_module! {
pub struct Module<T: Config> for enum Call where origin: T::Origin { pub struct Module<T: Config> for enum Call where origin: T::Origin {
fn on_initialize(block_number: T::BlockNumber) -> Weight { fn on_initialize(block_number: T::BlockNumber) -> Weight {
let parent_hash = <frame_system::Module<T>>::parent_hash(); let parent_hash = <frame_system::Pallet<T>>::parent_hash();
<RandomMaterial<T>>::mutate(|ref mut values| if values.len() < RANDOM_MATERIAL_LEN as usize { <RandomMaterial<T>>::mutate(|ref mut values| if values.len() < RANDOM_MATERIAL_LEN as usize {
values.push(parent_hash) values.push(parent_hash)
@@ -111,7 +111,7 @@ impl<T: Config> Randomness<T::Hash, T::BlockNumber> for Module<T> {
/// and mean that all bits of the resulting value are entirely manipulatable by the author of /// and mean that all bits of the resulting value are entirely manipulatable by the author of
/// the parent block, who can determine the value of `parent_hash`. /// the parent block, who can determine the value of `parent_hash`.
fn random(subject: &[u8]) -> (T::Hash, T::BlockNumber) { fn random(subject: &[u8]) -> (T::Hash, T::BlockNumber) {
let block_number = <frame_system::Module<T>>::block_number(); let block_number = <frame_system::Pallet<T>>::block_number();
let index = block_number_to_index::<T>(block_number); let index = block_number_to_index::<T>(block_number);
let hash_series = <RandomMaterial<T>>::get(); let hash_series = <RandomMaterial<T>>::get();
@@ -157,8 +157,8 @@ mod tests {
NodeBlock = Block, NodeBlock = Block,
UncheckedExtrinsic = UncheckedExtrinsic, UncheckedExtrinsic = UncheckedExtrinsic,
{ {
System: frame_system::{Module, Call, Config, Storage, Event<T>}, System: frame_system::{Pallet, Call, Config, Storage, Event<T>},
CollectiveFlip: pallet_randomness_collective_flip::{Module, Call, Storage}, CollectiveFlip: pallet_randomness_collective_flip::{Pallet, Call, Storage},
} }
); );
+4 -4
View File
@@ -496,7 +496,7 @@ decl_module! {
T::Currency::reserve(&who, recovery_deposit)?; T::Currency::reserve(&who, recovery_deposit)?;
// Create an active recovery status // Create an active recovery status
let recovery_status = ActiveRecovery { let recovery_status = ActiveRecovery {
created: <system::Module<T>>::block_number(), created: <system::Pallet<T>>::block_number(),
deposit: recovery_deposit, deposit: recovery_deposit,
friends: vec![], friends: vec![],
}; };
@@ -578,7 +578,7 @@ decl_module! {
let active_recovery = Self::active_recovery(&account, &who).ok_or(Error::<T>::NotStarted)?; let active_recovery = Self::active_recovery(&account, &who).ok_or(Error::<T>::NotStarted)?;
ensure!(!Proxy::<T>::contains_key(&who), Error::<T>::AlreadyProxy); ensure!(!Proxy::<T>::contains_key(&who), Error::<T>::AlreadyProxy);
// Make sure the delay period has passed // Make sure the delay period has passed
let current_block_number = <system::Module<T>>::block_number(); let current_block_number = <system::Pallet<T>>::block_number();
let recoverable_block_number = active_recovery.created let recoverable_block_number = active_recovery.created
.checked_add(&recovery_config.delay_period) .checked_add(&recovery_config.delay_period)
.ok_or(Error::<T>::Overflow)?; .ok_or(Error::<T>::Overflow)?;
@@ -588,7 +588,7 @@ decl_module! {
recovery_config.threshold as usize <= active_recovery.friends.len(), recovery_config.threshold as usize <= active_recovery.friends.len(),
Error::<T>::Threshold Error::<T>::Threshold
); );
system::Module::<T>::inc_consumers(&who).map_err(|_| Error::<T>::BadState)?; system::Pallet::<T>::inc_consumers(&who).map_err(|_| Error::<T>::BadState)?;
// Create the recovery storage item // Create the recovery storage item
Proxy::<T>::insert(&who, &account); Proxy::<T>::insert(&who, &account);
Self::deposit_event(RawEvent::AccountRecovered(account, who)); Self::deposit_event(RawEvent::AccountRecovered(account, who));
@@ -677,7 +677,7 @@ decl_module! {
// Check `who` is allowed to make a call on behalf of `account` // Check `who` is allowed to make a call on behalf of `account`
ensure!(Self::proxy(&who) == Some(account), Error::<T>::NotAllowed); ensure!(Self::proxy(&who) == Some(account), Error::<T>::NotAllowed);
Proxy::<T>::remove(&who); Proxy::<T>::remove(&who);
system::Module::<T>::dec_consumers(&who); system::Pallet::<T>::dec_consumers(&who);
} }
} }
} }
+3 -3
View File
@@ -35,9 +35,9 @@ frame_support::construct_runtime!(
NodeBlock = Block, NodeBlock = Block,
UncheckedExtrinsic = UncheckedExtrinsic, UncheckedExtrinsic = UncheckedExtrinsic,
{ {
System: frame_system::{Module, Call, Config, Storage, Event<T>}, System: frame_system::{Pallet, Call, Config, Storage, Event<T>},
Balances: pallet_balances::{Module, Call, Storage, Config<T>, Event<T>}, Balances: pallet_balances::{Pallet, Call, Storage, Config<T>, Event<T>},
Recovery: recovery::{Module, Call, Storage, Event<T>}, Recovery: recovery::{Pallet, Call, Storage, Event<T>},
} }
); );
@@ -26,7 +26,7 @@ use frame_support::{ensure, traits::OnInitialize};
use frame_benchmarking::{benchmarks, impl_benchmark_test_suite}; use frame_benchmarking::{benchmarks, impl_benchmark_test_suite};
use crate::Module as Scheduler; use crate::Module as Scheduler;
use frame_system::Module as System; use frame_system::Pallet as System;
const BLOCK_NUMBER: u32 = 2; const BLOCK_NUMBER: u32 = 2;
+4 -4
View File
@@ -465,7 +465,7 @@ impl<T: Config> Module<T> {
} }
fn resolve_time(when: DispatchTime<T::BlockNumber>) -> Result<T::BlockNumber, DispatchError> { fn resolve_time(when: DispatchTime<T::BlockNumber>) -> Result<T::BlockNumber, DispatchError> {
let now = frame_system::Module::<T>::block_number(); let now = frame_system::Pallet::<T>::block_number();
let when = match when { let when = match when {
DispatchTime::At(x) => x, DispatchTime::At(x) => x,
@@ -793,9 +793,9 @@ mod tests {
NodeBlock = Block, NodeBlock = Block,
UncheckedExtrinsic = UncheckedExtrinsic, UncheckedExtrinsic = UncheckedExtrinsic,
{ {
System: frame_system::{Module, Call, Config, Storage, Event<T>}, System: frame_system::{Pallet, Call, Config, Storage, Event<T>},
Logger: logger::{Module, Call, Event}, Logger: logger::{Pallet, Call, Event},
Scheduler: scheduler::{Module, Call, Storage, Event<T>}, Scheduler: scheduler::{Pallet, Call, Storage, Event<T>},
} }
); );
+3 -3
View File
@@ -37,9 +37,9 @@ frame_support::construct_runtime!(
NodeBlock = Block, NodeBlock = Block,
UncheckedExtrinsic = UncheckedExtrinsic, UncheckedExtrinsic = UncheckedExtrinsic,
{ {
System: frame_system::{Module, Call, Config, Storage, Event<T>}, System: frame_system::{Pallet, Call, Config, Storage, Event<T>},
Balances: pallet_balances::{Module, Call, Storage, Config<T>, Event<T>}, Balances: pallet_balances::{Pallet, Call, Storage, Config<T>, Event<T>},
ScoredPool: pallet_scored_pool::{Module, Call, Storage, Config<T>, Event<T>}, ScoredPool: pallet_scored_pool::{Pallet, Call, Storage, Config<T>, Event<T>},
} }
); );
+2 -2
View File
@@ -24,8 +24,8 @@ use frame_support::{assert_ok, assert_noop, traits::OnInitialize};
use sp_runtime::traits::BadOrigin; use sp_runtime::traits::BadOrigin;
type ScoredPool = Module<Test>; type ScoredPool = Module<Test>;
type System = frame_system::Module<Test>; type System = frame_system::Pallet<Test>;
type Balances = pallet_balances::Module<Test>; type Balances = pallet_balances::Pallet<Test>;
#[test] #[test]
fn query_membership_works() { fn query_membership_works() {
@@ -41,10 +41,10 @@ use sp_runtime::traits::{One, StaticLookup};
const MAX_VALIDATORS: u32 = 1000; const MAX_VALIDATORS: u32 = 1000;
pub struct Module<T: Config>(pallet_session::Module<T>); pub struct Pallet<T: Config>(pallet_session::Module<T>);
pub trait Config: pallet_session::Config + pallet_session::historical::Config + pallet_staking::Config {} pub trait Config: pallet_session::Config + pallet_session::historical::Config + pallet_staking::Config {}
impl<T: Config> OnInitialize<T::BlockNumber> for Module<T> { impl<T: Config> OnInitialize<T::BlockNumber> for Pallet<T> {
fn on_initialize(n: T::BlockNumber) -> frame_support::weights::Weight { fn on_initialize(n: T::BlockNumber) -> frame_support::weights::Weight {
pallet_session::Module::<T>::on_initialize(n) pallet_session::Module::<T>::on_initialize(n)
} }
@@ -157,7 +157,7 @@ fn check_membership_proof_setup<T: Config>(
Session::<T>::set_keys(RawOrigin::Signed(controller).into(), keys, proof).unwrap(); Session::<T>::set_keys(RawOrigin::Signed(controller).into(), keys, proof).unwrap();
} }
Module::<T>::on_initialize(T::BlockNumber::one()); Pallet::<T>::on_initialize(T::BlockNumber::one());
// skip sessions until the new validator set is enacted // skip sessions until the new validator set is enacted
while Session::<T>::validators().len() < n as usize { while Session::<T>::validators().len() < n as usize {
@@ -170,7 +170,7 @@ fn check_membership_proof_setup<T: Config>(
} }
impl_benchmark_test_suite!( impl_benchmark_test_suite!(
Module, Pallet,
crate::mock::new_test_ext(), crate::mock::new_test_ext(),
crate::mock::Test, crate::mock::Test,
extra = false, extra = false,
@@ -37,10 +37,10 @@ frame_support::construct_runtime!(
NodeBlock = Block, NodeBlock = Block,
UncheckedExtrinsic = UncheckedExtrinsic, UncheckedExtrinsic = UncheckedExtrinsic,
{ {
System: frame_system::{Module, Call, Config, Storage, Event<T>}, System: frame_system::{Pallet, Call, Config, Storage, Event<T>},
Balances: pallet_balances::{Module, Call, Storage, Config<T>, Event<T>}, Balances: pallet_balances::{Pallet, Call, Storage, Config<T>, Event<T>},
Staking: pallet_staking::{Module, Call, Config<T>, Storage, Event<T>, ValidateUnsigned}, Staking: pallet_staking::{Pallet, Call, Config<T>, Storage, Event<T>, ValidateUnsigned},
Session: pallet_session::{Module, Call, Storage, Event, Config<T>}, Session: pallet_session::{Pallet, Call, Storage, Event, Config<T>},
} }
); );
@@ -164,7 +164,7 @@ impl onchain::Config for Test {
impl pallet_staking::Config for Test { impl pallet_staking::Config for Test {
type Currency = Balances; type Currency = Balances;
type UnixTime = pallet_timestamp::Module<Self>; type UnixTime = pallet_timestamp::Pallet<Self>;
type CurrencyToVote = frame_support::traits::SaturatingCurrencyToVote; type CurrencyToVote = frame_support::traits::SaturatingCurrencyToVote;
type RewardRemainder = (); type RewardRemainder = ();
type Event = Event; type Event = Event;
@@ -358,7 +358,7 @@ pub(crate) mod tests {
); );
BasicExternalities::execute_with_storage(&mut t, || { BasicExternalities::execute_with_storage(&mut t, || {
for (ref k, ..) in &keys { for (ref k, ..) in &keys {
frame_system::Module::<Test>::inc_providers(k); frame_system::Pallet::<Test>::inc_providers(k);
} }
}); });
crate::GenesisConfig::<Test> { keys }.assimilate_storage(&mut t).unwrap(); crate::GenesisConfig::<Test> { keys }.assimilate_storage(&mut t).unwrap();
@@ -28,7 +28,7 @@
use sp_runtime::{offchain::storage::StorageValueRef, KeyTypeId}; use sp_runtime::{offchain::storage::StorageValueRef, KeyTypeId};
use sp_session::MembershipProof; use sp_session::MembershipProof;
use super::super::{Module as SessionModule, SessionIndex}; use super::super::{Pallet as SessionModule, SessionIndex};
use super::{IdentificationTuple, ProvingTrie, Config}; use super::{IdentificationTuple, ProvingTrie, Config};
use super::shared; use super::shared;
@@ -167,7 +167,7 @@ mod tests {
); );
BasicExternalities::execute_with_storage(&mut t, || { BasicExternalities::execute_with_storage(&mut t, || {
for (ref k, ..) in &keys { for (ref k, ..) in &keys {
frame_system::Module::<Test>::inc_providers(k); frame_system::Pallet::<Test>::inc_providers(k);
} }
}); });
@@ -21,7 +21,7 @@ use codec::Encode;
use sp_runtime::traits::Convert; use sp_runtime::traits::Convert;
use super::super::Config as SessionConfig; use super::super::Config as SessionConfig;
use super::super::{Module as SessionModule, SessionIndex}; use super::super::{Pallet as SessionModule, SessionIndex};
use super::Config as HistoricalConfig; use super::Config as HistoricalConfig;
use super::shared; use super::shared;
+4 -4
View File
@@ -442,7 +442,7 @@ decl_storage! {
for (account, val, keys) in config.keys.iter().cloned() { for (account, val, keys) in config.keys.iter().cloned() {
<Module<T>>::inner_set_keys(&val, keys) <Module<T>>::inner_set_keys(&val, keys)
.expect("genesis config must not contain duplicates; qed"); .expect("genesis config must not contain duplicates; qed");
assert!(frame_system::Module::<T>::inc_consumers(&account).is_ok()); assert!(frame_system::Pallet::<T>::inc_consumers(&account).is_ok());
} }
let initial_validators_0 = T::SessionManager::new_session(0) let initial_validators_0 = T::SessionManager::new_session(0)
@@ -746,10 +746,10 @@ impl<T: Config> Module<T> {
let who = T::ValidatorIdOf::convert(account.clone()) let who = T::ValidatorIdOf::convert(account.clone())
.ok_or(Error::<T>::NoAssociatedValidatorId)?; .ok_or(Error::<T>::NoAssociatedValidatorId)?;
frame_system::Module::<T>::inc_consumers(&account).map_err(|_| Error::<T>::NoAccount)?; frame_system::Pallet::<T>::inc_consumers(&account).map_err(|_| Error::<T>::NoAccount)?;
let old_keys = Self::inner_set_keys(&who, keys)?; let old_keys = Self::inner_set_keys(&who, keys)?;
if old_keys.is_some() { if old_keys.is_some() {
let _ = frame_system::Module::<T>::dec_consumers(&account); let _ = frame_system::Pallet::<T>::dec_consumers(&account);
// ^^^ Defensive only; Consumers were incremented just before, so should never fail. // ^^^ Defensive only; Consumers were incremented just before, so should never fail.
} }
@@ -798,7 +798,7 @@ impl<T: Config> Module<T> {
let key_data = old_keys.get_raw(*id); let key_data = old_keys.get_raw(*id);
Self::clear_key_owner(*id, key_data); Self::clear_key_owner(*id, key_data);
} }
frame_system::Module::<T>::dec_consumers(&account); frame_system::Pallet::<T>::dec_consumers(&account);
Ok(()) Ok(())
} }
+8 -8
View File
@@ -78,9 +78,9 @@ frame_support::construct_runtime!(
NodeBlock = Block, NodeBlock = Block,
UncheckedExtrinsic = UncheckedExtrinsic, UncheckedExtrinsic = UncheckedExtrinsic,
{ {
System: frame_system::{Module, Call, Config, Storage, Event<T>}, System: frame_system::{Pallet, Call, Config, Storage, Event<T>},
Session: pallet_session::{Module, Call, Storage, Event, Config<T>}, Session: pallet_session::{Pallet, Call, Storage, Event, Config<T>},
Historical: pallet_session_historical::{Module}, Historical: pallet_session_historical::{Pallet},
} }
); );
@@ -91,8 +91,8 @@ frame_support::construct_runtime!(
NodeBlock = Block, NodeBlock = Block,
UncheckedExtrinsic = UncheckedExtrinsic, UncheckedExtrinsic = UncheckedExtrinsic,
{ {
System: frame_system::{Module, Call, Config, Storage, Event<T>}, System: frame_system::{Pallet, Call, Config, Storage, Event<T>},
Session: pallet_session::{Module, Call, Storage, Event, Config<T>}, Session: pallet_session::{Pallet, Call, Storage, Event, Config<T>},
} }
); );
@@ -210,11 +210,11 @@ pub fn new_test_ext() -> sp_io::TestExternalities {
); );
BasicExternalities::execute_with_storage(&mut t, || { BasicExternalities::execute_with_storage(&mut t, || {
for (ref k, ..) in &keys { for (ref k, ..) in &keys {
frame_system::Module::<Test>::inc_providers(k); frame_system::Pallet::<Test>::inc_providers(k);
} }
frame_system::Module::<Test>::inc_providers(&4); frame_system::Pallet::<Test>::inc_providers(&4);
// An additional identity that we use. // An additional identity that we use.
frame_system::Module::<Test>::inc_providers(&69); frame_system::Pallet::<Test>::inc_providers(&69);
}); });
pallet_session::GenesisConfig::<Test> { keys }.assimilate_storage(&mut t).unwrap(); pallet_session::GenesisConfig::<Test> { keys }.assimilate_storage(&mut t).unwrap();
sp_io::TestExternalities::new(t) sp_io::TestExternalities::new(t)
+3 -3
View File
@@ -793,7 +793,7 @@ decl_module! {
let mut payouts = <Payouts<T, I>>::get(&who); let mut payouts = <Payouts<T, I>>::get(&who);
if let Some((when, amount)) = payouts.first() { if let Some((when, amount)) = payouts.first() {
if when <= &<system::Module<T>>::block_number() { if when <= &<system::Pallet<T>>::block_number() {
T::Currency::transfer(&Self::payouts(), &who, *amount, AllowDeath)?; T::Currency::transfer(&Self::payouts(), &who, *amount, AllowDeath)?;
payouts.remove(0); payouts.remove(0);
if payouts.is_empty() { if payouts.is_empty() {
@@ -981,7 +981,7 @@ decl_module! {
// Reduce next pot by payout // Reduce next pot by payout
<Pot<T, I>>::put(pot - value); <Pot<T, I>>::put(pot - value);
// Add payout for new candidate // Add payout for new candidate
let maturity = <system::Module<T>>::block_number() let maturity = <system::Pallet<T>>::block_number()
+ Self::lock_duration(Self::members().len() as u32); + Self::lock_duration(Self::members().len() as u32);
Self::pay_accepted_candidate(&who, value, kind, maturity); Self::pay_accepted_candidate(&who, value, kind, maturity);
} }
@@ -1324,7 +1324,7 @@ impl<T: Config<I>, I: Instance> Module<T, I> {
// critical issues or side-effects. This is auto-correcting as members fall out of society. // critical issues or side-effects. This is auto-correcting as members fall out of society.
members.reserve(candidates.len()); members.reserve(candidates.len());
let maturity = <system::Module<T>>::block_number() let maturity = <system::Pallet<T>>::block_number()
+ Self::lock_duration(members.len() as u32); + Self::lock_duration(members.len() as u32);
let mut rewardees = Vec::new(); let mut rewardees = Vec::new();
+4 -4
View File
@@ -41,9 +41,9 @@ frame_support::construct_runtime!(
NodeBlock = Block, NodeBlock = Block,
UncheckedExtrinsic = UncheckedExtrinsic, UncheckedExtrinsic = UncheckedExtrinsic,
{ {
System: frame_system::{Module, Call, Config, Storage, Event<T>}, System: frame_system::{Pallet, Call, Config, Storage, Event<T>},
Balances: pallet_balances::{Module, Call, Storage, Config<T>, Event<T>}, Balances: pallet_balances::{Pallet, Call, Storage, Config<T>, Event<T>},
Society: pallet_society::{Module, Call, Storage, Event<T>, Config<T>}, Society: pallet_society::{Pallet, Call, Storage, Event<T>, Config<T>},
} }
); );
@@ -104,7 +104,7 @@ impl pallet_balances::Config for Test {
impl Config for Test { impl Config for Test {
type Event = Event; type Event = Event;
type Currency = pallet_balances::Module<Self>; type Currency = pallet_balances::Pallet<Self>;
type Randomness = TestRandomness<Self>; type Randomness = TestRandomness<Self>;
type CandidateDeposit = CandidateDeposit; type CandidateDeposit = CandidateDeposit;
type WrongSideDeduction = WrongSideDeduction; type WrongSideDeduction = WrongSideDeduction;
+6 -6
View File
@@ -33,11 +33,11 @@ frame_support::construct_runtime!(
NodeBlock = Block, NodeBlock = Block,
UncheckedExtrinsic = UncheckedExtrinsic, UncheckedExtrinsic = UncheckedExtrinsic,
{ {
System: frame_system::{Module, Call, Config, Storage, Event<T>}, System: frame_system::{Pallet, Call, Config, Storage, Event<T>},
Balances: pallet_balances::{Module, Call, Storage, Config<T>, Event<T>}, Balances: pallet_balances::{Pallet, Call, Storage, Config<T>, Event<T>},
Staking: pallet_staking::{Module, Call, Config<T>, Storage, Event<T>, ValidateUnsigned}, Staking: pallet_staking::{Pallet, Call, Config<T>, Storage, Event<T>, ValidateUnsigned},
Indices: pallet_indices::{Module, Call, Storage, Config<T>, Event<T>}, Indices: pallet_indices::{Pallet, Call, Storage, Config<T>, Event<T>},
Session: pallet_session::{Module, Call, Storage, Event, Config<T>}, Session: pallet_session::{Pallet, Call, Storage, Event, Config<T>},
} }
); );
@@ -174,7 +174,7 @@ impl frame_election_provider_support::ElectionProvider<AccountId, BlockNumber>
impl pallet_staking::Config for Test { impl pallet_staking::Config for Test {
type Currency = Balances; type Currency = Balances;
type UnixTime = pallet_timestamp::Module<Self>; type UnixTime = pallet_timestamp::Pallet<Self>;
type CurrencyToVote = frame_support::traits::SaturatingCurrencyToVote; type CurrencyToVote = frame_support::traits::SaturatingCurrencyToVote;
type RewardRemainder = (); type RewardRemainder = ();
type Event = Event; type Event = Event;
+5 -5
View File
@@ -1552,7 +1552,7 @@ decl_module! {
Err(Error::<T>::InsufficientValue)? Err(Error::<T>::InsufficientValue)?
} }
system::Module::<T>::inc_consumers(&stash).map_err(|_| Error::<T>::BadState)?; system::Pallet::<T>::inc_consumers(&stash).map_err(|_| Error::<T>::BadState)?;
// You're auto-bonded forever, here. We might improve this by only bonding when // You're auto-bonded forever, here. We might improve this by only bonding when
// you actually validate/nominate and remove once you unbond __everything__. // you actually validate/nominate and remove once you unbond __everything__.
@@ -3254,7 +3254,7 @@ impl<T: Config> Module<T> {
<Validators<T>>::remove(stash); <Validators<T>>::remove(stash);
<Nominators<T>>::remove(stash); <Nominators<T>>::remove(stash);
system::Module::<T>::dec_consumers(stash); system::Pallet::<T>::dec_consumers(stash);
Ok(()) Ok(())
} }
@@ -3516,7 +3516,7 @@ impl<T: Config> pallet_session::SessionManager<T::AccountId> for Module<T> {
log!( log!(
trace, trace,
"[{:?}] planning new_session({})", "[{:?}] planning new_session({})",
<frame_system::Module<T>>::block_number(), <frame_system::Pallet<T>>::block_number(),
new_index, new_index,
); );
CurrentPlannedSession::put(new_index); CurrentPlannedSession::put(new_index);
@@ -3526,7 +3526,7 @@ impl<T: Config> pallet_session::SessionManager<T::AccountId> for Module<T> {
log!( log!(
trace, trace,
"[{:?}] starting start_session({})", "[{:?}] starting start_session({})",
<frame_system::Module<T>>::block_number(), <frame_system::Pallet<T>>::block_number(),
start_index, start_index,
); );
Self::start_session(start_index) Self::start_session(start_index)
@@ -3535,7 +3535,7 @@ impl<T: Config> pallet_session::SessionManager<T::AccountId> for Module<T> {
log!( log!(
trace, trace,
"[{:?}] ending end_session({})", "[{:?}] ending end_session({})",
<frame_system::Module<T>>::block_number(), <frame_system::Pallet<T>>::block_number(),
end_index, end_index,
); );
Self::end_session(end_index) Self::end_session(end_index)
+5 -5
View File
@@ -98,11 +98,11 @@ frame_support::construct_runtime!(
NodeBlock = Block, NodeBlock = Block,
UncheckedExtrinsic = UncheckedExtrinsic, UncheckedExtrinsic = UncheckedExtrinsic,
{ {
System: frame_system::{Module, Call, Config, Storage, Event<T>}, System: frame_system::{Pallet, Call, Config, Storage, Event<T>},
Timestamp: pallet_timestamp::{Module, Call, Storage, Inherent}, Timestamp: pallet_timestamp::{Pallet, Call, Storage, Inherent},
Balances: pallet_balances::{Module, Call, Storage, Config<T>, Event<T>}, Balances: pallet_balances::{Pallet, Call, Storage, Config<T>, Event<T>},
Staking: staking::{Module, Call, Config<T>, Storage, Event<T>, ValidateUnsigned}, Staking: staking::{Pallet, Call, Config<T>, Storage, Event<T>, ValidateUnsigned},
Session: pallet_session::{Module, Call, Storage, Event, Config<T>}, Session: pallet_session::{Pallet, Call, Storage, Event, Config<T>},
} }
); );
+3 -3
View File
@@ -82,9 +82,9 @@ frame_support::construct_runtime!(
NodeBlock = Block, NodeBlock = Block,
UncheckedExtrinsic = UncheckedExtrinsic, UncheckedExtrinsic = UncheckedExtrinsic,
{ {
System: frame_system::{Module, Call, Config, Storage, Event<T>}, System: frame_system::{Pallet, Call, Config, Storage, Event<T>},
Sudo: sudo::{Module, Call, Config<T>, Storage, Event<T>}, Sudo: sudo::{Pallet, Call, Config<T>, Storage, Event<T>},
Logger: logger::{Module, Call, Storage, Event<T>}, Logger: logger::{Pallet, Call, Storage, Event<T>},
} }
); );

Some files were not shown because too many files have changed in this diff Show More