Skip to content

Commit a1a9c6b

Browse files
authored
Merge AristoTxRef/KvtTxRef with their LayerRef (#3078)
* Merge AristoTxRef/KvtTxRef with their LayerRef also clean up unused files * rm unused test_rocksdb * Fix tests * lint
1 parent caca11b commit a1a9c6b

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+164
-569
lines changed

Makefile

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,6 @@ endif
241241

242242
# builds and runs the nimbus test suite
243243
test: | build deps rocksdb
244-
$(ENV_SCRIPT) nim test_rocksdb $(NIM_PARAMS) nimbus.nims
245244
$(ENV_SCRIPT) nim test $(NIM_PARAMS) nimbus.nims
246245

247246
test_import: nimbus_execution_client

execution_chain/db/aristo.nim

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# nimbus-eth1
2-
# Copyright (c) 2023-2024 Status Research & Development GmbH
2+
# Copyright (c) 2023-2025 Status Research & Development GmbH
33
# Licensed under either of
44
# * Apache License, version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or
55
# http://www.apache.org/licenses/LICENSE-2.0)
@@ -19,10 +19,10 @@ export
1919
aristo_api, aristo_constants
2020

2121
import
22-
aristo/aristo_init
22+
aristo/aristo_init/memory_only,
23+
aristo/aristo_init/init_common
2324
export
2425
MemBackendRef,
25-
VoidBackendRef,
2626
finish,
2727
init
2828

execution_chain/db/aristo/aristo_api.nim

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,9 @@ import
1818
results,
1919
./aristo_desc/desc_backend,
2020
./aristo_init/memory_db,
21-
"."/[aristo_delete, aristo_desc, aristo_fetch, aristo_init, aristo_merge,
21+
./aristo_init/memory_only,
22+
./aristo_init/init_common,
23+
"."/[aristo_delete, aristo_desc, aristo_fetch, aristo_merge,
2224
aristo_part, aristo_path, aristo_persist, aristo_profile, aristo_tx_frame]
2325

2426
export
@@ -379,9 +381,6 @@ proc dup(be: BackendRef): BackendRef =
379381
when AristoPersistentBackendOk:
380382
return RdbBackendRef(be).dup
381383

382-
of BackendVoid:
383-
discard
384-
385384
# ------------------------------------------------------------------------------
386385
# Public API constuctors
387386
# ------------------------------------------------------------------------------

execution_chain/db/aristo/aristo_check.nim

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import
1717
eth/common/hashes,
1818
results,
1919
./aristo_walk/persistent,
20-
"."/[aristo_desc, aristo_get, aristo_init],
20+
"."/[aristo_desc, aristo_get, aristo_init/memory_only],
2121
./aristo_check/[check_be, check_top, check_twig]
2222

2323
# ------------------------------------------------------------------------------
@@ -71,9 +71,6 @@ proc checkBE*(
7171
return MemBackendRef.checkBE db
7272
of BackendRocksDB:
7373
return RdbBackendRef.checkBE db
74-
of BackendVoid:
75-
return VoidBackendRef.checkBE db
76-
7774

7875
proc check*(
7976
db: AristoTxRef; # Database

execution_chain/db/aristo/aristo_check/check_be.nim

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,13 @@ import
1717
stew/interval_set,
1818
../../aristo,
1919
../aristo_walk/persistent,
20-
".."/[aristo_desc, aristo_get, aristo_layers]
20+
".."/[aristo_desc, aristo_get]
2121

2222
# ------------------------------------------------------------------------------
2323
# Public functions
2424
# ------------------------------------------------------------------------------
2525

26-
proc checkBE*[T: RdbBackendRef|MemBackendRef|VoidBackendRef](
26+
proc checkBE*[T: RdbBackendRef|MemBackendRef](
2727
_: type T;
2828
db: AristoDbRef; # Database, top layer
2929
): Result[void,(VertexID,AristoError)] =

execution_chain/db/aristo/aristo_check/check_top.nim

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ proc checkTopCommon*(
7575
let
7676
kMapCount = db.layersWalkKey.toSeq.mapIt(it[1]).filterIt(it.isValid).len
7777
kMapNilCount = db.layersWalkKey.toSeq.len - kMapCount
78-
vTop = db.layer.vTop
78+
vTop = db.vTop
7979
var
8080
topVid = VertexID(0)
8181
stoRoots: HashSet[VertexID]

execution_chain/db/aristo/aristo_debug.nim

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ import
2525
# ------------------------------------------------------------------------------
2626

2727
func orDefault(db: AristoTxRef): AristoTxRef =
28-
if db.isNil: AristoTxRef(layer: LayerRef()) else: db
28+
if db.isNil: AristoTxRef() else: db
2929

3030
# --------------------------
3131

@@ -359,7 +359,7 @@ proc ppXMap*(
359359

360360

361361
proc ppBalancer(
362-
fl: LayerRef;
362+
fl: AristoTxRef;
363363
db: AristoTxRef;
364364
indent: int;
365365
): string =
@@ -434,7 +434,7 @@ proc ppBe[T](be: T; db: AristoTxRef; limit: int; indent: int): string =
434434
result &= "[]"
435435
436436
proc ppLayer(
437-
layer: LayerRef;
437+
layer: AristoTxRef;
438438
db: AristoTxRef;
439439
vTopOk: bool;
440440
sTabOk: bool;
@@ -663,7 +663,7 @@ func pp*(wp: VidVtxPair; db: AristoTxRef): string =
663663
664664
665665
proc pp*(
666-
layer: LayerRef;
666+
layer: AristoTxRef;
667667
db: AristoTxRef;
668668
indent = 4;
669669
sTabOk = true,
@@ -679,14 +679,12 @@ proc pp*(
679679
limit = 100;
680680
indent = 4;
681681
): string =
682-
result = db.layer.ppBalancer(db, indent+1) & indent.toPfx
682+
result = db.ppBalancer(db, indent+1) & indent.toPfx
683683
case be.kind:
684684
of BackendMemory:
685685
result &= be.MemBackendRef.ppBe(db, limit, indent+1)
686686
of BackendRocksDB:
687687
result &= be.RdbBackendRef.ppBe(db, limit, indent+1)
688-
of BackendVoid:
689-
result &= "<NoBackend>"
690688
691689
proc pp*(
692690
db: AristoTxRef;

execution_chain/db/aristo/aristo_desc.nim

Lines changed: 41 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,40 @@ export
4141
type
4242
AristoTxRef* = ref object
4343
## Transaction descriptor
44-
db*: AristoDbRef ## Database descriptor
45-
parent*: AristoTxRef ## Previous transaction
46-
layer*: LayerRef
47-
blockNumber*: Opt[uint64] ## Block number set when freezing the frame
44+
##
45+
## Delta layers are stacked implying a tables hierarchy. Table entries on
46+
## a higher level take precedence over lower layer table entries. So an
47+
## existing key-value table entry of a layer on top supersedes same key
48+
## entries on all lower layers. A missing entry on a higher layer indicates
49+
## that the key-value pair might be fond on some lower layer.
50+
##
51+
## A zero value (`nil`, empty hash etc.) is considered am missing key-value
52+
## pair. Tables on the `LayerDelta` may have stray zero key-value pairs for
53+
## missing entries due to repeated transactions while adding and deleting
54+
## entries. There is no need to purge redundant zero entries.
55+
##
56+
## As for `kMap[]` entries, there might be a zero value entriy relating
57+
## (i.e. indexed by the same vertex ID) to an `sMap[]` non-zero value entry
58+
## (of the same layer or a lower layer whatever comes first.) This entry
59+
## is kept as a reminder that the hash value of the `kMap[]` entry needs
60+
## to be re-compiled.
61+
##
62+
## The reasoning behind the above scenario is that every vertex held on the
63+
## `sTab[]` tables must correspond to a hash entry held on the `kMap[]`
64+
## tables. So a corresponding zero value or missing entry produces an
65+
## inconsistent state that must be resolved.
66+
db*: AristoDbRef ## Database descriptor
67+
parent*: AristoTxRef ## Previous transaction
68+
69+
sTab*: Table[RootedVertexID,VertexRef] ## Structural vertex table
70+
kMap*: Table[RootedVertexID,HashKey] ## Merkle hash key mapping
71+
vTop*: VertexID ## Last used vertex ID
72+
73+
accLeaves*: Table[Hash32, VertexRef] ## Account path -> VertexRef
74+
stoLeaves*: Table[Hash32, VertexRef] ## Storage path -> VertexRef
75+
76+
cTop*: VertexID ## Last committed vertex ID
77+
blockNumber*: Opt[uint64] ## Block number set when freezing the frame
4878

4979
AristoDbRef* = ref object
5080
## Three tier database object supporting distributed instances.
@@ -120,8 +150,8 @@ func isValid*(nd: NodeRef): bool =
120150
func isValid*(pid: PathID): bool =
121151
pid != VOID_PATH_ID
122152
123-
func isValid*(layer: LayerRef): bool =
124-
layer != LayerRef(nil)
153+
func isValid*(tx: AristoTxRef): bool =
154+
tx != AristoTxRef(nil)
125155
126156
func isValid*(root: Hash32): bool =
127157
root != emptyRoot
@@ -163,21 +193,21 @@ iterator stack*(tx: AristoTxRef): AristoTxRef =
163193
while frames.len > 0:
164194
yield frames.pop()
165195
166-
iterator rstack*(tx: AristoTxRef): (LayerRef, int) =
196+
iterator rstack*(tx: AristoTxRef): (AristoTxRef, int) =
167197
# Stack in reverse order, ie going from tx to base
168198
var tx = tx
169199
170200
var i = 0
171201
while tx != nil:
172202
let level = if tx.parent == nil: -1 else: i
173-
yield (tx.layer, level)
203+
yield (tx, level)
174204
tx = tx.parent
175205
176-
proc deltaAtLevel*(db: AristoTxRef, level: int): LayerRef =
206+
proc deltaAtLevel*(db: AristoTxRef, level: int): AristoTxRef =
177207
if level == -2:
178208
nil
179209
elif level == -1:
180-
db.db.txRef.layer
210+
db.db.txRef
181211
else:
182212
var
183213
frame = db
@@ -187,7 +217,7 @@ proc deltaAtLevel*(db: AristoTxRef, level: int): LayerRef =
187217
frame = frame.parent
188218
level -= 1
189219
190-
frame.layer
220+
frame
191221
192222
# ------------------------------------------------------------------------------
193223
# End

execution_chain/db/aristo/aristo_desc/desc_error.nim

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -12,17 +12,6 @@ type
1212
AristoError* = enum
1313
NothingSerious = 0
1414

15-
# Miscelaneous/unclassified handy helpers
16-
GenericError
17-
18-
19-
# Data record transcoders, `blobify()` from `blobify.nim`
20-
BlobifyBranchMissingRefs
21-
BlobifyExtMissingRefs
22-
BlobifyExtPathOverflow
23-
BlobifyLeafPathOverflow
24-
BlobifyNilVertex
25-
2615

2716
# Cache checker `checkCache()`
2817
CheckAnyVidDeadStorageRoot
@@ -79,17 +68,6 @@ type
7968
DelStoRootNotAccepted
8069
DelVidStaleVtx
8170

82-
# Functions from `aristo_desc.nim`
83-
DescMustBeOnCentre
84-
DescNotAllowedOnCentre
85-
DescStaleDescriptor
86-
87-
88-
# Functions from `aristo_delta.nim`
89-
FilBackendRoMode
90-
FilSiblingsCommitUnfinshed
91-
92-
9371
# Fetch functions from `aristo_fetch.nim`
9472
FetchAccInaccessible
9573
FetchAccPathWithoutLeaf
@@ -205,7 +183,6 @@ type
205183
PartVtxSlotWasNotModified
206184

207185
# RocksDB backend
208-
RdbBeCantCreateDataDir
209186
RdbBeCantCreateTmpDir
210187
RdbBeDriverDelAdmError
211188
RdbBeDriverDelKeyError

execution_chain/db/aristo/aristo_desc/desc_structural.nim

Lines changed: 0 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -94,37 +94,6 @@ type
9494
key*: Hash32 ## Some state hash (if any)
9595
serial*: uint64 ## Generic identifier from application
9696

97-
LayerRef* = ref Layer
98-
Layer* = object
99-
## Delta layers are stacked implying a tables hierarchy. Table entries on
100-
## a higher level take precedence over lower layer table entries. So an
101-
## existing key-value table entry of a layer on top supersedes same key
102-
## entries on all lower layers. A missing entry on a higher layer indicates
103-
## that the key-value pair might be fond on some lower layer.
104-
##
105-
## A zero value (`nil`, empty hash etc.) is considered am missing key-value
106-
## pair. Tables on the `LayerDelta` may have stray zero key-value pairs for
107-
## missing entries due to repeated transactions while adding and deleting
108-
## entries. There is no need to purge redundant zero entries.
109-
##
110-
## As for `kMap[]` entries, there might be a zero value entriy relating
111-
## (i.e. indexed by the same vertex ID) to an `sMap[]` non-zero value entry
112-
## (of the same layer or a lower layer whatever comes first.) This entry
113-
## is kept as a reminder that the hash value of the `kMap[]` entry needs
114-
## to be re-compiled.
115-
##
116-
## The reasoning behind the above scenario is that every vertex held on the
117-
## `sTab[]` tables must correspond to a hash entry held on the `kMap[]`
118-
## tables. So a corresponding zero value or missing entry produces an
119-
## inconsistent state that must be resolved.
120-
##
121-
sTab*: Table[RootedVertexID,VertexRef] ## Structural vertex table
122-
kMap*: Table[RootedVertexID,HashKey] ## Merkle hash key mapping
123-
vTop*: VertexID ## Last used vertex ID
124-
125-
accLeaves*: Table[Hash32, VertexRef] ## Account path -> VertexRef
126-
stoLeaves*: Table[Hash32, VertexRef] ## Storage path -> VertexRef
127-
12897
GetVtxFlag* = enum
12998
PeekCache
13099
## Peek into, but don't update cache - useful on work loads that are

0 commit comments

Comments
 (0)