-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Serve typed blocks from recent block cache to avoid repeated deserialization #6400
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
Merged
+316
−242
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -7,6 +7,7 @@ use async_trait::async_trait; | |
| use super::*; | ||
| use crate::blockchain::block_stream::{EntitySourceOperation, FirehoseCursor}; | ||
| use crate::blockchain::{BlockTime, ChainIdentifier, ExtendedBlockPtr}; | ||
| use crate::components::ethereum::CachedBlock; | ||
| use crate::components::metrics::stopwatch::StopwatchMetrics; | ||
| use crate::components::network_provider::ChainName; | ||
| use crate::components::server::index_node::VersionInfo; | ||
|
|
@@ -553,8 +554,12 @@ pub trait ChainStore: ChainHeadStore { | |
| ancestor_count: BlockNumber, | ||
| ) -> Result<Option<B256>, Error>; | ||
|
|
||
| /// Returns the blocks present in the store. | ||
| async fn blocks( | ||
| /// Returns the blocks present in the store as typed cached blocks. | ||
| async fn blocks(self: Arc<Self>, hashes: Vec<BlockHash>) -> Result<Vec<CachedBlock>, Error>; | ||
|
|
||
| /// Returns blocks as raw JSON. Used by callers that need the original | ||
| /// JSON representation (e.g., GraphQL block queries, CLI tools). | ||
| async fn blocks_as_json( | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We should try and get rid of this one, but that's also for another PR
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Noted |
||
| self: Arc<Self>, | ||
| hashes: Vec<BlockHash>, | ||
| ) -> Result<Vec<serde_json::Value>, Error>; | ||
|
|
@@ -584,7 +589,7 @@ pub trait ChainStore: ChainHeadStore { | |
| block_ptr: BlockPtr, | ||
| offset: BlockNumber, | ||
| root: Option<BlockHash>, | ||
| ) -> Result<Option<(serde_json::Value, BlockPtr)>, Error>; | ||
| ) -> Result<Option<(CachedBlock, BlockPtr)>, Error>; | ||
|
|
||
| /// Remove old blocks from the cache we maintain in the database and | ||
| /// return a pair containing the number of the oldest block retained | ||
|
|
||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
It would be nice to get rid of
Clonefor this and all other block structs; that's probably a bigger puzzle and requires usingArcjudiciously in various data structures, i.e., something for another PR; but conceptually, blocks are readonly and it should therefore be possible toArcthem.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.
Noted