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

Snapshot integration and add cache to statedb #4419

Merged
merged 4 commits into from
Jun 6, 2023

Conversation

GheisMohammadi
Copy link
Contributor

Issue

It is pointless to check and re-verify every state item every time we retrieve it from disk. This PR makes advantage of the Ethereum snapshot functionality. When a new block is processed using snapshot, we do not merge the writes directly into the disk layer, but rather generate a new in-memory diff layer containing the modifications. When enough in-memory diff layers are piled on top, the bottom ones begin to merge and are eventually pushed to disk. When we need to read a state item, we start at the topmost diff layer and work our way backwards until we discover it or reach the disk.
This PR has the potential to dramatically enhance the performance of the state database. The snapshot reduces read times from O(log n) to O(1).

Operational Checklist

  1. Does this PR introduce backward-incompatible changes to the on-disk data structure and/or the over-the-wire protocol?. (If no, skip to question 8.)

    NO

Copy link
Contributor

@MaxMustermann2 MaxMustermann2 left a comment

Choose a reason for hiding this comment

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

Interesting! Do you have any results to see the improvements?

@ONECasey ONECasey merged commit 61b8aba into dev Jun 6, 2023
@ONECasey ONECasey deleted the feature/snapshot_integration branch June 9, 2023 02:08
@GheisMohammadi GheisMohammadi self-assigned this Jun 9, 2023
@GheisMohammadi
Copy link
Contributor Author

Interesting! Do you have any results to see the improvements?

This PR is tested on local node and it is supposed to reduce disk accesses for state writing/retrieving by a few times which is depends on the state path and type of access. It has been already deployed to devnet to do the functionality tests. If it were stable enough, we can do some exact benchmarks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants