Skip to content

Commit 14d597e

Browse files
authored
Update FC.baseTxFrame after txFrame persisted (#3272)
If the `baseTxFrame` is not updated, and `updateBase` yield to async event loop. Other module will access expired `baseTxFrame`. e.g. `getStatus` of eth/68 will crash the program.
1 parent e80788b commit 14d597e

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

execution_chain/core/chain/forked_chain.nim

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -418,7 +418,6 @@ proc updateBase(c: ForkedChainRef, newBase: BlockPos):
418418
# the blocks
419419
newBaseHash = newBase.hash
420420
nextIndex = int(newBase.number - branch.tailNumber)
421-
baseTxFrame = newBase.txFrame
422421

423422
# Persist the new base block - this replaces the base tx in coredb!
424423
for x in newBase.everyNthBlock(4):
@@ -432,7 +431,9 @@ proc updateBase(c: ForkedChainRef, newBase: BlockPos):
432431
discard await idleAsync().withTimeout(idleTimeout)
433432
c.com.db.persist(x.txFrame, Opt.some(x.stateRoot))
434433

435-
c.baseTxFrame = baseTxFrame
434+
# Update baseTxFrame when we about to yield to the event loop
435+
# and prevent other modules accessing expired baseTxFrame.
436+
c.baseTxFrame = x.txFrame
436437

437438
disposeBlocks(number, branch)
438439

0 commit comments

Comments
 (0)