Skip to content
Snippets Groups Projects
Unverified Commit 2aa006e0 authored by Sebastian Kunert's avatar Sebastian Kunert Committed by GitHub
Browse files

Refactor polkadot-parachain service for more code reuse (#3511)


This is a refactoring, no changes to the logic are included (if you find
some, report :D).

## Change Overview
In https://github.com/paritytech/polkadot-sdk/issues/2455, dependency on
actual runtimes was removed for the system parachains. This means that
the trait bounds we have on various `start_node_xy` do not check
anything anymore, since they all point to the same runtime. Exception is
asset-hub-polkadot which uses a different key type.

This PR unifies the different nodes as much as possible.
`start_node_impl` is doing the heavy lifting and has been made a bit
more flexible to support the rpc extension instantiation that was there
before.

The generics for `Runtime` and `AuraId` have been removed where
possible. The fake runtime is imported as `FakeRuntime` to make it very
clear to readers that it is not the generic parameter.

Multiple nodes where using the same import queue/start_consensus
closure, they have been unified.

---------

Co-authored-by: default avatarKian Paimani <5588131+kianenigma@users.noreply.github.com>
Co-authored-by: default avatarFrancisco Aguirre <franciscoaguirreperez@gmail.com>
Co-authored-by: default avatarAdrian Catangiu <adrian@parity.io>
Co-authored-by: default avatarEgor_P <egor@parity.io>
Co-authored-by: default avatarDmitry Markin <dmitry@markin.tech>
Co-authored-by: default avatarXiliang Chen <xlchen1291@gmail.com>
Co-authored-by: default avatarAndrei Eres <eresav@me.com>
Co-authored-by: default avatarAlexander Samusev <41779041+alvicsam@users.noreply.github.com>
Co-authored-by: default avatarAlin Dima <alin@parity.io>
Co-authored-by: default avatargupnik <nikhilgupta.iitk@gmail.com>
Co-authored-by: default avatarLiam Aharon <liam.aharon@hotmail.com>
Co-authored-by: default avatarDónal Murray <donalm@seadanda.dev>
parent f4fbddec
No related merge requests found
Pipeline #453028 failed with stages
in 44 minutes and 3 seconds
......@@ -399,7 +399,7 @@ macro_rules! construct_partials {
Runtime::AssetHubPolkadot => {
let $partials = new_partial::<AssetHubPolkadotRuntimeApi, _>(
&$config,
crate::service::aura_build_import_queue::<_, AssetHubPolkadotAuraId>,
crate::service::build_relay_to_aura_import_queue::<_, AssetHubPolkadotAuraId>,
)?;
$code
},
......@@ -413,28 +413,21 @@ macro_rules! construct_partials {
Runtime::People(_) => {
let $partials = new_partial::<RuntimeApi, _>(
&$config,
crate::service::aura_build_import_queue::<_, AuraId>,
crate::service::build_relay_to_aura_import_queue::<_, AuraId>,
)?;
$code
},
Runtime::GluttonWestend | Runtime::Glutton | Runtime::Shell | Runtime::Seedling => {
let $partials = new_partial::<RuntimeApi, _>(
&$config,
crate::service::shell_build_import_queue,
crate::service::build_shell_import_queue,
)?;
$code
},
Runtime::ContractsRococo => {
Runtime::ContractsRococo | Runtime::Penpal(_) | Runtime::Default => {
let $partials = new_partial::<RuntimeApi, _>(
&$config,
crate::service::contracts_rococo_build_import_queue,
)?;
$code
},
Runtime::Penpal(_) | Runtime::Default => {
let $partials = new_partial::<RuntimeApi, _>(
&$config,
crate::service::rococo_parachain_build_import_queue,
crate::service::build_aura_import_queue,
)?;
$code
},
......@@ -450,7 +443,7 @@ macro_rules! construct_async_run {
runner.async_run(|$config| {
let $components = new_partial::<AssetHubPolkadotRuntimeApi, _>(
&$config,
crate::service::aura_build_import_queue::<_, AssetHubPolkadotAuraId>,
crate::service::build_relay_to_aura_import_queue::<_, AssetHubPolkadotAuraId>,
)?;
let task_manager = $components.task_manager;
{ $( $code )* }.map(|v| (v, task_manager))
......@@ -467,7 +460,7 @@ macro_rules! construct_async_run {
runner.async_run(|$config| {
let $components = new_partial::<RuntimeApi, _>(
&$config,
crate::service::aura_build_import_queue::<_, AuraId>,
crate::service::build_relay_to_aura_import_queue::<_, AuraId>,
)?;
let task_manager = $components.task_manager;
{ $( $code )* }.map(|v| (v, task_manager))
......@@ -480,30 +473,20 @@ macro_rules! construct_async_run {
runner.async_run(|$config| {
let $components = new_partial::<RuntimeApi, _>(
&$config,
crate::service::shell_build_import_queue,
crate::service::build_shell_import_queue,
)?;
let task_manager = $components.task_manager;
{ $( $code )* }.map(|v| (v, task_manager))
})
}
Runtime::ContractsRococo => {
runner.async_run(|$config| {
let $components = new_partial::<RuntimeApi, _>(
&$config,
crate::service::contracts_rococo_build_import_queue,
)?;
let task_manager = $components.task_manager;
{ $( $code )* }.map(|v| (v, task_manager))
})
},
Runtime::Penpal(_) | Runtime::Default => {
Runtime::ContractsRococo | Runtime::Penpal(_) | Runtime::Default => {
runner.async_run(|$config| {
let $components = new_partial::<
RuntimeApi,
_,
>(
&$config,
crate::service::rococo_parachain_build_import_queue,
crate::service::build_aura_import_queue,
)?;
let task_manager = $components.task_manager;
{ $( $code )* }.map(|v| (v, task_manager))
......@@ -715,25 +698,19 @@ pub fn run() -> Result<()> {
.map_err(Into::into),
CollectivesPolkadot =>
crate::service::start_generic_aura_node::<
RuntimeApi,
AuraId,
>(config, polkadot_config, collator_options, id, hwbench)
crate::service::start_generic_aura_node(config, polkadot_config, collator_options, id, hwbench)
.await
.map(|r| r.0)
.map_err(Into::into),
CollectivesWestend =>
crate::service::start_generic_aura_lookahead_node::<
RuntimeApi,
AuraId,
>(config, polkadot_config, collator_options, id, hwbench)
crate::service::start_generic_aura_lookahead_node(config, polkadot_config, collator_options, id, hwbench)
.await
.map(|r| r.0)
.map_err(Into::into),
Seedling | Shell =>
crate::service::start_shell_node::<RuntimeApi>(
crate::service::start_shell_node(
config,
polkadot_config,
collator_options,
......@@ -758,36 +735,24 @@ pub fn run() -> Result<()> {
BridgeHub(bridge_hub_runtime_type) => match bridge_hub_runtime_type {
chain_spec::bridge_hubs::BridgeHubRuntimeType::Polkadot |
chain_spec::bridge_hubs::BridgeHubRuntimeType::PolkadotLocal =>
crate::service::start_generic_aura_node::<
RuntimeApi,
AuraId,
>(config, polkadot_config, collator_options, id, hwbench)
crate::service::start_generic_aura_node(config, polkadot_config, collator_options, id, hwbench)
.await
.map(|r| r.0),
chain_spec::bridge_hubs::BridgeHubRuntimeType::Kusama |
chain_spec::bridge_hubs::BridgeHubRuntimeType::KusamaLocal =>
crate::service::start_generic_aura_node::<
RuntimeApi,
AuraId,
>(config, polkadot_config, collator_options, id, hwbench)
crate::service::start_generic_aura_node(config, polkadot_config, collator_options, id, hwbench)
.await
.map(|r| r.0),
chain_spec::bridge_hubs::BridgeHubRuntimeType::Westend |
chain_spec::bridge_hubs::BridgeHubRuntimeType::WestendLocal |
chain_spec::bridge_hubs::BridgeHubRuntimeType::WestendDevelopment =>
crate::service::start_generic_aura_lookahead_node::<
RuntimeApi,
AuraId,
>(config, polkadot_config, collator_options, id, hwbench)
crate::service::start_generic_aura_lookahead_node(config, polkadot_config, collator_options, id, hwbench)
.await
.map(|r| r.0),
chain_spec::bridge_hubs::BridgeHubRuntimeType::Rococo |
chain_spec::bridge_hubs::BridgeHubRuntimeType::RococoLocal |
chain_spec::bridge_hubs::BridgeHubRuntimeType::RococoDevelopment =>
crate::service::start_generic_aura_lookahead_node::<
RuntimeApi,
AuraId,
>(config, polkadot_config, collator_options, id, hwbench)
crate::service::start_generic_aura_lookahead_node(config, polkadot_config, collator_options, id, hwbench)
.await
.map(|r| r.0),
}
......@@ -800,10 +765,7 @@ pub fn run() -> Result<()> {
chain_spec::coretime::CoretimeRuntimeType::Westend |
chain_spec::coretime::CoretimeRuntimeType::WestendLocal |
chain_spec::coretime::CoretimeRuntimeType::WestendDevelopment =>
crate::service::start_generic_aura_lookahead_node::<
RuntimeApi,
AuraId,
>(config, polkadot_config, collator_options, id, hwbench)
crate::service::start_generic_aura_lookahead_node(config, polkadot_config, collator_options, id, hwbench)
.await
.map(|r| r.0),
}
......@@ -822,10 +784,7 @@ pub fn run() -> Result<()> {
.map_err(Into::into),
Glutton | GluttonWestend =>
crate::service::start_basic_lookahead_node::<
RuntimeApi,
AuraId,
>(config, polkadot_config, collator_options, id, hwbench)
crate::service::start_basic_lookahead_node(config, polkadot_config, collator_options, id, hwbench)
.await
.map(|r| r.0)
.map_err(Into::into),
......@@ -837,10 +796,7 @@ pub fn run() -> Result<()> {
chain_spec::people::PeopleRuntimeType::Westend |
chain_spec::people::PeopleRuntimeType::WestendLocal |
chain_spec::people::PeopleRuntimeType::WestendDevelopment =>
crate::service::start_generic_aura_lookahead_node::<
RuntimeApi,
AuraId,
>(config, polkadot_config, collator_options, id, hwbench)
crate::service::start_generic_aura_lookahead_node(config, polkadot_config, collator_options, id, hwbench)
.await
.map(|r| r.0),
}
......
This diff is collapsed.
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment