mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-07-19 12:15:42 +00:00
Runtime API: introduce candidates_pending_availability (#4027)
Fixes https://github.com/paritytech/polkadot-sdk/issues/3576 Required by elastic scaling collators. Deprecates old API: `candidate_pending_availability`. TODO: - [x] PRDoc --------- Signed-off-by: Andrei Sandu <andrei-mihail@parity.io>
This commit is contained in:
@@ -1104,6 +1104,24 @@ impl<T: Config> Pallet<T> {
|
||||
})
|
||||
}
|
||||
|
||||
/// Returns all the `CommittedCandidateReceipt` pending availability for the para provided, if
|
||||
/// any.
|
||||
pub(crate) fn candidates_pending_availability(
|
||||
para: ParaId,
|
||||
) -> Vec<CommittedCandidateReceipt<T::Hash>> {
|
||||
<PendingAvailability<T>>::get(¶)
|
||||
.map(|candidates| {
|
||||
candidates
|
||||
.into_iter()
|
||||
.map(|candidate| CommittedCandidateReceipt {
|
||||
descriptor: candidate.descriptor.clone(),
|
||||
commitments: candidate.commitments.clone(),
|
||||
})
|
||||
.collect()
|
||||
})
|
||||
.unwrap_or_default()
|
||||
}
|
||||
|
||||
/// Returns the metadata around the first candidate pending availability for the
|
||||
/// para provided, if any.
|
||||
pub(crate) fn pending_availability(
|
||||
|
||||
@@ -301,6 +301,10 @@ pub fn validation_code<T: initializer::Config>(
|
||||
}
|
||||
|
||||
/// Implementation for the `candidate_pending_availability` function of the runtime API.
|
||||
#[deprecated(
|
||||
note = "`candidate_pending_availability` will be removed. Use `candidates_pending_availability` to query
|
||||
all candidates pending availability"
|
||||
)]
|
||||
pub fn candidate_pending_availability<T: initializer::Config>(
|
||||
para_id: ParaId,
|
||||
) -> Option<CommittedCandidateReceipt<T::Hash>> {
|
||||
|
||||
@@ -16,8 +16,8 @@
|
||||
|
||||
//! Put implementations of functions from staging APIs here.
|
||||
|
||||
use crate::scheduler;
|
||||
use primitives::{CoreIndex, Id as ParaId};
|
||||
use crate::{inclusion, initializer, scheduler};
|
||||
use primitives::{CommittedCandidateReceipt, CoreIndex, Id as ParaId};
|
||||
use sp_runtime::traits::One;
|
||||
use sp_std::{
|
||||
collections::{btree_map::BTreeMap, vec_deque::VecDeque},
|
||||
@@ -41,3 +41,11 @@ pub fn claim_queue<T: scheduler::Config>() -> BTreeMap<CoreIndex, VecDeque<ParaI
|
||||
})
|
||||
.collect()
|
||||
}
|
||||
|
||||
/// Returns all the candidates that are pending availability for a given `ParaId`.
|
||||
/// Deprecates `candidate_pending_availability` in favor of supporting elastic scaling.
|
||||
pub fn candidates_pending_availability<T: initializer::Config>(
|
||||
para_id: ParaId,
|
||||
) -> Vec<CommittedCandidateReceipt<T::Hash>> {
|
||||
<inclusion::Pallet<T>>::candidates_pending_availability(para_id)
|
||||
}
|
||||
|
||||
@@ -1795,6 +1795,7 @@ sp_api::impl_runtime_apis! {
|
||||
}
|
||||
|
||||
fn candidate_pending_availability(para_id: ParaId) -> Option<CommittedCandidateReceipt<Hash>> {
|
||||
#[allow(deprecated)]
|
||||
parachains_runtime_api_impl::candidate_pending_availability::<Runtime>(para_id)
|
||||
}
|
||||
|
||||
@@ -1908,6 +1909,10 @@ sp_api::impl_runtime_apis! {
|
||||
fn claim_queue() -> BTreeMap<CoreIndex, VecDeque<ParaId>> {
|
||||
vstaging_parachains_runtime_api_impl::claim_queue::<Runtime>()
|
||||
}
|
||||
|
||||
fn candidates_pending_availability(para_id: ParaId) -> Vec<CommittedCandidateReceipt<Hash>> {
|
||||
vstaging_parachains_runtime_api_impl::candidates_pending_availability::<Runtime>(para_id)
|
||||
}
|
||||
}
|
||||
|
||||
#[api_version(3)]
|
||||
|
||||
@@ -22,15 +22,19 @@
|
||||
|
||||
use pallet_transaction_payment::FungibleAdapter;
|
||||
use parity_scale_codec::Encode;
|
||||
use sp_std::{collections::btree_map::BTreeMap, prelude::*};
|
||||
use sp_std::{
|
||||
collections::{btree_map::BTreeMap, vec_deque::VecDeque},
|
||||
prelude::*,
|
||||
};
|
||||
|
||||
use polkadot_runtime_parachains::{
|
||||
assigner_parachains as parachains_assigner_parachains,
|
||||
configuration as parachains_configuration, disputes as parachains_disputes,
|
||||
disputes::slashing as parachains_slashing, dmp as parachains_dmp, hrmp as parachains_hrmp,
|
||||
inclusion as parachains_inclusion, initializer as parachains_initializer,
|
||||
origin as parachains_origin, paras as parachains_paras,
|
||||
paras_inherent as parachains_paras_inherent, runtime_api_impl::v10 as runtime_impl,
|
||||
disputes::slashing as parachains_slashing,
|
||||
dmp as parachains_dmp, hrmp as parachains_hrmp, inclusion as parachains_inclusion,
|
||||
initializer as parachains_initializer, origin as parachains_origin, paras as parachains_paras,
|
||||
paras_inherent as parachains_paras_inherent,
|
||||
runtime_api_impl::{v10 as runtime_impl, vstaging as vstaging_parachains_runtime_api_impl},
|
||||
scheduler as parachains_scheduler, session_info as parachains_session_info,
|
||||
shared as parachains_shared,
|
||||
};
|
||||
@@ -53,9 +57,9 @@ use pallet_transaction_payment::{FeeDetails, RuntimeDispatchInfo};
|
||||
use polkadot_runtime_parachains::reward_points::RewardValidatorsWithEraPoints;
|
||||
use primitives::{
|
||||
slashing, AccountId, AccountIndex, Balance, BlockNumber, CandidateEvent, CandidateHash,
|
||||
CommittedCandidateReceipt, CoreState, DisputeState, ExecutorParams, GroupRotationInfo,
|
||||
Hash as HashT, Id as ParaId, InboundDownwardMessage, InboundHrmpMessage, Moment, Nonce,
|
||||
OccupiedCoreAssumption, PersistedValidationData, ScrapedOnChainVotes,
|
||||
CommittedCandidateReceipt, CoreIndex, CoreState, DisputeState, ExecutorParams,
|
||||
GroupRotationInfo, Hash as HashT, Id as ParaId, InboundDownwardMessage, InboundHrmpMessage,
|
||||
Moment, Nonce, OccupiedCoreAssumption, PersistedValidationData, ScrapedOnChainVotes,
|
||||
SessionInfo as SessionInfoData, Signature, ValidationCode, ValidationCodeHash, ValidatorId,
|
||||
ValidatorIndex, PARACHAIN_KEY_TYPE_ID,
|
||||
};
|
||||
@@ -831,7 +835,7 @@ sp_api::impl_runtime_apis! {
|
||||
}
|
||||
}
|
||||
|
||||
#[api_version(10)]
|
||||
#[api_version(11)]
|
||||
impl primitives::runtime_api::ParachainHost<Block> for Runtime {
|
||||
fn validators() -> Vec<ValidatorId> {
|
||||
runtime_impl::validators::<Runtime>()
|
||||
@@ -879,6 +883,7 @@ sp_api::impl_runtime_apis! {
|
||||
}
|
||||
|
||||
fn candidate_pending_availability(para_id: ParaId) -> Option<CommittedCandidateReceipt<Hash>> {
|
||||
#[allow(deprecated)]
|
||||
runtime_impl::candidate_pending_availability::<Runtime>(para_id)
|
||||
}
|
||||
|
||||
@@ -983,6 +988,14 @@ sp_api::impl_runtime_apis! {
|
||||
fn node_features() -> primitives::NodeFeatures {
|
||||
runtime_impl::node_features::<Runtime>()
|
||||
}
|
||||
|
||||
fn claim_queue() -> BTreeMap<CoreIndex, VecDeque<ParaId>> {
|
||||
vstaging_parachains_runtime_api_impl::claim_queue::<Runtime>()
|
||||
}
|
||||
|
||||
fn candidates_pending_availability(para_id: ParaId) -> Vec<CommittedCandidateReceipt<Hash>> {
|
||||
vstaging_parachains_runtime_api_impl::candidates_pending_availability::<Runtime>(para_id)
|
||||
}
|
||||
}
|
||||
|
||||
impl beefy_primitives::BeefyApi<Block, BeefyId> for Runtime {
|
||||
|
||||
@@ -1853,6 +1853,7 @@ sp_api::impl_runtime_apis! {
|
||||
}
|
||||
|
||||
fn candidate_pending_availability(para_id: ParaId) -> Option<CommittedCandidateReceipt<Hash>> {
|
||||
#[allow(deprecated)]
|
||||
parachains_runtime_api_impl::candidate_pending_availability::<Runtime>(para_id)
|
||||
}
|
||||
|
||||
@@ -1966,6 +1967,10 @@ sp_api::impl_runtime_apis! {
|
||||
fn claim_queue() -> BTreeMap<CoreIndex, VecDeque<ParaId>> {
|
||||
vstaging_parachains_runtime_api_impl::claim_queue::<Runtime>()
|
||||
}
|
||||
|
||||
fn candidates_pending_availability(para_id: ParaId) -> Vec<CommittedCandidateReceipt<Hash>> {
|
||||
vstaging_parachains_runtime_api_impl::candidates_pending_availability::<Runtime>(para_id)
|
||||
}
|
||||
}
|
||||
|
||||
impl beefy_primitives::BeefyApi<Block, BeefyId> for Runtime {
|
||||
|
||||
Reference in New Issue
Block a user