diff --git a/node/core/bitfield-signing/src/lib.rs b/node/core/bitfield-signing/src/lib.rs index 79e783829471..ed47a0f44c63 100644 --- a/node/core/bitfield-signing/src/lib.rs +++ b/node/core/bitfield-signing/src/lib.rs @@ -172,17 +172,22 @@ async fn get_core_availability( } // delegates to the v1 runtime API -async fn get_availability_cores(_relay_parent: Hash, _sender: &mut mpsc::Sender) -> Result, Error> { - // pending https://github.com/paritytech/polkadot/issues/1419 - unimplemented!() +async fn get_availability_cores(relay_parent: Hash, sender: &mut mpsc::Sender) -> Result, Error> { + use FromJob::RuntimeApi; + use messages::{ + RuntimeApiMessage::Request, + RuntimeApiRequest::AvailabilityCores, + }; + + let (tx, rx) = oneshot::channel(); + sender.send(RuntimeApi(Request(relay_parent, AvailabilityCores(tx)))).await?; + rx.await.map_err(Into::into) } -// the way this function works is not intuitive: -// -// - get the scheduler roster so we have a list of cores, in order. -// - for each occupied core, fetch `candidate_pending_availability` from runtime -// - from there, we can get the `CandidateDescriptor` -// - from there, we can send a `AvailabilityStore::QueryPoV` and set the indexed bit to 1 if it returns Some(_) +// - get the list of core states from the runtime +// - for each core, concurrently determine chunk availability (see `get_core_availability`) +// - return the bitfield if there were no errors at any point in this process +// (otherwise, it's prone to false negatives) async fn construct_availability_bitfield( relay_parent: Hash, validator_idx: ValidatorIndex, diff --git a/node/subsystem/src/messages.rs b/node/subsystem/src/messages.rs index ffb70ff91070..d95ed710a03f 100644 --- a/node/subsystem/src/messages.rs +++ b/node/subsystem/src/messages.rs @@ -28,7 +28,7 @@ use polkadot_primitives::v1::{ BlockNumber, Hash, CandidateReceipt, CommittedCandidateReceipt, PoV, ErasureChunk, BackedCandidate, Id as ParaId, SignedAvailabilityBitfield, SigningContext, ValidatorId, ValidationCode, ValidatorIndex, - CoreAssignment, CoreOccupied, HeadData, CandidateDescriptor, + CoreAssignment, CoreOccupied, CoreState, HeadData, CandidateDescriptor, ValidatorSignature, OmittedValidationData, AvailableData, CandidateEvent, }; use polkadot_node_primitives::{ @@ -311,8 +311,10 @@ pub enum RuntimeApiRequest { HeadData(ParaId, oneshot::Sender), /// Get all events concerning candidates in the last block. CandidateEvents(oneshot::Sender>), - /// Get a the candidate pending availability for a particular parachain by parachain / core index + /// Get the candidate pending availability for a particular parachain by parachain / core index CandidatePendingAvailability(ParaId, oneshot::Sender>), + /// Get the current availability cores + AvailabilityCores(oneshot::Sender>), } /// A message to the Runtime API subsystem.