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

Archify EthStateCache #5744

Merged
merged 2 commits into from
Dec 15, 2023

Conversation

i-m-aditya
Copy link
Contributor

Ref #5720

Copy link
Member

@rkrasiuk rkrasiuk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

couple of comments:

  1. We should not change provider interfaces for this purpose
  2. The values should be wrapped in Arc inside lru cache itself and the Arc should only be created upon insertion
  3. Having values wrapped in an Arc would require creating a custom limiter since ByLength is not implemented for Arc<Vec<T>>
  4. All of the other to_vec and clone calls should become unnecessary after completion of all steps above

@rkrasiuk rkrasiuk added C-perf A change motivated by improving speed, memory usage or disk footprint A-rpc Related to the RPC implementation labels Dec 13, 2023
@i-m-aditya
Copy link
Contributor Author

i-m-aditya commented Dec 13, 2023

couple of comments:

  1. We should not change provider interfaces for this purpose
  2. The values should be wrapped in Arc inside lru cache itself and the Arc should only be created upon insertion
  3. Having values wrapped in an Arc would require creating a custom limiter since ByLength is not implemented for Arc<Vec<T>>
  4. All of the other to_vec and clone calls should become unnecessary after completion of all steps above

@rkrasiuk Thanks for the comments. However, I have one question:

let mut block_and_receipts = None;

        if block_id.is_pending() {
            block_and_receipts = self.provider().pending_block_and_receipts()?;
        } else if let Some(block_hash) = self.provider().block_hash_for_id(block_id)? {
            block_and_receipts = self.cache().get_block_and_receipts(block_hash).await?;
        }

For block_and_receipts to align with the same type, receipts can be Arc(as returned from the cache) or the value itself(returned from the provider). For this to happen, I need to change the provider interface. Am I missing something here?

@mattsse
Copy link
Collaborator

mattsse commented Dec 14, 2023

ah I see,
need to think about more, but we should proceed with simply putting the pending receipts in a new Arc before returning

@i-m-aditya
Copy link
Contributor Author

ah I see, need to think about more, but we should proceed with simply putting the pending receipts in a new Arc before returning

Yeah, would wrap the receipt in Arc and not change the provider interface.

@i-m-aditya i-m-aditya force-pushed the i-m-aditya/archify-ethStateCache branch from 7b43e6f to 92fc57b Compare December 15, 2023 11:29
@mattsse mattsse force-pushed the i-m-aditya/archify-ethStateCache branch from 543c486 to 9e4ad13 Compare December 15, 2023 12:48
Copy link
Collaborator

@mattsse mattsse left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@mattsse mattsse marked this pull request as ready for review December 15, 2023 12:49
@mattsse mattsse added this pull request to the merge queue Dec 15, 2023
@mattsse mattsse removed this pull request from the merge queue due to a manual request Dec 15, 2023
@mattsse mattsse added this pull request to the merge queue Dec 15, 2023
Merged via the queue into paradigmxyz:main with commit a0129b6 Dec 15, 2023
27 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-rpc Related to the RPC implementation C-perf A change motivated by improving speed, memory usage or disk footprint
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants