Parachain Consensus abstractions (#329)

* Move consensus to consensus-common crate

* Move the parachain consensus out of the collator

* Add first relay chain consensus stuff

* Remove some warnings

* Fix more stuff

* Fix collator test

* Change `ParachainConsensus` to take a mutable self

* Make everything compile

* Feedback
This commit is contained in:
Bastian Köcher
2021-02-16 12:45:30 +01:00
committed by GitHub
parent 5f5df0485a
commit d3f9c7db38
15 changed files with 707 additions and 551 deletions
+1 -1
View File
@@ -56,7 +56,7 @@ sp-offchain = { git = "https://github.com/paritytech/substrate", branch = "maste
jsonrpc-core = "15.1.0"
# Cumulus dependencies
cumulus-client-consensus = { path = "../client/consensus" }
cumulus-client-consensus-relay-chain = { path = "../client/consensus/relay-chain" }
cumulus-client-collator = { path = "../client/collator" }
cumulus-client-service = { path = "../client/service" }
cumulus-client-network = { path = "../client/network" }
+12 -7
View File
@@ -19,6 +19,7 @@ use cumulus_primitives_core::ParaId;
use cumulus_client_service::{
prepare_node_config, start_collator, start_full_node, StartCollatorParams, StartFullNodeParams,
};
use cumulus_client_consensus_relay_chain::{build_relay_chain_consensus, BuildRelayChainConsensusParams};
use parachain_runtime::RuntimeApi;
use polkadot_primitives::v0::CollatorPair;
use rococo_parachain_primitives::Block;
@@ -70,7 +71,7 @@ pub fn new_partial(
client.clone(),
);
let import_queue = cumulus_client_consensus::import_queue::import_queue(
let import_queue = cumulus_client_consensus_relay_chain::import_queue(
client.clone(),
client.clone(),
inherent_data_providers.clone(),
@@ -188,22 +189,26 @@ where
);
let spawner = task_manager.spawn_handle();
let polkadot_backend = polkadot_full_node.backend.clone();
let parachain_consensus = build_relay_chain_consensus(BuildRelayChainConsensusParams {
para_id: id,
proposer_factory,
inherent_data_providers: params.inherent_data_providers,
block_import: client.clone(),
relay_chain_client: polkadot_full_node.client.clone(),
relay_chain_backend: polkadot_full_node.backend.clone(),
});
let params = StartCollatorParams {
para_id: id,
block_import: client.clone(),
proposer_factory,
inherent_data_providers: params.inherent_data_providers,
block_status: client.clone(),
announce_block,
client: client.clone(),
task_manager: &mut task_manager,
collator_key,
polkadot_full_node,
relay_chain_full_node: polkadot_full_node,
spawner,
backend,
polkadot_backend,
parachain_consensus,
};
start_collator(params).await?;