-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Prospective Parachains: track candidate parent nodes in a fragment tree #5824
Prospective Parachains: track candidate parent nodes in a fragment tree #5824
Conversation
@@ -1195,7 +1197,7 @@ async fn seconding_sanity_check<Context>( | |||
return SecondingAllowed::No | |||
}, | |||
Ok((depths, head, leaf_state)) => { | |||
for depth in &depths { | |||
for (depth, _) in &depths { |
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
) | ||
.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 comment
The reason will be displayed to describe this comment to others. Learn more.
is_backed
would return false
for candidate not present in storage, but we do expect fragment trees and candidate storage to be updated correspondingly, thus this should never happen
@rphmeier while this PR makes it possible to implement the proposal from the collator protocol issue, For now, to finish #5740 we could go with a temporary "accept anything with an non-empty depth in a fragment tree" |
I don't understand the logical step from this requirement to tracking candidate parent hashes of nodes in the fragment tree. That is, if we get a collation announcement from a peer, we should expect that there is no such node in the fragment tree (it can exist, but only if one of our group's other members has seconded the candidate and we've gotten it via backing). What we actually need to check in order to enforce this condition is that there exists a node where |
Tracking parents is indeed unnecessary |
let parent_status = if depth == 0 || candidate_storage.is_backed(&parent) { | ||
ProspectiveCandidateParentState::Backed | ||
} else { | ||
ProspectiveCandidateParentState::Seconded(parent) |
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.
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 comment
The reason will be displayed to describe this comment to others. Learn more.
It refers to some particular depth, not membership in general
There's already logic for pruning advertisements (quoting from #5054 ):
Therefore, if we stick to what has already been described in the github issue description, we already limit the amount of incoming announcements based on the amount of collator peers we accept at any given time and we prune when those announcements leave the implicit view. So this PR seems totally unnecessary. |
This PR targets a different issue, when a collator advertises a collation built on top seconded para head. |
The code changes here don't relate to this issue as far as I can tell and is introducing complexity without a clear benefit. We already keep announcements in memory until they go out of view - we keep up to The way it should be implemented is to check whether I'm going to close this PR - happy to reopen if it helps with implementing the protocol as described in the issue. |
I amended some language in #5054 which may have been the cause of this confusion: previously:
changed to:
|
The plan with this PR was that the response for this request not only gives us vector of possible depths, but also returns a status of parent nodes (again, for each depth) What's unnecessary in this PR is tracking, but the overall idea should match the one you described. |
Yeah, it always either needed to change or to have some alternative request introduced which serves the same purpose. I mentioned that in a few places. I'll reopen, but it'd need to be almost completely changed, because the current changes to return depths: Vec<(usize, ParentHeadDataState)>, // or something more compact
enum ParentHeadDataState {
// i.e. the head data hash is the 'current head' of the `BaseConstraints`: this is the case for _all_ depths when depth 0 is a valid hypothetical depth
CommittedToRelayChain,
// A candidate committing to the parent's head-data has been backed.
Backed,
// A candidate committing to the parent's head-data has been seconded,
Seconded,
}
// unknown state is not necessary, because this is used under hypothetical depths which have already passed a 'parent head known' filter. The implementation of |
@rphmeier pub enum ProspectiveParachainsMessage {
// ...
IsSecondingAllowed {
para_id: ParaId,
parent_head_data_hash: Hash,
sender: oneshot::Sender<bool>,
}
// ...
} suited specifically for collator protocol. It would traverse para's fragment trees for each active leaf
If found, send Then we don't need to re-request hypothetical depth at new activations and can simply wait for The thing is, collator protocol doesn't track which depths are vacant in the tree and probably shouldn't. |
I would prefer a more general API which can be used by multiple subsystems. This Both statement distribution and collator-protocol need to receive notifications about new backed and seconded candidates. |
Which subsystem other than collator protocol will look into parent node status?
I was re-reading through conversation in this PR and assumed that was your intention here too:
We would then track depths twice and I don't really like it.
Collator protocol would only care about those seconded locally. But anyway, this is out of scope of the issue. |
Backing is actually capable of telling whether we can second a candidate. It just needs to track parent head data hash for each candidate in |
Needed for #5054
Previous version of
GetHypotheticalDepths
doesn't give any info about parent node being seconded/backed. Now:Also forward
CandidateSeconded
notifications to collator protocol