Skip to content

Commit

Permalink
feat(provider): LRUCache Layer (#954)
Browse files Browse the repository at this point in the history
* in-memory cache implementation

* load and dump cache from fs

* use RwLock

* doc nits

* feat: CacheConfig, load/save at specific paths

* RequestType enum

* params hash

* clone and arc `CacheProvider`

* add: get_block_by_hash

* todos

* refactor: port to transport layer

* rm provider cache layer

* use parking_lot::RwLock + tracing nits

* cleanup nits

* nit

* move cache instance to layer

* Revert "refactor: port to transport layer"

This reverts commit bb05544.

* use provider cache

* use macro

* cached get_proof

* nit

* nit

* use parking_lot

* make params hash independent of client

* fix

* cache_rpc_call_with_block!

* fix: request type

* redirect reqs with block tags to rpc

* nits

* get_accounts

* chain_id

* cfg gate wasm

* rm get_accounts and get_chain_id

* rm related tests

* tests: run_with_temp_dir

* feat: SharedCache

* make CacheProvider generic over Network

* add more methods

* fmt

* docs

* docs

* nit

* fix

* clippy

* mv SharedCache

* use schnellru

* feat: get_derialized

* nits
  • Loading branch information
yash-atreya authored Oct 8, 2024
1 parent 95ddf0c commit 1decf94
Show file tree
Hide file tree
Showing 5 changed files with 771 additions and 4 deletions.
3 changes: 3 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,9 @@ semver = "1.0"
thiserror = "1.0"
thiserror-no-std = "2.0.2"
url = "2.5"
schnellru = "0.2.3"
lru = "0.12"
parking_lot = "0.12.3"
derive_more = { version = "1.0.0", default-features = false }
strum = { version = "0.26", default-features = false }
http = "1.1.0"
Expand Down
7 changes: 5 additions & 2 deletions crates/provider/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,8 @@ auto_impl.workspace = true
dashmap = "6.0"
futures-utils-wasm.workspace = true
futures.workspace = true
lru = "0.12"
schnellru.workspace = true
lru.workspace = true
pin-project.workspace = true
reqwest = { workspace = true, optional = true }
serde_json.workspace = true
Expand All @@ -61,6 +62,8 @@ tokio = { workspace = true, features = ["sync", "macros"] }
tracing.workspace = true
url = { workspace = true, optional = true }

[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
parking_lot.workspace = true
[target.'cfg(target_arch = "wasm32")'.dependencies]
wasmtimer.workspace = true

Expand All @@ -77,7 +80,7 @@ alloy-transport-http = { workspace = true, features = ["reqwest", "jwt-auth"] }

itertools.workspace = true
reqwest.workspace = true
tokio = { workspace = true, features = ["macros"] }
tokio = { workspace = true, features = ["macros", "rt-multi-thread"] }
tracing-subscriber = { workspace = true, features = ["fmt"] }
tempfile.workspace = true
tower.workspace = true
Expand Down
Loading

0 comments on commit 1decf94

Please sign in to comment.