mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-07-17 22:55:40 +00:00
validator_discovery: cache by (Hash, ParaId) (#2402)
This commit is contained in:
@@ -279,7 +279,13 @@ async fn distribute_collation(
|
||||
}
|
||||
|
||||
// Issue a discovery request for the validators of the current group and the next group.
|
||||
connect_to_validators(ctx, relay_parent, state, current_validators.union(&next_validators).cloned().collect()).await?;
|
||||
connect_to_validators(
|
||||
ctx,
|
||||
relay_parent,
|
||||
id,
|
||||
state,
|
||||
current_validators.union(&next_validators).cloned().collect(),
|
||||
).await?;
|
||||
|
||||
state.our_validators_groups.insert(relay_parent, current_validators.into());
|
||||
|
||||
@@ -360,6 +366,7 @@ async fn declare(
|
||||
async fn connect_to_validators(
|
||||
ctx: &mut impl SubsystemContext<Message = CollatorProtocolMessage>,
|
||||
relay_parent: Hash,
|
||||
para_id: ParaId,
|
||||
state: &mut State,
|
||||
validators: Vec<ValidatorId>,
|
||||
) -> Result<()> {
|
||||
@@ -370,7 +377,7 @@ async fn connect_to_validators(
|
||||
PeerSet::Collation,
|
||||
).await?;
|
||||
|
||||
state.connection_requests.put(relay_parent, request);
|
||||
state.connection_requests.put(relay_parent, para_id, request);
|
||||
|
||||
Ok(())
|
||||
}
|
||||
@@ -680,7 +687,7 @@ async fn handle_our_view_change(
|
||||
for removed in state.view.difference(&view) {
|
||||
state.collations.remove(removed);
|
||||
state.our_validators_groups.remove(removed);
|
||||
state.connection_requests.remove(removed);
|
||||
state.connection_requests.remove_all(removed);
|
||||
state.span_per_relay_parent.remove(removed);
|
||||
}
|
||||
|
||||
|
||||
@@ -193,7 +193,7 @@ async fn handle_signal(
|
||||
}
|
||||
|
||||
for relay_parent in deactivated {
|
||||
state.connection_requests.remove(&relay_parent);
|
||||
state.connection_requests.remove_all(&relay_parent);
|
||||
state.relay_parent_state.remove(&relay_parent);
|
||||
}
|
||||
|
||||
@@ -303,13 +303,14 @@ async fn connect_to_relevant_validators(
|
||||
relay_parent: Hash,
|
||||
descriptor: &CandidateDescriptor,
|
||||
) {
|
||||
let para_id = descriptor.para_id;
|
||||
if let Ok(Some(relevant_validators)) =
|
||||
determine_relevant_validators(ctx, relay_parent, descriptor.para_id).await
|
||||
determine_relevant_validators(ctx, relay_parent, para_id).await
|
||||
{
|
||||
// We only need one connection request per (relay_parent, para_id)
|
||||
// so here we take this shortcut to avoid calling `connect_to_validators`
|
||||
// more than once.
|
||||
if !connection_requests.contains_request(&relay_parent) {
|
||||
if !connection_requests.contains_request(&relay_parent, para_id) {
|
||||
tracing::debug!(target: LOG_TARGET, validators=?relevant_validators, "connecting to validators");
|
||||
match validator_discovery::connect_to_validators(
|
||||
ctx,
|
||||
@@ -318,7 +319,7 @@ async fn connect_to_relevant_validators(
|
||||
PeerSet::Validation,
|
||||
).await {
|
||||
Ok(new_connection_request) => {
|
||||
connection_requests.put(relay_parent, new_connection_request);
|
||||
connection_requests.put(relay_parent, para_id, new_connection_request);
|
||||
}
|
||||
Err(e) => {
|
||||
tracing::debug!(
|
||||
|
||||
Reference in New Issue
Block a user