Skip to content

Commit

Permalink
feat(async-backing): phase 2 (node)
Browse files Browse the repository at this point in the history
  • Loading branch information
evilrobot-01 committed Mar 9, 2024
1 parent 72ba989 commit b674303
Showing 1 changed file with 17 additions and 11 deletions.
28 changes: 17 additions & 11 deletions node/src/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,10 @@ use cumulus_client_service::{
build_network, build_relay_chain_interface, prepare_node_config, start_relay_chain_tasks,
BuildNetworkParams, CollatorSybilResistance, DARecoveryProfile, StartRelayChainTasksParams,
};
use cumulus_primitives_core::{relay_chain::CollatorPair, ParaId};
use cumulus_primitives_core::{
relay_chain::{CollatorPair, ValidationCode},
ParaId,
};
use cumulus_relay_chain_interface::{OverseerHandle, RelayChainInterface};

// Substrate Imports
Expand Down Expand Up @@ -240,7 +243,7 @@ async fn start_node_impl(
task_manager: &mut task_manager,
config: parachain_config,
keystore: params.keystore_container.keystore(),
backend,
backend: backend.clone(),
network: network.clone(),
sync_service: sync_service.clone(),
system_rpc_tx,
Expand Down Expand Up @@ -304,6 +307,7 @@ async fn start_node_impl(
if validator {
start_consensus(
client.clone(),
backend.clone(),
block_import,
prometheus_registry.as_ref(),
telemetry.as_ref().map(|t| t.handle()),
Expand Down Expand Up @@ -357,6 +361,7 @@ fn build_import_queue(

fn start_consensus(
client: Arc<ParachainClient>,
backend: Arc<ParachainBackend>,
block_import: ParachainBlockImport,
prometheus_registry: Option<&Registry>,
telemetry: Option<TelemetryHandle>,
Expand All @@ -371,9 +376,7 @@ fn start_consensus(
overseer_handle: OverseerHandle,
announce_block: Arc<dyn Fn(Hash, Option<Vec<u8>>) + Send + Sync>,
) -> Result<(), sc_service::Error> {
use cumulus_client_consensus_aura::collators::basic::{
self as basic_aura, Params as BasicAuraParams,
};
use cumulus_client_consensus_aura::collators::lookahead::{self as aura, Params as AuraParams};

// NOTE: because we use Aura here explicitly, we can use `CollatorSybilResistance::Resistant`
// when starting the network.
Expand All @@ -397,11 +400,15 @@ fn start_consensus(
client.clone(),
);

let params = BasicAuraParams {
let params = AuraParams {
create_inherent_data_providers: move |_, ()| async move { Ok(()) },
block_import,
para_client: client,
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(|c| ValidationCode::from(c).hash())
},
sync_oracle,
keystore,
collator_key,
Expand All @@ -411,13 +418,12 @@ fn start_consensus(
relay_chain_slot_duration,
proposer,
collator_service,
// Very limited proposal time.
authoring_duration: Duration::from_millis(500),
collation_request_receiver: None,
authoring_duration: Duration::from_millis(1500),
reinitialize: false,
};

let fut =
basic_aura::run::<Block, sp_consensus_aura::sr25519::AuthorityPair, _, _, _, _, _, _, _>(
aura::run::<Block, sp_consensus_aura::sr25519::AuthorityPair, _, _, _, _, _, _, _, _, _>(
params,
);
task_manager.spawn_essential_handle().spawn("aura", None, fut);
Expand Down

0 comments on commit b674303

Please sign in to comment.