-
Notifications
You must be signed in to change notification settings - Fork 236
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
some suggestions
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
some questions
crates/provider/src/layers/cache.rs
Outdated
) -> TransportResult<Option<Block>> { | ||
let hash = RequestType::new("eth_getBlockByNumber", (number, hydrate)); | ||
|
||
cache_get_or_fetch!(self, hash, self.inner.get_block_by_number(number, hydrate)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is problematic because of reorgs, we'd need to track chain height somehow, but out of scope for this pr imo
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
almost there
few more suggestions
@mattsse addressed the suggestions |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
last suggestions
let req = RequestType::new("eth_getBlockReceipts", (block,)); | ||
|
||
let redirect = | ||
!matches!(block, BlockId::Hash(_) | BlockId::Number(BlockNumberOrTag::Number(_))); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the number case is also slightly problematic, but we can worry about this separately
async fn get_logs(&self, filter: &Filter) -> TransportResult<Vec<Log>> { | ||
let req = RequestType::new("eth_getLogs", filter.clone()); | ||
|
||
let params_hash = req.params_hash().ok(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is also a bit nuanced because the blockrange variants allows the server to chose the range for example if upper bound is missing
Motivation
Ref: #770
Solution
key
is the hash of the request and its params.Overrides the following RPC methods
get_block_by_number
get_block_by_hash
get_block_receipts
get_proof
get_storage_at
get_code_at
get_transaction_count
get_logs
get_transaction_by_hash
get_raw_transaction_by_hash
get_transaction_receipt
PR Checklist