2024-02-29 21:10:24 +00:00
|
|
|
# nimbus-eth1
|
|
|
|
# Copyright (c) 2024 Status Research & Development GmbH
|
|
|
|
# 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.
|
|
|
|
|
|
|
|
## Stackable API for `Aristo`
|
|
|
|
## ==========================
|
|
|
|
|
|
|
|
|
|
|
|
import
|
2024-06-03 20:10:35 +00:00
|
|
|
std/times,
|
2024-06-22 20:33:37 +00:00
|
|
|
eth/common,
|
2024-02-29 21:10:24 +00:00
|
|
|
results,
|
2024-03-14 22:17:43 +00:00
|
|
|
./aristo_desc/desc_backend,
|
|
|
|
./aristo_init/memory_db,
|
2024-08-07 11:30:55 +00:00
|
|
|
"."/[aristo_delete, aristo_desc, aristo_fetch, aristo_init, aristo_merge,
|
|
|
|
aristo_part, aristo_path, aristo_profile, aristo_tx]
|
2024-02-29 21:10:24 +00:00
|
|
|
|
|
|
|
export
|
|
|
|
AristoDbProfListRef
|
|
|
|
|
2024-03-07 19:24:05 +00:00
|
|
|
const
|
|
|
|
AutoValidateApiHooks = defined(release).not
|
|
|
|
## No validatinon needed for production suite.
|
|
|
|
|
2024-04-19 18:37:27 +00:00
|
|
|
AristoPersistentBackendOk = AutoValidateApiHooks # and false
|
2024-03-14 22:17:43 +00:00
|
|
|
## Set true for persistent backend profiling (which needs an extra
|
|
|
|
## link library.)
|
|
|
|
|
|
|
|
when AristoPersistentBackendOk:
|
|
|
|
import ./aristo_init/rocks_db
|
|
|
|
|
2024-02-29 21:10:24 +00:00
|
|
|
# Annotation helper(s)
|
|
|
|
{.pragma: noRaise, gcsafe, raises: [].}
|
|
|
|
|
|
|
|
type
|
|
|
|
AristoApiCommitFn* =
|
|
|
|
proc(tx: AristoTxRef;
|
|
|
|
): Result[void,AristoError]
|
|
|
|
{.noRaise.}
|
|
|
|
## Given a *top level* handle, this function accepts all database
|
|
|
|
## operations performed through this handle and merges it to the
|
|
|
|
## previous layer. The previous transaction is returned if there
|
|
|
|
## was any.
|
|
|
|
|
2024-06-27 09:01:26 +00:00
|
|
|
AristoApiDeleteAccountRecordFn* =
|
2024-06-18 19:30:01 +00:00
|
|
|
proc(db: AristoDbRef;
|
2024-10-01 21:03:10 +00:00
|
|
|
accPath: Hash32;
|
2024-06-18 19:30:01 +00:00
|
|
|
): Result[void,AristoError]
|
|
|
|
{.noRaise.}
|
|
|
|
## Delete the account leaf entry addressed by the argument `path`. If
|
|
|
|
## this leaf entry referres to a storage tree, this one will be deleted
|
|
|
|
## as well.
|
|
|
|
|
|
|
|
AristoApiDeleteStorageDataFn* =
|
|
|
|
proc(db: AristoDbRef;
|
2024-10-01 21:03:10 +00:00
|
|
|
accPath: Hash32;
|
|
|
|
stoPath: Hash32;
|
2024-06-18 19:30:01 +00:00
|
|
|
): Result[bool,AristoError]
|
2024-02-29 21:10:24 +00:00
|
|
|
{.noRaise.}
|
2024-06-18 19:30:01 +00:00
|
|
|
## For a given account argument `accPath`, this function deletes the
|
2024-06-27 19:21:01 +00:00
|
|
|
## argument `stoPath` from the associated storage tree (if any, at all.)
|
|
|
|
## If the if the argument `stoPath` deleted was the last one on the
|
|
|
|
## storage tree, account leaf referred to by `accPath` will be updated
|
|
|
|
## so that it will not refer to a storage tree anymore. In the latter
|
|
|
|
## case only the function will return `true`.
|
2024-06-18 19:30:01 +00:00
|
|
|
|
|
|
|
AristoApiDeleteStorageTreeFn* =
|
|
|
|
proc(db: AristoDbRef;
|
2024-10-01 21:03:10 +00:00
|
|
|
accPath: Hash32;
|
2024-06-18 19:30:01 +00:00
|
|
|
): Result[void,AristoError]
|
|
|
|
{.noRaise.}
|
|
|
|
## Variant of `deleteStorageData()` for purging the whole storage tree
|
|
|
|
## associated to the account argument `accPath`.
|
2024-02-29 21:10:24 +00:00
|
|
|
|
2024-05-31 17:32:22 +00:00
|
|
|
AristoApiFetchLastSavedStateFn* =
|
|
|
|
proc(db: AristoDbRef
|
|
|
|
): Result[SavedState,AristoError]
|
|
|
|
{.noRaise.}
|
|
|
|
## The function returns the state of the last saved state. This is a
|
|
|
|
## Merkle hash tag for vertex with ID 1 and a bespoke `uint64` identifier
|
|
|
|
## (may be interpreted as block number.)
|
|
|
|
|
2024-06-27 09:01:26 +00:00
|
|
|
AristoApiFetchAccountRecordFn* =
|
2024-06-19 12:40:00 +00:00
|
|
|
proc(db: AristoDbRef;
|
2024-10-01 21:03:10 +00:00
|
|
|
accPath: Hash32;
|
2024-06-19 12:40:00 +00:00
|
|
|
): Result[AristoAccount,AristoError]
|
|
|
|
{.noRaise.}
|
2024-06-27 19:21:01 +00:00
|
|
|
## Fetch an account record from the database indexed by `accPath`.
|
2024-06-19 12:40:00 +00:00
|
|
|
|
2024-11-22 13:15:35 +00:00
|
|
|
AristoApiFetchStateRootFn* =
|
2024-06-27 09:01:26 +00:00
|
|
|
proc(db: AristoDbRef;
|
2024-10-01 21:03:10 +00:00
|
|
|
): Result[Hash32,AristoError]
|
2024-06-27 09:01:26 +00:00
|
|
|
{.noRaise.}
|
2024-11-22 13:15:35 +00:00
|
|
|
## Fetch the Merkle hash of the account root.
|
2024-06-27 09:01:26 +00:00
|
|
|
|
2024-06-19 12:40:00 +00:00
|
|
|
AristoApiFetchStorageDataFn* =
|
|
|
|
proc(db: AristoDbRef;
|
2024-10-01 21:03:10 +00:00
|
|
|
accPath: Hash32;
|
|
|
|
stoPath: Hash32;
|
2024-11-01 19:06:26 +00:00
|
|
|
): Result[UInt256,AristoError]
|
2024-02-29 21:10:24 +00:00
|
|
|
{.noRaise.}
|
2024-06-19 12:40:00 +00:00
|
|
|
## For a storage tree related to account `accPath`, fetch the data
|
2024-06-27 19:21:01 +00:00
|
|
|
## record from the database indexed by `stoPath`.
|
2024-02-29 21:10:24 +00:00
|
|
|
|
2024-10-27 18:56:28 +00:00
|
|
|
AristoApiFetchStorageRootFn* =
|
2024-06-27 09:01:26 +00:00
|
|
|
proc(db: AristoDbRef;
|
2024-10-01 21:03:10 +00:00
|
|
|
accPath: Hash32;
|
|
|
|
): Result[Hash32,AristoError]
|
2024-06-27 09:01:26 +00:00
|
|
|
{.noRaise.}
|
2024-11-22 13:15:35 +00:00
|
|
|
## Fetch the Merkle hash of the storage root related to `accPath`.
|
2024-06-27 09:01:26 +00:00
|
|
|
|
2024-02-29 21:10:24 +00:00
|
|
|
AristoApiFinishFn* =
|
|
|
|
proc(db: AristoDbRef;
|
2024-06-14 11:19:48 +00:00
|
|
|
eradicate = false;
|
2024-02-29 21:10:24 +00:00
|
|
|
) {.noRaise.}
|
2024-06-14 11:19:48 +00:00
|
|
|
## Backend destructor. The argument `eradicate` indicates that a full
|
2024-02-29 21:10:24 +00:00
|
|
|
## database deletion is requested. If set `false` the outcome might
|
|
|
|
## differ depending on the type of backend (e.g. the `BackendMemory`
|
2024-06-14 11:19:48 +00:00
|
|
|
## backend will always eradicate on close.)
|
2024-02-29 21:10:24 +00:00
|
|
|
##
|
|
|
|
## In case of distributed descriptors accessing the same backend, all
|
|
|
|
## distributed descriptors will be destroyed.
|
|
|
|
##
|
|
|
|
## This distructor may be used on already *destructed* descriptors.
|
|
|
|
|
|
|
|
AristoApiForgetFn* =
|
|
|
|
proc(db: AristoDbRef;
|
|
|
|
): Result[void,AristoError]
|
|
|
|
{.noRaise.}
|
|
|
|
## Destruct the non centre argument `db` descriptor (see comments on
|
|
|
|
## `reCentre()` for details.)
|
|
|
|
##
|
|
|
|
## A non centre descriptor should always be destructed after use (see
|
|
|
|
## also# comments on `fork()`.)
|
|
|
|
|
|
|
|
AristoApiHashifyFn* =
|
|
|
|
proc(db: AristoDbRef;
|
|
|
|
): Result[void,(VertexID,AristoError)]
|
|
|
|
{.noRaise.}
|
|
|
|
## Add keys to the `Patricia Trie` so that it becomes a `Merkle
|
|
|
|
## Patricia Tree`.
|
|
|
|
|
2024-06-19 12:40:00 +00:00
|
|
|
AristoApiHasPathAccountFn* =
|
|
|
|
proc(db: AristoDbRef;
|
2024-10-01 21:03:10 +00:00
|
|
|
accPath: Hash32;
|
2024-06-19 12:40:00 +00:00
|
|
|
): Result[bool,AristoError]
|
|
|
|
{.noRaise.}
|
2024-06-27 19:21:01 +00:00
|
|
|
## For an account record indexed by `accPath` query whether this record
|
2024-06-19 12:40:00 +00:00
|
|
|
## exists on the database.
|
|
|
|
|
|
|
|
AristoApiHasPathStorageFn* =
|
|
|
|
proc(db: AristoDbRef;
|
2024-10-01 21:03:10 +00:00
|
|
|
accPath: Hash32;
|
|
|
|
stoPath: Hash32;
|
2024-06-19 12:40:00 +00:00
|
|
|
): Result[bool,AristoError]
|
2024-02-29 21:10:24 +00:00
|
|
|
{.noRaise.}
|
2024-06-19 12:40:00 +00:00
|
|
|
## For a storage tree related to account `accPath`, query whether the
|
2024-06-27 19:21:01 +00:00
|
|
|
## data record indexed by `stoPath` exists on the database.
|
2024-02-29 21:10:24 +00:00
|
|
|
|
2024-06-27 09:01:26 +00:00
|
|
|
AristoApiHasStorageDataFn* =
|
|
|
|
proc(db: AristoDbRef;
|
2024-10-01 21:03:10 +00:00
|
|
|
accPath: Hash32;
|
2024-06-27 09:01:26 +00:00
|
|
|
): Result[bool,AristoError]
|
|
|
|
{.noRaise.}
|
|
|
|
## For a storage tree related to account `accPath`, query whether there
|
|
|
|
## is a non-empty data storage area at all.
|
|
|
|
|
2024-02-29 21:10:24 +00:00
|
|
|
AristoApiIsTopFn* =
|
|
|
|
proc(tx: AristoTxRef;
|
|
|
|
): bool
|
|
|
|
{.noRaise.}
|
|
|
|
## Getter, returns `true` if the argument `tx` referes to the current
|
|
|
|
## top level transaction.
|
|
|
|
|
2024-12-18 16:03:51 +00:00
|
|
|
AristoApiTxFrameLevelFn* =
|
2024-02-29 21:10:24 +00:00
|
|
|
proc(db: AristoDbRef;
|
|
|
|
): int
|
|
|
|
{.noRaise.}
|
|
|
|
## Getter, non-negative nesting level (i.e. number of pending
|
|
|
|
## transactions)
|
|
|
|
|
2024-06-27 09:01:26 +00:00
|
|
|
AristoApiMergeAccountRecordFn* =
|
2024-02-29 21:10:24 +00:00
|
|
|
proc(db: AristoDbRef;
|
2024-10-01 21:03:10 +00:00
|
|
|
accPath: Hash32;
|
2024-06-27 09:01:26 +00:00
|
|
|
accRec: AristoAccount;
|
2024-06-18 11:14:02 +00:00
|
|
|
): Result[bool,AristoError]
|
|
|
|
{.noRaise.}
|
2024-06-27 09:01:26 +00:00
|
|
|
## Merge the key-value-pair argument `(accKey,accRec)` as an account
|
2024-06-18 11:14:02 +00:00
|
|
|
## ledger value, i.e. the the sub-tree starting at `VertexID(1)`.
|
2024-07-12 13:12:25 +00:00
|
|
|
##
|
|
|
|
## On success, the function returns `true` if the `accPath` argument was
|
|
|
|
## not on the database already or the value differend from `accRec`, and
|
|
|
|
## `false` otherwise.
|
2024-06-18 11:14:02 +00:00
|
|
|
|
|
|
|
AristoApiMergeStorageDataFn* =
|
2024-02-29 21:10:24 +00:00
|
|
|
proc(db: AristoDbRef;
|
2024-10-01 21:03:10 +00:00
|
|
|
accPath: Hash32;
|
|
|
|
stoPath: Hash32;
|
2024-07-04 23:48:45 +00:00
|
|
|
stoData: UInt256;
|
2024-06-27 19:21:01 +00:00
|
|
|
): Result[void,AristoError]
|
|
|
|
{.noRaise.}
|
|
|
|
## Store the `stoData` data argument on the storage area addressed by
|
|
|
|
## `(accPath,stoPath)` where `accPath` is the account key (into the MPT)
|
|
|
|
## and `stoPath` is the slot path of the corresponding storage area.
|
2024-02-29 21:10:24 +00:00
|
|
|
|
2024-08-07 11:30:55 +00:00
|
|
|
AristoApiPartAccountTwig* =
|
|
|
|
proc(db: AristoDbRef;
|
2024-10-01 21:03:10 +00:00
|
|
|
accPath: Hash32;
|
|
|
|
): Result[(seq[seq[byte]],bool), AristoError]
|
2024-08-07 11:30:55 +00:00
|
|
|
{.noRaise.}
|
|
|
|
## This function returns a chain of rlp-encoded nodes along the argument
|
2024-09-11 09:39:45 +00:00
|
|
|
## path `(root,path)` followed by a `true` value if the `path` argument
|
|
|
|
## exists in the database. If the argument `path` is not on the database,
|
|
|
|
## a partial path will be returned follwed by a `false` value.
|
|
|
|
##
|
|
|
|
## Errors will only be returned for invalid paths.
|
2024-08-07 11:30:55 +00:00
|
|
|
|
|
|
|
AristoApiPartStorageTwig* =
|
|
|
|
proc(db: AristoDbRef;
|
2024-10-01 21:03:10 +00:00
|
|
|
accPath: Hash32;
|
|
|
|
stoPath: Hash32;
|
|
|
|
): Result[(seq[seq[byte]],bool), AristoError]
|
2024-08-07 11:30:55 +00:00
|
|
|
{.noRaise.}
|
2024-09-11 09:39:45 +00:00
|
|
|
## Variant of `partAccountTwig()`. Note that the function always returns
|
|
|
|
## an error unless the `accPath` is valid.
|
2024-08-07 11:30:55 +00:00
|
|
|
|
|
|
|
AristoApiPartUntwigGeneric* =
|
2024-10-01 21:03:10 +00:00
|
|
|
proc(chain: openArray[seq[byte]];
|
|
|
|
root: Hash32;
|
2024-08-07 11:30:55 +00:00
|
|
|
path: openArray[byte];
|
2024-10-01 21:03:10 +00:00
|
|
|
): Result[Opt[seq[byte]],AristoError]
|
2024-08-07 11:30:55 +00:00
|
|
|
{.noRaise.}
|
2024-09-11 09:39:45 +00:00
|
|
|
## Follow and verify the argument `chain` up unlil the last entry which
|
|
|
|
## must be a leaf node. Extract the payload and pass it on as return
|
|
|
|
## code. If a `Opt.none()` result is returned then the `path` argument
|
|
|
|
## does provably not exist relative to `chain`.
|
2024-08-07 11:30:55 +00:00
|
|
|
|
|
|
|
AristoApiPartUntwigGenericOk* =
|
2024-10-01 21:03:10 +00:00
|
|
|
proc(chain: openArray[seq[byte]];
|
|
|
|
root: Hash32;
|
2024-08-07 11:30:55 +00:00
|
|
|
path: openArray[byte];
|
2024-10-01 21:03:10 +00:00
|
|
|
payload: Opt[seq[byte]];
|
2024-08-07 11:30:55 +00:00
|
|
|
): Result[void,AristoError]
|
|
|
|
{.noRaise.}
|
2024-09-11 09:39:45 +00:00
|
|
|
## Variant of `partUntwigGeneric()`. The function verifies the argument
|
2024-08-07 11:30:55 +00:00
|
|
|
## `chain` of rlp-encoded nodes against the `path` and `payload`
|
2024-09-11 09:39:45 +00:00
|
|
|
## arguments. If `payload` is passed `Opt.none()`, then the function is
|
|
|
|
## subject to proving that the `path` does not exist relaive to `chain`.
|
2024-08-07 11:30:55 +00:00
|
|
|
##
|
|
|
|
## Note: This function provides a functionality comparable to the
|
|
|
|
## `isValidBranch()` function from `hexary.nim`.
|
|
|
|
|
|
|
|
AristoApiPartUntwigPath* =
|
2024-10-01 21:03:10 +00:00
|
|
|
proc(chain: openArray[seq[byte]];
|
|
|
|
root: Hash32;
|
|
|
|
path: Hash32;
|
|
|
|
): Result[Opt[seq[byte]],AristoError]
|
2024-08-07 11:30:55 +00:00
|
|
|
{.noRaise.}
|
|
|
|
## Variant of `partUntwigGeneric()`.
|
|
|
|
|
|
|
|
AristoApiPartUntwigPathOk* =
|
2024-10-01 21:03:10 +00:00
|
|
|
proc(chain: openArray[seq[byte]];
|
|
|
|
root: Hash32;
|
|
|
|
path: Hash32;
|
|
|
|
payload: Opt[seq[byte]];
|
2024-08-07 11:30:55 +00:00
|
|
|
): Result[void,AristoError]
|
|
|
|
{.noRaise.}
|
|
|
|
## Variant of `partUntwigGenericOk()`.
|
|
|
|
|
2024-02-29 21:10:24 +00:00
|
|
|
AristoApiPathAsBlobFn* =
|
|
|
|
proc(tag: PathID;
|
2024-10-01 21:03:10 +00:00
|
|
|
): seq[byte]
|
2024-02-29 21:10:24 +00:00
|
|
|
{.noRaise.}
|
2024-03-21 10:45:57 +00:00
|
|
|
## Converts the `tag` argument to a sequence of an even number of
|
2024-10-01 21:03:10 +00:00
|
|
|
## nibbles represented by a `seq[byte]`. If the argument `tag` represents
|
2024-03-21 10:45:57 +00:00
|
|
|
## an odd number of nibbles, a zero nibble is appendend.
|
|
|
|
##
|
|
|
|
## This function is useful only if there is a tacit agreement that all
|
|
|
|
## paths used to index database leaf values can be represented as
|
2024-10-01 21:03:10 +00:00
|
|
|
## `seq[byte]`, i.e. `PathID` type paths with an even number of nibbles.
|
2024-03-21 10:45:57 +00:00
|
|
|
|
2024-04-29 20:17:17 +00:00
|
|
|
AristoApiPersistFn* =
|
|
|
|
proc(db: AristoDbRef;
|
2024-06-03 20:10:35 +00:00
|
|
|
nxtSid = 0u64;
|
2024-04-29 20:17:17 +00:00
|
|
|
): Result[void,AristoError]
|
|
|
|
{.noRaise.}
|
|
|
|
## Persistently store data onto backend database. If the system is
|
|
|
|
## running without a database backend, the function returns immediately
|
|
|
|
## with an error. The same happens if there is a pending transaction.
|
|
|
|
##
|
|
|
|
## The function merges all staged data from the top layer cache onto the
|
|
|
|
## backend stage area. After that, the top layer cache is cleared.
|
|
|
|
##
|
|
|
|
## Finally, the staged data are merged into the physical backend
|
2024-06-03 20:10:35 +00:00
|
|
|
## database and the staged data area is cleared.
|
2024-04-29 20:17:17 +00:00
|
|
|
##
|
2024-06-03 20:10:35 +00:00
|
|
|
## The argument `nxtSid` will be the ID for the next saved state record.
|
2024-04-29 20:17:17 +00:00
|
|
|
|
2024-02-29 21:10:24 +00:00
|
|
|
AristoApiRollbackFn* =
|
|
|
|
proc(tx: AristoTxRef;
|
|
|
|
): Result[void,AristoError]
|
|
|
|
{.noRaise.}
|
|
|
|
## Given a *top level* handle, this function discards all database
|
|
|
|
## operations performed for this transactio. The previous transaction
|
|
|
|
## is returned if there was any.
|
|
|
|
|
2024-12-18 16:03:51 +00:00
|
|
|
AristoApiTxFrameBeginFn* =
|
2024-07-03 15:50:27 +00:00
|
|
|
proc(db: AristoDbRef;
|
2024-02-29 21:10:24 +00:00
|
|
|
): Result[AristoTxRef,AristoError]
|
|
|
|
{.noRaise.}
|
|
|
|
## Starts a new transaction.
|
|
|
|
##
|
|
|
|
## Example:
|
|
|
|
## ::
|
|
|
|
## proc doSomething(db: AristoDbRef) =
|
|
|
|
## let tx = db.begin
|
|
|
|
## defer: tx.rollback()
|
|
|
|
## ... continue using db ...
|
|
|
|
## tx.commit()
|
|
|
|
|
2024-12-18 16:03:51 +00:00
|
|
|
AristoApiTxFrameTopFn* =
|
2024-02-29 21:10:24 +00:00
|
|
|
proc(db: AristoDbRef;
|
|
|
|
): Result[AristoTxRef,AristoError]
|
|
|
|
{.noRaise.}
|
|
|
|
## Getter, returns top level transaction if there is any.
|
|
|
|
|
|
|
|
AristoApiRef* = ref AristoApiObj
|
|
|
|
AristoApiObj* = object of RootObj
|
|
|
|
## Useful set of `Aristo` fuctions that can be filtered, stacked etc.
|
|
|
|
commit*: AristoApiCommitFn
|
2024-06-27 09:01:26 +00:00
|
|
|
|
|
|
|
deleteAccountRecord*: AristoApiDeleteAccountRecordFn
|
2024-06-18 19:30:01 +00:00
|
|
|
deleteStorageData*: AristoApiDeleteStorageDataFn
|
|
|
|
deleteStorageTree*: AristoApiDeleteStorageTreeFn
|
2024-06-27 09:01:26 +00:00
|
|
|
|
2024-05-31 17:32:22 +00:00
|
|
|
fetchLastSavedState*: AristoApiFetchLastSavedStateFn
|
2024-06-27 09:01:26 +00:00
|
|
|
|
|
|
|
fetchAccountRecord*: AristoApiFetchAccountRecordFn
|
2024-11-22 13:15:35 +00:00
|
|
|
fetchStateRoot*: AristoApiFetchStateRootFn
|
2024-06-19 12:40:00 +00:00
|
|
|
fetchStorageData*: AristoApiFetchStorageDataFn
|
2024-10-27 18:56:28 +00:00
|
|
|
fetchStorageRoot*: AristoApiFetchStorageRootFn
|
2024-06-27 09:01:26 +00:00
|
|
|
|
2024-02-29 21:10:24 +00:00
|
|
|
finish*: AristoApiFinishFn
|
2024-06-19 12:40:00 +00:00
|
|
|
hasPathAccount*: AristoApiHasPathAccountFn
|
|
|
|
hasPathStorage*: AristoApiHasPathStorageFn
|
2024-06-27 09:01:26 +00:00
|
|
|
hasStorageData*: AristoApiHasStorageDataFn
|
|
|
|
|
2024-02-29 21:10:24 +00:00
|
|
|
isTop*: AristoApiIsTopFn
|
2024-12-18 16:03:51 +00:00
|
|
|
txFrameLevel*: AristoApiTxFrameLevelFn
|
2024-06-27 09:01:26 +00:00
|
|
|
|
|
|
|
mergeAccountRecord*: AristoApiMergeAccountRecordFn
|
2024-06-18 11:14:02 +00:00
|
|
|
mergeStorageData*: AristoApiMergeStorageDataFn
|
2024-06-27 09:01:26 +00:00
|
|
|
|
2024-08-07 11:30:55 +00:00
|
|
|
partAccountTwig*: AristoApiPartAccountTwig
|
|
|
|
partStorageTwig*: AristoApiPartStorageTwig
|
|
|
|
partUntwigGeneric*: AristoApiPartUntwigGeneric
|
|
|
|
partUntwigGenericOk*: AristoApiPartUntwigGenericOk
|
|
|
|
partUntwigPath*: AristoApiPartUntwigPath
|
|
|
|
partUntwigPathOk*: AristoApiPartUntwigPathOk
|
|
|
|
|
2024-02-29 21:10:24 +00:00
|
|
|
pathAsBlob*: AristoApiPathAsBlobFn
|
2024-04-29 20:17:17 +00:00
|
|
|
persist*: AristoApiPersistFn
|
2024-02-29 21:10:24 +00:00
|
|
|
rollback*: AristoApiRollbackFn
|
2024-12-18 16:03:51 +00:00
|
|
|
txFrameBegin*: AristoApiTxFrameBeginFn
|
|
|
|
txFrameTop*: AristoApiTxFrameTopFn
|
2024-02-29 21:10:24 +00:00
|
|
|
|
|
|
|
|
|
|
|
AristoApiProfNames* = enum
|
|
|
|
## Index/name mapping for profile slots
|
2024-06-27 09:01:26 +00:00
|
|
|
AristoApiProfTotal = "total"
|
2024-06-18 19:30:01 +00:00
|
|
|
AristoApiProfCommitFn = "commit"
|
2024-06-27 09:01:26 +00:00
|
|
|
|
|
|
|
AristoApiProfDeleteAccountRecordFn = "deleteAccountRecord"
|
2024-06-18 19:30:01 +00:00
|
|
|
AristoApiProfDeleteStorageDataFn = "deleteStorageData"
|
|
|
|
AristoApiProfDeleteStorageTreeFn = "deleteStorageTree"
|
2024-06-27 09:01:26 +00:00
|
|
|
|
|
|
|
AristoApiProfFetchLastSavedStateFn = "fetchLastSavedState"
|
|
|
|
|
|
|
|
AristoApiProfFetchAccountRecordFn = "fetchAccountRecord"
|
2024-11-22 13:15:35 +00:00
|
|
|
AristoApiProfFetchStateRootFn = "fetchStateRoot"
|
2024-06-19 12:40:00 +00:00
|
|
|
AristoApiProfFetchStorageDataFn = "fetchStorageData"
|
2024-10-27 18:56:28 +00:00
|
|
|
AristoApiProfFetchStorageRootFn = "fetchStorageRoot"
|
2024-06-27 09:01:26 +00:00
|
|
|
|
2024-06-18 19:30:01 +00:00
|
|
|
AristoApiProfFinishFn = "finish"
|
2024-06-27 09:01:26 +00:00
|
|
|
|
2024-06-19 12:40:00 +00:00
|
|
|
AristoApiProfHasPathAccountFn = "hasPathAccount"
|
|
|
|
AristoApiProfHasPathStorageFn = "hasPathStorage"
|
2024-06-27 09:01:26 +00:00
|
|
|
AristoApiProfHasStorageDataFn = "hasStorageData"
|
|
|
|
|
2024-06-18 19:30:01 +00:00
|
|
|
AristoApiProfIsTopFn = "isTop"
|
|
|
|
AristoApiProfLevelFn = "level"
|
2024-06-27 09:01:26 +00:00
|
|
|
|
|
|
|
AristoApiProfMergeAccountRecordFn = "mergeAccountRecord"
|
2024-06-18 19:30:01 +00:00
|
|
|
AristoApiProfMergeStorageDataFn = "mergeStorageData"
|
2024-06-27 09:01:26 +00:00
|
|
|
|
2024-08-07 11:30:55 +00:00
|
|
|
AristoApiProfPartAccountTwigFn = "partAccountTwig"
|
|
|
|
AristoApiProfPartStorageTwigFn = "partStorageTwig"
|
|
|
|
AristoApiProfPartUntwigPathFn = "partUntwigPath"
|
|
|
|
AristoApiProfPartUntwigPathOkFn = "partUntwigPathOk"
|
|
|
|
|
2024-06-18 19:30:01 +00:00
|
|
|
AristoApiProfPathAsBlobFn = "pathAsBlob"
|
|
|
|
AristoApiProfPersistFn = "persist"
|
|
|
|
AristoApiProfRollbackFn = "rollback"
|
2024-12-18 16:03:51 +00:00
|
|
|
AristoApiProfTxFrameBeginFn = "txFrameBegin"
|
|
|
|
AristoApiProfTxFrameTopFn = "txFrameTop"
|
2024-06-18 19:30:01 +00:00
|
|
|
|
|
|
|
AristoApiProfBeGetVtxFn = "be/getVtx"
|
|
|
|
AristoApiProfBeGetKeyFn = "be/getKey"
|
|
|
|
AristoApiProfBeGetTuvFn = "be/getTuv"
|
|
|
|
AristoApiProfBeGetLstFn = "be/getLst"
|
|
|
|
AristoApiProfBePutVtxFn = "be/putVtx"
|
|
|
|
AristoApiProfBePutTuvFn = "be/putTuv"
|
|
|
|
AristoApiProfBePutLstFn = "be/putLst"
|
|
|
|
AristoApiProfBePutEndFn = "be/putEnd"
|
2024-02-29 21:10:24 +00:00
|
|
|
|
|
|
|
AristoApiProfRef* = ref object of AristoApiRef
|
|
|
|
## Profiling API extension of `AristoApiObj`
|
|
|
|
data*: AristoDbProfListRef
|
|
|
|
be*: BackendRef
|
|
|
|
|
2024-03-07 19:24:05 +00:00
|
|
|
# ------------------------------------------------------------------------------
|
|
|
|
# Private helpers
|
|
|
|
# ------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
when AutoValidateApiHooks:
|
|
|
|
proc validate(api: AristoApiObj|AristoApiRef) =
|
|
|
|
doAssert not api.commit.isNil
|
2024-06-27 09:01:26 +00:00
|
|
|
|
|
|
|
doAssert not api.deleteAccountRecord.isNil
|
2024-06-18 19:30:01 +00:00
|
|
|
doAssert not api.deleteStorageData.isNil
|
|
|
|
doAssert not api.deleteStorageTree.isNil
|
2024-06-27 09:01:26 +00:00
|
|
|
|
2024-05-31 17:32:22 +00:00
|
|
|
doAssert not api.fetchLastSavedState.isNil
|
2024-06-27 09:01:26 +00:00
|
|
|
|
|
|
|
doAssert not api.fetchAccountRecord.isNil
|
2024-11-22 13:15:35 +00:00
|
|
|
doAssert not api.fetchStateRoot.isNil
|
2024-06-19 12:40:00 +00:00
|
|
|
doAssert not api.fetchStorageData.isNil
|
2024-10-27 18:56:28 +00:00
|
|
|
doAssert not api.fetchStorageRoot.isNil
|
2024-06-27 09:01:26 +00:00
|
|
|
|
2024-03-07 19:24:05 +00:00
|
|
|
doAssert not api.finish.isNil
|
2024-06-27 09:01:26 +00:00
|
|
|
|
2024-06-19 12:40:00 +00:00
|
|
|
doAssert not api.hasPathAccount.isNil
|
|
|
|
doAssert not api.hasPathStorage.isNil
|
2024-06-27 09:01:26 +00:00
|
|
|
doAssert not api.hasStorageData.isNil
|
|
|
|
|
2024-03-07 19:24:05 +00:00
|
|
|
doAssert not api.isTop.isNil
|
2024-12-19 12:02:36 +00:00
|
|
|
doAssert not api.txFrameLevel.isNil
|
2024-06-27 09:01:26 +00:00
|
|
|
|
|
|
|
doAssert not api.mergeAccountRecord.isNil
|
2024-06-18 11:14:02 +00:00
|
|
|
doAssert not api.mergeStorageData.isNil
|
2024-06-27 09:01:26 +00:00
|
|
|
|
2024-08-07 11:30:55 +00:00
|
|
|
doAssert not api.partAccountTwig.isNil
|
|
|
|
doAssert not api.partStorageTwig.isNil
|
|
|
|
doAssert not api.partUntwigPath.isNil
|
|
|
|
doAssert not api.partUntwigPathOk.isNil
|
|
|
|
|
2024-03-07 19:24:05 +00:00
|
|
|
doAssert not api.pathAsBlob.isNil
|
2024-04-29 20:17:17 +00:00
|
|
|
doAssert not api.persist.isNil
|
2024-03-07 19:24:05 +00:00
|
|
|
doAssert not api.rollback.isNil
|
2024-12-18 16:03:51 +00:00
|
|
|
doAssert not api.txFrameBegin.isNil
|
|
|
|
doAssert not api.txFrameTop.isNil
|
2024-03-07 19:24:05 +00:00
|
|
|
|
2024-03-14 22:17:43 +00:00
|
|
|
proc validate(prf: AristoApiProfRef) =
|
2024-03-07 19:24:05 +00:00
|
|
|
prf.AristoApiRef.validate
|
|
|
|
doAssert not prf.data.isNil
|
2024-03-14 22:17:43 +00:00
|
|
|
|
|
|
|
proc dup(be: BackendRef): BackendRef =
|
|
|
|
case be.kind:
|
|
|
|
of BackendMemory:
|
|
|
|
return MemBackendRef(be).dup
|
|
|
|
|
2024-06-13 18:15:11 +00:00
|
|
|
of BackendRocksDB, BackendRdbHosting:
|
2024-03-14 22:17:43 +00:00
|
|
|
when AristoPersistentBackendOk:
|
|
|
|
return RdbBackendRef(be).dup
|
|
|
|
|
|
|
|
of BackendVoid:
|
|
|
|
discard
|
2024-03-07 19:24:05 +00:00
|
|
|
|
2024-02-29 21:10:24 +00:00
|
|
|
# ------------------------------------------------------------------------------
|
|
|
|
# Public API constuctors
|
|
|
|
# ------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
func init*(api: var AristoApiObj) =
|
|
|
|
## Initialise an `api` argument descriptor
|
|
|
|
##
|
2024-03-07 19:24:05 +00:00
|
|
|
when AutoValidateApiHooks:
|
|
|
|
api.reset
|
2024-02-29 21:10:24 +00:00
|
|
|
api.commit = commit
|
2024-06-27 09:01:26 +00:00
|
|
|
|
|
|
|
api.deleteAccountRecord = deleteAccountRecord
|
2024-06-18 19:30:01 +00:00
|
|
|
api.deleteStorageData = deleteStorageData
|
|
|
|
api.deleteStorageTree = deleteStorageTree
|
2024-06-27 09:01:26 +00:00
|
|
|
|
2024-05-31 17:32:22 +00:00
|
|
|
api.fetchLastSavedState = fetchLastSavedState
|
2024-06-27 09:01:26 +00:00
|
|
|
|
|
|
|
api.fetchAccountRecord = fetchAccountRecord
|
2024-11-22 13:15:35 +00:00
|
|
|
api.fetchStateRoot = fetchStateRoot
|
2024-06-19 12:40:00 +00:00
|
|
|
api.fetchStorageData = fetchStorageData
|
2024-10-27 18:56:28 +00:00
|
|
|
api.fetchStorageRoot = fetchStorageRoot
|
2024-06-27 09:01:26 +00:00
|
|
|
|
2024-02-29 21:10:24 +00:00
|
|
|
api.finish = finish
|
2024-06-27 09:01:26 +00:00
|
|
|
|
2024-06-19 12:40:00 +00:00
|
|
|
api.hasPathAccount = hasPathAccount
|
|
|
|
api.hasPathStorage = hasPathStorage
|
2024-06-27 09:01:26 +00:00
|
|
|
api.hasStorageData = hasStorageData
|
|
|
|
|
2024-06-17 12:18:50 +00:00
|
|
|
api.isTop = isTop
|
2024-12-18 16:03:51 +00:00
|
|
|
api.txFrameLevel = txFrameLevel
|
2024-06-27 09:01:26 +00:00
|
|
|
|
|
|
|
api.mergeAccountRecord = mergeAccountRecord
|
2024-06-18 11:14:02 +00:00
|
|
|
api.mergeStorageData = mergeStorageData
|
2024-06-27 09:01:26 +00:00
|
|
|
|
2024-08-07 11:30:55 +00:00
|
|
|
api.partAccountTwig = partAccountTwig
|
|
|
|
api.partStorageTwig = partStorageTwig
|
|
|
|
api.partUntwigPath = partUntwigPath
|
|
|
|
api.partUntwigPathOk = partUntwigPathOk
|
|
|
|
|
2024-02-29 21:10:24 +00:00
|
|
|
api.pathAsBlob = pathAsBlob
|
2024-04-29 20:17:17 +00:00
|
|
|
api.persist = persist
|
2024-02-29 21:10:24 +00:00
|
|
|
api.rollback = rollback
|
2024-12-18 16:03:51 +00:00
|
|
|
api.txFrameBegin = txFrameBegin
|
|
|
|
api.txFrameTop = txFrameTop
|
2024-03-07 19:24:05 +00:00
|
|
|
when AutoValidateApiHooks:
|
|
|
|
api.validate
|
2024-02-29 21:10:24 +00:00
|
|
|
|
|
|
|
func init*(T: type AristoApiRef): T =
|
|
|
|
new result
|
|
|
|
result[].init()
|
|
|
|
|
|
|
|
func dup*(api: AristoApiRef): AristoApiRef =
|
2024-03-07 19:24:05 +00:00
|
|
|
result = AristoApiRef(
|
2024-06-18 19:30:01 +00:00
|
|
|
commit: api.commit,
|
2024-06-27 09:01:26 +00:00
|
|
|
|
|
|
|
deleteAccountRecord: api.deleteAccountRecord,
|
2024-06-18 19:30:01 +00:00
|
|
|
deleteStorageData: api.deleteStorageData,
|
|
|
|
deleteStorageTree: api.deleteStorageTree,
|
2024-06-27 09:01:26 +00:00
|
|
|
|
2024-06-18 19:30:01 +00:00
|
|
|
fetchLastSavedState: api.fetchLastSavedState,
|
2024-06-27 09:01:26 +00:00
|
|
|
fetchAccountRecord: api.fetchAccountRecord,
|
2024-11-22 13:15:35 +00:00
|
|
|
fetchStateRoot: api.fetchStateRoot,
|
2024-06-19 12:40:00 +00:00
|
|
|
fetchStorageData: api.fetchStorageData,
|
2024-10-27 18:56:28 +00:00
|
|
|
fetchStorageRoot: api.fetchStorageRoot,
|
2024-06-27 09:01:26 +00:00
|
|
|
|
2024-06-18 19:30:01 +00:00
|
|
|
finish: api.finish,
|
2024-06-27 09:01:26 +00:00
|
|
|
|
2024-06-19 12:40:00 +00:00
|
|
|
hasPathAccount: api.hasPathAccount,
|
|
|
|
hasPathStorage: api.hasPathStorage,
|
2024-06-27 09:01:26 +00:00
|
|
|
hasStorageData: api.hasStorageData,
|
|
|
|
|
2024-06-18 19:30:01 +00:00
|
|
|
isTop: api.isTop,
|
2024-12-18 16:03:51 +00:00
|
|
|
txFrameLevel: api.txFrameLevel,
|
2024-06-27 09:01:26 +00:00
|
|
|
|
|
|
|
mergeAccountRecord: api.mergeAccountRecord,
|
2024-06-18 19:30:01 +00:00
|
|
|
mergeStorageData: api.mergeStorageData,
|
2024-06-27 09:01:26 +00:00
|
|
|
|
2024-08-07 11:30:55 +00:00
|
|
|
partAccountTwig: api.partAccountTwig,
|
|
|
|
partStorageTwig: api.partStorageTwig,
|
|
|
|
partUntwigPath: api.partUntwigPath,
|
|
|
|
partUntwigPathOk: api.partUntwigPathOk,
|
|
|
|
|
2024-06-18 19:30:01 +00:00
|
|
|
pathAsBlob: api.pathAsBlob,
|
|
|
|
persist: api.persist,
|
|
|
|
rollback: api.rollback,
|
2024-12-18 16:03:51 +00:00
|
|
|
txFrameBegin: api.txFrameBegin,
|
|
|
|
txFrameTop: api.txFrameTop)
|
2024-03-07 19:24:05 +00:00
|
|
|
when AutoValidateApiHooks:
|
2024-07-12 13:12:25 +00:00
|
|
|
result.validate
|
2024-02-29 21:10:24 +00:00
|
|
|
|
|
|
|
# ------------------------------------------------------------------------------
|
|
|
|
# Public profile API constuctor
|
|
|
|
# ------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
func init*(
|
|
|
|
T: type AristoApiProfRef;
|
|
|
|
api: AristoApiRef;
|
|
|
|
be = BackendRef(nil);
|
|
|
|
): T =
|
|
|
|
## This constructor creates a profiling API descriptor to be derived from
|
|
|
|
## an initialised `api` argument descriptor. For profiling the DB backend,
|
|
|
|
## the field `.be` of the result descriptor must be assigned to the
|
|
|
|
## `.backend` field of the `AristoDbRef` descriptor.
|
|
|
|
##
|
|
|
|
## The argument desctiptors `api` and `be` will not be modified and can be
|
|
|
|
## used to restore the previous set up.
|
|
|
|
##
|
|
|
|
let
|
|
|
|
data = AristoDbProfListRef(
|
|
|
|
list: newSeq[AristoDbProfData](1 + high(AristoApiProfNames).ord))
|
|
|
|
profApi = T(data: data)
|
|
|
|
|
|
|
|
template profileRunner(n: AristoApiProfNames, code: untyped): untyped =
|
|
|
|
let start = getTime()
|
|
|
|
code
|
|
|
|
data.update(n.ord, getTime() - start)
|
|
|
|
|
|
|
|
profApi.commit =
|
|
|
|
proc(a: AristoTxRef): auto =
|
|
|
|
AristoApiProfCommitFn.profileRunner:
|
|
|
|
result = api.commit(a)
|
|
|
|
|
2024-06-27 09:01:26 +00:00
|
|
|
profApi.deleteAccountRecord =
|
2024-10-01 21:03:10 +00:00
|
|
|
proc(a: AristoDbRef; b: Hash32): auto =
|
2024-06-27 09:01:26 +00:00
|
|
|
AristoApiProfDeleteAccountRecordFn.profileRunner:
|
2024-07-12 13:12:25 +00:00
|
|
|
result = api.deleteAccountRecord(a, b)
|
2024-02-29 21:10:24 +00:00
|
|
|
|
2024-06-18 19:30:01 +00:00
|
|
|
profApi.deleteStorageData =
|
2024-10-01 21:03:10 +00:00
|
|
|
proc(a: AristoDbRef; b: Hash32, c: Hash32): auto =
|
2024-06-18 19:30:01 +00:00
|
|
|
AristoApiProfDeleteStorageDataFn.profileRunner:
|
2024-07-12 13:12:25 +00:00
|
|
|
result = api.deleteStorageData(a, b, c)
|
2024-06-18 19:30:01 +00:00
|
|
|
|
|
|
|
profApi.deleteStorageTree =
|
2024-10-01 21:03:10 +00:00
|
|
|
proc(a: AristoDbRef; b: Hash32): auto =
|
2024-06-18 19:30:01 +00:00
|
|
|
AristoApiProfDeleteStorageTreeFn.profileRunner:
|
2024-07-12 13:12:25 +00:00
|
|
|
result = api.deleteStorageTree(a, b)
|
2024-02-29 21:10:24 +00:00
|
|
|
|
2024-05-31 17:32:22 +00:00
|
|
|
profApi.fetchLastSavedState =
|
|
|
|
proc(a: AristoDbRef): auto =
|
|
|
|
AristoApiProfFetchLastSavedStateFn.profileRunner:
|
|
|
|
result = api.fetchLastSavedState(a)
|
|
|
|
|
2024-06-27 09:01:26 +00:00
|
|
|
profApi.fetchAccountRecord =
|
2024-10-01 21:03:10 +00:00
|
|
|
proc(a: AristoDbRef; b: Hash32): auto =
|
2024-06-27 09:01:26 +00:00
|
|
|
AristoApiProfFetchAccountRecordFn.profileRunner:
|
2024-07-12 13:12:25 +00:00
|
|
|
result = api.fetchAccountRecord(a, b)
|
2024-06-27 09:01:26 +00:00
|
|
|
|
2024-11-22 13:15:35 +00:00
|
|
|
profApi.fetchStateRoot =
|
2024-06-28 15:03:12 +00:00
|
|
|
proc(a: AristoDbRef; b: bool): auto =
|
2024-11-22 13:15:35 +00:00
|
|
|
AristoApiProfFetchStateRootFn.profileRunner:
|
|
|
|
result = api.fetchStateRoot(a, b)
|
2024-06-19 12:40:00 +00:00
|
|
|
|
|
|
|
profApi.fetchStorageData =
|
2024-10-01 21:03:10 +00:00
|
|
|
proc(a: AristoDbRef; b, stoPath: Hash32): auto =
|
2024-06-19 12:40:00 +00:00
|
|
|
AristoApiProfFetchStorageDataFn.profileRunner:
|
2024-07-12 13:12:25 +00:00
|
|
|
result = api.fetchStorageData(a, b, stoPath)
|
2024-02-29 21:10:24 +00:00
|
|
|
|
2024-10-27 18:56:28 +00:00
|
|
|
profApi.fetchStorageRoot =
|
2024-11-22 13:15:35 +00:00
|
|
|
proc(a: AristoDbRef; b: Hash32): auto =
|
2024-10-27 18:56:28 +00:00
|
|
|
AristoApiProfFetchStorageRootFn.profileRunner:
|
2024-11-22 13:15:35 +00:00
|
|
|
result = api.fetchStorageRoot(a, b)
|
2024-06-27 09:01:26 +00:00
|
|
|
|
2024-02-29 21:10:24 +00:00
|
|
|
profApi.finish =
|
|
|
|
proc(a: AristoDbRef; b = false) =
|
|
|
|
AristoApiProfFinishFn.profileRunner:
|
|
|
|
api.finish(a, b)
|
|
|
|
|
2024-06-19 12:40:00 +00:00
|
|
|
profApi.hasPathAccount =
|
2024-10-01 21:03:10 +00:00
|
|
|
proc(a: AristoDbRef; b: Hash32): auto =
|
2024-06-19 12:40:00 +00:00
|
|
|
AristoApiProfHasPathAccountFn.profileRunner:
|
2024-07-12 13:12:25 +00:00
|
|
|
result = api.hasPathAccount(a, b)
|
2024-06-19 12:40:00 +00:00
|
|
|
|
|
|
|
profApi.hasPathStorage =
|
2024-10-01 21:03:10 +00:00
|
|
|
proc(a: AristoDbRef; b, c: Hash32): auto =
|
2024-06-19 12:40:00 +00:00
|
|
|
AristoApiProfHasPathStorageFn.profileRunner:
|
2024-07-12 13:12:25 +00:00
|
|
|
result = api.hasPathStorage(a, b, c)
|
2024-02-29 21:10:24 +00:00
|
|
|
|
2024-06-27 09:01:26 +00:00
|
|
|
profApi.hasStorageData =
|
2024-10-01 21:03:10 +00:00
|
|
|
proc(a: AristoDbRef; b: Hash32): auto =
|
2024-06-27 09:01:26 +00:00
|
|
|
AristoApiProfHasStorageDataFn.profileRunner:
|
2024-07-12 13:12:25 +00:00
|
|
|
result = api.hasStorageData(a, b)
|
2024-06-27 09:01:26 +00:00
|
|
|
|
2024-02-29 21:10:24 +00:00
|
|
|
profApi.isTop =
|
|
|
|
proc(a: AristoTxRef): auto =
|
|
|
|
AristoApiProfIsTopFn.profileRunner:
|
|
|
|
result = api.isTop(a)
|
|
|
|
|
|
|
|
profApi.level =
|
|
|
|
proc(a: AristoDbRef): auto =
|
|
|
|
AristoApiProfLevelFn.profileRunner:
|
|
|
|
result = api.level(a)
|
|
|
|
|
2024-06-27 09:01:26 +00:00
|
|
|
profApi.mergeAccountRecord =
|
2024-10-01 21:03:10 +00:00
|
|
|
proc(a: AristoDbRef; b: Hash32; c: AristoAccount): auto =
|
2024-06-27 09:01:26 +00:00
|
|
|
AristoApiProfMergeAccountRecordFn.profileRunner:
|
2024-07-12 13:12:25 +00:00
|
|
|
result = api.mergeAccountRecord(a, b, c)
|
2024-06-18 11:14:02 +00:00
|
|
|
|
|
|
|
profApi.mergeStorageData =
|
2024-11-01 19:06:26 +00:00
|
|
|
proc(a: AristoDbRef; b, c: Hash32, d: UInt256): auto =
|
2024-06-18 11:14:02 +00:00
|
|
|
AristoApiProfMergeStorageDataFn.profileRunner:
|
2024-07-12 13:12:25 +00:00
|
|
|
result = api.mergeStorageData(a, b, c, d)
|
2024-02-29 21:10:24 +00:00
|
|
|
|
2024-08-07 11:30:55 +00:00
|
|
|
profApi.partAccountTwig =
|
2024-10-01 21:03:10 +00:00
|
|
|
proc(a: AristoDbRef; b: Hash32): auto =
|
2024-08-07 11:30:55 +00:00
|
|
|
AristoApiProfPartAccountTwigFn.profileRunner:
|
|
|
|
result = api.partAccountTwig(a, b)
|
|
|
|
|
|
|
|
profApi.partStorageTwig =
|
2024-10-01 21:03:10 +00:00
|
|
|
proc(a: AristoDbRef; b: Hash32; c: Hash32): auto =
|
2024-08-07 11:30:55 +00:00
|
|
|
AristoApiProfPartStorageTwigFn.profileRunner:
|
|
|
|
result = api.partStorageTwig(a, b, c)
|
|
|
|
|
|
|
|
profApi.partUntwigPath =
|
2024-10-01 21:03:10 +00:00
|
|
|
proc(a: openArray[seq[byte]]; b, c: Hash32): auto =
|
2024-08-07 11:30:55 +00:00
|
|
|
AristoApiProfPartUntwigPathFn.profileRunner:
|
|
|
|
result = api.partUntwigPath(a, b, c)
|
|
|
|
|
|
|
|
profApi.partUntwigPathOk =
|
2024-10-01 21:03:10 +00:00
|
|
|
proc(a: openArray[seq[byte]]; b, c: Hash32; d: Opt[seq[byte]]): auto =
|
2024-08-07 11:30:55 +00:00
|
|
|
AristoApiProfPartUntwigPathOkFn.profileRunner:
|
|
|
|
result = api.partUntwigPathOk(a, b, c, d)
|
|
|
|
|
2024-02-29 21:10:24 +00:00
|
|
|
profApi.pathAsBlob =
|
|
|
|
proc(a: PathID): auto =
|
|
|
|
AristoApiProfPathAsBlobFn.profileRunner:
|
|
|
|
result = api.pathAsBlob(a)
|
|
|
|
|
2024-04-29 20:17:17 +00:00
|
|
|
profApi.persist =
|
2024-07-22 18:10:04 +00:00
|
|
|
proc(a: AristoDbRef; b = 0u64): auto =
|
2024-04-29 20:17:17 +00:00
|
|
|
AristoApiProfPersistFn.profileRunner:
|
2024-07-22 18:10:04 +00:00
|
|
|
result = api.persist(a, b)
|
2024-04-29 20:17:17 +00:00
|
|
|
|
2024-02-29 21:10:24 +00:00
|
|
|
profApi.rollback =
|
|
|
|
proc(a: AristoTxRef): auto =
|
|
|
|
AristoApiProfRollbackFn.profileRunner:
|
|
|
|
result = api.rollback(a)
|
|
|
|
|
2024-12-18 16:03:51 +00:00
|
|
|
profApi.txFrameBegin =
|
2024-02-29 21:10:24 +00:00
|
|
|
proc(a: AristoDbRef): auto =
|
2024-12-18 16:03:51 +00:00
|
|
|
AristoApiProfTxFrameBeginFn.profileRunner:
|
|
|
|
result = api.txFrameBegin(a)
|
2024-07-03 15:50:27 +00:00
|
|
|
|
2024-12-18 16:03:51 +00:00
|
|
|
profApi.txFrameTop =
|
2024-02-29 21:10:24 +00:00
|
|
|
proc(a: AristoDbRef): auto =
|
2024-12-18 16:03:51 +00:00
|
|
|
AristoApiProfTxFrameTopFn.profileRunner:
|
|
|
|
result = api.txFrameTop(a)
|
2024-02-29 21:10:24 +00:00
|
|
|
|
2024-04-19 18:37:27 +00:00
|
|
|
let beDup = be.dup()
|
|
|
|
if beDup.isNil:
|
|
|
|
profApi.be = be
|
2024-02-29 21:10:24 +00:00
|
|
|
|
2024-04-19 18:37:27 +00:00
|
|
|
else:
|
|
|
|
beDup.getVtxFn =
|
2024-09-20 05:43:53 +00:00
|
|
|
proc(a: RootedVertexID, flags: set[GetVtxFlag]): auto =
|
2024-02-29 21:10:24 +00:00
|
|
|
AristoApiProfBeGetVtxFn.profileRunner:
|
2024-09-20 05:43:53 +00:00
|
|
|
result = be.getVtxFn(a, flags)
|
2024-04-19 18:37:27 +00:00
|
|
|
data.list[AristoApiProfBeGetVtxFn.ord].masked = true
|
2024-02-29 21:10:24 +00:00
|
|
|
|
2024-04-19 18:37:27 +00:00
|
|
|
beDup.getKeyFn =
|
2024-07-04 13:46:52 +00:00
|
|
|
proc(a: RootedVertexID): auto =
|
2024-02-29 21:10:24 +00:00
|
|
|
AristoApiProfBeGetKeyFn.profileRunner:
|
|
|
|
result = be.getKeyFn(a)
|
2024-04-19 18:37:27 +00:00
|
|
|
data.list[AristoApiProfBeGetKeyFn.ord].masked = true
|
2024-02-29 21:10:24 +00:00
|
|
|
|
2024-06-14 11:19:48 +00:00
|
|
|
beDup.getTuvFn =
|
2024-04-22 19:02:22 +00:00
|
|
|
proc(): auto =
|
2024-06-14 11:19:48 +00:00
|
|
|
AristoApiProfBeGetTuvFn.profileRunner:
|
|
|
|
result = be.getTuvFn()
|
|
|
|
data.list[AristoApiProfBeGetTuvFn.ord].masked = true
|
2024-04-22 19:02:22 +00:00
|
|
|
|
2024-05-31 17:32:22 +00:00
|
|
|
beDup.getLstFn =
|
|
|
|
proc(): auto =
|
|
|
|
AristoApiProfBeGetLstFn.profileRunner:
|
|
|
|
result = be.getLstFn()
|
|
|
|
data.list[AristoApiProfBeGetLstFn.ord].masked = true
|
|
|
|
|
2024-04-22 19:02:22 +00:00
|
|
|
beDup.putVtxFn =
|
2024-07-04 13:46:52 +00:00
|
|
|
proc(a: PutHdlRef; b: RootedVertexID, c: VertexRef) =
|
2024-04-22 19:02:22 +00:00
|
|
|
AristoApiProfBePutVtxFn.profileRunner:
|
2024-06-27 19:21:01 +00:00
|
|
|
be.putVtxFn(a, b, c)
|
2024-04-22 19:02:22 +00:00
|
|
|
data.list[AristoApiProfBePutVtxFn.ord].masked = true
|
|
|
|
|
2024-06-14 11:19:48 +00:00
|
|
|
beDup.putTuvFn =
|
|
|
|
proc(a: PutHdlRef; b: VertexID) =
|
|
|
|
AristoApiProfBePutTuvFn.profileRunner:
|
|
|
|
be.putTuvFn(a,b)
|
|
|
|
data.list[AristoApiProfBePutTuvFn.ord].masked = true
|
2024-04-22 19:02:22 +00:00
|
|
|
|
2024-05-31 17:32:22 +00:00
|
|
|
beDup.putLstFn =
|
|
|
|
proc(a: PutHdlRef; b: SavedState) =
|
|
|
|
AristoApiProfBePutLstFn.profileRunner:
|
|
|
|
be.putLstFn(a,b)
|
|
|
|
data.list[AristoApiProfBePutLstFn.ord].masked = true
|
|
|
|
|
2024-04-19 18:37:27 +00:00
|
|
|
beDup.putEndFn =
|
2024-02-29 21:10:24 +00:00
|
|
|
proc(a: PutHdlRef): auto =
|
|
|
|
AristoApiProfBePutEndFn.profileRunner:
|
|
|
|
result = be.putEndFn(a)
|
2024-04-19 18:37:27 +00:00
|
|
|
data.list[AristoApiProfBePutEndFn.ord].masked = true
|
|
|
|
|
|
|
|
profApi.be = beDup
|
2024-02-29 21:10:24 +00:00
|
|
|
|
2024-03-07 19:24:05 +00:00
|
|
|
when AutoValidateApiHooks:
|
2024-03-14 22:17:43 +00:00
|
|
|
profApi.validate
|
2024-03-07 19:24:05 +00:00
|
|
|
|
2024-02-29 21:10:24 +00:00
|
|
|
profApi
|
|
|
|
|
|
|
|
# ------------------------------------------------------------------------------
|
|
|
|
# End
|
|
|
|
# ------------------------------------------------------------------------------
|