Network Bridge Refactoring (#1535)

* rename protocol ID to network capability

* guide: `ProtocolId` -> `NetworkCapability`

* guide: remove `RegisterEventProducer`

* capabilities and expand on underlying network assumptions

* guide: create network.md types file

* guide: network bridge is aware of network messages

* revert changes in code

* Update roadmap/implementers-guide/src/SUMMARY.md

Co-authored-by: Pierre Krieger <pierre.krieger1708@gmail.com>

* remove references to NetworkCapability

* Update roadmap/implementers-guide/src/types/network.md

Co-authored-by: Sergei Shulepov <sergei@parity.io>

Co-authored-by: Pierre Krieger <pierre.krieger1708@gmail.com>
Co-authored-by: Sergei Shulepov <sergei@parity.io>
This commit is contained in:
Robert Habermeier
2020-08-05 11:04:05 +02:00
committed by GitHub
parent 1e0ec19945
commit f554868cd4
9 changed files with 244 additions and 97 deletions
@@ -4,15 +4,14 @@ This subsystem is responsible for distributing PoV blocks. For now, unified with
## Protocol
`ProtocolId`: `b"povd"`, `PeerSet`: `Validation`
`PeerSet`: `Validation`
Input: [`PoVDistributionMessage`](../../types/overseer-protocol.md#pov-distribution-message)
Output:
- NetworkBridge::RegisterEventProducer(`ProtocolId`)
- NetworkBridge::SendMessage(`[PeerId]`, `ProtocolId`, `Bytes`)
- NetworkBridge::SendMessage(`[PeerId]`, message)
- NetworkBridge::ReportPeer(PeerId, cost_or_benefit)
@@ -56,18 +55,7 @@ struct PeerState {
}
```
We also assume the following network messages, which are sent and received by the [Network Bridge](../utility/network-bridge.md)
```rust
enum NetworkMessage {
/// Notification that we are awaiting the given PoVs (by hash) against a
/// specific relay-parent hash.
Awaiting(Hash, Vec<Hash>),
/// Notification of an awaited PoV, in a given relay-parent context.
/// (relay_parent, pov_hash, pov)
SendPoV(Hash, Hash, PoV),
}
```
We also use the [`PoVDistributionV1Message`](../../types/network.md#pov-distribution) as our `NetworkMessage`, which are sent and received by the [Network Bridge](../utility/network-bridge.md)
Here is the logic of the state machine: