polkadot-collator: Switch to wasm only (#1054)

* polkadot-collator: Switch to wasm only

This switches the polkadot-collator to run everything in wasm only mode. While we should not that
yet with the relay chain, because it can happen that we run out of memory (very unlikely). On the
relay chain that would be bad, because we only have at max 2 sessions to bring everything back, for
Parachains that isn't such a problem as they would only stall and we could roll out a release that
fixes it. Besides that, Parachain validation on the relay chain happens in Wasm already all the time
and there is the memory usage even higher then on block import.

* cargo fmt

* remove unused var

Co-authored-by: Squirrel <gilescope@gmail.com>
This commit is contained in:
Bastian Köcher
2022-03-02 12:44:53 +01:00
committed by GitHub
parent e42a7c3fff
commit 92313f6502
2 changed files with 137 additions and 180 deletions
+34 -31
View File
@@ -18,8 +18,7 @@ use crate::{
chain_spec, chain_spec,
cli::{Cli, RelayChainCli, Subcommand}, cli::{Cli, RelayChainCli, Subcommand},
service::{ service::{
new_partial, Block, CanvasKusamaRuntimeExecutor, RococoParachainRuntimeExecutor, new_partial, Block, ShellRuntimeExecutor, StatemineRuntimeExecutor,
SeedlingRuntimeExecutor, ShellRuntimeExecutor, StatemineRuntimeExecutor,
StatemintRuntimeExecutor, WestmintRuntimeExecutor, StatemintRuntimeExecutor, WestmintRuntimeExecutor,
}, },
}; };
@@ -274,34 +273,34 @@ macro_rules! construct_async_run {
let runner = $cli.create_runner($cmd)?; let runner = $cli.create_runner($cmd)?;
if runner.config().chain_spec.is_westmint() { if runner.config().chain_spec.is_westmint() {
runner.async_run(|$config| { runner.async_run(|$config| {
let $components = new_partial::<westmint_runtime::RuntimeApi, WestmintRuntimeExecutor, _>( let $components = new_partial::<westmint_runtime::RuntimeApi, _>(
&$config, &$config,
crate::service::statemint_build_import_queue::<_, _, AuraId>, crate::service::statemint_build_import_queue::<_, AuraId>,
)?; )?;
let task_manager = $components.task_manager; let task_manager = $components.task_manager;
{ $( $code )* }.map(|v| (v, task_manager)) { $( $code )* }.map(|v| (v, task_manager))
}) })
} else if runner.config().chain_spec.is_statemine() { } else if runner.config().chain_spec.is_statemine() {
runner.async_run(|$config| { runner.async_run(|$config| {
let $components = new_partial::<statemine_runtime::RuntimeApi, StatemineRuntimeExecutor, _>( let $components = new_partial::<statemine_runtime::RuntimeApi, _>(
&$config, &$config,
crate::service::statemint_build_import_queue::<_, _, AuraId>, crate::service::statemint_build_import_queue::<_, AuraId>,
)?; )?;
let task_manager = $components.task_manager; let task_manager = $components.task_manager;
{ $( $code )* }.map(|v| (v, task_manager)) { $( $code )* }.map(|v| (v, task_manager))
}) })
} else if runner.config().chain_spec.is_statemint() { } else if runner.config().chain_spec.is_statemint() {
runner.async_run(|$config| { runner.async_run(|$config| {
let $components = new_partial::<statemint_runtime::RuntimeApi, StatemintRuntimeExecutor, _>( let $components = new_partial::<statemint_runtime::RuntimeApi, _>(
&$config, &$config,
crate::service::statemint_build_import_queue::<_, _, StatemintAuraId>, crate::service::statemint_build_import_queue::<_, StatemintAuraId>,
)?; )?;
let task_manager = $components.task_manager; let task_manager = $components.task_manager;
{ $( $code )* }.map(|v| (v, task_manager)) { $( $code )* }.map(|v| (v, task_manager))
}) })
} else if runner.config().chain_spec.is_shell() { } else if runner.config().chain_spec.is_shell() {
runner.async_run(|$config| { runner.async_run(|$config| {
let $components = new_partial::<shell_runtime::RuntimeApi, ShellRuntimeExecutor, _>( let $components = new_partial::<shell_runtime::RuntimeApi, _>(
&$config, &$config,
crate::service::shell_build_import_queue, crate::service::shell_build_import_queue,
)?; )?;
@@ -310,7 +309,7 @@ macro_rules! construct_async_run {
}) })
} else if runner.config().chain_spec.is_seedling() { } else if runner.config().chain_spec.is_seedling() {
runner.async_run(|$config| { runner.async_run(|$config| {
let $components = new_partial::<seedling_runtime::RuntimeApi, SeedlingRuntimeExecutor, _>( let $components = new_partial::<seedling_runtime::RuntimeApi, _>(
&$config, &$config,
crate::service::shell_build_import_queue, crate::service::shell_build_import_queue,
)?; )?;
@@ -319,7 +318,7 @@ macro_rules! construct_async_run {
}) })
} else if runner.config().chain_spec.is_canvas_kusama() { } else if runner.config().chain_spec.is_canvas_kusama() {
runner.async_run(|$config| { runner.async_run(|$config| {
let $components = new_partial::<canvas_kusama_runtime::RuntimeApi, CanvasKusamaRuntimeExecutor, _>( let $components = new_partial::<canvas_kusama_runtime::RuntimeApi, _>(
&$config, &$config,
crate::service::canvas_kusama_build_import_queue, crate::service::canvas_kusama_build_import_queue,
)?; )?;
@@ -330,7 +329,6 @@ macro_rules! construct_async_run {
runner.async_run(|$config| { runner.async_run(|$config| {
let $components = new_partial::< let $components = new_partial::<
rococo_parachain_runtime::RuntimeApi, rococo_parachain_runtime::RuntimeApi,
RococoParachainRuntimeExecutor,
_ _
>( >(
&$config, &$config,
@@ -533,43 +531,48 @@ pub fn run() -> Result<()> {
if config.chain_spec.is_statemint() { if config.chain_spec.is_statemint() {
crate::service::start_statemint_node::< crate::service::start_statemint_node::<
statemint_runtime::RuntimeApi, statemint_runtime::RuntimeApi,
StatemintRuntimeExecutor,
StatemintAuraId, StatemintAuraId,
>(config, polkadot_config, collator_options, id) >(config, polkadot_config, collator_options, id)
.await .await
.map(|r| r.0) .map(|r| r.0)
.map_err(Into::into) .map_err(Into::into)
} else if config.chain_spec.is_statemine() { } else if config.chain_spec.is_statemine() {
crate::service::start_statemint_node::< crate::service::start_statemint_node::<statemine_runtime::RuntimeApi, AuraId>(
statemine_runtime::RuntimeApi, config,
StatemineRuntimeExecutor, polkadot_config,
AuraId, collator_options,
>(config, polkadot_config, collator_options, id) id,
)
.await .await
.map(|r| r.0) .map(|r| r.0)
.map_err(Into::into) .map_err(Into::into)
} else if config.chain_spec.is_westmint() { } else if config.chain_spec.is_westmint() {
crate::service::start_statemint_node::< crate::service::start_statemint_node::<westmint_runtime::RuntimeApi, AuraId>(
westmint_runtime::RuntimeApi, config,
WestmintRuntimeExecutor, polkadot_config,
AuraId, collator_options,
>(config, polkadot_config, collator_options, id) id,
)
.await .await
.map(|r| r.0) .map(|r| r.0)
.map_err(Into::into) .map_err(Into::into)
} else if config.chain_spec.is_shell() { } else if config.chain_spec.is_shell() {
crate::service::start_shell_node::< crate::service::start_shell_node::<shell_runtime::RuntimeApi>(
shell_runtime::RuntimeApi, config,
ShellRuntimeExecutor, polkadot_config,
>(config, polkadot_config, collator_options, id) collator_options,
id,
)
.await .await
.map(|r| r.0) .map(|r| r.0)
.map_err(Into::into) .map_err(Into::into)
} else if config.chain_spec.is_seedling() { } else if config.chain_spec.is_seedling() {
crate::service::start_shell_node::< crate::service::start_shell_node::<seedling_runtime::RuntimeApi>(
seedling_runtime::RuntimeApi, config,
SeedlingRuntimeExecutor, polkadot_config,
>(config, polkadot_config, collator_options, id) collator_options,
id,
)
.await .await
.map(|r| r.0) .map(|r| r.0)
.map_err(Into::into) .map_err(Into::into)
+77 -123
View File
@@ -31,7 +31,7 @@ use cumulus_primitives_core::{
use cumulus_relay_chain_inprocess_interface::build_inprocess_relay_chain; use cumulus_relay_chain_inprocess_interface::build_inprocess_relay_chain;
use cumulus_relay_chain_interface::{RelayChainError, RelayChainInterface, RelayChainResult}; use cumulus_relay_chain_interface::{RelayChainError, RelayChainInterface, RelayChainResult};
use cumulus_relay_chain_rpc_interface::RelayChainRPCInterface; use cumulus_relay_chain_rpc_interface::RelayChainRPCInterface;
use polkadot_service::{CollatorPair, NativeExecutionDispatch}; use polkadot_service::CollatorPair;
use sp_core::Pair; use sp_core::Pair;
use crate::rpc; use crate::rpc;
@@ -39,12 +39,11 @@ pub use parachains_common::{AccountId, Balance, Block, BlockNumber, Hash, Header
use cumulus_client_consensus_relay_chain::Verifier as RelayChainVerifier; use cumulus_client_consensus_relay_chain::Verifier as RelayChainVerifier;
use futures::lock::Mutex; use futures::lock::Mutex;
use sc_client_api::ExecutorProvider;
use sc_consensus::{ use sc_consensus::{
import_queue::{BasicQueue, Verifier as VerifierT}, import_queue::{BasicQueue, Verifier as VerifierT},
BlockImportParams, BlockImportParams,
}; };
use sc_executor::NativeElseWasmExecutor; use sc_executor::WasmExecutor;
use sc_network::NetworkService; use sc_network::NetworkService;
use sc_service::{Configuration, PartialComponents, Role, TFullBackend, TFullClient, TaskManager}; use sc_service::{Configuration, PartialComponents, Role, TFullBackend, TFullClient, TaskManager};
use sc_telemetry::{Telemetry, TelemetryHandle, TelemetryWorker, TelemetryWorkerHandle}; use sc_telemetry::{Telemetry, TelemetryHandle, TelemetryWorker, TelemetryWorkerHandle};
@@ -60,6 +59,13 @@ use sp_runtime::{
use std::{marker::PhantomData, sync::Arc, time::Duration}; use std::{marker::PhantomData, sync::Arc, time::Duration};
use substrate_prometheus_endpoint::Registry; use substrate_prometheus_endpoint::Registry;
#[cfg(not(feature = "runtime-benchmarks"))]
type HostFunctions = sp_io::SubstrateHostFunctions;
#[cfg(feature = "runtime-benchmarks")]
type HostFunctions =
(sp_io::SubstrateHostFunctions, frame_benchmarking::benchmarking::HostFunctions);
/// Native executor instance. /// Native executor instance.
pub struct RococoParachainRuntimeExecutor; pub struct RococoParachainRuntimeExecutor;
@@ -169,28 +175,28 @@ impl sc_executor::NativeExecutionDispatch for CanvasKusamaRuntimeExecutor {
/// ///
/// 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.
pub fn new_partial<RuntimeApi, Executor, BIQ>( pub fn new_partial<RuntimeApi, BIQ>(
config: &Configuration, config: &Configuration,
build_import_queue: BIQ, build_import_queue: BIQ,
) -> Result< ) -> Result<
PartialComponents< PartialComponents<
TFullClient<Block, RuntimeApi, NativeElseWasmExecutor<Executor>>, TFullClient<Block, RuntimeApi, WasmExecutor<HostFunctions>>,
TFullBackend<Block>, TFullBackend<Block>,
(), (),
sc_consensus::DefaultImportQueue< sc_consensus::DefaultImportQueue<
Block, Block,
TFullClient<Block, RuntimeApi, NativeElseWasmExecutor<Executor>>, TFullClient<Block, RuntimeApi, WasmExecutor<HostFunctions>>,
>, >,
sc_transaction_pool::FullPool< sc_transaction_pool::FullPool<
Block, Block,
TFullClient<Block, RuntimeApi, NativeElseWasmExecutor<Executor>>, TFullClient<Block, RuntimeApi, WasmExecutor<HostFunctions>>,
>, >,
(Option<Telemetry>, Option<TelemetryWorkerHandle>), (Option<Telemetry>, Option<TelemetryWorkerHandle>),
>, >,
sc_service::Error, sc_service::Error,
> >
where where
RuntimeApi: ConstructRuntimeApi<Block, TFullClient<Block, RuntimeApi, NativeElseWasmExecutor<Executor>>> RuntimeApi: ConstructRuntimeApi<Block, TFullClient<Block, RuntimeApi, WasmExecutor<HostFunctions>>>
+ Send + Send
+ Sync + Sync
+ 'static, + 'static,
@@ -203,16 +209,15 @@ where
> + sp_offchain::OffchainWorkerApi<Block> > + sp_offchain::OffchainWorkerApi<Block>
+ sp_block_builder::BlockBuilder<Block>, + sp_block_builder::BlockBuilder<Block>,
sc_client_api::StateBackendFor<TFullBackend<Block>, Block>: sp_api::StateBackend<BlakeTwo256>, sc_client_api::StateBackendFor<TFullBackend<Block>, Block>: sp_api::StateBackend<BlakeTwo256>,
Executor: NativeExecutionDispatch + 'static,
BIQ: FnOnce( BIQ: FnOnce(
Arc<TFullClient<Block, RuntimeApi, NativeElseWasmExecutor<Executor>>>, Arc<TFullClient<Block, RuntimeApi, WasmExecutor<HostFunctions>>>,
&Configuration, &Configuration,
Option<TelemetryHandle>, Option<TelemetryHandle>,
&TaskManager, &TaskManager,
) -> Result< ) -> Result<
sc_consensus::DefaultImportQueue< sc_consensus::DefaultImportQueue<
Block, Block,
TFullClient<Block, RuntimeApi, NativeElseWasmExecutor<Executor>>, TFullClient<Block, RuntimeApi, WasmExecutor<HostFunctions>>,
>, >,
sc_service::Error, sc_service::Error,
>, >,
@@ -228,10 +233,11 @@ where
}) })
.transpose()?; .transpose()?;
let executor = sc_executor::NativeElseWasmExecutor::<Executor>::new( let executor = sc_executor::WasmExecutor::<HostFunctions>::new(
config.wasm_method, config.wasm_method,
config.default_heap_pages, config.default_heap_pages,
config.max_runtime_instances, config.max_runtime_instances,
None,
config.runtime_cache_size, config.runtime_cache_size,
); );
@@ -303,7 +309,7 @@ async fn build_relay_chain_interface(
/// ///
/// This is the actual implementation that is abstract over the executor and the runtime api for shell nodes. /// 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")] #[sc_tracing::logging::prefix_logs_with("Parachain")]
async fn start_shell_node_impl<RuntimeApi, Executor, RB, BIQ, BIC>( async fn start_shell_node_impl<RuntimeApi, RB, BIQ, BIC>(
parachain_config: Configuration, parachain_config: Configuration,
polkadot_config: Configuration, polkadot_config: Configuration,
collator_options: CollatorOptions, collator_options: CollatorOptions,
@@ -313,10 +319,10 @@ async fn start_shell_node_impl<RuntimeApi, Executor, RB, BIQ, BIC>(
build_consensus: BIC, build_consensus: BIC,
) -> sc_service::error::Result<( ) -> sc_service::error::Result<(
TaskManager, TaskManager,
Arc<TFullClient<Block, RuntimeApi, NativeElseWasmExecutor<Executor>>>, Arc<TFullClient<Block, RuntimeApi, WasmExecutor<HostFunctions>>>,
)> )>
where where
RuntimeApi: ConstructRuntimeApi<Block, TFullClient<Block, RuntimeApi, NativeElseWasmExecutor<Executor>>> RuntimeApi: ConstructRuntimeApi<Block, TFullClient<Block, RuntimeApi, WasmExecutor<HostFunctions>>>
+ Send + Send
+ Sync + Sync
+ 'static, + 'static,
@@ -330,26 +336,25 @@ where
+ sp_block_builder::BlockBuilder<Block> + sp_block_builder::BlockBuilder<Block>
+ cumulus_primitives_core::CollectCollationInfo<Block>, + cumulus_primitives_core::CollectCollationInfo<Block>,
sc_client_api::StateBackendFor<TFullBackend<Block>, Block>: sp_api::StateBackend<BlakeTwo256>, sc_client_api::StateBackendFor<TFullBackend<Block>, Block>: sp_api::StateBackend<BlakeTwo256>,
Executor: sc_executor::NativeExecutionDispatch + 'static,
RB: Fn( RB: Fn(
Arc<TFullClient<Block, RuntimeApi, NativeElseWasmExecutor<Executor>>>, Arc<TFullClient<Block, RuntimeApi, WasmExecutor<HostFunctions>>>,
) -> Result<jsonrpc_core::IoHandler<sc_rpc::Metadata>, sc_service::Error> ) -> Result<jsonrpc_core::IoHandler<sc_rpc::Metadata>, sc_service::Error>
+ Send + Send
+ 'static, + 'static,
BIQ: FnOnce( BIQ: FnOnce(
Arc<TFullClient<Block, RuntimeApi, NativeElseWasmExecutor<Executor>>>, Arc<TFullClient<Block, RuntimeApi, WasmExecutor<HostFunctions>>>,
&Configuration, &Configuration,
Option<TelemetryHandle>, Option<TelemetryHandle>,
&TaskManager, &TaskManager,
) -> Result< ) -> Result<
sc_consensus::DefaultImportQueue< sc_consensus::DefaultImportQueue<
Block, Block,
TFullClient<Block, RuntimeApi, NativeElseWasmExecutor<Executor>>, TFullClient<Block, RuntimeApi, WasmExecutor<HostFunctions>>,
>, >,
sc_service::Error, sc_service::Error,
>, >,
BIC: FnOnce( BIC: FnOnce(
Arc<TFullClient<Block, RuntimeApi, NativeElseWasmExecutor<Executor>>>, Arc<TFullClient<Block, RuntimeApi, WasmExecutor<HostFunctions>>>,
Option<&Registry>, Option<&Registry>,
Option<TelemetryHandle>, Option<TelemetryHandle>,
&TaskManager, &TaskManager,
@@ -357,7 +362,7 @@ where
Arc< Arc<
sc_transaction_pool::FullPool< sc_transaction_pool::FullPool<
Block, Block,
TFullClient<Block, RuntimeApi, NativeElseWasmExecutor<Executor>>, TFullClient<Block, RuntimeApi, WasmExecutor<HostFunctions>>,
>, >,
>, >,
Arc<NetworkService<Block, Hash>>, Arc<NetworkService<Block, Hash>>,
@@ -371,7 +376,7 @@ where
let parachain_config = prepare_node_config(parachain_config); let parachain_config = prepare_node_config(parachain_config);
let params = new_partial::<RuntimeApi, Executor, BIQ>(&parachain_config, build_import_queue)?; let params = new_partial::<RuntimeApi, BIQ>(&parachain_config, build_import_queue)?;
let (mut telemetry, telemetry_worker_handle) = params.other; let (mut telemetry, telemetry_worker_handle) = params.other;
let client = params.client.clone(); let client = params.client.clone();
@@ -488,7 +493,7 @@ where
/// ///
/// This is the actual implementation that is abstract over the executor and the runtime api. /// This is the actual implementation that is abstract over the executor and the runtime api.
#[sc_tracing::logging::prefix_logs_with("Parachain")] #[sc_tracing::logging::prefix_logs_with("Parachain")]
async fn start_node_impl<RuntimeApi, Executor, RB, BIQ, BIC>( async fn start_node_impl<RuntimeApi, RB, BIQ, BIC>(
parachain_config: Configuration, parachain_config: Configuration,
polkadot_config: Configuration, polkadot_config: Configuration,
collator_options: CollatorOptions, collator_options: CollatorOptions,
@@ -498,10 +503,10 @@ async fn start_node_impl<RuntimeApi, Executor, RB, BIQ, BIC>(
build_consensus: BIC, build_consensus: BIC,
) -> sc_service::error::Result<( ) -> sc_service::error::Result<(
TaskManager, TaskManager,
Arc<TFullClient<Block, RuntimeApi, NativeElseWasmExecutor<Executor>>>, Arc<TFullClient<Block, RuntimeApi, WasmExecutor<HostFunctions>>>,
)> )>
where where
RuntimeApi: ConstructRuntimeApi<Block, TFullClient<Block, RuntimeApi, NativeElseWasmExecutor<Executor>>> RuntimeApi: ConstructRuntimeApi<Block, TFullClient<Block, RuntimeApi, WasmExecutor<HostFunctions>>>
+ Send + Send
+ Sync + Sync
+ 'static, + 'static,
@@ -517,26 +522,25 @@ where
+ pallet_transaction_payment_rpc::TransactionPaymentRuntimeApi<Block, Balance> + pallet_transaction_payment_rpc::TransactionPaymentRuntimeApi<Block, Balance>
+ frame_rpc_system::AccountNonceApi<Block, AccountId, Nonce>, + frame_rpc_system::AccountNonceApi<Block, AccountId, Nonce>,
sc_client_api::StateBackendFor<TFullBackend<Block>, Block>: sp_api::StateBackend<BlakeTwo256>, sc_client_api::StateBackendFor<TFullBackend<Block>, Block>: sp_api::StateBackend<BlakeTwo256>,
Executor: sc_executor::NativeExecutionDispatch + 'static,
RB: Fn( RB: Fn(
Arc<TFullClient<Block, RuntimeApi, Executor>>, Arc<TFullClient<Block, RuntimeApi, WasmExecutor<HostFunctions>>>,
) -> Result<jsonrpc_core::IoHandler<sc_rpc::Metadata>, sc_service::Error> ) -> Result<jsonrpc_core::IoHandler<sc_rpc::Metadata>, sc_service::Error>
+ Send + Send
+ 'static, + 'static,
BIQ: FnOnce( BIQ: FnOnce(
Arc<TFullClient<Block, RuntimeApi, NativeElseWasmExecutor<Executor>>>, Arc<TFullClient<Block, RuntimeApi, WasmExecutor<HostFunctions>>>,
&Configuration, &Configuration,
Option<TelemetryHandle>, Option<TelemetryHandle>,
&TaskManager, &TaskManager,
) -> Result< ) -> Result<
sc_consensus::DefaultImportQueue< sc_consensus::DefaultImportQueue<
Block, Block,
TFullClient<Block, RuntimeApi, NativeElseWasmExecutor<Executor>>, TFullClient<Block, RuntimeApi, WasmExecutor<HostFunctions>>,
>, >,
sc_service::Error, sc_service::Error,
> + 'static, > + 'static,
BIC: FnOnce( BIC: FnOnce(
Arc<TFullClient<Block, RuntimeApi, NativeElseWasmExecutor<Executor>>>, Arc<TFullClient<Block, RuntimeApi, WasmExecutor<HostFunctions>>>,
Option<&Registry>, Option<&Registry>,
Option<TelemetryHandle>, Option<TelemetryHandle>,
&TaskManager, &TaskManager,
@@ -544,7 +548,7 @@ where
Arc< Arc<
sc_transaction_pool::FullPool< sc_transaction_pool::FullPool<
Block, Block,
TFullClient<Block, RuntimeApi, NativeElseWasmExecutor<Executor>>, TFullClient<Block, RuntimeApi, WasmExecutor<HostFunctions>>,
>, >,
>, >,
Arc<NetworkService<Block, Hash>>, Arc<NetworkService<Block, Hash>>,
@@ -558,7 +562,7 @@ where
let parachain_config = prepare_node_config(parachain_config); let parachain_config = prepare_node_config(parachain_config);
let params = new_partial::<RuntimeApi, Executor, BIQ>(&parachain_config, build_import_queue)?; let params = new_partial::<RuntimeApi, BIQ>(&parachain_config, build_import_queue)?;
let (mut telemetry, telemetry_worker_handle) = params.other; let (mut telemetry, telemetry_worker_handle) = params.other;
let client = params.client.clone(); let client = params.client.clone();
@@ -685,11 +689,7 @@ where
/// Build the import queue for the rococo parachain runtime. /// Build the import queue for the rococo parachain runtime.
pub fn rococo_parachain_build_import_queue( pub fn rococo_parachain_build_import_queue(
client: Arc< client: Arc<
TFullClient< TFullClient<Block, rococo_parachain_runtime::RuntimeApi, WasmExecutor<HostFunctions>>,
Block,
rococo_parachain_runtime::RuntimeApi,
NativeElseWasmExecutor<RococoParachainRuntimeExecutor>,
>,
>, >,
config: &Configuration, config: &Configuration,
telemetry: Option<TelemetryHandle>, telemetry: Option<TelemetryHandle>,
@@ -697,11 +697,7 @@ pub fn rococo_parachain_build_import_queue(
) -> Result< ) -> Result<
sc_consensus::DefaultImportQueue< sc_consensus::DefaultImportQueue<
Block, Block,
TFullClient< TFullClient<Block, rococo_parachain_runtime::RuntimeApi, WasmExecutor<HostFunctions>>,
Block,
rococo_parachain_runtime::RuntimeApi,
NativeElseWasmExecutor<RococoParachainRuntimeExecutor>,
>,
>, >,
sc_service::Error, sc_service::Error,
> { > {
@@ -730,7 +726,7 @@ pub fn rococo_parachain_build_import_queue(
Ok((timestamp, slot)) Ok((timestamp, slot))
}, },
registry: config.prometheus_registry().clone(), registry: config.prometheus_registry().clone(),
can_author_with: sp_consensus::CanAuthorWithNativeVersion::new(client.executor().clone()), can_author_with: sp_consensus::AlwaysCanAuthor,
spawner: &task_manager.spawn_essential_handle(), spawner: &task_manager.spawn_essential_handle(),
telemetry, telemetry,
}) })
@@ -745,15 +741,9 @@ pub async fn start_rococo_parachain_node(
id: ParaId, id: ParaId,
) -> sc_service::error::Result<( ) -> sc_service::error::Result<(
TaskManager, TaskManager,
Arc< Arc<TFullClient<Block, rococo_parachain_runtime::RuntimeApi, WasmExecutor<HostFunctions>>>,
TFullClient<
Block,
rococo_parachain_runtime::RuntimeApi,
NativeElseWasmExecutor<RococoParachainRuntimeExecutor>,
>,
>,
)> { )> {
start_node_impl::<rococo_parachain_runtime::RuntimeApi, RococoParachainRuntimeExecutor, _, _, _>( start_node_impl::<rococo_parachain_runtime::RuntimeApi, _, _, _>(
parachain_config, parachain_config,
polkadot_config, polkadot_config,
collator_options, collator_options,
@@ -779,16 +769,8 @@ pub async fn start_rococo_parachain_node(
telemetry.clone(), telemetry.clone(),
); );
Ok(AuraConsensus::build::<sp_consensus_aura::sr25519::AuthorityPair, _, _, _, _, _, _>(
Ok(AuraConsensus::build::< BuildAuraConsensusParams {
sp_consensus_aura::sr25519::AuthorityPair,
_,
_,
_,
_,
_,
_,
>(BuildAuraConsensusParams {
proposer_factory, proposer_factory,
create_inherent_data_providers: move |_, (relay_parent, validation_data)| { create_inherent_data_providers: move |_, (relay_parent, validation_data)| {
let relay_chain_interface = relay_chain_interface.clone(); let relay_chain_interface = relay_chain_interface.clone();
@@ -831,27 +813,28 @@ pub async fn start_rococo_parachain_node(
// And a maximum of 750ms if slots are skipped // And a maximum of 750ms if slots are skipped
max_block_proposal_slot_portion: Some(SlotProportion::new(1f32 / 16f32)), max_block_proposal_slot_portion: Some(SlotProportion::new(1f32 / 16f32)),
telemetry, telemetry,
})) },
))
}, },
) )
.await .await
} }
/// Build the import queue for the shell runtime. /// Build the import queue for the shell runtime.
pub fn shell_build_import_queue<RuntimeApi, Executor>( pub fn shell_build_import_queue<RuntimeApi>(
client: Arc<TFullClient<Block, RuntimeApi, NativeElseWasmExecutor<Executor>>>, client: Arc<TFullClient<Block, RuntimeApi, WasmExecutor<HostFunctions>>>,
config: &Configuration, config: &Configuration,
_: Option<TelemetryHandle>, _: Option<TelemetryHandle>,
task_manager: &TaskManager, task_manager: &TaskManager,
) -> Result< ) -> Result<
sc_consensus::DefaultImportQueue< sc_consensus::DefaultImportQueue<
Block, Block,
TFullClient<Block, RuntimeApi, NativeElseWasmExecutor<Executor>>, TFullClient<Block, RuntimeApi, WasmExecutor<HostFunctions>>,
>, >,
sc_service::Error, sc_service::Error,
> >
where where
RuntimeApi: ConstructRuntimeApi<Block, TFullClient<Block, RuntimeApi, NativeElseWasmExecutor<Executor>>> RuntimeApi: ConstructRuntimeApi<Block, TFullClient<Block, RuntimeApi, WasmExecutor<HostFunctions>>>
+ Send + Send
+ Sync + Sync
+ 'static, + 'static,
@@ -864,7 +847,6 @@ where
> + sp_offchain::OffchainWorkerApi<Block> > + sp_offchain::OffchainWorkerApi<Block>
+ sp_block_builder::BlockBuilder<Block>, + sp_block_builder::BlockBuilder<Block>,
sc_client_api::StateBackendFor<TFullBackend<Block>, Block>: sp_api::StateBackend<BlakeTwo256>, sc_client_api::StateBackendFor<TFullBackend<Block>, Block>: sp_api::StateBackend<BlakeTwo256>,
Executor: sc_executor::NativeExecutionDispatch + 'static,
{ {
cumulus_client_consensus_relay_chain::import_queue( cumulus_client_consensus_relay_chain::import_queue(
client.clone(), client.clone(),
@@ -877,17 +859,17 @@ where
} }
/// Start a polkadot-shell parachain node. /// Start a polkadot-shell parachain node.
pub async fn start_shell_node<RuntimeApi, Executor>( pub async fn start_shell_node<RuntimeApi>(
parachain_config: Configuration, parachain_config: Configuration,
polkadot_config: Configuration, polkadot_config: Configuration,
collator_options: CollatorOptions, collator_options: CollatorOptions,
id: ParaId, id: ParaId,
) -> sc_service::error::Result<( ) -> sc_service::error::Result<(
TaskManager, TaskManager,
Arc<TFullClient<Block, RuntimeApi, NativeElseWasmExecutor<Executor>>>, Arc<TFullClient<Block, RuntimeApi, WasmExecutor<HostFunctions>>>,
)> )>
where where
RuntimeApi: ConstructRuntimeApi<Block, TFullClient<Block, RuntimeApi, NativeElseWasmExecutor<Executor>>> RuntimeApi: ConstructRuntimeApi<Block, TFullClient<Block, RuntimeApi, WasmExecutor<HostFunctions>>>
+ Send + Send
+ Sync + Sync
+ 'static, + 'static,
@@ -901,9 +883,8 @@ where
+ sp_block_builder::BlockBuilder<Block> + sp_block_builder::BlockBuilder<Block>
+ cumulus_primitives_core::CollectCollationInfo<Block>, + cumulus_primitives_core::CollectCollationInfo<Block>,
sc_client_api::StateBackendFor<TFullBackend<Block>, Block>: sp_api::StateBackend<BlakeTwo256>, sc_client_api::StateBackendFor<TFullBackend<Block>, Block>: sp_api::StateBackend<BlakeTwo256>,
Executor: sc_executor::NativeExecutionDispatch + 'static,
{ {
start_shell_node_impl::<RuntimeApi, Executor, _, _, _>( start_shell_node_impl::<RuntimeApi, _, _, _>(
parachain_config, parachain_config,
polkadot_config, polkadot_config,
collator_options, collator_options,
@@ -1066,20 +1047,20 @@ where
} }
/// Build the import queue for the statemint/statemine/westmine runtime. /// Build the import queue for the statemint/statemine/westmine runtime.
pub fn statemint_build_import_queue<RuntimeApi, Executor, AuraId: AppKey>( pub fn statemint_build_import_queue<RuntimeApi, AuraId: AppKey>(
client: Arc<TFullClient<Block, RuntimeApi, NativeElseWasmExecutor<Executor>>>, client: Arc<TFullClient<Block, RuntimeApi, WasmExecutor<HostFunctions>>>,
config: &Configuration, config: &Configuration,
telemetry_handle: Option<TelemetryHandle>, telemetry_handle: Option<TelemetryHandle>,
task_manager: &TaskManager, task_manager: &TaskManager,
) -> Result< ) -> Result<
sc_consensus::DefaultImportQueue< sc_consensus::DefaultImportQueue<
Block, Block,
TFullClient<Block, RuntimeApi, NativeElseWasmExecutor<Executor>>, TFullClient<Block, RuntimeApi, WasmExecutor<HostFunctions>>,
>, >,
sc_service::Error, sc_service::Error,
> >
where where
RuntimeApi: ConstructRuntimeApi<Block, TFullClient<Block, RuntimeApi, NativeElseWasmExecutor<Executor>>> RuntimeApi: ConstructRuntimeApi<Block, TFullClient<Block, RuntimeApi, WasmExecutor<HostFunctions>>>
+ Send + Send
+ Sync + Sync
+ 'static, + 'static,
@@ -1093,7 +1074,6 @@ where
+ sp_block_builder::BlockBuilder<Block> + sp_block_builder::BlockBuilder<Block>
+ sp_consensus_aura::AuraApi<Block, <<AuraId as AppKey>::Pair as Pair>::Public>, + sp_consensus_aura::AuraApi<Block, <<AuraId as AppKey>::Pair as Pair>::Public>,
sc_client_api::StateBackendFor<TFullBackend<Block>, Block>: sp_api::StateBackend<BlakeTwo256>, sc_client_api::StateBackendFor<TFullBackend<Block>, Block>: sp_api::StateBackend<BlakeTwo256>,
Executor: sc_executor::NativeExecutionDispatch + 'static,
<<AuraId as AppKey>::Pair as Pair>::Signature: <<AuraId as AppKey>::Pair as Pair>::Signature:
TryFrom<Vec<u8>> + std::hash::Hash + sp_runtime::traits::Member + Codec, TryFrom<Vec<u8>> + std::hash::Hash + sp_runtime::traits::Member + Codec,
{ {
@@ -1117,9 +1097,7 @@ where
Ok((timestamp, slot)) Ok((timestamp, slot))
}, },
can_author_with: sp_consensus::CanAuthorWithNativeVersion::new( can_author_with: sp_consensus::AlwaysCanAuthor,
client2.executor().clone(),
),
telemetry: telemetry_handle, telemetry: telemetry_handle,
}, },
), ),
@@ -1149,17 +1127,17 @@ where
} }
/// Start a statemint/statemine/westmint parachain node. /// Start a statemint/statemine/westmint parachain node.
pub async fn start_statemint_node<RuntimeApi, Executor, AuraId: AppKey>( pub async fn start_statemint_node<RuntimeApi, AuraId: AppKey>(
parachain_config: Configuration, parachain_config: Configuration,
polkadot_config: Configuration, polkadot_config: Configuration,
collator_options: CollatorOptions, collator_options: CollatorOptions,
id: ParaId, id: ParaId,
) -> sc_service::error::Result<( ) -> sc_service::error::Result<(
TaskManager, TaskManager,
Arc<TFullClient<Block, RuntimeApi, NativeElseWasmExecutor<Executor>>>, Arc<TFullClient<Block, RuntimeApi, WasmExecutor<HostFunctions>>>,
)> )>
where where
RuntimeApi: ConstructRuntimeApi<Block, TFullClient<Block, RuntimeApi, NativeElseWasmExecutor<Executor>>> RuntimeApi: ConstructRuntimeApi<Block, TFullClient<Block, RuntimeApi, WasmExecutor<HostFunctions>>>
+ Send + Send
+ Sync + Sync
+ 'static, + 'static,
@@ -1176,17 +1154,16 @@ where
+ pallet_transaction_payment_rpc::TransactionPaymentRuntimeApi<Block, Balance> + pallet_transaction_payment_rpc::TransactionPaymentRuntimeApi<Block, Balance>
+ frame_rpc_system::AccountNonceApi<Block, AccountId, Nonce>, + frame_rpc_system::AccountNonceApi<Block, AccountId, Nonce>,
sc_client_api::StateBackendFor<TFullBackend<Block>, Block>: sp_api::StateBackend<BlakeTwo256>, sc_client_api::StateBackendFor<TFullBackend<Block>, Block>: sp_api::StateBackend<BlakeTwo256>,
Executor: sc_executor::NativeExecutionDispatch + 'static,
<<AuraId as AppKey>::Pair as Pair>::Signature: <<AuraId as AppKey>::Pair as Pair>::Signature:
TryFrom<Vec<u8>> + std::hash::Hash + sp_runtime::traits::Member + Codec, TryFrom<Vec<u8>> + std::hash::Hash + sp_runtime::traits::Member + Codec,
{ {
start_node_impl::<RuntimeApi, Executor, _, _, _>( start_node_impl::<RuntimeApi, _, _, _>(
parachain_config, parachain_config,
polkadot_config, polkadot_config,
collator_options, collator_options,
id, id,
|_| Ok(Default::default()), |_| Ok(Default::default()),
statemint_build_import_queue::<_, _, AuraId>, statemint_build_import_queue::<_, AuraId>,
|client, |client,
prometheus_registry, prometheus_registry,
telemetry, telemetry,
@@ -1316,7 +1293,7 @@ where
} }
#[sc_tracing::logging::prefix_logs_with("Parachain")] #[sc_tracing::logging::prefix_logs_with("Parachain")]
async fn start_canvas_kusama_node_impl<RuntimeApi, Executor, RB, BIQ, BIC>( async fn start_canvas_kusama_node_impl<RuntimeApi, RB, BIQ, BIC>(
parachain_config: Configuration, parachain_config: Configuration,
polkadot_config: Configuration, polkadot_config: Configuration,
collator_options: CollatorOptions, collator_options: CollatorOptions,
@@ -1326,10 +1303,10 @@ async fn start_canvas_kusama_node_impl<RuntimeApi, Executor, RB, BIQ, BIC>(
build_consensus: BIC, build_consensus: BIC,
) -> sc_service::error::Result<( ) -> sc_service::error::Result<(
TaskManager, TaskManager,
Arc<TFullClient<Block, RuntimeApi, NativeElseWasmExecutor<Executor>>>, Arc<TFullClient<Block, RuntimeApi, WasmExecutor<HostFunctions>>>,
)> )>
where where
RuntimeApi: ConstructRuntimeApi<Block, TFullClient<Block, RuntimeApi, NativeElseWasmExecutor<Executor>>> RuntimeApi: ConstructRuntimeApi<Block, TFullClient<Block, RuntimeApi, WasmExecutor<HostFunctions>>>
+ Send + Send
+ Sync + Sync
+ 'static, + 'static,
@@ -1346,26 +1323,25 @@ where
+ frame_rpc_system::AccountNonceApi<Block, AccountId, Nonce> + frame_rpc_system::AccountNonceApi<Block, AccountId, Nonce>
+ pallet_contracts_rpc::ContractsRuntimeApi<Block, AccountId, Balance, BlockNumber, Hash>, + pallet_contracts_rpc::ContractsRuntimeApi<Block, AccountId, Balance, BlockNumber, Hash>,
sc_client_api::StateBackendFor<TFullBackend<Block>, Block>: sp_api::StateBackend<BlakeTwo256>, sc_client_api::StateBackendFor<TFullBackend<Block>, Block>: sp_api::StateBackend<BlakeTwo256>,
Executor: sc_executor::NativeExecutionDispatch + 'static,
RB: Fn( RB: Fn(
Arc<TFullClient<Block, RuntimeApi, Executor>>, Arc<TFullClient<Block, RuntimeApi, WasmExecutor<HostFunctions>>>,
) -> Result<jsonrpc_core::IoHandler<sc_rpc::Metadata>, sc_service::Error> ) -> Result<jsonrpc_core::IoHandler<sc_rpc::Metadata>, sc_service::Error>
+ Send + Send
+ 'static, + 'static,
BIQ: FnOnce( BIQ: FnOnce(
Arc<TFullClient<Block, RuntimeApi, NativeElseWasmExecutor<Executor>>>, Arc<TFullClient<Block, RuntimeApi, WasmExecutor<HostFunctions>>>,
&Configuration, &Configuration,
Option<TelemetryHandle>, Option<TelemetryHandle>,
&TaskManager, &TaskManager,
) -> Result< ) -> Result<
sc_consensus::DefaultImportQueue< sc_consensus::DefaultImportQueue<
Block, Block,
TFullClient<Block, RuntimeApi, NativeElseWasmExecutor<Executor>>, TFullClient<Block, RuntimeApi, WasmExecutor<HostFunctions>>,
>, >,
sc_service::Error, sc_service::Error,
> + 'static, > + 'static,
BIC: FnOnce( BIC: FnOnce(
Arc<TFullClient<Block, RuntimeApi, NativeElseWasmExecutor<Executor>>>, Arc<TFullClient<Block, RuntimeApi, WasmExecutor<HostFunctions>>>,
Option<&Registry>, Option<&Registry>,
Option<TelemetryHandle>, Option<TelemetryHandle>,
&TaskManager, &TaskManager,
@@ -1373,7 +1349,7 @@ where
Arc< Arc<
sc_transaction_pool::FullPool< sc_transaction_pool::FullPool<
Block, Block,
TFullClient<Block, RuntimeApi, NativeElseWasmExecutor<Executor>>, TFullClient<Block, RuntimeApi, WasmExecutor<HostFunctions>>,
>, >,
>, >,
Arc<NetworkService<Block, Hash>>, Arc<NetworkService<Block, Hash>>,
@@ -1387,7 +1363,7 @@ where
let parachain_config = prepare_node_config(parachain_config); let parachain_config = prepare_node_config(parachain_config);
let params = new_partial::<RuntimeApi, Executor, BIQ>(&parachain_config, build_import_queue)?; let params = new_partial::<RuntimeApi, BIQ>(&parachain_config, build_import_queue)?;
let (mut telemetry, telemetry_worker_handle) = params.other; let (mut telemetry, telemetry_worker_handle) = params.other;
let client = params.client.clone(); let client = params.client.clone();
@@ -1513,24 +1489,14 @@ where
#[allow(clippy::type_complexity)] #[allow(clippy::type_complexity)]
pub fn canvas_kusama_build_import_queue( pub fn canvas_kusama_build_import_queue(
client: Arc< client: Arc<TFullClient<Block, canvas_kusama_runtime::RuntimeApi, WasmExecutor<HostFunctions>>>,
TFullClient<
Block,
canvas_kusama_runtime::RuntimeApi,
NativeElseWasmExecutor<CanvasKusamaRuntimeExecutor>,
>,
>,
config: &Configuration, config: &Configuration,
telemetry: Option<TelemetryHandle>, telemetry: Option<TelemetryHandle>,
task_manager: &TaskManager, task_manager: &TaskManager,
) -> Result< ) -> Result<
sc_consensus::DefaultImportQueue< sc_consensus::DefaultImportQueue<
Block, Block,
TFullClient< TFullClient<Block, canvas_kusama_runtime::RuntimeApi, WasmExecutor<HostFunctions>>,
Block,
canvas_kusama_runtime::RuntimeApi,
NativeElseWasmExecutor<CanvasKusamaRuntimeExecutor>,
>,
>, >,
sc_service::Error, sc_service::Error,
> { > {
@@ -1559,7 +1525,7 @@ pub fn canvas_kusama_build_import_queue(
Ok((timestamp, slot)) Ok((timestamp, slot))
}, },
registry: config.prometheus_registry(), 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(), spawner: &task_manager.spawn_essential_handle(),
telemetry, telemetry,
}) })
@@ -1574,21 +1540,9 @@ pub async fn start_canvas_kusama_node(
id: ParaId, id: ParaId,
) -> sc_service::error::Result<( ) -> sc_service::error::Result<(
TaskManager, TaskManager,
Arc< Arc<TFullClient<Block, canvas_kusama_runtime::RuntimeApi, WasmExecutor<HostFunctions>>>,
TFullClient<
Block,
canvas_kusama_runtime::RuntimeApi,
NativeElseWasmExecutor<CanvasKusamaRuntimeExecutor>,
>,
>,
)> { )> {
start_canvas_kusama_node_impl::< start_canvas_kusama_node_impl::<canvas_kusama_runtime::RuntimeApi, _, _, _>(
canvas_kusama_runtime::RuntimeApi,
CanvasKusamaRuntimeExecutor,
_,
_,
_,
>(
parachain_config, parachain_config,
polkadot_config, polkadot_config,
collator_options, collator_options,