mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-05-30 07:01:03 +00:00
Compact proof. (#295)
* compact, need to be made optional and look into/compress child trie roots/state. * proto with child trie support * Missing set_offchain_storage overload. * right name * Ignore offchain indexing in validation function. * patch trie-db * decompress from iter * use compressed proof * remove wasm blob from proof (no inject plugged yet) * change lock * update trie * change in toml * Revert "change in toml" This reverts commit e588583b79e1a64e2a54157b40968aa6b586fbbe. * use patch to branches * i * i:wq * switch branch * ii * ok, needed to patch the runtime by putting substrate patch in polkadot project. * test passing with this conf * actual lazy code fetch * patch issue * Code reorg * restore commented tests. * update deps. * remove polka patch * fixes * remove patch * revert cargo.lock * cargo update -p sp-trie polkadot-service * fix collator test (using parent state root). * Update pallets/parachain-system/src/validate_block/implementation.rs Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com> * Remove encode_witness test function. * Update pallets/parachain-system/src/validate_block/implementation.rs * Fix compilation Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com> Co-authored-by: Bastian Köcher <info@kchr.de>
This commit is contained in:
@@ -65,11 +65,17 @@ pub fn validate_block<B: BlockT, E: ExecuteBlock<B>, PSC: crate::Config>(
|
||||
"Invalid parent hash",
|
||||
);
|
||||
|
||||
let db = storage_proof.into_memory_db();
|
||||
let root = parent_head.state_root().clone();
|
||||
if !HashDB::<HashFor<B>, _>::contains(&db, &root, EMPTY_PREFIX) {
|
||||
panic!("Witness data does not contain given storage root.");
|
||||
}
|
||||
// Uncompress
|
||||
let mut db = MemoryDB::default();
|
||||
let root = match sp_trie::decode_compact::<sp_trie::Layout<HashFor<B>>, _, _>(
|
||||
&mut db,
|
||||
storage_proof.iter_compact_encoded_nodes(),
|
||||
Some(parent_head.state_root()),
|
||||
) {
|
||||
Ok(root) => root,
|
||||
Err(_) => panic!("Compact proof decoding failure."),
|
||||
};
|
||||
|
||||
let backend = sp_state_machine::TrieBackend::new(db, root);
|
||||
let mut overlay = sp_state_machine::OverlayedChanges::default();
|
||||
let mut cache = Default::default();
|
||||
|
||||
@@ -86,7 +86,7 @@ fn create_test_client() -> (Client, LongestChain) {
|
||||
|
||||
struct TestBlockData {
|
||||
block: Block,
|
||||
witness: sp_trie::StorageProof,
|
||||
witness: sp_trie::CompactProof,
|
||||
validation_data: PersistedValidationData,
|
||||
}
|
||||
|
||||
@@ -114,11 +114,15 @@ fn build_block_with_witness(
|
||||
|
||||
let built_block = builder.build().expect("Creates block");
|
||||
|
||||
let witness = built_block
|
||||
.proof
|
||||
.expect("We enabled proof recording before.")
|
||||
.into_compact_proof::<<Header as HeaderT>::Hashing>(*parent_head.state_root())
|
||||
.unwrap();
|
||||
|
||||
TestBlockData {
|
||||
block: built_block.block,
|
||||
witness: built_block
|
||||
.proof
|
||||
.expect("We enabled proof recording before."),
|
||||
witness,
|
||||
validation_data,
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user