mirror of
https://github.com/status-im/nimbus-eth1.git
synced 2025-01-13 05:44:40 +00:00
aristo: remove replicate
(#2758)
Not used, not tested, mostly obsolete due to how key table has become a cache
This commit is contained in:
parent
2decb618c8
commit
503dcd40c4
@ -54,14 +54,6 @@ iterator walkPairs*[T: MemBackendRef|VoidBackendRef](
|
|||||||
for (rvid,vtx) in walkPairsImpl[T](db):
|
for (rvid,vtx) in walkPairsImpl[T](db):
|
||||||
yield (rvid,vtx)
|
yield (rvid,vtx)
|
||||||
|
|
||||||
iterator replicate*[T: MemBackendRef|VoidBackendRef](
|
|
||||||
_: type T;
|
|
||||||
db: AristoDbRef;
|
|
||||||
): tuple[rvid: RootedVertexID, key: HashKey, vtx: VertexRef, node: NodeRef] =
|
|
||||||
## Variant of `walkPairsImpl()` for legacy applications.
|
|
||||||
for (rvid,key,vtx,node) in replicateImpl[T](db):
|
|
||||||
yield (rvid,key,vtx,node)
|
|
||||||
|
|
||||||
# ------------------------------------------------------------------------------
|
# ------------------------------------------------------------------------------
|
||||||
# End
|
# End
|
||||||
# ------------------------------------------------------------------------------
|
# ------------------------------------------------------------------------------
|
||||||
|
@ -59,14 +59,6 @@ iterator walkPairs*[T: RdbBackendRef](
|
|||||||
for (rvid,vtx) in walkPairsImpl[T](db):
|
for (rvid,vtx) in walkPairsImpl[T](db):
|
||||||
yield (rvid,vtx)
|
yield (rvid,vtx)
|
||||||
|
|
||||||
iterator replicate*[T: RdbBackendRef](
|
|
||||||
_: type T;
|
|
||||||
db: AristoDbRef;
|
|
||||||
): tuple[rvid: RootedVertexID, key: HashKey, vtx: VertexRef, node: NodeRef] =
|
|
||||||
## Variant of `walkPairsImpl()` for legacy applications.
|
|
||||||
for (rvid,key,vtx,node) in replicateImpl[T](db):
|
|
||||||
yield (rvid,key,vtx,node)
|
|
||||||
|
|
||||||
# ------------------------------------------------------------------------------
|
# ------------------------------------------------------------------------------
|
||||||
# End
|
# End
|
||||||
# ------------------------------------------------------------------------------
|
# ------------------------------------------------------------------------------
|
||||||
|
@ -90,19 +90,6 @@ iterator walkPairsImpl*[T](
|
|||||||
if rvid.vid notin seen:
|
if rvid.vid notin seen:
|
||||||
yield (rvid,vtx)
|
yield (rvid,vtx)
|
||||||
|
|
||||||
iterator replicateImpl*[T](
|
|
||||||
db: AristoDbRef; # Database with top layer & backend filter
|
|
||||||
): tuple[rvid: RootedVertexID, key: HashKey, vtx: VertexRef, node: NodeRef] =
|
|
||||||
## Variant of `walkPairsImpl()` for legacy applications.
|
|
||||||
for (rvid,vtx) in walkPairsImpl[T](db):
|
|
||||||
let node = block:
|
|
||||||
let rc = vtx.toNode(rvid.root, db)
|
|
||||||
if rc.isOk:
|
|
||||||
rc.value
|
|
||||||
else:
|
|
||||||
NodeRef(nil)
|
|
||||||
yield (rvid, db.getKey rvid, vtx, node)
|
|
||||||
|
|
||||||
# ------------------------------------------------------------------------------
|
# ------------------------------------------------------------------------------
|
||||||
# End
|
# End
|
||||||
# ------------------------------------------------------------------------------
|
# ------------------------------------------------------------------------------
|
||||||
|
@ -1,74 +0,0 @@
|
|||||||
# Nimbus
|
|
||||||
# Copyright (c) 2023-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.
|
|
||||||
|
|
||||||
## Generic iterator, prototype to be included (rather than imported). Using
|
|
||||||
## an include file avoids duplicating code because the `T` argument is not
|
|
||||||
## bound to any object type. Otherwise all object types would be required
|
|
||||||
## when providing this iterator for import.
|
|
||||||
##
|
|
||||||
## This is not wanted here, because the import of a **pesistent** object
|
|
||||||
## would always require extra linking.
|
|
||||||
|
|
||||||
template valueOrApiError[U,V](rc: Result[U,V]; info: static[string]): U =
|
|
||||||
rc.valueOr: raise (ref CoreDbApiError)(msg: info)
|
|
||||||
|
|
||||||
template dbType(dsc: CoreDbKvtRef | CoreDbMptRef | CoreDbAccRef): CoreDbType =
|
|
||||||
dsc.distinctBase.parent.dbType
|
|
||||||
|
|
||||||
# ---------------
|
|
||||||
|
|
||||||
template kvt(dsc: CoreDbKvtRef): KvtDbRef =
|
|
||||||
dsc.distinctBase.kvt
|
|
||||||
|
|
||||||
template call(api: KvtApiRef; fn: untyped; args: varArgs[untyped]): untyped =
|
|
||||||
when CoreDbEnableApiJumpTable:
|
|
||||||
api.fn(args)
|
|
||||||
else:
|
|
||||||
fn(args)
|
|
||||||
|
|
||||||
template call(kvt: CoreDbKvtRef; fn: untyped; args: varArgs[untyped]): untyped =
|
|
||||||
kvt.distinctBase.parent.kvtApi.call(fn, args)
|
|
||||||
|
|
||||||
# ---------------
|
|
||||||
|
|
||||||
template mpt(dsc: CoreDbAccRef | CoreDbMptRef): AristoDbRef =
|
|
||||||
dsc.distinctBase.mpt
|
|
||||||
|
|
||||||
template call(api: AristoApiRef; fn: untyped; args: varArgs[untyped]): untyped =
|
|
||||||
when CoreDbEnableApiJumpTable:
|
|
||||||
api.fn(args)
|
|
||||||
else:
|
|
||||||
fn(args)
|
|
||||||
|
|
||||||
template call(
|
|
||||||
acc: CoreDbAccRef | CoreDbMptRef;
|
|
||||||
fn: untyped;
|
|
||||||
args: varArgs[untyped];
|
|
||||||
): untyped =
|
|
||||||
acc.distinctBase.parent.ariApi.call(fn, args)
|
|
||||||
|
|
||||||
# ---------------
|
|
||||||
|
|
||||||
iterator aristoReplicate[T](
|
|
||||||
mpt: CoreDbMptRef;
|
|
||||||
): (seq[byte],seq[byte])
|
|
||||||
{.gcsafe, raises: [CoreDbApiError].} =
|
|
||||||
## Generic iterator used for building dedicated backend iterators.
|
|
||||||
##
|
|
||||||
let p = mpt.call(forkTx, mpt.mpt, 0).valueOrApiError "aristoReplicate()"
|
|
||||||
defer: discard mpt.call(forget, p)
|
|
||||||
for (rVid,key,vtx,node) in T.replicate(p):
|
|
||||||
let w = node.to(seq[seq[byte]])
|
|
||||||
yield (@(key.data),w[0])
|
|
||||||
if 1 < w.len:
|
|
||||||
# Was an extension merged into a branch
|
|
||||||
yield (@(w[1].digestTo(HashKey).data),w[1])
|
|
||||||
|
|
||||||
# End
|
|
@ -87,7 +87,6 @@ type
|
|||||||
MptMergeFn = "mpt/merge"
|
MptMergeFn = "mpt/merge"
|
||||||
MptProofFn = "mpt/proof"
|
MptProofFn = "mpt/proof"
|
||||||
MptPairsIt = "mpt/pairs"
|
MptPairsIt = "mpt/pairs"
|
||||||
MptReplicateIt = "mpt/replicate"
|
|
||||||
MptStateFn = "mpt/state"
|
MptStateFn = "mpt/state"
|
||||||
|
|
||||||
TxCommitFn = "commit"
|
TxCommitFn = "commit"
|
||||||
|
@ -15,7 +15,6 @@ import
|
|||||||
eth/common,
|
eth/common,
|
||||||
../../errors,
|
../../errors,
|
||||||
../aristo as use_ari,
|
../aristo as use_ari,
|
||||||
../aristo/[aristo_walk, aristo_serialise],
|
|
||||||
../kvt as use_kvt,
|
../kvt as use_kvt,
|
||||||
../kvt/[kvt_init/memory_only, kvt_walk],
|
../kvt/[kvt_init/memory_only, kvt_walk],
|
||||||
./base/[api_tracking, base_config, base_desc]
|
./base/[api_tracking, base_config, base_desc]
|
||||||
@ -24,12 +23,9 @@ when CoreDbEnableApiJumpTable:
|
|||||||
discard
|
discard
|
||||||
else:
|
else:
|
||||||
import
|
import
|
||||||
../aristo/[aristo_desc, aristo_path, aristo_tx],
|
../aristo/[aristo_desc, aristo_path],
|
||||||
../kvt/[kvt_desc, kvt_tx]
|
../kvt/[kvt_desc, kvt_tx]
|
||||||
|
|
||||||
include
|
|
||||||
./backend/aristo_replicate
|
|
||||||
|
|
||||||
when CoreDbEnableApiTracking:
|
when CoreDbEnableApiTracking:
|
||||||
import
|
import
|
||||||
chronicles
|
chronicles
|
||||||
@ -41,6 +37,44 @@ when CoreDbEnableApiTracking:
|
|||||||
# Annotation helper(s)
|
# Annotation helper(s)
|
||||||
{.pragma: apiRaise, gcsafe, raises: [CoreDbApiError].}
|
{.pragma: apiRaise, gcsafe, raises: [CoreDbApiError].}
|
||||||
|
|
||||||
|
template valueOrApiError[U,V](rc: Result[U,V]; info: static[string]): U =
|
||||||
|
rc.valueOr: raise (ref CoreDbApiError)(msg: info)
|
||||||
|
|
||||||
|
template dbType(dsc: CoreDbKvtRef | CoreDbMptRef | CoreDbAccRef): CoreDbType =
|
||||||
|
dsc.distinctBase.parent.dbType
|
||||||
|
|
||||||
|
# ---------------
|
||||||
|
|
||||||
|
template kvt(dsc: CoreDbKvtRef): KvtDbRef =
|
||||||
|
dsc.distinctBase.kvt
|
||||||
|
|
||||||
|
template call(api: KvtApiRef; fn: untyped; args: varArgs[untyped]): untyped =
|
||||||
|
when CoreDbEnableApiJumpTable:
|
||||||
|
api.fn(args)
|
||||||
|
else:
|
||||||
|
fn(args)
|
||||||
|
|
||||||
|
template call(kvt: CoreDbKvtRef; fn: untyped; args: varArgs[untyped]): untyped =
|
||||||
|
kvt.distinctBase.parent.kvtApi.call(fn, args)
|
||||||
|
|
||||||
|
# ---------------
|
||||||
|
|
||||||
|
template mpt(dsc: CoreDbAccRef | CoreDbMptRef): AristoDbRef =
|
||||||
|
dsc.distinctBase.mpt
|
||||||
|
|
||||||
|
template call(api: AristoApiRef; fn: untyped; args: varArgs[untyped]): untyped =
|
||||||
|
when CoreDbEnableApiJumpTable:
|
||||||
|
api.fn(args)
|
||||||
|
else:
|
||||||
|
fn(args)
|
||||||
|
|
||||||
|
template call(
|
||||||
|
acc: CoreDbAccRef | CoreDbMptRef;
|
||||||
|
fn: untyped;
|
||||||
|
args: varArgs[untyped];
|
||||||
|
): untyped =
|
||||||
|
acc.distinctBase.parent.ariApi.call(fn, args)
|
||||||
|
|
||||||
# ------------------------------------------------------------------------------
|
# ------------------------------------------------------------------------------
|
||||||
# Public iterators
|
# Public iterators
|
||||||
# ------------------------------------------------------------------------------
|
# ------------------------------------------------------------------------------
|
||||||
@ -89,21 +123,6 @@ iterator slotPairs*(acc: CoreDbAccRef; accPath: Hash32): (seq[byte], UInt256) =
|
|||||||
acc.ifTrackNewApi:
|
acc.ifTrackNewApi:
|
||||||
debug logTxt, api, elapsed
|
debug logTxt, api, elapsed
|
||||||
|
|
||||||
iterator replicate*(mpt: CoreDbMptRef): (seq[byte], seq[byte]) {.apiRaise.} =
|
|
||||||
## Low level trie dump, only supported for non persistent `CoreDbMptRef`
|
|
||||||
##
|
|
||||||
mpt.setTrackNewApi MptReplicateIt
|
|
||||||
case mpt.dbType:
|
|
||||||
of AristoDbMemory:
|
|
||||||
for k,v in aristoReplicate[use_ari.MemBackendRef](mpt):
|
|
||||||
yield (k,v)
|
|
||||||
of AristoDbVoid:
|
|
||||||
for k,v in aristoReplicate[use_ari.VoidBackendRef](mpt):
|
|
||||||
yield (k,v)
|
|
||||||
of Ooops, AristoDbRocks:
|
|
||||||
raiseAssert: "Unsupported database type: " & $mpt.dbType
|
|
||||||
mpt.ifTrackNewApi: debug logTxt, api, elapsed
|
|
||||||
|
|
||||||
# ------------------------------------------------------------------------------
|
# ------------------------------------------------------------------------------
|
||||||
# End
|
# End
|
||||||
# ------------------------------------------------------------------------------
|
# ------------------------------------------------------------------------------
|
||||||
|
@ -1,61 +0,0 @@
|
|||||||
# Nimbus
|
|
||||||
# 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.
|
|
||||||
|
|
||||||
{.push raises: [].}
|
|
||||||
|
|
||||||
import
|
|
||||||
std/typetraits,
|
|
||||||
eth/common,
|
|
||||||
../../errors,
|
|
||||||
../aristo as use_ari,
|
|
||||||
../aristo/aristo_init/rocks_db,
|
|
||||||
../aristo/[aristo_desc, aristo_walk/persistent, aristo_serialise, aristo_tx],
|
|
||||||
../kvt, # needed for `aristo_replicate`
|
|
||||||
./base/[api_tracking, base_config, base_desc], ./base
|
|
||||||
|
|
||||||
include
|
|
||||||
./backend/aristo_replicate
|
|
||||||
|
|
||||||
when CoreDbEnableApiTracking:
|
|
||||||
import
|
|
||||||
chronicles
|
|
||||||
logScope:
|
|
||||||
topics = "core_db"
|
|
||||||
const
|
|
||||||
logTxt = "API"
|
|
||||||
|
|
||||||
# Annotation helper(s)
|
|
||||||
{.pragma: rlpRaise, gcsafe, raises: [CoreDbApiError].}
|
|
||||||
|
|
||||||
# ------------------------------------------------------------------------------
|
|
||||||
# Public iterators
|
|
||||||
# ------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
iterator replicatePersistent*(mpt: CoreDbMptRef): (seq[byte], seq[byte]) {.rlpRaise.} =
|
|
||||||
## Extended version of `replicate()` for `Aristo` persistent backend.
|
|
||||||
##
|
|
||||||
mpt.setTrackNewApi MptReplicateIt
|
|
||||||
case mpt.dbType:
|
|
||||||
of AristoDbMemory:
|
|
||||||
for k,v in aristoReplicate[use_ari.MemBackendRef](mpt):
|
|
||||||
yield (k,v)
|
|
||||||
of AristoDbVoid:
|
|
||||||
for k,v in aristoReplicate[use_ari.VoidBackendRef](mpt):
|
|
||||||
yield (k,v)
|
|
||||||
of AristoDbRocks:
|
|
||||||
for k, v in aristoReplicate[rocks_db.RdbBackendRef](mpt):
|
|
||||||
yield (k, v)
|
|
||||||
else:
|
|
||||||
raiseAssert: "Unsupported database type: " & $mpt.dbType
|
|
||||||
mpt.ifTrackNewApi: debug logTxt, api, elapsed
|
|
||||||
|
|
||||||
# ------------------------------------------------------------------------------
|
|
||||||
# End
|
|
||||||
# ------------------------------------------------------------------------------
|
|
@ -24,13 +24,11 @@
|
|||||||
import
|
import
|
||||||
../aristo,
|
../aristo,
|
||||||
./memory_only,
|
./memory_only,
|
||||||
base_iterators_persistent,
|
|
||||||
./backend/aristo_rocksdb,
|
./backend/aristo_rocksdb,
|
||||||
../opts
|
../opts
|
||||||
|
|
||||||
export
|
export
|
||||||
memory_only,
|
memory_only
|
||||||
base_iterators_persistent
|
|
||||||
|
|
||||||
proc newCoreDbRef*(
|
proc newCoreDbRef*(
|
||||||
dbType: static[CoreDbType]; # Database type symbol
|
dbType: static[CoreDbType]; # Database type symbol
|
||||||
|
Loading…
x
Reference in New Issue
Block a user