Add block database support #1189
Draft
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.
Why this should be merged
Not meant to be merged. This PR is for evaluation and testing only.
How this works
Adds a block database wrapper for the ETH database that redirects block header and body storage to a separate block database.
The block database wrapper does not allow storing multiple blocks per height. This means to use it, we must move block persistence from
Verify
toAccept
. Therefore, this PR also includes logic to not store block headers and bodies onVerify
. Instead, blocks are stored in an in-memory cache for verified blocks while block-related data (receipts, hash→number mapping, preimages) are still persisted onVerify
. These data are needed by other parts of the code before the block is accepted, so they are still persisted onVerify
.However, SAE changes should move block persistence from
Verify
toAccept
as well, so we might not need the changes introduced in this PR for moving block persistence. Therefore, this PR is marked as Do Not Merge for now as we should ideally rely on the SAE work for this change.This PR is mainly for testing the block database before SAE is fully usable in Coreth.
How this was tested
Tests & manually spinning up a node with block database enabled.