Compress the PoV block before sending it over the network (#2288)

* Compress the PoV block before sending it over the network

This pr changes the way we send PoV blocks over the network. We now
compress the PoV block before it is send over the network. This should
reduce the size significant for PoVs which contain the runtime WASM for
example.

* Preallocate 1KB

* Try something..

* Switch to zstd and some renamings

* Make compression/decompression fail in browsers

* Use some sane maximum value

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

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

* Fix and add test

* add

Co-authored-by: Andronik Ordian <write@reusable.software>
Co-authored-by: Robert Habermeier <rphmeier@gmail.com>
This commit is contained in:
Bastian Köcher
2021-01-21 19:04:14 +01:00
committed by GitHub
parent 2c0982d75e
commit 1439558f14
9 changed files with 190 additions and 56 deletions
@@ -19,6 +19,9 @@ enum ObservedRole {
Full,
Light,
}
/// SCALE and zstd encoded `PoV`.
struct CompressedPoV(Vec<u8>);
```
## V1 Network Subsystem Message Types
@@ -75,8 +78,8 @@ enum PoVDistributionV1Message {
/// 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),
/// (relay_parent, pov_hash, compressed_pov)
SendPoV(Hash, Hash, CompressedPoV),
}
```
@@ -101,7 +104,7 @@ enum CollatorProtocolV1Message {
/// Request the advertised collation at that relay-parent.
RequestCollation(RequestId, Hash, ParaId),
/// A requested collation.
Collation(RequestId, CandidateReceipt, PoV),
Collation(RequestId, CandidateReceipt, CompressedPoV),
}
```