From b44a4c3e7482d069fdd3d5c9d307f91f9f276c7f Mon Sep 17 00:00:00 2001 From: jangko Date: Tue, 25 Jun 2024 22:11:19 +0700 Subject: [PATCH] Add more doAssert constraint --- nimbus/core/chain/forked_chain.nim | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/nimbus/core/chain/forked_chain.nim b/nimbus/core/chain/forked_chain.nim index 0b93fc270..bedc6b53b 100644 --- a/nimbus/core/chain/forked_chain.nim +++ b/nimbus/core/chain/forked_chain.nim @@ -361,7 +361,7 @@ proc forkChoice*(c: var ForkedChain, # At this point cursorHeader.number > baseHeader.number if newBase.hash == c.cursorHash: # Paranoid check, guaranteed by findCanonicalHead - doAssert(c.cursorHash == headHash) + doAssert(c.cursorHash == head.cursorHash) # Current segment is canonical chain c.writeBaggage(newBase.hash) @@ -383,6 +383,7 @@ proc forkChoice*(c: var ForkedChain, # At this point finalizedHeader.number is <= headHeader.number # and possibly switched to other chain beside the one with cursor doAssert(finalizedHeader.number <= head.header.number) + doAssert(newBase.header.number <= finalizedHeader.number) # Write segment from base+1 to newBase into database c.stagingTx.rollback() @@ -403,7 +404,7 @@ proc forkChoice*(c: var ForkedChain, c.stagingTx = c.db.newTransaction() c.replaySegment(headHash) - # Move cursor forward to current head + # Move cursor to current head c.trimCanonicalChain(head) if c.cursorHash != headHash: c.cursorHeader = head.header