Skip to content

Commit

Permalink
update polkadot-parachain to use lookahead collator
Browse files Browse the repository at this point in the history
  • Loading branch information
Sophia-Gold committed Aug 31, 2023
1 parent 90c2697 commit 6010d6e
Showing 1 changed file with 24 additions and 11 deletions.
35 changes: 24 additions & 11 deletions cumulus/polkadot-parachain/src/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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};
Expand Down Expand Up @@ -555,6 +556,7 @@ where
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);
Expand Down Expand Up @@ -688,6 +690,7 @@ where
collator_key.expect("Command line arguments do not allow this. qed"),
overseer_handle,
announce_block,
backend.clone(),
)?;
}

Expand Down Expand Up @@ -766,7 +769,8 @@ pub async fn start_rococo_parachain_node(
para_id,
collator_key,
overseer_handle,
announce_block| {
announce_block,
backend| {
let slot_duration = cumulus_client_consensus_aura::slot_duration(&*client)?;

let proposer_factory = sc_basic_authorship::ProposerFactory::with_proof_recording(
Expand All @@ -785,11 +789,15 @@ pub async fn start_rococo_parachain_node(
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(ValidationCode).map(|c| c.hash())
},
sync_oracle,
keystore,
collator_key,
Expand All @@ -799,11 +807,10 @@ pub async fn start_rococo_parachain_node(
relay_chain_slot_duration,
proposer,
collator_service,
// Very limited proposal time.
authoring_duration: Duration::from_millis(500),
authoring_duration: Duration::from_millis(2000),
};

let fut = basic_aura::run::<
let fut = aura::run::<
Block,
sp_consensus_aura::sr25519::AuthorityPair,
_,
Expand All @@ -813,6 +820,8 @@ pub async fn start_rococo_parachain_node(
_,
_,
_,
_,
_,
>(params);
task_manager.spawn_essential_handle().spawn("aura", None, fut);

Expand Down Expand Up @@ -1158,7 +1167,8 @@ where
para_id,
collator_key,
overseer_handle,
announce_block| {
announce_block,
_backend| {
let slot_duration = cumulus_client_consensus_aura::slot_duration(&*client)?;

let proposer_factory = sc_basic_authorship::ProposerFactory::with_proof_recording(
Expand Down Expand Up @@ -1252,6 +1262,7 @@ where
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);
Expand Down Expand Up @@ -1384,6 +1395,7 @@ where
collator_key.expect("Command line arguments do not allow this. qed"),
overseer_handle,
announce_block,
backend.clone(),
)?;
}

Expand Down Expand Up @@ -1462,7 +1474,8 @@ pub async fn start_contracts_rococo_node(
para_id,
collator_key,
overseer_handle,
announce_block| {
announce_block,
_backend| {
let slot_duration = cumulus_client_consensus_aura::slot_duration(&*client)?;

let proposer_factory = sc_basic_authorship::ProposerFactory::with_proof_recording(
Expand Down

0 comments on commit 6010d6e

Please sign in to comment.