Fudge persistent legacy hexary db edge case (#1817)

details:
  Persistent pruning would not restore the `emptyRlp` value for the
  root node when the database becomes empty. This effects to an
  assertion exception next time the DB is accessed.

  As most unit tests run on the memory DB, this case slipped through
  unnoticed for a while (see also issue #9.)
This commit is contained in:
Jordan Hrycaj 2023-10-12 21:10:04 +01:00 committed by GitHub
parent 786263c0b8
commit 1ffac5b2ea
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 14 additions and 4 deletions

View File

@ -45,7 +45,7 @@ proc toGenesisHeader*(
#
# This kludge also fixes the initial crash described in
# https://github.com/status-im/nimbus-eth1/issues/932.
if sdb.pruneTrie and 0 < account.storage.len:
if sdb.pruneTrie:
sdb.db.compensateLegacySetup() # <-- kludge
for k, v in account.storage:

View File

@ -141,10 +141,20 @@ proc coreDbMain*(noisy = defined(debug)) =
when isMainModule:
const
noisy = defined(debug) or true
persDb = true
setErrorLevel()
noisy.legacyRunner()
# This one uses the readily available dump: `bulkTest0` and some huge replay
# dumps `bulkTest2`, `bulkTest3`, .. from the `nimbus-eth1-blobs` package.
# For specs see `tests/test_coredb/bulk_test_xx.nim`.
var testList = @[bulkTest0]
testList = @[bulkTest1] # This test supersedes `bulkTest0`
when true and false:
testList = @[bulkTest1, bulkTest2, bulkTest3]
for n,capture in testList:
noisy.legacyRunner(capture=capture, persistent=persDb)
# ------------------------------------------------------------------------------
# End

View File

@ -281,8 +281,8 @@ when isMainModule:
setErrorLevel()
# This one uses the readily available dump: `bulkTest0` and some huge replay
# dumps `bulkTest1`, `bulkTest2`, .. from the `nimbus-eth1-blobs` package.
# For specs see `tests/test_sync_snap/bulk_test_xx.nim`.
# dumps `bulkTest2`, `bulkTest3`, .. from the `nimbus-eth1-blobs` package.
# For specs see `tests/test_rocksdb_timing/bulk_test_xx.nim`.
var testList = @[bulkTest0]
when true and false:
testList &= @[bulkTest1, bulkTest2, bulkTest3]