Return compressed PoV from collation (#942)

* Return compressed PoV from collation

This enables us to also print the size of the compressed PoV.

* FMT

* Update Polkadot & Substrate

* Fix compilation

* Fixes

* FMT
This commit is contained in:
Bastian Köcher
2022-02-07 22:04:56 +01:00
committed by GitHub
parent de8462ec2b
commit 6cbb92bbc8
4 changed files with 539 additions and 396 deletions
+518 -388
View File
File diff suppressed because it is too large Load Diff
+2 -1
View File
@@ -37,10 +37,11 @@ polkadot-node-subsystem-test-helpers = { git = "https://github.com/paritytech/po
# Cumulus dependencies # Cumulus dependencies
cumulus-test-runtime = { path = "../../test/runtime" } cumulus-test-runtime = { path = "../../test/runtime" }
cumulus-test-client = { path = "../../test/client" } cumulus-test-client = { path = "../../test/client" }
# Substrate dependencies
# Substrate dependencies
sp-state-machine = { git = "https://github.com/paritytech/substrate", branch = "master" } sp-state-machine = { git = "https://github.com/paritytech/substrate", branch = "master" }
sp-tracing = { git = "https://github.com/paritytech/substrate", branch = "master" } sp-tracing = { git = "https://github.com/paritytech/substrate", branch = "master" }
sp-maybe-compressed-blob = { git = "https://github.com/paritytech/substrate", branch = "master" }
# Other dependencies # Other dependencies
async-trait = "0.1.42" async-trait = "0.1.42"
+18 -7
View File
@@ -33,7 +33,7 @@ use sp_runtime::{
use cumulus_client_consensus_common::ParachainConsensus; use cumulus_client_consensus_common::ParachainConsensus;
use polkadot_node_primitives::{ use polkadot_node_primitives::{
BlockData, Collation, CollationGenerationConfig, CollationResult, PoV, BlockData, Collation, CollationGenerationConfig, CollationResult, MaybeCompressedPoV, PoV,
}; };
use polkadot_node_subsystem::messages::{CollationGenerationMessage, CollatorProtocolMessage}; use polkadot_node_subsystem::messages::{CollationGenerationMessage, CollatorProtocolMessage};
use polkadot_overseer::Handle as OverseerHandle; use polkadot_overseer::Handle as OverseerHandle;
@@ -184,9 +184,8 @@ where
&self, &self,
block: ParachainBlockData<Block>, block: ParachainBlockData<Block>,
block_hash: Block::Hash, block_hash: Block::Hash,
pov: PoV,
) -> Option<Collation> { ) -> Option<Collation> {
let block_data = BlockData(block.encode());
let collation_info = self let collation_info = self
.fetch_collation_info(block_hash, block.header()) .fetch_collation_info(block_hash, block.header())
.map_err(|e| { .map_err(|e| {
@@ -206,7 +205,7 @@ where
horizontal_messages: collation_info.horizontal_messages, horizontal_messages: collation_info.horizontal_messages,
hrmp_watermark: collation_info.hrmp_watermark, hrmp_watermark: collation_info.hrmp_watermark,
head_data: collation_info.head_data, head_data: collation_info.head_data,
proof_of_validity: PoV { block_data }, proof_of_validity: MaybeCompressedPoV::Compressed(pov),
}) })
} }
@@ -274,8 +273,17 @@ where
b.storage_proof().encode().len() as f64 / 1024f64, b.storage_proof().encode().len() as f64 / 1024f64,
); );
let pov =
polkadot_node_primitives::maybe_compress_pov(PoV { block_data: BlockData(b.encode()) });
tracing::info!(
target: LOG_TARGET,
"Compressed PoV size: {}kb",
pov.block_data.0.len() as f64 / 1024f64,
);
let block_hash = b.header().hash(); let block_hash = b.header().hash();
let collation = self.build_collation(b, block_hash)?; let collation = self.build_collation(b, block_hash, pov)?;
let (result_sender, signed_stmt_recv) = oneshot::channel(); let (result_sender, signed_stmt_recv) = oneshot::channel();
@@ -452,10 +460,13 @@ mod tests {
.expect("Collation is build") .expect("Collation is build")
.collation; .collation;
let block_data = collation.proof_of_validity.block_data; let pov = collation.proof_of_validity.into_compressed();
let decompressed =
sp_maybe_compressed_blob::decompress(&pov.block_data.0, 1024 * 1024 * 10).unwrap();
let block = let block =
ParachainBlockData::<Block>::decode(&mut &block_data.0[..]).expect("Is a valid block"); ParachainBlockData::<Block>::decode(&mut &decompressed[..]).expect("Is a valid block");
assert_eq!(1, *block.header().number()); assert_eq!(1, *block.header().number());
@@ -337,6 +337,7 @@ fn build_polkadot_full_node(
true, true,
None, None,
telemetry_worker_handle, telemetry_worker_handle,
false,
polkadot_service::RealOverseerGen, polkadot_service::RealOverseerGen,
)?; )?;