@@ -41,8 +41,9 @@ use polkadot_node_subsystem::{
41
41
SubsystemContext , SubsystemError , SubsystemResult ,
42
42
} ;
43
43
use polkadot_node_subsystem_util:: {
44
- request_availability_cores, request_persisted_validation_data, request_validation_code,
45
- request_validation_code_hash, request_validators,
44
+ request_availability_cores, request_persisted_validation_data,
45
+ request_staging_async_backing_params, request_validation_code, request_validation_code_hash,
46
+ request_validators,
46
47
} ;
47
48
use polkadot_primitives:: {
48
49
collator_signature_payload, CandidateCommitments , CandidateDescriptor , CandidateReceipt ,
@@ -201,29 +202,46 @@ async fn handle_new_activations<Context>(
201
202
for relay_parent in activated {
202
203
let _relay_parent_timer = metrics. time_new_activations_relay_parent ( ) ;
203
204
204
- let ( availability_cores, validators) = join ! (
205
+ let ( availability_cores, validators, async_backing_params ) = join ! (
205
206
request_availability_cores( relay_parent, ctx. sender( ) ) . await ,
206
207
request_validators( relay_parent, ctx. sender( ) ) . await ,
208
+ request_staging_async_backing_params( relay_parent, ctx. sender( ) ) . await ,
207
209
) ;
208
210
209
211
let availability_cores = availability_cores??;
210
212
let n_validators = validators??. len ( ) ;
213
+ let async_backing_params = async_backing_params?. ok ( ) ;
211
214
212
215
for ( core_idx, core) in availability_cores. into_iter ( ) . enumerate ( ) {
213
216
let _availability_core_timer = metrics. time_new_activations_availability_core ( ) ;
214
217
215
218
let ( scheduled_core, assumption) = match core {
216
219
CoreState :: Scheduled ( scheduled_core) =>
217
220
( scheduled_core, OccupiedCoreAssumption :: Free ) ,
218
- CoreState :: Occupied ( occupied_core) => {
219
- // TODO [now]: this assumes that next up == current.
220
- // in practice we should only set `OccupiedCoreAssumption::Included`
221
- // when the candidate occupying the core is also of the same para.
222
- if let Some ( scheduled) = occupied_core. next_up_on_available {
223
- ( scheduled, OccupiedCoreAssumption :: Included )
224
- } else {
221
+ CoreState :: Occupied ( occupied_core) => match async_backing_params {
222
+ Some ( params) if params. max_candidate_depth >= 1 => {
223
+ // maximum candidate depth when building on top of a block
224
+ // pending availability is necessarily 1 - the depth of the
225
+ // pending block is 0 so the child has depth 1.
226
+
227
+ // TODO [now]: this assumes that next up == current.
228
+ // in practice we should only set `OccupiedCoreAssumption::Included`
229
+ // when the candidate occupying the core is also of the same para.
230
+ if let Some ( scheduled) = occupied_core. next_up_on_available {
231
+ ( scheduled, OccupiedCoreAssumption :: Included )
232
+ } else {
233
+ continue
234
+ }
235
+ } ,
236
+ _ => {
237
+ gum:: trace!(
238
+ target: LOG_TARGET ,
239
+ core_idx = %core_idx,
240
+ relay_parent = ?relay_parent,
241
+ "core is occupied. Keep going." ,
242
+ ) ;
225
243
continue
226
- }
244
+ } ,
227
245
} ,
228
246
CoreState :: Free => {
229
247
gum:: trace!(
0 commit comments