diff --git a/node/core/runtime-api/src/tests.rs b/node/core/runtime-api/src/tests.rs index b5ba4fc08a78..0d70a76fc1e2 100644 --- a/node/core/runtime-api/src/tests.rs +++ b/node/core/runtime-api/src/tests.rs @@ -21,11 +21,11 @@ use polkadot_node_primitives::{BabeAllowedSlots, BabeEpoch, BabeEpochConfigurati use polkadot_node_subsystem::SpawnGlue; use polkadot_node_subsystem_test_helpers::make_subsystem_context; use polkadot_primitives::{ - runtime_api::ParachainHost, AuthorityDiscoveryId, Block, CandidateEvent, - CommittedCandidateReceipt, CoreState, GroupRotationInfo, Id as ParaId, InboundDownwardMessage, - InboundHrmpMessage, OccupiedCoreAssumption, PersistedValidationData, PvfCheckStatement, - ScrapedOnChainVotes, SessionIndex, SessionInfo, ValidationCode, ValidationCodeHash, - ValidatorId, ValidatorIndex, ValidatorSignature, + runtime_api::ParachainHost, v4::CoreState, vstaging, AuthorityDiscoveryId, Block, + CandidateEvent, CommittedCandidateReceipt, GroupRotationInfo, Id as ParaId, + InboundDownwardMessage, InboundHrmpMessage, OccupiedCoreAssumption, PersistedValidationData, + PvfCheckStatement, ScrapedOnChainVotes, SessionIndex, SessionInfo, ValidationCode, + ValidationCodeHash, ValidatorId, ValidatorIndex, ValidatorSignature, }; use sp_api::ProvideRuntimeApi; use sp_authority_discovery::AuthorityDiscoveryApi; @@ -42,6 +42,7 @@ struct MockRuntimeApi { validators: Vec, validator_groups: Vec>, availability_cores: Vec, + availability_cores_vstaging: Vec, availability_cores_wait: Arc>, validation_data: HashMap, session_index_for_child: SessionIndex, @@ -90,6 +91,11 @@ sp_api::mock_impl_runtime_apis! { self.availability_cores.clone() } + fn availability_cores_vstaging(&self) -> Vec { + let _lock = self.availability_cores_wait.lock().unwrap(); + self.availability_cores_vstaging.clone() + } + fn persisted_validation_data( &self, para: ParaId, @@ -334,7 +340,7 @@ fn requests_availability_cores() { }) .await; - assert_eq!(rx.await.unwrap().unwrap(), runtime_api.availability_cores); + assert_eq!(rx.await.unwrap().unwrap(), runtime_api.availability_cores_vstaging); ctx_handle.send(FromOrchestra::Signal(OverseerSignal::Conclude)).await; }; @@ -891,7 +897,7 @@ fn multiple_requests_in_parallel_are_working() { join.await .into_iter() - .for_each(|r| assert_eq!(r.unwrap().unwrap(), runtime_api.availability_cores)); + .for_each(|r| assert_eq!(r.unwrap().unwrap(), runtime_api.availability_cores_vstaging)); ctx_handle.send(FromOrchestra::Signal(OverseerSignal::Conclude)).await; }; diff --git a/node/network/collator-protocol/src/validator_side/tests.rs b/node/network/collator-protocol/src/validator_side/tests.rs index ea1025592896..236a634ebb7e 100644 --- a/node/network/collator-protocol/src/validator_side/tests.rs +++ b/node/network/collator-protocol/src/validator_side/tests.rs @@ -33,8 +33,8 @@ use polkadot_node_subsystem::messages::{AllMessages, RuntimeApiMessage, RuntimeA use polkadot_node_subsystem_test_helpers as test_helpers; use polkadot_node_subsystem_util::TimeoutExt; use polkadot_primitives::{ - v4::CollatorRestrictionKind, vstaging::CollatorRestrictions, CollatorPair, CoreState, - GroupIndex, GroupRotationInfo, OccupiedCore, ScheduledCore, ValidatorId, ValidatorIndex, + CollatorPair, CollatorRestrictionKind, CollatorRestrictions, CoreState, GroupIndex, + GroupRotationInfo, OccupiedCore, ScheduledCore, ValidatorId, ValidatorIndex, }; use polkadot_primitives_test_helpers::{ dummy_candidate_descriptor, dummy_candidate_receipt_bad_sig, dummy_hash, diff --git a/node/subsystem-types/src/runtime_client.rs b/node/subsystem-types/src/runtime_client.rs index 2d6d7afcfd08..9f2ead54ea45 100644 --- a/node/subsystem-types/src/runtime_client.rs +++ b/node/subsystem-types/src/runtime_client.rs @@ -252,7 +252,18 @@ where &self, at: Hash, ) -> Result>, ApiError> { - self.runtime_api().availability_cores(at) + let version = self + .api_version_parachain_host(at) + .await + .unwrap_or_default() + .unwrap_or_default(); + if version >= 5 { + self.runtime_api().availability_cores_vstaging(at) + } else { + self.runtime_api() + .availability_cores(at) + .map(|css| css.into_iter().map(vstaging::corestate_from_v4).collect()) + } } async fn persisted_validation_data( diff --git a/primitives/src/lib.rs b/primitives/src/lib.rs index 9cd1de8b4778..a111c04051b5 100644 --- a/primitives/src/lib.rs +++ b/primitives/src/lib.rs @@ -41,17 +41,16 @@ pub use v4::{ CandidateCommitments, CandidateDescriptor, CandidateEvent, CandidateHash, CandidateIndex, CandidateReceipt, CheckedDisputeStatementSet, CheckedMultiDisputeStatementSet, CollatorId, CollatorSignature, CommittedCandidateReceipt, CompactStatement, ConsensusLog, CoreIndex, - CoreOccupied, CoreState, DisputeState, DisputeStatement, DisputeStatementSet, DownwardMessage, - EncodeAs, ExecutorParam, ExecutorParams, ExecutorParamsHash, ExplicitDisputeStatement, - GroupIndex, GroupRotationInfo, Hash, HashT, HeadData, Header, HrmpChannelId, Id, - InboundDownwardMessage, InboundHrmpMessage, IndexedVec, InherentData, - InvalidDisputeStatementKind, Moment, MultiDisputeStatementSet, Nonce, OccupiedCore, + DisputeState, DisputeStatement, DisputeStatementSet, DownwardMessage, EncodeAs, ExecutorParam, + ExecutorParams, ExecutorParamsHash, ExplicitDisputeStatement, GroupIndex, GroupRotationInfo, + Hash, HashT, HeadData, Header, HrmpChannelId, Id, InboundDownwardMessage, InboundHrmpMessage, + IndexedVec, InherentData, InvalidDisputeStatementKind, Moment, MultiDisputeStatementSet, Nonce, OccupiedCoreAssumption, OutboundHrmpMessage, ParathreadClaim, ParathreadEntry, PersistedValidationData, PvfCheckStatement, PvfExecTimeoutKind, PvfPrepTimeoutKind, RuntimeMetricLabel, RuntimeMetricLabelValue, RuntimeMetricLabelValues, RuntimeMetricLabels, - RuntimeMetricOp, RuntimeMetricUpdate, ScheduledCore, ScrapedOnChainVotes, SessionIndex, - SessionInfo, Signature, Signed, SignedAvailabilityBitfield, SignedAvailabilityBitfields, - SignedStatement, SigningContext, Slot, UncheckedSigned, UncheckedSignedAvailabilityBitfield, + RuntimeMetricOp, RuntimeMetricUpdate, ScrapedOnChainVotes, SessionIndex, SessionInfo, + Signature, Signed, SignedAvailabilityBitfield, SignedAvailabilityBitfields, SignedStatement, + SigningContext, Slot, UncheckedSigned, UncheckedSignedAvailabilityBitfield, UncheckedSignedAvailabilityBitfields, UncheckedSignedStatement, UpgradeGoAhead, UpgradeRestriction, UpwardMessage, ValidDisputeStatementKind, ValidationCode, ValidationCodeHash, ValidatorId, ValidatorIndex, ValidatorSignature, ValidityAttestation, @@ -59,5 +58,10 @@ pub use v4::{ MAX_POV_SIZE, PARACHAINS_INHERENT_IDENTIFIER, PARACHAIN_KEY_TYPE_ID, }; +pub use vstaging::{ + CollatorRestrictionKind, CollatorRestrictions, CoreOccupied, CoreState, OccupiedCore, + ScheduledCore, +}; + #[cfg(feature = "std")] pub use v4::{AssignmentPair, CollatorPair, ValidatorPair}; diff --git a/primitives/src/runtime_api.rs b/primitives/src/runtime_api.rs index c60ec8c92298..e5bd685bf533 100644 --- a/primitives/src/runtime_api.rs +++ b/primitives/src/runtime_api.rs @@ -112,7 +112,7 @@ use crate::{ vstaging, BlockNumber, CandidateCommitments, CandidateEvent, CandidateHash, - CommittedCandidateReceipt, CoreState, DisputeState, ExecutorParams, GroupRotationInfo, + CommittedCandidateReceipt, DisputeState, ExecutorParams, GroupRotationInfo, OccupiedCoreAssumption, PersistedValidationData, PvfCheckStatement, ScrapedOnChainVotes, SessionIndex, SessionInfo, ValidatorId, ValidatorIndex, ValidatorSignature, }; @@ -135,7 +135,12 @@ sp_api::decl_runtime_apis! { /// 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. - fn availability_cores() -> Vec>; + fn availability_cores() -> Vec>; + + /// 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_vstaging() -> Vec>; /// Yields the persisted validation data for the given `ParaId` along with an assumption that /// should be used if the para currently occupies a core. diff --git a/primitives/src/v4/mod.rs b/primitives/src/v4/mod.rs index c369e17406b9..ea53498ed1ce 100644 --- a/primitives/src/v4/mod.rs +++ b/primitives/src/v4/mod.rs @@ -20,7 +20,6 @@ use bitvec::vec::BitVec; use parity_scale_codec::{Decode, Encode}; use scale_info::TypeInfo; use sp_std::{ - collections::btree_set::BTreeSet, marker::PhantomData, prelude::*, slice::{Iter, IterMut}, @@ -29,7 +28,7 @@ use sp_std::{ use application_crypto::KeyTypeId; use inherents::InherentIdentifier; -use primitives::{OpaquePeerId, RuntimeDebug}; +use primitives::RuntimeDebug; use runtime_primitives::traits::{AppVerify, Header as HeaderT}; use sp_arithmetic::traits::{BaseArithmetic, Saturating}; @@ -50,9 +49,6 @@ pub use polkadot_parachain::primitives::{ use serde::{Deserialize, Serialize}; -#[cfg(feature = "std")] -use sc_network::PeerId; - pub use sp_authority_discovery::AuthorityId as AuthorityDiscoveryId; pub use sp_consensus_slots::Slot; pub use sp_staking::SessionIndex; @@ -818,121 +814,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)] -pub struct Assignment { - /// Assignment's ParaId - pub para_id: Id, - /// Assignment's CollatorRestrictions - pub collator_restrictions: CollatorRestrictions, -} - -impl Assignment { - /// Create a new `Assignment`. - pub fn new(para_id: Id, collator_restrictions: CollatorRestrictions) -> Self { - Assignment { para_id, collator_restrictions } - } -} - -/// Restrictions on collators for a specific paras block. -#[derive(Clone, Encode, Decode, PartialEq, TypeInfo, RuntimeDebug)] -pub struct CollatorRestrictions { - /// Collators to prefer/allow. - /// Empty set means no restrictions. - collator_peer_ids: BTreeSet, - restriction_kind: CollatorRestrictionKind, -} - -impl CollatorRestrictions { - /// Specialised new function for parachains. - pub fn none() -> Self { - CollatorRestrictions { - collator_peer_ids: BTreeSet::new(), - restriction_kind: CollatorRestrictionKind::Preferred, - } - } - - /// Create a new `CollatorRestrictions`. - pub fn new( - collator_peer_ids: BTreeSet, - restriction_kind: CollatorRestrictionKind, - ) -> Self { - CollatorRestrictions { collator_peer_ids, restriction_kind } - } - - /// Is peer_id allowed to collate? - #[cfg(feature = "std")] - pub fn can_collate(&self, peer_id: &PeerId) -> bool { - self.collator_peer_ids.is_empty() || - match self.restriction_kind { - CollatorRestrictionKind::Preferred => true, - CollatorRestrictionKind::Required => { - let peer_id = OpaquePeerId(peer_id.to_bytes()); - self.collator_peer_ids.contains(&peer_id) - }, - } - } -} - -/// How to apply the collator restrictions. -#[derive(Clone, Encode, Decode, PartialEq, TypeInfo, RuntimeDebug)] -pub enum CollatorRestrictionKind { - /// peer ids mentioned will be preferred in connections, but others are still allowed. - Preferred, - /// Any collator with a `PeerId` not in the set of `CollatorRestrictions` will be rejected. - Required, -} - -/// An entry tracking a paras -#[derive(Clone, Encode, Decode, TypeInfo, PartialEq, RuntimeDebug)] -pub struct ParasEntry { - /// The `Assignment` - pub assignment: Assignment, - /// Number of times this has been retried. - pub retries: u32, -} - -impl From for ParasEntry { - fn from(assignment: Assignment) -> Self { - ParasEntry { assignment, retries: 0 } - } -} - -impl ParasEntry { - /// Create a new `ParasEntry`. - pub fn new(assignment: Assignment) -> Self { - ParasEntry { assignment, retries: 0 } - } - - /// Return `Id` from the underlying `Assignment`. - pub fn para_id(&self) -> Id { - self.assignment.para_id - } - - /// Return `CollatorRestrictions` from the underlying `Assignment`. - pub fn collator_restrictions(&self) -> &CollatorRestrictions { - &self.assignment.collator_restrictions - } -} - /// What is occupying a specific availability core. #[derive(Clone, Encode, Decode, TypeInfo, RuntimeDebug)] #[cfg_attr(feature = "std", derive(PartialEq))] pub enum CoreOccupied { - /// The core is not occupied. - Free, - /// A paras. - Paras(ParasEntry), -} - -impl CoreOccupied { - /// Is core free? - pub fn is_free(&self) -> bool { - match self { - Self::Free => true, - Self::Paras(_) => false, - } - } + /// A parathread. + Parathread(ParathreadEntry), + /// A parachain. + Parachain, } /// A helper data-type for tracking validator-group rotations. @@ -1062,11 +951,10 @@ impl OccupiedCore { #[derive(Clone, Encode, Decode, TypeInfo, RuntimeDebug)] #[cfg_attr(feature = "std", derive(PartialEq))] pub struct ScheduledCore { - // TODO: Is the same as Assignment /// The ID of a para scheduled. pub para_id: Id, - /// The collator restrictions. - pub collator_restrictions: CollatorRestrictions, + /// The collator required to author the block, if any. + pub collator: Option, } /// The state of a particular availability core. diff --git a/primitives/src/vstaging/mod.rs b/primitives/src/vstaging/mod.rs index 9b6291ffbf32..971d9a1a131c 100644 --- a/primitives/src/vstaging/mod.rs +++ b/primitives/src/vstaging/mod.rs @@ -17,13 +17,16 @@ //! Staging Primitives. // Put any primitives used by staging APIs functions here -pub use crate::v4::*; +pub use crate::{v4, v4::*}; pub mod slashing; -use sp_std::prelude::*; - +use bitvec::prelude::BitVec; use parity_scale_codec::{Decode, Encode}; -use primitives::RuntimeDebug; +use primitives::{OpaquePeerId, RuntimeDebug}; use scale_info::TypeInfo; +use sp_std::{collections::btree_set::BTreeSet, prelude::*}; + +#[cfg(feature = "std")] +use sc_network::PeerId; /// Candidate's acceptance limitations for asynchronous backing per relay parent. #[derive( @@ -50,3 +53,242 @@ pub struct AsyncBackingParams { /// When async backing is disabled, the only valid value is 0. pub allowed_ancestry_len: u32, } + +/// What is occupying a specific availability core. +#[derive(Clone, Encode, Decode, TypeInfo, RuntimeDebug)] +#[cfg_attr(feature = "std", derive(PartialEq))] +pub enum CoreOccupied { + /// The core is not occupied. + Free, + /// A paras. + Paras(ParasEntry), +} + +impl CoreOccupied { + /// Is core free? + pub fn is_free(&self) -> bool { + match self { + Self::Free => true, + Self::Paras(_) => false, + } + } +} + +/// An Assignemnt for a paras going to produce a paras block. +#[derive(Clone, Encode, Decode, PartialEq, TypeInfo, RuntimeDebug)] +pub struct Assignment { + /// Assignment's ParaId + pub para_id: Id, + /// Assignment's CollatorRestrictions + pub collator_restrictions: CollatorRestrictions, +} + +impl Assignment { + /// Create a new `Assignment`. + pub fn new(para_id: Id, collator_restrictions: CollatorRestrictions) -> Self { + Assignment { para_id, collator_restrictions } + } +} + +/// Restrictions on collators for a specific paras block. +#[derive(Clone, Encode, Decode, PartialEq, TypeInfo, RuntimeDebug)] +pub struct CollatorRestrictions { + /// Collators to prefer/allow. + /// Empty set means no restrictions. + collator_peer_ids: BTreeSet, + restriction_kind: CollatorRestrictionKind, +} + +impl CollatorRestrictions { + /// Specialised new function for parachains. + pub fn none() -> Self { + CollatorRestrictions { + collator_peer_ids: BTreeSet::new(), + restriction_kind: CollatorRestrictionKind::Preferred, + } + } + + /// Create a new `CollatorRestrictions`. + pub fn new( + collator_peer_ids: BTreeSet, + restriction_kind: CollatorRestrictionKind, + ) -> Self { + CollatorRestrictions { collator_peer_ids, restriction_kind } + } + + /// Is `peer_id` allowed to collate? + #[cfg(feature = "std")] + pub fn can_collate(&self, peer_id: &PeerId) -> bool { + self.collator_peer_ids.is_empty() || + match self.restriction_kind { + CollatorRestrictionKind::Preferred => true, + CollatorRestrictionKind::Required => { + let peer_id = OpaquePeerId(peer_id.to_bytes()); + self.collator_peer_ids.contains(&peer_id) + }, + } + } +} + +/// How to apply the collator restrictions. +#[derive(Clone, Encode, Decode, PartialEq, TypeInfo, RuntimeDebug)] +pub enum CollatorRestrictionKind { + /// peer ids mentioned will be preferred in connections, but others are still allowed. + Preferred, + /// Any collator with a `PeerId` not in the set of `CollatorRestrictions` will be rejected. + Required, +} + +/// An entry tracking a paras +#[derive(Clone, Encode, Decode, TypeInfo, PartialEq, RuntimeDebug)] +pub struct ParasEntry { + /// The `Assignment` + pub assignment: Assignment, + /// Number of times this has been retried. + pub retries: u32, +} + +impl From for ParasEntry { + fn from(assignment: Assignment) -> Self { + Self::new(assignment) + } +} + +impl ParasEntry { + /// Create a new `ParasEntry`. + pub fn new(assignment: Assignment) -> Self { + ParasEntry { assignment, retries: 0 } + } + + /// Return `Id` from the underlying `Assignment`. + pub fn para_id(&self) -> Id { + self.assignment.para_id + } + + /// Return `CollatorRestrictions` from the underlying `Assignment`. + pub fn collator_restrictions(&self) -> &CollatorRestrictions { + &self.assignment.collator_restrictions + } +} + +/// Information about a core which is currently occupied. +#[derive(Clone, Encode, Decode, TypeInfo, RuntimeDebug)] +#[cfg_attr(feature = "std", derive(PartialEq))] +pub struct OccupiedCore { + // NOTE: this has no ParaId as it can be deduced from the candidate descriptor. + /// If this core is freed by availability, this is the assignment that is next up on this + /// core, if any. None if there is nothing queued for this core. + pub next_up_on_available: Option, + /// The relay-chain block number this began occupying the core at. + pub occupied_since: N, + /// The relay-chain block this will time-out at. + 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 the currently occupying assignment + /// already has exhausted its retry counter. + pub next_up_on_time_out: Option, + /// A bitfield with 1 bit for each validator in the set. `1` bits mean that the corresponding + /// validators has attested to availability on-chain. A 2/3+ majority of `1` bits means that + /// this will be available. + pub availability: BitVec, + /// The group assigned to distribute availability pieces and backing of this candidate. + pub group_responsible: GroupIndex, + /// The hash of the candidate occupying the core. + pub candidate_hash: CandidateHash, + /// The descriptor of the candidate occupying the core. + pub candidate_descriptor: CandidateDescriptor, +} + +impl OccupiedCore { + /// Get the Para currently occupying this core. + pub fn para_id(&self) -> Id { + self.candidate_descriptor.para_id + } +} + +/// Upgrade a v4 OccupiedCore to a vstaging one. +pub fn occupied_core_from_v4(oc: v4::OccupiedCore) -> OccupiedCore { + OccupiedCore { + next_up_on_available: oc.next_up_on_available.map(scheduled_core_from_v4), + occupied_since: oc.occupied_since, + time_out_at: oc.time_out_at, + next_up_on_time_out: oc.next_up_on_time_out.map(scheduled_core_from_v4), + availability: oc.availability, + group_responsible: oc.group_responsible, + candidate_hash: oc.candidate_hash, + candidate_descriptor: oc.candidate_descriptor, + } +} + +/// Information about a core which is currently occupied. +#[derive(Clone, Encode, Decode, TypeInfo, RuntimeDebug)] +#[cfg_attr(feature = "std", derive(PartialEq))] +pub struct ScheduledCore { + // TODO: Is the same as Assignment + /// The ID of a para scheduled. + pub para_id: Id, + /// The collator restrictions. + pub collator_restrictions: CollatorRestrictions, +} + +impl ScheduledCore { + /// Converts its current form of itself to the v4 version of itself + pub fn to_v4(self) -> crate::v4::ScheduledCore { + crate::v4::ScheduledCore { para_id: self.para_id, collator: None } + } +} + +/// Upgrade a v4 ScheduledCore to a vstaging one. +pub fn scheduled_core_from_v4(sc: v4::ScheduledCore) -> ScheduledCore { + ScheduledCore { + para_id: sc.para_id, + collator_restrictions: CollatorRestrictions::none(), // v4 is all leased parachains + } +} + +/// The state of a particular availability core. +#[derive(Clone, Encode, Decode, TypeInfo, RuntimeDebug)] +#[cfg_attr(feature = "std", derive(PartialEq))] +pub enum CoreState { + /// The core is currently occupied. + #[codec(index = 0)] + Occupied(OccupiedCore), + /// The core is currently free, with a para scheduled and given the opportunity + /// to occupy. + /// + /// If a particular Collator is required to author this block, that is also present in this + /// variant. + #[codec(index = 1)] + Scheduled(ScheduledCore), + /// The core is currently free and there is nothing scheduled. This can be the case for on-demand parachains + /// cores when there are no on-demand blocks queued. Leased parachain cores will never be left idle. + #[codec(index = 2)] + Free, +} + +impl CoreState { + /// If this core state has a `para_id`, return it. + pub fn para_id(&self) -> Option { + match self { + Self::Occupied(ref core) => Some(core.para_id()), + Self::Scheduled(core) => Some(core.para_id), + Self::Free => None, + } + } + + /// Is this core state `Self::Occupied`? + pub fn is_occupied(&self) -> bool { + matches!(self, Self::Occupied(_)) + } +} + +/// Upgrade a v4 CoreState to a vstaging one. +pub fn corestate_from_v4(cs: v4::CoreState) -> CoreState { + match cs { + v4::CoreState::Free => CoreState::Free, + v4::CoreState::Occupied(occupied_core) => + CoreState::Occupied(occupied_core_from_v4(occupied_core)), + v4::CoreState::Scheduled(scheduled_core) => + CoreState::Scheduled(scheduled_core_from_v4(scheduled_core)), + } +} diff --git a/runtime/kusama/src/lib.rs b/runtime/kusama/src/lib.rs index 1de396059e97..d3082a38e083 100644 --- a/runtime/kusama/src/lib.rs +++ b/runtime/kusama/src/lib.rs @@ -24,10 +24,10 @@ use pallet_nis::WithMaximumOf; use parity_scale_codec::{Decode, Encode, MaxEncodedLen}; use primitives::{ AccountId, AccountIndex, Balance, BlockNumber, CandidateEvent, CandidateHash, - CommittedCandidateReceipt, CoreState, DisputeState, ExecutorParams, GroupRotationInfo, Hash, - Id as ParaId, InboundDownwardMessage, InboundHrmpMessage, Moment, Nonce, - OccupiedCoreAssumption, PersistedValidationData, ScrapedOnChainVotes, SessionInfo, Signature, - ValidationCode, ValidationCodeHash, ValidatorId, ValidatorIndex, LOWEST_PUBLIC_ID, + CommittedCandidateReceipt, DisputeState, ExecutorParams, GroupRotationInfo, Hash, Id as ParaId, + InboundDownwardMessage, InboundHrmpMessage, Moment, Nonce, OccupiedCoreAssumption, + PersistedValidationData, ScrapedOnChainVotes, SessionInfo, Signature, ValidationCode, + ValidationCodeHash, ValidatorId, ValidatorIndex, LOWEST_PUBLIC_ID, }; use runtime_common::{ auctions, claims, crowdloan, impl_runtime_weights, impls::DealWithFees, paras_registrar, @@ -1730,7 +1730,7 @@ sp_api::impl_runtime_apis! { parachains_runtime_api_impl::validator_groups::() } - fn availability_cores() -> Vec> { + fn availability_cores() -> Vec> { parachains_runtime_api_impl::availability_cores::() } diff --git a/runtime/parachains/src/builder.rs b/runtime/parachains/src/builder.rs index a2bac962bbb7..581f257c5bef 100644 --- a/runtime/parachains/src/builder.rs +++ b/runtime/parachains/src/builder.rs @@ -24,11 +24,11 @@ use bitvec::{order::Lsb0 as BitOrderLsb0, vec::BitVec}; use frame_support::pallet_prelude::*; use primitives::{ collator_signature_payload, - v4::{Assignment, CollatorRestrictions, ParasEntry}, + vstaging::{Assignment, CollatorRestrictions, CoreOccupied, ParasEntry}, AvailabilityBitfield, BackedCandidate, CandidateCommitments, CandidateDescriptor, CandidateHash, CollatorId, CollatorSignature, CommittedCandidateReceipt, CompactStatement, - CoreIndex, CoreOccupied, DisputeStatement, DisputeStatementSet, GroupIndex, HeadData, - Id as ParaId, IndexedVec, InherentData as ParachainsInherentData, InvalidDisputeStatementKind, + CoreIndex, DisputeStatement, DisputeStatementSet, GroupIndex, HeadData, Id as ParaId, + IndexedVec, InherentData as ParachainsInherentData, InvalidDisputeStatementKind, PersistedValidationData, SessionIndex, SigningContext, UncheckedSigned, ValidDisputeStatementKind, ValidationCode, ValidatorId, ValidatorIndex, ValidityAttestation, }; diff --git a/runtime/parachains/src/inclusion/tests.rs b/runtime/parachains/src/inclusion/tests.rs index 051b95ede212..af14bee73bdc 100644 --- a/runtime/parachains/src/inclusion/tests.rs +++ b/runtime/parachains/src/inclusion/tests.rs @@ -30,7 +30,7 @@ use frame_support::assert_noop; use keyring::Sr25519Keyring; use parity_scale_codec::DecodeAll; use primitives::{ - v4::{Assignment, CollatorRestrictionKind, CollatorRestrictions, ParasEntry}, + vstaging::{Assignment, CollatorRestrictionKind, CollatorRestrictions, ParasEntry}, BlockNumber, CandidateCommitments, CandidateDescriptor, CollatorId, CompactStatement as Statement, EncodeAs, Hash, SignedAvailabilityBitfield, SignedStatement, UncheckedSignedAvailabilityBitfield, ValidationCode, ValidatorId, ValidityAttestation, diff --git a/runtime/parachains/src/paras_inherent/tests.rs b/runtime/parachains/src/paras_inherent/tests.rs index e1e0c18b116e..12cfade45897 100644 --- a/runtime/parachains/src/paras_inherent/tests.rs +++ b/runtime/parachains/src/paras_inherent/tests.rs @@ -891,7 +891,7 @@ mod sanitizers { use crate::mock::Test; use keyring::Sr25519Keyring; use primitives::{ - v4::{Assignment, CollatorRestrictions, ParasEntry}, + vstaging::{Assignment, CollatorRestrictions, ParasEntry}, PARACHAIN_KEY_TYPE_ID, }; use sc_keystore::LocalKeystore; diff --git a/runtime/parachains/src/runtime_api_impl/v4.rs b/runtime/parachains/src/runtime_api_impl/v4.rs index a4e43438ef0a..7d0ef9fb3ce7 100644 --- a/runtime/parachains/src/runtime_api_impl/v4.rs +++ b/runtime/parachains/src/runtime_api_impl/v4.rs @@ -18,14 +18,14 @@ //! functions. use crate::{ - configuration, disputes, dmp, hrmp, inclusion, initializer, paras, paras_inherent, scheduler, - session_info, shared, + disputes, dmp, hrmp, inclusion, initializer, paras, paras_inherent, scheduler, session_info, + shared, }; use primitives::{ AuthorityDiscoveryId, CandidateEvent, CandidateHash, CommittedCandidateReceipt, CoreIndex, - CoreOccupied, CoreState, DisputeState, ExecutorParams, GroupIndex, GroupRotationInfo, Hash, - Id as ParaId, InboundDownwardMessage, InboundHrmpMessage, OccupiedCore, OccupiedCoreAssumption, - PersistedValidationData, PvfCheckStatement, ScrapedOnChainVotes, SessionIndex, SessionInfo, + CoreOccupied, DisputeState, ExecutorParams, GroupIndex, GroupRotationInfo, Hash, Id as ParaId, + InboundDownwardMessage, InboundHrmpMessage, OccupiedCoreAssumption, PersistedValidationData, + PvfCheckStatement, ScheduledCore, ScrapedOnChainVotes, SessionIndex, SessionInfo, ValidationCode, ValidationCodeHash, ValidatorId, ValidatorIndex, ValidatorSignature, }; use sp_runtime::traits::One; @@ -48,32 +48,8 @@ pub fn validator_groups( } /// Implementation for the `availability_cores` function of the runtime API. -pub fn availability_cores() -> Vec> { - let cores = >::availability_cores(); - let config = >::config(); - let now = >::block_number() + One::one(); - let rotation_info = >::group_rotation_info(now); - - let time_out_at = |backed_in_number, availability_period| { - let time_out_at = backed_in_number + availability_period; - - let current_window = rotation_info.last_rotation_at() + availability_period; - let next_rotation = rotation_info.next_rotation_at(); - - // If we are within `period` blocks of rotation, timeouts are being checked - // actively. We could even time out this block. - if time_out_at < current_window { - time_out_at - } else if time_out_at <= next_rotation { - // Otherwise, it will time out at the sooner of the next rotation - next_rotation - } else { - // or the scheduled time-out. This is by definition within `period` blocks - // of `next_rotation` and is thus a valid timeout block. - time_out_at - } - }; - +pub fn availability_cores( +) -> Vec> { let group_responsible_for = |backed_in_number, core_index| match >::group_assigned_to_core( core_index, @@ -91,6 +67,7 @@ pub fn availability_cores() -> Vec>::availability_cores(); let mut core_states: Vec<_> = cores .into_iter() .enumerate() @@ -101,15 +78,17 @@ pub fn availability_cores() -> Vec>::next_up_on_available(CoreIndex( - i as u32, - )), + let core_index = CoreIndex::from(i as u32); + primitives::v4::CoreState::Occupied(primitives::v4::OccupiedCore { + next_up_on_available: >::next_up_on_available(core_index) + .map(ScheduledCore::to_v4), occupied_since: backed_in_number, - time_out_at: time_out_at(backed_in_number, config.chain_availability_period), - next_up_on_time_out: >::next_up_on_time_out(CoreIndex( - i as u32, - )), + time_out_at: >::calc_time_out_at( + backed_in_number, + core_index, + ), + next_up_on_time_out: >::next_up_on_time_out(core_index) + .map(ScheduledCore::to_v4), availability: pending_availability.availability_votes().clone(), group_responsible: group_responsible_for( backed_in_number, @@ -119,16 +98,18 @@ pub fn availability_cores() -> Vec CoreState::Free, + CoreOccupied::Free => primitives::v4::CoreState::Free, }) .collect(); + let now = >::block_number() + One::one(); // This will overwrite only `Free` cores if the scheduler module is working as intended. for scheduled in >::scheduled_claimqueue(now) { - core_states[scheduled.core.0 as usize] = CoreState::Scheduled(primitives::ScheduledCore { - para_id: scheduled.paras_entry.para_id(), - collator_restrictions: scheduled.paras_entry.collator_restrictions().clone(), - }); + core_states[scheduled.core.0 as usize] = + primitives::v4::CoreState::Scheduled(primitives::v4::ScheduledCore { + para_id: scheduled.paras_entry.para_id(), + collator: None, + }); } core_states diff --git a/runtime/parachains/src/runtime_api_impl/vstaging.rs b/runtime/parachains/src/runtime_api_impl/vstaging.rs index be7c58e3f24e..4170d6033d16 100644 --- a/runtime/parachains/src/runtime_api_impl/vstaging.rs +++ b/runtime/parachains/src/runtime_api_impl/vstaging.rs @@ -16,8 +16,9 @@ //! Put implementations of functions from staging APIs here. -use crate::disputes; -use primitives::{vstaging, CandidateHash, DisputeState, SessionIndex}; +use crate::{disputes, inclusion, initializer, scheduler}; +use primitives::{vstaging, CandidateHash, CoreIndex, DisputeState, GroupIndex, SessionIndex}; +use sp_runtime::traits::One; use sp_std::prelude::*; /// Implementation for `get_session_disputes` function from the runtime API @@ -44,3 +45,70 @@ pub fn submit_unsigned_slashing_report( key_ownership_proof, ) } + +/// Implementation for the `availability_cores_staging` function of the runtime API. +pub fn availability_cores( +) -> Vec> { + let group_responsible_for = + |backed_in_number, core_index| match >::group_assigned_to_core( + core_index, + backed_in_number, + ) { + Some(g) => g, + None => { + log::warn!( + target: "runtime::polkadot-api::v2", + "Could not determine the group responsible for core extracted \ + from list of cores for some prior block in same session", + ); + + GroupIndex(0) + }, + }; + + let cores = >::availability_cores(); + let mut core_states: Vec<_> = cores + .into_iter() + .enumerate() + .map(|(i, core)| match core { + vstaging::CoreOccupied::Paras(entry) => { + let pending_availability = + >::pending_availability(entry.para_id()) + .expect("Occupied core always has pending availability; qed"); + + let backed_in_number = *pending_availability.backed_in_number(); + let core_index = CoreIndex::from(i as u32); + vstaging::CoreState::Occupied(vstaging::OccupiedCore { + next_up_on_available: >::next_up_on_available(core_index), + occupied_since: backed_in_number, + time_out_at: >::calc_time_out_at( + backed_in_number, + core_index, + ), + next_up_on_time_out: >::next_up_on_time_out(core_index), + availability: pending_availability.availability_votes().clone(), + group_responsible: group_responsible_for( + backed_in_number, + pending_availability.core_occupied(), + ), + candidate_hash: pending_availability.candidate_hash(), + candidate_descriptor: pending_availability.candidate_descriptor().clone(), + }) + }, + vstaging::CoreOccupied::Free => vstaging::CoreState::Free, + }) + .collect(); + + let now = >::block_number() + One::one(); + // TODO: update to use claimqueue + // This will overwrite only `Free` cores if the scheduler module is working as intended. + for scheduled in >::scheduled_claimqueue(now) { + core_states[scheduled.core.0 as usize] = + vstaging::CoreState::Scheduled(vstaging::ScheduledCore { + para_id: scheduled.para_id(), + collator_restrictions: scheduled.paras_entry.collator_restrictions().clone(), + }); + } + + core_states +} diff --git a/runtime/parachains/src/scheduler.rs b/runtime/parachains/src/scheduler.rs index b94a9c21067c..fe671b7c59a7 100644 --- a/runtime/parachains/src/scheduler.rs +++ b/runtime/parachains/src/scheduler.rs @@ -37,10 +37,10 @@ use frame_support::pallet_prelude::*; use primitives::{ - CoreIndex, CoreOccupied, GroupIndex, GroupRotationInfo, Id as ParaId, ScheduledCore, - ValidatorIndex, + vstaging::{CoreOccupied, ParasEntry, ScheduledCore}, + CoreIndex, GroupIndex, GroupRotationInfo, Id as ParaId, ValidatorIndex, }; -use sp_runtime::traits::{One, Saturating}; +use sp_runtime::traits::One; use sp_std::{ collections::{btree_map::BTreeMap, btree_set::BTreeSet, vec_deque::VecDeque}, prelude::*, @@ -54,7 +54,6 @@ use crate::{ }; pub use pallet::*; -use primitives::v4::ParasEntry; #[cfg(test)] mod tests; @@ -68,7 +67,7 @@ pub mod migration; pub mod pallet { use super::*; use crate::scheduler_common::AssignmentProvider; - use primitives::v4::ParasEntry; + use primitives::vstaging::ParasEntry; #[pallet::pallet] #[pallet::without_storage_info] @@ -345,14 +344,23 @@ impl Pallet { pub(crate) fn availability_timeout_predicate() -> Box bool> { let predicate = move |core_index: CoreIndex, pending_since| { - let availability_period = T::AssignmentProvider::get_availability_period(core_index); + let time_out_at = Self::calc_time_out_at(pending_since, core_index); let now = >::block_number(); - now.saturating_sub(pending_since) >= availability_period + + now >= time_out_at }; Box::new(predicate) } + /// Returns the block at which a parachain that has occupied a core at `core_index` since `backed_in` gets timed out. + pub(crate) fn calc_time_out_at( + backed_in: T::BlockNumber, + core_index: CoreIndex, + ) -> T::BlockNumber { + backed_in + T::AssignmentProvider::get_availability_period(core_index) + } + /// Returns a helper for determining group rotation. pub(crate) fn group_rotation_info(now: T::BlockNumber) -> GroupRotationInfo { let session_start_block = Self::session_start_block(); @@ -528,6 +536,11 @@ impl Pallet { }); } + // Only used for migration + fn set_availability_cores(cores: Vec) { + AvailabilityCores::::set(cores); + } + /// Returns `ParasEntry` with `para_id` at `core_idx` if found. fn remove_from_claimqueue( core_idx: CoreIndex, diff --git a/runtime/parachains/src/scheduler/migration.rs b/runtime/parachains/src/scheduler/migration.rs index f1830ac27304..292417e2142f 100644 --- a/runtime/parachains/src/scheduler/migration.rs +++ b/runtime/parachains/src/scheduler/migration.rs @@ -7,11 +7,19 @@ pub mod v1 { use frame_support::{ pallet_prelude::ValueQuery, storage_alias, traits::OnRuntimeUpgrade, weights::Weight, }; - use primitives::{v4::CollatorRestrictions, vstaging::Assignment, CollatorId}; + use primitives::{ + v4, + vstaging::{Assignment, CollatorRestrictions}, + CollatorId, + }; #[storage_alias] pub(super) type Scheduled = StorageValue, Vec, ValueQuery>; + #[storage_alias] + pub(crate) type AvailabilityCores = + StorageValue, Vec>, ValueQuery>; + #[derive(Encode, Decode)] pub struct QueuedParathread { claim: primitives::ParathreadEntry, @@ -98,7 +106,7 @@ pub mod v1 { ); ensure!( StorageVersion::get::>() == 0, - "Storage version should be less than `1` before the migration", + "Storage version should be `0` before the migration", ); let bytes = u32::to_be_bytes(Scheduled::::get().len() as u32); @@ -146,6 +154,32 @@ pub mod v1 { Pallet::::add_to_claimqueue(core_idx, pe); } + let cores = AvailabilityCores::::take(); + let cores_len = cores.len() as u64; + let parachains = >::parachains(); + let new_cores = cores + .iter() + .enumerate() + .map(|(idx, core)| match core { + None => CoreOccupied::Free, + Some(v4::CoreOccupied::Parachain) => { + let para_id = parachains[idx]; + let pe = + ParasEntry::from(Assignment::new(para_id, CollatorRestrictions::none())); + + CoreOccupied::Paras(pe) + }, + Some(v4::CoreOccupied::Parathread(_entry)) => { + panic!("There are no parathreads pre-v5") + }, + }) + .collect(); + + Pallet::::set_availability_cores(new_cores); + + // 2x as once for reading AvailabilityCores and for writing new ones + weight = + weight.saturating_add(T::DbWeight::get().reads_writes(2 * cores_len, 2 * cores_len)); // 2x as once for Scheduled and once for Claimqueue weight = weight.saturating_add(T::DbWeight::get().reads_writes(2 * sched_len, 2 * sched_len)); diff --git a/runtime/parachains/src/scheduler/tests.rs b/runtime/parachains/src/scheduler/tests.rs index 6fd86014d3ef..a620ed23994b 100644 --- a/runtime/parachains/src/scheduler/tests.rs +++ b/runtime/parachains/src/scheduler/tests.rs @@ -19,7 +19,7 @@ use super::*; use frame_support::assert_ok; use keyring::Sr25519Keyring; use primitives::{ - v4::{Assignment, CollatorRestrictionKind, CollatorRestrictions}, + vstaging::{Assignment, CollatorRestrictionKind, CollatorRestrictions}, BlockNumber, CollatorId, SessionIndex, ValidationCode, ValidatorId, }; use sp_core::{ByteArray, OpaquePeerId}; diff --git a/runtime/parachains/src/scheduler_common/mod.rs b/runtime/parachains/src/scheduler_common/mod.rs index c56f273aefb8..a03415f0df2d 100644 --- a/runtime/parachains/src/scheduler_common/mod.rs +++ b/runtime/parachains/src/scheduler_common/mod.rs @@ -37,7 +37,7 @@ use frame_support::pallet_prelude::*; use primitives::{ - v4::{Assignment, ParasEntry}, + vstaging::{Assignment, ParasEntry}, CoreIndex, GroupIndex, Id as ParaId, }; use scale_info::TypeInfo; diff --git a/runtime/parachains/src/scheduler_parachains/mod.rs b/runtime/parachains/src/scheduler_parachains/mod.rs index 8003783ff03d..075169c6bb8d 100644 --- a/runtime/parachains/src/scheduler_parachains/mod.rs +++ b/runtime/parachains/src/scheduler_parachains/mod.rs @@ -17,7 +17,7 @@ use crate::{configuration, paras, scheduler_common::AssignmentProvider}; pub use pallet::*; use primitives::{ - v4::{Assignment, CollatorRestrictions}, + vstaging::{Assignment, CollatorRestrictions}, CoreIndex, Id as ParaId, }; diff --git a/runtime/parachains/src/scheduler_polkadot/mod.rs b/runtime/parachains/src/scheduler_polkadot/mod.rs index b32deb3d2644..da5c6586400e 100644 --- a/runtime/parachains/src/scheduler_polkadot/mod.rs +++ b/runtime/parachains/src/scheduler_polkadot/mod.rs @@ -16,7 +16,7 @@ use crate::{configuration, paras, scheduler_common::AssignmentProvider}; pub use pallet::*; -use primitives::{v4::Assignment, CoreIndex, Id as ParaId}; +use primitives::{vstaging::Assignment, CoreIndex, Id as ParaId}; #[frame_support::pallet] pub mod pallet { diff --git a/runtime/polkadot/src/lib.rs b/runtime/polkadot/src/lib.rs index bbefd4ae686c..cd8e09665789 100644 --- a/runtime/polkadot/src/lib.rs +++ b/runtime/polkadot/src/lib.rs @@ -58,10 +58,10 @@ use pallet_transaction_payment::{FeeDetails, RuntimeDispatchInfo}; use parity_scale_codec::{Decode, Encode, MaxEncodedLen}; use primitives::{ AccountId, AccountIndex, Balance, BlockNumber, CandidateEvent, CandidateHash, - CommittedCandidateReceipt, CoreState, DisputeState, ExecutorParams, GroupRotationInfo, Hash, - Id as ParaId, InboundDownwardMessage, InboundHrmpMessage, Moment, Nonce, - OccupiedCoreAssumption, PersistedValidationData, ScrapedOnChainVotes, SessionInfo, Signature, - ValidationCode, ValidationCodeHash, ValidatorId, ValidatorIndex, LOWEST_PUBLIC_ID, + CommittedCandidateReceipt, DisputeState, ExecutorParams, GroupRotationInfo, Hash, Id as ParaId, + InboundDownwardMessage, InboundHrmpMessage, Moment, Nonce, OccupiedCoreAssumption, + PersistedValidationData, ScrapedOnChainVotes, SessionInfo, Signature, ValidationCode, + ValidationCodeHash, ValidatorId, ValidatorIndex, LOWEST_PUBLIC_ID, }; use sp_core::OpaqueMetadata; use sp_mmr_primitives as mmr; @@ -1744,7 +1744,7 @@ sp_api::impl_runtime_apis! { parachains_runtime_api_impl::validator_groups::() } - fn availability_cores() -> Vec> { + fn availability_cores() -> Vec> { parachains_runtime_api_impl::availability_cores::() } diff --git a/runtime/rococo/src/lib.rs b/runtime/rococo/src/lib.rs index 3d477d139f5d..cd483fdecd78 100644 --- a/runtime/rococo/src/lib.rs +++ b/runtime/rococo/src/lib.rs @@ -24,10 +24,10 @@ use pallet_nis::WithMaximumOf; use parity_scale_codec::{Decode, Encode, MaxEncodedLen}; use primitives::{ vstaging, AccountId, AccountIndex, Balance, BlockNumber, CandidateEvent, CandidateHash, - CommittedCandidateReceipt, CoreState, DisputeState, ExecutorParams, GroupRotationInfo, Hash, - Id as ParaId, InboundDownwardMessage, InboundHrmpMessage, Moment, Nonce, - OccupiedCoreAssumption, PersistedValidationData, ScrapedOnChainVotes, SessionInfo, Signature, - ValidationCode, ValidationCodeHash, ValidatorId, ValidatorIndex, PARACHAIN_KEY_TYPE_ID, + CommittedCandidateReceipt, DisputeState, ExecutorParams, GroupRotationInfo, Hash, Id as ParaId, + InboundDownwardMessage, InboundHrmpMessage, Moment, Nonce, OccupiedCoreAssumption, + PersistedValidationData, ScrapedOnChainVotes, SessionInfo, Signature, ValidationCode, + ValidationCodeHash, ValidatorId, ValidatorIndex, PARACHAIN_KEY_TYPE_ID, }; use runtime_common::{ assigned_slots, auctions, claims, crowdloan, impl_runtime_weights, impls::ToAuthor, @@ -1821,10 +1821,14 @@ sp_api::impl_runtime_apis! { parachains_runtime_api_impl::validator_groups::() } - fn availability_cores() -> Vec> { + fn availability_cores() -> Vec> { parachains_runtime_api_impl::availability_cores::() } + fn availability_cores_vstaging() -> Vec> { + runtime_parachains::runtime_api_impl::vstaging::availability_cores::() + } + fn persisted_validation_data(para_id: ParaId, assumption: OccupiedCoreAssumption) -> Option> { parachains_runtime_api_impl::persisted_validation_data::(para_id, assumption) diff --git a/runtime/test-runtime/src/lib.rs b/runtime/test-runtime/src/lib.rs index 3a2634978e00..a839555c00f0 100644 --- a/runtime/test-runtime/src/lib.rs +++ b/runtime/test-runtime/src/lib.rs @@ -45,9 +45,9 @@ use pallet_session::historical as session_historical; use pallet_transaction_payment::{FeeDetails, RuntimeDispatchInfo}; use polkadot_runtime_parachains::reward_points::RewardValidatorsWithEraPoints; use primitives::{ - AccountId, AccountIndex, Balance, BlockNumber, CandidateEvent, CandidateHash, - CommittedCandidateReceipt, CoreState, DisputeState, ExecutorParams, GroupRotationInfo, - Hash as HashT, Id as ParaId, InboundDownwardMessage, InboundHrmpMessage, Moment, Nonce, + v4::CoreState, AccountId, AccountIndex, Balance, BlockNumber, CandidateEvent, CandidateHash, + CommittedCandidateReceipt, DisputeState, ExecutorParams, GroupRotationInfo, Hash as HashT, + Id as ParaId, InboundDownwardMessage, InboundHrmpMessage, Moment, Nonce, OccupiedCoreAssumption, PersistedValidationData, ScrapedOnChainVotes, SessionInfo as SessionInfoData, Signature, ValidationCode, ValidationCodeHash, ValidatorId, ValidatorIndex, @@ -804,6 +804,7 @@ sp_api::impl_runtime_apis! { } fn availability_cores() -> Vec> { + //polkadot_runtime_parachains::runtime_api_impl::vstaging::availability_cores::() runtime_impl::availability_cores::() } diff --git a/runtime/westend/src/lib.rs b/runtime/westend/src/lib.rs index eb13ae845527..d5b115569f72 100644 --- a/runtime/westend/src/lib.rs +++ b/runtime/westend/src/lib.rs @@ -40,11 +40,11 @@ use pallet_transaction_payment::{CurrencyAdapter, FeeDetails, RuntimeDispatchInf use parity_scale_codec::{Decode, Encode, MaxEncodedLen}; use primitives::{ vstaging, AccountId, AccountIndex, Balance, BlockNumber, CandidateEvent, CandidateHash, - CommittedCandidateReceipt, CoreState, DisputeState, ExecutorParams, GroupRotationInfo, Hash, - Id as ParaId, InboundDownwardMessage, InboundHrmpMessage, Moment, Nonce, - OccupiedCoreAssumption, PersistedValidationData, PvfCheckStatement, ScrapedOnChainVotes, - SessionInfo, Signature, ValidationCode, ValidationCodeHash, ValidatorId, ValidatorIndex, - ValidatorSignature, PARACHAIN_KEY_TYPE_ID, + CommittedCandidateReceipt, DisputeState, ExecutorParams, GroupRotationInfo, Hash, Id as ParaId, + InboundDownwardMessage, InboundHrmpMessage, Moment, Nonce, OccupiedCoreAssumption, + PersistedValidationData, PvfCheckStatement, ScrapedOnChainVotes, SessionInfo, Signature, + ValidationCode, ValidationCodeHash, ValidatorId, ValidatorIndex, ValidatorSignature, + PARACHAIN_KEY_TYPE_ID, }; use runtime_common::{ assigned_slots, auctions, crowdloan, elections::OnChainAccuracy, impl_runtime_weights, @@ -1488,10 +1488,14 @@ sp_api::impl_runtime_apis! { parachains_runtime_api_impl::validator_groups::() } - fn availability_cores() -> Vec> { + fn availability_cores() -> Vec> { parachains_runtime_api_impl::availability_cores::() } + fn availability_cores_vstaging() -> Vec> { + runtime_parachains::runtime_api_impl::vstaging::availability_cores::() + } + fn persisted_validation_data(para_id: ParaId, assumption: OccupiedCoreAssumption) -> Option> { parachains_runtime_api_impl::persisted_validation_data::(para_id, assumption)