mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-05-30 17:31:03 +00:00
Collate only if --validator is given (#161)
This commit is contained in:
Generated
+1222
-1212
File diff suppressed because it is too large
Load Diff
@@ -47,8 +47,8 @@ use sp_runtime::{
|
|||||||
use polkadot_collator::{
|
use polkadot_collator::{
|
||||||
BuildParachainContext, Network as CollatorNetwork, ParachainContext, RuntimeApiCollection,
|
BuildParachainContext, Network as CollatorNetwork, ParachainContext, RuntimeApiCollection,
|
||||||
};
|
};
|
||||||
use polkadot_primitives::{
|
use polkadot_primitives::v0::{
|
||||||
parachain::{self, BlockData, GlobalValidationSchedule, Id as ParaId, LocalValidationData},
|
self as parachain, BlockData, GlobalValidationData, Id as ParaId, LocalValidationData,
|
||||||
Block as PBlock, DownwardMessage, Hash as PHash,
|
Block as PBlock, DownwardMessage, Hash as PHash,
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -105,7 +105,7 @@ impl<Block: BlockT, PF, BI, BS> Collator<Block, PF, BI, BS> {
|
|||||||
/// Get the inherent data with validation function parameters injected
|
/// Get the inherent data with validation function parameters injected
|
||||||
fn inherent_data(
|
fn inherent_data(
|
||||||
inherent_providers: InherentDataProviders,
|
inherent_providers: InherentDataProviders,
|
||||||
global_validation: GlobalValidationSchedule,
|
global_validation: GlobalValidationData,
|
||||||
local_validation: LocalValidationData,
|
local_validation: LocalValidationData,
|
||||||
downward_messages: DownwardMessagesType,
|
downward_messages: DownwardMessagesType,
|
||||||
) -> Option<InherentData> {
|
) -> Option<InherentData> {
|
||||||
@@ -239,7 +239,7 @@ where
|
|||||||
fn produce_candidate(
|
fn produce_candidate(
|
||||||
&mut self,
|
&mut self,
|
||||||
relay_chain_parent: PHash,
|
relay_chain_parent: PHash,
|
||||||
global_validation: GlobalValidationSchedule,
|
global_validation: GlobalValidationData,
|
||||||
local_validation: LocalValidationData,
|
local_validation: LocalValidationData,
|
||||||
downward_messages: Vec<DownwardMessage>,
|
downward_messages: Vec<DownwardMessage>,
|
||||||
) -> Self::ProduceCandidate {
|
) -> Self::ProduceCandidate {
|
||||||
@@ -493,10 +493,10 @@ mod tests {
|
|||||||
use std::time::Duration;
|
use std::time::Duration;
|
||||||
|
|
||||||
use polkadot_collator::{collate, SignedStatement};
|
use polkadot_collator::{collate, SignedStatement};
|
||||||
use polkadot_primitives::parachain::Id as ParaId;
|
use polkadot_primitives::v0::Id as ParaId;
|
||||||
|
|
||||||
use sp_blockchain::Result as ClientResult;
|
use sp_blockchain::Result as ClientResult;
|
||||||
use sp_core::testing::SpawnBlockingExecutor;
|
use sp_core::testing::TaskExecutor;
|
||||||
use sp_inherents::InherentData;
|
use sp_inherents::InherentData;
|
||||||
use sp_keyring::Sr25519Keyring;
|
use sp_keyring::Sr25519Keyring;
|
||||||
use sp_runtime::traits::{DigestFor, Header as HeaderT};
|
use sp_runtime::traits::{DigestFor, Header as HeaderT};
|
||||||
@@ -601,7 +601,7 @@ mod tests {
|
|||||||
fn collates_produces_a_block() {
|
fn collates_produces_a_block() {
|
||||||
let id = ParaId::from(100);
|
let id = ParaId::from(100);
|
||||||
let _ = env_logger::try_init();
|
let _ = env_logger::try_init();
|
||||||
let spawner = SpawnBlockingExecutor::new();
|
let spawner = TaskExecutor::new();
|
||||||
let announce_block = |_, _| ();
|
let announce_block = |_, _| ();
|
||||||
let block_announce_validator = DelayedBlockAnnounceValidator::new();
|
let block_announce_validator = DelayedBlockAnnounceValidator::new();
|
||||||
let client = Arc::new(TestClientBuilder::new().build());
|
let client = Arc::new(TestClientBuilder::new().build());
|
||||||
@@ -639,7 +639,7 @@ mod tests {
|
|||||||
let collation = collate(
|
let collation = collate(
|
||||||
Default::default(),
|
Default::default(),
|
||||||
id,
|
id,
|
||||||
GlobalValidationSchedule {
|
GlobalValidationData {
|
||||||
block_number: 0,
|
block_number: 0,
|
||||||
max_code_size: 0,
|
max_code_size: 0,
|
||||||
max_head_data_size: 0,
|
max_head_data_size: 0,
|
||||||
|
|||||||
@@ -26,9 +26,8 @@ use sp_runtime::{
|
|||||||
traits::{Block as BlockT, Header as HeaderT},
|
traits::{Block as BlockT, Header as HeaderT},
|
||||||
};
|
};
|
||||||
|
|
||||||
use polkadot_primitives::{
|
use polkadot_primitives::v0::{
|
||||||
parachain::{Id as ParaId, ParachainHost},
|
Id as ParaId, ParachainHost, Block as PBlock, Hash as PHash,
|
||||||
Block as PBlock, Hash as PHash,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
use codec::Decode;
|
use codec::Decode;
|
||||||
|
|||||||
@@ -32,11 +32,10 @@ use sp_runtime::{
|
|||||||
|
|
||||||
use polkadot_collator::Network as CollatorNetwork;
|
use polkadot_collator::Network as CollatorNetwork;
|
||||||
use polkadot_network::legacy::gossip::{GossipMessage, GossipStatement};
|
use polkadot_network::legacy::gossip::{GossipMessage, GossipStatement};
|
||||||
use polkadot_primitives::{
|
use polkadot_primitives::v0::{
|
||||||
parachain::{Id as ParaId, ParachainHost},
|
Id as ParaId, ParachainHost, Block as PBlock, Hash as PHash,
|
||||||
Block as PBlock, Hash as PHash,
|
|
||||||
};
|
};
|
||||||
use polkadot_statement_table::{SignedStatement, Statement};
|
use polkadot_statement_table::v0::{SignedStatement, Statement};
|
||||||
use polkadot_validation::check_statement;
|
use polkadot_validation::check_statement;
|
||||||
|
|
||||||
use cumulus_primitives::HeadData;
|
use cumulus_primitives::HeadData;
|
||||||
|
|||||||
@@ -16,13 +16,10 @@
|
|||||||
|
|
||||||
use super::*;
|
use super::*;
|
||||||
use cumulus_test_runtime::{Block, Header};
|
use cumulus_test_runtime::{Block, Header};
|
||||||
use polkadot_primitives::{
|
use polkadot_primitives::v0::{
|
||||||
parachain::{
|
AbridgedCandidateReceipt, Chain, CollatorId, DutyRoster, GlobalValidationData,
|
||||||
AbridgedCandidateReceipt, Chain, CollatorId, DutyRoster, GlobalValidationSchedule,
|
Id as ParaId, LocalValidationData, ParachainHost, Retriable, SigningContext,
|
||||||
Id as ParaId, LocalValidationData, ParachainHost, Retriable, SigningContext,
|
ValidationCode, ValidatorId, Block as PBlock, Hash as PHash, Header as PHeader,
|
||||||
ValidationCode, ValidatorId,
|
|
||||||
},
|
|
||||||
Block as PBlock, Hash as PHash, Header as PHeader,
|
|
||||||
};
|
};
|
||||||
use polkadot_test_runtime_client::{
|
use polkadot_test_runtime_client::{
|
||||||
DefaultTestClientBuilderExt, TestClient, TestClientBuilder, TestClientBuilderExt,
|
DefaultTestClientBuilderExt, TestClient, TestClientBuilder, TestClientBuilderExt,
|
||||||
@@ -418,7 +415,7 @@ sp_api::mock_impl_runtime_apis! {
|
|||||||
Some(ValidationCode(Vec::new()))
|
Some(ValidationCode(Vec::new()))
|
||||||
}
|
}
|
||||||
|
|
||||||
fn global_validation_schedule() -> GlobalValidationSchedule {
|
fn global_validation_data() -> GlobalValidationData {
|
||||||
Default::default()
|
Default::default()
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -440,7 +437,7 @@ sp_api::mock_impl_runtime_apis! {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn downward_messages(_: ParaId) -> Vec<polkadot_primitives::DownwardMessage> {
|
fn downward_messages(_: ParaId) -> Vec<polkadot_primitives::v0::DownwardMessage> {
|
||||||
Vec::new()
|
Vec::new()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ parachain = { package = "polkadot-parachain", git = "https://github.com/parityte
|
|||||||
# Substrate dependencies
|
# Substrate dependencies
|
||||||
frame-support = { git = "https://github.com/paritytech/substrate", branch = "cumulus-branch", default-features = false }
|
frame-support = { git = "https://github.com/paritytech/substrate", branch = "cumulus-branch", default-features = false }
|
||||||
pallet-balances = { git = "https://github.com/paritytech/substrate", branch = "cumulus-branch", default-features = false }
|
pallet-balances = { git = "https://github.com/paritytech/substrate", branch = "cumulus-branch", default-features = false }
|
||||||
sp-core = { git = "https://github.com/paritytech/substrate", branch = "cumulus-branch", version = "2.0.0-dev", default-features = false }
|
sp-core = { git = "https://github.com/paritytech/substrate", branch = "cumulus-branch", version = "2.0.0-rc5", default-features = false }
|
||||||
sp-inherents = { git = "https://github.com/paritytech/substrate", branch = "cumulus-branch", default-features = false }
|
sp-inherents = { git = "https://github.com/paritytech/substrate", branch = "cumulus-branch", default-features = false }
|
||||||
sp-io = { git = "https://github.com/paritytech/substrate", branch = "cumulus-branch", default-features = false }
|
sp-io = { git = "https://github.com/paritytech/substrate", branch = "cumulus-branch", default-features = false }
|
||||||
sp-std = { git = "https://github.com/paritytech/substrate", branch = "cumulus-branch", default-features = false }
|
sp-std = { git = "https://github.com/paritytech/substrate", branch = "cumulus-branch", default-features = false }
|
||||||
|
|||||||
@@ -18,7 +18,7 @@
|
|||||||
|
|
||||||
use codec::{Decode, Encode};
|
use codec::{Decode, Encode};
|
||||||
use polkadot_parachain::primitives::{RelayChainBlockNumber, ValidationParams};
|
use polkadot_parachain::primitives::{RelayChainBlockNumber, ValidationParams};
|
||||||
use polkadot_primitives::parachain::{GlobalValidationSchedule, LocalValidationData};
|
use polkadot_primitives::v0::{GlobalValidationData, LocalValidationData};
|
||||||
|
|
||||||
/// Validation Function Parameters
|
/// Validation Function Parameters
|
||||||
///
|
///
|
||||||
@@ -48,8 +48,8 @@ impl From<&ValidationParams> for ValidationFunctionParams {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<(GlobalValidationSchedule, LocalValidationData)> for ValidationFunctionParams {
|
impl From<(GlobalValidationData, LocalValidationData)> for ValidationFunctionParams {
|
||||||
fn from(t: (GlobalValidationSchedule, LocalValidationData)) -> Self {
|
fn from(t: (GlobalValidationData, LocalValidationData)) -> Self {
|
||||||
let (global_validation, local_validation) = t;
|
let (global_validation, local_validation) = t;
|
||||||
ValidationFunctionParams {
|
ValidationFunctionParams {
|
||||||
max_code_size: global_validation.max_code_size,
|
max_code_size: global_validation.max_code_size,
|
||||||
|
|||||||
@@ -16,7 +16,7 @@
|
|||||||
|
|
||||||
//! XMCP related primitives
|
//! XMCP related primitives
|
||||||
|
|
||||||
use polkadot_primitives::parachain::Id as ParaId;
|
use polkadot_primitives::v0::Id as ParaId;
|
||||||
use sp_std::vec::Vec;
|
use sp_std::vec::Vec;
|
||||||
|
|
||||||
/// A raw XCMP message that is being send between two Parachain's.
|
/// A raw XCMP message that is being send between two Parachain's.
|
||||||
|
|||||||
@@ -31,15 +31,18 @@ sp-inherents = { git = "https://github.com/paritytech/substrate", branch = "cumu
|
|||||||
sp-consensus = { git = "https://github.com/paritytech/substrate", branch = "cumulus-branch" }
|
sp-consensus = { git = "https://github.com/paritytech/substrate", branch = "cumulus-branch" }
|
||||||
sc-consensus = { git = "https://github.com/paritytech/substrate", branch = "cumulus-branch" }
|
sc-consensus = { git = "https://github.com/paritytech/substrate", branch = "cumulus-branch" }
|
||||||
sc-cli = { git = "https://github.com/paritytech/substrate", branch = "cumulus-branch" }
|
sc-cli = { git = "https://github.com/paritytech/substrate", branch = "cumulus-branch" }
|
||||||
|
sc-client-api = { git = "https://github.com/paritytech/substrate", branch = "cumulus-branch" }
|
||||||
sc-executor = { git = "https://github.com/paritytech/substrate", branch = "cumulus-branch" }
|
sc-executor = { git = "https://github.com/paritytech/substrate", branch = "cumulus-branch" }
|
||||||
sc-service = { git = "https://github.com/paritytech/substrate", branch = "cumulus-branch" }
|
sc-service = { git = "https://github.com/paritytech/substrate", branch = "cumulus-branch" }
|
||||||
sc-transaction-pool = { git = "https://github.com/paritytech/substrate", branch = "cumulus-branch" }
|
sc-transaction-pool = { git = "https://github.com/paritytech/substrate", branch = "cumulus-branch" }
|
||||||
sp-transaction-pool = { git = "https://github.com/paritytech/substrate", branch = "cumulus-branch" }
|
sp-transaction-pool = { git = "https://github.com/paritytech/substrate", branch = "cumulus-branch" }
|
||||||
sc-network = { git = "https://github.com/paritytech/substrate", branch = "cumulus-branch" }
|
sc-network = { git = "https://github.com/paritytech/substrate", branch = "cumulus-branch" }
|
||||||
sc-basic-authorship = { git = "https://github.com/paritytech/substrate", branch = "cumulus-branch", version = "0.8.0-alpha.5" }
|
sc-basic-authorship = { git = "https://github.com/paritytech/substrate", branch = "cumulus-branch", version = "0.8.0-rc5" }
|
||||||
sp-timestamp = { git = "https://github.com/paritytech/substrate", branch = "cumulus-branch" }
|
sp-timestamp = { git = "https://github.com/paritytech/substrate", branch = "cumulus-branch" }
|
||||||
|
sp-trie = { git = "https://github.com/paritytech/substrate", branch = "cumulus-branch" }
|
||||||
sc-finality-grandpa = { git = "https://github.com/paritytech/substrate", branch = "cumulus-branch" }
|
sc-finality-grandpa = { git = "https://github.com/paritytech/substrate", branch = "cumulus-branch" }
|
||||||
sc-informant = { git = "https://github.com/paritytech/substrate", branch = "cumulus-branch" }
|
sc-informant = { git = "https://github.com/paritytech/substrate", branch = "cumulus-branch" }
|
||||||
|
sc-chain-spec = { git = "https://github.com/paritytech/substrate", branch = "cumulus-branch" }
|
||||||
|
|
||||||
# Cumulus dependencies
|
# Cumulus dependencies
|
||||||
cumulus-consensus = { path = "../../consensus" }
|
cumulus-consensus = { path = "../../consensus" }
|
||||||
@@ -72,6 +75,5 @@ polkadot-test-service = { git = "https://github.com/paritytech/polkadot", branch
|
|||||||
|
|
||||||
# Substrate dependencies
|
# Substrate dependencies
|
||||||
pallet-sudo = { git = "https://github.com/paritytech/substrate", branch = "cumulus-branch" }
|
pallet-sudo = { git = "https://github.com/paritytech/substrate", branch = "cumulus-branch" }
|
||||||
sc-client-api = { git = "https://github.com/paritytech/substrate", branch = "cumulus-branch" }
|
|
||||||
substrate-test-client = { git = "https://github.com/paritytech/substrate", branch = "cumulus-branch" }
|
substrate-test-client = { git = "https://github.com/paritytech/substrate", branch = "cumulus-branch" }
|
||||||
substrate-test-runtime-client = { git = "https://github.com/paritytech/substrate", branch = "cumulus-branch" }
|
substrate-test-runtime-client = { git = "https://github.com/paritytech/substrate", branch = "cumulus-branch" }
|
||||||
|
|||||||
@@ -152,8 +152,10 @@ pub fn run() -> Result<()> {
|
|||||||
Some(Subcommand::Base(subcommand)) => {
|
Some(Subcommand::Base(subcommand)) => {
|
||||||
let runner = cli.create_runner(subcommand)?;
|
let runner = cli.create_runner(subcommand)?;
|
||||||
|
|
||||||
runner.run_subcommand(subcommand, |config| {
|
runner.run_subcommand(subcommand, |mut config| {
|
||||||
Ok(new_full_start!(config).0.to_chain_ops_parts())
|
let params = crate::service::new_partial(&mut config)?;
|
||||||
|
|
||||||
|
Ok((params.client, params.backend, params.import_queue, params.task_manager))
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
Some(Subcommand::ExportGenesisState(params)) => {
|
Some(Subcommand::ExportGenesisState(params)) => {
|
||||||
@@ -185,7 +187,7 @@ pub fn run() -> Result<()> {
|
|||||||
let id = ParaId::from(cli.run.parachain_id);
|
let id = ParaId::from(cli.run.parachain_id);
|
||||||
|
|
||||||
let parachain_account =
|
let parachain_account =
|
||||||
AccountIdConversion::<polkadot_primitives::AccountId>::into_account(&id);
|
AccountIdConversion::<polkadot_primitives::v0::AccountId>::into_account(&id);
|
||||||
|
|
||||||
let block = generate_genesis_state(id)?;
|
let block = generate_genesis_state(id)?;
|
||||||
let genesis_state = format!("0x{:?}", HexDisplay::from(&block.header().encode()));
|
let genesis_state = format!("0x{:?}", HexDisplay::from(&block.header().encode()));
|
||||||
@@ -207,8 +209,8 @@ pub fn run() -> Result<()> {
|
|||||||
info!("Parachain Account: {}", parachain_account);
|
info!("Parachain Account: {}", parachain_account);
|
||||||
info!("Parachain genesis state: {}", genesis_state);
|
info!("Parachain genesis state: {}", genesis_state);
|
||||||
|
|
||||||
crate::service::run_collator(config, key, polkadot_config, id)
|
crate::service::run_collator(config, key, polkadot_config, id, cli.run.base.validator)
|
||||||
.map(|x| x.task_manager)
|
.map(|(x, _)| x)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ use futures::{
|
|||||||
future::{self, FutureExt},
|
future::{self, FutureExt},
|
||||||
pin_mut, select,
|
pin_mut, select,
|
||||||
};
|
};
|
||||||
use polkadot_primitives::parachain::{Id as ParaId, Info, Scheduling};
|
use polkadot_primitives::v0::{Id as ParaId, Info, Scheduling};
|
||||||
use polkadot_runtime_common::registrar;
|
use polkadot_runtime_common::registrar;
|
||||||
use polkadot_test_runtime_client::Sr25519Keyring;
|
use polkadot_test_runtime_client::Sr25519Keyring;
|
||||||
use sc_client_api::execution_extensions::ExecutionStrategies;
|
use sc_client_api::execution_extensions::ExecutionStrategies;
|
||||||
@@ -43,9 +43,8 @@ static INTEGRATION_TEST_ALLOWED_TIME: Option<&str> = option_env!("INTEGRATION_TE
|
|||||||
#[ignore]
|
#[ignore]
|
||||||
async fn integration_test() {
|
async fn integration_test() {
|
||||||
let task_executor: TaskExecutor = (|fut, _| {
|
let task_executor: TaskExecutor = (|fut, _| {
|
||||||
spawn(fut);
|
spawn(fut).map(|_| ())
|
||||||
})
|
}).into();
|
||||||
.into();
|
|
||||||
|
|
||||||
// start alice
|
// start alice
|
||||||
let mut alice =
|
let mut alice =
|
||||||
@@ -104,10 +103,10 @@ async fn integration_test() {
|
|||||||
polkadot_config.rpc_methods = sc_service::config::RpcMethods::Unsafe;
|
polkadot_config.rpc_methods = sc_service::config::RpcMethods::Unsafe;
|
||||||
let parachain_config =
|
let parachain_config =
|
||||||
parachain_config(task_executor.clone(), Charlie, vec![], para_id).unwrap();
|
parachain_config(task_executor.clone(), Charlie, vec![], para_id).unwrap();
|
||||||
let service =
|
let (_service, charlie_client) =
|
||||||
crate::service::run_collator(parachain_config, key, polkadot_config, para_id).unwrap();
|
crate::service::run_collator(parachain_config, key, polkadot_config, para_id, true).unwrap();
|
||||||
sleep(Duration::from_secs(3)).await;
|
sleep(Duration::from_secs(3)).await;
|
||||||
service.client.wait_for_blocks(4).await;
|
charlie_client.wait_for_blocks(4).await;
|
||||||
|
|
||||||
alice.task_manager.terminate();
|
alice.task_manager.terminate();
|
||||||
bob.task_manager.terminate();
|
bob.task_manager.terminate();
|
||||||
|
|||||||
@@ -18,15 +18,15 @@ use ansi_term::Color;
|
|||||||
use cumulus_collator::{prepare_collator_config, CollatorBuilder};
|
use cumulus_collator::{prepare_collator_config, CollatorBuilder};
|
||||||
use cumulus_network::DelayedBlockAnnounceValidator;
|
use cumulus_network::DelayedBlockAnnounceValidator;
|
||||||
use futures::{future::ready, FutureExt};
|
use futures::{future::ready, FutureExt};
|
||||||
use polkadot_primitives::parachain::CollatorPair;
|
use polkadot_primitives::v0::CollatorPair;
|
||||||
use sc_executor::native_executor_instance;
|
use sc_executor::native_executor_instance;
|
||||||
pub use sc_executor::NativeExecutor;
|
pub use sc_executor::NativeExecutor;
|
||||||
use sc_finality_grandpa::{
|
|
||||||
FinalityProofProvider as GrandpaFinalityProofProvider, StorageAndProofProvider,
|
|
||||||
};
|
|
||||||
use sc_informant::OutputFormat;
|
use sc_informant::OutputFormat;
|
||||||
use sc_service::{Configuration, ServiceComponents, TFullBackend, TFullClient};
|
use sc_service::{Configuration, PartialComponents, TaskManager, TFullBackend, TFullClient, Role};
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
|
use sp_core::crypto::Pair;
|
||||||
|
use sp_trie::PrefixedMemoryDB;
|
||||||
|
use sp_runtime::traits::BlakeTwo256;
|
||||||
|
|
||||||
// Our native executor instance.
|
// Our native executor instance.
|
||||||
native_executor_instance!(
|
native_executor_instance!(
|
||||||
@@ -39,45 +39,60 @@ native_executor_instance!(
|
|||||||
///
|
///
|
||||||
/// Use this macro if you don't actually need the full service, but just the builder in order to
|
/// Use this macro if you don't actually need the full service, but just the builder in order to
|
||||||
/// be able to perform chain operations.
|
/// be able to perform chain operations.
|
||||||
macro_rules! new_full_start {
|
pub fn new_partial(config: &mut Configuration) -> Result<
|
||||||
($config:expr) => {{
|
PartialComponents<
|
||||||
let inherent_data_providers = sp_inherents::InherentDataProviders::new();
|
TFullClient<parachain_runtime::opaque::Block, parachain_runtime::RuntimeApi, crate::service::Executor>,
|
||||||
|
TFullBackend<parachain_runtime::opaque::Block>,
|
||||||
|
(),
|
||||||
|
sp_consensus::import_queue::BasicQueue<parachain_runtime::opaque::Block, PrefixedMemoryDB<BlakeTwo256>>,
|
||||||
|
sc_transaction_pool::FullPool<parachain_runtime::opaque::Block, TFullClient<parachain_runtime::opaque::Block, parachain_runtime::RuntimeApi, crate::service::Executor>>,
|
||||||
|
(),
|
||||||
|
>,
|
||||||
|
sc_service::Error,
|
||||||
|
>
|
||||||
|
{
|
||||||
|
let inherent_data_providers = sp_inherents::InherentDataProviders::new();
|
||||||
|
|
||||||
let builder = sc_service::ServiceBuilder::new_full::<
|
let (client, backend, keystore, task_manager) =
|
||||||
|
sc_service::new_full_parts::<
|
||||||
parachain_runtime::opaque::Block,
|
parachain_runtime::opaque::Block,
|
||||||
parachain_runtime::RuntimeApi,
|
parachain_runtime::RuntimeApi,
|
||||||
crate::service::Executor,
|
crate::service::Executor,
|
||||||
>($config)?
|
>(&config)?;
|
||||||
.with_select_chain(|_config, backend| Ok(sc_consensus::LongestChain::new(backend.clone())))?
|
let client = Arc::new(client);
|
||||||
.with_transaction_pool(|builder| {
|
//let select_chain = sc_consensus::LongestChain::new(backend.clone());
|
||||||
let client = builder.client();
|
|
||||||
let pool_api = Arc::new(sc_transaction_pool::FullChainApi::new(
|
|
||||||
client.clone(),
|
|
||||||
builder.prometheus_registry(),
|
|
||||||
));
|
|
||||||
let pool = sc_transaction_pool::BasicPool::new_full(
|
|
||||||
builder.config().transaction_pool.clone(),
|
|
||||||
pool_api,
|
|
||||||
builder.prometheus_registry(),
|
|
||||||
builder.spawn_handle(),
|
|
||||||
client.clone(),
|
|
||||||
);
|
|
||||||
Ok(pool)
|
|
||||||
})?
|
|
||||||
.with_import_queue(|_config, client, _, _, spawner, registry| {
|
|
||||||
let import_queue = cumulus_consensus::import_queue::import_queue(
|
|
||||||
client.clone(),
|
|
||||||
client,
|
|
||||||
inherent_data_providers.clone(),
|
|
||||||
spawner,
|
|
||||||
registry,
|
|
||||||
)?;
|
|
||||||
|
|
||||||
Ok(import_queue)
|
let registry = config.prometheus_registry();
|
||||||
})?;
|
|
||||||
|
|
||||||
(builder, inherent_data_providers)
|
let transaction_pool = sc_transaction_pool::BasicPool::new_full(
|
||||||
}};
|
config.transaction_pool.clone(),
|
||||||
|
//std::sync::Arc::new(pool_api),
|
||||||
|
config.prometheus_registry(),
|
||||||
|
task_manager.spawn_handle(),
|
||||||
|
client.clone(),
|
||||||
|
);
|
||||||
|
|
||||||
|
let import_queue = cumulus_consensus::import_queue::import_queue(
|
||||||
|
client.clone(),
|
||||||
|
client.clone(),
|
||||||
|
inherent_data_providers.clone(),
|
||||||
|
&task_manager.spawn_handle(),
|
||||||
|
registry.clone(),
|
||||||
|
)?;
|
||||||
|
|
||||||
|
let params = PartialComponents {
|
||||||
|
backend,
|
||||||
|
client,
|
||||||
|
import_queue,
|
||||||
|
keystore,
|
||||||
|
task_manager,
|
||||||
|
transaction_pool,
|
||||||
|
inherent_data_providers,
|
||||||
|
select_chain: (),
|
||||||
|
other: (),
|
||||||
|
};
|
||||||
|
|
||||||
|
Ok(params)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Run a collator node with the given parachain `Configuration` and relaychain `Configuration`
|
/// Run a collator node with the given parachain `Configuration` and relaychain `Configuration`
|
||||||
@@ -87,84 +102,123 @@ pub fn run_collator(
|
|||||||
parachain_config: Configuration,
|
parachain_config: Configuration,
|
||||||
key: Arc<CollatorPair>,
|
key: Arc<CollatorPair>,
|
||||||
mut polkadot_config: polkadot_collator::Configuration,
|
mut polkadot_config: polkadot_collator::Configuration,
|
||||||
id: polkadot_primitives::parachain::Id,
|
id: polkadot_primitives::v0::Id,
|
||||||
) -> sc_service::error::Result<ServiceComponents<
|
validator: bool,
|
||||||
parachain_runtime::opaque::Block,
|
) -> sc_service::error::Result<(
|
||||||
TFullBackend<parachain_runtime::opaque::Block>,
|
TaskManager,
|
||||||
sc_consensus::LongestChain<TFullBackend<parachain_runtime::opaque::Block>, parachain_runtime::opaque::Block>,
|
Arc<TFullClient<parachain_runtime::opaque::Block, parachain_runtime::RuntimeApi, crate::service::Executor>>,
|
||||||
sc_transaction_pool::BasicPool<
|
)> {
|
||||||
sc_transaction_pool::FullChainApi<
|
|
||||||
TFullClient<parachain_runtime::opaque::Block, parachain_runtime::RuntimeApi, crate::service::Executor>,
|
|
||||||
parachain_runtime::opaque::Block,
|
|
||||||
>,
|
|
||||||
parachain_runtime::opaque::Block,
|
|
||||||
>,
|
|
||||||
TFullClient<parachain_runtime::opaque::Block, parachain_runtime::RuntimeApi, crate::service::Executor>,
|
|
||||||
>> {
|
|
||||||
let mut parachain_config = prepare_collator_config(parachain_config);
|
let mut parachain_config = prepare_collator_config(parachain_config);
|
||||||
|
|
||||||
parachain_config.informant_output_format = OutputFormat {
|
parachain_config.informant_output_format = OutputFormat {
|
||||||
enable_color: true,
|
enable_color: true,
|
||||||
prefix: format!("[{}] ", Color::Yellow.bold().paint("Parachain")),
|
prefix: format!("[{}] ", Color::Yellow.bold().paint("Parachain")),
|
||||||
};
|
};
|
||||||
|
|
||||||
let (builder, inherent_data_providers) = new_full_start!(parachain_config);
|
|
||||||
inherent_data_providers
|
|
||||||
.register_provider(sp_timestamp::InherentDataProvider)
|
|
||||||
.unwrap();
|
|
||||||
|
|
||||||
let block_announce_validator = DelayedBlockAnnounceValidator::new();
|
|
||||||
let block_announce_validator_copy = block_announce_validator.clone();
|
|
||||||
let service = builder
|
|
||||||
.with_finality_proof_provider(|client, backend| {
|
|
||||||
// GenesisAuthoritySetProvider is implemented for StorageAndProofProvider
|
|
||||||
let provider = client as Arc<dyn StorageAndProofProvider<_, _>>;
|
|
||||||
Ok(Arc::new(GrandpaFinalityProofProvider::new(backend, provider)) as _)
|
|
||||||
})?
|
|
||||||
.with_block_announce_validator(|_client| Box::new(block_announce_validator_copy))?
|
|
||||||
.build_full()?;
|
|
||||||
|
|
||||||
let registry = service.prometheus_registry.clone();
|
|
||||||
|
|
||||||
let proposer_factory = sc_basic_authorship::ProposerFactory::new(
|
|
||||||
service.client.clone(),
|
|
||||||
service.transaction_pool.clone(),
|
|
||||||
registry.as_ref(),
|
|
||||||
);
|
|
||||||
|
|
||||||
let block_import = service.client.clone();
|
|
||||||
let client = service.client.clone();
|
|
||||||
let network = service.network.clone();
|
|
||||||
let announce_block = Arc::new(move |hash, data| network.announce_block(hash, data));
|
|
||||||
let builder = CollatorBuilder::new(
|
|
||||||
proposer_factory,
|
|
||||||
inherent_data_providers,
|
|
||||||
block_import,
|
|
||||||
client.clone(),
|
|
||||||
id,
|
|
||||||
client,
|
|
||||||
announce_block,
|
|
||||||
block_announce_validator,
|
|
||||||
);
|
|
||||||
|
|
||||||
polkadot_config.informant_output_format = OutputFormat {
|
polkadot_config.informant_output_format = OutputFormat {
|
||||||
enable_color: true,
|
enable_color: true,
|
||||||
prefix: format!("[{}] ", Color::Blue.bold().paint("Relaychain")),
|
prefix: format!("[{}] ", Color::Blue.bold().paint("Relaychain")),
|
||||||
};
|
};
|
||||||
|
|
||||||
let (polkadot_future, task_manager) =
|
let params = new_partial(&mut parachain_config)?;
|
||||||
polkadot_collator::start_collator(builder, id, key, polkadot_config)?;
|
params.inherent_data_providers
|
||||||
|
.register_provider(sp_timestamp::InherentDataProvider)
|
||||||
|
.unwrap();
|
||||||
|
|
||||||
// Make sure the polkadot task manager survives as long as the service.
|
let client = params.client.clone();
|
||||||
let polkadot_future = polkadot_future.then(move |_| {
|
let backend = params.backend.clone();
|
||||||
let _ = task_manager;
|
let block_announce_validator = DelayedBlockAnnounceValidator::new();
|
||||||
ready(())
|
let block_announce_validator_builder = {
|
||||||
});
|
let block_announce_validator = block_announce_validator.clone();
|
||||||
|
move |_| Box::new(block_announce_validator) as Box<_>
|
||||||
|
};
|
||||||
|
|
||||||
service
|
let prometheus_registry = parachain_config.prometheus_registry().cloned();
|
||||||
.task_manager
|
let transaction_pool = params.transaction_pool.clone();
|
||||||
.spawn_essential_handle()
|
let mut task_manager = params.task_manager;
|
||||||
.spawn("polkadot", polkadot_future);
|
let import_queue = params.import_queue;
|
||||||
|
let (network, network_status_sinks, system_rpc_tx) =
|
||||||
|
sc_service::build_network(sc_service::BuildNetworkParams {
|
||||||
|
config: ¶chain_config,
|
||||||
|
client: client.clone(),
|
||||||
|
transaction_pool: transaction_pool.clone(),
|
||||||
|
spawn_handle: task_manager.spawn_handle(),
|
||||||
|
import_queue,
|
||||||
|
on_demand: None,
|
||||||
|
block_announce_validator_builder: Some(Box::new(block_announce_validator_builder)),
|
||||||
|
finality_proof_request_builder: None,
|
||||||
|
finality_proof_provider: None,
|
||||||
|
})?;
|
||||||
|
|
||||||
Ok(service)
|
let _rpc_handlers = sc_service::spawn_tasks(sc_service::SpawnTasksParams {
|
||||||
|
on_demand: None,
|
||||||
|
remote_blockchain: None,
|
||||||
|
rpc_extensions_builder: Box::new(|_| ()),
|
||||||
|
client: client.clone(),
|
||||||
|
transaction_pool: transaction_pool.clone(),
|
||||||
|
task_manager: &mut task_manager,
|
||||||
|
telemetry_connection_sinks: Default::default(),
|
||||||
|
config: parachain_config,
|
||||||
|
keystore: params.keystore,
|
||||||
|
backend,
|
||||||
|
network: network.clone(),
|
||||||
|
network_status_sinks,
|
||||||
|
system_rpc_tx,
|
||||||
|
})?;
|
||||||
|
|
||||||
|
if validator {
|
||||||
|
let proposer_factory = sc_basic_authorship::ProposerFactory::new(
|
||||||
|
client.clone(),
|
||||||
|
transaction_pool,
|
||||||
|
prometheus_registry.as_ref(),
|
||||||
|
);
|
||||||
|
|
||||||
|
let block_import = client.clone();
|
||||||
|
let announce_block = Arc::new(move |hash, data| network.announce_block(hash, data));
|
||||||
|
let builder = CollatorBuilder::new(
|
||||||
|
proposer_factory,
|
||||||
|
params.inherent_data_providers,
|
||||||
|
block_import,
|
||||||
|
client.clone(),
|
||||||
|
id,
|
||||||
|
client.clone(),
|
||||||
|
announce_block,
|
||||||
|
block_announce_validator,
|
||||||
|
);
|
||||||
|
|
||||||
|
let (polkadot_future, polkadpt_task_manager) =
|
||||||
|
polkadot_collator::start_collator(builder, id, key, polkadot_config)?;
|
||||||
|
|
||||||
|
// Make sure the polkadot task manager survives as long as the service.
|
||||||
|
let polkadot_future = polkadot_future.then(move |_| {
|
||||||
|
let _ = polkadpt_task_manager;
|
||||||
|
ready(())
|
||||||
|
});
|
||||||
|
|
||||||
|
task_manager
|
||||||
|
.spawn_essential_handle()
|
||||||
|
.spawn("polkadot", polkadot_future);
|
||||||
|
} else {
|
||||||
|
let is_light = matches!(polkadot_config.role, Role::Light);
|
||||||
|
let builder = polkadot_service::NodeBuilder::new(polkadot_config);
|
||||||
|
let mut polkadot_task_manager = if is_light {
|
||||||
|
return Err("Light client not supported.".into());
|
||||||
|
} else {
|
||||||
|
builder.build_full(
|
||||||
|
Some((key.public(), id)),
|
||||||
|
None,
|
||||||
|
false,
|
||||||
|
6000,
|
||||||
|
None,
|
||||||
|
)
|
||||||
|
}?;
|
||||||
|
let polkadot_future = async move {
|
||||||
|
polkadot_task_manager.future().await.expect("polkadot essential task failed");
|
||||||
|
};
|
||||||
|
|
||||||
|
task_manager
|
||||||
|
.spawn_essential_handle()
|
||||||
|
.spawn("polkadot", polkadot_future);
|
||||||
|
}
|
||||||
|
|
||||||
|
Ok((task_manager, client))
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ fn interrupt_polkadot_mdns_issue_test() {
|
|||||||
fn run_command_and_kill(signal: Signal) {
|
fn run_command_and_kill(signal: Signal) {
|
||||||
let _ = fs::remove_dir_all("interrupt_polkadot_mdns_issue_test");
|
let _ = fs::remove_dir_all("interrupt_polkadot_mdns_issue_test");
|
||||||
let mut cmd = Command::new(cargo_bin("cumulus-test-parachain-collator"))
|
let mut cmd = Command::new(cargo_bin("cumulus-test-parachain-collator"))
|
||||||
.args(&["-d", "interrupt_polkadot_mdns_issue_test"])
|
.args(&["-d", "interrupt_polkadot_mdns_issue_test", "--dev", "--", "--dev"])
|
||||||
.spawn()
|
.spawn()
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ fn purge_chain_works() {
|
|||||||
|
|
||||||
let _ = fs::remove_dir_all(base_path);
|
let _ = fs::remove_dir_all(base_path);
|
||||||
let mut cmd = Command::new(cargo_bin("cumulus-test-parachain-collator"))
|
let mut cmd = Command::new(cargo_bin("cumulus-test-parachain-collator"))
|
||||||
.args(&["-d", base_path])
|
.args(&["-d", base_path, "--dev", "--", "--dev"])
|
||||||
.spawn()
|
.spawn()
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ fn running_the_node_works_and_can_be_interrupted() {
|
|||||||
fn run_command_and_kill(signal: Signal) {
|
fn run_command_and_kill(signal: Signal) {
|
||||||
let _ = fs::remove_dir_all("interrupt_test");
|
let _ = fs::remove_dir_all("interrupt_test");
|
||||||
let mut cmd = Command::new(cargo_bin("cumulus-test-parachain-collator"))
|
let mut cmd = Command::new(cargo_bin("cumulus-test-parachain-collator"))
|
||||||
.args(&["--dev", "-d", "interrupt_test"])
|
.args(&["--dev", "-d", "interrupt_test", "--", "--dev"])
|
||||||
.spawn()
|
.spawn()
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ build = "build.rs"
|
|||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
runtime = { package = "cumulus-runtime", path = "../../runtime", default-features = false }
|
runtime = { package = "cumulus-runtime", path = "../../runtime", default-features = false }
|
||||||
substrate-test-runtime = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "cumulus-branch", version = "2.0.0-rc4" }
|
substrate-test-runtime = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "cumulus-branch", version = "2.0.0-rc5" }
|
||||||
|
|
||||||
[build-dependencies]
|
[build-dependencies]
|
||||||
wasm-builder-runner = { package = "substrate-wasm-builder-runner", version = " 1.0.6" }
|
wasm-builder-runner = { package = "substrate-wasm-builder-runner", version = " 1.0.6" }
|
||||||
|
|||||||
Reference in New Issue
Block a user