From 4f077b09bc77e701ff9ea3e68535aaf757ed361b Mon Sep 17 00:00:00 2001 From: Falco Hirschenberger Date: Wed, 28 Sep 2022 18:13:39 +0200 Subject: [PATCH 1/2] #12067 wip --- primitives/externalities/src/lib.rs | 24 ++-- primitives/state-machine/src/backend.rs | 1 + primitives/state-machine/src/basic.rs | 33 +++--- primitives/state-machine/src/ext.rs | 40 +++---- primitives/state-machine/src/lib.rs | 107 ++++++++++-------- primitives/state-machine/src/read_only.rs | 18 +-- primitives/state-machine/src/testing.rs | 2 +- primitives/state-machine/src/trie_backend.rs | 33 ++++-- .../state-machine/src/trie_backend_essence.rs | 40 ++++--- primitives/trie/src/cache/mod.rs | 68 +++++------ primitives/trie/src/cache/shared_cache.rs | 21 ++-- 11 files changed, 207 insertions(+), 180 deletions(-) diff --git a/primitives/externalities/src/lib.rs b/primitives/externalities/src/lib.rs index b343b8c393e00..9c75c467c04dc 100644 --- a/primitives/externalities/src/lib.rs +++ b/primitives/externalities/src/lib.rs @@ -84,24 +84,24 @@ pub trait Externalities: ExtensionStore { fn set_offchain_storage(&mut self, key: &[u8], value: Option<&[u8]>); /// Read runtime storage. - fn storage(&self, key: &[u8]) -> Option>; + fn storage(&mut self, key: &[u8]) -> Option>; /// Get storage value hash. /// /// This may be optimized for large values. - fn storage_hash(&self, key: &[u8]) -> Option>; + fn storage_hash(&mut self, key: &[u8]) -> Option>; /// Get child storage value hash. /// /// This may be optimized for large values. /// /// Returns an `Option` that holds the SCALE encoded hash. - fn child_storage_hash(&self, child_info: &ChildInfo, key: &[u8]) -> Option>; + fn child_storage_hash(&mut self, child_info: &ChildInfo, key: &[u8]) -> Option>; /// Read child runtime storage. /// /// Returns an `Option` that holds the SCALE encoded hash. - fn child_storage(&self, child_info: &ChildInfo, key: &[u8]) -> Option>; + fn child_storage(&mut self, child_info: &ChildInfo, key: &[u8]) -> Option>; /// Set storage entry `key` of current contract being called (effective immediately). fn set_storage(&mut self, key: Vec, value: Vec) { @@ -125,20 +125,20 @@ pub trait Externalities: ExtensionStore { } /// Whether a storage entry exists. - fn exists_storage(&self, key: &[u8]) -> bool { + fn exists_storage(&mut self, key: &[u8]) -> bool { self.storage(key).is_some() } /// Whether a child storage entry exists. - fn exists_child_storage(&self, child_info: &ChildInfo, key: &[u8]) -> bool { + fn exists_child_storage(&mut self, child_info: &ChildInfo, key: &[u8]) -> bool { self.child_storage(child_info, key).is_some() } /// Returns the key immediately following the given key, if it exists. - fn next_storage_key(&self, key: &[u8]) -> Option>; + fn next_storage_key(&mut self, key: &[u8]) -> Option>; /// Returns the key immediately following the given key, if it exists, in child storage. - fn next_child_storage_key(&self, child_info: &ChildInfo, key: &[u8]) -> Option>; + fn next_child_storage_key(&mut self, child_info: &ChildInfo, key: &[u8]) -> Option>; /// Clear an entire child storage. /// @@ -270,7 +270,7 @@ pub trait Externalities: ExtensionStore { /// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! /// /// Gets the current read/write count for the benchmarking process. - fn read_write_count(&self) -> (u32, u32, u32, u32); + fn read_write_count(&mut self) -> (u32, u32, u32, u32); /// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! /// Benchmarking related functionality and shouldn't be used anywhere else! @@ -284,7 +284,7 @@ pub trait Externalities: ExtensionStore { /// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! /// /// Gets the current DB tracking whitelist. - fn get_whitelist(&self) -> Vec; + fn get_whitelist(&mut self) -> Vec; /// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! /// Benchmarking related functionality and shouldn't be used anywhere else! @@ -299,7 +299,7 @@ pub trait Externalities: ExtensionStore { /// /// Returns estimated proof size for the state queries so far. /// Proof is reset on commit and wipe. - fn proof_size(&self) -> Option { + fn proof_size(&mut self) -> Option { None } @@ -308,7 +308,7 @@ pub trait Externalities: ExtensionStore { /// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! /// /// Get all the keys that have been read or written to during the benchmark. - fn get_read_and_written_keys(&self) -> Vec<(Vec, u32, u32, bool)>; + fn get_read_and_written_keys(&mut self) -> Vec<(Vec, u32, u32, bool)>; } /// Extension for the [`Externalities`] trait. diff --git a/primitives/state-machine/src/backend.rs b/primitives/state-machine/src/backend.rs index 791183c4d7e4d..64b493800ca16 100644 --- a/primitives/state-machine/src/backend.rs +++ b/primitives/state-machine/src/backend.rs @@ -275,6 +275,7 @@ pub trait AsTrieBackend> { /// Return the type as [`TrieBackend`]. fn as_trie_backend(&self) -> &TrieBackend; + fn as_trie_backend_mut(&mut self) -> &mut TrieBackend; } /// Trait that allows consolidate two transactions together. diff --git a/primitives/state-machine/src/basic.rs b/primitives/state-machine/src/basic.rs index fdc50e3f8f207..9fc2f0232cedd 100644 --- a/primitives/state-machine/src/basic.rs +++ b/primitives/state-machine/src/basic.rs @@ -121,13 +121,14 @@ impl BasicExternalities { impl PartialEq for BasicExternalities { fn eq(&self, other: &BasicExternalities) -> bool { - self.overlay.changes().map(|(k, v)| (k, v.value())).collect::>() == - other.overlay.changes().map(|(k, v)| (k, v.value())).collect::>() && - self.overlay + self.overlay.changes().map(|(k, v)| (k, v.value())).collect::>() + == other.overlay.changes().map(|(k, v)| (k, v.value())).collect::>() + && self + .overlay .children() .map(|(iter, i)| (i, iter.map(|(k, v)| (k, v.value())).collect::>())) - .collect::>() == - other + .collect::>() + == other .overlay .children() .map(|(iter, i)| { @@ -160,27 +161,27 @@ impl From> for BasicExternalities { impl Externalities for BasicExternalities { fn set_offchain_storage(&mut self, _key: &[u8], _value: Option<&[u8]>) {} - fn storage(&self, key: &[u8]) -> Option { + fn storage(&mut self, key: &[u8]) -> Option { self.overlay.storage(key).and_then(|v| v.map(|v| v.to_vec())) } - fn storage_hash(&self, key: &[u8]) -> Option> { + fn storage_hash(&mut self, key: &[u8]) -> Option> { self.storage(key).map(|v| Blake2Hasher::hash(&v).encode()) } - fn child_storage(&self, child_info: &ChildInfo, key: &[u8]) -> Option { + fn child_storage(&mut self, child_info: &ChildInfo, key: &[u8]) -> Option { self.overlay.child_storage(child_info, key).and_then(|v| v.map(|v| v.to_vec())) } - fn child_storage_hash(&self, child_info: &ChildInfo, key: &[u8]) -> Option> { + fn child_storage_hash(&mut self, child_info: &ChildInfo, key: &[u8]) -> Option> { self.child_storage(child_info, key).map(|v| Blake2Hasher::hash(&v).encode()) } - fn next_storage_key(&self, key: &[u8]) -> Option { + fn next_storage_key(&mut self, key: &[u8]) -> Option { self.overlay.iter_after(key).find_map(|(k, v)| v.value().map(|_| k.to_vec())) } - fn next_child_storage_key(&self, child_info: &ChildInfo, key: &[u8]) -> Option { + fn next_child_storage_key(&mut self, child_info: &ChildInfo, key: &[u8]) -> Option { self.overlay .child_iter_after(child_info.storage_key(), key) .find_map(|(k, v)| v.value().map(|_| k.to_vec())) @@ -189,7 +190,7 @@ impl Externalities for BasicExternalities { fn place_storage(&mut self, key: StorageKey, maybe_value: Option) { if is_child_storage_key(&key) { warn!(target: "trie", "Refuse to set child storage key via main storage"); - return + return; } self.overlay.set_storage(key, maybe_value) @@ -226,7 +227,7 @@ impl Externalities for BasicExternalities { "Refuse to clear prefix that is part of child storage key via main storage" ); let maybe_cursor = Some(prefix.to_vec()); - return MultiRemovalResults { maybe_cursor, backend: 0, unique: 0, loops: 0 } + return MultiRemovalResults { maybe_cursor, backend: 0, unique: 0, loops: 0 }; } let count = self.overlay.clear_prefix(prefix); @@ -307,7 +308,7 @@ impl Externalities for BasicExternalities { fn commit(&mut self) {} - fn read_write_count(&self) -> (u32, u32, u32, u32) { + fn read_write_count(&mut self) -> (u32, u32, u32, u32) { unimplemented!("read_write_count is not supported in Basic") } @@ -315,7 +316,7 @@ impl Externalities for BasicExternalities { unimplemented!("reset_read_write_count is not supported in Basic") } - fn get_whitelist(&self) -> Vec { + fn get_whitelist(&mut self) -> Vec { unimplemented!("get_whitelist is not supported in Basic") } @@ -323,7 +324,7 @@ impl Externalities for BasicExternalities { unimplemented!("set_whitelist is not supported in Basic") } - fn get_read_and_written_keys(&self) -> Vec<(Vec, u32, u32, bool)> { + fn get_read_and_written_keys(&mut self) -> Vec<(Vec, u32, u32, bool)> { unimplemented!("get_read_and_written_keys is not supported in Basic") } } diff --git a/primitives/state-machine/src/ext.rs b/primitives/state-machine/src/ext.rs index 1db0ec517015b..93a0224b09f59 100644 --- a/primitives/state-machine/src/ext.rs +++ b/primitives/state-machine/src/ext.rs @@ -180,7 +180,7 @@ where self.overlay.set_offchain_storage(key, value) } - fn storage(&self, key: &[u8]) -> Option { + fn storage(&mut self, key: &[u8]) -> Option { let _guard = guard(); let result = self .overlay @@ -206,7 +206,7 @@ where result } - fn storage_hash(&self, key: &[u8]) -> Option> { + fn storage_hash(&mut self, key: &[u8]) -> Option> { let _guard = guard(); let result = self .overlay @@ -224,7 +224,7 @@ where result.map(|r| r.encode()) } - fn child_storage(&self, child_info: &ChildInfo, key: &[u8]) -> Option { + fn child_storage(&mut self, child_info: &ChildInfo, key: &[u8]) -> Option { let _guard = guard(); let result = self .overlay @@ -246,7 +246,7 @@ where result } - fn child_storage_hash(&self, child_info: &ChildInfo, key: &[u8]) -> Option> { + fn child_storage_hash(&mut self, child_info: &ChildInfo, key: &[u8]) -> Option> { let _guard = guard(); let result = self .overlay @@ -268,7 +268,7 @@ where result.map(|r| r.encode()) } - fn exists_storage(&self, key: &[u8]) -> bool { + fn exists_storage(&mut self, key: &[u8]) -> bool { let _guard = guard(); let result = match self.overlay.storage(key) { Some(x) => x.is_some(), @@ -286,7 +286,7 @@ where result } - fn exists_child_storage(&self, child_info: &ChildInfo, key: &[u8]) -> bool { + fn exists_child_storage(&mut self, child_info: &ChildInfo, key: &[u8]) -> bool { let _guard = guard(); let result = match self.overlay.child_storage(child_info, key) { @@ -308,7 +308,7 @@ where result } - fn next_storage_key(&self, key: &[u8]) -> Option { + fn next_storage_key(&mut self, key: &[u8]) -> Option { let mut next_backend_key = self.backend.next_storage_key(key).expect(EXT_NOT_ALLOWED_TO_FAIL); let mut overlay_changes = self.overlay.iter_after(key).peekable(); @@ -321,11 +321,11 @@ where // If `backend_key` is less than the `overlay_key`, we found out next key. if cmp == Some(Ordering::Less) { - return next_backend_key + return next_backend_key; } else if overlay_key.1.value().is_some() { // If there exists a value for the `overlay_key` in the overlay // (aka the key is still valid), it means we have found our next key. - return Some(overlay_key.0.to_vec()) + return Some(overlay_key.0.to_vec()); } else if cmp == Some(Ordering::Equal) { // If the `backend_key` and `overlay_key` are equal, it means that we need // to search for the next backend key, because the overlay has overwritten @@ -346,7 +346,7 @@ where } } - fn next_child_storage_key(&self, child_info: &ChildInfo, key: &[u8]) -> Option { + fn next_child_storage_key(&mut self, child_info: &ChildInfo, key: &[u8]) -> Option { let mut next_backend_key = self .backend .next_child_storage_key(child_info, key) @@ -362,11 +362,11 @@ where // If `backend_key` is less than the `overlay_key`, we found out next key. if cmp == Some(Ordering::Less) { - return next_backend_key + return next_backend_key; } else if overlay_key.1.value().is_some() { // If there exists a value for the `overlay_key` in the overlay // (aka the key is still valid), it means we have found our next key. - return Some(overlay_key.0.to_vec()) + return Some(overlay_key.0.to_vec()); } else if cmp == Some(Ordering::Equal) { // If the `backend_key` and `overlay_key` are equal, it means that we need // to search for the next backend key, because the overlay has overwritten @@ -391,7 +391,7 @@ where let _guard = guard(); if is_child_storage_key(&key) { warn!(target: "trie", "Refuse to directly set child storage key"); - return + return; } // NOTE: be careful about touching the key names – used outside substrate! @@ -472,7 +472,7 @@ where target: "trie", "Refuse to directly clear prefix that is part or contains of child storage key", ); - return MultiRemovalResults { maybe_cursor: None, backend: 0, unique: 0, loops: 0 } + return MultiRemovalResults { maybe_cursor: None, backend: 0, unique: 0, loops: 0 }; } self.mark_dirty(); @@ -538,7 +538,7 @@ where storage_root = %HexDisplay::from(&root.as_ref()), cached = true, ); - return root.encode() + return root.encode(); } let root = @@ -716,7 +716,7 @@ where .expect("We have reset the overlay above, so we can not be in the runtime; qed"); } - fn read_write_count(&self) -> (u32, u32, u32, u32) { + fn read_write_count(&mut self) -> (u32, u32, u32, u32) { self.backend.read_write_count() } @@ -724,7 +724,7 @@ where self.backend.reset_read_write_count() } - fn get_whitelist(&self) -> Vec { + fn get_whitelist(&mut self) -> Vec { self.backend.get_whitelist() } @@ -732,11 +732,11 @@ where self.backend.set_whitelist(new) } - fn proof_size(&self) -> Option { + fn proof_size(&mut self) -> Option { self.backend.proof_size() } - fn get_read_and_written_keys(&self) -> Vec<(Vec, u32, u32, bool)> { + fn get_read_and_written_keys(&mut self) -> Vec<(Vec, u32, u32, bool)> { self.backend.get_read_and_written_keys() } } @@ -761,7 +761,7 @@ where .apply_to_keys_while(maybe_child, maybe_prefix, maybe_cursor, |key| { if maybe_limit.map_or(false, |limit| loop_count == limit) { maybe_next_key = Some(key.to_vec()); - return false + return false; } let overlay = match maybe_child { Some(child_info) => self.overlay.child_storage(child_info, key), diff --git a/primitives/state-machine/src/lib.rs b/primitives/state-machine/src/lib.rs index 4126aea478d5b..363bd9896070b 100644 --- a/primitives/state-machine/src/lib.rs +++ b/primitives/state-machine/src/lib.rs @@ -242,8 +242,9 @@ mod execution { /// Gets the corresponding manager for the execution strategy. pub fn get_manager(self) -> ExecutionManager> { match self { - ExecutionStrategy::AlwaysWasm => - ExecutionManager::AlwaysWasm(BackendTrustLevel::Trusted), + ExecutionStrategy::AlwaysWasm => { + ExecutionManager::AlwaysWasm(BackendTrustLevel::Trusted) + }, ExecutionStrategy::NativeWhenPossible => ExecutionManager::NativeWhenPossible, ExecutionStrategy::NativeElseWasm => ExecutionManager::NativeElseWasm, ExecutionStrategy::Both => ExecutionManager::Both(|wasm_result, native_result| { @@ -440,9 +441,10 @@ mod execution { self.overlay.rollback_transaction().expect(PROOF_CLOSE_TRANSACTION); let (wasm_result, _) = self.execute_aux(false); - if (result.is_ok() && - wasm_result.is_ok() && result.as_ref().ok() == wasm_result.as_ref().ok()) || - result.is_err() && wasm_result.is_err() + if (result.is_ok() + && wasm_result.is_ok() + && result.as_ref().ok() == wasm_result.as_ref().ok()) + || result.is_err() && wasm_result.is_err() { result } else { @@ -486,15 +488,18 @@ mod execution { { let result = { match manager { - ExecutionManager::Both(on_consensus_failure) => - self.execute_call_with_both_strategy(on_consensus_failure), - ExecutionManager::NativeElseWasm => - self.execute_call_with_native_else_wasm_strategy(), + ExecutionManager::Both(on_consensus_failure) => { + self.execute_call_with_both_strategy(on_consensus_failure) + }, + ExecutionManager::NativeElseWasm => { + self.execute_call_with_native_else_wasm_strategy() + }, ExecutionManager::AlwaysWasm(trust_level) => { let _abort_guard = match trust_level { BackendTrustLevel::Trusted => None, - BackendTrustLevel::Untrusted => - Some(sp_panic_handler::AbortGuard::never_abort()), + BackendTrustLevel::Untrusted => { + Some(sp_panic_handler::AbortGuard::never_abort()) + }, }; self.execute_aux(false).0 }, @@ -523,7 +528,7 @@ mod execution { Exec: CodeExecutor + Clone + 'static, Spawn: SpawnNamed + Send + 'static, { - let trie_backend = backend.as_trie_backend(); + let trie_backend = backend.as_trie_backend_mut(); prove_execution_on_trie_backend::<_, _, _, _>( trie_backend, overlay, @@ -545,7 +550,7 @@ mod execution { /// Note: changes to code will be in place if this call is made again. For running partial /// blocks (e.g. a transaction at a time), ensure a different method is used. pub fn prove_execution_on_trie_backend( - trie_backend: &TrieBackend, + trie_backend: &mut TrieBackend, overlay: &mut OverlayedChanges, exec: &Exec, spawn_handle: Spawn, @@ -649,7 +654,7 @@ mod execution { I: IntoIterator, I::Item: AsRef<[u8]>, { - let trie_backend = backend.as_trie_backend(); + let trie_backend = backend.as_trie_backend_mut(); prove_read_on_trie_backend(trie_backend, keys) } @@ -705,7 +710,7 @@ mod execution { last: &mut SmallVec<[Vec; 2]>, ) -> bool { if stopped_at == 0 || stopped_at > MAX_NESTED_TRIE_DEPTH { - return false + return false; } match stopped_at { 1 => { @@ -715,7 +720,7 @@ mod execution { match last.len() { 0 => { last.push(top_last); - return true + return true; }, 2 => { last.pop(); @@ -724,12 +729,12 @@ mod execution { } // update top trie access. last[0] = top_last; - return true + return true; } else { // No change in top trie accesses. // Indicates end of reading of a child trie. last.truncate(1); - return true + return true; } }, 2 => { @@ -743,7 +748,7 @@ mod execution { if let Some(top_last) = top_last { last.push(top_last) } else { - return false + return false; } } else if let Some(top_last) = top_last { last[0] = top_last; @@ -752,10 +757,10 @@ mod execution { last.pop(); } last.push(child_last); - return true + return true; } else { // stopped at level 2 so child last is define. - return false + return false; } }, _ => (), @@ -781,7 +786,7 @@ mod execution { H: Hasher, H::Out: Ord + Codec, { - let trie_backend = backend.as_trie_backend(); + let trie_backend = backend.as_trie_backend_mut(); prove_range_read_with_child_with_size_on_trie_backend(trie_backend, size_limit, start_at) } @@ -789,7 +794,7 @@ mod execution { /// content. /// See `prove_range_read_with_child_with_size`. pub fn prove_range_read_with_child_with_size_on_trie_backend( - trie_backend: &TrieBackend, + trie_backend: &mut TrieBackend, size_limit: usize, start_at: &[Vec], ) -> Result<(StorageProof, u32), Box> @@ -799,7 +804,7 @@ mod execution { H::Out: Ord + Codec, { if start_at.len() > MAX_NESTED_TRIE_DEPTH { - return Err(Box::new("Invalid start of range.")) + return Err(Box::new("Invalid start of range.")); } let recorder = sp_trie::recorder::Recorder::default(); @@ -816,7 +821,7 @@ mod execution { { child_roots.insert(state_root); } else { - return Err(Box::new("Invalid range start child trie key.")) + return Err(Box::new("Invalid range start child trie key.")); } (Some(storage_key), start_at.get(1).cloned()) @@ -829,8 +834,9 @@ mod execution { let storage_key = PrefixedStorageKey::new_ref(storage_key); ( Some(match ChildType::from_prefixed_key(storage_key) { - Some((ChildType::ParentKeyId, storage_key)) => - ChildInfo::new_default(storage_key), + Some((ChildType::ParentKeyId, storage_key)) => { + ChildInfo::new_default(storage_key) + }, None => return Err(Box::new("Invalid range start child trie key.")), }), 2, @@ -848,8 +854,8 @@ mod execution { None, start_at_ref, |key, value| { - if first && - start_at_ref + if first + && start_at_ref .as_ref() .map(|start| &key.as_slice() > start) .unwrap_or(true) @@ -859,8 +865,8 @@ mod execution { if first { true - } else if depth < MAX_NESTED_TRIE_DEPTH && - sp_core::storage::well_known_keys::is_child_storage_key( + } else if depth < MAX_NESTED_TRIE_DEPTH + && sp_core::storage::well_known_keys::is_child_storage_key( key.as_slice(), ) { count += 1; @@ -885,11 +891,11 @@ mod execution { if switch_child_key.is_none() { if depth == 1 { - break + break; } else if completed { start_at = child_key.take(); } else { - break + break; } } else { child_key = switch_child_key; @@ -916,7 +922,7 @@ mod execution { H: Hasher, H::Out: Ord + Codec, { - let trie_backend = backend.as_trie_backend(); + let trie_backend = backend.as_trie_backend_mut(); prove_range_read_with_size_on_trie_backend( trie_backend, child_info, @@ -928,7 +934,7 @@ mod execution { /// Generate range storage read proof on an existing trie backend. pub fn prove_range_read_with_size_on_trie_backend( - trie_backend: &TrieBackend, + trie_backend: &mut TrieBackend, child_info: Option<&ChildInfo>, prefix: Option<&[u8]>, size_limit: usize, @@ -979,13 +985,13 @@ mod execution { I: IntoIterator, I::Item: AsRef<[u8]>, { - let trie_backend = backend.as_trie_backend(); + let trie_backend = backend.as_trie_backend_mut(); prove_child_read_on_trie_backend(trie_backend, child_info, keys) } /// Generate storage read proof on pre-created trie backend. pub fn prove_read_on_trie_backend( - trie_backend: &TrieBackend, + trie_backend: &mut TrieBackend, keys: I, ) -> Result> where @@ -1010,7 +1016,7 @@ mod execution { /// Generate storage read proof on pre-created trie backend. pub fn prove_child_read_on_trie_backend( - trie_backend: &TrieBackend, + trie_backend: &mut TrieBackend, child_info: &ChildInfo, keys: I, ) -> Result> @@ -1198,7 +1204,7 @@ mod execution { parent_storage_keys: Default::default(), }]; if start_at.len() > MAX_NESTED_TRIE_DEPTH { - return Err(Box::new("Invalid start of range.")) + return Err(Box::new("Invalid start of range.")); } let mut child_roots = HashSet::new(); @@ -1211,7 +1217,7 @@ mod execution { child_roots.insert(state_root.clone()); Some((storage_key, state_root)) } else { - return Err(Box::new("Invalid range start child trie key.")) + return Err(Box::new("Invalid range start child trie key.")); }; (child_key, start_at.get(1).cloned()) @@ -1230,8 +1236,9 @@ mod execution { let storage_key = PrefixedStorageKey::new_ref(storage_key); ( Some(match ChildType::from_prefixed_key(storage_key) { - Some((ChildType::ParentKeyId, storage_key)) => - ChildInfo::new_default(storage_key), + Some((ChildType::ParentKeyId, storage_key)) => { + ChildInfo::new_default(storage_key) + }, None => return Err(Box::new("Invalid range start child trie key.")), }), 2, @@ -1254,8 +1261,8 @@ mod execution { None, start_at_ref, |key, value| { - if first && - start_at_ref + if first + && start_at_ref .as_ref() .map(|start| &key.as_slice() > start) .unwrap_or(true) @@ -1268,8 +1275,8 @@ mod execution { } if first { true - } else if depth < MAX_NESTED_TRIE_DEPTH && - sp_core::storage::well_known_keys::is_child_storage_key( + } else if depth < MAX_NESTED_TRIE_DEPTH + && sp_core::storage::well_known_keys::is_child_storage_key( key.as_slice(), ) { if child_roots.contains(value.as_slice()) { @@ -1290,10 +1297,10 @@ mod execution { if switch_child_key.is_none() { if !completed { - break depth + break depth; } if depth == 1 { - break 0 + break 0; } else { start_at = child_key.take().map(|entry| entry.0); } @@ -1903,7 +1910,7 @@ mod tests { key.clone(), Some(value.clone()), )); - break + break; } } } @@ -2064,7 +2071,7 @@ mod tests { .unwrap(); if completed_depth == 0 { - break + break; } assert!(result.update_last_key(completed_depth, &mut start_at)); } diff --git a/primitives/state-machine/src/read_only.rs b/primitives/state-machine/src/read_only.rs index e58fb760f4d7e..0851bf902b9f3 100644 --- a/primitives/state-machine/src/read_only.rs +++ b/primitives/state-machine/src/read_only.rs @@ -88,39 +88,39 @@ where panic!("Should not be used in read-only externalities!") } - fn storage(&self, key: &[u8]) -> Option { + fn storage(&mut self, key: &[u8]) -> Option { self.backend .storage(key) .expect("Backed failed for storage in ReadOnlyExternalities") } - fn storage_hash(&self, key: &[u8]) -> Option> { + fn storage_hash(&mut self, key: &[u8]) -> Option> { self.backend .storage_hash(key) .expect("Backed failed for storage_hash in ReadOnlyExternalities") .map(|h| h.encode()) } - fn child_storage(&self, child_info: &ChildInfo, key: &[u8]) -> Option { + fn child_storage(&mut self, child_info: &ChildInfo, key: &[u8]) -> Option { self.backend .child_storage(child_info, key) .expect("Backed failed for child_storage in ReadOnlyExternalities") } - fn child_storage_hash(&self, child_info: &ChildInfo, key: &[u8]) -> Option> { + fn child_storage_hash(&mut self, child_info: &ChildInfo, key: &[u8]) -> Option> { self.backend .child_storage_hash(child_info, key) .expect("Backed failed for child_storage_hash in ReadOnlyExternalities") .map(|h| h.encode()) } - fn next_storage_key(&self, key: &[u8]) -> Option { + fn next_storage_key(&mut self, key: &[u8]) -> Option { self.backend .next_storage_key(key) .expect("Backed failed for next_storage_key in ReadOnlyExternalities") } - fn next_child_storage_key(&self, child_info: &ChildInfo, key: &[u8]) -> Option { + fn next_child_storage_key(&mut self, child_info: &ChildInfo, key: &[u8]) -> Option { self.backend .next_child_storage_key(child_info, key) .expect("Backed failed for next_child_storage_key in ReadOnlyExternalities") @@ -199,7 +199,7 @@ where fn commit(&mut self) {} - fn read_write_count(&self) -> (u32, u32, u32, u32) { + fn read_write_count(&mut self) -> (u32, u32, u32, u32) { unimplemented!("read_write_count is not supported in ReadOnlyExternalities") } @@ -207,7 +207,7 @@ where unimplemented!("reset_read_write_count is not supported in ReadOnlyExternalities") } - fn get_whitelist(&self) -> Vec { + fn get_whitelist(&mut self) -> Vec { unimplemented!("get_whitelist is not supported in ReadOnlyExternalities") } @@ -215,7 +215,7 @@ where unimplemented!("set_whitelist is not supported in ReadOnlyExternalities") } - fn get_read_and_written_keys(&self) -> Vec<(Vec, u32, u32, bool)> { + fn get_read_and_written_keys(&mut self) -> Vec<(Vec, u32, u32, bool)> { unimplemented!("get_read_and_written_keys is not supported in ReadOnlyExternalities") } } diff --git a/primitives/state-machine/src/testing.rs b/primitives/state-machine/src/testing.rs index e94d34b5560cd..53699a39b2612 100644 --- a/primitives/state-machine/src/testing.rs +++ b/primitives/state-machine/src/testing.rs @@ -204,7 +204,7 @@ where /// This implementation will wipe the proof recorded in between calls. Consecutive calls will /// get their own proof from scratch. pub fn execute_and_prove(&mut self, execute: impl FnOnce() -> R) -> (R, StorageProof) { - let proving_backend = TrieBackendBuilder::wrap(&self.backend) + let proving_backend = TrieBackendBuilder::wrap(&mut self.backend) .with_recorder(Default::default()) .build(); let mut proving_ext = Ext::new( diff --git a/primitives/state-machine/src/trie_backend.rs b/primitives/state-machine/src/trie_backend.rs index 447c276a6049c..727b963f06a99 100644 --- a/primitives/state-machine/src/trie_backend.rs +++ b/primitives/state-machine/src/trie_backend.rs @@ -47,6 +47,9 @@ pub trait AsLocalTrieCache: sealed::Sealed { /// Returns `self` as [`LocalTrieCache`]. #[cfg(feature = "std")] fn as_local_trie_cache(&self) -> &LocalTrieCache; + + #[cfg(feature = "std")] + fn as_local_trie_cache_mut(&mut self) -> &mut LocalTrieCache; } impl AsLocalTrieCache for LocalTrieCache { @@ -54,13 +57,21 @@ impl AsLocalTrieCache for LocalTrieCache { fn as_local_trie_cache(&self) -> &LocalTrieCache { self } + + fn as_local_trie_cache_mut(&mut self) -> &mut LocalTrieCache { + self + } } #[cfg(feature = "std")] -impl AsLocalTrieCache for &LocalTrieCache { +impl AsLocalTrieCache for &mut LocalTrieCache { fn as_local_trie_cache(&self) -> &LocalTrieCache { self } + + fn as_local_trie_cache_mut(&mut self) -> &mut LocalTrieCache { + self + } } /// Special module that contains the `Sealed` trait. @@ -72,6 +83,7 @@ mod sealed { pub trait Sealed {} impl Sealed for LocalTrieCache {} + impl Sealed for &mut LocalTrieCache {} impl Sealed for &LocalTrieCache {} } @@ -113,14 +125,17 @@ where /// backend. /// /// The backend storage and the cache will be taken from `other`. - pub fn wrap(other: &TrieBackend) -> TrieBackendBuilder<&S, H, &C> { + pub fn wrap(other: &mut TrieBackend) -> TrieBackendBuilder<&S, H, &mut C> { + let cache = other.essence.trie_node_cache.as_mut(); + let root = other.essence.root(); + let storage = other.essence.backend_storage_mut(); TrieBackendBuilder { - storage: other.essence.backend_storage(), - root: *other.essence.root(), + storage, + root, #[cfg(feature = "std")] recorder: None, #[cfg(feature = "std")] - cache: other.essence.trie_node_cache.as_ref(), + cache, #[cfg(not(feature = "std"))] cache: None, } @@ -361,6 +376,10 @@ impl, H: Hasher, C> AsTrieBackend for TrieBackend fn as_trie_backend(&self) -> &TrieBackend { self } + + fn as_trie_backend_mut(&mut self) -> &mut TrieBackend { + self + } } /// Create a backend used for checking the proof, using `H` as hasher. @@ -619,8 +638,8 @@ pub mod tests { .storage_root(iter::once((&b"new-key"[..], Some(&b"new-value"[..]))), state_version); assert!(!tx.drain().is_empty()); assert!( - new_root != - test_trie(state_version, None, None) + new_root + != test_trie(state_version, None, None) .storage_root(iter::empty(), state_version) .0 ); diff --git a/primitives/state-machine/src/trie_backend_essence.rs b/primitives/state-machine/src/trie_backend_essence.rs index cd2a71163e2ee..a270ac64598b9 100644 --- a/primitives/state-machine/src/trie_backend_essence.rs +++ b/primitives/state-machine/src/trie_backend_essence.rs @@ -138,8 +138,8 @@ impl, H: Hasher, C> TrieBackendEssence { } /// Get trie root. - pub fn root(&self) -> &H::Out { - &self.root + pub fn root(&self) -> H::Out { + self.root } /// Set trie root. This is useful for testing. @@ -224,13 +224,13 @@ impl, H: Hasher, C: AsLocalTrieCache> TrieBackendEss None => None, }; - let result = if let Some(local_cache) = self.trie_node_cache.as_ref() { + let result = if let Some(mut local_cache) = self.trie_node_cache.as_ref() { let mut cache = local_cache.as_local_trie_cache().as_trie_db_mut_cache(); let (new_root, r) = callback(recorder, Some(&mut cache)); if let Some(new_root) = new_root { - cache.merge_into(local_cache.as_local_trie_cache(), new_root); + cache.merge_into(local_cache.as_local_trie_cache_mut(), new_root); } r @@ -269,7 +269,7 @@ where #[cfg(feature = "std")] { if let Some(result) = self.cache.read().child_root.get(child_info.storage_key()) { - return Ok(*result) + return Ok(*result); } } @@ -465,7 +465,7 @@ where Ok(None) => return, Err(e) => { debug!(target: "trie", "Error while iterating child storage: {}", e); - return + return; }, } } else { @@ -488,7 +488,7 @@ where Ok(None) => return, Err(e) => { debug!(target: "trie", "Error while iterating child storage: {}", e); - return + return; }, }; @@ -534,8 +534,9 @@ where .build(); let prefix = maybe_prefix.unwrap_or(&[]); let iter = match maybe_start_at { - Some(start_at) => - TrieDBKeyIterator::new_prefixed_then_seek(&trie, prefix, start_at), + Some(start_at) => { + TrieDBKeyIterator::new_prefixed_then_seek(&trie, prefix, start_at) + }, None => TrieDBKeyIterator::new_prefixed(&trie, prefix), }?; @@ -548,7 +549,7 @@ where .unwrap_or(true)); if !f(&key) { - break + break; } } @@ -595,7 +596,7 @@ where debug_assert!(key.starts_with(prefix)); if !f(key, value) { - return Ok(false) + return Ok(false); } } @@ -611,8 +612,9 @@ where }; match result { Ok(completed) => Ok(completed), - Err(e) if matches!(*e, TrieError::IncompleteDatabase(_)) && allow_missing_nodes => - Ok(false), + Err(e) if matches!(*e, TrieError::IncompleteDatabase(_)) && allow_missing_nodes => { + Ok(false) + }, Err(e) => Err(format!("TrieDB iteration error: {}", e)), } } @@ -722,7 +724,7 @@ where let new_child_root = self.with_recorder_and_cache_for_storage_root(|recorder, cache| { let mut eph = Ephemeral::new(self.backend_storage(), &mut write_overlay); match match state_version { - StateVersion::V0 => + StateVersion::V0 => { child_delta_trie_root::, _, _, _, _, _, _>( child_info.keyspace(), &mut eph, @@ -730,8 +732,9 @@ where delta, recorder, cache, - ), - StateVersion::V1 => + ) + }, + StateVersion::V1 => { child_delta_trie_root::, _, _, _, _, _, _>( child_info.keyspace(), &mut eph, @@ -739,7 +742,8 @@ where delta, recorder, cache, - ), + ) + }, } { Ok(ret) => (Some(ret), ret), Err(e) => { @@ -871,7 +875,7 @@ impl, H: Hasher, C: AsLocalTrieCache + Send + Sync> { fn get(&self, key: &H::Out, prefix: Prefix) -> Option { if *key == self.empty { - return Some([0u8].to_vec()) + return Some([0u8].to_vec()); } match self.storage.get(key, prefix) { Ok(x) => x, diff --git a/primitives/trie/src/cache/mod.rs b/primitives/trie/src/cache/mod.rs index f6a447763a80e..69e46ff1f21cc 100644 --- a/primitives/trie/src/cache/mod.rs +++ b/primitives/trie/src/cache/mod.rs @@ -38,7 +38,7 @@ use crate::{Error, NodeCodec}; use hash_db::Hasher; use hashbrown::HashSet; use nohash_hasher::BuildNoHashHasher; -use parking_lot::{Mutex, MutexGuard, RwLockReadGuard}; +use parking_lot::RwLockReadGuard; use shared_cache::{SharedValueCache, ValueCacheKey}; use std::{ collections::{hash_map::Entry as MapEntry, HashMap}, @@ -87,19 +87,17 @@ pub struct LocalTrieCache { /// The shared trie cache that created this instance. shared: SharedTrieCache, /// The local cache for the trie nodes. - node_cache: Mutex>>, + node_cache: HashMap>, /// Keeps track of all the trie nodes accessed in the shared cache. /// /// This will be used to ensure that these nodes are brought to the front of the lru when this /// local instance is merged back to the shared cache. - shared_node_cache_access: Mutex>, + shared_node_cache_access: HashSet, /// The local cache for the values. - value_cache: Mutex< - HashMap< - ValueCacheKey<'static, H::Out>, - CachedValue, - BuildNoHashHasher>, - >, + value_cache: HashMap< + ValueCacheKey<'static, H::Out>, + CachedValue, + BuildNoHashHasher>, >, /// Keeps track of all values accessed in the shared cache. /// @@ -109,28 +107,27 @@ pub struct LocalTrieCache { /// as we only use this set to update the lru position it is fine, even if we bring the wrong /// value to the top. The important part is that we always get the correct value from the value /// cache for a given key. - shared_value_cache_access: - Mutex>>, + shared_value_cache_access: HashSet>, } impl LocalTrieCache { /// Return self as a [`TrieDB`](trie_db::TrieDB) compatible cache. /// /// The given `storage_root` needs to be the storage root of the trie this cache is used for. - pub fn as_trie_db_cache(&self, storage_root: H::Out) -> TrieCache<'_, H> { + pub fn as_trie_db_cache(&mut self, storage_root: H::Out) -> TrieCache { let shared_inner = self.shared.read_lock_inner(); let value_cache = ValueCache::ForStorageRoot { storage_root, - local_value_cache: self.value_cache.lock(), - shared_value_cache_access: self.shared_value_cache_access.lock(), + local_value_cache: &mut self.value_cache, + shared_value_cache_access: &mut self.shared_value_cache_access, }; TrieCache { shared_inner, - local_cache: self.node_cache.lock(), + local_cache: &mut self.node_cache, value_cache, - shared_node_cache_access: self.shared_node_cache_access.lock(), + shared_node_cache_access: &mut self.shared_node_cache_access, } } @@ -141,12 +138,12 @@ impl LocalTrieCache { /// cache instance. If the function is not called, cached data is just thrown away and not /// propagated to the shared cache. So, accessing these new items will be slower, but nothing /// would break because of this. - pub fn as_trie_db_mut_cache(&self) -> TrieCache<'_, H> { + pub fn as_trie_db_mut_cache(&mut self) -> TrieCache { TrieCache { shared_inner: self.shared.read_lock_inner(), - local_cache: self.node_cache.lock(), + local_cache: &mut self.node_cache, value_cache: ValueCache::Fresh(Default::default()), - shared_node_cache_access: self.shared_node_cache_access.lock(), + shared_node_cache_access: &mut self.shared_node_cache_access, } } } @@ -157,11 +154,11 @@ impl Drop for LocalTrieCache { shared_inner .node_cache_mut() - .update(self.node_cache.lock().drain(), self.shared_node_cache_access.lock().drain()); + .update(self.node_cache.drain(), self.shared_node_cache_access.drain()); shared_inner .value_cache_mut() - .update(self.value_cache.lock().drain(), self.shared_value_cache_access.lock().drain()); + .update(self.value_cache.drain(), self.shared_value_cache_access.drain()); } } @@ -172,17 +169,12 @@ enum ValueCache<'a, H> { Fresh(HashMap, CachedValue>), /// The value cache is already bound to a specific storage root. ForStorageRoot { - shared_value_cache_access: MutexGuard< - 'a, - HashSet>, - >, - local_value_cache: MutexGuard< - 'a, - HashMap< - ValueCacheKey<'static, H>, - CachedValue, - nohash_hasher::BuildNoHashHasher>, - >, + shared_value_cache_access: + &'a mut HashSet>, + local_value_cache: &'a mut HashMap< + ValueCacheKey<'static, H>, + CachedValue, + nohash_hasher::BuildNoHashHasher>, >, storage_root: H, }, @@ -248,8 +240,8 @@ impl + std::hash::Hash + Eq + Clone + Copy> ValueCache<'_, H> { /// done. pub struct TrieCache<'a, H: Hasher> { shared_inner: RwLockReadGuard<'a, SharedTrieCacheInner>, - shared_node_cache_access: MutexGuard<'a, HashSet>, - local_cache: MutexGuard<'a, HashMap>>, + shared_node_cache_access: &'a mut HashSet, + local_cache: &'a mut HashMap>, value_cache: ValueCache<'a, H::Out>, } @@ -260,11 +252,11 @@ impl<'a, H: Hasher> TrieCache<'a, H> { /// [`LocalTrieCache::as_trie_db_mut_cache`], otherwise this method is a no-op. The given /// `storage_root` is the new storage root that was obtained after finishing all operations /// using the [`TrieDBMut`](trie_db::TrieDBMut). - pub fn merge_into(self, local: &LocalTrieCache, storage_root: H::Out) { + pub fn merge_into(self, local: &mut LocalTrieCache, storage_root: H::Out) { let cache = if let ValueCache::Fresh(cache) = self.value_cache { cache } else { return }; if !cache.is_empty() { - let mut value_cache = local.value_cache.lock(); + let mut value_cache = &mut local.value_cache; let partial_hash = ValueCacheKey::hash_partial_data(&storage_root); cache @@ -290,7 +282,7 @@ impl<'a, H: Hasher> trie_db::TrieCache> for TrieCache<'a, H> { if let Some(res) = self.shared_inner.node_cache().get(&hash) { tracing::trace!(target: LOG_TARGET, ?hash, "Serving node from shared cache"); self.shared_node_cache_access.insert(hash); - return Ok(res) + return Ok(res); } match self.local_cache.entry(hash) { @@ -317,7 +309,7 @@ impl<'a, H: Hasher> trie_db::TrieCache> for TrieCache<'a, H> { if let Some(node) = self.shared_inner.node_cache().get(hash) { tracing::trace!(target: LOG_TARGET, ?hash, "Getting node from shared cache"); self.shared_node_cache_access.insert(*hash); - return Some(node) + return Some(node); } let res = self.local_cache.get(hash); diff --git a/primitives/trie/src/cache/shared_cache.rs b/primitives/trie/src/cache/shared_cache.rs index abac8c9f946ca..d224f6da7aacd 100644 --- a/primitives/trie/src/cache/shared_cache.rs +++ b/primitives/trie/src/cache/shared_cache.rs @@ -287,10 +287,11 @@ impl PartialEq for ValueCacheKey<'_, H> { (Self::Hash { hash, .. }, _) => *hash == other.get_hash(), (_, Self::Hash { hash: other_hash, .. }) => self.get_hash() == *other_hash, // If both are not the `Hash` variant, we compare all the values. - _ => - self.get_hash() == other.get_hash() && - self.storage_root() == other.storage_root() && - self.storage_key() == other.storage_key(), + _ => { + self.get_hash() == other.get_hash() + && self.storage_root() == other.storage_root() + && self.storage_key() == other.storage_key() + }, } } } @@ -405,12 +406,14 @@ impl> SharedValueCache { "`SharedValueCached::update` was called with a key to add \ that uses the `Hash` variant. This would lead to potential hash collision!", ); - return + return; + }, + ValueCacheKey::Ref { storage_key, storage_root, hash } => { + (storage_root, storage_key.into(), hash) + }, + ValueCacheKey::Value { storage_root, storage_key, hash } => { + (storage_root, storage_key, hash) }, - ValueCacheKey::Ref { storage_key, storage_root, hash } => - (storage_root, storage_key.into(), hash), - ValueCacheKey::Value { storage_root, storage_key, hash } => - (storage_root, storage_key, hash), }; let (size_update, storage_key) = From 486b98fa7ebfd4677584fca64243b9364148be76 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 3 Oct 2022 04:24:05 +0000 Subject: [PATCH 2/2] Bump lru from 0.7.5 to 0.8.1 Bumps [lru](https://github.com/jeromefroe/lru-rs) from 0.7.5 to 0.8.1. - [Release notes](https://github.com/jeromefroe/lru-rs/releases) - [Changelog](https://github.com/jeromefroe/lru-rs/blob/master/CHANGELOG.md) - [Commits](https://github.com/jeromefroe/lru-rs/compare/0.7.5...0.8.1) --- updated-dependencies: - dependency-name: lru dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- Cargo.lock | 29 +++++++++++++++++++---------- client/executor/Cargo.toml | 2 +- client/network-gossip/Cargo.toml | 2 +- client/network/Cargo.toml | 2 +- client/network/sync/Cargo.toml | 2 +- primitives/blockchain/Cargo.toml | 2 +- primitives/trie/Cargo.toml | 2 +- 7 files changed, 25 insertions(+), 16 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index a9a0eef551179..0ec4d1e755a81 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3730,7 +3730,7 @@ dependencies = [ "libp2p-core", "libp2p-swarm", "log", - "lru", + "lru 0.7.8", "prost 0.10.3", "prost-build 0.10.4", "prost-codec", @@ -4229,11 +4229,20 @@ dependencies = [ [[package]] name = "lru" -version = "0.7.5" +version = "0.7.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "32613e41de4c47ab04970c348ca7ae7382cf116625755af070b008a15516a889" +checksum = "e999beba7b6e8345721bd280141ed958096a2e4abdf74f67ff4ce49b4b54e47a" dependencies = [ - "hashbrown 0.11.2", + "hashbrown 0.12.3", +] + +[[package]] +name = "lru" +version = "0.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b6e8aaa3f231bb4bd57b84b2d5dc3ae7f350265df8aa96492e0bc394a1571909" +dependencies = [ + "hashbrown 0.12.3", ] [[package]] @@ -8269,7 +8278,7 @@ dependencies = [ "criterion", "env_logger", "lazy_static", - "lru", + "lru 0.8.1", "num_cpus", "parity-scale-codec", "parking_lot 0.12.1", @@ -8482,7 +8491,7 @@ dependencies = [ "linked-hash-map", "linked_hash_set", "log", - "lru", + "lru 0.8.1", "parity-scale-codec", "parking_lot 0.12.1", "pin-project", @@ -8576,7 +8585,7 @@ dependencies = [ "futures-timer", "libp2p", "log", - "lru", + "lru 0.8.1", "quickcheck", "sc-network-common", "sc-peerset", @@ -8615,7 +8624,7 @@ dependencies = [ "futures", "libp2p", "log", - "lru", + "lru 0.8.1", "parity-scale-codec", "prost 0.10.3", "prost-build 0.10.4", @@ -9695,7 +9704,7 @@ version = "4.0.0-dev" dependencies = [ "futures", "log", - "lru", + "lru 0.8.1", "parity-scale-codec", "parking_lot 0.12.1", "sp-api", @@ -10335,7 +10344,7 @@ dependencies = [ "hash-db", "hashbrown 0.12.3", "lazy_static", - "lru", + "lru 0.8.1", "memory-db", "nohash-hasher", "parity-scale-codec", diff --git a/client/executor/Cargo.toml b/client/executor/Cargo.toml index 264db0e89b1c8..122db11dd4a09 100644 --- a/client/executor/Cargo.toml +++ b/client/executor/Cargo.toml @@ -15,7 +15,7 @@ targets = ["x86_64-unknown-linux-gnu"] [dependencies] lazy_static = "1.4.0" -lru = "0.7.5" +lru = "0.8.1" parking_lot = "0.12.1" tracing = "0.1.29" wasmi = "0.13" diff --git a/client/network-gossip/Cargo.toml b/client/network-gossip/Cargo.toml index 8ecf2b9cec787..0c79375418ca0 100644 --- a/client/network-gossip/Cargo.toml +++ b/client/network-gossip/Cargo.toml @@ -19,7 +19,7 @@ futures = "0.3.21" futures-timer = "3.0.1" libp2p = { version = "0.46.1", default-features = false } log = "0.4.17" -lru = "0.7.5" +lru = "0.8.1" tracing = "0.1.29" prometheus-endpoint = { package = "substrate-prometheus-endpoint", version = "0.10.0-dev", path = "../../utils/prometheus" } sc-network-common = { version = "0.10.0-dev", path = "../network/common" } diff --git a/client/network/Cargo.toml b/client/network/Cargo.toml index e96749df40aa2..fceb250f27aae 100644 --- a/client/network/Cargo.toml +++ b/client/network/Cargo.toml @@ -30,7 +30,7 @@ libp2p = "0.46.1" linked_hash_set = "0.1.3" linked-hash-map = "0.5.4" log = "0.4.17" -lru = "0.7.5" +lru = "0.8.1" parking_lot = "0.12.1" pin-project = "1.0.10" prost = "0.10" diff --git a/client/network/sync/Cargo.toml b/client/network/sync/Cargo.toml index 269214aeff3f7..d82cbae87fb9f 100644 --- a/client/network/sync/Cargo.toml +++ b/client/network/sync/Cargo.toml @@ -24,7 +24,7 @@ codec = { package = "parity-scale-codec", version = "3.0.0", features = [ futures = "0.3.21" libp2p = "0.46.1" log = "0.4.17" -lru = "0.7.5" +lru = "0.8.1" prost = "0.10" smallvec = "1.8.0" thiserror = "1.0" diff --git a/primitives/blockchain/Cargo.toml b/primitives/blockchain/Cargo.toml index 4d4718b4038d4..454bc4d7c1103 100644 --- a/primitives/blockchain/Cargo.toml +++ b/primitives/blockchain/Cargo.toml @@ -17,7 +17,7 @@ targets = ["x86_64-unknown-linux-gnu"] codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false, features = ["derive"] } futures = "0.3.21" log = "0.4.17" -lru = "0.7.5" +lru = "0.8.1" parking_lot = "0.12.1" thiserror = "1.0.30" sp-api = { version = "4.0.0-dev", path = "../api" } diff --git a/primitives/trie/Cargo.toml b/primitives/trie/Cargo.toml index 6d2d57b590e6a..1accb4b125dde 100644 --- a/primitives/trie/Cargo.toml +++ b/primitives/trie/Cargo.toml @@ -23,7 +23,7 @@ codec = { package = "parity-scale-codec", version = "3.0.0", default-features = hashbrown = { version = "0.12.3", optional = true } hash-db = { version = "0.15.2", default-features = false } lazy_static = { version = "1.4.0", optional = true } -lru = { version = "0.7.5", optional = true } +lru = { version = "0.8.1", optional = true } memory-db = { version = "0.29.0", default-features = false } nohash-hasher = { version = "0.2.0", optional = true } parking_lot = { version = "0.12.1", optional = true }