mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-05-30 12:51:02 +00:00
Inclusion Module (#1242)
* add availability bitfield types to primitives * begin inclusion module * use GitHub issue link for limitation * fix some compiler errors * integrate validators into initializer * add generic signing context * make signing-context more generic * fix issues with inclusion module * add TODO * guide: add validators and session index to inclusion * guide: add session index to change notification * implement session change logic * add BackedCandidate type * guide: refine inclusion pipeline * guide: rename group_on to group_validators * guide: add check about collator for parathread * guide: add last_code_upgrade to paras and use in inclusion * implement Paras::last_code_upgrade * implement most checks in process_candidates * make candidate receipt structs more generic * make BackedCandidate struct more generic * use hash param, not block number * check that candidate is in context of the parent block * include inclusion module in initializer * implement enact-candidate * check that only occupied cores have bits set * finish implementing bitfield processing * restructure consistency checks on candidates * make some more primitives generic * signature checking logic for backed candidates * finish implementing process_candidates * implement collect_pending * add some trait implementations to primitives * implement InclusionInherent and squash warnings * test bitfield signing checks * rename parachain head to para_head * fix note_new_head bug in paras * test bitfield enactment in inclusion * helpers for candidate checks * add test for most candidate checks * add test for backing setting storage * test session change logic * remove extraneous type parameter * remove some allow(unused)s * extract threshold computation to const fn * remove some more allow(unused)s * improve doc * add debug assertion * fix primitive test compilation * tag unanimous variant as unused
This commit is contained in:
committed by
GitHub
parent
7accc6e499
commit
879892d3f9
@@ -174,7 +174,7 @@ decl_storage! {
|
||||
/// All parathreads.
|
||||
Parathreads: map hasher(twox_64_concat) ParaId => Option<()>;
|
||||
/// The head-data of every registered para.
|
||||
Heads get(fn parachain_head): map hasher(twox_64_concat) ParaId => Option<HeadData>;
|
||||
Heads get(fn para_head): map hasher(twox_64_concat) ParaId => Option<HeadData>;
|
||||
/// The validation code of every live para.
|
||||
CurrentCode get(fn current_code): map hasher(twox_64_concat) ParaId => Option<ValidationCode>;
|
||||
/// Actual past code, indicated by the para id as well as the block number at which it became outdated.
|
||||
@@ -368,7 +368,7 @@ impl<T: Trait> Module<T> {
|
||||
<Self as Store>::PastCode::remove(&(para_id, pruned_repl_at));
|
||||
}
|
||||
|
||||
meta.most_recent_change().is_none() && Self::parachain_head(¶_id).is_none()
|
||||
meta.most_recent_change().is_none() && Self::para_head(¶_id).is_none()
|
||||
});
|
||||
|
||||
// This parachain has been removed and now the vestigial code
|
||||
@@ -428,7 +428,6 @@ impl<T: Trait> Module<T> {
|
||||
/// with number >= `expected_at`
|
||||
///
|
||||
/// If there is already a scheduled code upgrade for the para, this is a no-op.
|
||||
#[allow(unused)]
|
||||
pub(crate) fn schedule_code_upgrade(
|
||||
id: ParaId,
|
||||
new_code: ValidationCode,
|
||||
@@ -448,15 +447,14 @@ impl<T: Trait> Module<T> {
|
||||
/// Note that a para has progressed to a new head, where the new head was executed in the context
|
||||
/// of a relay-chain block with given number. This will apply pending code upgrades based
|
||||
/// on the block number provided.
|
||||
#[allow(unused)]
|
||||
pub(crate) fn note_new_head(
|
||||
id: ParaId,
|
||||
new_head: HeadData,
|
||||
execution_context: T::BlockNumber,
|
||||
) -> Weight {
|
||||
if let Some(expected_at) = <Self as Store>::FutureCodeUpgrades::get(&id) {
|
||||
Heads::insert(&id, new_head);
|
||||
Heads::insert(&id, new_head);
|
||||
|
||||
if let Some(expected_at) = <Self as Store>::FutureCodeUpgrades::get(&id) {
|
||||
if expected_at <= execution_context {
|
||||
<Self as Store>::FutureCodeUpgrades::remove(&id);
|
||||
|
||||
@@ -481,7 +479,7 @@ impl<T: Trait> Module<T> {
|
||||
T::DbWeight::get().reads_writes(1, 1 + 0)
|
||||
}
|
||||
} else {
|
||||
T::DbWeight::get().reads_writes(1, 0)
|
||||
T::DbWeight::get().reads_writes(1, 1)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -526,6 +524,18 @@ impl<T: Trait> Module<T> {
|
||||
pub(crate) fn is_parathread(id: ParaId) -> bool {
|
||||
Parathreads::get(&id).is_some()
|
||||
}
|
||||
|
||||
/// The block number of the last scheduled upgrade of the requested para. Includes future upgrades
|
||||
/// if the flag is set. This is the `expected_at` number, not the `activated_at` number.
|
||||
pub(crate) fn last_code_upgrade(id: ParaId, include_future: bool) -> Option<T::BlockNumber> {
|
||||
if include_future {
|
||||
if let Some(at) = Self::future_code_upgrade_at(id) {
|
||||
return Some(at);
|
||||
}
|
||||
}
|
||||
|
||||
Self::past_code_meta(&id).most_recent_change()
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
@@ -683,6 +693,40 @@ mod tests {
|
||||
});
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn note_new_head_sets_head() {
|
||||
let acceptance_period = 10;
|
||||
let paras = vec![
|
||||
(0u32.into(), ParaGenesisArgs {
|
||||
parachain: true,
|
||||
genesis_head: Default::default(),
|
||||
validation_code: Default::default(),
|
||||
}),
|
||||
];
|
||||
|
||||
let genesis_config = MockGenesisConfig {
|
||||
paras: GenesisConfig { paras, ..Default::default() },
|
||||
configuration: crate::configuration::GenesisConfig {
|
||||
config: HostConfiguration {
|
||||
acceptance_period,
|
||||
..Default::default()
|
||||
},
|
||||
..Default::default()
|
||||
},
|
||||
..Default::default()
|
||||
};
|
||||
|
||||
new_test_ext(genesis_config).execute_with(|| {
|
||||
let id_a = ParaId::from(0u32);
|
||||
|
||||
assert_eq!(Paras::para_head(&id_a), Some(Default::default()));
|
||||
|
||||
Paras::note_new_head(id_a, vec![1, 2, 3].into(), 0);
|
||||
|
||||
assert_eq!(Paras::para_head(&id_a), Some(vec![1, 2, 3].into()));
|
||||
});
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn note_past_code_sets_up_pruning_correctly() {
|
||||
let acceptance_period = 10;
|
||||
|
||||
Reference in New Issue
Block a user