Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Aristo cull journal related stuff #2288

Merged
merged 9 commits into from
Jun 3, 2024
Prev Previous commit
Next Next commit
Refactor function names journal*() => delta*(), filter*() => delta*()
  • Loading branch information
mjfh committed Jun 3, 2024
commit 9ac0c8873ee5bff758ab9235c35aac8b3b403595
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,13 @@ import
results,
"."/[aristo_desc, aristo_get, aristo_vid],
./aristo_desc/desc_backend,
./aristo_journal/[
filter_state_root, filter_merge, filter_reverse, filter_siblings]
./aristo_delta/[delta_state_root, delta_merge, delta_siblings]

# ------------------------------------------------------------------------------
# Public functions, construct filters
# ------------------------------------------------------------------------------

proc journalFwdFilter*(
proc deltaFwd*(
db: AristoDbRef; # Database
layer: LayerRef; # Layer to derive filter from
chunkedMpt = false; # Relax for snap/proof scenario
Expand Down Expand Up @@ -64,7 +63,7 @@ proc journalFwdFilter*(
# Public functions, apply/install filters
# ------------------------------------------------------------------------------

proc journalMerge*(
proc deltaMerge*(
db: AristoDbRef; # Database
filter: FilterRef; # Filter to apply to database
): Result[void,(VertexID,AristoError)] =
Expand Down Expand Up @@ -93,12 +92,12 @@ proc journalMerge*(
ok()


proc journalUpdateOk*(db: AristoDbRef): bool =
proc deltaPersistentOk*(db: AristoDbRef): bool =
## Check whether the read-only filter can be merged into the backend
not db.backend.isNil and db.isCentre


proc journalUpdate*(
proc deltaPersistent*(
db: AristoDbRef; # Database
nxtFid = 0u64; # Next filter ID (if any)
reCentreOk = false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
import
results,
../aristo_desc,
"."/[filter_merge, filter_reverse]
"."/[delta_merge, delta_reverse]

type
UpdateState = enum
Expand Down
10 changes: 5 additions & 5 deletions nimbus/db/aristo/aristo_tx/tx_stow.nim
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
import
std/tables,
results,
".."/[aristo_desc, aristo_get, aristo_journal, aristo_layers, aristo_hashify]
".."/[aristo_desc, aristo_get, aristo_delta, aristo_layers, aristo_hashify]

# ------------------------------------------------------------------------------
# Public functions
Expand All @@ -34,19 +34,19 @@ proc txStow*(
return err(TxPendingTx)
if 0 < db.stack.len:
return err(TxStackGarbled)
if persistent and not db.journalUpdateOk():
if persistent and not db.deltaPersistentOk():
return err(TxBackendNotWritable)

# Update Merkle hashes (unless disabled)
db.hashify().isOkOr:
return err(error[1])

let fwd = db.journalFwdFilter(db.top, chunkedMpt).valueOr:
let fwd = db.deltaFwd(db.top, chunkedMpt).valueOr:
return err(error[1])

if fwd.isValid:
# Move/merge `top` layer onto `roFilter`
db.journalMerge(fwd).isOkOr:
db.deltaMerge(fwd).isOkOr:
return err(error[1])

# Special treatment for `snap` proofs (aka `chunkedMpt`)
Expand Down Expand Up @@ -75,7 +75,7 @@ proc txStow*(

if persistent:
# Merge/move `roFilter` into persistent tables
? db.journalUpdate nxtSid
? db.deltaPersistent nxtSid

# Special treatment for `snap` proofs (aka `chunkedMpt`)
let final =
Expand Down