Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

impl guide: Collator Generation #6938

Closed
Closed
Show file tree
Hide file tree
Changes from 75 commits
Commits
Show all changes
78 commits
Select commit Hold shift + click to select a range
559a46c
inclusion emulator logic for asynchronous backing (#4790)
rphmeier Feb 21, 2022
ba0def5
Merge branch 'rh-async-backing-feature' of https://github.com/parityt…
rphmeier Feb 25, 2022
37735ee
Runtime changes for Asynchronous Backing (#4786)
rphmeier Mar 2, 2022
1fdd683
Merge branch 'master' into rh-async-backing-feature
rphmeier Mar 7, 2022
6261133
Merge branch 'rh-async-backing-feature' of https://github.com/parityt…
rphmeier Mar 7, 2022
e398a9b
Merge branch 'master' into rh-async-backing-feature
rphmeier Mar 9, 2022
b265c4b
Merge branch 'master' into rh-async-backing-feature
rphmeier Apr 5, 2022
ce23bf7
Merge branch 'master' into rh-async-backing-feature
rphmeier Apr 20, 2022
569242a
Merge branch 'master' into rh-async-backing-feature
rphmeier Apr 27, 2022
3cdda45
Merge branch 'master' into rh-async-backing-feature
rphmeier May 18, 2022
c1fbdee
Prospective Parachains Subsystem (#4913)
rphmeier May 18, 2022
36268ec
Merge remote-tracking branch 'origin/master' into rh-async-backing-fe…
slumber Jun 22, 2022
88be445
Integrate prospective parachains subsystem into backing: Part 1 (#5557)
rphmeier Jul 10, 2022
2c9296d
Track occupied depth in backing per parachain (#5778)
slumber Jul 13, 2022
d63ecc8
provisioner: async backing changes (#5711)
slumber Sep 6, 2022
de0fc3e
Merge branch 'master' into rh-async-backing-feature
rphmeier Sep 6, 2022
c61b949
provisioner: async backing changes (#5711)
slumber Sep 6, 2022
db5e798
Merge remote-tracking branch 'upstream/rh-async-backing-feature' into…
rphmeier Sep 6, 2022
aa5b9bf
fmt
rphmeier Sep 6, 2022
25b9f7e
Network bridge changes for asynchronous backing + update subsystems t…
rphmeier Sep 12, 2022
2c215b2
remove max_pov_size requirement from prospective pvd request (#6014)
rphmeier Sep 15, 2022
4b913e7
Extract legacy statement distribution to its own module (#6026)
rphmeier Sep 23, 2022
e17bffb
Merge branch 'master' into rh-async-backing-feature
eskimor Sep 23, 2022
82ff991
Version 3 is already live.
eskimor Sep 26, 2022
614ee8c
Fix tests (#6055)
eskimor Sep 28, 2022
1bde1f7
Merge remote-tracking branch 'origin/master' into rh-async-backing-fe…
slumber Oct 7, 2022
04de8e5
fmt
slumber Oct 7, 2022
ca5e2fe
Merge remote-tracking branch 'origin/master' into rh-async-backing-fe…
slumber Oct 12, 2022
c23032a
collator-protocol: asynchronous backing changes (#5740)
slumber Oct 12, 2022
e3dff2f
Merge branch 'master' into rh-async-backing-feature
rphmeier Oct 13, 2022
6138103
Merge branch 'rh-async-backing-feature' of https://github.com/parityt…
rphmeier Oct 13, 2022
604cfc4
validator assignment fixes for backing and collator protocol (#6158)
slumber Oct 19, 2022
41e2f4d
Refactor prospective parachains mode request (#6179)
slumber Oct 24, 2022
fd1569a
backing: don't send backed candidate to provisioner (#6185)
slumber Oct 25, 2022
0f3ef99
backing: introduce `CanSecond` request for advertisements filtering (…
slumber Nov 3, 2022
21e1932
Merge remote-tracking branch 'origin/master' into rh-async-backing-fe…
slumber Nov 9, 2022
55f3633
Merge remote-tracking branch 'origin/master' into rh-async-backing-fe…
slumber Nov 13, 2022
f062f3c
cargo generate-lockfile
slumber Nov 13, 2022
8b1eb15
Implement `StagingValidityConstraints` Runtime API method (#6258)
slumber Nov 13, 2022
aacb2b3
Merge branch 'master' into rh-async-backing-feature
slumber Nov 28, 2022
c41cbbe
Prepare the Runtime for asynchronous backing upgrade (#6287)
slumber Nov 30, 2022
9f27a2f
Use real prospective parachains subsystem (#6407)
mrcnski Dec 8, 2022
17e945c
Merge remote-tracking branch 'origin/master' into rh-async-backing-fe…
slumber Jan 12, 2023
d9847aa
Merge branch 'master' into rh-async-backing-feature
rphmeier Jan 18, 2023
32759c5
Merge branch 'master' into rh-async-backing-feature
rphmeier Jan 19, 2023
cb193fb
Backport `HypotheticalFrontier` into the feature branch (#6605)
slumber Jan 24, 2023
fbd5999
Resolve todo about legacy leaf activation (#6447)
mrcnski Jan 24, 2023
d7cca3f
fix bug/warning in handling membership answers
rphmeier Jan 25, 2023
7dde6d7
Remove `HypotheticalDepthRequest` in favor of `HypotheticalFrontierRe…
mrcnski Jan 27, 2023
c760b76
Async Backing: Send Statement Distribution "Backed" messages (#6634)
mrcnski Jan 27, 2023
3ae0f24
Fix compile error
mrcnski Jan 28, 2023
d2e6081
Fix some clippy errors
mrcnski Jan 29, 2023
11556a6
Add prospective parachains subsystem tests (#6454)
mrcnski Jan 30, 2023
1c59180
Node-side metrics for asynchronous backing (#6549)
mrcnski Jan 30, 2023
8ce4057
Fix `check_depth_query` test
mrcnski Jan 30, 2023
9153998
inclusion-emulator: mirror advancement rule check (#6361)
slumber Jan 31, 2023
b858af1
prospective-parachains: introduce `backed_in_path_only` flag for adve…
slumber Jan 31, 2023
300e301
Merge remote-tracking branch 'origin/master' into rh-async-backing-fe…
slumber Feb 16, 2023
381862b
fmt
slumber Feb 16, 2023
7f19196
Merge branch 'master' into rh-async-backing-feature
rphmeier Feb 22, 2023
c752c6c
Add async-backing zombienet tests (#6314)
bredamatt Mar 1, 2023
797b32f
Async backing: impl guide for statement distribution (#6738)
mrcnski Mar 1, 2023
8c45c2e
Asynchronous backing statement distribution: Take III (#5999)
rphmeier Mar 3, 2023
2b1f1c7
miscellaneous fixes to make asynchronous backing work (#6791)
rphmeier Mar 8, 2023
ab476ca
Merge branch 'master' into rh-async-backing-feature
rphmeier Mar 8, 2023
626805d
Merge branch 'rh-async-backing-feature' of https://github.com/parityt…
rphmeier Mar 8, 2023
5e53c38
Remove restart from test (#6840)
bredamatt Mar 8, 2023
6d7f78a
Merge remote-tracking branch 'origin/master' into rh-async-backing-fe…
slumber Mar 9, 2023
cf5f666
Async Backing: Statement Distribution Tests (#6755)
mrcnski Mar 10, 2023
6dfbd20
Fix some clippy lints in tests
mrcnski Mar 15, 2023
c9552b7
Async backing: minor fixes (#6920)
mrcnski Mar 21, 2023
2945ba2
Merge remote-tracking branch 'origin/master' into rh-async-backing-fe…
slumber Mar 21, 2023
49ca776
bitfield-distribution test
slumber Mar 21, 2023
e03fb90
implicit view tests
slumber Mar 21, 2023
0ab072a
Async backing: impl guide: Collator Generation
mrcnski Mar 22, 2023
fd45eb3
Update roadmap/implementers-guide/src/node/collators/collation-genera…
mrcnski Mar 31, 2023
09ea685
Update roadmap/implementers-guide/src/node/collators/collation-genera…
mrcnski Mar 31, 2023
5c80c43
Remove async backing section
mrcnski May 18, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
481 changes: 278 additions & 203 deletions Cargo.lock

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ members = [
"node/core/chain-selection",
"node/core/dispute-coordinator",
"node/core/parachains-inherent",
"node/core/prospective-parachains",
"node/core/provisioner",
"node/core/pvf",
"node/core/pvf-checker",
Expand Down Expand Up @@ -207,6 +208,7 @@ fast-runtime = [ "polkadot-cli/fast-runtime" ]
runtime-metrics = [ "polkadot-cli/runtime-metrics" ]
pyroscope = ["polkadot-cli/pyroscope"]
jemalloc-allocator = ["polkadot-node-core-pvf/jemalloc-allocator", "polkadot-overseer/jemalloc-allocator"]
network-protocol-staging = ["polkadot-cli/network-protocol-staging"]

# Configuration for building a .deb package - for use with `cargo-deb`
[package.metadata.deb]
Expand Down
1 change: 1 addition & 0 deletions cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -75,3 +75,4 @@ rococo-native = ["service/rococo-native"]

malus = ["full-node", "service/malus"]
runtime-metrics = ["service/runtime-metrics", "polkadot-node-metrics/runtime-metrics"]
network-protocol-staging = ["service/network-protocol-staging"]
41 changes: 30 additions & 11 deletions node/collation-generation/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,19 @@
// along with Polkadot. If not, see <http://www.gnu.org/licenses/>.

//! The collation generation subsystem is the interface between polkadot and the collators.
//!
//! # Protocol
//!
//! On every `ActiveLeavesUpdate`:
//!
//! * If there is no collation generation config, ignore.
//! * Otherwise, for each `activated` head in the update:
//! * Determine if the para is scheduled on any core by fetching the `availability_cores` Runtime API.
//! * Determine an occupied core assumption to make about the para. Scheduled cores can make [`OccupiedCoreAssumption::Free`].
//! * TODO: What does this mean?
//! * Use the Runtime API subsystem to fetch the full validation data.
//! * Invoke the `collator`, and use its outputs to produce a [`CandidateReceipt`], signed with the configuration's `key`.
//! * Dispatch a [`CollatorProtocolMessage::DistributeCollation`](receipt, pov)`.

#![deny(missing_docs)]

Expand Down Expand Up @@ -198,15 +211,15 @@ async fn handle_new_activations<Context>(
let (scheduled_core, assumption) = match core {
CoreState::Scheduled(scheduled_core) =>
(scheduled_core, OccupiedCoreAssumption::Free),
CoreState::Occupied(_occupied_core) => {
// TODO: https://github.com/paritytech/polkadot/issues/1573
gum::trace!(
target: LOG_TARGET,
core_idx = %core_idx,
relay_parent = ?relay_parent,
"core is occupied. Keep going.",
);
continue
CoreState::Occupied(occupied_core) => {
// TODO [now]: this assumes that next up == current.
// in practice we should only set `OccupiedCoreAssumption::Included`
// when the candidate occupying the core is also of the same para.
if let Some(scheduled) = occupied_core.next_up_on_available {
(scheduled, OccupiedCoreAssumption::Included)
} else {
continue
}
},
CoreState::Free => {
gum::trace!(
Expand Down Expand Up @@ -286,6 +299,7 @@ async fn handle_new_activations<Context>(
"collation-builder",
Box::pin(async move {
let persisted_validation_data_hash = validation_data.hash();
let parent_head_data_hash = validation_data.parent_head.hash();

let (collation, result_sender) =
match (task_config.collator)(relay_parent, &validation_data).await {
Expand Down Expand Up @@ -385,8 +399,13 @@ async fn handle_new_activations<Context>(

if let Err(err) = task_sender
.send(
CollatorProtocolMessage::DistributeCollation(ccr, pov, result_sender)
.into(),
CollatorProtocolMessage::DistributeCollation(
ccr,
parent_head_data_hash,
pov,
result_sender,
)
.into(),
)
.await
{
Expand Down
4 changes: 2 additions & 2 deletions node/core/approval-voting/src/criteria.rs
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ pub(crate) fn compute_assignments(
// Ignore any cores where the assigned group is our own.
let leaving_cores = leaving_cores
.into_iter()
.filter(|&(_, _, ref g)| !is_in_backing_group(&config.validator_groups, index, *g))
.filter(|(_, _, g)| !is_in_backing_group(&config.validator_groups, index, *g))
.map(|(c_hash, core, _)| (c_hash, core))
.collect::<Vec<_>>();

Expand Down Expand Up @@ -496,7 +496,7 @@ pub(crate) fn check_assignment_cert(
return Err(InvalidAssignment(Reason::IsInBackingGroup))
}

let &(ref vrf_output, ref vrf_proof) = &assignment.vrf;
let (vrf_output, vrf_proof) = &assignment.vrf;
match assignment.kind {
AssignmentCertKind::RelayVRFModulo { sample } => {
if sample >= config.relay_vrf_modulo_samples {
Expand Down
2 changes: 1 addition & 1 deletion node/core/approval-voting/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -486,7 +486,7 @@ impl Wakeups {
.collect();

let mut pruned_wakeups = BTreeMap::new();
self.reverse_wakeups.retain(|&(ref h, ref c_h), tick| {
self.reverse_wakeups.retain(|(h, c_h), tick| {
let live = !pruned_blocks.contains(h);
if !live {
pruned_wakeups.entry(*tick).or_insert_with(HashSet::new).insert((*h, *c_h));
Expand Down
4 changes: 2 additions & 2 deletions node/core/approval-voting/src/ops.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ fn visit_and_remove_block_entry(
};

overlayed_db.delete_block_entry(&block_hash);
for &(_, ref candidate_hash) in block_entry.candidates() {
for (_, candidate_hash) in block_entry.candidates() {
let candidate = match visited_candidates.entry(*candidate_hash) {
Entry::Occupied(e) => e.into_mut(),
Entry::Vacant(e) => {
Expand Down Expand Up @@ -227,7 +227,7 @@ pub fn add_block_entry(

// read and write all updated entries.
{
for &(_, ref candidate_hash) in entry.candidates() {
for (_, candidate_hash) in entry.candidates() {
let NewCandidateInfo { candidate, backing_group, our_assignment } =
match candidate_info(candidate_hash) {
None => return Ok(Vec::new()),
Expand Down
43 changes: 31 additions & 12 deletions node/core/backing/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@
use fatality::Nested;
use futures::channel::{mpsc, oneshot};

use polkadot_node_subsystem::{messages::ValidationFailed, SubsystemError};
use polkadot_node_subsystem_util::Error as UtilError;
use polkadot_primitives::BackedCandidate;
use polkadot_node_subsystem::{messages::ValidationFailed, RuntimeApiError, SubsystemError};
use polkadot_node_subsystem_util::{runtime, Error as UtilError};
use polkadot_primitives::{BackedCandidate, ValidationCodeHash};

use crate::LOG_TARGET;

Expand All @@ -30,6 +30,18 @@ pub type FatalResult<T> = std::result::Result<T, FatalError>;
#[allow(missing_docs)]
#[fatality::fatality(splitable)]
pub enum Error {
#[fatal]
#[error("Failed to spawn background task")]
FailedToSpawnBackgroundTask,

#[fatal(forward)]
#[error("Error while accessing runtime information")]
Runtime(#[from] runtime::Error),

#[fatal]
#[error(transparent)]
BackgroundValidationMpsc(#[from] mpsc::SendError),

#[error("Candidate is not found")]
CandidateNotFound,

Expand All @@ -42,16 +54,27 @@ pub enum Error {
#[error("FetchPoV failed")]
FetchPoV,

#[fatal]
#[error("Failed to spawn background task")]
FailedToSpawnBackgroundTask,
#[error("Fetching validation code by hash failed {0:?}, {1:?}")]
FetchValidationCode(ValidationCodeHash, RuntimeApiError),

#[error("Fetching Runtime API version failed {0:?}")]
FetchRuntimeApiVersion(RuntimeApiError),

#[error("No validation code {0:?}")]
NoValidationCode(ValidationCodeHash),

#[error("Candidate rejected by prospective parachains subsystem")]
RejectedByProspectiveParachains,

#[error("ValidateFromChainState channel closed before receipt")]
ValidateFromChainState(#[source] oneshot::Canceled),
#[error("ValidateFromExhaustive channel closed before receipt")]
ValidateFromExhaustive(#[source] oneshot::Canceled),

#[error("StoreAvailableData channel closed before receipt")]
StoreAvailableData(#[source] oneshot::Canceled),

#[error("RuntimeAPISubsystem channel closed before receipt")]
RuntimeApiUnavailable(#[source] oneshot::Canceled),

#[error("a channel was closed before receipt in try_join!")]
JoinMultiple(#[source] oneshot::Canceled),

Expand All @@ -61,10 +84,6 @@ pub enum Error {
#[error(transparent)]
ValidationFailed(#[from] ValidationFailed),

#[fatal]
#[error(transparent)]
BackgroundValidationMpsc(#[from] mpsc::SendError),

#[error(transparent)]
UtilError(#[from] UtilError),

Expand Down
Loading