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

start working on building the real overseer #1795

Merged
54 commits merged into from
Oct 28, 2020
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
Show all changes
54 commits
Select commit Hold shift + click to select a range
c4c6738
start working on building the real overseer
coriolinus Oct 8, 2020
a334432
fill in AllSubsystems internal constructors
coriolinus Oct 9, 2020
db98360
Merge remote-tracking branch 'origin/master' into prgn-real-overseer
coriolinus Oct 9, 2020
b8c9463
replace fn make_metrics with Metrics::attempt_to_register
coriolinus Oct 9, 2020
e769207
update to account for #1740
coriolinus Oct 9, 2020
98204d5
remove Metrics::register, rename Metrics::attempt_to_register
coriolinus Oct 9, 2020
b847b85
Merge remote-tracking branch 'origin/master' into prgn-real-overseer
coriolinus Oct 9, 2020
40850ac
Merge remote-tracking branch 'origin/master' into prgn-real-overseer
coriolinus Oct 13, 2020
36eaa46
add 'static bounds to real_overseer type params
coriolinus Oct 13, 2020
7334016
pass authority_discovery and network_service to real_overseer
coriolinus Oct 13, 2020
5ea441e
select a proper database configuration for the availability store db
coriolinus Oct 13, 2020
0720f5d
use subdirectory for av-store database path
coriolinus Oct 14, 2020
8185a55
apply Basti's patch which avoids needing to parameterize everything o…
coriolinus Oct 15, 2020
801063d
simplify path extraction
ordian Oct 15, 2020
99a61f9
get all tests to compile
coriolinus Oct 15, 2020
79abc50
Fix Prometheus double-registry error
coriolinus Oct 19, 2020
ff63eb2
authorities must have authority discovery, but not necessarily overse…
coriolinus Oct 19, 2020
1b13b29
fix broken SpawnedSubsystem impls
coriolinus Oct 20, 2020
16ce6cb
use prometheus properly
coriolinus Oct 20, 2020
3a0d1a6
get av-store subsystem to actually run properly and not die on first …
coriolinus Oct 21, 2020
ec91b9b
Merge remote-tracking branch 'origin/master' into prgn-real-overseer
coriolinus Oct 21, 2020
1b52a0e
typo fix: incomming -> incoming
coriolinus Oct 21, 2020
c6e78be
don't disable authority discovery in test nodes
coriolinus Oct 21, 2020
f369874
Merge remote-tracking branch 'origin/master' into prgn-real-overseer
bkchr Oct 21, 2020
dba976f
Fix rococo-v1 missing session keys
bkchr Oct 21, 2020
a4642e1
Update node/core/av-store/Cargo.toml
montekki Oct 23, 2020
239c182
try dummying out av-store on non-full-nodes
coriolinus Oct 23, 2020
96ae179
overseer and subsystems are required only for full nodes
coriolinus Oct 23, 2020
f3fd10f
Reduce the amount of warnings on browser target
montekki Oct 23, 2020
ee23259
Fix two more warnings
montekki Oct 23, 2020
98aa01d
InclusionInherent should actually have an Inherent module on rococo
montekki Oct 23, 2020
ba768b4
Ancestry: don't return genesis' parent hash
Oct 24, 2020
57418fb
Update Cargo.lock
montekki Oct 24, 2020
a395acb
Merge remote-tracking branch 'origin/master' into prgn-real-overseer
coriolinus Oct 26, 2020
b953b01
fix broken test
coriolinus Oct 26, 2020
25ec0be
update test script: specify chainspec as script argument
coriolinus Oct 26, 2020
2449358
Apply suggestions from code review
coriolinus Oct 26, 2020
ffc37f2
Update node/service/src/lib.rs
coriolinus Oct 26, 2020
6ee3d7b
Merge branch 'paritytech/master' into real-overseer
mxinden Oct 26, 2020
919d530
node/service/src/lib: Return error via ? operator
mxinden Oct 26, 2020
af37ece
Merge remote-tracking branch 'mxinden/real-overseer' into prgn-real-o…
coriolinus Oct 26, 2020
244e980
Merge remote-tracking branch 'origin/master' into prgn-real-overseer
coriolinus Oct 27, 2020
cd97445
post-merge blues
coriolinus Oct 27, 2020
d1d4163
add is_collator flag
coriolinus Oct 27, 2020
283f426
prevent occasional av-store test panic
coriolinus Oct 27, 2020
2ddc5ee
simplify fix; expand application
coriolinus Oct 27, 2020
2bf2980
run authority_discovery in Role::Discover when collating
coriolinus Oct 27, 2020
ac0a90f
distinguish between proposer closed channel errors
coriolinus Oct 27, 2020
566fd21
add IsCollator enum, remove is_collator CLI flag
coriolinus Oct 27, 2020
0f4a86e
improve formatting
coriolinus Oct 27, 2020
558844d
remove nop loop
coriolinus Oct 27, 2020
d16f502
Fix some stuff
bkchr Oct 27, 2020
51ce190
Merge remote-tracking branch 'origin/master' into prgn-real-overseer
coriolinus Oct 28, 2020
5791bb4
Merge branch 'prgn-real-overseer' of github.com:paritytech/polkadot i…
coriolinus Oct 28, 2020
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
19 changes: 18 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion node/network/collator-protocol/src/collator_side.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ use polkadot_node_subsystem_util::{
};

