nimbus-eth1/nimbus/db/core_db
web3-developer 11691c33e9
Update Nimbus codebase to use the new nim-rocksdb API. (#2054)
* Bump nim-rocksdb.

* Update codebase to use latest nim-rocksdb API.

* Update copyright notices.

* Fix memory leak due to allocCStringArray without deallocCStringArray.

* Improve kvstore_rocksdb code.

* Refactor and cleanup RocksStoreRef.

* Update nim-rocksdb submodule to latest.
2024-03-05 12:54:42 +08:00
..
backend Update Nimbus codebase to use the new nim-rocksdb API. (#2054) 2024-03-05 12:54:42 +08:00
base Coredb use stackable api for aristo backend (#2060) 2024-02-29 21:10:24 +00:00
.gitignore Unified database frontend (#1661) 2023-07-31 14:43:38 +01:00
README.md Unified database frontend integration (#1670) 2023-08-04 12:10:09 +01:00
base.nim Coredb use stackable api for aristo backend (#2060) 2024-02-29 21:10:24 +00:00
base_iterators.nim Reduce compiler warnings (#2030) 2024-02-16 16:08:07 +07:00
base_iterators_persistent.nim Reduce compiler warnings (#2030) 2024-02-16 16:08:07 +07:00
core_apps_legacy.nim Storage of block witnesses (#1986) 2024-02-13 17:49:41 +08:00
core_apps_newapi.nim Core db+friends fix sync bail outs (#2026) 2024-02-14 10:02:09 +00:00
memory_only.nim Coredb use stackable api for aristo backend (#2060) 2024-02-29 21:10:24 +00:00
persistent.nim Remove obsolete select_backend and fix simulators CI (#2007) 2024-02-04 21:28:20 +07:00

README.md

Core database replacement wrapper object

This wrapper replaces the TrieDatabaseRef and its derivatives by the new object CoreDbRef.

Relations to current TrieDatabaseRef implementation

Here are some incomplete translations for objects and constructors.

Object types:

Legacy notation CoreDbRef based replacement
ChainDB (don't use/avoid)
ChainDbRef CoreDbRef
TrieDatabaseRef CoreDbKvtRef
HexaryTrie CoreDbMptRef
SecureHexaryTrie CoreDbPhkRef
DbTransaction CoreDbTxRef
TransactionID CoreDbTxID

Constructors:

Legacy notation CoreDbRef based replacement
trieDB newChainDB("..") newCoreDbRef(LegacyDbPersistent,"..")
newMemoryDB() newCoreDbRef(LegacyDbMemory)
--
initHexaryTrie(db,..) db.mpt(..) (no pruning)
db.mptPrune(..) (w/pruning true/false)
--
initSecureHexaryTrie(db,..) db.phk(..) (no pruning)
db.phkPrune(..) (w/pruning true/false)
--
newCaptureDB(db,memDB) db.capture() (see below)

Usage of the replacement wrapper

Objects pedigree:

    CoreDbRef                   -- base descriptor
     | | | |
     | | | +-- CoreDbMptRef     -- hexary trie instance
     | | | |    :                    :
     | | | +-- CoreDbMptRef     -- hexary trie instance
     | | |
     | | |
     | | +---- CoreDbPhkRef     -- pre-hashed key hexary trie instance
     | | |      :                    :
     | | +---- CoreDbPhkRef     -- pre-hashed key hexary trie instance
     | |
     | |
     | +------ CoreDbKvtRef     -- single static key-value table
     |
     |
     +-------- CoreDbCaptRef    -- tracer support descriptor

Instantiating standard database object descriptors works as follows:

    let
      db = newCoreDbRef(..)           # new base descriptor
      mpt = db.mpt(..)                # hexary trie/Merkle Patricia Tree
      phk = db.phk(..)                # pre-hashed key hexary trie/MPT
      kvt = db.kvt                    # key-value table

Tracer support setup by hiding the current CoreDbRef behind a replacement:

    let
      capture = db.capture()
      db = capture.recorder           # use the recorder in place of db
    ...

    for key,value in capture.recorder.kvt:
     ...                              # process recorded data