approval-distribution: a fix for out-of-view messages (#4908)

* approval-distribution: a fix for out-of-view messages

* approval-distribution: trace logs

* adjust the guide slightly

* comments and nits
This commit is contained in:
Andronik
2022-02-22 16:02:03 +01:00
committed by GitHub
parent bf1a805c9e
commit 9d9f82256e
2 changed files with 118 additions and 42 deletions
@@ -241,12 +241,12 @@ Imports an approval signature referenced by block hash and candidate index:
#### `unify_with_peer(peer: PeerId, view)`:
1. Initialize a set `fresh_blocks = {}`
1. Initialize a set `missing_knowledge = {}`
For each block in the view:
2. Load the `BlockEntry` for the block. If the block is unknown, or the number is less than or equal to the view's finalized number go to step 6.
3. Inspect the `known_by` set of the `BlockEntry`. If the peer is already present, go to step 6.
4. Add the peer to `known_by` with a cloned version of `block_entry.knowledge`. and add the hash of the block to `fresh_blocks`.
3. Inspect the `known_by` set of the `BlockEntry`. If the peer already knows all assignments/approvals, go to step 6.
4. Add the peer to `known_by` and add the hash and missing knowledge of the block to `missing_knowledge`.
5. Return to step 2 with the ancestor of the block.
6. For each block in `fresh_blocks`, send all assignments and approvals for all candidates in those blocks to the peer.
6. For each block in `missing_knowledge`, send all assignments and approvals for all candidates in those blocks to the peer.