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-01 21:27:48 +00:00
|
|
|
# Copyright (c) 2023-2024 Status Research & Development GmbH
|
2023-08-17 13:42:01 +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.
|
|
|
|
|
|
|
|
## Aristo (aka Patricia) DB records distributed backend access test.
|
|
|
|
##
|
|
|
|
|
|
|
|
import
|
|
|
|
eth/common,
|
|
|
|
results,
|
|
|
|
unittest2,
|
2024-06-05 15:08:29 +00:00
|
|
|
../../nimbus/db/opts,
|
2024-06-19 08:55:57 +00:00
|
|
|
../../nimbus/db/core_db/backend/aristo_rocksdb,
|
2023-08-17 13:42:01 +00:00
|
|
|
../../nimbus/db/aristo/[
|
2024-02-29 21:10:24 +00:00
|
|
|
aristo_check,
|
|
|
|
aristo_debug,
|
|
|
|
aristo_desc,
|
|
|
|
aristo_get,
|
|
|
|
aristo_persistent,
|
|
|
|
aristo_tx],
|
2023-10-11 19:09:11 +00:00
|
|
|
../replay/xcheck,
|
2023-08-17 13:42:01 +00:00
|
|
|
./test_helpers
|
|
|
|
|
|
|
|
type
|
2023-08-18 19:46:55 +00:00
|
|
|
LeafQuartet =
|
|
|
|
array[0..3, seq[LeafTiePayload]]
|
2023-08-17 13:42:01 +00:00
|
|
|
|
2023-08-18 19:46:55 +00:00
|
|
|
DbTriplet =
|
|
|
|
array[0..2, AristoDbRef]
|
2023-08-17 13:42:01 +00:00
|
|
|
|
2024-06-18 11:14:02 +00:00
|
|
|
const
|
|
|
|
testRootVid = VertexID(2)
|
|
|
|
## Need to reconfigure for the test, root ID 1 cannot be deleted as a trie
|
|
|
|
|
2023-08-17 13:42:01 +00:00
|
|
|
# ------------------------------------------------------------------------------
|
|
|
|
# Private debugging helpers
|
|
|
|
# ------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
proc dump(pfx: string; dx: varargs[AristoDbRef]): string =
|
|
|
|
if 0 < dx.len:
|
|
|
|
result = "\n "
|
|
|
|
var
|
|
|
|
pfx = pfx
|
|
|
|
qfx = ""
|
|
|
|
if pfx.len == 0:
|
|
|
|
(pfx,qfx) = ("[","]")
|
|
|
|
elif 1 < dx.len:
|
|
|
|
pfx = pfx & "#"
|
|
|
|
for n in 0 ..< dx.len:
|
|
|
|
let n1 = n + 1
|
|
|
|
result &= pfx
|
|
|
|
if 1 < dx.len:
|
|
|
|
result &= $n1
|
2023-12-12 17:47:41 +00:00
|
|
|
result &= qfx & "\n " & dx[n].pp(backendOk=true) & "\n"
|
2023-08-17 13:42:01 +00:00
|
|
|
if n1 < dx.len:
|
|
|
|
result &= " ==========\n "
|
|
|
|
|
2024-07-17 19:27:33 +00:00
|
|
|
proc dump(dx: varargs[AristoDbRef]): string {.used.} =
|
|
|
|
"".dump dx
|
2023-08-17 13:42:01 +00:00
|
|
|
|
2024-07-17 19:27:33 +00:00
|
|
|
proc dump(w: DbTriplet): string {.used.} =
|
|
|
|
"db".dump(w[0], w[1], w[2])
|
2023-08-17 13:42:01 +00:00
|
|
|
|
|
|
|
# ------------------------------------------------------------------------------
|
|
|
|
# Private helpers
|
|
|
|
# ------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
iterator quadripartite(td: openArray[ProofTrieData]): LeafQuartet =
|
|
|
|
## ...
|
|
|
|
var collect: seq[seq[LeafTiePayload]]
|
|
|
|
|
|
|
|
for w in td:
|
2024-06-18 11:14:02 +00:00
|
|
|
let lst = w.kvpLst.mapRootVid testRootVid
|
2023-08-17 13:42:01 +00:00
|
|
|
|
|
|
|
if lst.len < 8:
|
|
|
|
if 2 < collect.len:
|
2023-08-18 19:46:55 +00:00
|
|
|
yield [collect[0], collect[1], collect[2], lst]
|
2023-08-17 13:42:01 +00:00
|
|
|
collect.setLen(0)
|
|
|
|
else:
|
|
|
|
collect.add lst
|
|
|
|
else:
|
|
|
|
if collect.len == 0:
|
|
|
|
let a = lst.len div 4
|
2023-08-18 19:46:55 +00:00
|
|
|
yield [lst[0 ..< a], lst[a ..< 2*a], lst[2*a ..< 3*a], lst[3*a .. ^1]]
|
2023-08-17 13:42:01 +00:00
|
|
|
else:
|
|
|
|
if collect.len == 1:
|
|
|
|
let a = lst.len div 3
|
2023-08-18 19:46:55 +00:00
|
|
|
yield [collect[0], lst[0 ..< a], lst[a ..< 2*a], lst[a .. ^1]]
|
2023-08-17 13:42:01 +00:00
|
|
|
elif collect.len == 2:
|
|
|
|
let a = lst.len div 2
|
2023-08-18 19:46:55 +00:00
|
|
|
yield [collect[0], collect[1], lst[0 ..< a], lst[a .. ^1]]
|
2023-08-17 13:42:01 +00:00
|
|
|
else:
|
2023-08-18 19:46:55 +00:00
|
|
|
yield [collect[0], collect[1], collect[2], lst]
|
2023-08-17 13:42:01 +00:00
|
|
|
collect.setLen(0)
|
|
|
|
|
|
|
|
proc dbTriplet(w: LeafQuartet; rdbPath: string): Result[DbTriplet,AristoError] =
|
2023-08-18 19:46:55 +00:00
|
|
|
let db = block:
|
2023-09-12 18:45:12 +00:00
|
|
|
if 0 < rdbPath.len:
|
2024-06-19 08:55:57 +00:00
|
|
|
let (dbOpts, cfOpts) = DbOptions.init().toRocksDb()
|
|
|
|
let rc = AristoDbRef.init(RdbBackendRef, rdbPath, dbOpts, cfOpts, [])
|
2024-06-18 11:14:02 +00:00
|
|
|
xCheckRc rc.error == 0:
|
|
|
|
result = err(rc.error)
|
2024-06-19 08:55:57 +00:00
|
|
|
rc.value()[0]
|
2023-09-12 18:45:12 +00:00
|
|
|
else:
|
2023-09-15 15:23:53 +00:00
|
|
|
AristoDbRef.init MemBackendRef
|
2023-08-17 13:42:01 +00:00
|
|
|
|
2024-06-18 11:14:02 +00:00
|
|
|
# Set failed `xCheck()` error result
|
|
|
|
result = err(AristoError 1)
|
|
|
|
|
2023-08-18 19:46:55 +00:00
|
|
|
# Fill backend
|
|
|
|
block:
|
2024-02-01 21:27:48 +00:00
|
|
|
let report = db.mergeList w[0]
|
2023-09-11 20:38:49 +00:00
|
|
|
if report.error != 0:
|
2024-06-14 11:19:48 +00:00
|
|
|
db.finish(eradicate=true)
|
2024-06-18 11:14:02 +00:00
|
|
|
xCheck report.error == 0
|
2024-04-29 20:17:17 +00:00
|
|
|
let rc = db.persist()
|
2024-06-18 11:14:02 +00:00
|
|
|
xCheckRc rc.error == 0:
|
|
|
|
result = err(rc.error)
|
2023-08-17 13:42:01 +00:00
|
|
|
|
2024-05-03 17:38:17 +00:00
|
|
|
let dx = [db, db.forkTx(0).value, db.forkTx(0).value]
|
2024-03-14 22:17:43 +00:00
|
|
|
xCheck dx[0].nForked == 2
|
2023-08-17 13:42:01 +00:00
|
|
|
|
2024-03-20 15:15:56 +00:00
|
|
|
# Reduce unwanted tx layers
|
|
|
|
for n in 1 ..< dx.len:
|
2024-06-18 11:14:02 +00:00
|
|
|
xCheck dx[n].level == 1
|
|
|
|
xCheck dx[n].txTop.value.commit.isOk
|
2024-03-20 15:15:56 +00:00
|
|
|
|
2023-08-18 19:46:55 +00:00
|
|
|
# Clause (9) from `aristo/README.md` example
|
|
|
|
for n in 0 ..< dx.len:
|
2024-02-01 21:27:48 +00:00
|
|
|
let report = dx[n].mergeList w[n+1]
|
2023-09-11 20:38:49 +00:00
|
|
|
if report.error != 0:
|
2024-06-14 11:19:48 +00:00
|
|
|
db.finish(eradicate=true)
|
2024-06-18 11:14:02 +00:00
|
|
|
xCheck (n, report.error) == (n,0)
|
|
|
|
|
|
|
|
return ok(dx)
|
2023-08-17 13:42:01 +00:00
|
|
|
|
2023-08-18 19:46:55 +00:00
|
|
|
# ----------------------
|
2023-08-17 13:42:01 +00:00
|
|
|
|
2024-03-15 14:20:00 +00:00
|
|
|
proc cleanUp(dx: var DbTriplet) =
|
|
|
|
if not dx[0].isNil:
|
2024-06-14 11:19:48 +00:00
|
|
|
dx[0].finish(eradicate=true)
|
2024-03-15 14:20:00 +00:00
|
|
|
dx.reset
|
2023-08-17 13:42:01 +00:00
|
|
|
|
2024-07-17 19:27:33 +00:00
|
|
|
# ----------------------
|
|
|
|
|
2024-06-03 20:10:35 +00:00
|
|
|
proc isDbEq(a, b: LayerDeltaRef; db: AristoDbRef; noisy = true): bool =
|
2023-08-17 13:42:01 +00:00
|
|
|
## Verify that argument filter `a` has the same effect on the
|
|
|
|
## physical/unfiltered backend of `db` as argument filter `b`.
|
|
|
|
if a.isNil:
|
|
|
|
return b.isNil
|
|
|
|
if b.isNil:
|
|
|
|
return false
|
|
|
|
if unsafeAddr(a[]) != unsafeAddr(b[]):
|
No ext update (#2494)
* Imported/rebase from `no-ext`, PR #2485
Store extension nodes together with the branch
Extension nodes must be followed by a branch - as such, it makes sense
to store the two together both in the database and in memory:
* fewer reads, writes and updates to traverse the tree
* simpler logic for maintaining the node structure
* less space used, both memory and storage, because there are fewer
nodes overall
There is also a downside: hashes can no longer be cached for an
extension - instead, only the extension+branch hash can be cached - this
seems like a fine tradeoff since computing it should be fast.
TODO: fix commented code
* Fix merge functions and `toNode()`
* Update `merkleSignCommit()` prototype
why:
Result is always a 32bit hash
* Update short Merkle hash key generation
details:
Ethereum reference MPTs use Keccak hashes as node links if the size of
an RLP encoded node is at least 32 bytes. Otherwise, the RLP encoded
node value is used as a pseudo node link (rather than a hash.) This is
specified in the yellow paper, appendix D.
Different to the `Aristo` implementation, the reference MPT would not
store such a node on the key-value database. Rather the RLP encoded node value is stored instead of a node link in a parent node
is stored as a node link on the parent database.
Only for the root hash, the top level node is always referred to by the
hash.
* Fix/update `Extension` sections
why:
Were commented out after removal of a dedicated `Extension` type which
left the system disfunctional.
* Clean up unused error codes
* Update unit tests
* Update docu
---------
Co-authored-by: Jacek Sieka <jacek@status.im>
2024-07-16 19:47:59 +00:00
|
|
|
if a.kMap.getOrVoid((testRootVid, testRootVid)) !=
|
|
|
|
b.kMap.getOrVoid((testRootVid, testRootVid)) or
|
2024-06-04 15:05:13 +00:00
|
|
|
a.vTop != b.vTop:
|
2023-08-17 13:42:01 +00:00
|
|
|
return false
|
|
|
|
|
|
|
|
# Void entries may differ unless on physical backend
|
|
|
|
var (aTab, bTab) = (a.sTab, b.sTab)
|
|
|
|
if aTab.len < bTab.len:
|
|
|
|
aTab.swap bTab
|
|
|
|
for (vid,aVtx) in aTab.pairs:
|
|
|
|
let bVtx = bTab.getOrVoid vid
|
|
|
|
bTab.del vid
|
|
|
|
|
|
|
|
if aVtx != bVtx:
|
|
|
|
if aVtx.isValid and bVtx.isValid:
|
|
|
|
return false
|
|
|
|
# The valid one must match the backend data
|
2024-04-26 13:43:52 +00:00
|
|
|
let rc = db.getVtxUbe vid
|
2023-08-17 13:42:01 +00:00
|
|
|
if rc.isErr:
|
|
|
|
return false
|
|
|
|
let vtx = if aVtx.isValid: aVtx else: bVtx
|
|
|
|
if vtx != rc.value:
|
|
|
|
return false
|
|
|
|
|
|
|
|
elif not vid.isValid and not bTab.hasKey vid:
|
2024-04-26 13:43:52 +00:00
|
|
|
let rc = db.getVtxUbe vid
|
2023-08-17 13:42:01 +00:00
|
|
|
if rc.isOk:
|
|
|
|
return false # Exists on backend but missing on `bTab[]`
|
|
|
|
elif rc.error != GetKeyNotFound:
|
|
|
|
return false # general error
|
|
|
|
|
|
|
|
if 0 < bTab.len:
|
2023-08-18 19:46:55 +00:00
|
|
|
noisy.say "***", "not dbEq:", "bTabLen=", bTab.len
|
2023-08-17 13:42:01 +00:00
|
|
|
return false
|
|
|
|
|
|
|
|
# Similar for `kMap[]`
|
|
|
|
var (aMap, bMap) = (a.kMap, b.kMap)
|
|
|
|
if aMap.len < bMap.len:
|
|
|
|
aMap.swap bMap
|
|
|
|
for (vid,aKey) in aMap.pairs:
|
|
|
|
let bKey = bMap.getOrVoid vid
|
|
|
|
bMap.del vid
|
|
|
|
|
|
|
|
if aKey != bKey:
|
|
|
|
if aKey.isValid and bKey.isValid:
|
|
|
|
return false
|
|
|
|
# The valid one must match the backend data
|
2024-04-26 13:43:52 +00:00
|
|
|
let rc = db.getKeyUbe vid
|
2023-08-17 13:42:01 +00:00
|
|
|
if rc.isErr:
|
|
|
|
return false
|
|
|
|
let key = if aKey.isValid: aKey else: bKey
|
|
|
|
if key != rc.value:
|
|
|
|
return false
|
|
|
|
|
|
|
|
elif not vid.isValid and not bMap.hasKey vid:
|
2024-04-26 13:43:52 +00:00
|
|
|
let rc = db.getKeyUbe vid
|
2023-08-17 13:42:01 +00:00
|
|
|
if rc.isOk:
|
|
|
|
return false # Exists on backend but missing on `bMap[]`
|
|
|
|
elif rc.error != GetKeyNotFound:
|
|
|
|
return false # general error
|
|
|
|
|
|
|
|
if 0 < bMap.len:
|
2023-08-18 19:46:55 +00:00
|
|
|
noisy.say "***", "not dbEq:", " bMapLen=", bMap.len
|
2023-08-17 13:42:01 +00:00
|
|
|
return false
|
|
|
|
|
|
|
|
true
|
|
|
|
|
2023-08-18 19:46:55 +00:00
|
|
|
# ----------------------
|
|
|
|
|
|
|
|
proc checkBeOk(
|
|
|
|
dx: DbTriplet;
|
|
|
|
forceCache = false;
|
|
|
|
noisy = true;
|
|
|
|
): bool =
|
|
|
|
## ..
|
2024-07-01 10:59:18 +00:00
|
|
|
for n in 0 ..< dx.len:
|
|
|
|
let rc = dx[n].checkBE()
|
|
|
|
xCheckRc rc.error == (0,0):
|
|
|
|
noisy.say "***", "db checkBE failed",
|
|
|
|
" n=", n, "/", dx.len-1
|
2023-09-05 18:00:40 +00:00
|
|
|
true
|
|
|
|
|
2023-08-17 13:42:01 +00:00
|
|
|
# ------------------------------------------------------------------------------
|
|
|
|
# Public test function
|
|
|
|
# ------------------------------------------------------------------------------
|
|
|
|
|
2024-07-17 19:27:33 +00:00
|
|
|
proc testBalancer*(
|
2023-08-17 13:42:01 +00:00
|
|
|
noisy: bool;
|
|
|
|
list: openArray[ProofTrieData];
|
|
|
|
rdbPath: string; # Rocks DB storage directory
|
|
|
|
): bool =
|
|
|
|
var n = 0
|
|
|
|
for w in list.quadripartite:
|
|
|
|
n.inc
|
|
|
|
|
|
|
|
# Resulting clause (11) filters from `aristo/README.md` example
|
|
|
|
# which will be used in the second part of the tests
|
|
|
|
var
|
2024-06-03 20:10:35 +00:00
|
|
|
c11Filter1 = LayerDeltaRef(nil)
|
|
|
|
c11Filter3 = LayerDeltaRef(nil)
|
2023-08-17 13:42:01 +00:00
|
|
|
|
|
|
|
# Work through clauses (8)..(11) from `aristo/README.md` example
|
|
|
|
block:
|
|
|
|
|
|
|
|
# Clause (8) from `aristo/README.md` example
|
2024-03-15 14:20:00 +00:00
|
|
|
var
|
2023-08-17 13:42:01 +00:00
|
|
|
dx = block:
|
|
|
|
let rc = dbTriplet(w, rdbPath)
|
2023-09-05 13:57:20 +00:00
|
|
|
xCheckRc rc.error == 0
|
2023-08-17 13:42:01 +00:00
|
|
|
rc.value
|
2023-08-18 19:46:55 +00:00
|
|
|
(db1, db2, db3) = (dx[0], dx[1], dx[2])
|
2023-08-17 13:42:01 +00:00
|
|
|
defer:
|
|
|
|
dx.cleanUp()
|
|
|
|
|
|
|
|
when false: # or true:
|
2023-12-12 17:47:41 +00:00
|
|
|
noisy.say "*** testDistributedAccess (1)", "n=", n # , dx.dump
|
2023-08-17 13:42:01 +00:00
|
|
|
|
|
|
|
# Clause (9) from `aristo/README.md` example
|
|
|
|
block:
|
2024-04-29 20:17:17 +00:00
|
|
|
let rc = db1.persist()
|
2023-09-15 15:23:53 +00:00
|
|
|
xCheckRc rc.error == 0
|
2024-06-03 20:10:35 +00:00
|
|
|
xCheck db1.balancer == LayerDeltaRef(nil)
|
|
|
|
xCheck db2.balancer == db3.balancer
|
2023-08-17 13:42:01 +00:00
|
|
|
|
|
|
|
block:
|
2024-04-29 20:17:17 +00:00
|
|
|
let rc = db2.stow() # non-persistent
|
2023-09-15 15:23:53 +00:00
|
|
|
xCheckRc rc.error == 0:
|
2023-08-17 13:42:01 +00:00
|
|
|
noisy.say "*** testDistributedAccess (3)", "n=", n, "db2".dump db2
|
2024-06-03 20:10:35 +00:00
|
|
|
xCheck db1.balancer == LayerDeltaRef(nil)
|
|
|
|
xCheck db2.balancer != db3.balancer
|
2023-08-17 13:42:01 +00:00
|
|
|
|
|
|
|
# Clause (11) from `aristo/README.md` example
|
2024-06-13 18:15:11 +00:00
|
|
|
discard db2.reCentre()
|
2023-08-17 13:42:01 +00:00
|
|
|
block:
|
2024-04-29 20:17:17 +00:00
|
|
|
let rc = db2.persist()
|
2023-09-15 15:23:53 +00:00
|
|
|
xCheckRc rc.error == 0
|
2024-06-03 20:10:35 +00:00
|
|
|
xCheck db2.balancer == LayerDeltaRef(nil)
|
2023-08-17 13:42:01 +00:00
|
|
|
|
|
|
|
# Check/verify backends
|
|
|
|
block:
|
2024-07-01 10:59:18 +00:00
|
|
|
let ok = dx.checkBeOk(noisy=noisy)
|
2023-09-05 13:57:20 +00:00
|
|
|
xCheck ok:
|
2023-08-17 13:42:01 +00:00
|
|
|
noisy.say "*** testDistributedAccess (4)", "n=", n, "db3".dump db3
|
|
|
|
|
|
|
|
# Capture filters from clause (11)
|
2024-06-03 20:10:35 +00:00
|
|
|
c11Filter1 = db1.balancer
|
|
|
|
c11Filter3 = db3.balancer
|
2023-08-17 13:42:01 +00:00
|
|
|
|
|
|
|
# Clean up
|
|
|
|
dx.cleanUp()
|
|
|
|
|
|
|
|
# ----------
|
|
|
|
|
|
|
|
# Work through clauses (12)..(15) from `aristo/README.md` example
|
|
|
|
block:
|
2024-03-15 14:20:00 +00:00
|
|
|
var
|
2023-08-17 13:42:01 +00:00
|
|
|
dy = block:
|
|
|
|
let rc = dbTriplet(w, rdbPath)
|
2023-09-05 13:57:20 +00:00
|
|
|
xCheckRc rc.error == 0
|
2023-08-17 13:42:01 +00:00
|
|
|
rc.value
|
2023-08-18 19:46:55 +00:00
|
|
|
(db1, db2, db3) = (dy[0], dy[1], dy[2])
|
2023-08-17 13:42:01 +00:00
|
|
|
defer:
|
|
|
|
dy.cleanUp()
|
|
|
|
|
|
|
|
# Build clause (12) from `aristo/README.md` example
|
2024-06-13 18:15:11 +00:00
|
|
|
discard db2.reCentre()
|
2023-08-17 13:42:01 +00:00
|
|
|
block:
|
2024-04-29 20:17:17 +00:00
|
|
|
let rc = db2.persist()
|
2023-09-15 15:23:53 +00:00
|
|
|
xCheckRc rc.error == 0
|
2024-06-03 20:10:35 +00:00
|
|
|
xCheck db2.balancer == LayerDeltaRef(nil)
|
|
|
|
xCheck db1.balancer == db3.balancer
|
2023-08-17 13:42:01 +00:00
|
|
|
|
|
|
|
# Clause (13) from `aristo/README.md` example
|
2024-03-14 22:17:43 +00:00
|
|
|
xCheck not db1.isCentre()
|
2023-08-17 13:42:01 +00:00
|
|
|
block:
|
2024-04-29 20:17:17 +00:00
|
|
|
let rc = db1.stow() # non-persistent
|
2023-09-15 15:23:53 +00:00
|
|
|
xCheckRc rc.error == 0
|
2023-08-17 13:42:01 +00:00
|
|
|
|
No ext update (#2494)
* Imported/rebase from `no-ext`, PR #2485
Store extension nodes together with the branch
Extension nodes must be followed by a branch - as such, it makes sense
to store the two together both in the database and in memory:
* fewer reads, writes and updates to traverse the tree
* simpler logic for maintaining the node structure
* less space used, both memory and storage, because there are fewer
nodes overall
There is also a downside: hashes can no longer be cached for an
extension - instead, only the extension+branch hash can be cached - this
seems like a fine tradeoff since computing it should be fast.
TODO: fix commented code
* Fix merge functions and `toNode()`
* Update `merkleSignCommit()` prototype
why:
Result is always a 32bit hash
* Update short Merkle hash key generation
details:
Ethereum reference MPTs use Keccak hashes as node links if the size of
an RLP encoded node is at least 32 bytes. Otherwise, the RLP encoded
node value is used as a pseudo node link (rather than a hash.) This is
specified in the yellow paper, appendix D.
Different to the `Aristo` implementation, the reference MPT would not
store such a node on the key-value database. Rather the RLP encoded node value is stored instead of a node link in a parent node
is stored as a node link on the parent database.
Only for the root hash, the top level node is always referred to by the
hash.
* Fix/update `Extension` sections
why:
Were commented out after removal of a dedicated `Extension` type which
left the system disfunctional.
* Clean up unused error codes
* Update unit tests
* Update docu
---------
Co-authored-by: Jacek Sieka <jacek@status.im>
2024-07-16 19:47:59 +00:00
|
|
|
# Clause (14) from `aristo/README.md` check
|
|
|
|
let c11Fil1_eq_db1RoFilter = c11Filter1.isDbEq(db1.balancer, db1, noisy)
|
|
|
|
xCheck c11Fil1_eq_db1RoFilter:
|
|
|
|
noisy.say "*** testDistributedAccess (7)", "n=", n,
|
|
|
|
"db1".dump(db1),
|
|
|
|
""
|
|
|
|
|
|
|
|
# Clause (15) from `aristo/README.md` check
|
|
|
|
let c11Fil3_eq_db3RoFilter = c11Filter3.isDbEq(db3.balancer, db3, noisy)
|
|
|
|
xCheck c11Fil3_eq_db3RoFilter:
|
|
|
|
noisy.say "*** testDistributedAccess (8)", "n=", n,
|
|
|
|
"db3".dump(db3),
|
|
|
|
""
|
2023-08-17 13:42:01 +00:00
|
|
|
# Check/verify backends
|
|
|
|
block:
|
2024-07-01 10:59:18 +00:00
|
|
|
let ok = dy.checkBeOk(noisy=noisy)
|
2023-09-05 13:57:20 +00:00
|
|
|
xCheck ok
|
2023-08-17 13:42:01 +00:00
|
|
|
|
|
|
|
when false: # or true:
|
2023-12-12 17:47:41 +00:00
|
|
|
noisy.say "*** testDistributedAccess (9)", "n=", n # , dy.dump
|
2023-08-17 13:42:01 +00:00
|
|
|
|
|
|
|
true
|
|
|
|
|
|
|
|
# ------------------------------------------------------------------------------
|
|
|
|
# End
|
|
|
|
# ------------------------------------------------------------------------------
|