Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Constrain parachain block validity on a specific core #103
Constrain parachain block validity on a specific core #103
Changes from 17 commits
eadc50d
b20fd68
9e754fc
7cff0ed
a404bab
476d941
d429299
f1d1a60
f3e8167
c78ddd5
952a03a
bab26c4
1b200f3
4d92c14
56e0b39
13c6ae9
029cc11
a19d318
7b6dfc6
ea485d4
d6d35b9
e01dd95
5962c06
01719f7
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
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.
Does Polkadot right now allows to use a claim ahead in the queue? I still don't really get why we need it. The parachain runtime should ensure that always a new core is being used, for that using selector is enough.
Do we use right now the relay chain block of the pov was build on to determine the claim queue and then to determine the core? Or what are we doing right now?
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.
Right now, the core index is determined by the backers who have voted. We map validator index to group index to core index.
The claim queue offset is required because of the
CoreSelector % number_of_assignments
operation that selects the core. Because parachains can have a varying number of cores assigned to them (on-demand) at different offsets in the claim queue, the core index you get might be different depending on which claim is used.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.
I mean I get this. However, you want to us all possible claims? So, you probably don't want to waste any cores. Which means you will build on all the cores. With prospective parachains you also can calculate which should be the next claim to use. Thus, we should not require the offset?
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.
Yes
That would not be enough. Let's see what happens. In backing we need to determine if the candidate is valid on the core the backers are assigned to. We take the core selector and get compute the core index and assume we start to fill the claims at top of the queue , which is exactly like claim queue offset 0, or we could have a more evolved tracking mechanism and we'd know which is the next free claim on a higher queue depth.
The problem is that the collator has to provide the core index in the descriptor. Keep in mind that the modulo core_selector operation gives different results depending on number of claims. So the parachain runtime has to actually pick a claim. That is why we need this offset so that validator know what the parachain has picked. If we don't have this parameter, collators need to make same assumption as validators and the runtime otherwise they get different core index.
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.
I thought about this a little bit more and I think I found a way to not require the
offset
. My main problem with thisoffset
is that it is static. You also write in the RFC itself that it isn't that great.So, to my proposal. I would propose we store the latest
core_selector
of each parachain in the relay chain state. Then we can use thislatest_core_selector
(fetched at the candidate context relay chain block) together with theclaim_queue
to determine if thecore_index
in the candidate is correct. First we would calculate thecore_selector_diff = core_selector.wrapping_sub(latest_core_selector)
. Then we would fetch theclaim_queue
at the candidate context relay chain block. We would count all cores assigned to our parachain until the count reachescore_selector_diff
and then we would have ourcore_index
.I think we can then also get rid off
max_candidate_len
from the async backing parameters as the maximum length would be determined by the "claim queue lookahead".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.
Keeping a claim queue snapshot at valid relayparents in the runtime allows us to compute the core index correctly.
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.
Snapshots are fine. Possible future optimization (if necessary): Accompany each entry in the claim queue with the block number it came into existence. Then by only knowing the block number of the relay parent, we can filter to only the relevant entries.
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.
And if the claim queue is not empty? They loose their claim?
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.
If the parachain is using offset 1, no. They have enough time to build the candidate.
If the parachain is using offset 0, then it can only do synchronous backing if my understanding is right.
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.
No. The claim would not even be lost without the duplication on empty queues, but if the queue was empty before your claim immediately goes to position 0, which means only synchronous backing. Position 0 is therefore kind of "special".
There is no such problem if the queue was not empty. If at least one item was present before, you start at position 1, which already provides capability for full blocks.