mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-05-31 05:11:02 +00:00
Enable mainnet system parachains to use async backing-enabled collator (#3630)
This is phase 2 of async backing enablement for the system parachains on the production networks. ~~It should be merged after polkadot-fellows/runtimes#228 is enacted. After it is released,~~ all the system parachain collators should be upgraded, and then we can proceed with phase 3, which will enable async backing in the runtimes. UPDATE: Indeed, we don't need to wait for the runtime upgrade enactions. The lookahead collator handles the transition by itself, so we can upgrade ASAP. ## Scope of changes Here, we eliminate the dichotomy of having "generic Aura collators" for the production system parachains and "lookahead Aura collators" for the testnet system parachains. Now, all the collators are started as lookahead ones, preserving the logic of transferring from the shell node to Aura-enabled collators for the asset hubs. So, indeed, it simplifies the parachain service logic, which cannot but rejoice.
This commit is contained in:
@@ -315,9 +315,10 @@ where
|
|||||||
let mut parent_header = initial_parent.header;
|
let mut parent_header = initial_parent.header;
|
||||||
let overseer_handle = &mut params.overseer_handle;
|
let overseer_handle = &mut params.overseer_handle;
|
||||||
|
|
||||||
// We mainly call this to inform users at genesis if there is a mismatch with the
|
// Do not try to build upon an unknown, pruned or bad block
|
||||||
// on-chain data.
|
if !collator.collator_service().check_block_status(parent_hash, &parent_header) {
|
||||||
collator.collator_service().check_block_status(parent_hash, &parent_header);
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
// This needs to change to support elastic scaling, but for continuously
|
// This needs to change to support elastic scaling, but for continuously
|
||||||
// scheduled chains this ensures that the backlog will grow steadily.
|
// scheduled chains this ensures that the backlog will grow steadily.
|
||||||
|
|||||||
@@ -702,7 +702,7 @@ async fn start_node<Network: sc_network::NetworkBackend<Block, Hash>>(
|
|||||||
hwbench: Option<sc_sysinfo::HwBench>,
|
hwbench: Option<sc_sysinfo::HwBench>,
|
||||||
) -> Result<sc_service::TaskManager> {
|
) -> Result<sc_service::TaskManager> {
|
||||||
match config.chain_spec.runtime()? {
|
match config.chain_spec.runtime()? {
|
||||||
Runtime::AssetHubPolkadot => crate::service::start_asset_hub_node::<
|
Runtime::AssetHubPolkadot => crate::service::start_asset_hub_lookahead_node::<
|
||||||
AssetHubPolkadotRuntimeApi,
|
AssetHubPolkadotRuntimeApi,
|
||||||
AssetHubPolkadotAuraId,
|
AssetHubPolkadotAuraId,
|
||||||
Network,
|
Network,
|
||||||
@@ -711,16 +711,7 @@ async fn start_node<Network: sc_network::NetworkBackend<Block, Hash>>(
|
|||||||
.map(|r| r.0)
|
.map(|r| r.0)
|
||||||
.map_err(Into::into),
|
.map_err(Into::into),
|
||||||
|
|
||||||
Runtime::AssetHubKusama => crate::service::start_asset_hub_node::<
|
Runtime::AssetHubRococo | Runtime::AssetHubWestend | Runtime::AssetHubKusama =>
|
||||||
RuntimeApi,
|
|
||||||
AuraId,
|
|
||||||
Network,
|
|
||||||
>(config, polkadot_config, collator_options, id, hwbench)
|
|
||||||
.await
|
|
||||||
.map(|r| r.0)
|
|
||||||
.map_err(Into::into),
|
|
||||||
|
|
||||||
Runtime::AssetHubRococo | Runtime::AssetHubWestend =>
|
|
||||||
crate::service::start_asset_hub_lookahead_node::<RuntimeApi, AuraId, Network>(
|
crate::service::start_asset_hub_lookahead_node::<RuntimeApi, AuraId, Network>(
|
||||||
config,
|
config,
|
||||||
polkadot_config,
|
polkadot_config,
|
||||||
@@ -732,18 +723,7 @@ async fn start_node<Network: sc_network::NetworkBackend<Block, Hash>>(
|
|||||||
.map(|r| r.0)
|
.map(|r| r.0)
|
||||||
.map_err(Into::into),
|
.map_err(Into::into),
|
||||||
|
|
||||||
Runtime::CollectivesPolkadot => crate::service::start_generic_aura_node::<Network>(
|
Runtime::CollectivesWestend | Runtime::CollectivesPolkadot =>
|
||||||
config,
|
|
||||||
polkadot_config,
|
|
||||||
collator_options,
|
|
||||||
id,
|
|
||||||
hwbench,
|
|
||||||
)
|
|
||||||
.await
|
|
||||||
.map(|r| r.0)
|
|
||||||
.map_err(Into::into),
|
|
||||||
|
|
||||||
Runtime::CollectivesWestend =>
|
|
||||||
crate::service::start_generic_aura_lookahead_node::<Network>(
|
crate::service::start_generic_aura_lookahead_node::<Network>(
|
||||||
config,
|
config,
|
||||||
polkadot_config,
|
polkadot_config,
|
||||||
@@ -779,39 +759,12 @@ async fn start_node<Network: sc_network::NetworkBackend<Block, Hash>>(
|
|||||||
|
|
||||||
Runtime::BridgeHub(bridge_hub_runtime_type) => match bridge_hub_runtime_type {
|
Runtime::BridgeHub(bridge_hub_runtime_type) => match bridge_hub_runtime_type {
|
||||||
chain_spec::bridge_hubs::BridgeHubRuntimeType::Polkadot |
|
chain_spec::bridge_hubs::BridgeHubRuntimeType::Polkadot |
|
||||||
chain_spec::bridge_hubs::BridgeHubRuntimeType::PolkadotLocal =>
|
chain_spec::bridge_hubs::BridgeHubRuntimeType::PolkadotLocal |
|
||||||
crate::service::start_generic_aura_node::<Network>(
|
|
||||||
config,
|
|
||||||
polkadot_config,
|
|
||||||
collator_options,
|
|
||||||
id,
|
|
||||||
hwbench,
|
|
||||||
)
|
|
||||||
.await
|
|
||||||
.map(|r| r.0),
|
|
||||||
chain_spec::bridge_hubs::BridgeHubRuntimeType::Kusama |
|
chain_spec::bridge_hubs::BridgeHubRuntimeType::Kusama |
|
||||||
chain_spec::bridge_hubs::BridgeHubRuntimeType::KusamaLocal =>
|
chain_spec::bridge_hubs::BridgeHubRuntimeType::KusamaLocal |
|
||||||
crate::service::start_generic_aura_node::<Network>(
|
|
||||||
config,
|
|
||||||
polkadot_config,
|
|
||||||
collator_options,
|
|
||||||
id,
|
|
||||||
hwbench,
|
|
||||||
)
|
|
||||||
.await
|
|
||||||
.map(|r| r.0),
|
|
||||||
chain_spec::bridge_hubs::BridgeHubRuntimeType::Westend |
|
chain_spec::bridge_hubs::BridgeHubRuntimeType::Westend |
|
||||||
chain_spec::bridge_hubs::BridgeHubRuntimeType::WestendLocal |
|
chain_spec::bridge_hubs::BridgeHubRuntimeType::WestendLocal |
|
||||||
chain_spec::bridge_hubs::BridgeHubRuntimeType::WestendDevelopment =>
|
chain_spec::bridge_hubs::BridgeHubRuntimeType::WestendDevelopment |
|
||||||
crate::service::start_generic_aura_lookahead_node::<Network>(
|
|
||||||
config,
|
|
||||||
polkadot_config,
|
|
||||||
collator_options,
|
|
||||||
id,
|
|
||||||
hwbench,
|
|
||||||
)
|
|
||||||
.await
|
|
||||||
.map(|r| r.0),
|
|
||||||
chain_spec::bridge_hubs::BridgeHubRuntimeType::Rococo |
|
chain_spec::bridge_hubs::BridgeHubRuntimeType::Rococo |
|
||||||
chain_spec::bridge_hubs::BridgeHubRuntimeType::RococoLocal |
|
chain_spec::bridge_hubs::BridgeHubRuntimeType::RococoLocal |
|
||||||
chain_spec::bridge_hubs::BridgeHubRuntimeType::RococoDevelopment =>
|
chain_spec::bridge_hubs::BridgeHubRuntimeType::RococoDevelopment =>
|
||||||
|
|||||||
@@ -17,10 +17,7 @@
|
|||||||
use codec::{Codec, Decode};
|
use codec::{Codec, Decode};
|
||||||
use cumulus_client_cli::CollatorOptions;
|
use cumulus_client_cli::CollatorOptions;
|
||||||
use cumulus_client_collator::service::CollatorService;
|
use cumulus_client_collator::service::CollatorService;
|
||||||
use cumulus_client_consensus_aura::collators::{
|
use cumulus_client_consensus_aura::collators::lookahead::{self as aura, Params as AuraParams};
|
||||||
basic::{self as basic_aura, Params as BasicAuraParams},
|
|
||||||
lookahead::{self as aura, Params as AuraParams},
|
|
||||||
};
|
|
||||||
use cumulus_client_consensus_common::{
|
use cumulus_client_consensus_common::{
|
||||||
ParachainBlockImport as TParachainBlockImport, ParachainCandidate, ParachainConsensus,
|
ParachainBlockImport as TParachainBlockImport, ParachainCandidate, ParachainConsensus,
|
||||||
};
|
};
|
||||||
@@ -687,82 +684,6 @@ where
|
|||||||
Ok(BasicQueue::new(verifier, Box::new(block_import), None, &spawner, registry))
|
Ok(BasicQueue::new(verifier, Box::new(block_import), None, &spawner, registry))
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Start an aura powered parachain node. Some system chains use this.
|
|
||||||
pub async fn start_generic_aura_node<Net: NetworkBackend<Block, Hash>>(
|
|
||||||
parachain_config: Configuration,
|
|
||||||
polkadot_config: Configuration,
|
|
||||||
collator_options: CollatorOptions,
|
|
||||||
para_id: ParaId,
|
|
||||||
hwbench: Option<sc_sysinfo::HwBench>,
|
|
||||||
) -> sc_service::error::Result<(TaskManager, Arc<ParachainClient<FakeRuntimeApi>>)> {
|
|
||||||
start_node_impl::<FakeRuntimeApi, _, _, _, Net>(
|
|
||||||
parachain_config,
|
|
||||||
polkadot_config,
|
|
||||||
collator_options,
|
|
||||||
CollatorSybilResistance::Resistant, // Aura
|
|
||||||
para_id,
|
|
||||||
build_parachain_rpc_extensions::<FakeRuntimeApi>,
|
|
||||||
build_relay_to_aura_import_queue::<_, AuraId>,
|
|
||||||
|client,
|
|
||||||
block_import,
|
|
||||||
prometheus_registry,
|
|
||||||
telemetry,
|
|
||||||
task_manager,
|
|
||||||
relay_chain_interface,
|
|
||||||
transaction_pool,
|
|
||||||
sync_oracle,
|
|
||||||
keystore,
|
|
||||||
relay_chain_slot_duration,
|
|
||||||
para_id,
|
|
||||||
collator_key,
|
|
||||||
overseer_handle,
|
|
||||||
announce_block,
|
|
||||||
_backend| {
|
|
||||||
let proposer_factory = sc_basic_authorship::ProposerFactory::with_proof_recording(
|
|
||||||
task_manager.spawn_handle(),
|
|
||||||
client.clone(),
|
|
||||||
transaction_pool,
|
|
||||||
prometheus_registry,
|
|
||||||
telemetry.clone(),
|
|
||||||
);
|
|
||||||
let proposer = Proposer::new(proposer_factory);
|
|
||||||
|
|
||||||
let collator_service = CollatorService::new(
|
|
||||||
client.clone(),
|
|
||||||
Arc::new(task_manager.spawn_handle()),
|
|
||||||
announce_block,
|
|
||||||
client.clone(),
|
|
||||||
);
|
|
||||||
|
|
||||||
let params = BasicAuraParams {
|
|
||||||
create_inherent_data_providers: move |_, ()| async move { Ok(()) },
|
|
||||||
block_import,
|
|
||||||
para_client: client,
|
|
||||||
relay_client: relay_chain_interface,
|
|
||||||
sync_oracle,
|
|
||||||
keystore,
|
|
||||||
collator_key,
|
|
||||||
para_id,
|
|
||||||
overseer_handle,
|
|
||||||
relay_chain_slot_duration,
|
|
||||||
proposer,
|
|
||||||
collator_service,
|
|
||||||
// Very limited proposal time.
|
|
||||||
authoring_duration: Duration::from_millis(500),
|
|
||||||
collation_request_receiver: None,
|
|
||||||
};
|
|
||||||
|
|
||||||
let fut =
|
|
||||||
basic_aura::run::<Block, <AuraId as AppCrypto>::Pair, _, _, _, _, _, _, _>(params);
|
|
||||||
task_manager.spawn_essential_handle().spawn("aura", None, fut);
|
|
||||||
|
|
||||||
Ok(())
|
|
||||||
},
|
|
||||||
hwbench,
|
|
||||||
)
|
|
||||||
.await
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Uses the lookahead collator to support async backing.
|
/// Uses the lookahead collator to support async backing.
|
||||||
///
|
///
|
||||||
/// Start an aura powered parachain node. Some system chains use this.
|
/// Start an aura powered parachain node. Some system chains use this.
|
||||||
@@ -787,142 +708,6 @@ pub async fn start_generic_aura_lookahead_node<Net: NetworkBackend<Block, Hash>>
|
|||||||
.await
|
.await
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Start a shell node which should later transition into an Aura powered parachain node. Asset Hub
|
|
||||||
/// uses this because at genesis, Asset Hub was on the `shell` runtime which didn't have Aura and
|
|
||||||
/// needs to sync and upgrade before it can run `AuraApi` functions.
|
|
||||||
pub async fn start_asset_hub_node<RuntimeApi, AuraId: AppCrypto + Send + Codec + Sync, Net>(
|
|
||||||
parachain_config: Configuration,
|
|
||||||
polkadot_config: Configuration,
|
|
||||||
collator_options: CollatorOptions,
|
|
||||||
para_id: ParaId,
|
|
||||||
hwbench: Option<sc_sysinfo::HwBench>,
|
|
||||||
) -> sc_service::error::Result<(TaskManager, Arc<ParachainClient<RuntimeApi>>)>
|
|
||||||
where
|
|
||||||
RuntimeApi: ConstructRuntimeApi<Block, ParachainClient<RuntimeApi>> + Send + Sync + 'static,
|
|
||||||
RuntimeApi::RuntimeApi: sp_transaction_pool::runtime_api::TaggedTransactionQueue<Block>
|
|
||||||
+ sp_api::Metadata<Block>
|
|
||||||
+ sp_session::SessionKeys<Block>
|
|
||||||
+ sp_api::ApiExt<Block>
|
|
||||||
+ sp_offchain::OffchainWorkerApi<Block>
|
|
||||||
+ sp_block_builder::BlockBuilder<Block>
|
|
||||||
+ cumulus_primitives_core::CollectCollationInfo<Block>
|
|
||||||
+ sp_consensus_aura::AuraApi<Block, <<AuraId as AppCrypto>::Pair as Pair>::Public>
|
|
||||||
+ pallet_transaction_payment_rpc::TransactionPaymentRuntimeApi<Block, Balance>
|
|
||||||
+ frame_rpc_system::AccountNonceApi<Block, AccountId, Nonce>,
|
|
||||||
<<AuraId as AppCrypto>::Pair as Pair>::Signature:
|
|
||||||
TryFrom<Vec<u8>> + std::hash::Hash + sp_runtime::traits::Member + Codec,
|
|
||||||
Net: NetworkBackend<Block, Hash>,
|
|
||||||
{
|
|
||||||
start_node_impl::<RuntimeApi, _, _, _, Net>(
|
|
||||||
parachain_config,
|
|
||||||
polkadot_config,
|
|
||||||
collator_options,
|
|
||||||
CollatorSybilResistance::Resistant, // Aura
|
|
||||||
para_id,
|
|
||||||
build_parachain_rpc_extensions::<RuntimeApi>,
|
|
||||||
build_relay_to_aura_import_queue::<_, AuraId>,
|
|
||||||
|client,
|
|
||||||
block_import,
|
|
||||||
prometheus_registry,
|
|
||||||
telemetry,
|
|
||||||
task_manager,
|
|
||||||
relay_chain_interface,
|
|
||||||
transaction_pool,
|
|
||||||
sync_oracle,
|
|
||||||
keystore,
|
|
||||||
relay_chain_slot_duration,
|
|
||||||
para_id,
|
|
||||||
collator_key,
|
|
||||||
overseer_handle,
|
|
||||||
announce_block,
|
|
||||||
_backend| {
|
|
||||||
let relay_chain_interface2 = relay_chain_interface.clone();
|
|
||||||
|
|
||||||
let collator_service = CollatorService::new(
|
|
||||||
client.clone(),
|
|
||||||
Arc::new(task_manager.spawn_handle()),
|
|
||||||
announce_block,
|
|
||||||
client.clone(),
|
|
||||||
);
|
|
||||||
|
|
||||||
let spawner = task_manager.spawn_handle();
|
|
||||||
|
|
||||||
let proposer_factory = sc_basic_authorship::ProposerFactory::with_proof_recording(
|
|
||||||
spawner,
|
|
||||||
client.clone(),
|
|
||||||
transaction_pool,
|
|
||||||
prometheus_registry,
|
|
||||||
telemetry.clone(),
|
|
||||||
);
|
|
||||||
|
|
||||||
let collation_future = Box::pin(async move {
|
|
||||||
// Start collating with the `shell` runtime while waiting for an upgrade to an Aura
|
|
||||||
// compatible runtime.
|
|
||||||
let mut request_stream = cumulus_client_collator::relay_chain_driven::init(
|
|
||||||
collator_key.clone(),
|
|
||||||
para_id,
|
|
||||||
overseer_handle.clone(),
|
|
||||||
)
|
|
||||||
.await;
|
|
||||||
while let Some(request) = request_stream.next().await {
|
|
||||||
let pvd = request.persisted_validation_data().clone();
|
|
||||||
let last_head_hash =
|
|
||||||
match <Block as BlockT>::Header::decode(&mut &pvd.parent_head.0[..]) {
|
|
||||||
Ok(header) => header.hash(),
|
|
||||||
Err(e) => {
|
|
||||||
log::error!("Could not decode the head data: {e}");
|
|
||||||
request.complete(None);
|
|
||||||
continue
|
|
||||||
},
|
|
||||||
};
|
|
||||||
|
|
||||||
// Check if we have upgraded to an Aura compatible runtime and transition if
|
|
||||||
// necessary.
|
|
||||||
if client
|
|
||||||
.runtime_api()
|
|
||||||
.has_api::<dyn AuraApi<Block, AuraId>>(last_head_hash)
|
|
||||||
.unwrap_or(false)
|
|
||||||
{
|
|
||||||
// Respond to this request before transitioning to Aura.
|
|
||||||
request.complete(None);
|
|
||||||
break
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
let proposer = Proposer::new(proposer_factory);
|
|
||||||
|
|
||||||
let params = BasicAuraParams {
|
|
||||||
create_inherent_data_providers: move |_, ()| async move { Ok(()) },
|
|
||||||
block_import,
|
|
||||||
para_client: client,
|
|
||||||
relay_client: relay_chain_interface2,
|
|
||||||
sync_oracle,
|
|
||||||
keystore,
|
|
||||||
collator_key,
|
|
||||||
para_id,
|
|
||||||
overseer_handle,
|
|
||||||
relay_chain_slot_duration,
|
|
||||||
proposer,
|
|
||||||
collator_service,
|
|
||||||
// Very limited proposal time.
|
|
||||||
authoring_duration: Duration::from_millis(500),
|
|
||||||
collation_request_receiver: Some(request_stream),
|
|
||||||
};
|
|
||||||
|
|
||||||
basic_aura::run::<Block, <AuraId as AppCrypto>::Pair, _, _, _, _, _, _, _>(params)
|
|
||||||
.await
|
|
||||||
});
|
|
||||||
|
|
||||||
let spawner = task_manager.spawn_essential_handle();
|
|
||||||
spawner.spawn_essential("cumulus-asset-hub-collator", None, collation_future);
|
|
||||||
|
|
||||||
Ok(())
|
|
||||||
},
|
|
||||||
hwbench,
|
|
||||||
)
|
|
||||||
.await
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Start a shell node which should later transition into an Aura powered parachain node. Asset Hub
|
/// Start a shell node which should later transition into an Aura powered parachain node. Asset Hub
|
||||||
/// uses this because at genesis, Asset Hub was on the `shell` runtime which didn't have Aura and
|
/// uses this because at genesis, Asset Hub was on the `shell` runtime which didn't have Aura and
|
||||||
/// needs to sync and upgrade before it can run `AuraApi` functions.
|
/// needs to sync and upgrade before it can run `AuraApi` functions.
|
||||||
|
|||||||
@@ -0,0 +1,12 @@
|
|||||||
|
title: "Use async backing enabled collator for all the parachains"
|
||||||
|
|
||||||
|
doc:
|
||||||
|
- audience: Node Operator
|
||||||
|
description: |
|
||||||
|
Promotes all the parachains supported by `polkadot-parachain`, including all the systems
|
||||||
|
parachains, to use the async backing enabled lookahead Aura collator instead of the generic
|
||||||
|
one.
|
||||||
|
|
||||||
|
crates:
|
||||||
|
- name: polkadot-parachain-bin
|
||||||
|
bump: major
|
||||||
Reference in New Issue
Block a user