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:
Andrei Sandu
2024-04-12 13:50:13 +03:00
committed by GitHub
parent a1cb2a5123
commit 2dfe5f745c
18 changed files with 191 additions and 16 deletions
@@ -670,7 +670,7 @@ pub enum RuntimeApiRequest {
/// Get validation code by its hash, either past, current or future code can be returned, as
/// long as state is still available.
ValidationCodeByHash(ValidationCodeHash, RuntimeApiSender<Option<ValidationCode>>),
/// Get a the candidate pending availability for a particular parachain by parachain / core
/// Get the candidate pending availability for a particular parachain by parachain / core
/// index
CandidatePendingAvailability(ParaId, RuntimeApiSender<Option<CommittedCandidateReceipt>>),
/// Get all events concerning candidates (backing, inclusion, time-out) in the parent of
@@ -739,6 +739,9 @@ pub enum RuntimeApiRequest {
/// Fetch the `ClaimQueue` from scheduler pallet
/// `V11`
ClaimQueue(RuntimeApiSender<BTreeMap<CoreIndex, VecDeque<ParaId>>>),
/// Get the candidates pending availability for a particular parachain
/// `V11`
CandidatesPendingAvailability(ParaId, RuntimeApiSender<Vec<CommittedCandidateReceipt>>),
}
impl RuntimeApiRequest {
@@ -776,6 +779,9 @@ impl RuntimeApiRequest {
/// `ClaimQueue`
pub const CLAIM_QUEUE_RUNTIME_REQUIREMENT: u32 = 11;
/// `candidates_pending_availability`
pub const CANDIDATES_PENDING_AVAILABILITY_RUNTIME_REQUIREMENT: u32 = 11;
}
/// A message to the Runtime API subsystem.
@@ -333,6 +333,14 @@ pub trait RuntimeApiSubsystemClient {
// == v11: Claim queue ==
/// Fetch the `ClaimQueue` from scheduler pallet
async fn claim_queue(&self, at: Hash) -> Result<BTreeMap<CoreIndex, VecDeque<Id>>, ApiError>;
// == v11: Elastic scaling support ==
/// Get the receipts of all candidates pending availability for a `ParaId`.
async fn candidates_pending_availability(
&self,
at: Hash,
para_id: Id,
) -> Result<Vec<CommittedCandidateReceipt<Hash>>, ApiError>;
}
/// Default implementation of [`RuntimeApiSubsystemClient`] using the client.
@@ -428,6 +436,14 @@ where
self.client.runtime_api().candidate_pending_availability(at, para_id)
}
async fn candidates_pending_availability(
&self,
at: Hash,
para_id: Id,
) -> Result<Vec<CommittedCandidateReceipt<Hash>>, ApiError> {
self.client.runtime_api().candidates_pending_availability(at, para_id)
}
async fn candidate_events(&self, at: Hash) -> Result<Vec<CandidateEvent<Hash>>, ApiError> {
self.client.runtime_api().candidate_events(at)
}