Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

collator protocol changes for elastic scaling (validator side) #3302

Merged
merged 14 commits into from
Mar 15, 2024
Merged
Prev Previous commit
Next Next commit
get rid of with_elastic_scaling
ordian committed Feb 16, 2024
commit 94ba49bfa00a4f0ce68c2dc77f95364772e84e11
4 changes: 1 addition & 3 deletions cumulus/client/collator/src/lib.rs
Original file line number Diff line number Diff line change
@@ -220,7 +220,6 @@ pub mod relay_chain_driven {
this_rx.await.ok().flatten()
})
})),
with_elastic_scaling: false,
};

overseer_handle
@@ -244,9 +243,8 @@ pub async fn initialize_collator_subsystems(
key: CollatorPair,
para_id: ParaId,
reinitialize: bool,
with_elastic_scaling: bool,
) {
let config = CollationGenerationConfig { key, para_id, collator: None, with_elastic_scaling };
let config = CollationGenerationConfig { key, para_id, collator: None };

if reinitialize {
overseer_handle
4 changes: 0 additions & 4 deletions cumulus/client/consensus/aura/src/collators/lookahead.rs
Original file line number Diff line number Diff line change
@@ -107,9 +107,6 @@ pub struct Params<BI, CIDP, Client, Backend, RClient, CHP, SO, Proposer, CS> {
pub authoring_duration: Duration,
/// Whether we should reinitialize the collator config (i.e. we are transitioning to aura).
pub reinitialize: bool,
/// Whether elastic scaling is enabled for this collation.
/// If it is, the collator will send the parent-head data along with the collation.
pub with_elastic_scaling: bool,
}

/// Run async-backing-friendly Aura.
@@ -155,7 +152,6 @@ where
params.collator_key,
params.para_id,
params.reinitialize,
params.with_elastic_scaling,
)
.await;

5 changes: 0 additions & 5 deletions cumulus/polkadot-parachain/src/service.rs
Original file line number Diff line number Diff line change
@@ -977,7 +977,6 @@ pub async fn start_rococo_parachain_node(
collator_service,
authoring_duration: Duration::from_millis(1500),
reinitialize: false,
with_elastic_scaling: false,
};

let fut = aura::run::<
@@ -1474,7 +1473,6 @@ where
collator_service,
authoring_duration: Duration::from_millis(1500),
reinitialize: false,
with_elastic_scaling: false,
};

let fut =
@@ -1770,7 +1768,6 @@ where
authoring_duration: Duration::from_millis(1500),
reinitialize: true, /* we need to always re-initialize for asset-hub moving
* to aura */
with_elastic_scaling: false,
};

aura::run::<Block, <AuraId as AppCrypto>::Pair, _, _, _, _, _, _, _, _, _>(params)
@@ -1873,7 +1870,6 @@ where
collator_service,
authoring_duration: Duration::from_millis(1500),
reinitialize: false,
with_elastic_scaling: false,
};

let fut =
@@ -2184,7 +2180,6 @@ pub async fn start_contracts_rococo_node(
// Very limited proposal time.
authoring_duration: Duration::from_millis(1500),
reinitialize: false,
with_elastic_scaling: false,
};

let fut = aura::run::<
11 changes: 1 addition & 10 deletions polkadot/node/collation-generation/src/lib.rs
Original file line number Diff line number Diff line change
@@ -350,8 +350,6 @@ async fn handle_new_activations<Context>(
},
};

let with_elastic_scaling = task_config.with_elastic_scaling;

