diff --git a/client/collator/src/lib.rs b/client/collator/src/lib.rs index 59eb56df3591..c8aac19526ca 100644 --- a/client/collator/src/lib.rs +++ b/client/collator/src/lib.rs @@ -225,19 +225,8 @@ where let (header, extrinsics) = candidate.block.deconstruct(); - let compact_proof = match candidate - .proof - .into_compact_proof::>(last_head.state_root().clone()) - { - Ok(proof) => proof, - Err(e) => { - tracing::error!(target: "cumulus-collator", "Failed to compact proof: {:?}", e); - return None; - } - }; - // Create the parachain block data for the validators. - let b = ParachainBlockData::::new(header, extrinsics, compact_proof); + let b = ParachainBlockData::::new(header, extrinsics, candidate.proof); tracing::debug!( target: LOG_TARGET, @@ -454,12 +443,7 @@ mod tests { assert_eq!(1, *block.header().number()); // Ensure that we did not include `:code` in the proof. - let db = block - .storage_proof() - .to_storage_proof::(Some(header.state_root())) - .unwrap() - .0 - .into_memory_db(); + let db = block.storage_proof().clone().into_memory_db(); let backend = sp_state_machine::new_in_mem::().update_backend(*header.state_root(), db); diff --git a/client/consensus/aura/src/lib.rs b/client/consensus/aura/src/lib.rs index c3d5c0c3f375..f53444c9fe11 100644 --- a/client/consensus/aura/src/lib.rs +++ b/client/consensus/aura/src/lib.rs @@ -142,7 +142,6 @@ where sc_consensus_aura::build_aura_worker::(BuildAuraWorkerParams { client: para_client, block_import: ParachainBlockImport::new(block_import), - justification_sync_link: (), proposer_factory, sync_oracle, force_authoring, @@ -151,6 +150,7 @@ where telemetry, block_proposal_slot_portion, max_block_proposal_slot_portion, + justification_sync_link: (), }); Self { diff --git a/pallets/parachain-system/src/validate_block/implementation.rs b/pallets/parachain-system/src/validate_block/implementation.rs index 439e1450db21..4b70e9dbded7 100644 --- a/pallets/parachain-system/src/validate_block/implementation.rs +++ b/pallets/parachain-system/src/validate_block/implementation.rs @@ -69,18 +69,11 @@ where "Invalid parent hash", ); - // Uncompress - let mut db = MemoryDB::default(); - let root = match sp_trie::decode_compact::>, _, _>( - &mut db, - storage_proof.iter_compact_encoded_nodes(), - Some(parent_head.state_root()), - ) { - Ok(root) => root, - Err(_) => panic!("Compact proof decoding failure."), - }; - sp_std::mem::drop(storage_proof); - + let db = storage_proof.into_memory_db(); + let root = parent_head.state_root().clone(); + if !sp_trie::HashDBT::, _>::contains(&db, &root, sp_trie::EMPTY_PREFIX) { + panic!("Witness data does not contain given storage root."); + } let backend = sp_state_machine::TrieBackend::new(db, root); let _guard = ( diff --git a/primitives/core/src/lib.rs b/primitives/core/src/lib.rs index 5d49b892862d..a622452942d5 100644 --- a/primitives/core/src/lib.rs +++ b/primitives/core/src/lib.rs @@ -195,7 +195,7 @@ pub struct ParachainBlockData { /// The extrinsics of the parachain block. extrinsics: sp_std::vec::Vec, /// The data that is required to emulate the storage accesses executed by all extrinsics. - storage_proof: sp_trie::CompactProof, + storage_proof: sp_trie::StorageProof, } impl ParachainBlockData { @@ -203,7 +203,7 @@ impl ParachainBlockData { pub fn new( header: ::Header, extrinsics: sp_std::vec::Vec<::Extrinsic>, - storage_proof: sp_trie::CompactProof, + storage_proof: sp_trie::StorageProof, ) -> Self { Self { header, @@ -232,19 +232,13 @@ impl ParachainBlockData { &self.extrinsics } - /// Returns the [`CompactProof`](sp_trie::CompactProof). - pub fn storage_proof(&self) -> &sp_trie::CompactProof { + /// Returns the [`StorageProof`](sp_trie::StorageProof). + pub fn storage_proof(&self) -> &sp_trie::StorageProof { &self.storage_proof } /// Deconstruct into the inner parts. - pub fn deconstruct( - self, - ) -> ( - B::Header, - sp_std::vec::Vec, - sp_trie::CompactProof, - ) { + pub fn deconstruct(self) -> (B::Header, sp_std::vec::Vec, sp_trie::StorageProof) { (self.header, self.extrinsics, self.storage_proof) } } diff --git a/test/client/src/block_builder.rs b/test/client/src/block_builder.rs index 00a327c10974..8f819179bcaf 100644 --- a/test/client/src/block_builder.rs +++ b/test/client/src/block_builder.rs @@ -18,7 +18,7 @@ use crate::{Backend, Client}; use cumulus_primitives_core::{ParachainBlockData, PersistedValidationData}; use cumulus_primitives_parachain_inherent::{ParachainInherentData, INHERENT_IDENTIFIER}; use cumulus_test_relay_sproof_builder::RelayStateSproofBuilder; -use cumulus_test_runtime::{Block, GetLastTimestamp, Hash, Header}; +use cumulus_test_runtime::{Block, GetLastTimestamp, Hash}; use polkadot_primitives::v1::{BlockNumber as PBlockNumber, Hash as PHash}; use sc_block_builder::{BlockBuilder, BlockBuilderProvider}; use sp_api::ProvideRuntimeApi; @@ -167,14 +167,12 @@ pub trait BuildParachainBlockData { } impl<'a> BuildParachainBlockData for sc_block_builder::BlockBuilder<'a, Block, Client, Backend> { - fn build_parachain_block(self, parent_state_root: Hash) -> ParachainBlockData { + fn build_parachain_block(self, _: Hash) -> ParachainBlockData { let built_block = self.build().expect("Builds the block"); let storage_proof = built_block .proof - .expect("We enabled proof recording before.") - .into_compact_proof::<
::Hashing>(parent_state_root) - .expect("Creates the compact proof"); + .expect("We enabled proof recording before."); let (header, extrinsics) = built_block.block.deconstruct(); ParachainBlockData::new(header, extrinsics, storage_proof)