2023-09-26 09:21:13 +00:00
|
|
|
# Nimbus
|
Core db and aristo updates for destructor and tx logic (#1894)
* Disable `TransactionID` related functions from `state_db.nim`
why:
Functions `getCommittedStorage()` and `updateOriginalRoot()` from
the `state_db` module are nowhere used. The emulation of a legacy
`TransactionID` type functionality is administratively expensive to
provide by `Aristo` (the legacy DB version is only partially
implemented, anyway).
As there is no other place where `TransactionID`s are used, they will
not be provided by the `Aristo` variant of the `CoreDb`. For the
legacy DB API, nothing will change.
* Fix copyright headers in source code
* Get rid of compiler warning
* Update Aristo code, remove unused `merge()` variant, export `hashify()`
why:
Adapt to upcoming `CoreDb` wrapper
* Remove synced tx feature from `Aristo`
why:
+ This feature allowed to synchronise transaction methods like begin,
commit, and rollback for a group of descriptors.
+ The feature is over engineered and not needed for `CoreDb`, neither
is it complete (some convergence features missing.)
* Add debugging helpers to `Kvt`
also:
Update database iterator, add count variable yield argument similar
to `Aristo`.
* Provide optional destructors for `CoreDb` API
why;
For the upcoming Aristo wrapper, this allows to control when certain
smart destruction and update can take place. The auto destructor works
fine in general when the storage/cache strategy is known and acceptable
when creating descriptors.
* Add update option for `CoreDb` API function `hash()`
why;
The hash function is typically used to get the state root of the MPT.
Due to lazy hashing, this might be not available on the `Aristo` DB.
So the `update` function asks for re-hashing the gurrent state changes
if needed.
* Update API tracking log mode: `info` => `debug
* Use shared `Kvt` descriptor in new Ledger API
why:
No need to create a new descriptor all the time
2023-11-16 19:35:03 +00:00
|
|
|
# Copyright (c) 2023 Status Research & Development GmbH
|
2023-09-26 09:21:13 +00:00
|
|
|
# Licensed under either of
|
|
|
|
# * Apache License, version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or
|
|
|
|
# http://www.apache.org/licenses/LICENSE-2.0)
|
|
|
|
# * MIT license ([LICENSE-MIT](LICENSE-MIT) or
|
|
|
|
# http://opensource.org/licenses/MIT)
|
|
|
|
# at your option. This file may not be copied, modified, or distributed except
|
|
|
|
# according to those terms.
|
|
|
|
|
|
|
|
{.push raises: [].}
|
|
|
|
|
|
|
|
import
|
|
|
|
eth/common,
|
|
|
|
results,
|
|
|
|
../../../errors
|
|
|
|
|
|
|
|
# Annotation helpers
|
|
|
|
{.pragma: noRaise, gcsafe, raises: [].}
|
|
|
|
{.pragma: apiRaise, gcsafe, raises: [CoreDbApiError].}
|
|
|
|
|
|
|
|
type
|
|
|
|
CoreDbType* = enum
|
|
|
|
Ooops
|
|
|
|
LegacyDbMemory
|
|
|
|
LegacyDbPersistent
|
|
|
|
|
|
|
|
const
|
2023-10-25 14:03:09 +00:00
|
|
|
CoreDbPersistentTypes* = {LegacyDbPersistent}
|
2023-09-26 09:21:13 +00:00
|
|
|
|
|
|
|
type
|
2023-10-02 18:05:17 +00:00
|
|
|
CoreDbRc*[T] = Result[T,CoreDbErrorRef]
|
2023-09-26 09:21:13 +00:00
|
|
|
|
2023-10-11 19:09:11 +00:00
|
|
|
CoreDbAccount* = object
|
|
|
|
## Generic account representation referencing an *MPT* sub-trie
|
|
|
|
nonce*: AccountNonce ## Some `uint64` type
|
|
|
|
balance*: UInt256
|
|
|
|
storageVid*: CoreDbVidRef ## Implies storage root sub-MPT
|
|
|
|
codeHash*: Hash256
|
|
|
|
|
|
|
|
CoreDbErrorCode* = enum
|
2023-11-08 12:18:32 +00:00
|
|
|
Unset = 0
|
|
|
|
Unspecified
|
2023-10-11 19:09:11 +00:00
|
|
|
RlpException
|
|
|
|
KvtNotFound
|
|
|
|
MptNotFound
|
2023-11-08 12:18:32 +00:00
|
|
|
AccNotFound
|
2023-10-11 19:09:11 +00:00
|
|
|
RootNotFound
|
Core db and aristo updates for destructor and tx logic (#1894)
* Disable `TransactionID` related functions from `state_db.nim`
why:
Functions `getCommittedStorage()` and `updateOriginalRoot()` from
the `state_db` module are nowhere used. The emulation of a legacy
`TransactionID` type functionality is administratively expensive to
provide by `Aristo` (the legacy DB version is only partially
implemented, anyway).
As there is no other place where `TransactionID`s are used, they will
not be provided by the `Aristo` variant of the `CoreDb`. For the
legacy DB API, nothing will change.
* Fix copyright headers in source code
* Get rid of compiler warning
* Update Aristo code, remove unused `merge()` variant, export `hashify()`
why:
Adapt to upcoming `CoreDb` wrapper
* Remove synced tx feature from `Aristo`
why:
+ This feature allowed to synchronise transaction methods like begin,
commit, and rollback for a group of descriptors.
+ The feature is over engineered and not needed for `CoreDb`, neither
is it complete (some convergence features missing.)
* Add debugging helpers to `Kvt`
also:
Update database iterator, add count variable yield argument similar
to `Aristo`.
* Provide optional destructors for `CoreDb` API
why;
For the upcoming Aristo wrapper, this allows to control when certain
smart destruction and update can take place. The auto destructor works
fine in general when the storage/cache strategy is known and acceptable
when creating descriptors.
* Add update option for `CoreDb` API function `hash()`
why;
The hash function is typically used to get the state root of the MPT.
Due to lazy hashing, this might be not available on the `Aristo` DB.
So the `update` function asks for re-hashing the gurrent state changes
if needed.
* Update API tracking log mode: `info` => `debug
* Use shared `Kvt` descriptor in new Ledger API
why:
No need to create a new descriptor all the time
2023-11-16 19:35:03 +00:00
|
|
|
HashNotAvailable
|
|
|
|
StorageFailed
|
|
|
|
|
|
|
|
CoreDbSaveFlags* = enum
|
|
|
|
Cached ## Shared, leaves changes in memory cache
|
|
|
|
AutoSave ## Shared, save changes on destruction
|
|
|
|
Companion ## Separate, leaves changes in memory cache
|
2023-10-11 19:09:11 +00:00
|
|
|
|
2023-09-26 09:21:13 +00:00
|
|
|
CoreDbCaptFlags* {.pure.} = enum
|
|
|
|
PersistPut
|
|
|
|
PersistDel
|
|
|
|
|
|
|
|
# --------------------------------------------------
|
2023-10-11 19:09:11 +00:00
|
|
|
# Sub-descriptor: Misc methods for main descriptor
|
2023-09-26 09:21:13 +00:00
|
|
|
# --------------------------------------------------
|
2023-10-11 19:09:11 +00:00
|
|
|
CoreDbBaseBackendFn* = proc(): CoreDbBackendRef {.noRaise.}
|
|
|
|
CoreDbBaseDestroyFn* = proc(flush = true) {.noRaise.}
|
|
|
|
CoreDbBaseVidHashFn* =
|
Core db and aristo updates for destructor and tx logic (#1894)
* Disable `TransactionID` related functions from `state_db.nim`
why:
Functions `getCommittedStorage()` and `updateOriginalRoot()` from
the `state_db` module are nowhere used. The emulation of a legacy
`TransactionID` type functionality is administratively expensive to
provide by `Aristo` (the legacy DB version is only partially
implemented, anyway).
As there is no other place where `TransactionID`s are used, they will
not be provided by the `Aristo` variant of the `CoreDb`. For the
legacy DB API, nothing will change.
* Fix copyright headers in source code
* Get rid of compiler warning
* Update Aristo code, remove unused `merge()` variant, export `hashify()`
why:
Adapt to upcoming `CoreDb` wrapper
* Remove synced tx feature from `Aristo`
why:
+ This feature allowed to synchronise transaction methods like begin,
commit, and rollback for a group of descriptors.
+ The feature is over engineered and not needed for `CoreDb`, neither
is it complete (some convergence features missing.)
* Add debugging helpers to `Kvt`
also:
Update database iterator, add count variable yield argument similar
to `Aristo`.
* Provide optional destructors for `CoreDb` API
why;
For the upcoming Aristo wrapper, this allows to control when certain
smart destruction and update can take place. The auto destructor works
fine in general when the storage/cache strategy is known and acceptable
when creating descriptors.
* Add update option for `CoreDb` API function `hash()`
why;
The hash function is typically used to get the state root of the MPT.
Due to lazy hashing, this might be not available on the `Aristo` DB.
So the `update` function asks for re-hashing the gurrent state changes
if needed.
* Update API tracking log mode: `info` => `debug
* Use shared `Kvt` descriptor in new Ledger API
why:
No need to create a new descriptor all the time
2023-11-16 19:35:03 +00:00
|
|
|
proc(vid: CoreDbVidRef; update: bool): CoreDbRc[Hash256] {.noRaise.}
|
2023-10-11 19:09:11 +00:00
|
|
|
CoreDbBaseErrorPrintFn* = proc(e: CoreDbErrorRef): string {.noRaise.}
|
|
|
|
CoreDbBaseInitLegaSetupFn* = proc() {.noRaise.}
|
|
|
|
CoreDbBaseRootFn* =
|
|
|
|
proc(root: Hash256; createOk: bool): CoreDbRc[CoreDbVidRef] {.noRaise.}
|
Core db and aristo updates for destructor and tx logic (#1894)
* Disable `TransactionID` related functions from `state_db.nim`
why:
Functions `getCommittedStorage()` and `updateOriginalRoot()` from
the `state_db` module are nowhere used. The emulation of a legacy
`TransactionID` type functionality is administratively expensive to
provide by `Aristo` (the legacy DB version is only partially
implemented, anyway).
As there is no other place where `TransactionID`s are used, they will
not be provided by the `Aristo` variant of the `CoreDb`. For the
legacy DB API, nothing will change.
* Fix copyright headers in source code
* Get rid of compiler warning
* Update Aristo code, remove unused `merge()` variant, export `hashify()`
why:
Adapt to upcoming `CoreDb` wrapper
* Remove synced tx feature from `Aristo`
why:
+ This feature allowed to synchronise transaction methods like begin,
commit, and rollback for a group of descriptors.
+ The feature is over engineered and not needed for `CoreDb`, neither
is it complete (some convergence features missing.)
* Add debugging helpers to `Kvt`
also:
Update database iterator, add count variable yield argument similar
to `Aristo`.
* Provide optional destructors for `CoreDb` API
why;
For the upcoming Aristo wrapper, this allows to control when certain
smart destruction and update can take place. The auto destructor works
fine in general when the storage/cache strategy is known and acceptable
when creating descriptors.
* Add update option for `CoreDb` API function `hash()`
why;
The hash function is typically used to get the state root of the MPT.
Due to lazy hashing, this might be not available on the `Aristo` DB.
So the `update` function asks for re-hashing the gurrent state changes
if needed.
* Update API tracking log mode: `info` => `debug
* Use shared `Kvt` descriptor in new Ledger API
why:
No need to create a new descriptor all the time
2023-11-16 19:35:03 +00:00
|
|
|
CoreDbBaseKvtFn* = proc(
|
|
|
|
saveMode: CoreDbSaveFlags): CoreDbRc[CoreDxKvtRef] {.noRaise.}
|
|
|
|
CoreDbBaseMptFn* = proc(
|
|
|
|
root: CoreDbVidRef; prune: bool; saveMode: CoreDbSaveFlags;
|
|
|
|
): CoreDbRc[CoreDxMptRef] {.noRaise.}
|
|
|
|
CoreDbBaseAccFn* = proc(
|
|
|
|
root: CoreDbVidRef; prune: bool; saveMode: CoreDbSaveFlags;
|
|
|
|
): CoreDbRc[CoreDxAccRef] {.noRaise.}
|
2023-10-11 19:09:11 +00:00
|
|
|
CoreDbBaseTxGetIdFn* = proc(): CoreDbRc[CoreDxTxID] {.noRaise.}
|
|
|
|
CoreDbBaseTxBeginFn* = proc(): CoreDbRc[CoreDxTxRef] {.noRaise.}
|
|
|
|
CoreDbBaseCaptFn* =
|
2023-09-26 09:21:13 +00:00
|
|
|
proc(flgs: set[CoreDbCaptFlags]): CoreDbRc[CoreDxCaptRef] {.noRaise.}
|
|
|
|
|
2023-10-11 19:09:11 +00:00
|
|
|
CoreDbBaseFns* = object
|
|
|
|
backendFn*: CoreDbBaseBackendFn
|
|
|
|
destroyFn*: CoreDbBaseDestroyFn
|
|
|
|
vidHashFn*: CoreDbBaseVidHashFn
|
|
|
|
errorPrintFn*: CoreDbBaseErrorPrintFn
|
|
|
|
legacySetupFn*: CoreDbBaseInitLegaSetupFn
|
|
|
|
getRootFn*: CoreDbBaseRootFn
|
2023-09-26 09:21:13 +00:00
|
|
|
|
2023-10-11 19:09:11 +00:00
|
|
|
# Kvt constructor
|
|
|
|
newKvtFn*: CoreDbBaseKvtFn
|
2023-09-26 09:21:13 +00:00
|
|
|
|
2023-10-11 19:09:11 +00:00
|
|
|
# Hexary trie constructors
|
|
|
|
newMptFn*: CoreDbBaseMptFn
|
|
|
|
newAccFn*: CoreDbBaseAccFn
|
2023-09-26 09:21:13 +00:00
|
|
|
|
2023-10-11 19:09:11 +00:00
|
|
|
# Transactions constructors
|
|
|
|
getIdFn*: CoreDbBaseTxGetIdFn
|
|
|
|
beginFn*: CoreDbBaseTxBeginFn
|
2023-09-26 09:21:13 +00:00
|
|
|
|
2023-10-11 19:09:11 +00:00
|
|
|
# capture/tracer constructors
|
|
|
|
captureFn*: CoreDbBaseCaptFn
|
2023-09-26 09:21:13 +00:00
|
|
|
|
|
|
|
|
|
|
|
# --------------------------------------------------
|
|
|
|
# Sub-descriptor: KVT methods
|
|
|
|
# --------------------------------------------------
|
|
|
|
CoreDbKvtBackendFn* = proc(): CoreDbKvtBackendRef {.noRaise.}
|
|
|
|
CoreDbKvtGetFn* = proc(k: openArray[byte]): CoreDbRc[Blob] {.noRaise.}
|
|
|
|
CoreDbKvtDelFn* = proc(k: openArray[byte]): CoreDbRc[void] {.noRaise.}
|
|
|
|
CoreDbKvtPutFn* =
|
|
|
|
proc(k: openArray[byte]; v: openArray[byte]): CoreDbRc[void] {.noRaise.}
|
Core db and aristo updates for destructor and tx logic (#1894)
* Disable `TransactionID` related functions from `state_db.nim`
why:
Functions `getCommittedStorage()` and `updateOriginalRoot()` from
the `state_db` module are nowhere used. The emulation of a legacy
`TransactionID` type functionality is administratively expensive to
provide by `Aristo` (the legacy DB version is only partially
implemented, anyway).
As there is no other place where `TransactionID`s are used, they will
not be provided by the `Aristo` variant of the `CoreDb`. For the
legacy DB API, nothing will change.
* Fix copyright headers in source code
* Get rid of compiler warning
* Update Aristo code, remove unused `merge()` variant, export `hashify()`
why:
Adapt to upcoming `CoreDb` wrapper
* Remove synced tx feature from `Aristo`
why:
+ This feature allowed to synchronise transaction methods like begin,
commit, and rollback for a group of descriptors.
+ The feature is over engineered and not needed for `CoreDb`, neither
is it complete (some convergence features missing.)
* Add debugging helpers to `Kvt`
also:
Update database iterator, add count variable yield argument similar
to `Aristo`.
* Provide optional destructors for `CoreDb` API
why;
For the upcoming Aristo wrapper, this allows to control when certain
smart destruction and update can take place. The auto destructor works
fine in general when the storage/cache strategy is known and acceptable
when creating descriptors.
* Add update option for `CoreDb` API function `hash()`
why;
The hash function is typically used to get the state root of the MPT.
Due to lazy hashing, this might be not available on the `Aristo` DB.
So the `update` function asks for re-hashing the gurrent state changes
if needed.
* Update API tracking log mode: `info` => `debug
* Use shared `Kvt` descriptor in new Ledger API
why:
No need to create a new descriptor all the time
2023-11-16 19:35:03 +00:00
|
|
|
CoreDbKvtDestroyFn* = proc(
|
|
|
|
saveMode: CoreDbSaveFlags): CoreDbRc[void] {.noRaise.}
|
2023-11-08 12:18:32 +00:00
|
|
|
CoreDbKvtHasKeyFn* = proc(k: openArray[byte]): CoreDbRc[bool] {.noRaise.}
|
2023-09-26 09:21:13 +00:00
|
|
|
CoreDbKvtPairsIt* = iterator(): (Blob,Blob) {.apiRaise.}
|
|
|
|
|
|
|
|
CoreDbKvtFns* = object
|
|
|
|
## Methods for key-value table
|
|
|
|
backendFn*: CoreDbKvtBackendFn
|
|
|
|
getFn*: CoreDbKvtGetFn
|
|
|
|
delFn*: CoreDbKvtDelFn
|
|
|
|
putFn*: CoreDbKvtPutFn
|
2023-11-08 12:18:32 +00:00
|
|
|
hasKeyFn*: CoreDbKvtHasKeyFn
|
Core db and aristo updates for destructor and tx logic (#1894)
* Disable `TransactionID` related functions from `state_db.nim`
why:
Functions `getCommittedStorage()` and `updateOriginalRoot()` from
the `state_db` module are nowhere used. The emulation of a legacy
`TransactionID` type functionality is administratively expensive to
provide by `Aristo` (the legacy DB version is only partially
implemented, anyway).
As there is no other place where `TransactionID`s are used, they will
not be provided by the `Aristo` variant of the `CoreDb`. For the
legacy DB API, nothing will change.
* Fix copyright headers in source code
* Get rid of compiler warning
* Update Aristo code, remove unused `merge()` variant, export `hashify()`
why:
Adapt to upcoming `CoreDb` wrapper
* Remove synced tx feature from `Aristo`
why:
+ This feature allowed to synchronise transaction methods like begin,
commit, and rollback for a group of descriptors.
+ The feature is over engineered and not needed for `CoreDb`, neither
is it complete (some convergence features missing.)
* Add debugging helpers to `Kvt`
also:
Update database iterator, add count variable yield argument similar
to `Aristo`.
* Provide optional destructors for `CoreDb` API
why;
For the upcoming Aristo wrapper, this allows to control when certain
smart destruction and update can take place. The auto destructor works
fine in general when the storage/cache strategy is known and acceptable
when creating descriptors.
* Add update option for `CoreDb` API function `hash()`
why;
The hash function is typically used to get the state root of the MPT.
Due to lazy hashing, this might be not available on the `Aristo` DB.
So the `update` function asks for re-hashing the gurrent state changes
if needed.
* Update API tracking log mode: `info` => `debug
* Use shared `Kvt` descriptor in new Ledger API
why:
No need to create a new descriptor all the time
2023-11-16 19:35:03 +00:00
|
|
|
destroyFn*: CoreDbKvtDestroyFn
|
2023-09-26 09:21:13 +00:00
|
|
|
pairsIt*: CoreDbKvtPairsIt
|
|
|
|
|
|
|
|
|
|
|
|
# --------------------------------------------------
|
2023-10-11 19:09:11 +00:00
|
|
|
# Sub-descriptor: generic Mpt/hexary trie methods
|
2023-09-26 09:21:13 +00:00
|
|
|
# --------------------------------------------------
|
|
|
|
CoreDbMptBackendFn* = proc(): CoreDbMptBackendRef {.noRaise.}
|
2023-10-11 19:09:11 +00:00
|
|
|
CoreDbMptFetchFn* =
|
2023-09-26 09:21:13 +00:00
|
|
|
proc(k: openArray[byte]): CoreDbRc[Blob] {.noRaise.}
|
2023-10-11 19:09:11 +00:00
|
|
|
CoreDbMptFetchAccountFn* =
|
|
|
|
proc(k: openArray[byte]): CoreDbRc[CoreDbAccount] {.noRaise.}
|
|
|
|
CoreDbMptDeleteFn* =
|
2023-09-26 09:21:13 +00:00
|
|
|
proc(k: openArray[byte]): CoreDbRc[void] {.noRaise.}
|
2023-10-11 19:09:11 +00:00
|
|
|
CoreDbMptMergeFn* =
|
|
|
|
proc(k: openArray[byte]; v: openArray[byte]): CoreDbRc[void] {.noRaise.}
|
|
|
|
CoreDbMptMergeAccountFn* =
|
|
|
|
proc(k: openArray[byte]; v: CoreDbAccount): CoreDbRc[void] {.noRaise.}
|
2023-11-08 12:18:32 +00:00
|
|
|
CoreDbMptHasPathFn* = proc(k: openArray[byte]): CoreDbRc[bool] {.noRaise.}
|
2023-10-11 19:09:11 +00:00
|
|
|
CoreDbMptRootVidFn* = proc(): CoreDbVidRef {.noRaise.}
|
2023-09-26 09:21:13 +00:00
|
|
|
CoreDbMptIsPruningFn* = proc(): bool {.noRaise.}
|
Core db and aristo updates for destructor and tx logic (#1894)
* Disable `TransactionID` related functions from `state_db.nim`
why:
Functions `getCommittedStorage()` and `updateOriginalRoot()` from
the `state_db` module are nowhere used. The emulation of a legacy
`TransactionID` type functionality is administratively expensive to
provide by `Aristo` (the legacy DB version is only partially
implemented, anyway).
As there is no other place where `TransactionID`s are used, they will
not be provided by the `Aristo` variant of the `CoreDb`. For the
legacy DB API, nothing will change.
* Fix copyright headers in source code
* Get rid of compiler warning
* Update Aristo code, remove unused `merge()` variant, export `hashify()`
why:
Adapt to upcoming `CoreDb` wrapper
* Remove synced tx feature from `Aristo`
why:
+ This feature allowed to synchronise transaction methods like begin,
commit, and rollback for a group of descriptors.
+ The feature is over engineered and not needed for `CoreDb`, neither
is it complete (some convergence features missing.)
* Add debugging helpers to `Kvt`
also:
Update database iterator, add count variable yield argument similar
to `Aristo`.
* Provide optional destructors for `CoreDb` API
why;
For the upcoming Aristo wrapper, this allows to control when certain
smart destruction and update can take place. The auto destructor works
fine in general when the storage/cache strategy is known and acceptable
when creating descriptors.
* Add update option for `CoreDb` API function `hash()`
why;
The hash function is typically used to get the state root of the MPT.
Due to lazy hashing, this might be not available on the `Aristo` DB.
So the `update` function asks for re-hashing the gurrent state changes
if needed.
* Update API tracking log mode: `info` => `debug
* Use shared `Kvt` descriptor in new Ledger API
why:
No need to create a new descriptor all the time
2023-11-16 19:35:03 +00:00
|
|
|
CoreDbMptDestroyFn* = proc(
|
|
|
|
saveMode: CoreDbSaveFlags): CoreDbRc[void] {.noRaise.}
|
2023-09-26 09:21:13 +00:00
|
|
|
CoreDbMptPairsIt* = iterator(): (Blob,Blob) {.apiRaise.}
|
|
|
|
CoreDbMptReplicateIt* = iterator(): (Blob,Blob) {.apiRaise.}
|
|
|
|
|
|
|
|
CoreDbMptFns* = object
|
|
|
|
## Methods for trie objects
|
2023-10-11 19:09:11 +00:00
|
|
|
backendFn*: CoreDbMptBackendFn
|
|
|
|
fetchFn*: CoreDbMptFetchFn
|
|
|
|
deleteFn*: CoreDbMptDeleteFn
|
|
|
|
mergeFn*: CoreDbMptMergeFn
|
2023-11-08 12:18:32 +00:00
|
|
|
hasPathFn*: CoreDbMptHasPathFn
|
2023-10-11 19:09:11 +00:00
|
|
|
rootVidFn*: CoreDbMptRootVidFn
|
Core db and aristo updates for destructor and tx logic (#1894)
* Disable `TransactionID` related functions from `state_db.nim`
why:
Functions `getCommittedStorage()` and `updateOriginalRoot()` from
the `state_db` module are nowhere used. The emulation of a legacy
`TransactionID` type functionality is administratively expensive to
provide by `Aristo` (the legacy DB version is only partially
implemented, anyway).
As there is no other place where `TransactionID`s are used, they will
not be provided by the `Aristo` variant of the `CoreDb`. For the
legacy DB API, nothing will change.
* Fix copyright headers in source code
* Get rid of compiler warning
* Update Aristo code, remove unused `merge()` variant, export `hashify()`
why:
Adapt to upcoming `CoreDb` wrapper
* Remove synced tx feature from `Aristo`
why:
+ This feature allowed to synchronise transaction methods like begin,
commit, and rollback for a group of descriptors.
+ The feature is over engineered and not needed for `CoreDb`, neither
is it complete (some convergence features missing.)
* Add debugging helpers to `Kvt`
also:
Update database iterator, add count variable yield argument similar
to `Aristo`.
* Provide optional destructors for `CoreDb` API
why;
For the upcoming Aristo wrapper, this allows to control when certain
smart destruction and update can take place. The auto destructor works
fine in general when the storage/cache strategy is known and acceptable
when creating descriptors.
* Add update option for `CoreDb` API function `hash()`
why;
The hash function is typically used to get the state root of the MPT.
Due to lazy hashing, this might be not available on the `Aristo` DB.
So the `update` function asks for re-hashing the gurrent state changes
if needed.
* Update API tracking log mode: `info` => `debug
* Use shared `Kvt` descriptor in new Ledger API
why:
No need to create a new descriptor all the time
2023-11-16 19:35:03 +00:00
|
|
|
isPruningFn*: CoreDbMptIsPruningFn
|
|
|
|
destroyFn*: CoreDbMptDestroyFn
|
2023-10-11 19:09:11 +00:00
|
|
|
pairsIt*: CoreDbMptPairsIt
|
|
|
|
replicateIt*: CoreDbMptReplicateIt
|
|
|
|
|
|
|
|
|
|
|
|
# ----------------------------------------------------
|
|
|
|
# Sub-descriptor: Mpt/hexary trie methods for accounts
|
|
|
|
# ------------------------------------------------------
|
|
|
|
CoreDbAccBackendFn* = proc(): CoreDbAccBackendRef {.noRaise.}
|
|
|
|
CoreDbAccFetchFn* = proc(k: EthAddress): CoreDbRc[CoreDbAccount] {.noRaise.}
|
|
|
|
CoreDbAccDeleteFn* = proc(k: EthAddress): CoreDbRc[void] {.noRaise.}
|
|
|
|
CoreDbAccMergeFn* =
|
|
|
|
proc(k: EthAddress; v: CoreDbAccount): CoreDbRc[void] {.noRaise.}
|
2023-11-08 12:18:32 +00:00
|
|
|
CoreDbAccHasPathFn* = proc(k: EthAddress): CoreDbRc[bool] {.noRaise.}
|
2023-10-11 19:09:11 +00:00
|
|
|
CoreDbAccRootVidFn* = proc(): CoreDbVidRef {.noRaise.}
|
|
|
|
CoreDbAccIsPruningFn* = proc(): bool {.noRaise.}
|
Core db and aristo updates for destructor and tx logic (#1894)
* Disable `TransactionID` related functions from `state_db.nim`
why:
Functions `getCommittedStorage()` and `updateOriginalRoot()` from
the `state_db` module are nowhere used. The emulation of a legacy
`TransactionID` type functionality is administratively expensive to
provide by `Aristo` (the legacy DB version is only partially
implemented, anyway).
As there is no other place where `TransactionID`s are used, they will
not be provided by the `Aristo` variant of the `CoreDb`. For the
legacy DB API, nothing will change.
* Fix copyright headers in source code
* Get rid of compiler warning
* Update Aristo code, remove unused `merge()` variant, export `hashify()`
why:
Adapt to upcoming `CoreDb` wrapper
* Remove synced tx feature from `Aristo`
why:
+ This feature allowed to synchronise transaction methods like begin,
commit, and rollback for a group of descriptors.
+ The feature is over engineered and not needed for `CoreDb`, neither
is it complete (some convergence features missing.)
* Add debugging helpers to `Kvt`
also:
Update database iterator, add count variable yield argument similar
to `Aristo`.
* Provide optional destructors for `CoreDb` API
why;
For the upcoming Aristo wrapper, this allows to control when certain
smart destruction and update can take place. The auto destructor works
fine in general when the storage/cache strategy is known and acceptable
when creating descriptors.
* Add update option for `CoreDb` API function `hash()`
why;
The hash function is typically used to get the state root of the MPT.
Due to lazy hashing, this might be not available on the `Aristo` DB.
So the `update` function asks for re-hashing the gurrent state changes
if needed.
* Update API tracking log mode: `info` => `debug
* Use shared `Kvt` descriptor in new Ledger API
why:
No need to create a new descriptor all the time
2023-11-16 19:35:03 +00:00
|
|
|
CoreDbAccDestroyFn* = proc(
|
|
|
|
saveMode: CoreDbSaveFlags): CoreDbRc[void] {.noRaise.}
|
2023-10-11 19:09:11 +00:00
|
|
|
|
|
|
|
CoreDbAccFns* = object
|
|
|
|
## Methods for trie objects
|
|
|
|
backendFn*: CoreDbAccBackendFn
|
|
|
|
fetchFn*: CoreDbAccFetchFn
|
|
|
|
deleteFn*: CoreDbAccDeleteFn
|
|
|
|
mergeFn*: CoreDbAccMergeFn
|
2023-11-08 12:18:32 +00:00
|
|
|
hasPathFn*: CoreDbAccHasPathFn
|
2023-10-11 19:09:11 +00:00
|
|
|
rootVidFn*: CoreDbAccRootVidFn
|
|
|
|
isPruningFn*: CoreDbAccIsPruningFn
|
Core db and aristo updates for destructor and tx logic (#1894)
* Disable `TransactionID` related functions from `state_db.nim`
why:
Functions `getCommittedStorage()` and `updateOriginalRoot()` from
the `state_db` module are nowhere used. The emulation of a legacy
`TransactionID` type functionality is administratively expensive to
provide by `Aristo` (the legacy DB version is only partially
implemented, anyway).
As there is no other place where `TransactionID`s are used, they will
not be provided by the `Aristo` variant of the `CoreDb`. For the
legacy DB API, nothing will change.
* Fix copyright headers in source code
* Get rid of compiler warning
* Update Aristo code, remove unused `merge()` variant, export `hashify()`
why:
Adapt to upcoming `CoreDb` wrapper
* Remove synced tx feature from `Aristo`
why:
+ This feature allowed to synchronise transaction methods like begin,
commit, and rollback for a group of descriptors.
+ The feature is over engineered and not needed for `CoreDb`, neither
is it complete (some convergence features missing.)
* Add debugging helpers to `Kvt`
also:
Update database iterator, add count variable yield argument similar
to `Aristo`.
* Provide optional destructors for `CoreDb` API
why;
For the upcoming Aristo wrapper, this allows to control when certain
smart destruction and update can take place. The auto destructor works
fine in general when the storage/cache strategy is known and acceptable
when creating descriptors.
* Add update option for `CoreDb` API function `hash()`
why;
The hash function is typically used to get the state root of the MPT.
Due to lazy hashing, this might be not available on the `Aristo` DB.
So the `update` function asks for re-hashing the gurrent state changes
if needed.
* Update API tracking log mode: `info` => `debug
* Use shared `Kvt` descriptor in new Ledger API
why:
No need to create a new descriptor all the time
2023-11-16 19:35:03 +00:00
|
|
|
destroyFn*: CoreDbAccDestroyFn
|
2023-09-26 09:21:13 +00:00
|
|
|
|
|
|
|
# --------------------------------------------------
|
|
|
|
# Sub-descriptor: Transaction frame management
|
|
|
|
# --------------------------------------------------
|
|
|
|
CoreDbTxCommitFn* = proc(applyDeletes: bool): CoreDbRc[void] {.noRaise.}
|
|
|
|
CoreDbTxRollbackFn* = proc(): CoreDbRc[void] {.noRaise.}
|
|
|
|
CoreDbTxDisposeFn* = proc(): CoreDbRc[void] {.noRaise.}
|
|
|
|
CoreDbTxSafeDisposeFn* = proc(): CoreDbRc[void] {.noRaise.}
|
|
|
|
|
|
|
|
CoreDbTxFns* = object
|
|
|
|
commitFn*: CoreDbTxCommitFn
|
|
|
|
rollbackFn*: CoreDbTxRollbackFn
|
|
|
|
disposeFn*: CoreDbTxDisposeFn
|
|
|
|
safeDisposeFn*: CoreDbTxSafeDisposeFn
|
|
|
|
|
|
|
|
# --------------------------------------------------
|
|
|
|
# Sub-descriptor: Transaction ID management
|
|
|
|
# --------------------------------------------------
|
|
|
|
CoreDbTxIdSetIdFn* = proc(): CoreDbRc[void] {.noRaise.}
|
|
|
|
CoreDbTxIdActionFn* = proc() {.noRaise.}
|
|
|
|
CoreDbTxIdRoWrapperFn* =
|
|
|
|
proc(action: CoreDbTxIdActionFn): CoreDbRc[void] {.noRaise.}
|
|
|
|
CoreDbTxIdFns* = object
|
|
|
|
roWrapperFn*: CoreDbTxIdRoWrapperFn
|
|
|
|
|
|
|
|
|
|
|
|
# --------------------------------------------------
|
|
|
|
# Sub-descriptor: capture recorder methods
|
|
|
|
# --------------------------------------------------
|
|
|
|
CoreDbCaptRecorderFn* = proc(): CoreDbRc[CoreDbRef] {.noRaise.}
|
2023-10-11 19:09:11 +00:00
|
|
|
CoreDbCaptLogDbFn* = proc(): CoreDbRc[CoreDbRef] {.noRaise.}
|
2023-09-26 09:21:13 +00:00
|
|
|
CoreDbCaptFlagsFn* = proc(): set[CoreDbCaptFlags] {.noRaise.}
|
|
|
|
|
|
|
|
CoreDbCaptFns* = object
|
|
|
|
recorderFn*: CoreDbCaptRecorderFn
|
2023-10-11 19:09:11 +00:00
|
|
|
logDbFn*: CoreDbCaptLogDbFn
|
2023-09-26 09:21:13 +00:00
|
|
|
getFlagsFn*: CoreDbCaptFlagsFn
|
|
|
|
|
|
|
|
# --------------------------------------------------
|
|
|
|
# Production descriptors
|
|
|
|
# --------------------------------------------------
|
|
|
|
CoreDbRef* = ref object of RootRef
|
|
|
|
## Database descriptor
|
2023-10-25 14:03:09 +00:00
|
|
|
dbType*: CoreDbType ## Type of database backend
|
|
|
|
trackLegaApi*: bool ## Debugging support
|
|
|
|
trackNewApi*: bool ## Debugging support
|
|
|
|
trackLedgerApi*: bool ## Debugging suggestion for subsequent ledger
|
|
|
|
localDbOnly*: bool ## Debugging, suggestion to ignore async fetch
|
2023-10-11 19:09:11 +00:00
|
|
|
methods*: CoreDbBaseFns
|
2023-09-26 09:21:13 +00:00
|
|
|
|
2023-10-02 18:05:17 +00:00
|
|
|
CoreDbErrorRef* = ref object of RootRef
|
2023-09-26 09:21:13 +00:00
|
|
|
## Generic error object
|
2023-10-11 19:09:11 +00:00
|
|
|
error*: CoreDbErrorCode
|
2023-09-26 09:21:13 +00:00
|
|
|
parent*: CoreDbRef
|
|
|
|
|
|
|
|
CoreDbBackendRef* = ref object of RootRef
|
|
|
|
## Backend wrapper for direct backend access
|
|
|
|
parent*: CoreDbRef
|
|
|
|
|
|
|
|
CoreDbKvtBackendRef* = ref object of RootRef
|
|
|
|
## Backend wrapper for direct backend access
|
|
|
|
parent*: CoreDbRef
|
|
|
|
|
|
|
|
CoreDbMptBackendRef* = ref object of RootRef
|
|
|
|
## Backend wrapper for direct backend access
|
|
|
|
parent*: CoreDbRef
|
|
|
|
|
2023-10-11 19:09:11 +00:00
|
|
|
CoreDbAccBackendRef* = ref object of RootRef
|
|
|
|
## Backend wrapper for direct backend access
|
|
|
|
parent*: CoreDbRef
|
|
|
|
|
Core db and aristo updates for destructor and tx logic (#1894)
* Disable `TransactionID` related functions from `state_db.nim`
why:
Functions `getCommittedStorage()` and `updateOriginalRoot()` from
the `state_db` module are nowhere used. The emulation of a legacy
`TransactionID` type functionality is administratively expensive to
provide by `Aristo` (the legacy DB version is only partially
implemented, anyway).
As there is no other place where `TransactionID`s are used, they will
not be provided by the `Aristo` variant of the `CoreDb`. For the
legacy DB API, nothing will change.
* Fix copyright headers in source code
* Get rid of compiler warning
* Update Aristo code, remove unused `merge()` variant, export `hashify()`
why:
Adapt to upcoming `CoreDb` wrapper
* Remove synced tx feature from `Aristo`
why:
+ This feature allowed to synchronise transaction methods like begin,
commit, and rollback for a group of descriptors.
+ The feature is over engineered and not needed for `CoreDb`, neither
is it complete (some convergence features missing.)
* Add debugging helpers to `Kvt`
also:
Update database iterator, add count variable yield argument similar
to `Aristo`.
* Provide optional destructors for `CoreDb` API
why;
For the upcoming Aristo wrapper, this allows to control when certain
smart destruction and update can take place. The auto destructor works
fine in general when the storage/cache strategy is known and acceptable
when creating descriptors.
* Add update option for `CoreDb` API function `hash()`
why;
The hash function is typically used to get the state root of the MPT.
Due to lazy hashing, this might be not available on the `Aristo` DB.
So the `update` function asks for re-hashing the gurrent state changes
if needed.
* Update API tracking log mode: `info` => `debug
* Use shared `Kvt` descriptor in new Ledger API
why:
No need to create a new descriptor all the time
2023-11-16 19:35:03 +00:00
|
|
|
CoreDxKvtRef* = ref object of RootRef
|
2023-09-26 09:21:13 +00:00
|
|
|
## Statically initialised Key-Value pair table living in `CoreDbRef`
|
|
|
|
parent*: CoreDbRef
|
|
|
|
methods*: CoreDbKvtFns
|
|
|
|
|
Core db and aristo updates for destructor and tx logic (#1894)
* Disable `TransactionID` related functions from `state_db.nim`
why:
Functions `getCommittedStorage()` and `updateOriginalRoot()` from
the `state_db` module are nowhere used. The emulation of a legacy
`TransactionID` type functionality is administratively expensive to
provide by `Aristo` (the legacy DB version is only partially
implemented, anyway).
As there is no other place where `TransactionID`s are used, they will
not be provided by the `Aristo` variant of the `CoreDb`. For the
legacy DB API, nothing will change.
* Fix copyright headers in source code
* Get rid of compiler warning
* Update Aristo code, remove unused `merge()` variant, export `hashify()`
why:
Adapt to upcoming `CoreDb` wrapper
* Remove synced tx feature from `Aristo`
why:
+ This feature allowed to synchronise transaction methods like begin,
commit, and rollback for a group of descriptors.
+ The feature is over engineered and not needed for `CoreDb`, neither
is it complete (some convergence features missing.)
* Add debugging helpers to `Kvt`
also:
Update database iterator, add count variable yield argument similar
to `Aristo`.
* Provide optional destructors for `CoreDb` API
why;
For the upcoming Aristo wrapper, this allows to control when certain
smart destruction and update can take place. The auto destructor works
fine in general when the storage/cache strategy is known and acceptable
when creating descriptors.
* Add update option for `CoreDb` API function `hash()`
why;
The hash function is typically used to get the state root of the MPT.
Due to lazy hashing, this might be not available on the `Aristo` DB.
So the `update` function asks for re-hashing the gurrent state changes
if needed.
* Update API tracking log mode: `info` => `debug
* Use shared `Kvt` descriptor in new Ledger API
why:
No need to create a new descriptor all the time
2023-11-16 19:35:03 +00:00
|
|
|
CoreDxMptRef* = ref object of RootRef
|
2023-09-26 09:21:13 +00:00
|
|
|
## Hexary/Merkle-Patricia tree derived from `CoreDbRef`, will be
|
|
|
|
## initialised on-the-fly.
|
|
|
|
parent*: CoreDbRef
|
|
|
|
methods*: CoreDbMptFns
|
|
|
|
|
Core db and aristo updates for destructor and tx logic (#1894)
* Disable `TransactionID` related functions from `state_db.nim`
why:
Functions `getCommittedStorage()` and `updateOriginalRoot()` from
the `state_db` module are nowhere used. The emulation of a legacy
`TransactionID` type functionality is administratively expensive to
provide by `Aristo` (the legacy DB version is only partially
implemented, anyway).
As there is no other place where `TransactionID`s are used, they will
not be provided by the `Aristo` variant of the `CoreDb`. For the
legacy DB API, nothing will change.
* Fix copyright headers in source code
* Get rid of compiler warning
* Update Aristo code, remove unused `merge()` variant, export `hashify()`
why:
Adapt to upcoming `CoreDb` wrapper
* Remove synced tx feature from `Aristo`
why:
+ This feature allowed to synchronise transaction methods like begin,
commit, and rollback for a group of descriptors.
+ The feature is over engineered and not needed for `CoreDb`, neither
is it complete (some convergence features missing.)
* Add debugging helpers to `Kvt`
also:
Update database iterator, add count variable yield argument similar
to `Aristo`.
* Provide optional destructors for `CoreDb` API
why;
For the upcoming Aristo wrapper, this allows to control when certain
smart destruction and update can take place. The auto destructor works
fine in general when the storage/cache strategy is known and acceptable
when creating descriptors.
* Add update option for `CoreDb` API function `hash()`
why;
The hash function is typically used to get the state root of the MPT.
Due to lazy hashing, this might be not available on the `Aristo` DB.
So the `update` function asks for re-hashing the gurrent state changes
if needed.
* Update API tracking log mode: `info` => `debug
* Use shared `Kvt` descriptor in new Ledger API
why:
No need to create a new descriptor all the time
2023-11-16 19:35:03 +00:00
|
|
|
CoreDxAccRef* = ref object of RootRef
|
2023-10-11 19:09:11 +00:00
|
|
|
## Similar to `CoreDxKvtRef`, only dealing with `CoreDbAccount` data
|
|
|
|
## rather than `Blob` values.
|
|
|
|
parent*: CoreDbRef
|
|
|
|
methods*: CoreDbAccFns
|
|
|
|
|
|
|
|
CoreDbVidRef* = ref object of RootRef
|
|
|
|
## Generic state root: `Hash256` for legacy, `VertexID` for Aristo. This
|
|
|
|
## object makes only sense in the context od an *MPT*.
|
|
|
|
parent*: CoreDbRef
|
|
|
|
ready*: bool ## Must be set `true` to enable
|
|
|
|
|
2023-09-26 09:21:13 +00:00
|
|
|
CoreDxPhkRef* = ref object
|
|
|
|
## Similar to `CoreDbMptRef` but with pre-hashed keys. That is, any
|
2023-10-11 19:09:11 +00:00
|
|
|
## argument key for `merge()`, `fetch()` etc. will be hashed first
|
|
|
|
## before being applied.
|
2023-09-26 09:21:13 +00:00
|
|
|
fromMpt*: CoreDxMptRef
|
|
|
|
methods*: CoreDbMptFns
|
|
|
|
|
|
|
|
CoreDxTxRef* = ref object
|
|
|
|
## Transaction descriptor derived from `CoreDbRef`
|
|
|
|
parent*: CoreDbRef
|
|
|
|
methods*: CoreDbTxFns
|
|
|
|
|
|
|
|
CoreDxTxID* = ref object
|
|
|
|
## Transaction ID descriptor derived from `CoreDbRef`
|
|
|
|
parent*: CoreDbRef
|
|
|
|
methods*: CoreDbTxIdFns
|
|
|
|
|
|
|
|
CoreDxCaptRef* = ref object
|
|
|
|
## Db transaction tracer derived from `CoreDbRef`
|
|
|
|
parent*: CoreDbRef
|
|
|
|
methods*: CoreDbCaptFns
|
|
|
|
|
|
|
|
# ------------------------------------------------------------------------------
|
|
|
|
# End
|
|
|
|
# ------------------------------------------------------------------------------
|