Commit 850fe62c authored by Peter Goodspeed-Niklaus's avatar Peter Goodspeed-Niklaus
Browse files

Pass number of block under construction via RequestInherentData

parent 4f05dcd6
......@@ -4372,7 +4372,7 @@ checksum = "feb3b2b1033b8a60b4da6ee470325f887758c95d5320f52f9ce0df055a55940e"
[[package]]
name = "polkadot"
version = "0.8.22"
version = "0.8.19"
dependencies = [
"assert_cmd",
"futures 0.3.5",
......@@ -4691,6 +4691,31 @@ dependencies = [
"wasm-timer",
]
[[package]]
name = "polkadot-node-core-provisioner"
version = "0.1.0"
dependencies = [
"bitvec",
"derive_more 0.99.9",
"futures 0.3.5",
"log 0.4.8",
"polkadot-node-subsystem",
"polkadot-primitives",
]
[[package]]
name = "polkadot-node-core-runtime-api"
version = "0.1.0"
dependencies = [
"futures 0.3.5",
"polkadot-node-primitives",
"polkadot-node-subsystem",
"polkadot-primitives",
"sp-api",
"sp-blockchain",
"sp-core",
]
[[package]]
name = "polkadot-node-primitives"
version = "0.1.0"
......
......@@ -29,7 +29,7 @@ use polkadot_node_subsystem::{
},
util::{self, request_availability_cores, JobTrait, ToJobTrait},
};
use polkadot_primitives::v1::{BackedCandidate, CoreState, Hash, SignedAvailabilityBitfield};
use polkadot_primitives::v1::{BackedCandidate, BlockNumber, CoreState, Hash, SignedAvailabilityBitfield};
use std::{
collections::{HashMap, HashSet},
convert::TryFrom,
......@@ -163,7 +163,7 @@ impl ProvisioningJob {
};
match msg {
ToJob::Provisioner(RequestInherentData(_, sender)) => {
ToJob::Provisioner(RequestInherentData(_, block_number, sender)) => {
// Note the cloning here: we have to clone the vectors of signed bitfields and backed candidates
// so that we can respond to more than a single request for inherent data; we can't just move them.
// It would be legal, however, to set up `from_job` as `&mut _` instead of a clone. We clone it instead
......@@ -174,6 +174,7 @@ impl ProvisioningJob {
self.backed_candidates.clone(),
sender,
self.sender.clone(),
block_number,
)
.await?
}
......@@ -231,6 +232,7 @@ async fn send_inherent_data(
mut backed_candidates: Vec<BackedCandidate>,
return_sender: oneshot::Sender<ProvisionerInherentData>,
mut from_job: mpsc::Sender<FromJob>,
block_number: BlockNumber,
) -> Result<(), Error> {
let availability_cores = match request_availability_cores(relay_parent, &mut from_job)
.await?
......@@ -293,9 +295,7 @@ async fn send_inherent_data(
}
if let Some(ref scheduled) = occupied.next_up_on_time_out {
return scheduled.para_id == para_id
// TODO: this function currently doesn't know about what block we're building
// get it from the runtime? where?
&& unimplemented!("occupied.time_out_at == the block we are building")
&& occupied.time_out_at == block_number
// REVIEW: the guide says we have to ensure that the merged bitfields are < 2/3 in this case,
// but intuition suggests that we'd still want it to be >=. Just want a double-check that
// there's no typo in the guide.
......
......@@ -310,7 +310,7 @@ pub enum ChainApiMessage {
hash: Hash,
/// The number of ancestors to request.
k: usize,
/// The response channel.
/// The response channel.
response_channel: ChainApiResponseChannel<Vec<Hash>>,
},
}
......@@ -438,7 +438,9 @@ pub enum ProvisionerMessage {
///
/// This is expected to be used by a proposer, to inject that information into the InherentData
/// where it can be assembled into the InclusionInherent.
RequestInherentData(Hash, oneshot::Sender<ProvisionerInherentData>),
///
/// The block number is of the relay chain block under construction.
RequestInherentData(Hash, BlockNumber, oneshot::Sender<ProvisionerInherentData>),
/// This data should become part of a relay chain block
ProvisionableData(ProvisionableData),
}
......@@ -448,7 +450,7 @@ impl ProvisionerMessage {
pub fn relay_parent(&self) -> Option<Hash> {
match self {
Self::RequestBlockAuthorshipData(hash, _) => Some(*hash),
Self::RequestInherentData(hash, _) => Some(*hash),
Self::RequestInherentData(hash, _, _) => Some(*hash),
Self::ProvisionableData(_) => None,
}
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment