diff --git a/polkadot/node/network/availability-distribution/src/requester/fetch_task/mod.rs b/polkadot/node/network/availability-distribution/src/requester/fetch_task/mod.rs index 3f89239c31..b3331b54a6 100644 --- a/polkadot/node/network/availability-distribution/src/requester/fetch_task/mod.rs +++ b/polkadot/node/network/availability-distribution/src/requester/fetch_task/mod.rs @@ -203,7 +203,9 @@ impl FetchTask { /// Remove leaves and cancel the task, if it was the last one and the task has still been /// fetching. pub fn remove_leaves(&mut self, leaves: &HashSet) { - self.live_in.difference(leaves); + for leaf in leaves { + self.live_in.remove(leaf); + } if self.live_in.is_empty() && !self.is_finished() { self.state = FetchedState::Canceled } diff --git a/polkadot/node/network/collator-protocol/src/collator_side/mod.rs b/polkadot/node/network/collator-protocol/src/collator_side/mod.rs index 5a957735da..a56b4b627f 100644 --- a/polkadot/node/network/collator-protocol/src/collator_side/mod.rs +++ b/polkadot/node/network/collator-protocol/src/collator_side/mod.rs @@ -42,7 +42,7 @@ use polkadot_node_subsystem_util::{ }; use polkadot_primitives::v1::{ AuthorityDiscoveryId, CandidateHash, CandidateReceipt, CollatorPair, CoreIndex, CoreState, - GroupIndex, Hash, Id as ParaId, + Hash, Id as ParaId, }; use polkadot_subsystem::{ jaeger, @@ -148,20 +148,23 @@ impl metrics::Metrics for Metrics { } } -/// The group of validators that is assigned to our para at a given point of time. +/// Info about validators we are currently connected to. /// -/// This structure is responsible for keeping track of which validators belong to a certain group for a para. It also -/// stores a mapping from [`PeerId`] to [`ValidatorId`] as we learn about it over the lifetime of this object. Besides -/// that it also keeps track to which validators we advertised our collation. +/// It keeps track to which validators we advertised our collation. #[derive(Debug)] struct ValidatorGroup { - /// All [`AuthorityDiscoveryId`]'s that are assigned to us in this group. - discovery_ids: HashSet, /// All [`ValidatorId`]'s of the current group to that we advertised our collation. advertised_to: HashSet, } impl ValidatorGroup { + /// Create a new `ValidatorGroup` + /// + /// without any advertisements. + fn new() -> Self { + Self { advertised_to: HashSet::new() } + } + /// Returns `true` if we should advertise our collation to the given peer. fn should_advertise_to( &self, @@ -188,12 +191,6 @@ impl ValidatorGroup { } } -impl From> for ValidatorGroup { - fn from(discovery_ids: HashSet) -> Self { - Self { discovery_ids, advertised_to: HashSet::new() } - } -} - /// The status of a collation as seen from the collator. enum CollationStatus { /// The collation was created, but we did not advertise it to any validator. @@ -406,13 +403,10 @@ where "Accepted collation, connecting to validators." ); - let validator_group: HashSet<_> = - current_validators.validators.iter().map(Clone::clone).collect(); - // Issue a discovery request for the validators of the current group: connect_to_validators(ctx, current_validators.validators.into_iter().collect()).await; - state.our_validators_groups.insert(relay_parent, validator_group.into()); + state.our_validators_groups.insert(relay_parent, ValidatorGroup::new()); if let Some(result_sender) = result_sender { state.collation_result_senders.insert(receipt.hash(), result_sender); @@ -458,8 +452,6 @@ where /// Validators of a particular group index. #[derive(Debug)] struct GroupValidators { - /// The group those validators belong to. - group: GroupIndex, /// The validators of above group (their discovery keys). validators: Vec, } @@ -498,8 +490,7 @@ where let current_validators = current_validators.iter().map(|i| validators[i.0 as usize].clone()).collect(); - let current_validators = - GroupValidators { group: current_group_index, validators: current_validators }; + let current_validators = GroupValidators { validators: current_validators }; Ok(current_validators) } diff --git a/polkadot/node/network/collator-protocol/src/collator_side/tests.rs b/polkadot/node/network/collator-protocol/src/collator_side/tests.rs index 44a3d1ee2c..a506b524ec 100644 --- a/polkadot/node/network/collator-protocol/src/collator_side/tests.rs +++ b/polkadot/node/network/collator-protocol/src/collator_side/tests.rs @@ -68,7 +68,6 @@ impl TestCandidateBuilder { #[derive(Clone)] struct TestState { para_id: ParaId, - validators: Vec, session_info: SessionInfo, group_rotation_info: GroupRotationInfo, validator_peer_id: Vec, @@ -121,7 +120,6 @@ impl Default for TestState { Self { para_id, - validators, session_info: SessionInfo { validators: validator_public, discovery_keys, diff --git a/polkadot/node/network/collator-protocol/src/validator_side/tests.rs b/polkadot/node/network/collator-protocol/src/validator_side/tests.rs index 6815e1966f..e9b184bbfc 100644 --- a/polkadot/node/network/collator-protocol/src/validator_side/tests.rs +++ b/polkadot/node/network/collator-protocol/src/validator_side/tests.rs @@ -44,7 +44,6 @@ struct TestState { chain_ids: Vec, relay_parent: Hash, collators: Vec, - validators: Vec, validator_public: Vec, validator_groups: Vec>, group_rotation_info: GroupRotationInfo, @@ -102,7 +101,6 @@ impl Default for TestState { chain_ids, relay_parent, collators, - validators, validator_public, validator_groups, group_rotation_info,