From 1e17ef1fc4ee2ddfa63d76ac3ba6835c8679c466 Mon Sep 17 00:00:00 2001 From: jasl Date: Sun, 27 Mar 2022 04:32:44 +0800 Subject: [PATCH] Switch to wasm only, port https://github.com/paritytech/cumulus/pull/1054 --- Cargo.lock | 2 +- node/Cargo.toml | 2 +- node/src/command.rs | 10 +++---- node/src/service/khala.rs | 24 +++++++++------- node/src/service/mod.rs | 60 +++++++++++++++++++++------------------ node/src/service/phala.rs | 57 +++++++++++++++++++------------------ node/src/service/rhala.rs | 24 +++++++++------- node/src/service/shell.rs | 50 ++++++++++++++++---------------- node/src/service/thala.rs | 24 +++++++++------- 9 files changed, 133 insertions(+), 120 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index a1f4e6df..98540c7e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3931,7 +3931,6 @@ dependencies = [ "clap", "crossbeam-epoch", "cumulus-client-cli", - "cumulus-client-collator", "cumulus-client-consensus-aura", "cumulus-client-consensus-common", "cumulus-client-consensus-relay-chain", @@ -3985,6 +3984,7 @@ dependencies = [ "sp-consensus-aura", "sp-core", "sp-inherents", + "sp-io", "sp-keystore", "sp-offchain", "sp-runtime", diff --git a/node/Cargo.toml b/node/Cargo.toml index d48848d1..ead86cdd 100644 --- a/node/Cargo.toml +++ b/node/Cargo.toml @@ -68,6 +68,7 @@ sc-transaction-pool-api = { git = "https://github.com/paritytech/substrate", bra sc-tracing = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.18" } # Substrate Primitive Dependencies +sp-io = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.18" } sp-api = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.18" } sp-block-builder = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.18" } sp-blockchain = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.18" } @@ -84,7 +85,6 @@ sp-transaction-pool = { git = "https://github.com/paritytech/substrate", branch # Cumulus dependencies cumulus-client-cli = { git = "https://github.com/paritytech/cumulus", branch = "polkadot-v0.9.18" } -cumulus-client-collator = { git = "https://github.com/paritytech/cumulus", branch = "polkadot-v0.9.18" } cumulus-client-consensus-aura = { git = "https://github.com/paritytech/cumulus", branch = "polkadot-v0.9.18" } cumulus-client-consensus-relay-chain = { git = "https://github.com/paritytech/cumulus", branch = "polkadot-v0.9.18" } cumulus-client-consensus-common = { git = "https://github.com/paritytech/cumulus", branch = "polkadot-v0.9.18" } diff --git a/node/src/command.rs b/node/src/command.rs index 2b9f21b3..c4b0a453 100644 --- a/node/src/command.rs +++ b/node/src/command.rs @@ -354,7 +354,7 @@ macro_rules! construct_async_run { #[cfg(feature = "phala-native")] if runner.config().chain_spec.is_phala() { return runner.async_run(|$config| { - let $components = new_partial::( + let $components = new_partial::( &$config, crate::service::phala::parachain_build_import_queue, )?; @@ -366,7 +366,7 @@ macro_rules! construct_async_run { #[cfg(feature = "khala-native")] if runner.config().chain_spec.is_khala() { return runner.async_run(|$config| { - let $components = new_partial::( + let $components = new_partial::( &$config, crate::service::khala::parachain_build_import_queue, )?; @@ -378,7 +378,7 @@ macro_rules! construct_async_run { #[cfg(feature = "rhala-native")] if runner.config().chain_spec.is_rhala() { return runner.async_run(|$config| { - let $components = new_partial::( + let $components = new_partial::( &$config, crate::service::rhala::parachain_build_import_queue, )?; @@ -390,7 +390,7 @@ macro_rules! construct_async_run { #[cfg(feature = "thala-native")] if runner.config().chain_spec.is_thala() { return runner.async_run(|$config| { - let $components = new_partial::( + let $components = new_partial::( &$config, crate::service::thala::parachain_build_import_queue, )?; @@ -402,7 +402,7 @@ macro_rules! construct_async_run { #[cfg(feature = "shell-native")] if runner.config().chain_spec.is_shell() { return runner.async_run(|$config| { - let $components = new_partial::( + let $components = new_partial::( &$config, crate::service::shell::parachain_build_import_queue, )?; diff --git a/node/src/service/khala.rs b/node/src/service/khala.rs index 4783c927..5c730ddf 100644 --- a/node/src/service/khala.rs +++ b/node/src/service/khala.rs @@ -7,9 +7,8 @@ use cumulus_client_consensus_aura::{ use cumulus_primitives_core::ParaId; pub use parachains_common::{AccountId, Balance, Block, Hash, Header, Index as Nonce}; -use sc_executor::NativeElseWasmExecutor; +use sc_executor::WasmExecutor; -use sc_client_api::ExecutorProvider; use sc_service::{ Configuration, TFullClient, TaskManager, }; @@ -34,14 +33,14 @@ impl sc_executor::NativeExecutionDispatch for RuntimeExecutor { /// Build the import queue for the parachain runtime. #[allow(clippy::type_complexity)] pub fn parachain_build_import_queue( - client: Arc>>, + client: Arc>>, config: &Configuration, telemetry: Option, task_manager: &TaskManager, ) -> Result< sc_consensus::DefaultImportQueue< Block, - TFullClient>, + TFullClient>, >, sc_service::Error, > { @@ -70,7 +69,7 @@ pub fn parachain_build_import_queue( Ok((time, slot)) }, registry: config.prometheus_registry(), - can_author_with: sp_consensus::CanAuthorWithNativeVersion::new(client.executor().clone()), + can_author_with: sp_consensus::AlwaysCanAuthor, spawner: &task_manager.spawn_essential_handle(), telemetry, }) @@ -85,9 +84,9 @@ pub async fn start_parachain_node( id: ParaId, ) -> sc_service::error::Result<( TaskManager, - Arc>>, + Arc>>, )> { - crate::service::start_node_impl::( + crate::service::start_node_impl::( parachain_config, polkadot_config, collator_options, @@ -118,6 +117,7 @@ pub async fn start_parachain_node( proposer_factory, create_inherent_data_providers: move |_, (relay_parent, validation_data)| { let relay_chain_interface = relay_chain_interface.clone(); + async move { let parachain_inherent = cumulus_primitives_parachain_inherent::ParachainInherentData::create_at( @@ -126,11 +126,12 @@ pub async fn start_parachain_node( &validation_data, id, ).await; - let time = sp_timestamp::InherentDataProvider::from_system_time(); + + let timestamp = sp_timestamp::InherentDataProvider::from_system_time(); let slot = sp_consensus_aura::inherents::InherentDataProvider::from_timestamp_and_slot_duration( - *time, + *timestamp, slot_duration, ); @@ -139,11 +140,12 @@ pub async fn start_parachain_node( "Failed to create parachain inherent", ) })?; - Ok((time, slot, parachain_inherent)) + + Ok((timestamp, slot, parachain_inherent)) } }, block_import: client.clone(), - para_client: client, + para_client: client.clone(), backoff_authoring_blocks: Option::<()>::None, sync_oracle, keystore, diff --git a/node/src/service/mod.rs b/node/src/service/mod.rs index e82b2610..c41fc2c8 100644 --- a/node/src/service/mod.rs +++ b/node/src/service/mod.rs @@ -28,7 +28,7 @@ use cumulus_relay_chain_rpc_interface::RelayChainRPCInterface; use polkadot_service::CollatorPair; pub use parachains_common::{AccountId, Balance, Block, Hash, Header, Index as Nonce}; -use sc_executor::NativeElseWasmExecutor; +use sc_executor::WasmExecutor; use sc_network::NetworkService; use sc_service::{ @@ -51,6 +51,13 @@ pub mod thala; #[cfg(feature = "shell-native")] pub mod shell; +#[cfg(not(feature = "runtime-benchmarks"))] +type HostFunctions = sp_io::SubstrateHostFunctions; + +#[cfg(feature = "runtime-benchmarks")] +type HostFunctions = + (sp_io::SubstrateHostFunctions, frame_benchmarking::benchmarking::HostFunctions); + async fn build_relay_chain_interface( polkadot_config: Configuration, parachain_config: &Configuration, @@ -75,28 +82,28 @@ async fn build_relay_chain_interface( /// 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. #[allow(clippy::type_complexity)] -pub fn new_partial( +pub fn new_partial( config: &Configuration, build_import_queue: BIQ, ) -> Result< PartialComponents< - TFullClient>, + TFullClient>, TFullBackend, (), sc_consensus::DefaultImportQueue< Block, - TFullClient>, + TFullClient>, >, sc_transaction_pool::FullPool< Block, - TFullClient>, + TFullClient>, >, (Option, Option), >, sc_service::Error, > where - RuntimeApi: ConstructRuntimeApi>> + RuntimeApi: ConstructRuntimeApi>> + Send + Sync + 'static, @@ -109,16 +116,15 @@ pub fn new_partial( > + sp_offchain::OffchainWorkerApi + sp_block_builder::BlockBuilder, sc_client_api::StateBackendFor, Block>: sp_api::StateBackend, - Executor: sc_executor::NativeExecutionDispatch + 'static, BIQ: FnOnce( - Arc>>, + Arc>>, &Configuration, Option, &TaskManager, ) -> Result< sc_consensus::DefaultImportQueue< Block, - TFullClient>, + TFullClient>, >, sc_service::Error, >, @@ -134,16 +140,17 @@ pub fn new_partial( }) .transpose()?; - let executor = sc_executor::NativeElseWasmExecutor::::new( + let executor = sc_executor::WasmExecutor::::new( config.wasm_method, config.default_heap_pages, config.max_runtime_instances, + None, config.runtime_cache_size, ); let (client, backend, keystore_container, task_manager) = sc_service::new_full_parts::( - config, + &config, telemetry.as_ref().map(|(_, telemetry)| telemetry.handle()), executor, )?; @@ -189,7 +196,7 @@ pub fn new_partial( /// /// This is the actual implementation that is abstract over the executor and the runtime api. #[sc_tracing::logging::prefix_logs_with("Parachain")] -async fn start_node_impl( +async fn start_node_impl( parachain_config: Configuration, polkadot_config: Configuration, collator_options: CollatorOptions, @@ -199,10 +206,10 @@ async fn start_node_impl( build_consensus: BIC, ) -> sc_service::error::Result<( TaskManager, - Arc>>, + Arc>>, )> where - RuntimeApi: ConstructRuntimeApi>> + RuntimeApi: ConstructRuntimeApi>> + Send + Sync + 'static, @@ -219,26 +226,25 @@ async fn start_node_impl( + substrate_frame_rpc_system::AccountNonceApi + pallet_mq_runtime_api::MqApi, sc_client_api::StateBackendFor, Block>: sp_api::StateBackend, - Executor: sc_executor::NativeExecutionDispatch + 'static, RB: Fn( - Arc>, + Arc>>, ) -> Result, sc_service::Error> + Send + 'static, BIQ: FnOnce( - Arc>>, + Arc>>, &Configuration, Option, &TaskManager, ) -> Result< sc_consensus::DefaultImportQueue< Block, - TFullClient>, + TFullClient>, >, sc_service::Error, > + 'static, BIC: FnOnce( - Arc>>, + Arc>>, Option<&Registry>, Option, &TaskManager, @@ -246,7 +252,7 @@ async fn start_node_impl( Arc< sc_transaction_pool::FullPool< Block, - TFullClient>, + TFullClient>, >, >, Arc>, @@ -260,7 +266,7 @@ async fn start_node_impl( let parachain_config = prepare_node_config(parachain_config); - let params = new_partial::(¶chain_config, build_import_queue)?; + let params = new_partial::(¶chain_config, build_import_queue)?; let (mut telemetry, telemetry_worker_handle) = params.other; let client = params.client.clone(); @@ -274,11 +280,11 @@ async fn start_node_impl( &mut task_manager, collator_options.clone(), ) - .await - .map_err(|e| match e { - RelayChainError::ServiceError(polkadot_service::Error::Sub(x)) => x, - s => s.to_string().into(), - })?; + .await + .map_err(|e| match e { + RelayChainError::ServiceError(polkadot_service::Error::Sub(x)) => x, + s => s.to_string().into(), + })?; let block_announce_validator = BlockAnnounceValidator::new(relay_chain_interface.clone(), id); @@ -363,7 +369,7 @@ async fn start_node_impl( announce_block, client: client.clone(), task_manager: &mut task_manager, - relay_chain_interface, + relay_chain_interface: relay_chain_interface.clone(), spawner, parachain_consensus, import_queue, diff --git a/node/src/service/phala.rs b/node/src/service/phala.rs index 31fc46b1..6baed213 100644 --- a/node/src/service/phala.rs +++ b/node/src/service/phala.rs @@ -13,9 +13,8 @@ use cumulus_primitives_core::ParaId; use cumulus_relay_chain_interface::{RelayChainError, RelayChainInterface}; pub use parachains_common::{AccountId, Balance, Block, Hash, Header, Index as Nonce}; -use sc_executor::NativeElseWasmExecutor; +use sc_executor::WasmExecutor; -use sc_client_api::ExecutorProvider; use sc_network::NetworkService; use sc_service::{ Configuration, PruningMode, Role, TFullBackend, TFullClient, TaskManager, @@ -45,14 +44,14 @@ impl sc_executor::NativeExecutionDispatch for RuntimeExecutor { /// Build the import queue for the parachain runtime. #[allow(clippy::type_complexity)] pub fn parachain_build_import_queue( - client: Arc>>, + client: Arc>>, config: &Configuration, telemetry: Option, task_manager: &TaskManager, ) -> Result< sc_consensus::DefaultImportQueue< Block, - TFullClient>, + TFullClient>, >, sc_service::Error, > { @@ -81,7 +80,7 @@ pub fn parachain_build_import_queue( Ok((time, slot)) }, registry: config.prometheus_registry(), - can_author_with: sp_consensus::CanAuthorWithNativeVersion::new(client.executor().clone()), + can_author_with: sp_consensus::AlwaysCanAuthor, spawner: &task_manager.spawn_essential_handle(), telemetry, }) @@ -96,9 +95,9 @@ pub async fn start_parachain_node( id: ParaId, ) -> sc_service::error::Result<( TaskManager, - Arc>>, + Arc>>, )> { - start_node_impl::( + start_node_impl::( parachain_config, polkadot_config, collator_options, @@ -120,7 +119,7 @@ pub async fn start_parachain_node( task_manager.spawn_handle(), client.clone(), transaction_pool, - prometheus_registry, + prometheus_registry.clone(), telemetry.clone(), ); @@ -129,6 +128,7 @@ pub async fn start_parachain_node( proposer_factory, create_inherent_data_providers: move |_, (relay_parent, validation_data)| { let relay_chain_interface = relay_chain_interface.clone(); + async move { let parachain_inherent = cumulus_primitives_parachain_inherent::ParachainInherentData::create_at( @@ -137,11 +137,12 @@ pub async fn start_parachain_node( &validation_data, id, ).await; - let time = sp_timestamp::InherentDataProvider::from_system_time(); + + let timestamp = sp_timestamp::InherentDataProvider::from_system_time(); let slot = sp_consensus_aura::inherents::InherentDataProvider::from_timestamp_and_slot_duration( - *time, + *timestamp, slot_duration, ); @@ -150,11 +151,12 @@ pub async fn start_parachain_node( "Failed to create parachain inherent", ) })?; - Ok((time, slot, parachain_inherent)) + + Ok((timestamp, slot, parachain_inherent)) } }, block_import: client.clone(), - para_client: client, + para_client: client.clone(), backoff_authoring_blocks: Option::<()>::None, sync_oracle, keystore, @@ -177,7 +179,7 @@ pub async fn start_parachain_node( /// /// This is the actual implementation that is abstract over the executor and the runtime api. #[sc_tracing::logging::prefix_logs_with("Parachain")] -async fn start_node_impl( +async fn start_node_impl( parachain_config: Configuration, polkadot_config: Configuration, collator_options: CollatorOptions, @@ -187,10 +189,10 @@ async fn start_node_impl( build_consensus: BIC, ) -> sc_service::error::Result<( TaskManager, - Arc>>, + Arc>>, )> where - RuntimeApi: ConstructRuntimeApi>> + RuntimeApi: ConstructRuntimeApi>> + Send + Sync + 'static, @@ -206,26 +208,25 @@ async fn start_node_impl( + pallet_transaction_payment_rpc::TransactionPaymentRuntimeApi + substrate_frame_rpc_system::AccountNonceApi, sc_client_api::StateBackendFor, Block>: sp_api::StateBackend, - Executor: sc_executor::NativeExecutionDispatch + 'static, RB: Fn( - Arc>, + Arc>>, ) -> Result, sc_service::Error> + Send + 'static, BIQ: FnOnce( - Arc>>, + Arc>>, &Configuration, Option, &TaskManager, ) -> Result< sc_consensus::DefaultImportQueue< Block, - TFullClient>, + TFullClient>, >, sc_service::Error, > + 'static, BIC: FnOnce( - Arc>>, + Arc>>, Option<&Registry>, Option, &TaskManager, @@ -233,7 +234,7 @@ async fn start_node_impl( Arc< sc_transaction_pool::FullPool< Block, - TFullClient>, + TFullClient>, >, >, Arc>, @@ -247,7 +248,7 @@ async fn start_node_impl( let parachain_config = prepare_node_config(parachain_config); - let params = crate::service::new_partial::(¶chain_config, build_import_queue)?; + let params = crate::service::new_partial::(¶chain_config, build_import_queue)?; let (mut telemetry, telemetry_worker_handle) = params.other; let client = params.client.clone(); @@ -261,11 +262,11 @@ async fn start_node_impl( &mut task_manager, collator_options.clone(), ) - .await - .map_err(|e| match e { - RelayChainError::ServiceError(polkadot_service::Error::Sub(x)) => x, - s => s.to_string().into(), - })?; + .await + .map_err(|e| match e { + RelayChainError::ServiceError(polkadot_service::Error::Sub(x)) => x, + s => s.to_string().into(), + })?; let block_announce_validator = BlockAnnounceValidator::new(relay_chain_interface.clone(), id); @@ -350,7 +351,7 @@ async fn start_node_impl( announce_block, client: client.clone(), task_manager: &mut task_manager, - relay_chain_interface, + relay_chain_interface: relay_chain_interface.clone(), spawner, parachain_consensus, import_queue, diff --git a/node/src/service/rhala.rs b/node/src/service/rhala.rs index 21d49624..c31f8e9d 100644 --- a/node/src/service/rhala.rs +++ b/node/src/service/rhala.rs @@ -7,9 +7,8 @@ use cumulus_client_consensus_aura::{ use cumulus_primitives_core::ParaId; pub use parachains_common::{AccountId, Balance, Block, Hash, Header, Index as Nonce}; -use sc_executor::NativeElseWasmExecutor; +use sc_executor::WasmExecutor; -use sc_client_api::ExecutorProvider; use sc_service::{ Configuration, TFullClient, TaskManager, }; @@ -34,14 +33,14 @@ impl sc_executor::NativeExecutionDispatch for RuntimeExecutor { /// Build the import queue for the parachain runtime. #[allow(clippy::type_complexity)] pub fn parachain_build_import_queue( - client: Arc>>, + client: Arc>>, config: &Configuration, telemetry: Option, task_manager: &TaskManager, ) -> Result< sc_consensus::DefaultImportQueue< Block, - TFullClient>, + TFullClient>, >, sc_service::Error, > { @@ -70,7 +69,7 @@ pub fn parachain_build_import_queue( Ok((time, slot)) }, registry: config.prometheus_registry(), - can_author_with: sp_consensus::CanAuthorWithNativeVersion::new(client.executor().clone()), + can_author_with: sp_consensus::AlwaysCanAuthor, spawner: &task_manager.spawn_essential_handle(), telemetry, }) @@ -85,9 +84,9 @@ pub async fn start_parachain_node( id: ParaId, ) -> sc_service::error::Result<( TaskManager, - Arc>>, + Arc>>, )> { - crate::service::start_node_impl::( + crate::service::start_node_impl::( parachain_config, polkadot_config, collator_options, @@ -118,6 +117,7 @@ pub async fn start_parachain_node( proposer_factory, create_inherent_data_providers: move |_, (relay_parent, validation_data)| { let relay_chain_interface = relay_chain_interface.clone(); + async move { let parachain_inherent = cumulus_primitives_parachain_inherent::ParachainInherentData::create_at( @@ -126,11 +126,12 @@ pub async fn start_parachain_node( &validation_data, id, ).await; - let time = sp_timestamp::InherentDataProvider::from_system_time(); + + let timestamp = sp_timestamp::InherentDataProvider::from_system_time(); let slot = sp_consensus_aura::inherents::InherentDataProvider::from_timestamp_and_slot_duration( - *time, + *timestamp, slot_duration, ); @@ -139,11 +140,12 @@ pub async fn start_parachain_node( "Failed to create parachain inherent", ) })?; - Ok((time, slot, parachain_inherent)) + + Ok((timestamp, slot, parachain_inherent)) } }, block_import: client.clone(), - para_client: client, + para_client: client.clone(), backoff_authoring_blocks: Option::<()>::None, sync_oracle, keystore, diff --git a/node/src/service/shell.rs b/node/src/service/shell.rs index f5385480..c42e42dd 100644 --- a/node/src/service/shell.rs +++ b/node/src/service/shell.rs @@ -7,11 +7,10 @@ use cumulus_client_service::{ prepare_node_config, start_collator, start_full_node, StartCollatorParams, StartFullNodeParams, }; use cumulus_primitives_core::ParaId; -use cumulus_relay_chain_inprocess_interface::build_inprocess_relay_chain; use cumulus_relay_chain_interface::{RelayChainError, RelayChainInterface}; pub use parachains_common::{AccountId, Balance, Block, Hash, Header, Index as Nonce}; -use sc_executor::NativeElseWasmExecutor; +use sc_executor::WasmExecutor; use sc_network::NetworkService; use sc_service::{ @@ -40,20 +39,20 @@ impl sc_executor::NativeExecutionDispatch for RuntimeExecutor { } /// Build the import queue for the shell runtime. -pub fn parachain_build_import_queue( - client: Arc>>, +pub fn parachain_build_import_queue( + client: Arc>>, config: &Configuration, _: Option, task_manager: &TaskManager, ) -> Result< sc_consensus::DefaultImportQueue< Block, - TFullClient>, + TFullClient>, >, sc_service::Error, > where - RuntimeApi: ConstructRuntimeApi>> + RuntimeApi: ConstructRuntimeApi>> + Send + Sync + 'static, @@ -66,7 +65,6 @@ pub fn parachain_build_import_queue( > + sp_offchain::OffchainWorkerApi + sp_block_builder::BlockBuilder, sc_client_api::StateBackendFor, Block>: sp_api::StateBackend, - Executor: sc_executor::NativeExecutionDispatch + 'static, { cumulus_client_consensus_relay_chain::import_queue( client.clone(), @@ -82,7 +80,7 @@ pub fn parachain_build_import_queue( /// /// This is the actual implementation that is abstract over the executor and the runtime api for shell nodes. #[sc_tracing::logging::prefix_logs_with("Parachain")] -async fn start_node_impl( +async fn start_node_impl( parachain_config: Configuration, polkadot_config: Configuration, collator_options: CollatorOptions, @@ -92,10 +90,10 @@ async fn start_node_impl( build_consensus: BIC, ) -> sc_service::error::Result<( TaskManager, - Arc>>, + Arc>>, )> where - RuntimeApi: ConstructRuntimeApi>> + RuntimeApi: ConstructRuntimeApi>> + Send + Sync + 'static, @@ -109,26 +107,25 @@ async fn start_node_impl( + sp_block_builder::BlockBuilder + cumulus_primitives_core::CollectCollationInfo, sc_client_api::StateBackendFor, Block>: sp_api::StateBackend, - Executor: sc_executor::NativeExecutionDispatch + 'static, RB: Fn( - Arc>>, + Arc>>, ) -> Result, sc_service::Error> + Send + 'static, BIQ: FnOnce( - Arc>>, + Arc>>, &Configuration, Option, &TaskManager, ) -> Result< sc_consensus::DefaultImportQueue< Block, - TFullClient>, + TFullClient>, >, sc_service::Error, >, BIC: FnOnce( - Arc>>, + Arc>>, Option<&Registry>, Option, &TaskManager, @@ -136,7 +133,7 @@ async fn start_node_impl( Arc< sc_transaction_pool::FullPool< Block, - TFullClient>, + TFullClient>, >, >, Arc>, @@ -150,13 +147,14 @@ async fn start_node_impl( let parachain_config = prepare_node_config(parachain_config); - let params = crate::service::new_partial::(¶chain_config, build_import_queue)?; + let params = crate::service::new_partial::(¶chain_config, build_import_queue)?; let (mut telemetry, telemetry_worker_handle) = params.other; let client = params.client.clone(); let backend = params.backend.clone(); let mut task_manager = params.task_manager; + let (relay_chain_interface, collator_key) = crate::service::build_relay_chain_interface( polkadot_config, ¶chain_config, @@ -164,11 +162,11 @@ async fn start_node_impl( &mut task_manager, collator_options.clone(), ) - .await - .map_err(|e| match e { - RelayChainError::ServiceError(polkadot_service::Error::Sub(x)) => x, - s => s.to_string().into(), - })?; + .await + .map_err(|e| match e { + RelayChainError::ServiceError(polkadot_service::Error::Sub(x)) => x, + s => s.to_string().into(), + })?; let block_announce_validator = BlockAnnounceValidator::new(relay_chain_interface.clone(), id); @@ -263,6 +261,7 @@ async fn start_node_impl( Ok((task_manager, client)) } + /// Start a polkadot-shell parachain node. pub async fn start_parachain_node( parachain_config: Configuration, @@ -271,9 +270,10 @@ pub async fn start_parachain_node( id: ParaId, ) -> sc_service::error::Result<( TaskManager, - Arc>>, -)> { - start_node_impl::( + Arc>>, +)> +{ + start_node_impl::( parachain_config, polkadot_config, collator_options, diff --git a/node/src/service/thala.rs b/node/src/service/thala.rs index b029824e..7a9354f2 100644 --- a/node/src/service/thala.rs +++ b/node/src/service/thala.rs @@ -7,9 +7,8 @@ use cumulus_client_consensus_aura::{ use cumulus_primitives_core::ParaId; pub use parachains_common::{AccountId, Balance, Block, Hash, Header, Index as Nonce}; -use sc_executor::NativeElseWasmExecutor; +use sc_executor::WasmExecutor; -use sc_client_api::ExecutorProvider; use sc_service::{ Configuration, TFullClient, TaskManager, }; @@ -34,14 +33,14 @@ impl sc_executor::NativeExecutionDispatch for RuntimeExecutor { /// Build the import queue for the parachain runtime. #[allow(clippy::type_complexity)] pub fn parachain_build_import_queue( - client: Arc>>, + client: Arc>>, config: &Configuration, telemetry: Option, task_manager: &TaskManager, ) -> Result< sc_consensus::DefaultImportQueue< Block, - TFullClient>, + TFullClient>, >, sc_service::Error, > { @@ -70,7 +69,7 @@ pub fn parachain_build_import_queue( Ok((time, slot)) }, registry: config.prometheus_registry(), - can_author_with: sp_consensus::CanAuthorWithNativeVersion::new(client.executor().clone()), + can_author_with: sp_consensus::AlwaysCanAuthor, spawner: &task_manager.spawn_essential_handle(), telemetry, }) @@ -85,9 +84,9 @@ pub async fn start_parachain_node( id: ParaId, ) -> sc_service::error::Result<( TaskManager, - Arc>>, + Arc>>, )> { - crate::service::start_node_impl::( + crate::service::start_node_impl::( parachain_config, polkadot_config, collator_options, @@ -118,6 +117,7 @@ pub async fn start_parachain_node( proposer_factory, create_inherent_data_providers: move |_, (relay_parent, validation_data)| { let relay_chain_interface = relay_chain_interface.clone(); + async move { let parachain_inherent = cumulus_primitives_parachain_inherent::ParachainInherentData::create_at( @@ -126,11 +126,12 @@ pub async fn start_parachain_node( &validation_data, id, ).await; - let time = sp_timestamp::InherentDataProvider::from_system_time(); + + let timestamp = sp_timestamp::InherentDataProvider::from_system_time(); let slot = sp_consensus_aura::inherents::InherentDataProvider::from_timestamp_and_slot_duration( - *time, + *timestamp, slot_duration, ); @@ -139,11 +140,12 @@ pub async fn start_parachain_node( "Failed to create parachain inherent", ) })?; - Ok((time, slot, parachain_inherent)) + + Ok((timestamp, slot, parachain_inherent)) } }, block_import: client.clone(), - para_client: client, + para_client: client.clone(), backoff_authoring_blocks: Option::<()>::None, sync_oracle, keystore,