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
|
|
|
# Nimbus
|
2024-02-02 20:23:04 +00:00
|
|
|
# Copyright (c) 2023-2024 Status Research & Development GmbH
|
2023-10-03 11:56: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.
|
|
|
|
|
|
|
|
import
|
|
|
|
eth/common,
|
2024-02-12 19:37:00 +00:00
|
|
|
../../nimbus/db/core_db,
|
2023-10-03 11:56:13 +00:00
|
|
|
../../nimbus/common/chain_config
|
|
|
|
|
|
|
|
type
|
|
|
|
CaptureSpecs* = object
|
2024-02-09 13:30:07 +00:00
|
|
|
name*: string ## Sample name, also used as db directory
|
|
|
|
case builtIn*: bool
|
|
|
|
of true:
|
|
|
|
network*: NetworkId ## Built-in network ID (unless `config` below)
|
|
|
|
else:
|
|
|
|
genesis*: string ## Optional config file (instead of `network`)
|
|
|
|
files*: seq[string] ## Names of capture files
|
|
|
|
numBlocks*: int ## Number of blocks to load
|
2024-02-12 19:37:00 +00:00
|
|
|
dbType*: CoreDbType ## Use `CoreDbType(0)` for default
|
2023-10-03 11:56:13 +00:00
|
|
|
|
2024-02-29 21:10:24 +00:00
|
|
|
func cloneWith(
|
|
|
|
dsc: CaptureSpecs;
|
|
|
|
name = "";
|
|
|
|
network = NetworkId(0);
|
|
|
|
genesis = "";
|
|
|
|
files = seq[string].default;
|
|
|
|
numBlocks = 0;
|
|
|
|
dbType = CoreDbType(0);
|
|
|
|
): CaptureSpecs =
|
|
|
|
result = dsc
|
|
|
|
if network != NetworkId(0):
|
|
|
|
result.builtIn = true
|
|
|
|
result.network = network
|
|
|
|
elif 0 < genesis.len:
|
|
|
|
result.builtIn = false
|
|
|
|
result.genesis = genesis
|
|
|
|
if 0 < name.len:
|
|
|
|
if name[0] == '-':
|
|
|
|
result.name &= name
|
|
|
|
elif name[0] == '+' and 1 < name.len:
|
|
|
|
result.name &= name[1 .. ^1]
|
|
|
|
else:
|
|
|
|
result.name = name
|
|
|
|
if 0 < files.len:
|
|
|
|
result.files = files
|
|
|
|
if 0 < numBlocks:
|
|
|
|
result.numBlocks = numBlocks
|
|
|
|
if dbType != CoreDbType(0):
|
|
|
|
result.dbType = dbType
|
|
|
|
|
|
|
|
|
2024-02-09 13:30:07 +00:00
|
|
|
# Must not use `const` here, see `//github.com/nim-lang/Nim/issues/23295`
|
|
|
|
# Waiting for fix `//github.com/nim-lang/Nim/pull/23297` (or similar) to
|
|
|
|
# appear on local `Nim` compiler version.
|
|
|
|
let
|
2024-02-29 21:10:24 +00:00
|
|
|
goerliSample = CaptureSpecs(
|
|
|
|
builtIn: true,
|
|
|
|
name: "goerli",
|
|
|
|
network: GoerliNet,
|
2024-05-20 13:59:18 +00:00
|
|
|
files: @["goerli68161.txt.gz"]) # on local replay folder
|
2024-02-29 21:10:24 +00:00
|
|
|
|
|
|
|
goerliSampleEx = CaptureSpecs(
|
|
|
|
builtIn: true,
|
|
|
|
name: "goerli",
|
|
|
|
network: GoerliNet,
|
|
|
|
files: @[
|
2024-05-20 13:59:18 +00:00
|
|
|
"goerli482304.txt.gz", # on nimbus-eth1-blobs/replay
|
2024-02-29 21:10:24 +00:00
|
|
|
"goerli482305-504192.txt.gz"])
|
|
|
|
|
2024-05-20 13:59:18 +00:00
|
|
|
mainSample = CaptureSpecs(
|
|
|
|
builtIn: true,
|
|
|
|
name: "main",
|
|
|
|
network: MainNet,
|
|
|
|
files: @["mainnet-00000-5ec1ffb8.era1"], # on local replay folder
|
|
|
|
numBlocks: high(int),
|
|
|
|
dbType: AristoDbRocks)
|
|
|
|
|
2024-02-29 21:10:24 +00:00
|
|
|
mainSampleEx = CaptureSpecs(
|
|
|
|
builtIn: true,
|
|
|
|
name: "main",
|
|
|
|
network: MainNet,
|
2024-05-20 13:59:18 +00:00
|
|
|
# will run over all avail files in parent folder
|
|
|
|
files: @["mainnet-era1.txt"]) # on external repo
|
2024-02-29 21:10:24 +00:00
|
|
|
|
|
|
|
# ------------------
|
|
|
|
|
2024-05-20 13:59:18 +00:00
|
|
|
# Supposed to run mostly on defaults
|
|
|
|
bulkTest0* = mainSample
|
2024-02-29 21:10:24 +00:00
|
|
|
.cloneWith(
|
|
|
|
name = "-more",
|
|
|
|
numBlocks = high(int))
|
|
|
|
|
2024-05-20 13:59:18 +00:00
|
|
|
bulkTest1* = mainSample
|
2024-02-29 21:10:24 +00:00
|
|
|
.cloneWith(
|
2024-05-20 13:59:18 +00:00
|
|
|
name = "-some",
|
|
|
|
numBlocks = 1_000)
|
2024-02-09 13:30:07 +00:00
|
|
|
|
2024-05-20 13:59:18 +00:00
|
|
|
bulkTest2* = mainSampleEx
|
2024-02-29 21:10:24 +00:00
|
|
|
.cloneWith(
|
|
|
|
name = "-am",
|
2024-05-20 13:59:18 +00:00
|
|
|
numBlocks = 500_000,
|
2024-02-29 21:10:24 +00:00
|
|
|
dbType = AristoDbMemory)
|
|
|
|
|
2024-05-20 13:59:18 +00:00
|
|
|
bulkTest3* = mainSampleEx
|
2024-02-29 21:10:24 +00:00
|
|
|
.cloneWith(
|
|
|
|
name = "-ar",
|
|
|
|
numBlocks = high(int),
|
|
|
|
dbType = AristoDbRocks)
|
|
|
|
|
2024-05-20 13:59:18 +00:00
|
|
|
|
|
|
|
bulkTest4* = goerliSample
|
|
|
|
.cloneWith(
|
|
|
|
name = "-more",
|
|
|
|
numBlocks = high(int))
|
|
|
|
|
|
|
|
bulkTest5* = goerliSample
|
|
|
|
.cloneWith(
|
|
|
|
name = "-some",
|
|
|
|
numBlocks = 1_000)
|
|
|
|
|
|
|
|
bulkTest6* = goerliSampleEx
|
2024-02-29 21:10:24 +00:00
|
|
|
.cloneWith(
|
|
|
|
name = "-am",
|
2024-05-20 13:59:18 +00:00
|
|
|
numBlocks = high(int),
|
2024-02-29 21:10:24 +00:00
|
|
|
dbType = AristoDbMemory)
|
|
|
|
|
2024-05-20 13:59:18 +00:00
|
|
|
bulkTest7* = goerliSampleEx
|
2024-02-29 21:10:24 +00:00
|
|
|
.cloneWith(
|
|
|
|
name = "-ar",
|
|
|
|
numBlocks = high(int),
|
|
|
|
dbType = AristoDbRocks)
|
|
|
|
|
2024-02-12 19:37:00 +00:00
|
|
|
# ------------------
|
|
|
|
|
|
|
|
allSamples* = [
|
|
|
|
bulkTest0, bulkTest1, bulkTest2, bulkTest3,
|
2024-05-20 13:59:18 +00:00
|
|
|
bulkTest4, bulkTest5, bulkTest6, bulkTest7]
|
2023-10-18 19:27:22 +00:00
|
|
|
|
2023-10-03 11:56:13 +00:00
|
|
|
# End
|