Skip to content
This repository was archived by the owner on Nov 15, 2023. It is now read-only.

Commit 0f1caf3

Browse files
committed
Revert "Compact proof. (#295)"
This reverts commit d935b81.
1 parent 3462a4b commit 0f1caf3

File tree

5 files changed

+16
-47
lines changed

5 files changed

+16
-47
lines changed

client/collator/src/lib.rs

Lines changed: 2 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -225,19 +225,8 @@ where
225225

226226
let (header, extrinsics) = candidate.block.deconstruct();
227227

228-
let compact_proof = match candidate
229-
.proof
230-
.into_compact_proof::<HashFor<Block>>(last_head.state_root().clone())
231-
{
232-
Ok(proof) => proof,
233-
Err(e) => {
234-
tracing::error!(target: "cumulus-collator", "Failed to compact proof: {:?}", e);
235-
return None;
236-
}
237-
};
238-
239228
// Create the parachain block data for the validators.
240-
let b = ParachainBlockData::<Block>::new(header, extrinsics, compact_proof);
229+
let b = ParachainBlockData::<Block>::new(header, extrinsics, candidate.proof);
241230

242231
tracing::debug!(
243232
target: LOG_TARGET,
@@ -454,12 +443,7 @@ mod tests {
454443
assert_eq!(1, *block.header().number());
455444

456445
// Ensure that we did not include `:code` in the proof.
457-
let db = block
458-
.storage_proof()
459-
.to_storage_proof::<BlakeTwo256>(Some(header.state_root()))
460-
.unwrap()
461-
.0
462-
.into_memory_db();
446+
let db = block.storage_proof().clone().into_memory_db();
463447

464448
let backend =
465449
sp_state_machine::new_in_mem::<BlakeTwo256>().update_backend(*header.state_root(), db);

client/consensus/aura/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,6 @@ where
142142
sc_consensus_aura::build_aura_worker::<P, _, _, _, _, _, _, _, _>(BuildAuraWorkerParams {
143143
client: para_client,
144144
block_import: ParachainBlockImport::new(block_import),
145-
justification_sync_link: (),
146145
proposer_factory,
147146
sync_oracle,
148147
force_authoring,
@@ -151,6 +150,7 @@ where
151150
telemetry,
152151
block_proposal_slot_portion,
153152
max_block_proposal_slot_portion,
153+
justification_sync_link: (),
154154
});
155155

156156
Self {

pallets/parachain-system/src/validate_block/implementation.rs

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -69,18 +69,11 @@ where
6969
"Invalid parent hash",
7070
);
7171

72-
// Uncompress
73-
let mut db = MemoryDB::default();
74-
let root = match sp_trie::decode_compact::<sp_trie::Layout<HashFor<B>>, _, _>(
75-
&mut db,
76-
storage_proof.iter_compact_encoded_nodes(),
77-
Some(parent_head.state_root()),
78-
) {
79-
Ok(root) => root,
80-
Err(_) => panic!("Compact proof decoding failure."),
81-
};
82-
sp_std::mem::drop(storage_proof);
83-
72+
let db = storage_proof.into_memory_db();
73+
let root = parent_head.state_root().clone();
74+
if !sp_trie::HashDBT::<HashFor<B>, _>::contains(&db, &root, sp_trie::EMPTY_PREFIX) {
75+
panic!("Witness data does not contain given storage root.");
76+
}
8477
let backend = sp_state_machine::TrieBackend::new(db, root);
8578

8679
let _guard = (

primitives/core/src/lib.rs

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -195,15 +195,15 @@ pub struct ParachainBlockData<B: BlockT> {
195195
/// The extrinsics of the parachain block.
196196
extrinsics: sp_std::vec::Vec<B::Extrinsic>,
197197
/// The data that is required to emulate the storage accesses executed by all extrinsics.
198-
storage_proof: sp_trie::CompactProof,
198+
storage_proof: sp_trie::StorageProof,
199199
}
200200

201201
impl<B: BlockT> ParachainBlockData<B> {
202202
/// Creates a new instance of `Self`.
203203
pub fn new(
204204
header: <B as BlockT>::Header,
205205
extrinsics: sp_std::vec::Vec<<B as BlockT>::Extrinsic>,
206-
storage_proof: sp_trie::CompactProof,
206+
storage_proof: sp_trie::StorageProof,
207207
) -> Self {
208208
Self {
209209
header,
@@ -232,19 +232,13 @@ impl<B: BlockT> ParachainBlockData<B> {
232232
&self.extrinsics
233233
}
234234

235-
/// Returns the [`CompactProof`](sp_trie::CompactProof).
236-
pub fn storage_proof(&self) -> &sp_trie::CompactProof {
235+
/// Returns the [`StorageProof`](sp_trie::StorageProof).
236+
pub fn storage_proof(&self) -> &sp_trie::StorageProof {
237237
&self.storage_proof
238238
}
239239

240240
/// Deconstruct into the inner parts.
241-
pub fn deconstruct(
242-
self,
243-
) -> (
244-
B::Header,
245-
sp_std::vec::Vec<B::Extrinsic>,
246-
sp_trie::CompactProof,
247-
) {
241+
pub fn deconstruct(self) -> (B::Header, sp_std::vec::Vec<B::Extrinsic>, sp_trie::StorageProof) {
248242
(self.header, self.extrinsics, self.storage_proof)
249243
}
250244
}

test/client/src/block_builder.rs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ use crate::{Backend, Client};
1818
use cumulus_primitives_core::{ParachainBlockData, PersistedValidationData};
1919
use cumulus_primitives_parachain_inherent::{ParachainInherentData, INHERENT_IDENTIFIER};
2020
use cumulus_test_relay_sproof_builder::RelayStateSproofBuilder;
21-
use cumulus_test_runtime::{Block, GetLastTimestamp, Hash, Header};
21+
use cumulus_test_runtime::{Block, GetLastTimestamp, Hash};
2222
use polkadot_primitives::v1::{BlockNumber as PBlockNumber, Hash as PHash};
2323
use sc_block_builder::{BlockBuilder, BlockBuilderProvider};
2424
use sp_api::ProvideRuntimeApi;
@@ -167,14 +167,12 @@ pub trait BuildParachainBlockData {
167167
}
168168

169169
impl<'a> BuildParachainBlockData for sc_block_builder::BlockBuilder<'a, Block, Client, Backend> {
170-
fn build_parachain_block(self, parent_state_root: Hash) -> ParachainBlockData<Block> {
170+
fn build_parachain_block(self, _: Hash) -> ParachainBlockData<Block> {
171171
let built_block = self.build().expect("Builds the block");
172172

173173
let storage_proof = built_block
174174
.proof
175-
.expect("We enabled proof recording before.")
176-
.into_compact_proof::<<Header as HeaderT>::Hashing>(parent_state_root)
177-
.expect("Creates the compact proof");
175+
.expect("We enabled proof recording before.");
178176

179177
let (header, extrinsics) = built_block.block.deconstruct();
180178
ParachainBlockData::new(header, extrinsics, storage_proof)

0 commit comments

Comments
 (0)