Skip to content

Commit

Permalink
Revert previous fix and force clear cache after processing each block.
Browse files Browse the repository at this point in the history
  • Loading branch information
bhartnett committed Mar 14, 2024
1 parent 66ec9f4 commit 40bf10e
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 3 deletions.
2 changes: 1 addition & 1 deletion nimbus/core/executor/process_block.nim
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ proc procBlkEpilogue(vmState: BaseVMState;
if vmState.generateWitness:
db.collectWitnessData()
let clearEmptyAccount = vmState.determineFork >= FkSpurious
db.persist(clearEmptyAccount, ClearCache in vmState.flags)
db.persist(clearEmptyAccount, clearCache = true)

let stateDb = vmState.stateDB
if header.stateRoot != stateDb.rootHash:
Expand Down
5 changes: 4 additions & 1 deletion nimbus/db/ledger/accounts_cache.nim
Original file line number Diff line number Diff line change
Expand Up @@ -596,7 +596,6 @@ proc persist*(ac: AccountsCache,

if clearCache:
ac.savePoint.cache.clear()
ac.witnessCache.clear()
else:
for x in cleanAccounts:
ac.savePoint.cache.del x
Expand Down Expand Up @@ -695,6 +694,10 @@ proc makeMultiKeys*(ac: AccountsCache): MultiKeysRef =
result.add(k, v.codeTouched, multiKeys(v.storageKeys))
result.sort()

# reset the witness cache after collecting the witness data
# so it is clean before executing the next block
ac.witnessCache.clear()

proc accessList*(ac: AccountsCache, address: EthAddress) {.inline.} =
ac.savePoint.accessList.add(address)

Expand Down
1 change: 0 additions & 1 deletion nimbus/db/ledger/accounts_ledger.nim
Original file line number Diff line number Diff line change
Expand Up @@ -627,7 +627,6 @@ proc persist*(ac: AccountsLedgerRef,

if clearCache:
ac.savePoint.cache.clear()
ac.witnessCache.clear()
else:
for x in cleanAccounts:
ac.savePoint.cache.del x
Expand Down

0 comments on commit 40bf10e

Please sign in to comment.