Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

Make sure that Parachain heads are updated #945

Merged
merged 1 commit into from
Apr 1, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion runtime/common/src/parachains.rs
Original file line number Diff line number Diff line change
Expand Up @@ -640,6 +640,7 @@ impl<T: Trait> Module<T> {

for head in heads.iter() {
let id = head.parachain_index();
Heads::insert(id, &head.candidate.head_data.0);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A somewhat random place to insert this. Should probably be in the check_candidates loop instead.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just added it back to the position where it was before being removed 🤷‍♀️

d9b4fc4#diff-e21f8096708b22fcdbd66ebc74f0821aL457

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like Heads should be modified only in case check_candidates succeeded; if that insert was moved in check_candidates loop over all candidates we may end up with a partially modified Heads ? Or add another loop in the end of check_candidates right before returning Ok.


// Queue up upwards messages (from parachains to relay chain).
Self::queue_upward_messages(
Expand Down Expand Up @@ -1577,10 +1578,13 @@ mod tests {

// creates a template candidate which pins to correct relay-chain state.
fn raw_candidate(para_id: ParaId) -> CandidateReceipt {
let mut head_data = Parachains::parachain_head(&para_id).unwrap();
head_data.extend(para_id.encode());

CandidateReceipt {
parachain_index: para_id,
relay_parent: System::parent_hash(),
head_data: Default::default(),
head_data: HeadData(head_data),
collator: Default::default(),
signature: Default::default(),
pov_block_hash: Default::default(),
Expand Down Expand Up @@ -2129,6 +2133,9 @@ mod tests {
set_heads(vec![candidate_a.clone(), candidate_b.clone()]),
Origin::NONE,
));

assert_eq!(Heads::get(&ParaId::from(0)).map(HeadData), Some(candidate_a.candidate.head_data));
assert_eq!(Heads::get(&ParaId::from(1)).map(HeadData), Some(candidate_b.candidate.head_data));
});
}

Expand Down