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:
Bastian Köcher
2021-11-17 11:35:02 +01:00
committed by GitHub
parent 6664019e9d
commit 620a4e45de
17 changed files with 281 additions and 256 deletions
@@ -16,7 +16,7 @@
//! Authority discovery service interfacing.
use std::fmt::Debug;
use std::{collections::HashSet, fmt::Debug};
use async_trait::async_trait;
@@ -34,12 +34,12 @@ pub trait AuthorityDiscovery: Send + Debug + 'static {
async fn get_addresses_by_authority_id(
&mut self,
authority: AuthorityDiscoveryId,
) -> Option<Vec<Multiaddr>>;
) -> Option<HashSet<Multiaddr>>;
/// Get the [`AuthorityId`] for the given [`PeerId`] from the local address cache.
async fn get_authority_id_by_peer_id(
async fn get_authority_ids_by_peer_id(
&mut self,
peer_id: PeerId,
) -> Option<AuthorityDiscoveryId>;
) -> Option<HashSet<AuthorityDiscoveryId>>;
}
#[async_trait]
@@ -47,14 +47,14 @@ impl AuthorityDiscovery for AuthorityDiscoveryService {
async fn get_addresses_by_authority_id(
&mut self,
authority: AuthorityDiscoveryId,
) -> Option<Vec<Multiaddr>> {
) -> Option<HashSet<Multiaddr>> {
AuthorityDiscoveryService::get_addresses_by_authority_id(self, authority).await
}
async fn get_authority_id_by_peer_id(
async fn get_authority_ids_by_peer_id(
&mut self,
peer_id: PeerId,
) -> Option<AuthorityDiscoveryId> {
AuthorityDiscoveryService::get_authority_id_by_peer_id(self, peer_id).await
) -> Option<HashSet<AuthorityDiscoveryId>> {
AuthorityDiscoveryService::get_authority_ids_by_peer_id(self, peer_id).await
}
}