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

Switch trie cache random seed #1935

Merged
merged 2 commits into from
Oct 20, 2023
Merged
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
1 change: 1 addition & 0 deletions Cargo.lock

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

2 changes: 2 additions & 0 deletions substrate/primitives/trie/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ lazy_static = { version = "1.4.0", optional = true }
memory-db = { version = "0.32.0", default-features = false }
nohash-hasher = { version = "0.2.0", optional = true }
parking_lot = { version = "0.12.1", optional = true }
rand = { version = "0.8", optional = true }
scale-info = { version = "2.5.0", default-features = false, features = ["derive"] }
thiserror = { version = "1.0.48", optional = true }
tracing = { version = "0.1.29", optional = true }
Expand Down Expand Up @@ -53,6 +54,7 @@ std = [
"memory-db/std",
"nohash-hasher",
"parking_lot",
"rand",
"scale-info/std",
"schnellru",
"sp-core/std",
Expand Down
6 changes: 5 additions & 1 deletion substrate/primitives/trie/src/cache/shared_cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,11 @@ use std::{
use trie_db::{node::NodeOwned, CachedValue};

lazy_static::lazy_static! {
static ref RANDOM_STATE: ahash::RandomState = ahash::RandomState::default();
static ref RANDOM_STATE: ahash::RandomState = {
use rand::Rng;
let mut rng = rand::thread_rng();
ahash::RandomState::generate_with(rng.gen(), rng.gen(), rng.gen(), rng.gen())
};
}

pub struct SharedNodeCacheLimiter {
Expand Down
Loading