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

Commit c1fbdee

Browse files
authored
Prospective Parachains Subsystem (#4913)
* docs and skeleton * subsystem skeleton * main loop * fragment tree basics & fmt * begin fragment trees & view * flesh out more of view update logic * further flesh out update logic * some refcount functions for fragment trees * add fatal/non-fatal errors * use non-fatal results * clear up some TODOs * ideal format for scheduling info * add a bunch of TODOs * some more fluff * extract fragment graph to submodule * begin fragment graph API * trees, not graphs * improve docs * scope and constructor for trees * add some test TODOs * limit max ancestors and store constraints * constructor * constraints: fix bug in HRMP watermarks * fragment tree population logic * set::retain * extract population logic * implement add_and_populate * fmt * add some TODOs in tests * implement child-selection * strip out old stuff based on wrong assumptions * use fatality * implement pruning * remove unused ancestor constraints * fragment tree instantiation * remove outdated comment * add message/request types and skeleton for handling * fmt * implement handle_candidate_seconded * candidate storage: handle backed * implement handle_candidate_backed * implement answer_get_backable_candidate * remove async where not needed * implement fetch_ancestry * add logic for run_iteration * add some docs * remove global allow(unused), fix warnings * make spellcheck happy (despite English) * fmt * bump Cargo.lock * replace tracing with gum * introduce PopulateFrom trait * implement GetHypotheticalDepths * revise docs slightly * first fragment tree scope test * more scope tests * test add_candidate * fmt * test retain * refactor test code * test populate is recursive * test contiguity of depth 0 is maintained * add_and_populate tests * cycle tests * remove PopulateFrom trait * fmt * test hypothetical depths (non-recursive) * have CandidateSeconded return membership * tree membership requests * Add a ProspectiveParachainsSubsystem struct * add a staging API for base constraints * add a `From` impl * add runtime API for staging_validity_constraints * implement fetch_base_constraints * implement `fetch_upcoming_paras` * remove reconstruction of candidate receipt; no obvious usecase * fmt * export message to broader module * remove last TODO * correctly export * fix compilation and add GetMinimumRelayParent request * make provisioner into a real subsystem with proper mesage bounds * fmt * fix ChannelsOut in overseer test * fix overseer tests * fix again * fmt
1 parent 3cdda45 commit c1fbdee

File tree

23 files changed

+2637
-247
lines changed

23 files changed

+2637
-247
lines changed

Cargo.lock

Lines changed: 270 additions & 209 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ members = [
6868
"node/core/chain-selection",
6969
"node/core/dispute-coordinator",
7070
"node/core/parachains-inherent",
71+
"node/core/prospective-parachains",
7172
"node/core/provisioner",
7273
"node/core/pvf",
7374
"node/core/pvf-checker",
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
[package]
2+
name = "polkadot-node-core-prospective-parachains"
3+
version = "0.9.16"
4+
authors = ["Parity Technologies <[email protected]>"]
5+
edition = "2018"
6+
7+
[dependencies]
8+
futures = "0.3.19"
9+
gum = { package = "tracing-gum", path = "../../gum" }
10+
parity-scale-codec = "2"
11+
thiserror = "1.0.30"
12+
fatality = "0.0.6"
13+
bitvec = "1"
14+
15+
polkadot-primitives = { path = "../../../primitives" }
16+
polkadot-node-primitives = { path = "../../primitives" }
17+
polkadot-node-subsystem = { path = "../../subsystem" }
18+
polkadot-node-subsystem-util = { path = "../../subsystem-util" }
19+
20+
[dev-dependencies]
21+
assert_matches = "1"
22+
polkadot-primitives-test-helpers = { path = "../../../primitives/test-helpers" }
23+
24+
[features]
25+
# If not enabled, the dispute coordinator will do nothing.
26+
disputes = []
Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
// Copyright 2022 Parity Technologies (UK) Ltd.
2+
// This file is part of Polkadot.
3+
4+
// Polkadot is free software: you can redistribute it and/or modify
5+
// it under the terms of the GNU General Public License as published by
6+
// the Free Software Foundation, either version 3 of the License, or
7+
// (at your option) any later version.
8+
9+
// Polkadot is distributed in the hope that it will be useful,
10+
// but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12+
// GNU General Public License for more details.
13+
14+
// You should have received a copy of the GNU General Public License
15+
// along with Polkadot. If not, see <http://www.gnu.org/licenses/>.
16+
17+
//! Error types.
18+
19+
use futures::channel::oneshot;
20+
21+
use polkadot_node_subsystem::{
22+
errors::{ChainApiError, RuntimeApiError},
23+
SubsystemError,
24+
};
25+
26+
use crate::LOG_TARGET;
27+
use fatality::Nested;
28+
29+
#[allow(missing_docs)]
30+
#[fatality::fatality(splitable)]
31+
pub enum Error {
32+
#[fatal]
33+
#[error("SubsystemError::Context error: {0}")]
34+
SubsystemContext(String),
35+
36+
#[fatal]
37+
#[error("Spawning a task failed: {0}")]
38+
SpawnFailed(SubsystemError),
39+
40+
#[fatal]
41+
#[error("Participation worker receiver exhausted.")]
42+
ParticipationWorkerReceiverExhausted,
43+
44+
#[fatal]
45+
#[error("Receiving message from overseer failed: {0}")]
46+
SubsystemReceive(#[source] SubsystemError),
47+
48+
#[error(transparent)]
49+
RuntimeApi(#[from] RuntimeApiError),
50+
51+
#[error(transparent)]
52+
ChainApi(#[from] ChainApiError),
53+
54+
#[error(transparent)]
55+
Subsystem(SubsystemError),
56+
57+
#[error("Request to chain API subsystem dropped")]
58+
ChainApiRequestCanceled(oneshot::Canceled),
59+
60+
#[error("Request to runtime API subsystem dropped")]
61+
RuntimeApiRequestCanceled(oneshot::Canceled),
62+
}
63+
64+
/// General `Result` type.
65+
pub type Result<R> = std::result::Result<R, Error>;
66+
/// Result for non-fatal only failures.
67+
pub type JfyiErrorResult<T> = std::result::Result<T, JfyiError>;
68+
/// Result for fatal only failures.
69+
pub type FatalResult<T> = std::result::Result<T, FatalError>;
70+
71+
/// Utility for eating top level errors and log them.
72+
///
73+
/// We basically always want to try and continue on error. This utility function is meant to
74+
/// consume top-level errors by simply logging them
75+
pub fn log_error(result: Result<()>, ctx: &'static str) -> FatalResult<()> {
76+
match result.into_nested()? {
77+
Ok(()) => Ok(()),
78+
Err(jfyi) => {
79+
gum::debug!(target: LOG_TARGET, error = ?jfyi, ctx);
80+
Ok(())
81+
},
82+
}
83+
}

0 commit comments

Comments
 (0)