mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-05-30 02:21:04 +00:00
Updating glutton for async backing (#1619)
Applied changes from the [User Update Guide](https://docs.google.com/document/d/1WQijD3bZTCsudOyPcDvugv659nCa2hEp2b_8eRU0h-Q), diverging in the node side where service.rs is different for `polkadot-parachain` than in the parachain template.
This commit is contained in:
@@ -87,6 +87,7 @@ cumulus-client-consensus-relay-chain = { path = "../client/consensus/relay-chain
|
||||
cumulus-client-consensus-common = { path = "../client/consensus/common" }
|
||||
cumulus-client-consensus-proposer = { path = "../client/consensus/proposer" }
|
||||
cumulus-client-service = { path = "../client/service" }
|
||||
cumulus-primitives-aura = { path = "../primitives/aura" }
|
||||
cumulus-primitives-core = { path = "../primitives/core" }
|
||||
cumulus-primitives-parachain-inherent = { path = "../primitives/parachain-inherent" }
|
||||
cumulus-relay-chain-interface = { path = "../client/relay-chain-interface" }
|
||||
|
||||
@@ -876,12 +876,17 @@ pub fn run() -> Result<()> {
|
||||
.await
|
||||
.map(|r| r.0)
|
||||
.map_err(Into::into),
|
||||
Runtime::Seedling => crate::service::start_shell_node::<
|
||||
seedling_runtime::RuntimeApi,
|
||||
>(config, polkadot_config, collator_options, id, hwbench)
|
||||
.await
|
||||
.map(|r| r.0)
|
||||
.map_err(Into::into),
|
||||
Runtime::Seedling =>
|
||||
crate::service::start_shell_node::<seedling_runtime::RuntimeApi>(
|
||||
config,
|
||||
polkadot_config,
|
||||
collator_options,
|
||||
id,
|
||||
hwbench
|
||||
)
|
||||
.await
|
||||
.map(|r| r.0)
|
||||
.map_err(Into::into),
|
||||
Runtime::ContractsRococo => crate::service::start_contracts_rococo_node(
|
||||
config,
|
||||
polkadot_config,
|
||||
@@ -949,13 +954,10 @@ pub fn run() -> Result<()> {
|
||||
.map(|r| r.0)
|
||||
.map_err(Into::into),
|
||||
Runtime::Glutton =>
|
||||
crate::service::start_shell_node::<glutton_runtime::RuntimeApi>(
|
||||
config,
|
||||
polkadot_config,
|
||||
collator_options,
|
||||
id,
|
||||
hwbench,
|
||||
)
|
||||
crate::service::start_basic_lookahead_node::<
|
||||
glutton_runtime::RuntimeApi,
|
||||
AuraId,
|
||||
>(config, polkadot_config, collator_options, id, hwbench)
|
||||
.await
|
||||
.map(|r| r.0)
|
||||
.map_err(Into::into),
|
||||
|
||||
@@ -17,8 +17,9 @@
|
||||
use codec::Codec;
|
||||
use cumulus_client_cli::CollatorOptions;
|
||||
use cumulus_client_collator::service::CollatorService;
|
||||
use cumulus_client_consensus_aura::collators::basic::{
|
||||
self as basic_aura, Params as BasicAuraParams,
|
||||
use cumulus_client_consensus_aura::collators::{
|
||||
basic::{self as basic_aura, Params as BasicAuraParams},
|
||||
lookahead::{self as aura, Params as AuraParams},
|
||||
};
|
||||
use cumulus_client_consensus_common::{
|
||||
ParachainBlockImport as TParachainBlockImport, ParachainCandidate, ParachainConsensus,
|
||||
@@ -31,7 +32,7 @@ use cumulus_client_service::{
|
||||
BuildNetworkParams, CollatorSybilResistance, DARecoveryProfile, StartRelayChainTasksParams,
|
||||
};
|
||||
use cumulus_primitives_core::{
|
||||
relay_chain::{Hash as PHash, PersistedValidationData},
|
||||
relay_chain::{Hash as PHash, PersistedValidationData, ValidationCode},
|
||||
ParaId,
|
||||
};
|
||||
use cumulus_relay_chain_interface::{OverseerHandle, RelayChainInterface};
|
||||
@@ -696,6 +697,188 @@ where
|
||||
Ok((task_manager, client))
|
||||
}
|
||||
|
||||
/// Start a node with the given parachain `Configuration` and relay chain `Configuration`.
|
||||
///
|
||||
/// This is the actual implementation that is abstract over the executor and the runtime api.
|
||||
///
|
||||
/// This node is basic in the sense that it doesn't support functionality like transaction
|
||||
/// payment. Intended to replace start_shell_node in use for glutton, shell, and seedling.
|
||||
#[sc_tracing::logging::prefix_logs_with("Parachain")]
|
||||
async fn start_basic_lookahead_node_impl<RuntimeApi, RB, BIQ, SC>(
|
||||
parachain_config: Configuration,
|
||||
polkadot_config: Configuration,
|
||||
collator_options: CollatorOptions,
|
||||
sybil_resistance_level: CollatorSybilResistance,
|
||||
para_id: ParaId,
|
||||
rpc_ext_builder: RB,
|
||||
build_import_queue: BIQ,
|
||||
start_consensus: SC,
|
||||
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>
|
||||
+ frame_rpc_system::AccountNonceApi<Block, AccountId, Nonce>,
|
||||
RB: Fn(Arc<ParachainClient<RuntimeApi>>) -> Result<jsonrpsee::RpcModule<()>, sc_service::Error>
|
||||
+ 'static,
|
||||
BIQ: FnOnce(
|
||||
Arc<ParachainClient<RuntimeApi>>,
|
||||
ParachainBlockImport<RuntimeApi>,
|
||||
&Configuration,
|
||||
Option<TelemetryHandle>,
|
||||
&TaskManager,
|
||||
) -> Result<sc_consensus::DefaultImportQueue<Block>, sc_service::Error>,
|
||||
SC: FnOnce(
|
||||
Arc<ParachainClient<RuntimeApi>>,
|
||||
ParachainBlockImport<RuntimeApi>,
|
||||
Option<&Registry>,
|
||||
Option<TelemetryHandle>,
|
||||
&TaskManager,
|
||||
Arc<dyn RelayChainInterface>,
|
||||
Arc<sc_transaction_pool::FullPool<Block, ParachainClient<RuntimeApi>>>,
|
||||
Arc<SyncingService<Block>>,
|
||||
KeystorePtr,
|
||||
Duration,
|
||||
ParaId,
|
||||
CollatorPair,
|
||||
OverseerHandle,
|
||||
Arc<dyn Fn(Hash, Option<Vec<u8>>) + Send + Sync>,
|
||||
Arc<ParachainBackend>,
|
||||
) -> Result<(), sc_service::Error>,
|
||||
{
|
||||
let parachain_config = prepare_node_config(parachain_config);
|
||||
|
||||
let params = new_partial::<RuntimeApi, BIQ>(¶chain_config, build_import_queue)?;
|
||||
let (block_import, 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) = build_relay_chain_interface(
|
||||
polkadot_config,
|
||||
¶chain_config,
|
||||
telemetry_worker_handle,
|
||||
&mut task_manager,
|
||||
collator_options.clone(),
|
||||
hwbench.clone(),
|
||||
)
|
||||
.await
|
||||
.map_err(|e| sc_service::Error::Application(Box::new(e) as Box<_>))?;
|
||||
|
||||
let validator = parachain_config.role.is_authority();
|
||||
let prometheus_registry = parachain_config.prometheus_registry().cloned();
|
||||
let transaction_pool = params.transaction_pool.clone();
|
||||
let import_queue_service = params.import_queue.service();
|
||||
let net_config = FullNetworkConfiguration::new(¶chain_config.network);
|
||||
|
||||
let (network, system_rpc_tx, tx_handler_controller, start_network, sync_service) =
|
||||
build_network(BuildNetworkParams {
|
||||
parachain_config: ¶chain_config,
|
||||
net_config,
|
||||
client: client.clone(),
|
||||
transaction_pool: transaction_pool.clone(),
|
||||
para_id,
|
||||
spawn_handle: task_manager.spawn_handle(),
|
||||
relay_chain_interface: relay_chain_interface.clone(),
|
||||
import_queue: params.import_queue,
|
||||
sybil_resistance_level,
|
||||
})
|
||||
.await?;
|
||||
|
||||
let rpc_client = client.clone();
|
||||
let rpc_builder = Box::new(move |_, _| rpc_ext_builder(rpc_client.clone()));
|
||||
|
||||
sc_service::spawn_tasks(sc_service::SpawnTasksParams {
|
||||
rpc_builder,
|
||||
client: client.clone(),
|
||||
transaction_pool: transaction_pool.clone(),
|
||||
task_manager: &mut task_manager,
|
||||
config: parachain_config,
|
||||
keystore: params.keystore_container.keystore(),
|
||||
backend: backend.clone(),
|
||||
network: network.clone(),
|
||||
sync_service: sync_service.clone(),
|
||||
system_rpc_tx,
|
||||
tx_handler_controller,
|
||||
telemetry: telemetry.as_mut(),
|
||||
})?;
|
||||
|
||||
if let Some(hwbench) = hwbench {
|
||||
sc_sysinfo::print_hwbench(&hwbench);
|
||||
if validator {
|
||||
warn_if_slow_hardware(&hwbench);
|
||||
}
|
||||
|
||||
if let Some(ref mut telemetry) = telemetry {
|
||||
let telemetry_handle = telemetry.handle();
|
||||
task_manager.spawn_handle().spawn(
|
||||
"telemetry_hwbench",
|
||||
None,
|
||||
sc_sysinfo::initialize_hwbench_telemetry(telemetry_handle, hwbench),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
let announce_block = {
|
||||
let sync_service = sync_service.clone();
|
||||
Arc::new(move |hash, data| sync_service.announce_block(hash, data))
|
||||
};
|
||||
|
||||
let relay_chain_slot_duration = Duration::from_secs(6);
|
||||
|
||||
let overseer_handle = relay_chain_interface
|
||||
.overseer_handle()
|
||||
.map_err(|e| sc_service::Error::Application(Box::new(e)))?;
|
||||
|
||||
start_relay_chain_tasks(StartRelayChainTasksParams {
|
||||
client: client.clone(),
|
||||
announce_block: announce_block.clone(),
|
||||
para_id,
|
||||
relay_chain_interface: relay_chain_interface.clone(),
|
||||
task_manager: &mut task_manager,
|
||||
da_recovery_profile: if validator {
|
||||
DARecoveryProfile::Collator
|
||||
} else {
|
||||
DARecoveryProfile::FullNode
|
||||
},
|
||||
import_queue: import_queue_service,
|
||||
relay_chain_slot_duration,
|
||||
recovery_handle: Box::new(overseer_handle.clone()),
|
||||
sync_service: sync_service.clone(),
|
||||
})?;
|
||||
|
||||
if validator {
|
||||
start_consensus(
|
||||
client.clone(),
|
||||
block_import,
|
||||
prometheus_registry.as_ref(),
|
||||
telemetry.as_ref().map(|t| t.handle()),
|
||||
&task_manager,
|
||||
relay_chain_interface.clone(),
|
||||
transaction_pool,
|
||||
sync_service.clone(),
|
||||
params.keystore_container.keystore(),
|
||||
relay_chain_slot_duration,
|
||||
para_id,
|
||||
collator_key.expect("Command line arguments do not allow this. qed"),
|
||||
overseer_handle,
|
||||
announce_block,
|
||||
backend.clone(),
|
||||
)?;
|
||||
}
|
||||
|
||||
start_network.start_network();
|
||||
|
||||
Ok((task_manager, client))
|
||||
}
|
||||
|
||||
/// Build the import queue for the rococo parachain runtime.
|
||||
pub fn rococo_parachain_build_import_queue(
|
||||
client: Arc<ParachainClient<rococo_parachain_runtime::RuntimeApi>>,
|
||||
@@ -1206,6 +1389,104 @@ where
|
||||
.await
|
||||
}
|
||||
|
||||
/// Start an aura powered parachain node which uses the lookahead collator to support async backing.
|
||||
/// This node is basic in the sense that its runtime api doesn't include common contents such as
|
||||
/// transaction payment. Used for aura glutton.
|
||||
pub async fn start_basic_lookahead_node<RuntimeApi, AuraId: AppCrypto>(
|
||||
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>
|
||||
+ frame_rpc_system::AccountNonceApi<Block, AccountId, Nonce>
|
||||
+ cumulus_primitives_aura::AuraUnincludedSegmentApi<Block>,
|
||||
<<AuraId as AppCrypto>::Pair as Pair>::Signature:
|
||||
TryFrom<Vec<u8>> + std::hash::Hash + sp_runtime::traits::Member + Codec,
|
||||
{
|
||||
start_basic_lookahead_node_impl::<RuntimeApi, _, _, _>(
|
||||
parachain_config,
|
||||
polkadot_config,
|
||||
collator_options,
|
||||
CollatorSybilResistance::Resistant, // Aura
|
||||
para_id,
|
||||
|_| Ok(RpcModule::new(())),
|
||||
aura_build_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 slot_duration = cumulus_client_consensus_aura::slot_duration(&*client)?;
|
||||
|
||||
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 = AuraParams {
|
||||
create_inherent_data_providers: move |_, ()| async move { Ok(()) },
|
||||
block_import,
|
||||
para_client: client.clone(),
|
||||
para_backend: backend.clone(),
|
||||
relay_client: relay_chain_interface,
|
||||
code_hash_provider: move |block_hash| {
|
||||
client.code_at(block_hash).ok().map(ValidationCode).map(|c| c.hash())
|
||||
},
|
||||
sync_oracle,
|
||||
keystore,
|
||||
collator_key,
|
||||
para_id,
|
||||
overseer_handle,
|
||||
slot_duration,
|
||||
relay_chain_slot_duration,
|
||||
proposer,
|
||||
collator_service,
|
||||
authoring_duration: Duration::from_millis(1500),
|
||||
};
|
||||
|
||||
let fut =
|
||||
aura::run::<Block, <AuraId as AppCrypto>::Pair, _, _, _, _, _, _, _, _, _>(params);
|
||||
task_manager.spawn_essential_handle().spawn("aura", None, fut);
|
||||
|
||||
Ok(())
|
||||
},
|
||||
hwbench,
|
||||
)
|
||||
.await
|
||||
}
|
||||
|
||||
#[sc_tracing::logging::prefix_logs_with("Parachain")]
|
||||
async fn start_contracts_rococo_node_impl<RuntimeApi, RB, BIQ, SC>(
|
||||
parachain_config: Configuration,
|
||||
|
||||
Reference in New Issue
Block a user