From 483b2d8ef4162ab5bf87db4e604ebef986b96df3 Mon Sep 17 00:00:00 2001 From: Jordan Hrycaj Date: Fri, 31 May 2024 10:43:31 +0100 Subject: [PATCH] Fix block-number last saved block state (#2263) why: Typo. That worked the wrong way in the unit tests because the tests always store the last item separately with extended logging. Co-authored-by: jordan --- nimbus/core/chain/persist_blocks.nim | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/nimbus/core/chain/persist_blocks.nim b/nimbus/core/chain/persist_blocks.nim index 2886af5a2..28bbaf6f5 100644 --- a/nimbus/core/chain/persist_blocks.nim +++ b/nimbus/core/chain/persist_blocks.nim @@ -170,14 +170,8 @@ proc persistBlocksImpl(c: ChainRef; headers: openArray[BlockHeader]; dbTx.commit() - # The `c.db.persistent()` call is ignored by the legacy DB which - # automatically saves persistently when reaching the zero level transaction. - # - # For the `Aristo` database, this code position is only reached if the - # the parent state of the first block (as registered in `headers[0]`) was - # the canonical state before updating. So this state will be saved with - # `persistent()` together with the respective block number. - c.db.persistent(headers[0].blockNumber - 1) + # Save and record the block number before the last saved block state. + c.db.persistent(headers[^1].blockNumber - 1) if c.com.pruneHistory: # There is a feature for test systems to regularly clean up older blocks