Integrate Shell runtime into collator (#414)

* Introduce the converter into the hub

* Parachain recognises Rococo governance body as admin

* Whitespace

* Use UsingComponents for fee payment in XCM

* Fixes

* Fixes for XCM permissions

* Remove encode_call test

* Fixes

* Rococo Collator supports Shell runtime

* Fixes

* Fixes
This commit is contained in:
Gavin Wood
2021-04-28 18:35:55 +02:00
committed by GitHub
parent fc82a611ce
commit 9e8f16b970
6 changed files with 411 additions and 315 deletions
+68 -11
View File
@@ -22,7 +22,6 @@ use cumulus_client_service::{
prepare_node_config, start_collator, start_full_node, StartCollatorParams, StartFullNodeParams,
};
use cumulus_primitives_core::ParaId;
use parachain_runtime::RuntimeApi;
use polkadot_primitives::v0::CollatorPair;
use rococo_parachain_primitives::Block;
use sc_executor::native_executor_instance;
@@ -31,20 +30,28 @@ use sc_service::{Configuration, PartialComponents, Role, TFullBackend, TFullClie
use sc_telemetry::{Telemetry, TelemetryWorker, TelemetryWorkerHandle};
use sp_runtime::traits::BlakeTwo256;
use sp_trie::PrefixedMemoryDB;
use sp_api::ConstructRuntimeApi;
use std::sync::Arc;
// Native executor instance.
native_executor_instance!(
pub Executor,
pub RuntimeExecutor,
parachain_runtime::api::dispatch,
parachain_runtime::native_version,
);
// Native executor instance.
native_executor_instance!(
pub ShellRuntimeExecutor,
shell_runtime::api::dispatch,
shell_runtime::native_version,
);
/// Starts a `ServiceBuilder` for a full service.
///
/// 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.
pub fn new_partial(
pub fn new_partial<RuntimeApi, Executor>(
config: &Configuration,
) -> Result<
PartialComponents<
@@ -56,7 +63,22 @@ pub fn new_partial(
(Option<Telemetry>, Option<TelemetryWorkerHandle>),
>,
sc_service::Error,
> {
> where
RuntimeApi: ConstructRuntimeApi<Block, TFullClient<Block, RuntimeApi, Executor>>
+ Send
+ Sync
+ 'static,
RuntimeApi::RuntimeApi: sp_transaction_pool::runtime_api::TaggedTransactionQueue<Block>
+ sp_api::Metadata<Block>
+ sp_session::SessionKeys<Block>
+ sp_api::ApiExt<
Block,
StateBackend = sc_client_api::StateBackendFor<TFullBackend<Block>, Block>,
> + sp_offchain::OffchainWorkerApi<Block>
+ sp_block_builder::BlockBuilder<Block>,
sc_client_api::StateBackendFor<TFullBackend<Block>, Block>: sp_api::StateBackend<BlakeTwo256>,
Executor: sc_executor::NativeExecutionDispatch + 'static,
{
let inherent_data_providers = sp_inherents::InherentDataProviders::new();
let telemetry = config.telemetry_endpoints.clone()
@@ -122,7 +144,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<RB>(
async fn start_node_impl<RuntimeApi, Executor, RB>(
parachain_config: Configuration,
collator_key: CollatorPair,
polkadot_config: Configuration,
@@ -131,6 +153,20 @@ async fn start_node_impl<RB>(
rpc_ext_builder: RB,
) -> sc_service::error::Result<(TaskManager, Arc<TFullClient<Block, RuntimeApi, Executor>>)>
where
RuntimeApi: ConstructRuntimeApi<Block, TFullClient<Block, RuntimeApi, Executor>>
+ Send
+ Sync
+ 'static,
RuntimeApi::RuntimeApi: sp_transaction_pool::runtime_api::TaggedTransactionQueue<Block>
+ sp_api::Metadata<Block>
+ sp_session::SessionKeys<Block>
+ sp_api::ApiExt<
Block,
StateBackend = sc_client_api::StateBackendFor<TFullBackend<Block>, Block>,
> + sp_offchain::OffchainWorkerApi<Block>
+ sp_block_builder::BlockBuilder<Block>,
sc_client_api::StateBackendFor<TFullBackend<Block>, Block>: sp_api::StateBackend<BlakeTwo256>,
Executor: sc_executor::NativeExecutionDispatch + 'static,
RB: Fn(
Arc<TFullClient<Block, RuntimeApi, Executor>>,
) -> jsonrpc_core::IoHandler<sc_rpc::Metadata>
@@ -143,7 +179,7 @@ where
let parachain_config = prepare_node_config(parachain_config);
let params = new_partial(&parachain_config)?;
let params = new_partial::<RuntimeApi, Executor>(&parachain_config)?;
params
.inherent_data_providers
.register_provider(sp_timestamp::InherentDataProvider)
@@ -259,21 +295,42 @@ where
Ok((task_manager, client))
}
/// Start a normal parachain node.
/// Start a rococo-test parachain node.
pub async fn start_node(
parachain_config: Configuration,
collator_key: CollatorPair,
polkadot_config: Configuration,
id: ParaId,
validator: bool,
) -> sc_service::error::Result<(TaskManager, Arc<TFullClient<Block, RuntimeApi, Executor>>)> {
start_node_impl(
) -> sc_service::error::Result<
(TaskManager, Arc<TFullClient<Block, parachain_runtime::RuntimeApi, RuntimeExecutor>>)
> {
start_node_impl::<parachain_runtime::RuntimeApi, RuntimeExecutor, _>(
parachain_config,
collator_key,
polkadot_config,
id,
validator,
|_| Default::default(),
)
.await
).await
}
/// Start a rococo-shell parachain node.
pub async fn start_shell_node(
parachain_config: Configuration,
collator_key: CollatorPair,
polkadot_config: Configuration,
id: ParaId,
validator: bool,
) -> sc_service::error::Result<
(TaskManager, Arc<TFullClient<Block, shell_runtime::RuntimeApi, ShellRuntimeExecutor>>)
> {
start_node_impl::<shell_runtime::RuntimeApi, ShellRuntimeExecutor, _>(
parachain_config,
collator_key,
polkadot_config,
id,
validator,
|_| Default::default(),
).await
}