Skip to content

Commit 348425a

Browse files
authored
Speed up sync speed by skipping state root checks (#3721)
* Speed up sync speed by skipping state root checks. * Set finalized flag based on block number <= latest finalized block number.
1 parent 7584ddd commit 348425a

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

execution_chain/sync/beacon/worker/blocks/blocks_import.nim

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,13 @@ proc importBlock*(
3737
B=ctx.chain.baseNumber.bnStr, L=ctx.chain.latestNumber.bnStr
3838
else:
3939
try:
40-
(await ctx.chain.queueImportBlock blk).isOkOr:
41-
return err((ENoException,"",error,Moment.now()-start))
40+
# At this point the header chain has already been verifed and so we know
41+
# the block is finalized as long as the block number is less than or equal
42+
# to the latest finalized block. Setting the finalized flag to true here
43+
# has the effect of skipping the stateroot check for performance reasons.
44+
let isFinalized = blk.header.number <= ctx.chain.latestFinalizedBlockNumber
45+
(await ctx.chain.queueImportBlock(blk, isFinalized)).isOkOr:
46+
return err((ENoException, "", error, Moment.now() - start))
4247
except CancelledError as e:
4348
return err((ECancelledError,$e.name,e.msg,Moment.now()-start))
4449

@@ -61,4 +66,3 @@ proc importBlock*(
6166
# ------------------------------------------------------------------------------
6267
# End
6368
# ------------------------------------------------------------------------------
64-

0 commit comments

Comments
 (0)