From c6f82ee3d93bc810e125131206362cc35cf1c383 Mon Sep 17 00:00:00 2001 From: ferrell-code Date: Wed, 7 Jul 2021 23:02:51 -0400 Subject: [PATCH 1/7] frame v2 --- runtime/parachains/src/inclusion.rs | 186 ++++++++++-------- runtime/parachains/src/initializer.rs | 6 +- runtime/parachains/src/paras_inherent.rs | 6 +- runtime/parachains/src/runtime_api_impl/v1.rs | 14 +- 4 files changed, 113 insertions(+), 99 deletions(-) diff --git a/runtime/parachains/src/inclusion.rs b/runtime/parachains/src/inclusion.rs index eb58f315a0fa..b7bccd072d24 100644 --- a/runtime/parachains/src/inclusion.rs +++ b/runtime/parachains/src/inclusion.rs @@ -27,16 +27,15 @@ use primitives::v1::{ BackedCandidate, CoreIndex, GroupIndex, CommittedCandidateReceipt, CandidateReceipt, HeadData, CandidateHash, }; -use frame_support::{ - decl_storage, decl_module, decl_error, decl_event, ensure, dispatch::DispatchResult, IterableStorageMap, - weights::Weight, traits::Get, -}; +use frame_support::pallet_prelude::*; use parity_scale_codec::{Encode, Decode}; use bitvec::{order::Lsb0 as BitOrderLsb0, vec::BitVec}; use sp_runtime::{DispatchError, traits::{One, Saturating}}; use crate::{configuration, paras, dmp, ump, hrmp, shared, scheduler::CoreAssignment}; +pub use pallet::*; + /// A bitfield signed by a validator indicating that it is keeping its piece of the erasure-coding /// for any backed candidates referred to by a `1` bit available. /// @@ -108,37 +107,42 @@ pub trait RewardValidators { fn reward_bitfields(validators: impl IntoIterator); } -pub trait Config: - frame_system::Config - + shared::Config - + paras::Config - + dmp::Config - + ump::Config - + hrmp::Config - + configuration::Config -{ - type Event: From> + Into<::Event>; - type RewardValidators: RewardValidators; -} - -decl_storage! { - trait Store for Module as ParaInclusion { - /// The latest bitfield for each validator, referred to by their index in the validator set. - AvailabilityBitfields: map hasher(twox_64_concat) ValidatorIndex - => Option>; +#[frame_support::pallet] +pub mod pallet { + use super::*; - /// Candidates pending availability by `ParaId`. - PendingAvailability: map hasher(twox_64_concat) ParaId - => Option>; + #[pallet::pallet] + #[pallet::generate_store(pub(super) trait Store)] + pub struct Pallet(_); + + #[pallet::config] + pub trait Config: + frame_system::Config + + shared::Config + + paras::Config + + dmp::Config + + ump::Config + + hrmp::Config + + configuration::Config + { + type Event: From> + IsType<::Event>; + type RewardValidators: RewardValidators; + } - /// The commitments of candidates pending availability, by ParaId. - PendingAvailabilityCommitments: map hasher(twox_64_concat) ParaId - => Option; + #[pallet::event] + #[pallet::generate_deposit(pub(super) fn deposit_event)] + #[pallet::metadata(T::Hash = "Hash")] + pub enum Event { + /// A candidate was backed. [candidate, head_data] + CandidateBacked(CandidateReceipt, HeadData, CoreIndex, GroupIndex), + /// A candidate was included. [candidate, head_data] + CandidateIncluded(CandidateReceipt, HeadData, CoreIndex, GroupIndex), + /// A candidate timed out. [candidate, head_data] + CandidateTimedOut(CandidateReceipt, HeadData, CoreIndex), } -} -decl_error! { - pub enum Error for Module { + #[pallet::error] + pub enum Error { /// Availability bitfield has unexpected size. WrongBitfieldSize, /// Multiple bitfields submitted by same validator or validators out of order by index. @@ -188,33 +192,42 @@ decl_error! { /// The validation code hash of the candidate is not valid. InvalidValidationCodeHash, } -} - -decl_event! { - pub enum Event where ::Hash { - /// A candidate was backed. [candidate, head_data] - CandidateBacked(CandidateReceipt, HeadData, CoreIndex, GroupIndex), - /// A candidate was included. [candidate, head_data] - CandidateIncluded(CandidateReceipt, HeadData, CoreIndex, GroupIndex), - /// A candidate timed out. [candidate, head_data] - CandidateTimedOut(CandidateReceipt, HeadData, CoreIndex), - } -} -decl_module! { - /// The parachain-candidate inclusion module. - pub struct Module - for enum Call where origin: ::Origin - { - type Error = Error; + /// The latest bitfield for each validator, referred to by their index in the validator set. + #[pallet::storage] + pub type AvailabilityBitfields = StorageMap< + _, + Twox64Concat, + ValidatorIndex, + AvailabilityBitfieldRecord + >; + + /// Candidates pending availability by `ParaId`. + #[pallet::storage] + pub type PendingAvailability = StorageMap< + _, + Twox64Concat, + ParaId, + CandidatePendingAvailability + >; + + /// The commitments of candidates pending availability, by ParaId. + #[pallet::storage] + pub type PendingAvailabilityCommitments = StorageMap< + _, + Twox64Concat, + ParaId, + CandidateCommitments + >; + + #[pallet::call] + impl Pallet {} - fn deposit_event() = default; - } } const LOG_TARGET: &str = "runtime::inclusion"; -impl Module { +impl Pallet { /// Block initialization logic, called by initializer. pub(crate) fn initializer_initialize(_now: T::BlockNumber) -> Weight { 0 } @@ -227,7 +240,7 @@ impl Module { ) { // unlike most drain methods, drained elements are not cleared on `Drop` of the iterator // and require consumption. - for _ in ::drain() { } + for _ in >::drain() { } for _ in >::drain() { } for _ in >::drain() { } } @@ -343,7 +356,7 @@ impl Module { { if pending_availability.availability_votes.count_ones() >= threshold { >::remove(¶_id); - let commitments = match PendingAvailabilityCommitments::take(¶_id) { + let commitments = match PendingAvailabilityCommitments::::take(¶_id) { Some(commitments) => commitments, None => { log::warn!( @@ -520,7 +533,7 @@ impl Module { ensure!( >::get(¶_id).is_none() && - ::get(¶_id).is_none(), + >::get(¶_id).is_none(), Error::::CandidateScheduledBeforeParaFree, ); @@ -616,7 +629,7 @@ impl Module { backed_in_number: check_cx.now, backing_group: group, }); - ::insert(¶_id, commitments); + >::insert(¶_id, commitments); } Ok(core_indices) @@ -734,7 +747,7 @@ impl Module { for para_id in cleaned_up_ids { let pending = >::take(¶_id); - let commitments = ::take(¶_id); + let commitments = >::take(¶_id); if let (Some(pending), Some(commitments)) = (pending, commitments) { // defensive: this should always be true. @@ -762,7 +775,7 @@ impl Module { /// where the changes to the state are expected to be discarded directly after. pub(crate) fn force_enact(para: ParaId) { let pending = >::take(¶); - let commitments = ::take(¶); + let commitments = >::take(¶); if let (Some(pending), Some(commitments)) = (pending, commitments) { let candidate = CommittedCandidateReceipt { @@ -787,7 +800,7 @@ impl Module { { >::get(¶) .map(|p| p.descriptor) - .and_then(|d| ::get(¶).map(move |c| (d, c))) + .and_then(|d| >::get(¶).map(move |c| (d, c))) .map(|(d, c)| CommittedCandidateReceipt { descriptor: d, commitments: c }) } @@ -915,7 +928,6 @@ mod tests { CandidateCommitments, SignedStatement, CandidateDescriptor, ValidationCode, ValidatorId, }; use sp_keystore::{SyncCryptoStorePtr, SyncCryptoStore}; - use frame_support::traits::{OnFinalize, OnInitialize}; use keyring::Sr25519Keyring; use sc_keystore::LocalKeystore; use crate::mock::{ @@ -1182,7 +1194,7 @@ mod tests { backers: default_backing_bitfield(), backing_group: GroupIndex::from(0), }); - PendingAvailabilityCommitments::insert(chain_a, default_candidate.commitments.clone()); + PendingAvailabilityCommitments::::insert(chain_a, default_candidate.commitments.clone()); >::insert(&chain_b, CandidatePendingAvailability { core: CoreIndex::from(1), @@ -1194,21 +1206,21 @@ mod tests { backers: default_backing_bitfield(), backing_group: GroupIndex::from(1), }); - PendingAvailabilityCommitments::insert(chain_b, default_candidate.commitments); + PendingAvailabilityCommitments::::insert(chain_b, default_candidate.commitments); run_to_block(5, |_| None); assert!(>::get(&chain_a).is_some()); assert!(>::get(&chain_b).is_some()); - assert!(::get(&chain_a).is_some()); - assert!(::get(&chain_b).is_some()); + assert!(>::get(&chain_a).is_some()); + assert!(>::get(&chain_b).is_some()); Inclusion::collect_pending(|core, _since| core == CoreIndex::from(0)); assert!(>::get(&chain_a).is_none()); assert!(>::get(&chain_b).is_some()); - assert!(::get(&chain_a).is_none()); - assert!(::get(&chain_b).is_some()); + assert!(>::get(&chain_a).is_none()); + assert!(>::get(&chain_b).is_some()); }); } @@ -1385,7 +1397,7 @@ mod tests { backers: default_backing_bitfield(), backing_group: GroupIndex::from(0), }); - PendingAvailabilityCommitments::insert(chain_a, default_candidate.commitments); + PendingAvailabilityCommitments::::insert(chain_a, default_candidate.commitments); *bare_bitfield.0.get_mut(0).unwrap() = true; let signed = block_on(sign_bitfield( @@ -1403,7 +1415,7 @@ mod tests { ).is_ok()); >::remove(chain_a); - PendingAvailabilityCommitments::remove(chain_a); + PendingAvailabilityCommitments::::remove(chain_a); } // bitfield signed with pending bit signed, but no commitments. @@ -1498,7 +1510,7 @@ mod tests { backers: backing_bitfield(&[3, 4]), backing_group: GroupIndex::from(0), }); - PendingAvailabilityCommitments::insert(chain_a, candidate_a.commitments); + PendingAvailabilityCommitments::::insert(chain_a, candidate_a.commitments); let candidate_b = TestCandidateBuilder { para_id: chain_b, @@ -1516,7 +1528,7 @@ mod tests { backers: backing_bitfield(&[0, 2]), backing_group: GroupIndex::from(1), }); - PendingAvailabilityCommitments::insert(chain_b, candidate_b.commitments); + PendingAvailabilityCommitments::::insert(chain_b, candidate_b.commitments); // this bitfield signals that a and b are available. let a_and_b_available = { @@ -1568,8 +1580,8 @@ mod tests { // chain A had 4 signing off, which is >= threshold. // chain B has 3 signing off, which is < threshold. assert!(>::get(&chain_a).is_none()); - assert!(::get(&chain_a).is_none()); - assert!(::get(&chain_b).is_some()); + assert!(>::get(&chain_a).is_none()); + assert!(>::get(&chain_b).is_some()); assert_eq!( >::get(&chain_b).unwrap().availability_votes, { @@ -1955,7 +1967,7 @@ mod tests { backers: default_backing_bitfield(), backing_group: GroupIndex::from(0), }); - ::insert(&chain_a, candidate.commitments); + >::insert(&chain_a, candidate.commitments); assert_eq!( Inclusion::process_candidates( @@ -1968,7 +1980,7 @@ mod tests { ); >::remove(&chain_a); - ::remove(&chain_a); + >::remove(&chain_a); } // messed up commitments storage - do not panic - reject. @@ -1988,7 +2000,7 @@ mod tests { ); // this is not supposed to happen - ::insert(&chain_a, candidate.commitments.clone()); + >::insert(&chain_a, candidate.commitments.clone()); let backed = block_on(back_candidate( candidate, @@ -2009,7 +2021,7 @@ mod tests { Err(Error::::CandidateScheduledBeforeParaFree.into()), ); - ::remove(&chain_a); + >::remove(&chain_a); } // interfering code upgrade - reject @@ -2289,7 +2301,7 @@ mod tests { }) ); assert_eq!( - ::get(&chain_a), + >::get(&chain_a), Some(candidate_a.commitments), ); @@ -2307,7 +2319,7 @@ mod tests { }) ); assert_eq!( - ::get(&chain_b), + >::get(&chain_b), Some(candidate_b.commitments), ); @@ -2325,7 +2337,7 @@ mod tests { }) ); assert_eq!( - ::get(&thread_a), + >::get(&thread_a), Some(candidate_c.commitments), ); }); @@ -2423,7 +2435,7 @@ mod tests { }) ); assert_eq!( - ::get(&chain_a), + >::get(&chain_a), Some(candidate_a.commitments), ); }); @@ -2498,7 +2510,7 @@ mod tests { backers: default_backing_bitfield(), backing_group: GroupIndex::from(0), }); - ::insert(&chain_a, candidate.commitments.clone()); + >::insert(&chain_a, candidate.commitments.clone()); >::insert(&chain_b, CandidatePendingAvailability { core: CoreIndex::from(1), @@ -2510,7 +2522,7 @@ mod tests { backers: default_backing_bitfield(), backing_group: GroupIndex::from(1), }); - ::insert(&chain_b, candidate.commitments); + >::insert(&chain_b, candidate.commitments); run_to_block(11, |_| None); @@ -2522,8 +2534,8 @@ mod tests { assert!(>::get(&chain_a).is_some()); assert!(>::get(&chain_b).is_some()); - assert!(::get(&chain_a).is_some()); - assert!(::get(&chain_b).is_some()); + assert!(>::get(&chain_a).is_some()); + assert!(>::get(&chain_b).is_some()); run_to_block(12, |n| match n { 12 => Some(SessionChangeNotification { @@ -2545,12 +2557,12 @@ mod tests { assert!(>::get(&chain_a).is_none()); assert!(>::get(&chain_b).is_none()); - assert!(::get(&chain_a).is_none()); - assert!(::get(&chain_b).is_none()); + assert!(>::get(&chain_a).is_none()); + assert!(>::get(&chain_b).is_none()); assert!(>::iter().collect::>().is_empty()); assert!(>::iter().collect::>().is_empty()); - assert!(::iter().collect::>().is_empty()); + assert!(>::iter().collect::>().is_empty()); }); } } diff --git a/runtime/parachains/src/initializer.rs b/runtime/parachains/src/initializer.rs index 5bbc56c21455..845fe98bfb0b 100644 --- a/runtime/parachains/src/initializer.rs +++ b/runtime/parachains/src/initializer.rs @@ -135,7 +135,7 @@ pub mod pallet { shared::Module::::initializer_initialize(now) + paras::Pallet::::initializer_initialize(now) + scheduler::Module::::initializer_initialize(now) + - inclusion::Module::::initializer_initialize(now) + + inclusion::Pallet::::initializer_initialize(now) + session_info::Module::::initializer_initialize(now) + dmp::Module::::initializer_initialize(now) + ump::Module::::initializer_initialize(now) + @@ -152,7 +152,7 @@ pub mod pallet { ump::Module::::initializer_finalize(); dmp::Module::::initializer_finalize(); session_info::Module::::initializer_finalize(); - inclusion::Module::::initializer_finalize(); + inclusion::Pallet::::initializer_finalize(); scheduler::Module::::initializer_finalize(); paras::Pallet::::initializer_finalize(); shared::Module::::initializer_finalize(); @@ -232,7 +232,7 @@ impl Pallet { let outgoing_paras = paras::Pallet::::initializer_on_new_session(¬ification); scheduler::Module::::initializer_on_new_session(¬ification); - inclusion::Module::::initializer_on_new_session(¬ification); + inclusion::Pallet::::initializer_on_new_session(¬ification); session_info::Module::::initializer_on_new_session(¬ification); dmp::Module::::initializer_on_new_session(¬ification, &outgoing_paras); ump::Module::::initializer_on_new_session(¬ification, &outgoing_paras); diff --git a/runtime/parachains/src/paras_inherent.rs b/runtime/parachains/src/paras_inherent.rs index c96495d639e3..2d7bf288f69f 100644 --- a/runtime/parachains/src/paras_inherent.rs +++ b/runtime/parachains/src/paras_inherent.rs @@ -115,7 +115,7 @@ decl_module! { // Process new availability bitfields, yielding any availability cores whose // work has now concluded. let expected_bits = >::availability_cores().len(); - let freed_concluded = >::process_bitfields( + let freed_concluded = >::process_bitfields( expected_bits, signed_bitfields, >::core_para, @@ -124,7 +124,7 @@ decl_module! { // Handle timeouts for any availability core work. let availability_pred = >::availability_timeout_predicate(); let freed_timeout = if let Some(pred) = availability_pred { - >::collect_pending(pred) + >::collect_pending(pred) } else { Vec::new() }; @@ -144,7 +144,7 @@ decl_module! { // Process backed candidates according to scheduled cores. let parent_storage_root = parent_header.state_root().clone(); - let occupied = >::process_candidates( + let occupied = >::process_candidates( parent_storage_root, backed_candidates, >::scheduled(), diff --git a/runtime/parachains/src/runtime_api_impl/v1.rs b/runtime/parachains/src/runtime_api_impl/v1.rs index d51e980c933a..67d42e37cef5 100644 --- a/runtime/parachains/src/runtime_api_impl/v1.rs +++ b/runtime/parachains/src/runtime_api_impl/v1.rs @@ -100,7 +100,7 @@ pub fn availability_cores() -> Vec { let para_id = parachains[i]; - let pending_availability = > + let pending_availability = > ::pending_availability(para_id) .expect("Occupied core always has pending availability; qed"); @@ -128,7 +128,7 @@ pub fn availability_cores() -> Vec { let para_id = p.claim.0; - let pending_availability = > + let pending_availability = > ::pending_availability(para_id) .expect("Occupied core always has pending availability; qed"); @@ -180,14 +180,14 @@ fn with_assumption( { match assumption { OccupiedCoreAssumption::Included => { - >::force_enact(para_id); + >::force_enact(para_id); build() } OccupiedCoreAssumption::TimedOut => { build() } OccupiedCoreAssumption::Free => { - if >::pending_availability(para_id).is_some() { + if >::pending_availability(para_id).is_some() { None } else { build() @@ -219,7 +219,7 @@ pub fn check_validation_outputs( para_id: ParaId, outputs: primitives::v1::CandidateCommitments, ) -> bool { - >::check_validation_outputs_for_runtime_api(para_id, outputs) + >::check_validation_outputs_for_runtime_api(para_id, outputs) } /// Implementation for the `session_index_for_child` function of the runtime API. @@ -278,7 +278,7 @@ pub fn validation_code( pub fn candidate_pending_availability(para_id: ParaId) -> Option> { - >::candidate_pending_availability(para_id) + >::candidate_pending_availability(para_id) } /// Implementation for the `candidate_events` function of the runtime API. @@ -300,6 +300,8 @@ where => CandidateEvent::CandidateIncluded(c, h, core, group), RawEvent::::CandidateTimedOut(c, h, core) => CandidateEvent::CandidateTimedOut(c, h, core), + RawEvent::::__Ignore(_, _) + => unreachable!("__Ignore cannot be used"), }) .collect() } From db6ae51e3d54039599e1cb7dec72686a59591ad3 Mon Sep 17 00:00:00 2001 From: ferrell-code Date: Thu, 8 Jul 2021 00:43:16 -0400 Subject: [PATCH 2/7] migrate runtimes --- runtime/kusama/src/lib.rs | 4 +-- runtime/parachains/src/inclusion.rs | 54 ++++++++++++++--------------- runtime/parachains/src/mock.rs | 2 +- runtime/rococo/src/lib.rs | 2 +- runtime/test-runtime/src/lib.rs | 2 +- runtime/westend/src/lib.rs | 4 +-- 6 files changed, 34 insertions(+), 34 deletions(-) diff --git a/runtime/kusama/src/lib.rs b/runtime/kusama/src/lib.rs index 32e8691faac4..bb0551190337 100644 --- a/runtime/kusama/src/lib.rs +++ b/runtime/kusama/src/lib.rs @@ -1481,7 +1481,7 @@ construct_runtime! { ParachainsOrigin: parachains_origin::{Pallet, Origin} = 50, ParachainsConfiguration: parachains_configuration::{Pallet, Call, Storage, Config} = 51, ParasShared: parachains_shared::{Pallet, Call, Storage} = 52, - ParasInclusion: parachains_inclusion::{Pallet, Call, Storage, Event} = 53, + ParaInclusion: parachains_inclusion::{Pallet, Call, Storage, Event} = 53, ParasInherent: parachains_paras_inherent::{Pallet, Call, Storage, Inherent} = 54, ParasScheduler: parachains_scheduler::{Pallet, Call, Storage} = 55, Paras: parachains_paras::{Pallet, Call, Storage, Event, Config} = 56, @@ -1646,7 +1646,7 @@ sp_api::impl_runtime_apis! { fn candidate_events() -> Vec> { parachains_runtime_api_impl::candidate_events::(|ev| { match ev { - Event::ParasInclusion(ev) => { + Event::ParaInclusion(ev) => { Some(ev) } _ => None, diff --git a/runtime/parachains/src/inclusion.rs b/runtime/parachains/src/inclusion.rs index b7bccd072d24..73b2c2d25320 100644 --- a/runtime/parachains/src/inclusion.rs +++ b/runtime/parachains/src/inclusion.rs @@ -931,7 +931,7 @@ mod tests { use keyring::Sr25519Keyring; use sc_keystore::LocalKeystore; use crate::mock::{ - new_test_ext, Configuration, Paras, System, Inclusion, + new_test_ext, Configuration, Paras, System, ParaInclusion, MockGenesisConfig, Test, Shared, }; use crate::initializer::SessionChangeNotification; @@ -1059,7 +1059,7 @@ mod tests { while System::block_number() < to { let b = System::block_number(); - Inclusion::initializer_finalize(); + ParaInclusion::initializer_finalize(); Paras::initializer_finalize(); Shared::initializer_finalize(); @@ -1071,7 +1071,7 @@ mod tests { notification.validators.clone(), ); Paras::initializer_on_new_session(¬ification); - Inclusion::initializer_on_new_session(¬ification); + ParaInclusion::initializer_on_new_session(¬ification); } System::on_finalize(b); @@ -1081,7 +1081,7 @@ mod tests { Shared::initializer_initialize(b + 1); Paras::initializer_initialize(b + 1); - Inclusion::initializer_initialize(b + 1); + ParaInclusion::initializer_initialize(b + 1); } } @@ -1215,7 +1215,7 @@ mod tests { assert!(>::get(&chain_a).is_some()); assert!(>::get(&chain_b).is_some()); - Inclusion::collect_pending(|core, _since| core == CoreIndex::from(0)); + ParaInclusion::collect_pending(|core, _since| core == CoreIndex::from(0)); assert!(>::get(&chain_a).is_none()); assert!(>::get(&chain_b).is_some()); @@ -1273,7 +1273,7 @@ mod tests { &signing_context, )); - assert!(Inclusion::process_bitfields( + assert!(ParaInclusion::process_bitfields( expected_bits(), vec![signed.into()], &core_lookup, @@ -1291,7 +1291,7 @@ mod tests { &signing_context, )); - assert!(Inclusion::process_bitfields( + assert!(ParaInclusion::process_bitfields( expected_bits() + 1, vec![signed.into()], &core_lookup, @@ -1310,7 +1310,7 @@ mod tests { &signing_context, )).into(); - assert!(Inclusion::process_bitfields( + assert!(ParaInclusion::process_bitfields( expected_bits(), vec![signed.clone(), signed], &core_lookup, @@ -1336,7 +1336,7 @@ mod tests { &signing_context, )).into(); - assert!(Inclusion::process_bitfields( + assert!(ParaInclusion::process_bitfields( expected_bits(), vec![signed_1, signed_0], &core_lookup, @@ -1355,7 +1355,7 @@ mod tests { &signing_context, )); - assert!(Inclusion::process_bitfields( + assert!(ParaInclusion::process_bitfields( expected_bits(), vec![signed.into()], &core_lookup, @@ -1373,7 +1373,7 @@ mod tests { &signing_context, )); - assert!(Inclusion::process_bitfields( + assert!(ParaInclusion::process_bitfields( expected_bits(), vec![signed.into()], &core_lookup, @@ -1408,7 +1408,7 @@ mod tests { &signing_context, )); - assert!(Inclusion::process_bitfields( + assert!(ParaInclusion::process_bitfields( expected_bits(), vec![signed.into()], &core_lookup, @@ -1447,7 +1447,7 @@ mod tests { // no core is freed assert_eq!( - Inclusion::process_bitfields( + ParaInclusion::process_bitfields( expected_bits(), vec![signed.into()], &core_lookup, @@ -1571,7 +1571,7 @@ mod tests { )).into()) }).collect(); - assert!(Inclusion::process_bitfields( + assert!(ParaInclusion::process_bitfields( expected_bits(), signed_bitfields, &core_lookup, @@ -1709,7 +1709,7 @@ mod tests { )); assert_eq!( - Inclusion::process_candidates( + ParaInclusion::process_candidates( Default::default(), vec![backed], vec![chain_b_assignment.clone()], @@ -1768,7 +1768,7 @@ mod tests { // out-of-order manifests as unscheduled. assert_eq!( - Inclusion::process_candidates( + ParaInclusion::process_candidates( Default::default(), vec![backed_b, backed_a], vec![chain_a_assignment.clone(), chain_b_assignment.clone()], @@ -1803,7 +1803,7 @@ mod tests { )); assert_eq!( - Inclusion::process_candidates( + ParaInclusion::process_candidates( Default::default(), vec![backed], vec![chain_a_assignment.clone()], @@ -1840,7 +1840,7 @@ mod tests { )); assert_eq!( - Inclusion::process_candidates( + ParaInclusion::process_candidates( Default::default(), vec![backed], vec![chain_a_assignment.clone()], @@ -1877,7 +1877,7 @@ mod tests { )); assert_eq!( - Inclusion::process_candidates( + ParaInclusion::process_candidates( Default::default(), vec![backed], vec![ @@ -1921,7 +1921,7 @@ mod tests { )); assert_eq!( - Inclusion::process_candidates( + ParaInclusion::process_candidates( Default::default(), vec![backed], vec![thread_a_assignment.clone()], @@ -1970,7 +1970,7 @@ mod tests { >::insert(&chain_a, candidate.commitments); assert_eq!( - Inclusion::process_candidates( + ParaInclusion::process_candidates( Default::default(), vec![backed], vec![chain_a_assignment.clone()], @@ -2012,7 +2012,7 @@ mod tests { )); assert_eq!( - Inclusion::process_candidates( + ParaInclusion::process_candidates( Default::default(), vec![backed], vec![chain_a_assignment.clone()], @@ -2059,7 +2059,7 @@ mod tests { assert_eq!(Paras::last_code_upgrade(chain_a, true), Some(10)); assert_eq!( - Inclusion::process_candidates( + ParaInclusion::process_candidates( Default::default(), vec![backed], vec![chain_a_assignment.clone()], @@ -2095,7 +2095,7 @@ mod tests { )); assert_eq!( - Inclusion::process_candidates( + ParaInclusion::process_candidates( Default::default(), vec![backed], vec![chain_a_assignment.clone()], @@ -2132,7 +2132,7 @@ mod tests { )); assert_eq!( - Inclusion::process_candidates( + ParaInclusion::process_candidates( Default::default(), vec![backed], vec![chain_a_assignment.clone()], @@ -2274,7 +2274,7 @@ mod tests { BackingKind::Threshold, )); - let occupied_cores = Inclusion::process_candidates( + let occupied_cores = ParaInclusion::process_candidates( Default::default(), vec![backed_a, backed_b, backed_c], vec![ @@ -2410,7 +2410,7 @@ mod tests { BackingKind::Threshold, )); - let occupied_cores = Inclusion::process_candidates( + let occupied_cores = ParaInclusion::process_candidates( Default::default(), vec![backed_a], vec![ diff --git a/runtime/parachains/src/mock.rs b/runtime/parachains/src/mock.rs index ccf25104ee0e..f00e79dfee98 100644 --- a/runtime/parachains/src/mock.rs +++ b/runtime/parachains/src/mock.rs @@ -46,7 +46,7 @@ frame_support::construct_runtime!( Paras: paras::{Pallet, Origin, Call, Storage, Event, Config}, Configuration: configuration::{Pallet, Call, Storage, Config}, Shared: shared::{Pallet, Call, Storage}, - Inclusion: inclusion::{Pallet, Call, Storage, Event}, + ParaInclusion: inclusion::{Pallet, Call, Storage, Event}, Scheduler: scheduler::{Pallet, Call, Storage}, Initializer: initializer::{Pallet, Call, Storage}, Dmp: dmp::{Pallet, Call, Storage}, diff --git a/runtime/rococo/src/lib.rs b/runtime/rococo/src/lib.rs index a68123efea23..994bbb553653 100644 --- a/runtime/rococo/src/lib.rs +++ b/runtime/rococo/src/lib.rs @@ -214,7 +214,7 @@ construct_runtime! { ParachainsOrigin: parachains_origin::{Pallet, Origin}, ParachainsConfiguration: parachains_configuration::{Pallet, Call, Storage, Config}, Shared: parachains_shared::{Pallet, Call, Storage}, - Inclusion: parachains_inclusion::{Pallet, Call, Storage, Event}, + ParaInclusion: parachains_inclusion::{Pallet, Call, Storage, Event}, ParasInherent: parachains_paras_inherent::{Pallet, Call, Storage, Inherent}, Scheduler: parachains_scheduler::{Pallet, Call, Storage}, Paras: parachains_paras::{Pallet, Call, Storage, Event, Config}, diff --git a/runtime/test-runtime/src/lib.rs b/runtime/test-runtime/src/lib.rs index a1d9a76cffc5..78f168df2037 100644 --- a/runtime/test-runtime/src/lib.rs +++ b/runtime/test-runtime/src/lib.rs @@ -528,7 +528,7 @@ construct_runtime! { // Parachains runtime modules ParachainsConfiguration: parachains_configuration::{Pallet, Call, Storage, Config}, - Inclusion: parachains_inclusion::{Pallet, Call, Storage, Event}, + ParaInclusion: parachains_inclusion::{Pallet, Call, Storage, Event}, ParasInherent: parachains_paras_inherent::{Pallet, Call, Storage, Inherent}, Initializer: parachains_initializer::{Pallet, Call, Storage}, Paras: parachains_paras::{Pallet, Call, Storage, Origin, Event}, diff --git a/runtime/westend/src/lib.rs b/runtime/westend/src/lib.rs index 9c1f203680b2..cca17dca8213 100644 --- a/runtime/westend/src/lib.rs +++ b/runtime/westend/src/lib.rs @@ -1072,7 +1072,7 @@ construct_runtime! { ParachainsOrigin: parachains_origin::{Pallet, Origin} = 41, ParachainsConfiguration: parachains_configuration::{Pallet, Call, Storage, Config} = 42, ParasShared: parachains_shared::{Pallet, Call, Storage} = 43, - ParasInclusion: parachains_inclusion::{Pallet, Call, Storage, Event} = 44, + ParaInclusion: parachains_inclusion::{Pallet, Call, Storage, Event} = 44, ParasInherent: parachains_paras_inherent::{Pallet, Call, Storage, Inherent} = 45, ParasScheduler: parachains_scheduler::{Pallet, Call, Storage} = 46, Paras: parachains_paras::{Pallet, Call, Storage, Event, Config} = 47, @@ -1238,7 +1238,7 @@ sp_api::impl_runtime_apis! { fn candidate_events() -> Vec> { parachains_runtime_api_impl::candidate_events::(|ev| { match ev { - Event::ParasInclusion(ev) => { + Event::ParaInclusion(ev) => { Some(ev) } _ => None, From 8c77f2b25cd463bd00ab755926f3eb36d4609de5 Mon Sep 17 00:00:00 2001 From: ferrell-code Date: Thu, 8 Jul 2021 00:57:00 -0400 Subject: [PATCH 3/7] migrate more --- runtime/rococo/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/runtime/rococo/src/lib.rs b/runtime/rococo/src/lib.rs index 994bbb553653..3289c5357078 100644 --- a/runtime/rococo/src/lib.rs +++ b/runtime/rococo/src/lib.rs @@ -1226,7 +1226,7 @@ sp_api::impl_runtime_apis! { fn candidate_events() -> Vec> { runtime_api_impl::candidate_events::(|ev| { match ev { - Event::Inclusion(ev) => { + Event::ParaInclusion(ev) => { Some(ev) } _ => None, From 82ea1485e4643a3b739d72f19862629e148073f0 Mon Sep 17 00:00:00 2001 From: ferrell-code Date: Thu, 8 Jul 2021 00:59:39 -0400 Subject: [PATCH 4/7] comments --- runtime/parachains/src/inclusion.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/runtime/parachains/src/inclusion.rs b/runtime/parachains/src/inclusion.rs index 73b2c2d25320..d2fe985371ec 100644 --- a/runtime/parachains/src/inclusion.rs +++ b/runtime/parachains/src/inclusion.rs @@ -14,7 +14,7 @@ // You should have received a copy of the GNU General Public License // along with Polkadot. If not, see . -//! The inclusion module is responsible for inclusion and availability of scheduled parachains +//! The inclusion pallet is responsible for inclusion and availability of scheduled parachains //! and parathreads. //! //! It is responsible for carrying candidates from being backable to being backed, and then from backed @@ -387,7 +387,7 @@ impl Pallet { } } - // TODO: pass available candidates onwards to validity module once implemented. + // TODO: pass available candidates onwards to validity pallet once implemented. // https://github.com/paritytech/polkadot/issues/1251 Ok(freed_cores) From c79ac4be681d351cecbf01b256b3e9dbeee520b4 Mon Sep 17 00:00:00 2001 From: ferrell-code Date: Fri, 16 Jul 2021 01:19:04 -0400 Subject: [PATCH 5/7] docs --- runtime/parachains/src/inclusion.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/runtime/parachains/src/inclusion.rs b/runtime/parachains/src/inclusion.rs index 68f581b6ca0b..61f8e4d74d36 100644 --- a/runtime/parachains/src/inclusion.rs +++ b/runtime/parachains/src/inclusion.rs @@ -139,7 +139,6 @@ pub mod pallet { CandidateIncluded(CandidateReceipt, HeadData, CoreIndex, GroupIndex), /// A candidate timed out. `[candidate, head_data]` CandidateTimedOut(CandidateReceipt, HeadData, CoreIndex), - /// The commitments of candidates pending availability, by `ParaId`. } #[pallet::error] From c6a7aaf6f2fee68bee0afae603351e603935b410 Mon Sep 17 00:00:00 2001 From: ferrell-code Date: Tue, 20 Jul 2021 18:43:54 -0400 Subject: [PATCH 6/7] cleanup --- runtime/parachains/src/inclusion.rs | 2 +- runtime/parachains/src/paras_inherent.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/runtime/parachains/src/inclusion.rs b/runtime/parachains/src/inclusion.rs index 9a29faaeb115..f09cc4807dda 100644 --- a/runtime/parachains/src/inclusion.rs +++ b/runtime/parachains/src/inclusion.rs @@ -780,7 +780,7 @@ impl Pallet { for para_id in cleaned_up_ids { let _ = >::take(¶_id); - let _ = ::take(¶_id); + let _ = >::take(¶_id); } cleaned_up_cores diff --git a/runtime/parachains/src/paras_inherent.rs b/runtime/parachains/src/paras_inherent.rs index 37b6a04cf102..e7d53f00cb0a 100644 --- a/runtime/parachains/src/paras_inherent.rs +++ b/runtime/parachains/src/paras_inherent.rs @@ -137,7 +137,7 @@ decl_module! { .map(|(_, c)| *c) .collect(); - >::collect_disputed(current_session_disputes) + >::collect_disputed(current_session_disputes) .into_iter() .map(|core| (core, FreedReason::Concluded)) .collect() From 0cb473b1bcafa273a80cfebb3c52622cb13d00f4 Mon Sep 17 00:00:00 2001 From: Keith Yeung Date: Wed, 21 Jul 2021 16:51:24 -0700 Subject: [PATCH 7/7] Adjust visibility on storage items --- runtime/parachains/src/inclusion.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/runtime/parachains/src/inclusion.rs b/runtime/parachains/src/inclusion.rs index f09cc4807dda..1a626123cccb 100644 --- a/runtime/parachains/src/inclusion.rs +++ b/runtime/parachains/src/inclusion.rs @@ -196,7 +196,7 @@ pub mod pallet { /// The latest bitfield for each validator, referred to by their index in the validator set. #[pallet::storage] - pub type AvailabilityBitfields = StorageMap< + pub(crate) type AvailabilityBitfields = StorageMap< _, Twox64Concat, ValidatorIndex, @@ -205,7 +205,7 @@ pub mod pallet { /// Candidates pending availability by `ParaId`. #[pallet::storage] - pub type PendingAvailability = StorageMap< + pub(crate) type PendingAvailability = StorageMap< _, Twox64Concat, ParaId, @@ -214,7 +214,7 @@ pub mod pallet { /// The commitments of candidates pending availability, by `ParaId`. #[pallet::storage] - pub type PendingAvailabilityCommitments = StorageMap< + pub(crate) type PendingAvailabilityCommitments = StorageMap< _, Twox64Concat, ParaId,