#[derive(Clone, Default)]
pub(super) struct Metrics(Option<MetricsInner>);
pub struct Metrics(Option<MetricsInner>);

impl Metrics {
fn on_advertisment_made(&self) {
Expand Down
19 changes: 8 additions & 11 deletions node/network/collator-protocol/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ use polkadot_node_network_protocol::{
use polkadot_primitives::v1::CollatorId;
use polkadot_node_subsystem_util::{
self as util,
metrics::{self, prometheus},
metrics::prometheus,
};

mod collator_side;
Expand Down Expand Up @@ -71,28 +71,25 @@ impl From<util::validator_discovery::Error> for Error {

type Result<T> = std::result::Result<T, Error>;

enum ProtocolSide {
/// What side of the collator protocol is being engaged
pub enum ProtocolSide {
/// Validators operate on the relay chain.
Validator(validator_side::Metrics),
/// Collators operate on a parachain.
Collator(CollatorId, collator_side::Metrics),
}

/// The collator protocol subsystem.
pub struct CollatorProtocolSubsystem {
protocol_side: ProtocolSide,
protocol_side: ProtocolSide,
}

impl CollatorProtocolSubsystem {
/// Start the collator protocol.
/// If `id` is `Some` this is a collator side of the protocol.
/// If `id` is `None` this is a validator side of the protocol.
/// If `id` is `None` this is a validator side of the protocol.
/// Caller must provide a registry for prometheus metrics.
pub fn new(id: Option<CollatorId>, registry: Option<&prometheus::Registry>) -> Self {
use metrics::Metrics;
let protocol_side = match id {
Some(id) => ProtocolSide::Collator(id, collator_side::Metrics::register(registry)),
None => ProtocolSide::Validator(validator_side::Metrics::register(registry)),
};

pub fn new(protocol_side: ProtocolSide) -> Self {
coriolinus marked this conversation as resolved.
Show resolved Hide resolved
Self {
protocol_side,
}
Expand Down
2 changes: 1 addition & 1 deletion node/network/collator-protocol/src/validator_side.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ const COST_REPORT_BAD: Rep = Rep::new(-50, "A collator was reported by another s
const BENEFIT_NOTIFY_GOOD: Rep = Rep::new(50, "A collator was noted good by another subsystem");

#[derive(Clone, Default)]
pub(super) struct Metrics(Option<MetricsInner>);
pub struct Metrics(Option<MetricsInner>);

impl Metrics {
fn on_request(&self, succeeded: std::result::Result<(), ()>) {
Expand Down
9 changes: 9 additions & 0 deletions node/network/statement-distribution/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,15 @@ impl<C> Subsystem<C> for StatementDistribution
}
}

impl StatementDistribution {
/// Create a new Statement Distribution Subsystem
pub fn new(metrics: Metrics) -> StatementDistribution {
StatementDistribution {
metrics,
}
}
}

/// Tracks our impression of a single peer's view of the candidates a validator has seconded
/// for a given relay-parent.
///
Expand Down
2 changes: 1 addition & 1 deletion node/overseer/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1169,7 +1169,7 @@ where

let active_leaves = HashMap::new();

let metrics = <Metrics as metrics::Metrics>::register(prometheus_registry);
let metrics = <Metrics as metrics::Metrics>::register(prometheus_registry)?;
let activation_external_listeners = HashMap::new();

let this = Self {
Expand Down
28 changes: 24 additions & 4 deletions node/service/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ sc-client-api = { git = "https://github.com/paritytech/substrate", branch = "mas
sc-client-db = { git = "https://github.com/paritytech/substrate", branch = "master" }
sc-consensus = { git = "https://github.com/paritytech/substrate", branch = "master" }
sc-executor = { git = "https://github.com/paritytech/substrate", branch = "master" }
sc-keystore = { git = "https://github.com/paritytech/substrate", branch = "master" }
sc-network = { git = "https://github.com/paritytech/substrate", branch = "master" }
sc-transaction-pool = { git = "https://github.com/paritytech/substrate", branch = "master" }
service = { package = "sc-service", git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
Expand All @@ -32,6 +31,7 @@ sp-block-builder = { git = "https://github.com/paritytech/substrate", branch = "
sp-blockchain = { git = "https://github.com/paritytech/substrate", branch = "master" }
sp-core = { git = "https://github.com/paritytech/substrate", branch = "master" }
sp-io = { git = "https://github.com/paritytech/substrate", branch = "master" }
sp-keystore = { git = "https://github.com/paritytech/substrate", branch = "master" }
sp-offchain = { package = "sp-offchain", git = "https://github.com/paritytech/substrate", branch = "master" }
sp-runtime = { git = "https://github.com/paritytech/substrate", branch = "master" }
sp-session = { git = "https://github.com/paritytech/substrate", branch = "master" }
Expand Down Expand Up @@ -61,16 +61,36 @@ serde = { version = "1.0.102", features = ["derive"] }
slog = "2.5.2"

# Polkadot
kusama-runtime = { path = "../../runtime/kusama" }
polkadot-node-core-proposer = { path = "../core/proposer" }
polkadot-overseer = { path = "../overseer" }
polkadot-parachain = { path = "../../parachain" }
polkadot-primitives = { path = "../../primitives" }
polkadot-rpc = { path = "../../rpc" }
polkadot-runtime = { path = "../../runtime/polkadot" }
polkadot-subsystem = { package = "polkadot-node-subsystem", path = "../subsystem" }
rococo-runtime = { package = "rococo-v1-runtime", path = "../../runtime/rococo-v1" }
polkadot-node-subsystem-util = { path = "../subsystem-util" }

# Polkadot Runtimes
polkadot-runtime = { path = "../../runtime/polkadot" }
kusama-runtime = { path = "../../runtime/kusama" }
westend-runtime = { path = "../../runtime/westend" }
rococo-runtime = { package = "rococo-v1-runtime", path = "../../runtime/rococo-v1" }

# Polkadot Subsystems
polkadot-availability-bitfield-distribution = { path = "../network/bitfield-distribution" }
polkadot-availability-distribution = { path = "../network/availability-distribution" }
polkadot-collator-protocol = { path = "../network/collator-protocol" }
polkadot-network-bridge = { path = "../network/bridge" }
polkadot-node-collation-generation = { path = "../collation-generation" }
polkadot-node-core-av-store = { path = "../core/av-store" }
polkadot-node-core-backing = { path = "../core/backing" }
polkadot-node-core-bitfield-signing = { path = "../core/bitfield-signing" }
polkadot-node-core-candidate-selection = { path = "../core/candidate-selection" }
polkadot-node-core-candidate-validation = { path = "../core/candidate-validation" }
polkadot-node-core-chain-api = { path = "../core/chain-api" }
polkadot-node-core-provisioner = { path = "../core/provisioner" }
polkadot-node-core-runtime-api = { path = "../core/runtime-api" }
polkadot-pov-distribution = { path = "../network/pov-distribution" }
polkadot-statement-distribution = { path = "../network/statement-distribution" }

[dev-dependencies]
polkadot-test-runtime-client = { path = "../../runtime/test-runtime/client" }
Expand Down
131 changes: 107 additions & 24 deletions node/service/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,18 @@ mod client;

use grandpa::{self, FinalityProofProvider as GrandpaFinalityProofProvider};
use log::info;
use polkadot_node_core_av_store::Config as AvailabilityConfig;
use polkadot_node_core_proposer::ProposerFactory;
use polkadot_overseer::{AllSubsystems, BlockInfo, Overseer, OverseerHandler};
use polkadot_subsystem::DummySubsystem;
use polkadot_primitives::v1::ParachainHost;
use prometheus_endpoint::Registry;
use authority_discovery::Service as AuthorityDiscoveryService;
use sc_client_api::ExecutorProvider;
use sc_executor::native_executor_instance;
use service::{error::Error as ServiceError, RpcHandlers};
use sp_blockchain::HeaderBackend;
use sp_core::traits::SpawnNamed;
use sp_keystore::SyncCryptoStorePtr;
use sp_trie::PrefixedMemoryDB;
use std::sync::Arc;
use std::time::Duration;
Expand All @@ -42,7 +45,7 @@ pub use chain_spec::{PolkadotChainSpec, KusamaChainSpec, WestendChainSpec, Rococ
pub use codec::Codec;
pub use consensus_common::{Proposal, SelectChain, BlockImport, RecordProof, block_validation::Chain};
pub use polkadot_parachain::wasm_executor::run_worker as run_validation_worker;
pub use polkadot_primitives::v1::{Block, BlockId, CollatorId, Id as ParaId};
pub use polkadot_primitives::v1::{Block, BlockId, CollatorId, Hash, Id as ParaId};
pub use sc_client_api::{Backend, ExecutionStrategy, CallExecutor};
pub use sc_consensus::LongestChain;
pub use sc_executor::NativeExecutionDispatch;
Expand Down Expand Up @@ -266,34 +269,105 @@ fn new_partial<RuntimeApi, Executor>(config: &mut Configuration) -> Result<
})
}

fn real_overseer<S: SpawnNamed>(
fn real_overseer<Spawner, RuntimeClient>(
montekki marked this conversation as resolved.
Show resolved Hide resolved
leaves: impl IntoIterator<Item = BlockInfo>,
prometheus_registry: Option<&Registry>,
s: S,
) -> Result<(Overseer<S>, OverseerHandler), ServiceError> {
keystore: SyncCryptoStorePtr,
runtime_client: RuntimeClient,
availability_config: AvailabilityConfig,
network_service: Arc<sc_network::NetworkService<Block, Hash>>,
authority_discovery: AuthorityDiscoveryService,
registry: Option<&Registry>,
spawner: Spawner,
) -> Result<(Overseer<Spawner>, OverseerHandler), ServiceError>
where
RuntimeClient: ProvideRuntimeApi<Block> + HeaderBackend<Block>,
RuntimeClient::Api: ParachainHost<Block>,
Spawner: SpawnNamed + Clone + Unpin,
{
use polkadot_node_subsystem_util::metrics::Metrics;

use polkadot_availability_distribution::AvailabilityDistributionSubsystem;
use polkadot_node_core_av_store::AvailabilityStoreSubsystem;
use polkadot_availability_bitfield_distribution::BitfieldDistribution as BitfieldDistributionSubsystem;
use polkadot_node_core_bitfield_signing::BitfieldSigningSubsystem;
use polkadot_node_core_backing::CandidateBackingSubsystem;
use polkadot_node_core_candidate_selection::CandidateSelectionSubsystem;
use polkadot_node_core_candidate_validation::CandidateValidationSubsystem;
use polkadot_node_core_chain_api::ChainApiSubsystem;
use polkadot_node_collation_generation::CollationGenerationSubsystem;
use polkadot_collator_protocol::{CollatorProtocolSubsystem, ProtocolSide};
use polkadot_network_bridge::NetworkBridge as NetworkBridgeSubsystem;
use polkadot_pov_distribution::PoVDistribution as PoVDistributionSubsystem;
use polkadot_node_core_provisioner::ProvisioningSubsystem as ProvisionerSubsystem;
use polkadot_node_core_runtime_api::RuntimeApiSubsystem;
use polkadot_statement_distribution::StatementDistribution as StatementDistributionSubsystem;

let all_subsystems = AllSubsystems {
candidate_validation: DummySubsystem,
candidate_backing: DummySubsystem,
candidate_selection: DummySubsystem,
statement_distribution: DummySubsystem,
availability_distribution: DummySubsystem,
bitfield_signing: DummySubsystem,
bitfield_distribution: DummySubsystem,
provisioner: DummySubsystem,
pov_distribution: DummySubsystem,
runtime_api: DummySubsystem,
availability_store: DummySubsystem,
network_bridge: DummySubsystem,
chain_api: DummySubsystem,
collation_generation: DummySubsystem,
collator_protocol: DummySubsystem,
availability_distribution: AvailabilityDistributionSubsystem::new(
keystore.clone(),
Metrics::register(registry)?,
),
availability_store: AvailabilityStoreSubsystem::new_on_disk(
availability_config,
Metrics::register(registry)?,
)?,
bitfield_distribution: BitfieldDistributionSubsystem::new(
Metrics::register(registry)?,
),
bitfield_signing: BitfieldSigningSubsystem::new(
spawner.clone(),
keystore.clone(), Metrics::register(registry)?,
coriolinus marked this conversation as resolved.
Show resolved Hide resolved
),
candidate_backing: CandidateBackingSubsystem::new(
spawner.clone(),
keystore.clone(),
Metrics::register(registry)?,
),
candidate_selection: CandidateSelectionSubsystem::new(
spawner.clone(),
(),
Metrics::register(registry)?,
),
candidate_validation: CandidateValidationSubsystem::new(
spawner.clone(),
Metrics::register(registry)?,
),
chain_api: ChainApiSubsystem::new(
runtime_client,
Metrics::register(registry)?,
),
collation_generation: CollationGenerationSubsystem::new(
Metrics::register(registry)?,
),
collator_protocol: CollatorProtocolSubsystem::new(
ProtocolSide::Validator(Metrics::register(registry)?),
),
network_bridge: NetworkBridgeSubsystem::new(
network_service,
authority_discovery,
),
pov_distribution: PoVDistributionSubsystem::new(
Metrics::register(registry)?,
),
provisioner: ProvisionerSubsystem::new(
spawner.clone(),
(),
Metrics::register(registry)?,
),
runtime_api: RuntimeApiSubsystem::new(
runtime_client,
Metrics::register(registry)?,
),
statement_distribution: StatementDistributionSubsystem::new(
Metrics::register(registry)?,
),
};

Overseer::new(
leaves,
all_subsystems,
prometheus_registry,
s,
registry,
spawner,
).map_err(|e| ServiceError::Other(format!("Failed to create an Overseer: {:?}", e)))
}

Expand Down Expand Up @@ -418,7 +492,16 @@ pub fn new_full<RuntimeApi, Executor>(
})
.collect();

let (overseer, handler) = real_overseer(leaves, prometheus_registry.as_ref(), spawner)?;
let (overseer, handler) = real_overseer(
leaves,
keystore_container.sync_keystore(),
overseer_client,
unimplemented!("TODO: availability_config"),
unimplemented!("TODO: network_service"),
unimplemented!("TODO: authority_discovery"),
prometheus_registry.as_ref(),
spawner,
)?;
let handler_clone = handler.clone();

task_manager.spawn_essential_handle().spawn_blocking("overseer", Box::pin(async move {
Expand Down
21 changes: 9 additions & 12 deletions node/subsystem-util/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -462,18 +462,15 @@ pub mod metrics {
/// Try to register metrics in the Prometheus registry.
fn try_register(registry: &prometheus::Registry) -> Result<Self, prometheus::PrometheusError>;

/// Convience method to register metrics in the optional Prometheus registry.
/// If the registration fails, prints a warning and returns `Default::default()`.
fn register(registry: Option<&prometheus::Registry>) -> Self {
registry.map(|r| {
match Self::try_register(r) {
Err(e) => {
log::warn!("Failed to register metrics: {:?}", e);
Default::default()
},
Ok(metrics) => metrics,
}
}).unwrap_or_default()
// Convenience method to register metrics in the optional Promethius registry.
//
// If no registry is provided, returns `Default::default()`. Otherwise, returns the same
// thing that `try_register` does.
fn register(registry: Option<&prometheus::Registry>) -> Result<Self, prometheus::PrometheusError> {
match registry {
None => Ok(Self::default()),
Some(registry) => Self::try_register(registry),
}
}
}

Expand Down
Loading