From 554ebe30d03c75cfc80406b7630a3b9064ae499a Mon Sep 17 00:00:00 2001 From: Andronik Date: Thu, 30 Dec 2021 17:17:38 +0100 Subject: [PATCH] gather validators across all active leaves --- .../src/collator_side/mod.rs | 47 ++++++++++--------- 1 file changed, 26 insertions(+), 21 deletions(-) diff --git a/node/network/collator-protocol/src/collator_side/mod.rs b/node/network/collator-protocol/src/collator_side/mod.rs index fd03ec11a72b..aa0a9ba3e16f 100644 --- a/node/network/collator-protocol/src/collator_side/mod.rs +++ b/node/network/collator-protocol/src/collator_side/mod.rs @@ -945,11 +945,22 @@ where let new_leaves: Vec<_> = view.difference(&state.view).cloned().collect(); state.view = view; + if new_leaves.is_empty() { + return Ok(()) + } + let id = match state.collating_on { Some(id) => id, None => return Ok(()), }; + // all validators assigned to the core + // across all active leaves + // this is typically our current group + // but can also include the previous group at + // rotation boundaries and considering forks + let mut group_validators = HashSet::new(); + for relay_parent in new_leaves { tracing::debug!( target: LOG_TARGET, @@ -970,31 +981,25 @@ where determine_our_validators(ctx, runtime, our_core, num_cores, relay_parent).await?; let validators = current_validators.validators; - let no_one_is_assigned = validators.is_empty(); - - if no_one_is_assigned { - tracing::warn!( - target: LOG_TARGET, - core = ?our_core, - "No validators assigned to our core.", - ); - continue - } - - tracing::debug!( - target: LOG_TARGET, - ?relay_parent, - ?validators, - para_id = ?id, - "Connecting to validators.", - ); - - // Add the current validator group to the reserved peers - connect_to_validators(ctx, validators).await; + group_validators.extend(validators); state.our_validators_groups.insert(relay_parent, ValidatorGroup::new()); } + let validators: Vec<_> = group_validators.into_iter().collect(); + let no_one_is_assigned = validators.is_empty(); + if no_one_is_assigned { + tracing::warn!(target: LOG_TARGET, "No validators assigned to our core.",); + return Ok(()) + } + tracing::debug!( + target: LOG_TARGET, + ?validators, + para_id = ?id, + "Connecting to validators.", + ); + connect_to_validators(ctx, validators).await; + Ok(()) }