Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

Commit

Permalink
gather validators across all active leaves
Browse files Browse the repository at this point in the history
  • Loading branch information
ordian committed Dec 30, 2021
1 parent b552244 commit 554ebe3
Showing 1 changed file with 26 additions and 21 deletions.
47 changes: 26 additions & 21 deletions node/network/collator-protocol/src/collator_side/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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(())
}

Expand Down

0 comments on commit 554ebe3

Please sign in to comment.