Skip to content

Commit

Permalink
perf: stop replaying empty blocks
Browse files Browse the repository at this point in the history
Simply do not replay empty blocks and reap the performance rewards.
I'm careful here to still keep any upgrade blocks.

Change-Id: I601cb81cd5e241fa3ceaa315d80b33ae9f17c75d
  • Loading branch information
edmundnoble committed Jun 19, 2024
1 parent 6c4db9d commit 22c187d
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
1 change: 1 addition & 0 deletions changes/2024-06-19T182611-0400.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Speed up read-only replay by avoiding playing empty blocks
5 changes: 4 additions & 1 deletion src/Chainweb/Pact/PactService.hs
Original file line number Diff line number Diff line change
Expand Up @@ -824,7 +824,10 @@ execReadOnlyReplay lowerBound maybeUpperBound = pactLabel "execReadOnlyReplay" $
liftIO $ writeIORef heightRef (_blockHeight bh)
payload <- liftIO $ fromJuste <$>
lookupPayloadDataWithHeight pdb (Just $ _blockHeight bh) (_blockPayloadHash bh)
void $ execBlock bh (CheckablePayload payload)
let isPayloadEmpty = V.null (_payloadDataTransactions payload)
let isUpgradeBlock = isJust $ _chainwebVersion bhdb ^? versionUpgrades . onChain (_chainId bhdb) . ix (_blockHeight bh)
unless (isPayloadEmpty && not isUpgradeBlock) $
void $ execBlock bh (CheckablePayload payload)
)
validationFailed <- readIORef validationFailedRef
when validationFailed $
Expand Down

0 comments on commit 22c187d

Please sign in to comment.