construct_and_distribute_receipt(
PreparedCollation {
collation,
@@ -360,7 +358,6 @@ async fn handle_new_activations<Context>(
validation_data,
validation_code_hash,
n_validators,
with_elastic_scaling,
},
task_config.key.clone(),
&mut task_sender,
@@ -395,7 +392,6 @@ async fn handle_submit_collation<Context>(

let validators = request_validators(relay_parent, ctx.sender()).await.await??;
let n_validators = validators.len();
let with_elastic_scaling = config.with_elastic_scaling;

// We need to swap the parent-head data, but all other fields here will be correct.
let mut validation_data = match request_persisted_validation_data(
@@ -428,7 +424,6 @@ async fn handle_submit_collation<Context>(
validation_data,
validation_code_hash,
n_validators,
with_elastic_scaling,
};

construct_and_distribute_receipt(
@@ -450,7 +445,6 @@ struct PreparedCollation {
validation_data: PersistedValidationData,
validation_code_hash: ValidationCodeHash,
n_validators: usize,
with_elastic_scaling: bool,
}

/// Takes a prepared collation, along with its context, and produces a candidate receipt
@@ -469,7 +463,6 @@ async fn construct_and_distribute_receipt(
validation_data,
validation_code_hash,
n_validators,
with_elastic_scaling,
} = collation;

let persisted_validation_data_hash = validation_data.hash();
@@ -547,16 +540,14 @@ async fn construct_and_distribute_receipt(
},
};

let maybe_parent_head_data =
if with_elastic_scaling { Some(commitments.head_data.clone()) } else { None };
let maybe_parent_head_data = None;

gum::debug!(
target: LOG_TARGET,
candidate_hash = ?ccr.hash(),
?pov_hash,
?relay_parent,
para_id = %para_id,
?with_elastic_scaling,
"candidate is generated",
);
metrics.on_collation_generated();
2 changes: 0 additions & 2 deletions polkadot/node/collation-generation/src/tests.rs
Original file line number Diff line number Diff line change
@@ -117,7 +117,6 @@ fn test_config<Id: Into<ParaId>>(para_id: Id) -> CollationGenerationConfig {
key: CollatorPair::generate().0,
collator: Some(Box::new(|_: Hash, _vd: &PersistedValidationData| TestCollator.boxed())),
para_id: para_id.into(),
with_elastic_scaling: false,
}
}

@@ -126,7 +125,6 @@ fn test_config_no_collator<Id: Into<ParaId>>(para_id: Id) -> CollationGeneration
key: CollatorPair::generate().0,
collator: None,
para_id: para_id.into(),
with_elastic_scaling: false,
}
}

1 change: 0 additions & 1 deletion polkadot/node/overseer/src/tests.rs
Original file line number Diff line number Diff line change
@@ -824,7 +824,6 @@ fn test_collator_generation_msg() -> CollationGenerationMessage {
key: CollatorPair::generate().0,
collator: Some(Box::new(|_, _| TestCollator.boxed())),
para_id: Default::default(),
with_elastic_scaling: false,
})
}
struct TestCollator;
5 changes: 0 additions & 5 deletions polkadot/node/primitives/src/lib.rs
Original file line number Diff line number Diff line change
@@ -498,11 +498,6 @@ pub struct CollationGenerationConfig {
pub collator: Option<CollatorFn>,
/// The parachain that this collator collates for
pub para_id: ParaId,
/// Whether elastic scaling is enabled for this collation.
/// If it is, the collator will send the parent-head data along with the collation.
/// If your parachain is not assigned to multiple cores at the same time,
/// you should set this to `false`.
pub with_elastic_scaling: bool,
}

#[cfg(not(target_os = "unknown"))]
8 changes: 2 additions & 6 deletions polkadot/node/test/service/src/lib.rs
Original file line number Diff line number Diff line change
@@ -353,12 +353,8 @@ impl PolkadotTestNode {
para_id: ParaId,
collator: CollatorFn,
) {
let config = CollationGenerationConfig {
key: collator_key,
collator: Some(collator),
para_id,
with_elastic_scaling: false,
};
let config =
CollationGenerationConfig { key: collator_key, collator: Some(collator), para_id };

self.overseer_handle
.send_msg(CollationGenerationMessage::Initialize(config), "Collator")
Original file line number Diff line number Diff line change
@@ -119,7 +119,6 @@ fn main() -> Result<()> {
collator.create_collation_function(full_node.task_manager.spawn_handle()),
),
para_id,
with_elastic_scaling: false,
};
overseer_handle
.send_msg(CollationGenerationMessage::Initialize(config), "Collator")
Original file line number Diff line number Diff line change
@@ -121,7 +121,6 @@ fn main() -> Result<()> {
collator.create_collation_function(full_node.task_manager.spawn_handle()),
),
para_id,
with_elastic_scaling: false,
};
overseer_handle
.send_msg(CollationGenerationMessage::Initialize(config), "Collator")