refactor grid topology to expose more info to subsystems (#6140)

* refactor grid topology to expose more info to subsystems

* fix grid_topology test

* fix overseer test

* Update node/network/protocol/src/grid_topology.rs

Co-authored-by: Vsevolod Stakhov <vsevolod.stakhov@parity.io>

* Update node/network/protocol/src/grid_topology.rs

Co-authored-by: Andronik <write@reusable.software>

* Update node/network/protocol/src/grid_topology.rs

Co-authored-by: Andronik <write@reusable.software>

* fix bug in populating topology

* fmt

Co-authored-by: Vsevolod Stakhov <vsevolod.stakhov@parity.io>
Co-authored-by: Andronik <write@reusable.software>
This commit is contained in:
asynchronous rob
2022-10-12 18:30:12 -05:00
committed by GitHub
parent bccffcad12
commit a7780e0797
17 changed files with 614 additions and 328 deletions
@@ -145,10 +145,19 @@ These updates are posted from the [Network Bridge Subsystem](../node/utility/net
struct NewGossipTopology {
/// The session index this topology corresponds to.
session: SessionIndex,
/// Neighbors in the 'X' dimension of the grid.
our_neighbors_x: HashMap<AuthorityDiscoveryId, TopologyPeerInfo>,
/// Neighbors in the 'Y' dimension of the grid.
our_neighbors_y: HashMap<AuthorityDiscoveryId, TopologyPeerInfo>,
/// The topology itself.
topology: SessionGridTopology,
/// The local validator index, if any.
local_index: Option<ValidatorIndex>,
}
struct SessionGridTopology {
/// An array mapping validator indices to their indices in the
/// shuffling itself. This has the same size as the number of validators
/// in the session.
shuffled_indices: Vec<usize>,
/// The canonical shuffling of validators for the session.
canonical_shuffling: Vec<TopologyPeerInfo>,
}
struct TopologyPeerInfo {
@@ -157,6 +166,9 @@ struct TopologyPeerInfo {
/// The index of the validator in the discovery keys of the corresponding
/// `SessionInfo`. This can extend _beyond_ the set of active parachain validators.
validator_index: ValidatorIndex,
/// The authority discovery public key of the validator in the corresponding
/// `SessionInfo`.
discovery_id: AuthorityDiscoveryId,
}
enum NetworkBridgeEvent<M> {
@@ -555,14 +555,15 @@ enum NetworkBridgeMessage {
/// Inform the distribution subsystems about the new
/// gossip network topology formed.
NewGossipTopology {
/// The session this topology corresponds to.
session: SessionIndex,
/// Ids of our neighbors in the X dimension of the new gossip topology.
/// We're not necessarily connected to all of them, but we should try to be.
our_neighbors_x: HashSet<AuthorityDiscoveryId>,
/// Ids of our neighbors in the Y dimension of the new gossip topology.
/// We're not necessarily connected to all of them, but we should try to be.
our_neighbors_y: HashSet<AuthorityDiscoveryId>,
/// The session info this gossip topology is concerned with.
session: SessionIndex,
/// Our validator index in the session, if any.
local_index: Option<ValidatorIndex>,
/// The canonical shuffling of validators for the session.
canonical_shuffling: Vec<(AuthorityDiscoveryId, ValidatorIndex)>,
/// The reverse mapping of `canonical_shuffling`: from validator index
/// to the index in `canonical_shuffling`
shuffled_indices: Vec<usize>,
}
}
```