core/*: Encapsulate blockchain data storage #19200
Closed
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.
This introduces a blockchain data storage package,
chaindb.chaindb.ChainDBserves as a layer between the blockchain (and headerchain and lightchain) and
the underlying key-value storage. It can be best thought of as the blockchain
data counterpart to
core/state/statedband ultimately a replacement forrawdb[1], whose code would be moved where it is currently being called withinchaindb.ChainDBwhose use is a 1:1 mapping from before [2]The goals of this work are twofold:
Follow up work from this PR would be:
chaindb.ChainDBin the remaining places whererawdbis being used.ethdb.Databaseinside the storageand also expose tuning options to set them.
This also introduces the
github.com/google/go-cmp/cmp/cmpoptspackage,which is used for the tests added for this work.
[1] The only exception is
WritePreimageswhich is really aStateDBconcept, however it is included as it is currently stored/retrieved
through methods in
rawdb.[2] The only exception is
WriteCanonicalHashwhose method parameter orderwas swapped as the
numberis the key and thehashis the value beingmapped to it, making it consistent with the "key" then "value" convention
the remaining methods use.