mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-13 08:11:04 +00:00
Apply some clippy lints (#11154)
* Apply some clippy hints * Revert clippy ci changes * Update client/cli/src/commands/generate.rs Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com> * Update client/cli/src/commands/inspect_key.rs Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com> * Update client/db/src/bench.rs Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com> * Update client/db/src/bench.rs Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com> * Update client/service/src/client/block_rules.rs Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com> * Update client/service/src/client/block_rules.rs Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com> * Update client/network/src/transactions.rs Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com> * Update client/network/src/protocol.rs Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com> * Revert due to missing `or_default` function. * Fix compilation and simplify code * Undo change that corrupts benchmark. * fix clippy * Update client/service/test/src/lib.rs Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com> * Update client/state-db/src/noncanonical.rs Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com> * Update client/state-db/src/noncanonical.rs remove leftovers! * Update client/tracing/src/logging/directives.rs Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com> * Update utils/fork-tree/src/lib.rs Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com> * added needed ref * Update frame/referenda/src/benchmarking.rs * Simplify byte-vec creation * let's just not overlap the ranges * Correction * cargo fmt * Update utils/frame/benchmarking-cli/src/shared/stats.rs Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com> * Update utils/frame/benchmarking-cli/src/pallet/command.rs Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com> * Update utils/frame/benchmarking-cli/src/pallet/command.rs Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com> Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com> Co-authored-by: Giles Cope <gilescope@gmail.com>
This commit is contained in:
committed by
GitHub
parent
a990473cf9
commit
b581604aa7
@@ -197,7 +197,7 @@ pub trait Backend<H: Hasher>: sp_std::fmt::Debug {
|
||||
// child first
|
||||
for (child_info, child_delta) in child_deltas {
|
||||
let (child_root, empty, child_txs) =
|
||||
self.child_storage_root(&child_info, child_delta, state_version);
|
||||
self.child_storage_root(child_info, child_delta, state_version);
|
||||
let prefixed_storage_key = child_info.prefixed_storage_key();
|
||||
txs.consolidate(child_txs);
|
||||
if empty {
|
||||
@@ -311,7 +311,7 @@ pub struct BackendRuntimeCode<'a, B, H> {
|
||||
impl<'a, B: Backend<H>, H: Hasher> sp_core::traits::FetchRuntimeCode
|
||||
for BackendRuntimeCode<'a, B, H>
|
||||
{
|
||||
fn fetch_runtime_code<'b>(&'b self) -> Option<std::borrow::Cow<'b, [u8]>> {
|
||||
fn fetch_runtime_code(&self) -> Option<std::borrow::Cow<[u8]>> {
|
||||
self.backend
|
||||
.storage(sp_core::storage::well_known_keys::CODE)
|
||||
.ok()
|
||||
|
||||
@@ -288,7 +288,7 @@ impl Externalities for BasicExternalities {
|
||||
let empty_hash = empty_child_trie_root::<LayoutV1<Blake2Hasher>>();
|
||||
for (prefixed_storage_key, child_info) in prefixed_keys {
|
||||
let child_root = self.child_storage_root(&child_info, state_version);
|
||||
if &empty_hash[..] == &child_root[..] {
|
||||
if empty_hash[..] == child_root[..] {
|
||||
top.remove(prefixed_storage_key.as_slice());
|
||||
} else {
|
||||
top.insert(prefixed_storage_key.into_inner(), child_root);
|
||||
|
||||
@@ -316,8 +316,8 @@ where
|
||||
match (&next_backend_key, overlay_changes.peek()) {
|
||||
(_, None) => next_backend_key,
|
||||
(Some(_), Some(_)) => {
|
||||
while let Some(overlay_key) = overlay_changes.next() {
|
||||
let cmp = next_backend_key.as_deref().map(|v| v.cmp(&overlay_key.0));
|
||||
for overlay_key in overlay_changes {
|
||||
let cmp = next_backend_key.as_deref().map(|v| v.cmp(overlay_key.0));
|
||||
|
||||
// If `backend_key` is less than the `overlay_key`, we found out next key.
|
||||
if cmp == Some(Ordering::Less) {
|
||||
@@ -332,7 +332,7 @@ where
|
||||
// this key.
|
||||
next_backend_key = self
|
||||
.backend
|
||||
.next_storage_key(&overlay_key.0)
|
||||
.next_storage_key(overlay_key.0)
|
||||
.expect(EXT_NOT_ALLOWED_TO_FAIL);
|
||||
}
|
||||
}
|
||||
@@ -357,8 +357,8 @@ where
|
||||
match (&next_backend_key, overlay_changes.peek()) {
|
||||
(_, None) => next_backend_key,
|
||||
(Some(_), Some(_)) => {
|
||||
while let Some(overlay_key) = overlay_changes.next() {
|
||||
let cmp = next_backend_key.as_deref().map(|v| v.cmp(&overlay_key.0));
|
||||
for overlay_key in overlay_changes {
|
||||
let cmp = next_backend_key.as_deref().map(|v| v.cmp(overlay_key.0));
|
||||
|
||||
// If `backend_key` is less than the `overlay_key`, we found out next key.
|
||||
if cmp == Some(Ordering::Less) {
|
||||
@@ -373,7 +373,7 @@ where
|
||||
// this key.
|
||||
next_backend_key = self
|
||||
.backend
|
||||
.next_child_storage_key(child_info, &overlay_key.0)
|
||||
.next_child_storage_key(child_info, overlay_key.0)
|
||||
.expect(EXT_NOT_ALLOWED_TO_FAIL);
|
||||
}
|
||||
}
|
||||
@@ -546,7 +546,7 @@ where
|
||||
.storage(prefixed_storage_key.as_slice())
|
||||
.and_then(|k| Decode::decode(&mut &k[..]).ok())
|
||||
// V1 is equivalent to V0 on empty root.
|
||||
.unwrap_or_else(|| empty_child_trie_root::<LayoutV1<H>>());
|
||||
.unwrap_or_else(empty_child_trie_root::<LayoutV1<H>>);
|
||||
trace!(
|
||||
target: "state",
|
||||
method = "ChildStorageRoot",
|
||||
@@ -593,7 +593,7 @@ where
|
||||
.storage(prefixed_storage_key.as_slice())
|
||||
.and_then(|k| Decode::decode(&mut &k[..]).ok())
|
||||
// V1 is equivalent to V0 on empty root.
|
||||
.unwrap_or_else(|| empty_child_trie_root::<LayoutV1<H>>());
|
||||
.unwrap_or_else(empty_child_trie_root::<LayoutV1<H>>);
|
||||
|
||||
trace!(
|
||||
target: "state",
|
||||
|
||||
@@ -94,7 +94,7 @@ where
|
||||
H::Out: Codec + Ord,
|
||||
{
|
||||
fn clone(&self) -> Self {
|
||||
TrieBackend::new(self.backend_storage().clone(), self.root().clone())
|
||||
TrieBackend::new(self.backend_storage().clone(), *self.root())
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -644,7 +644,7 @@ mod execution {
|
||||
H::Out: Ord + 'static + codec::Codec,
|
||||
Spawn: SpawnNamed + Send + 'static,
|
||||
{
|
||||
let trie_backend = create_proof_check_backend::<H>(root.into(), proof)?;
|
||||
let trie_backend = create_proof_check_backend::<H>(root, proof)?;
|
||||
execution_proof_check_on_trie_backend::<_, _, _>(
|
||||
&trie_backend,
|
||||
overlay,
|
||||
@@ -791,7 +791,7 @@ mod execution {
|
||||
self.0.last().and_then(|s| s.key_values.last().map(|kv| kv.0.clone()));
|
||||
|
||||
if let Some(child_last) = child_last {
|
||||
if last.len() == 0 {
|
||||
if last.is_empty() {
|
||||
if let Some(top_last) = top_last {
|
||||
last.push(top_last)
|
||||
} else {
|
||||
@@ -866,7 +866,7 @@ mod execution {
|
||||
.storage(&storage_key)
|
||||
.map_err(|e| Box::new(e) as Box<dyn Error>)?
|
||||
{
|
||||
child_roots.insert(state_root.clone());
|
||||
child_roots.insert(state_root);
|
||||
} else {
|
||||
return Err(Box::new("Invalid range start child trie key."))
|
||||
}
|
||||
@@ -880,7 +880,7 @@ mod execution {
|
||||
let (child_info, depth) = if let Some(storage_key) = child_key.as_ref() {
|
||||
let storage_key = PrefixedStorageKey::new_ref(storage_key);
|
||||
(
|
||||
Some(match ChildType::from_prefixed_key(&storage_key) {
|
||||
Some(match ChildType::from_prefixed_key(storage_key) {
|
||||
Some((ChildType::ParentKeyId, storage_key)) =>
|
||||
ChildInfo::new_default(storage_key),
|
||||
None => return Err(Box::new("Invalid range start child trie key.")),
|
||||
@@ -900,15 +900,15 @@ mod execution {
|
||||
None,
|
||||
start_at_ref,
|
||||
|key, value| {
|
||||
if first {
|
||||
if start_at_ref
|
||||
if first &&
|
||||
start_at_ref
|
||||
.as_ref()
|
||||
.map(|start| &key.as_slice() > start)
|
||||
.unwrap_or(true)
|
||||
{
|
||||
first = false;
|
||||
}
|
||||
{
|
||||
first = false;
|
||||
}
|
||||
|
||||
if first {
|
||||
true
|
||||
} else if depth < MAX_NESTED_TRIE_DEPTH &&
|
||||
@@ -938,12 +938,10 @@ mod execution {
|
||||
if switch_child_key.is_none() {
|
||||
if depth == 1 {
|
||||
break
|
||||
} else if completed {
|
||||
start_at = child_key.take();
|
||||
} else {
|
||||
if completed {
|
||||
start_at = child_key.take();
|
||||
} else {
|
||||
break
|
||||
}
|
||||
break
|
||||
}
|
||||
} else {
|
||||
child_key = switch_child_key;
|
||||
@@ -1269,7 +1267,7 @@ mod execution {
|
||||
|
||||
let storage_key = PrefixedStorageKey::new_ref(storage_key);
|
||||
(
|
||||
Some(match ChildType::from_prefixed_key(&storage_key) {
|
||||
Some(match ChildType::from_prefixed_key(storage_key) {
|
||||
Some((ChildType::ParentKeyId, storage_key)) =>
|
||||
ChildInfo::new_default(storage_key),
|
||||
None => return Err(Box::new("Invalid range start child trie key.")),
|
||||
@@ -1294,15 +1292,15 @@ mod execution {
|
||||
None,
|
||||
start_at_ref,
|
||||
|key, value| {
|
||||
if first {
|
||||
if start_at_ref
|
||||
if first &&
|
||||
start_at_ref
|
||||
.as_ref()
|
||||
.map(|start| &key.as_slice() > start)
|
||||
.unwrap_or(true)
|
||||
{
|
||||
first = false;
|
||||
}
|
||||
{
|
||||
first = false;
|
||||
}
|
||||
|
||||
if !first {
|
||||
values.push((key.to_vec(), value.to_vec()));
|
||||
}
|
||||
@@ -1390,7 +1388,7 @@ mod tests {
|
||||
let using_native = use_native && self.native_available;
|
||||
match (using_native, self.native_succeeds, self.fallback_succeeds, native_call) {
|
||||
(true, true, _, Some(call)) => {
|
||||
let res = sp_externalities::set_and_run_with_externalities(ext, || call());
|
||||
let res = sp_externalities::set_and_run_with_externalities(ext, call);
|
||||
(res.map(NativeOrEncoded::Native).map_err(|_| 0), true)
|
||||
},
|
||||
(true, true, _, None) | (false, _, true, None) => (
|
||||
@@ -1584,13 +1582,13 @@ mod tests {
|
||||
.map(|(k, v)| (k.clone(), v.value().cloned()))
|
||||
.collect::<HashMap<_, _>>(),
|
||||
map![
|
||||
b"abc".to_vec() => None.into(),
|
||||
b"abb".to_vec() => None.into(),
|
||||
b"aba".to_vec() => None.into(),
|
||||
b"abd".to_vec() => None.into(),
|
||||
b"abc".to_vec() => None,
|
||||
b"abb".to_vec() => None,
|
||||
b"aba".to_vec() => None,
|
||||
b"abd".to_vec() => None,
|
||||
|
||||
b"bab".to_vec() => Some(b"228".to_vec()).into(),
|
||||
b"bbd".to_vec() => Some(b"42".to_vec()).into()
|
||||
b"bab".to_vec() => Some(b"228".to_vec()),
|
||||
b"bbd".to_vec() => Some(b"42".to_vec())
|
||||
],
|
||||
);
|
||||
|
||||
@@ -1608,12 +1606,12 @@ mod tests {
|
||||
.map(|(k, v)| (k.clone(), v.value().cloned()))
|
||||
.collect::<HashMap<_, _>>(),
|
||||
map![
|
||||
b"abb".to_vec() => None.into(),
|
||||
b"aba".to_vec() => None.into(),
|
||||
b"abd".to_vec() => None.into(),
|
||||
b"abb".to_vec() => None,
|
||||
b"aba".to_vec() => None,
|
||||
b"abd".to_vec() => None,
|
||||
|
||||
b"bab".to_vec() => Some(b"228".to_vec()).into(),
|
||||
b"bbd".to_vec() => Some(b"42".to_vec()).into()
|
||||
b"bab".to_vec() => Some(b"228".to_vec()),
|
||||
b"bbd".to_vec() => Some(b"42".to_vec())
|
||||
],
|
||||
);
|
||||
}
|
||||
@@ -1647,15 +1645,15 @@ mod tests {
|
||||
overlay
|
||||
.children()
|
||||
.flat_map(|(iter, _child_info)| iter)
|
||||
.map(|(k, v)| (k.clone(), v.value().clone()))
|
||||
.map(|(k, v)| (k.clone(), v.value()))
|
||||
.collect::<BTreeMap<_, _>>(),
|
||||
map![
|
||||
b"1".to_vec() => None.into(),
|
||||
b"2".to_vec() => None.into(),
|
||||
b"3".to_vec() => None.into(),
|
||||
b"4".to_vec() => None.into(),
|
||||
b"a".to_vec() => None.into(),
|
||||
b"b".to_vec() => None.into(),
|
||||
b"1".to_vec() => None,
|
||||
b"2".to_vec() => None,
|
||||
b"3".to_vec() => None,
|
||||
b"4".to_vec() => None,
|
||||
b"a".to_vec() => None,
|
||||
b"b".to_vec() => None,
|
||||
],
|
||||
);
|
||||
}
|
||||
@@ -1796,7 +1794,7 @@ mod tests {
|
||||
|
||||
fn test_compact(remote_proof: StorageProof, remote_root: &sp_core::H256) -> StorageProof {
|
||||
let compact_remote_proof =
|
||||
remote_proof.into_compact_proof::<BlakeTwo256>(remote_root.clone()).unwrap();
|
||||
remote_proof.into_compact_proof::<BlakeTwo256>(*remote_root).unwrap();
|
||||
compact_remote_proof
|
||||
.to_storage_proof::<BlakeTwo256>(Some(remote_root))
|
||||
.unwrap()
|
||||
@@ -1823,8 +1821,7 @@ mod tests {
|
||||
read_proof_check::<BlakeTwo256, _>(remote_root, remote_proof.clone(), &[b"value2"])
|
||||
.unwrap();
|
||||
let local_result2 =
|
||||
read_proof_check::<BlakeTwo256, _>(remote_root, remote_proof.clone(), &[&[0xff]])
|
||||
.is_ok();
|
||||
read_proof_check::<BlakeTwo256, _>(remote_root, remote_proof, &[&[0xff]]).is_ok();
|
||||
// check that results are correct
|
||||
assert_eq!(
|
||||
local_result1.into_iter().collect::<Vec<_>>(),
|
||||
@@ -1852,7 +1849,7 @@ mod tests {
|
||||
.unwrap();
|
||||
let local_result3 = read_child_proof_check::<BlakeTwo256, _>(
|
||||
remote_root,
|
||||
remote_proof.clone(),
|
||||
remote_proof,
|
||||
missing_child_info,
|
||||
&[b"dummy"],
|
||||
)
|
||||
@@ -1899,7 +1896,7 @@ mod tests {
|
||||
|
||||
let trie: InMemoryBackend<BlakeTwo256> =
|
||||
(storage.clone(), StateVersion::default()).into();
|
||||
let trie_root = trie.root().clone();
|
||||
let trie_root = trie.root();
|
||||
let backend = crate::ProvingBackend::new(&trie);
|
||||
let mut queries = Vec::new();
|
||||
for c in 0..(5 + nb_child_trie / 2) {
|
||||
@@ -1948,7 +1945,7 @@ mod tests {
|
||||
let storage_proof = backend.extract_proof();
|
||||
let remote_proof = test_compact(storage_proof, &trie_root);
|
||||
let proof_check =
|
||||
create_proof_check_backend::<BlakeTwo256>(trie_root, remote_proof).unwrap();
|
||||
create_proof_check_backend::<BlakeTwo256>(*trie_root, remote_proof).unwrap();
|
||||
|
||||
for (child_info, key, expected) in queries {
|
||||
assert_eq!(
|
||||
@@ -1998,15 +1995,9 @@ mod tests {
|
||||
prove_range_read_with_size(remote_backend, None, None, 50000, Some(&[])).unwrap();
|
||||
assert_eq!(proof.clone().into_memory_db::<BlakeTwo256>().drain().len(), 11);
|
||||
assert_eq!(count, 132);
|
||||
let (results, completed) = read_range_proof_check::<BlakeTwo256>(
|
||||
remote_root,
|
||||
proof.clone(),
|
||||
None,
|
||||
None,
|
||||
None,
|
||||
None,
|
||||
)
|
||||
.unwrap();
|
||||
let (results, completed) =
|
||||
read_range_proof_check::<BlakeTwo256>(remote_root, proof, None, None, None, None)
|
||||
.unwrap();
|
||||
assert_eq!(results.len() as u32, count);
|
||||
assert_eq!(completed, true);
|
||||
}
|
||||
@@ -2041,11 +2032,11 @@ mod tests {
|
||||
remote_proof
|
||||
};
|
||||
|
||||
let remote_proof = check_proof(mdb.clone(), root.clone(), state_version);
|
||||
let remote_proof = check_proof(mdb.clone(), root, state_version);
|
||||
// check full values in proof
|
||||
assert!(remote_proof.encode().len() > 1_100);
|
||||
assert!(remote_proof.encoded_size() > 1_100);
|
||||
let root1 = root.clone();
|
||||
let root1 = root;
|
||||
|
||||
// do switch
|
||||
state_version = StateVersion::V1;
|
||||
@@ -2057,9 +2048,9 @@ mod tests {
|
||||
trie.insert(b"foo", vec![1u8; 1000].as_slice()) // inner hash
|
||||
.expect("insert failed");
|
||||
}
|
||||
let root3 = root.clone();
|
||||
let root3 = root;
|
||||
assert!(root1 != root3);
|
||||
let remote_proof = check_proof(mdb.clone(), root.clone(), state_version);
|
||||
let remote_proof = check_proof(mdb.clone(), root, state_version);
|
||||
// nodes foo is replaced by its hashed value form.
|
||||
assert!(remote_proof.encode().len() < 1000);
|
||||
assert!(remote_proof.encoded_size() < 1000);
|
||||
@@ -2159,7 +2150,7 @@ mod tests {
|
||||
let remote_proof = test_compact(remote_proof, &remote_root);
|
||||
let local_result1 = read_child_proof_check::<BlakeTwo256, _>(
|
||||
remote_root,
|
||||
remote_proof.clone(),
|
||||
remote_proof,
|
||||
&child_info1,
|
||||
&[b"key1"],
|
||||
)
|
||||
|
||||
@@ -513,7 +513,7 @@ impl OverlayedChanges {
|
||||
pub fn drain_storage_changes<B: Backend<H>, H: Hasher>(
|
||||
&mut self,
|
||||
backend: &B,
|
||||
mut cache: &mut StorageTransactionCache<B::Transaction, H>,
|
||||
cache: &mut StorageTransactionCache<B::Transaction, H>,
|
||||
state_version: StateVersion,
|
||||
) -> Result<StorageChanges<B::Transaction, H>, DefaultError>
|
||||
where
|
||||
@@ -521,7 +521,7 @@ impl OverlayedChanges {
|
||||
{
|
||||
// If the transaction does not exist, we generate it.
|
||||
if cache.transaction.is_none() {
|
||||
self.storage_root(backend, &mut cache, state_version);
|
||||
self.storage_root(backend, cache, state_version);
|
||||
}
|
||||
|
||||
let (transaction, transaction_storage_root) = cache
|
||||
|
||||
@@ -42,7 +42,7 @@ impl OffchainOverlayedChanges {
|
||||
}
|
||||
|
||||
/// Iterate over all key value pairs by reference.
|
||||
pub fn iter<'a>(&'a self) -> impl Iterator<Item = OffchainOverlayedChangesItem<'a>> {
|
||||
pub fn iter(&self) -> impl Iterator<Item = OffchainOverlayedChangesItem> {
|
||||
self.0.changes().map(|kv| (kv.0, kv.1.value_ref()))
|
||||
}
|
||||
|
||||
|
||||
@@ -77,7 +77,7 @@ where
|
||||
.storage(storage_key)?
|
||||
.and_then(|r| Decode::decode(&mut &r[..]).ok())
|
||||
// V1 is equivalent to V0 on empty trie
|
||||
.unwrap_or_else(|| empty_child_trie_root::<LayoutV1<H>>());
|
||||
.unwrap_or_else(empty_child_trie_root::<LayoutV1<H>>);
|
||||
|
||||
let mut read_overlay = S::Overlay::default();
|
||||
let eph = Ephemeral::new(self.backend.backend_storage(), &mut read_overlay);
|
||||
@@ -88,7 +88,7 @@ where
|
||||
read_child_trie_value_with::<LayoutV1<H>, _, _>(
|
||||
child_info.keyspace(),
|
||||
&eph,
|
||||
&root.as_ref(),
|
||||
root.as_ref(),
|
||||
key,
|
||||
&mut *self.proof_recorder,
|
||||
)
|
||||
@@ -203,7 +203,7 @@ where
|
||||
proof_recorder: ProofRecorder<H::Out>,
|
||||
) -> Self {
|
||||
let essence = backend.essence();
|
||||
let root = essence.root().clone();
|
||||
let root = *essence.root();
|
||||
let recorder = ProofRecorderBackend { backend: essence.backend_storage(), proof_recorder };
|
||||
ProvingBackend(TrieBackend::new(recorder, root))
|
||||
}
|
||||
@@ -238,7 +238,7 @@ impl<'a, S: 'a + TrieBackendStorage<H>, H: 'a + Hasher> TrieBackendStorage<H>
|
||||
}
|
||||
|
||||
let backend_value = self.backend.get(key, prefix)?;
|
||||
self.proof_recorder.record(key.clone(), backend_value.clone());
|
||||
self.proof_recorder.record(*key, backend_value.clone());
|
||||
Ok(backend_value)
|
||||
}
|
||||
}
|
||||
@@ -395,9 +395,9 @@ mod tests {
|
||||
use sp_runtime::traits::BlakeTwo256;
|
||||
use sp_trie::PrefixedMemoryDB;
|
||||
|
||||
fn test_proving<'a>(
|
||||
trie_backend: &'a TrieBackend<PrefixedMemoryDB<BlakeTwo256>, BlakeTwo256>,
|
||||
) -> ProvingBackend<'a, PrefixedMemoryDB<BlakeTwo256>, BlakeTwo256> {
|
||||
fn test_proving(
|
||||
trie_backend: &TrieBackend<PrefixedMemoryDB<BlakeTwo256>, BlakeTwo256>,
|
||||
) -> ProvingBackend<PrefixedMemoryDB<BlakeTwo256>, BlakeTwo256> {
|
||||
ProvingBackend::new(trie_backend)
|
||||
}
|
||||
|
||||
@@ -474,7 +474,6 @@ mod tests {
|
||||
let trie_root = trie.storage_root(std::iter::empty(), state_version).0;
|
||||
assert_eq!(in_memory_root, trie_root);
|
||||
value_range
|
||||
.clone()
|
||||
.for_each(|i| assert_eq!(trie.storage(&[i]).unwrap().unwrap(), vec![i; size_content]));
|
||||
|
||||
let proving = ProvingBackend::new(trie);
|
||||
@@ -482,8 +481,7 @@ mod tests {
|
||||
|
||||
let proof = proving.extract_proof();
|
||||
|
||||
let proof_check =
|
||||
create_proof_check_backend::<BlakeTwo256>(in_memory_root.into(), proof).unwrap();
|
||||
let proof_check = create_proof_check_backend::<BlakeTwo256>(in_memory_root, proof).unwrap();
|
||||
assert_eq!(proof_check.storage(&[42]).unwrap().unwrap(), vec![42; size_content]);
|
||||
}
|
||||
|
||||
@@ -530,8 +528,7 @@ mod tests {
|
||||
|
||||
let proof = proving.extract_proof();
|
||||
|
||||
let proof_check =
|
||||
create_proof_check_backend::<BlakeTwo256>(in_memory_root.into(), proof).unwrap();
|
||||
let proof_check = create_proof_check_backend::<BlakeTwo256>(in_memory_root, proof).unwrap();
|
||||
assert!(proof_check.storage(&[0]).is_err());
|
||||
assert_eq!(proof_check.storage(&[42]).unwrap().unwrap(), vec![42]);
|
||||
// note that it is include in root because proof close
|
||||
@@ -542,8 +539,7 @@ mod tests {
|
||||
assert_eq!(proving.child_storage(child_info_1, &[64]), Ok(Some(vec![64])));
|
||||
|
||||
let proof = proving.extract_proof();
|
||||
let proof_check =
|
||||
create_proof_check_backend::<BlakeTwo256>(in_memory_root.into(), proof).unwrap();
|
||||
let proof_check = create_proof_check_backend::<BlakeTwo256>(in_memory_root, proof).unwrap();
|
||||
assert_eq!(proof_check.child_storage(child_info_1, &[64]).unwrap().unwrap(), vec![64]);
|
||||
}
|
||||
|
||||
|
||||
@@ -521,7 +521,7 @@ where
|
||||
Ok(None) => default_root,
|
||||
Err(e) => {
|
||||
warn!(target: "trie", "Failed to read child storage root: {}", e);
|
||||
default_root.clone()
|
||||
default_root
|
||||
},
|
||||
};
|
||||
|
||||
@@ -580,16 +580,12 @@ impl<'a, S: 'a + TrieBackendStorage<H>, H: Hasher> hash_db::HashDB<H, DBValue>
|
||||
for Ephemeral<'a, S, H>
|
||||
{
|
||||
fn get(&self, key: &H::Out, prefix: Prefix) -> Option<DBValue> {
|
||||
match HashDB::get(self.overlay, key, prefix) {
|
||||
Some(val) => Some(val),
|
||||
None => match self.storage.get(&key, prefix) {
|
||||
Ok(x) => x,
|
||||
Err(e) => {
|
||||
warn!(target: "trie", "Failed to read from DB: {}", e);
|
||||
None
|
||||
},
|
||||
},
|
||||
}
|
||||
HashDB::get(self.overlay, key, prefix).or_else(|| {
|
||||
self.storage.get(key, prefix).unwrap_or_else(|e| {
|
||||
warn!(target: "trie", "Failed to read from DB: {}", e);
|
||||
None
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
fn contains(&self, key: &H::Out, prefix: Prefix) -> bool {
|
||||
@@ -664,7 +660,7 @@ impl<S: TrieBackendStorage<H>, H: Hasher> HashDB<H, DBValue> for TrieBackendEsse
|
||||
if *key == self.empty {
|
||||
return Some([0u8].to_vec())
|
||||
}
|
||||
match self.storage.get(&key, prefix) {
|
||||
match self.storage.get(key, prefix) {
|
||||
Ok(x) => x,
|
||||
Err(e) => {
|
||||
warn!(target: "trie", "Failed to read from DB: {}", e);
|
||||
|
||||
Reference in New Issue
Block a user