diff --git a/Cargo.toml b/Cargo.toml index 084ca827c92..748e7f5bf94 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -25,7 +25,7 @@ all = "warn" [workspace.lints.clippy] all = { level = "warn", priority = -1 } -missing-const-for-fn = "warn" +missing-const-for-fn = "allow" # TODO: https://github.com/rust-lang/rust-clippy/issues/14020 use-self = "warn" option-if-let-else = "warn" redundant-clone = "warn" @@ -115,7 +115,7 @@ rustls = { version = "0.23", default-features = false, features = [ "tls12", ] } tokio-test = "0.4" -tokio-tungstenite = "0.24" +tokio-tungstenite = "0.26" tower = { version = "0.5", features = ["util"] } # tracing @@ -138,15 +138,14 @@ cfg-if = "1" derive_more = { version = "1.0.0", default-features = false } home = "0.5" http = "1.1.0" -itertools = { version = "0.13", default-features = false } +itertools = { version = ">=0.13, <=0.14", default-features = false } jsonwebtoken = "9.3.0" -lru = "0.12" +lru = "0.13" once_cell = { version = "1.19", default-features = false } parking_lot = "0.12.3" pin-project = "1.1" rand = "0.8" reqwest = { version = "0.12", default-features = false } -schnellru = "0.2.3" semver = "1.0" strum = { version = "0.26", default-features = false } thiserror = { version = "2.0", default-features = false } diff --git a/crates/provider/Cargo.toml b/crates/provider/Cargo.toml index 0c014ecbeb2..b47dd564142 100644 --- a/crates/provider/Cargo.toml +++ b/crates/provider/Cargo.toml @@ -56,7 +56,6 @@ auto_impl.workspace = true dashmap = "6.0" futures-utils-wasm.workspace = true futures.workspace = true -schnellru.workspace = true lru.workspace = true pin-project.workspace = true reqwest = { workspace = true, optional = true } diff --git a/crates/provider/src/layers/cache.rs b/crates/provider/src/layers/cache.rs index 91397a07072..c20a95a9319 100644 --- a/crates/provider/src/layers/cache.rs +++ b/crates/provider/src/layers/cache.rs @@ -9,10 +9,10 @@ use alloy_rpc_types_eth::{ BlockNumberOrTag, BlockTransactionsKind, EIP1186AccountProofResponse, Filter, Log, }; use alloy_transport::{TransportErrorKind, TransportResult}; +use lru::LruCache; use parking_lot::RwLock; -use schnellru::{ByLength, LruMap}; use serde::{Deserialize, Serialize}; -use std::{io::BufReader, marker::PhantomData, path::PathBuf, sync::Arc}; +use std::{io::BufReader, marker::PhantomData, num::NonZero, path::PathBuf, sync::Arc}; /// A provider layer that caches RPC responses and serves them on subsequent requests. /// @@ -430,28 +430,30 @@ struct FsCacheEntry { /// Serialized response to the request from which the hash was computed. value: String, } + /// Shareable cache. #[derive(Debug, Clone)] pub struct SharedCache { - inner: Arc>>, - max_items: u32, + inner: Arc>>>, + max_items: NonZero, } impl SharedCache { /// Instantiate a new shared cache. pub fn new(max_items: u32) -> Self { - let inner = Arc::new(RwLock::new(LruMap::new(ByLength::new(max_items)))); + let max_items = NonZero::new(max_items as usize).unwrap_or(NonZero::::MIN); + let inner = Arc::new(RwLock::new(LruCache::with_hasher(max_items, Default::default()))); Self { inner, max_items } } /// Maximum number of items that can be stored in the cache. pub const fn max_items(&self) -> u32 { - self.max_items + self.max_items.get() as u32 } /// Puts a value into the cache, and returns the old value if it existed. pub fn put(&self, key: B256, value: String) -> TransportResult { - Ok(self.inner.write().insert(key, value)) + Ok(self.inner.write().put(key, value).is_some()) } /// Gets a value from the cache, if it exists. @@ -498,7 +500,7 @@ impl SharedCache { serde_json::from_reader(file).map_err(TransportErrorKind::custom)?; let mut cache = self.inner.write(); for entry in entries { - cache.insert(entry.key, entry.value); + cache.put(entry.key, entry.value); } Ok(()) diff --git a/crates/signer-gcp/Cargo.toml b/crates/signer-gcp/Cargo.toml index 493baa51da2..a37e9fcaac9 100644 --- a/crates/signer-gcp/Cargo.toml +++ b/crates/signer-gcp/Cargo.toml @@ -29,7 +29,7 @@ alloy-primitives.workspace = true alloy-signer.workspace = true async-trait.workspace = true -gcloud-sdk = { version = "0.25", features = [ +gcloud-sdk = { version = "0.26", features = [ "google-cloud-kms-v1", "google-longrunning", ] } diff --git a/crates/transport-ws/src/native.rs b/crates/transport-ws/src/native.rs index f12d4794ed1..f324ff11d6a 100644 --- a/crates/transport-ws/src/native.rs +++ b/crates/transport-ws/src/native.rs @@ -109,7 +109,7 @@ impl WsBackend { /// Send a message to the server. pub async fn send(&mut self, msg: Box) -> Result<(), tungstenite::Error> { - self.socket.send(Message::Text(msg.get().to_owned())).await + self.socket.send(Message::Text(msg.get().to_owned().into())).await } /// Spawn a new backend task. @@ -155,7 +155,7 @@ impl WsBackend { _ = &mut keepalive => { // Reset the keepalive timer. keepalive.set(sleep(Duration::from_secs(KEEPALIVE))); - if let Err(err) = self.socket.send(Message::Ping(vec![])).await { + if let Err(err) = self.socket.send(Message::Ping(Default::default())).await { error!(%err, "WS connection error"); errored = true; break