Switch trie cache random seed (#1935)

Use a more secure seed for hashsets of cache.
This commit is contained in:
cheme
2023-10-20 05:13:19 +02:00
committed by GitHub
parent e1e0381380
commit f4c4c0fe29
3 changed files with 8 additions and 1 deletions
Generated
+1
View File
@@ -17527,6 +17527,7 @@ dependencies = [
"nohash-hasher",
"parity-scale-codec",
"parking_lot 0.12.1",
"rand 0.8.5",
"scale-info",
"schnellru",
"sp-core",
+2
View File
@@ -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 }
@@ -53,6 +54,7 @@ std = [
"memory-db/std",
"nohash-hasher",
"parking_lot",
"rand",
"scale-info/std",
"schnellru",
"sp-core/std",
+5 -1
View File
@@ -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 {