-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Prospective Parachains: track candidate parent nodes in a fragment tree #5824
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -33,9 +33,9 @@ use futures::{channel::oneshot, prelude::*}; | |
|
||
use polkadot_node_subsystem::{ | ||
messages::{ | ||
ChainApiMessage, FragmentTreeMembership, HypotheticalDepthRequest, | ||
ProspectiveParachainsMessage, ProspectiveValidationDataRequest, RuntimeApiMessage, | ||
RuntimeApiRequest, | ||
ChainApiMessage, CollatorProtocolMessage, FragmentTreeMembership, HypotheticalDepthRequest, | ||
ProspectiveCandidateParentState, ProspectiveParachainsMessage, | ||
ProspectiveValidationDataRequest, RuntimeApiMessage, RuntimeApiRequest, | ||
}, | ||
overseer, ActiveLeavesUpdate, FromOrchestra, OverseerSignal, SpawnedSubsystem, SubsystemError, | ||
}; | ||
|
@@ -326,7 +326,7 @@ async fn handle_candidate_seconded<Context>( | |
|
||
#[overseer::contextbounds(ProspectiveParachains, prefix = self::overseer)] | ||
async fn handle_candidate_backed<Context>( | ||
_ctx: &mut Context, | ||
ctx: &mut Context, | ||
view: &mut View, | ||
para: ParaId, | ||
candidate_hash: CandidateHash, | ||
|
@@ -368,6 +368,9 @@ async fn handle_candidate_backed<Context>( | |
} | ||
|
||
storage.mark_backed(&candidate_hash); | ||
|
||
ctx.send_message(CollatorProtocolMessage::Backed(para, candidate_hash)).await; | ||
|
||
Ok(()) | ||
} | ||
|
||
|
@@ -429,22 +432,35 @@ fn answer_get_backable_candidate( | |
fn answer_hypothetical_depths_request( | ||
view: &View, | ||
request: HypotheticalDepthRequest, | ||
tx: oneshot::Sender<Vec<usize>>, | ||
tx: oneshot::Sender<Vec<(usize, ProspectiveCandidateParentState)>>, | ||
) { | ||
match view | ||
let fragment_tree = view | ||
.active_leaves | ||
.get(&request.fragment_tree_relay_parent) | ||
.and_then(|l| l.fragment_trees.get(&request.candidate_para)) | ||
{ | ||
Some(fragment_tree) => { | ||
let depths = fragment_tree.hypothetical_depths( | ||
request.candidate_hash, | ||
request.parent_head_data_hash, | ||
request.candidate_relay_parent, | ||
); | ||
.and_then(|l| l.fragment_trees.get(&request.candidate_para)); | ||
let candidate_storage = view.candidate_storage.get(&request.candidate_para); | ||
match (fragment_tree, candidate_storage) { | ||
(Some(fragment_tree), Some(candidate_storage)) => { | ||
let depths = fragment_tree | ||
.hypothetical_depths( | ||
request.candidate_hash, | ||
request.parent_head_data_hash, | ||
request.candidate_relay_parent, | ||
) | ||
.into_iter() | ||
.map(|(depth, parent)| { | ||
let parent_status = if depth == 0 || candidate_storage.is_backed(&parent) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
ProspectiveCandidateParentState::Backed | ||
} else { | ||
ProspectiveCandidateParentState::Seconded(parent) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This doesn't make sense, conceptually. Candidates don't refer to their parent by hash, therefore there can be multiple parents. If this is introduced, it should be a Vec, but I also don't think this makes sense to include in the first place. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It refers to some particular depth, not membership in general |
||
}; | ||
(depth, parent_status) | ||
}) | ||
.collect(); | ||
|
||
let _ = tx.send(depths); | ||
}, | ||
None => { | ||
_ => { | ||
let _ = tx.send(Vec::new()); | ||
}, | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
At this point it should be guaranteed by collator protocol that at least 1 depth corresponds to backed parent, and we do occupy the rest too. This seems to be correct