Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bump lru from 0.7.5 to 0.8.1 #6

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 19 additions & 10 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion client/executor/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion client/network-gossip/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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" }
Expand Down
2 changes: 1 addition & 1 deletion client/network/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion client/network/sync/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion primitives/blockchain/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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" }
Expand Down
24 changes: 12 additions & 12 deletions primitives/externalities/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<Vec<u8>>;
fn storage(&mut self, key: &[u8]) -> Option<Vec<u8>>;

/// Get storage value hash.
///
/// This may be optimized for large values.
fn storage_hash(&self, key: &[u8]) -> Option<Vec<u8>>;
fn storage_hash(&mut self, key: &[u8]) -> Option<Vec<u8>>;

/// 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<Vec<u8>>;
fn child_storage_hash(&mut self, child_info: &ChildInfo, key: &[u8]) -> Option<Vec<u8>>;

/// Read child runtime storage.
///
/// Returns an `Option` that holds the SCALE encoded hash.
fn child_storage(&self, child_info: &ChildInfo, key: &[u8]) -> Option<Vec<u8>>;
fn child_storage(&mut self, child_info: &ChildInfo, key: &[u8]) -> Option<Vec<u8>>;

/// Set storage entry `key` of current contract being called (effective immediately).
fn set_storage(&mut self, key: Vec<u8>, value: Vec<u8>) {
Expand All @@ -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<Vec<u8>>;
fn next_storage_key(&mut self, key: &[u8]) -> Option<Vec<u8>>;

/// 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<Vec<u8>>;
fn next_child_storage_key(&mut self, child_info: &ChildInfo, key: &[u8]) -> Option<Vec<u8>>;

/// Clear an entire child storage.
///
Expand Down Expand Up @@ -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!
Expand All @@ -284,7 +284,7 @@ pub trait Externalities: ExtensionStore {
/// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
///
/// Gets the current DB tracking whitelist.
fn get_whitelist(&self) -> Vec<TrackedStorageKey>;
fn get_whitelist(&mut self) -> Vec<TrackedStorageKey>;

/// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
/// Benchmarking related functionality and shouldn't be used anywhere else!
Expand All @@ -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<u32> {
fn proof_size(&mut self) -> Option<u32> {
None
}

Expand All @@ -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<u8>, u32, u32, bool)>;
fn get_read_and_written_keys(&mut self) -> Vec<(Vec<u8>, u32, u32, bool)>;
}

/// Extension for the [`Externalities`] trait.
Expand Down
1 change: 1 addition & 0 deletions primitives/state-machine/src/backend.rs
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,7 @@ pub trait AsTrieBackend<H: Hasher, C = sp_trie::cache::LocalTrieCache<H>> {

/// Return the type as [`TrieBackend`].
fn as_trie_backend(&self) -> &TrieBackend<Self::TrieBackendStorage, H, C>;
fn as_trie_backend_mut(&mut self) -> &mut TrieBackend<Self::TrieBackendStorage, H, C>;
}

/// Trait that allows consolidate two transactions together.
Expand Down
33 changes: 17 additions & 16 deletions primitives/state-machine/src/basic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::<BTreeMap<_, _>>() ==
other.overlay.changes().map(|(k, v)| (k, v.value())).collect::<BTreeMap<_, _>>() &&
self.overlay
self.overlay.changes().map(|(k, v)| (k, v.value())).collect::<BTreeMap<_, _>>()
== other.overlay.changes().map(|(k, v)| (k, v.value())).collect::<BTreeMap<_, _>>()
&& self
.overlay
.children()
.map(|(iter, i)| (i, iter.map(|(k, v)| (k, v.value())).collect::<BTreeMap<_, _>>()))
.collect::<BTreeMap<_, _>>() ==
other
.collect::<BTreeMap<_, _>>()
== other
.overlay
.children()
.map(|(iter, i)| {
Expand Down Expand Up @@ -160,27 +161,27 @@ impl From<BTreeMap<StorageKey, StorageValue>> for BasicExternalities {
impl Externalities for BasicExternalities {
fn set_offchain_storage(&mut self, _key: &[u8], _value: Option<&[u8]>) {}

fn storage(&self, key: &[u8]) -> Option<StorageValue> {
fn storage(&mut self, key: &[u8]) -> Option<StorageValue> {
self.overlay.storage(key).and_then(|v| v.map(|v| v.to_vec()))
}

fn storage_hash(&self, key: &[u8]) -> Option<Vec<u8>> {
fn storage_hash(&mut self, key: &[u8]) -> Option<Vec<u8>> {
self.storage(key).map(|v| Blake2Hasher::hash(&v).encode())
}

fn child_storage(&self, child_info: &ChildInfo, key: &[u8]) -> Option<StorageValue> {
fn child_storage(&mut self, child_info: &ChildInfo, key: &[u8]) -> Option<StorageValue> {
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<Vec<u8>> {
fn child_storage_hash(&mut self, child_info: &ChildInfo, key: &[u8]) -> Option<Vec<u8>> {
self.child_storage(child_info, key).map(|v| Blake2Hasher::hash(&v).encode())
}

fn next_storage_key(&self, key: &[u8]) -> Option<StorageKey> {
fn next_storage_key(&mut self, key: &[u8]) -> Option<StorageKey> {
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<StorageKey> {
fn next_child_storage_key(&mut self, child_info: &ChildInfo, key: &[u8]) -> Option<StorageKey> {
self.overlay
.child_iter_after(child_info.storage_key(), key)
.find_map(|(k, v)| v.value().map(|_| k.to_vec()))
Expand All @@ -189,7 +190,7 @@ impl Externalities for BasicExternalities {
fn place_storage(&mut self, key: StorageKey, maybe_value: Option<StorageValue>) {
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)
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -307,23 +308,23 @@ 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")
}

fn reset_read_write_count(&mut self) {
unimplemented!("reset_read_write_count is not supported in Basic")
}

fn get_whitelist(&self) -> Vec<TrackedStorageKey> {
fn get_whitelist(&mut self) -> Vec<TrackedStorageKey> {
unimplemented!("get_whitelist is not supported in Basic")
}

fn set_whitelist(&mut self, _: Vec<TrackedStorageKey>) {
unimplemented!("set_whitelist is not supported in Basic")
}

fn get_read_and_written_keys(&self) -> Vec<(Vec<u8>, u32, u32, bool)> {
fn get_read_and_written_keys(&mut self) -> Vec<(Vec<u8>, u32, u32, bool)> {
unimplemented!("get_read_and_written_keys is not supported in Basic")
}
}
Expand Down
Loading