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

* Replace 'Module' with 'Pallet'.

* "Update Substrate"

* fix babe usage

* fix benchmark

Co-authored-by: parity-processbot <>
Co-authored-by: thiolliere <gui.thiolliere@gmail.com>
This commit is contained in:
Shaun Wang
2021-03-18 23:10:17 +13:00
committed by GitHub
parent 503e2b74f9
commit 9047bbb392
36 changed files with 491 additions and 493 deletions
+1 -1
View File
@@ -145,7 +145,7 @@ impl<T: Config> Module<T> {
let inbound = InboundDownwardMessage {
msg,
sent_at: <frame_system::Module<T>>::block_number(),
sent_at: <frame_system::Pallet<T>>::block_number(),
};
// obtain the new link in the MQC and update the head.
+1 -1
View File
@@ -809,7 +809,7 @@ impl<T: Config> Module<T> {
out_hrmp_msgs: Vec<OutboundHrmpMessage<ParaId>>,
) -> Weight {
let mut weight = 0;
let now = <frame_system::Module<T>>::block_number();
let now = <frame_system::Pallet<T>>::block_number();
for out_msg in out_hrmp_msgs {
let channel_id = HrmpChannelId {
+6 -6
View File
@@ -260,7 +260,7 @@ impl<T: Config> Module<T> {
let mut last_index = None;
let signing_context = SigningContext {
parent_hash: <frame_system::Module<T>>::parent_hash(),
parent_hash: <frame_system::Pallet<T>>::parent_hash(),
session_index,
};
@@ -296,7 +296,7 @@ impl<T: Config> Module<T> {
}
}
let now = <frame_system::Module<T>>::block_number();
let now = <frame_system::Pallet<T>>::block_number();
for signed_bitfield in signed_bitfields {
for (bit_idx, _)
in signed_bitfield.payload().0.iter().enumerate().filter(|(_, is_av)| **is_av)
@@ -390,11 +390,11 @@ impl<T: Config> Module<T> {
}
let validators = shared::Module::<T>::active_validator_keys();
let parent_hash = <frame_system::Module<T>>::parent_hash();
let parent_hash = <frame_system::Pallet<T>>::parent_hash();
// At the moment we assume (and in fact enforce, below) that the relay-parent is always one
// before of the block where we include a candidate (i.e. this code path).
let now = <frame_system::Module<T>>::block_number();
let now = <frame_system::Pallet<T>>::block_number();
let relay_parent_number = now - One::one();
let check_cx = CandidateCheckContext::<T>::new(now, relay_parent_number);
@@ -612,7 +612,7 @@ impl<T: Config> Module<T> {
) -> bool {
// This function is meant to be called from the runtime APIs against the relay-parent, hence
// `relay_parent_number` is equal to `now`.
let now = <frame_system::Module<T>>::block_number();
let now = <frame_system::Pallet<T>>::block_number();
let relay_parent_number = now;
let check_cx = CandidateCheckContext::<T>::new(now, relay_parent_number);
@@ -1133,7 +1133,7 @@ mod tests {
}
fn make_vdata_hash(para_id: ParaId) -> Option<Hash> {
let relay_parent_number = <frame_system::Module<Test>>::block_number() - 1;
let relay_parent_number = <frame_system::Pallet<Test>>::block_number() - 1;
let persisted_validation_data
= crate::util::make_persisted_validation_data::<Test>(
para_id,
@@ -100,7 +100,7 @@ decl_module! {
ensure!(!<Included>::exists(), Error::<T>::TooManyInclusionInherents);
// Check that the submitted parent header indeed corresponds to the previous block hash.
let parent_hash = <frame_system::Module<T>>::parent_hash();
let parent_hash = <frame_system::Pallet<T>>::parent_hash();
ensure!(
parent_header.hash().as_ref() == parent_hash.as_ref(),
Error::<T>::InvalidParentHeader,
@@ -130,7 +130,7 @@ decl_module! {
<scheduler::Module<T>>::clear();
<scheduler::Module<T>>::schedule(
freed,
<frame_system::Module<T>>::block_number(),
<frame_system::Pallet<T>>::block_number(),
);
let backed_candidates = limit_backed_candidates::<T>(backed_candidates);
@@ -197,7 +197,7 @@ fn limit_backed_candidates<T: Config>(
// the weight of the inclusion inherent is already included in the current block weight,
// so our operation is simple: if the block is currently overloaded, make this intrinsic smaller
if frame_system::Module::<T>::block_weight().total() > <T as frame_system::Config>::BlockWeights::get().max_block {
if frame_system::Pallet::<T>::block_weight().total() > <T as frame_system::Config>::BlockWeights::get().max_block {
Vec::new()
} else {
backed_candidates
+13 -13
View File
@@ -40,18 +40,18 @@ frame_support::construct_runtime!(
NodeBlock = Block,
UncheckedExtrinsic = UncheckedExtrinsic,
{
System: frame_system::{Module, Call, Config, Storage, Event<T>},
Balances: pallet_balances::{Module, Call, Storage, Config<T>, Event<T>},
Paras: paras::{Module, Origin, Call, Storage, Config<T>},
Configuration: configuration::{Module, Call, Storage, Config<T>},
Shared: shared::{Module, Call, Storage},
Inclusion: inclusion::{Module, Call, Storage, Event<T>},
Scheduler: scheduler::{Module, Call, Storage},
Initializer: initializer::{Module, Call, Storage},
Dmp: dmp::{Module, Call, Storage},
Ump: ump::{Module, Call, Storage},
Hrmp: hrmp::{Module, Call, Storage, Event},
SessionInfo: session_info::{Module, Call, Storage},
System: frame_system::{Pallet, Call, Config, Storage, Event<T>},
Balances: pallet_balances::{Pallet, Call, Storage, Config<T>, Event<T>},
Paras: paras::{Pallet, Origin, Call, Storage, Config<T>},
Configuration: configuration::{Pallet, Call, Storage, Config<T>},
Shared: shared::{Pallet, Call, Storage},
Inclusion: inclusion::{Pallet, Call, Storage, Event<T>},
Scheduler: scheduler::{Pallet, Call, Storage},
Initializer: initializer::{Pallet, Call, Storage},
Dmp: dmp::{Pallet, Call, Storage},
Ump: ump::{Pallet, Call, Storage},
Hrmp: hrmp::{Pallet, Call, Storage, Event},
SessionInfo: session_info::{Pallet, Call, Storage},
}
);
@@ -121,7 +121,7 @@ impl crate::ump::Config for Test {
impl crate::hrmp::Config for Test {
type Event = Event;
type Origin = Origin;
type Currency = pallet_balances::Module<Test>;
type Currency = pallet_balances::Pallet<Test>;
}
impl crate::scheduler::Config for Test { }
+3 -3
View File
@@ -367,7 +367,7 @@ impl<T: Config> Module<T> {
fn apply_actions_queue(session: SessionIndex) -> Vec<ParaId> {
let actions = ActionsQueue::take(session);
let mut parachains = <Self as Store>::Parachains::get();
let now = <frame_system::Module<T>>::block_number();
let now = <frame_system::Pallet<T>>::block_number();
let mut outgoing = Vec::new();
for para in actions {
@@ -643,7 +643,7 @@ impl<T: Config> Module<T> {
CurrentCode::insert(&id, &new_code);
// `now` is only used for registering pruning as part of `fn note_past_code`
let now = <frame_system::Module<T>>::block_number();
let now = <frame_system::Pallet<T>>::block_number();
let weight = Self::note_past_code(
id,
@@ -675,7 +675,7 @@ impl<T: Config> Module<T> {
at: T::BlockNumber,
assume_intermediate: Option<T::BlockNumber>,
) -> Option<ValidationCode> {
let now = <frame_system::Module<T>>::block_number();
let now = <frame_system::Pallet<T>>::block_number();
let config = <configuration::Module<T>>::config();
if assume_intermediate.as_ref().map_or(false, |i| &at <= i) {
@@ -40,7 +40,7 @@ pub fn validator_groups<T: initializer::Config>() -> (
Vec<Vec<ValidatorIndex>>,
GroupRotationInfo<T::BlockNumber>,
) {
let now = <frame_system::Module<T>>::block_number() + One::one();
let now = <frame_system::Pallet<T>>::block_number() + One::one();
let groups = <scheduler::Module<T>>::validator_groups();
let rotation_info = <scheduler::Module<T>>::group_rotation_info(now);
@@ -54,7 +54,7 @@ pub fn availability_cores<T: initializer::Config>() -> Vec<CoreState<T::Hash, T:
let parachains = <paras::Module<T>>::parachains();
let config = <configuration::Module<T>>::config();
let now = <frame_system::Module<T>>::block_number() + One::one();
let now = <frame_system::Pallet<T>>::block_number() + One::one();
<scheduler::Module<T>>::clear();
<scheduler::Module<T>>::schedule(Vec::new(), now);
@@ -202,7 +202,7 @@ pub fn persisted_validation_data<T: initializer::Config>(
assumption: OccupiedCoreAssumption,
) -> Option<PersistedValidationData<T::BlockNumber>> {
use parity_scale_codec::Decode as _;
let relay_parent_number = <frame_system::Module<T>>::block_number();
let relay_parent_number = <frame_system::Pallet<T>>::block_number();
let relay_parent_storage_root = Hash::decode(&mut &sp_io::storage::root()[..])
.expect("storage root must decode to the Hash type; qed");
with_assumption::<T, _, _>(para_id, assumption, || {
@@ -292,7 +292,7 @@ where
{
use inclusion::Event as RawEvent;
<frame_system::Module<T>>::events().into_iter()
<frame_system::Pallet<T>>::events().into_iter()
.filter_map(|record| extract_event(record.event))
.map(|event| match event {
RawEvent::<T>::CandidateBacked(c, h, core, group)
+2 -2
View File
@@ -323,7 +323,7 @@ impl<T: Config> Module<T> {
});
ParathreadQueue::set(thread_queue);
let now = <frame_system::Module<T>>::block_number() + One::one();
let now = <frame_system::Pallet<T>>::block_number() + One::one();
<SessionStartBlock<T>>::set(now);
}
@@ -587,7 +587,7 @@ impl<T: Config> Module<T> {
/// https://github.com/rust-lang/rust/issues/73226
/// which prevents us from testing the code if using `impl Trait`.
pub(crate) fn availability_timeout_predicate() -> Option<Box<dyn Fn(CoreIndex, T::BlockNumber) -> bool>> {
let now = <frame_system::Module<T>>::block_number();
let now = <frame_system::Pallet<T>>::block_number();
let config = <configuration::Module<T>>::config();
let session_start = <SessionStartBlock<T>>::get();