nimbus-eth1/nimbus/db/core_db
Jordan Hrycaj e8ad950e0a
Ledger abstraction for accounts cache (#1824)
* Provide TDD/debug facility for inspecting `persistBlocks()` working

detail:
+ Make sure that the last block of a test sample is the first batch
  item in `persistBlocks()`.
+ Additionally, allow `AccountsCache` API tracing by setting the flag
  `extraTraceMessages = true` in the file `accounts_cache.nim`

* Overload AccountsCache by abstraction wrapper

details:
  Can facilitate CoreDb API switch, details in `ledger/README.md`.
2023-10-18 20:27:22 +01:00
..
backend Ledger abstraction for accounts cache (#1824) 2023-10-18 20:27:22 +01:00
base Core db update api and fix tracer methods (#1816) 2023-10-11 20:09:11 +01: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 Core db update api and fix tracer methods (#1816) 2023-10-11 20:09:11 +01:00
core_apps.nim Core db aristo and kvt updates preparing for integration (#1760) 2023-09-18 21:20:28 +01:00
memory_only.nim Core db update api and fix tracer methods (#1816) 2023-10-11 20:09:11 +01:00
persistent.nim Core db update api and fix tracer methods (#1816) 2023-10-11 20:09:11 +01: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