From 1ffac5b2ea26f0582d693d491846bbd7c306e43d Mon Sep 17 00:00:00 2001 From: Jordan Hrycaj Date: Thu, 12 Oct 2023 21:10:04 +0100 Subject: [PATCH] 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.) --- nimbus/common/genesis.nim | 2 +- tests/test_coredb.nim | 12 +++++++++++- tests/test_rocksdb_timing.nim | 4 ++-- 3 files changed, 14 insertions(+), 4 deletions(-) diff --git a/nimbus/common/genesis.nim b/nimbus/common/genesis.nim index 2394c902f..2fa11668a 100644 --- a/nimbus/common/genesis.nim +++ b/nimbus/common/genesis.nim @@ -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: diff --git a/tests/test_coredb.nim b/tests/test_coredb.nim index 6c846aa10..b7401072d 100644 --- a/tests/test_coredb.nim +++ b/tests/test_coredb.nim @@ -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 diff --git a/tests/test_rocksdb_timing.nim b/tests/test_rocksdb_timing.nim index a51be57a9..c46ca114f 100644 --- a/tests/test_rocksdb_timing.nim +++ b/tests/test_rocksdb_timing.nim @@ -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]