mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-04-26 15:47:58 +00:00
Substrate companion: Authority discovery multiple peer ids (#4295)
* Substrate companion: Authority discovery multiple peer ids Authority discovery before had a fixed mapping from `PeerId` to `AuthorityId`. This wasn't correct, as a `PeerId` can actually map to multiple `AuthorityId`s. The linked Substrate pr fixes this. https://github.com/paritytech/substrate/pull/10259 * Update node/network/availability-distribution/src/requester/mod.rs * Update node/network/collator-protocol/src/validator_side/mod.rs * Update node/network/statement-distribution/src/tests.rs * Update guide * Adapt to Substrate pr * Update Substrate
This commit is contained in:
@@ -197,7 +197,7 @@ where
|
||||
let peer = incoming.peer;
|
||||
|
||||
// Only accept messages from validators:
|
||||
if self.authority_discovery.get_authority_id_by_peer_id(peer).await.is_none() {
|
||||
if self.authority_discovery.get_authority_ids_by_peer_id(peer).await.is_none() {
|
||||
incoming
|
||||
.send_outgoing_response(OutgoingResponse {
|
||||
result: Err(()),
|
||||
|
||||
@@ -17,7 +17,10 @@
|
||||
|
||||
//! Mock data and utility functions for unit tests in this subsystem.
|
||||
|
||||
use std::{collections::HashMap, sync::Arc};
|
||||
use std::{
|
||||
collections::{HashMap, HashSet},
|
||||
sync::Arc,
|
||||
};
|
||||
|
||||
use async_trait::async_trait;
|
||||
use lazy_static::lazy_static;
|
||||
@@ -171,19 +174,23 @@ impl AuthorityDiscovery for MockAuthorityDiscovery {
|
||||
async fn get_addresses_by_authority_id(
|
||||
&mut self,
|
||||
_authority: polkadot_primitives::v1::AuthorityDiscoveryId,
|
||||
) -> Option<Vec<sc_network::Multiaddr>> {
|
||||
) -> Option<HashSet<sc_network::Multiaddr>> {
|
||||
panic!("Not implemented");
|
||||
}
|
||||
|
||||
async fn get_authority_id_by_peer_id(
|
||||
async fn get_authority_ids_by_peer_id(
|
||||
&mut self,
|
||||
peer_id: polkadot_node_network_protocol::PeerId,
|
||||
) -> Option<polkadot_primitives::v1::AuthorityDiscoveryId> {
|
||||
) -> Option<HashSet<polkadot_primitives::v1::AuthorityDiscoveryId>> {
|
||||
for (a, p) in self.peer_ids.iter() {
|
||||
if p == &peer_id {
|
||||
return Some(MOCK_VALIDATORS_DISCOVERY_KEYS.get(&a).unwrap().clone())
|
||||
return Some(HashSet::from([MOCK_VALIDATORS_DISCOVERY_KEYS
|
||||
.get(&a)
|
||||
.unwrap()
|
||||
.clone()]))
|
||||
}
|
||||
}
|
||||
|
||||
None
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user