-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Undo v4 changes, move them to vstaging #7103
base: alex/parathreads_review
Are you sure you want to change the base?
Conversation
8b03c90
to
fc276d6
Compare
primitives/src/runtime_api.rs
Outdated
@@ -123,7 +123,7 @@ use sp_std::{collections::btree_map::BTreeMap, prelude::*}; | |||
|
|||
sp_api::decl_runtime_apis! { | |||
/// The API for querying the state of parachains on-chain. | |||
#[api_version(4)] | |||
#[api_version(5)] |
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 is good. You also need to add (can't leave a comment at the right):
#[changed_in(5)]
fn availability_cores() -> Vec<CoreState<H, N>>;
This way you can have two implementations - old and new ones. The intention of changed_in
is to change the method signature. I'm not sure if it will work in the case 'same signature, different implementation'.
If this is the case - you can just add another function and handle the right one in the client code. This one breaks the semantics a little but imo it's fine. If pick this approach, you shouldn't touch base version here and just add another method:
#[api_version(5)]
fn availability_cores_with_parathreads() -> Vec<CoreState<H, N>>;
@@ -819,121 +815,14 @@ pub struct ParathreadEntry { | |||
pub retries: u32, | |||
} | |||
|
|||
/// An Assignemnt for a paras going to produce a paras block. | |||
#[derive(Clone, Encode, Decode, PartialEq, TypeInfo, RuntimeDebug)] |
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 remember these are actually not part of v4 at the moment and you are undoing previous work done in alex/parathreads_review, 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.
Exactly! At the end of the day, we'll need to make sure v4 is just as it is on master
. Which I think it is here but will confirm later down the road when we have the final feature branch with a diff to master
.
@@ -252,7 +252,18 @@ where | |||
&self, | |||
at: Hash, | |||
) -> Result<Vec<CoreState<Hash, BlockNumber>>, ApiError> { | |||
self.runtime_api().availability_cores(at) | |||
let version = self |
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.
We discussed somewhere that such transformations in the client are not encouraged and we prefer doing this in the subsystem. Unfortunately I don't remember the exact reasons.
For your particular case I think it's okay though. Depending on the runtime api you call either the new or the old version of the function. And you do this workaround to avoid the changed_in
issues with the runtime api.
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.
Which file would this ideally go to then? What exactly is the subsystem again? I'm only aware of the node/client and runtime distinction.
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.
Subsystem is a module (lets say) from the node - e.g. approval-voting
, dispute-coordinator
etc.
You can put a function in any helpers module (e.g. https://github.com/paritytech/polkadot/blob/dbae30efe080a1d41fe54ef4da8af47614c9ca93/node/subsystem-util/src/runtime/mod.rs) and call it each time you need the availability_cores.
But I'd suggest not to touch it for now.
primitives/src/vstaging/mod.rs
Outdated
pub next_up_on_available: Option<ScheduledCore>, | ||
/// The relay-chain block number this began occupying the core at. | ||
pub occupied_since: N, | ||
/// The relay-chain block this will time-out at, if any. |
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 is not an Option
, so the if any
seems odd.
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 is a copy and paste from v4
. Fixed.
primitives/src/vstaging/mod.rs
Outdated
/// The relay-chain block this will time-out at, if any. | ||
pub time_out_at: N, | ||
/// If this core is freed by being timed-out, this is the assignment that is next up on this | ||
/// core. None if there is nothing queued for this core or there is no possibility of timing |
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.
There is always a possibility of timing out. What could be that there is no other assignment queued and the currently occupying assignment already has exhausted its retry counter.
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 is a copy and paste from v4
. Fixed.
primitives/src/vstaging/mod.rs
Outdated
/// validators has attested to availability on-chain. A 2/3+ majority of `1` bits means that | ||
/// this will be available. | ||
pub availability: BitVec<u8, bitvec::order::Lsb0>, | ||
/// The group assigned to distribute availability pieces of this candidate. |
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 backing the candidate.
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 is a copy and paste from v4. Fixed.
primitives/src/vstaging/mod.rs
Outdated
/// variant. | ||
#[codec(index = 1)] | ||
Scheduled(ScheduledCore), | ||
/// The core is currently free and there is nothing scheduled. This can be the case for parathread |
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.
We should start using on-demand parachain.
primitives/src/runtime_api.rs
Outdated
/// Yields information on all availability cores as relevant to the child block. | ||
/// Cores are either free or occupied. Free cores can have paras assigned to them. | ||
#[api_version(5)] | ||
fn availability_cores_on_demand() -> Vec<vstaging::CoreState<H, N>>; |
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.
So this only gets us on-demand availability cores? I guess not, from the docs and from my understanding. So where does the name come from?
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's supposed to be the v5
availability_cores
call. I thought just calling it availability_cores_v5
would be a bit meaningless but I see how the current name is misleading as well.
// actively. We could even time out this block. | ||
if time_out_at < current_window { | ||
time_out_at | ||
} else if time_out_at <= next_rotation { |
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 code is out of sync with the updated timeout predicate. It is bad that this can even happen, we should be using the same logic. DRY.
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.
Agreed! The issue is that the updated timeout predicate is in the scheduler itself. The runtime API uses its own implementation for reasons unknown to me. Will unify.
No description provided.