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

core/*: Encapsulate blockchain data storage #19200

Conversation

Matthalp-zz
Copy link
Contributor

@Matthalp-zz Matthalp-zz commented Mar 3, 2019

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 for
rawdb[1], whose code would be moved where it is currently being called within
chaindb.ChainDB whose use is a 1:1 mapping from before [2]

The goals of this work are twofold:

  1. Consolidate code interacting with storage.
  2. With (1) in place continue the freezer work initiated implement chain freezer, clean up database accesses #17814 inside.

Follow up work from this PR would be:

  1. Use chaindb.ChainDB in the remaining places where rawdb is being used.
  2. Migrate the various caches used between ethdb.Database inside the storage
    and also expose tuning options to set them.
  3. Continue with the freezer work.

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 a StateDB
concept, however it is included as it is currently stored/retrieved
through methods in rawdb.
[2] The only exception is WriteCanonicalHash whose method parameter order
was swapped as the number is the key and the hash is the value being
mapped to it, making it consistent with the "key" then "value" convention
the remaining methods use.

@Matthalp-zz Matthalp-zz force-pushed the core-chaindb-for-headerchain-and-above branch 3 times, most recently from 3c6099f to a3cc9cd Compare March 3, 2019 06:46
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 for
`rawdb`*, whose code would be moved where it is currently being called within
`chaindb.ChainDB` whose use is a 1:1 mapping from before.**

The goals of this work are twofold:
1. Consolidate code interacting with storage.
2. With (1) in place continue the freezer work initiated ethereum#17814 inside.

Follow up work from this PR would be:
1. Use `chaindb.ChainDB` in the remaining places where `rawdb` is being used.
2. Migrate the various caches used between `ethdb.Database` inside the storage
   and also expose tuning options to set them.
3. Continue with the freezer work.

This also introduces the `github.com/google/go-cmp/cmp/cmpopts` package,
which is used for the tests added for this work.

* The only exception is `WritePreimages` which is really a `StateDB`
concept, however it is included as it is currently stored/retrieved
through methods in `rawdb`.
** The only exception is `WriteCanonicalHash` whose method parameter order
was swapped as the `number` is the key and the `hash` is the value being
mapped to it, making it consistent with the "key" then "value" convention
the remaining methods use.
return rawdb.ReadCanonicalHash(c.db, number)
}

// WriteCanonicalHash stores the canoical hash assigned to a block number.
Copy link
Contributor

Choose a reason for hiding this comment

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

canoical => canonical, typo

@holiman
Copy link
Contributor

holiman commented Sep 12, 2019

This PR came at a time when we were doing major internal refactorings (e.g. ancients), and has thus at this point in time become very hard to apply.

@holiman holiman closed this Sep 12, 2019
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.

5 participants