update Substrate/Polkadot/Cumulus refs (#1562)

* update Substrate/Polkadot/Cumulus refs

* finality-grandpa 0.16

* fix miillau-runtime compilation

* fix rialto runtime compilation

* fixed rialto-parachain runtime compilation

* backport GRANDPA test fixes

* helper instead of removed record_all_keys

* substrate-relay is compiling

* millau-bridge-node at least compiles

* rialto-bridge-node at least compiles

* rialto-parachain-collator compiles

* fixings tests (wip)

* fmt

* fixed BEEFY alert

* clippy

* removed unused dep

* -extra var

* move Leaf to mod mmr

* fix benchmarks
This commit is contained in:
Svyatoslav Nikolsky
2022-09-09 10:56:39 +03:00
committed by Bastian Köcher
parent ad38cdb873
commit 95c30c780c
32 changed files with 416 additions and 292 deletions
+2 -1
View File
@@ -37,7 +37,8 @@ pub use frame_support::storage::storage_prefix as storage_value_final_key;
use num_traits::{CheckedSub, One};
use sp_runtime::transaction_validity::TransactionValidity;
pub use storage_proof::{
Error as StorageProofError, ProofSize as StorageProofSize, StorageProofChecker,
record_all_keys as record_all_trie_keys, Error as StorageProofError,
ProofSize as StorageProofSize, StorageProofChecker,
};
#[cfg(feature = "std")]
@@ -19,8 +19,11 @@
use codec::Decode;
use hash_db::{HashDB, Hasher, EMPTY_PREFIX};
use sp_runtime::RuntimeDebug;
use sp_std::vec::Vec;
use sp_trie::{read_trie_value, LayoutV1, MemoryDB, StorageProof};
use sp_std::{boxed::Box, vec::Vec};
use sp_trie::{
read_trie_value, LayoutV1, MemoryDB, Recorder, StorageProof, Trie, TrieConfiguration,
TrieDBBuilder, TrieError, TrieHash,
};
/// Storage proof size requirements.
///
@@ -70,7 +73,7 @@ where
/// incomplete or otherwise invalid proof, this function returns an error.
pub fn read_value(&self, key: &[u8]) -> Result<Option<Vec<u8>>, Error> {
// LayoutV1 or LayoutV0 is identical for proof that only read values.
read_trie_value::<LayoutV1<H>, _>(&self.db, &self.root, key)
read_trie_value::<LayoutV1<H>, _>(&self.db, &self.root, key, None, None)
.map_err(|_| Error::StorageValueUnavailable)
}
@@ -124,6 +127,24 @@ pub fn craft_valid_storage_proof() -> (sp_core::H256, StorageProof) {
(root, proof)
}
/// Record all keys for a given root.
pub fn record_all_keys<L: TrieConfiguration, DB>(
db: &DB,
root: &TrieHash<L>,
recorder: &mut Recorder<L>,
) -> Result<(), Box<TrieError<L>>>
where
DB: hash_db::HashDBRef<L::Hash, trie_db::DBValue>,
{
let trie = TrieDBBuilder::<L>::new(db, root).with_recorder(recorder).build();
for x in trie.iter()? {
let (key, _) = x?;
trie.get(&key)?;
}
Ok(())
}
#[cfg(test)]
pub mod tests {
use super::*;