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.ChainDB
serves 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/statedb
and ultimately a replacement forrawdb
[1], whose code would be moved where it is currently being called withinchaindb.ChainDB
whose 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.ChainDB
in the remaining places whererawdb
is being used.ethdb.Database
inside the storageand also expose tuning options to set them.
This also introduces the
github.com/google/go-cmp/cmp/cmpopts
package,which is used for the tests added for this work.
[1] The only exception is
WritePreimages
which is really aStateDB
concept, however it is included as it is currently stored/retrieved
through methods in
rawdb
.[2] The only exception is
WriteCanonicalHash
whose method parameter orderwas swapped as the
number
is the key and thehash
is the value beingmapped to it, making it consistent with the "key" then "value" convention
the remaining methods use.