Sync: Propagate block announcement data (#7903)

* Sync: Propagate block announcement data

This pr adds a feature to the sync protocol to propagate the data that
we received alongside a block announcement. This is done by adding a
cache that caches the last X block announcement data where X is set to
the number of `in_peers` (giving every peer the chance to send us a
different block). This will be required by parachains to ensure that
even peers who are not connected to a collator receive the data
alongside the block announcement to properly validate it and request the
block.

* Review comment

* Bring back the code and add new variant to ensure we don't insert block
announce data when something wasn't checked

* Also use out_peers
This commit is contained in:
Bastian Köcher
2021-01-19 17:01:11 +01:00
committed by GitHub
parent 2e44ffb7a7
commit 450b96c50d
13 changed files with 198 additions and 72 deletions
@@ -722,7 +722,7 @@ impl<Block: BlockT> Sink<Message<Block>> for OutgoingMessages<Block>
);
// announce the block we voted on to our peers.
self.network.lock().announce(target_hash, Vec::new());
self.network.lock().announce(target_hash, None);
// propagate the message to peers
let topic = round_topic::<Block>(self.round, self.set_id);
@@ -68,7 +68,7 @@ impl sc_network_gossip::Network<Block> for TestNetwork {
let _ = self.sender.unbounded_send(Event::WriteNotification(who, message));
}
fn announce(&self, block: Hash, _associated_data: Vec<u8>) {
fn announce(&self, block: Hash, _associated_data: Option<Vec<u8>>) {
let _ = self.sender.unbounded_send(Event::Announce(block));
}
}