[go: up one dir, main page]

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

feat(provider): LRUCache Layer #954

Open
wants to merge 37 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
0d56877
in-memory cache implementation
yash-atreya Jun 21, 2024
df7d861
load and dump cache from fs
yash-atreya Jun 24, 2024
cc8b11d
use RwLock
yash-atreya Jun 24, 2024
8a1e353
doc nits
yash-atreya Jun 24, 2024
03c50c5
feat: CacheConfig, load/save at specific paths
yash-atreya Jun 24, 2024
0fc93a1
RequestType enum
yash-atreya Jun 24, 2024
9b95833
params hash
yash-atreya Jun 24, 2024
f79a128
clone and arc `CacheProvider`
yash-atreya Jun 24, 2024
e6da7f7
add: get_block_by_hash
yash-atreya Jun 24, 2024
902a24b
todos
yash-atreya Jun 24, 2024
863c868
Merge branch 'main' into yash/provider-cache
yash-atreya Jul 29, 2024
bb05544
refactor: port to transport layer
yash-atreya Aug 1, 2024
5fa27f4
rm provider cache layer
yash-atreya Aug 1, 2024
12a76c3
use parking_lot::RwLock + tracing nits
yash-atreya Aug 6, 2024
64343b0
cleanup nits
yash-atreya Aug 6, 2024
9fee441
nit
yash-atreya Aug 6, 2024
cb1c1b5
move cache instance to layer
yash-atreya Aug 7, 2024
6e9c7f4
Merge branch 'main' into yash/provider-cache
yash-atreya Aug 21, 2024
47ee0c6
resolve conflicts
yash-atreya Sep 19, 2024
5eb4af2
Revert "refactor: port to transport layer"
yash-atreya Sep 20, 2024
3e9538e
use provider cache
yash-atreya Sep 20, 2024
efa027a
use macro
yash-atreya Sep 20, 2024
ab44b80
cached get_proof
yash-atreya Sep 20, 2024
ae9e123
nit
yash-atreya Sep 20, 2024
9f646b2
nit
yash-atreya Sep 20, 2024
c25371a
Merge branch 'main' into yash/provider-cache
yash-atreya Sep 24, 2024
947bd91
use parking_lot
yash-atreya Sep 24, 2024
5653119
Merge branch 'main' into yash/provider-cache
yash-atreya Sep 27, 2024
c82901c
make params hash independent of client
yash-atreya Sep 27, 2024
32a7beb
fix
yash-atreya Sep 27, 2024
0478ded
cache_rpc_call_with_block!
yash-atreya Sep 27, 2024
fa8346c
fix: request type
yash-atreya Sep 27, 2024
6e0c676
redirect reqs with block tags to rpc
yash-atreya Sep 27, 2024
70bc5e1
nits
yash-atreya Sep 27, 2024
f8d1ab6
get_accounts
yash-atreya Sep 27, 2024
d8d4094
chain_id
yash-atreya Sep 27, 2024
d67142c
cfg gate wasm
yash-atreya Sep 30, 2024
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
Prev Previous commit
Next Next commit
resolve conflicts
  • Loading branch information
yash-atreya committed Sep 19, 2024
commit 47ee0c6a235f78035cb51072e35136dcf923b533
3 changes: 2 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -137,9 +137,10 @@ semver = "1.0"
thiserror = "1.0"
thiserror-no-std = "2.0.2"
url = "2.5"
derive_more = "1.0.0"
lru = "0.12"
parking_lot = "0.12.3"
derive_more = { version = "1.0.0", default-features = false }
http = "1.1.0"

## serde
serde = { version = "1.0", default-features = false, features = [
Expand Down
17 changes: 16 additions & 1 deletion crates/provider/src/provider/trait.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1024,8 +1024,23 @@ mod tests {
use alloy_node_bindings::Anvil;
use alloy_primitives::{address, b256, bytes, keccak256};
use alloy_rpc_client::ClientBuilder;
use alloy_rpc_types_eth::request::TransactionRequest;
use alloy_rpc_types_eth::{request::TransactionRequest, Block};
use alloy_transport::layers::CacheLayer;
// For layer transport tests
#[cfg(feature = "hyper")]
use alloy_transport_http::{
hyper,
hyper::body::Bytes as HyperBytes,
hyper_util::{
client::legacy::{Client, Error},
rt::TokioExecutor,
},
HyperResponse, HyperResponseFut,
};
#[cfg(feature = "hyper")]
use http_body_util::Full;
#[cfg(feature = "hyper")]
use tower::{Layer, Service};

fn init_tracing() {
let _ = tracing_subscriber::fmt::try_init();
Expand Down
4 changes: 2 additions & 2 deletions crates/transport/src/layers/cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ pub struct CachingService<S> {

impl<S> CachingService<S> {
/// Instantiate a new cache service.
pub fn new(inner: S, layer: CacheLayer) -> Self {
pub const fn new(inner: S, layer: CacheLayer) -> Self {
Self { inner, layer }
}

Expand All @@ -157,7 +157,7 @@ impl<S> CachingService<S> {
}

/// Handles a cache hit.
fn handle_cache_hit(&self, id: Id, raw: Box<RawValue>) -> ResponsePacket {
const fn handle_cache_hit(&self, id: Id, raw: Box<RawValue>) -> ResponsePacket {
let payload = ResponsePayload::Success(raw);
let response = Response { id, payload };
ResponsePacket::Single(response)
Expand Down
You are viewing a condensed version of this merge commit. You can view the full changes here.