Skip to content
This repository was archived by the owner on Nov 15, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
c23a13c
introduce candidatedescriptor type
rphmeier Jul 2, 2020
7a2be24
add PoVDistribution message type
rphmeier Jul 2, 2020
55e1b5a
loosen bound on PoV Distribution to account for equivocations
rphmeier Jul 2, 2020
1db4f3c
re-export some types from the messages module
rphmeier Jul 2, 2020
f6641c4
begin PoV Distribution subsystem
rphmeier Jul 2, 2020
fe005b7
remove redundant index from PoV distribution
rphmeier Jul 3, 2020
27da7ef
define state machine for pov distribution
rphmeier Jul 3, 2020
2cdcefd
handle overseer signals
rphmeier Jul 3, 2020
e66e063
set up control flow
rphmeier Jul 3, 2020
6197058
remove `ValidatorStatement` section
rphmeier Jul 3, 2020
623db00
implement PoV fetching
rphmeier Jul 3, 2020
86d1cf0
implement distribution logic
rphmeier Jul 3, 2020
8557778
add missing `
rphmeier Jul 3, 2020
fa86b24
implement some network bridge event handlers
rphmeier Jul 3, 2020
8b4a7b0
stub for message processing, handle our view change
rphmeier Jul 3, 2020
0b82a0c
control flow for handling messages
rphmeier Jul 3, 2020
a45e58e
handle `awaiting` message
rphmeier Jul 3, 2020
a768179
handle any incoming PoVs and redistribute
rphmeier Jul 3, 2020
d47905d
actually provide a subsystem implementation
rphmeier Jul 3, 2020
bb31777
remove set-builder notation
rphmeier Jul 6, 2020
24d6278
begin testing PoV distribution
rphmeier Jul 7, 2020
5202b3d
test that we send awaiting messages only to peers with same view
rphmeier Jul 7, 2020
3d9d000
ensure we distribute awaited PoVs to peers on view changes
rphmeier Jul 7, 2020
df4a1f1
test that peers can complete fetch and are rewarded
rphmeier Jul 7, 2020
f2c9bfb
test some reporting logic
rphmeier Jul 7, 2020
7923146
ensure peer is reported for flooding
rphmeier Jul 7, 2020
43d610d
test punishing peers diverging from awaited protocol
rphmeier Jul 7, 2020
57f133f
test that we eagerly complete peers' awaited PoVs based on what we re…
rphmeier Jul 7, 2020
7d26c53
test that we prune the awaited set after receiving
rphmeier Jul 7, 2020
6406423
Merge branch 'master' into rh-pov-distribution
rphmeier Jul 7, 2020
0ff3988
expand pov-distribution in guide to match a change I made
rphmeier Jul 7, 2020
8cc66a7
Merge branch 'master' into rh-pov-distribution
rphmeier Jul 7, 2020
f506a91
remove unneeded import
rphmeier Jul 7, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
remove redundant index from PoV distribution
  • Loading branch information
rphmeier committed Jul 3, 2020
commit fe005b7f086fe7e30eef21ee65dd3afdba19e4b9
10 changes: 4 additions & 6 deletions roadmap/implementors-guide/src/node/backing/pov-distribution.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ The view update mechanism of the [Network Bridge](../utility/network-bridge.md)

View updates from peers and our own view updates are received from the network bridge. These will lag somewhat behind the `StartWork` and `StopWork` messages received from the overseer, which will influence the actual data we store. The `OurViewUpdate`s from the [`NetworkBridgeEvent`](../../types/overseer-protocol.md#network-bridge-update) must be considered canonical in terms of our peers' perception of us.

Lastly, the system needs to be bootstrapped with our own perception of which PoVs we are cognizant of but awaiting data for. This is done by receipt of the [`PoVDistributionMessage`](../../types/overseer-protocol.md#pov-distribution-message)::ValidatorStatement variant. We can ignore anything except for `Seconded` statements.
Lastly, the system needs to be bootstrapped with our own perception of which PoVs we are cognizant of but awaiting data for. This is done by receipt of the [`PoVDistributionMessage`](../../types/overseer-protocol.md#pov-distribution-message)::FetchPoV variant. Proper operation of this subsystem depends on the descriptors passed faithfully representing candidates which have been seconded by other validators.

## Formal Description

Expand All @@ -47,7 +47,6 @@ struct State {

struct BlockBasedState {
known: Map<Hash, PoV>, // should be a shared PoV in practice. these things are heavy.
awaited: Set<Hash>, // awaited PoVs by blake2-256 hash.
fetching: Map<Hash, [ResponseChannel<PoV>]>,
n_validators: usize,
}
Expand Down Expand Up @@ -83,12 +82,11 @@ Here is the logic of the state machine:
*PoV Distribution Messages*
- On `ValidatorStatement(relay_parent, statement)`
- If this is not `Statement::Seconded`, ignore.
- If there is an entry under `relay_parent` in `relay_parent_state`, add the `pov_hash` of the seconded Candidate's [`CandidateDescriptor`](../../types/candidate.md#candidate-descriptor) to the `awaited` set of the entry.
- If the `pov_hash` was not previously awaited and there are `n_validators` or fewer entries in the `awaited` set, send `NetworkMessage::Awaiting(relay_parent, vec![pov_hash])` to all peers.
- On `FetchPoV(relay_parent, descriptor, response_channel)`
- If there is no entry in `relay_parent_state` under `relay_parent`, ignore.
- If there is a PoV under `descriptor.pov_hash` in the `known` map, send that PoV on the channel and return.
- Otherwise, place the `response_channel` in the `fetching` map under `descriptor.pov_hash`.
- If the `pov_hash` had no previous entry in `fetching` and there are `n_validators` or fewer entries in the `fetching` set, send `NetworkMessage::Awaiting(relay_parent, vec![pov_hash])` to all peers.
- On `DistributePoV(relay_parent, descriptor, PoV)`
- If there is no entry in `relay_parent_state` under `relay_parent`, ignore.
- Complete and remove any channels under `descriptor.pov_hash` in the `fetching` map.
Expand All @@ -105,13 +103,13 @@ Here is the logic of the state machine:
- If this is `NetworkMessage::Awaiting(relay_parent, pov_hashes)`:
- If there is no entry under `peer_state.awaited` for the `relay_parent`, report and ignore.
- If `relay_parent` is not contained within `our_view`, report and ignore.
- Otherwise, if the `awaited` map combined with the `pov_hashes` would have more than ` 2 * relay_parent_state[relay_parent].n_validators` entries, report and ignore. Note that we are leaning on the property of the network bridge that it sets our view based on `StartWork` messages.
- Otherwise, if the peer's `awaited` map combined with the `pov_hashes` would have more than ` 2 * relay_parent_state[relay_parent].n_validators` entries, report and ignore. Note that we are leaning on the property of the network bridge that it sets our view based on `StartWork` messages.
- For each new `pov_hash` in `pov_hashes`, if there is a `pov` under `pov_hash` in the `known` map, send the peer a `NetworkMessage::SendPoV(relay_parent, pov_hash, pov)`.
- Otherwise, add the `pov_hash` to the `awaited` map
- If this is `NetworkMessage::SendPoV(relay_parent, pov_hash, pov)`:
- If there is no entry under `relay_parent` in `relay_parent_state` or no entry under `pov_hash` in our `awaited` map for that `relay_parent`, report and ignore.
- If the blake2-256 hash of the pov doesn't equal `pov_hash`, report and ignore.
- Complete and remove any listeners in the `fetching` map under `pov_hash`.
- Complete and remove any listeners in the `fetching` map under `pov_hash`. However, leave an empty set of listeners in the `fetching` map to denote that this was something we once awaited. This will allow us to recognize peers who have sent us something we were expecting, but just a little late.
- Add to `known` map.
- Send `NetworkMessage::SendPoV(relay_parent, descriptor.pov_hash, PoV)` to all peers who have the `descriptor.pov_hash` in the set under `relay_parent` in the `peer.awaited` map and remove the entry from `peer.awaited`.
- On `PeerViewChange(peer_id, view)`
Expand Down
7 changes: 3 additions & 4 deletions roadmap/implementors-guide/src/types/overseer-protocol.md
Original file line number Diff line number Diff line change
Expand Up @@ -172,11 +172,10 @@ If this subsystem chooses to second a parachain block, it dispatches a `Candidat

```rust
enum PoVDistributionMessage {
/// Note a statement by a validator on a relay-parent. `Seconded` statements must always
/// have been passed in before `Valid` or `Invalid` statements.
ValidatorStatement(Hash, SignedFullStatement),
/// Fetch a PoV from the network.
/// (relay_parent, PoV-hash, Response channel).
///
/// This `CandidateDescriptor` should correspond to a candidate seconded under the provided
/// relay-parent hash.
FetchPoV(Hash, CandidateDescriptor, ResponseChannel<PoV>),
/// Distribute a PoV for the given relay-parent and CandidateDescriptor.
/// The PoV should correctly hash to the PoV hash mentioned in the CandidateDescriptor
Expand Down