From 5b5d4747695dccbef32f418abc2eb72c9859641e Mon Sep 17 00:00:00 2001 From: Ben Adams Date: Tue, 20 Aug 2024 21:27:01 +0100 Subject: [PATCH] Move prewarm wait to end of all block activity --- .../Nethermind.Consensus/Processing/BlockProcessor.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/Nethermind/Nethermind.Consensus/Processing/BlockProcessor.cs b/src/Nethermind/Nethermind.Consensus/Processing/BlockProcessor.cs index d3ea3d0fea5..434e213ddd1 100644 --- a/src/Nethermind/Nethermind.Consensus/Processing/BlockProcessor.cs +++ b/src/Nethermind/Nethermind.Consensus/Processing/BlockProcessor.cs @@ -122,8 +122,8 @@ the previous head state.*/ ? null : _preWarmer?.PreWarmCaches(suggestedBlock, preBlockStateRoot!, cancellationTokenSource.Token); (Block processedBlock, TxReceipt[] receipts) = ProcessOne(suggestedBlock, options, blockTracer); + // Block is processed, we can cancel the prewarm task cancellationTokenSource.Cancel(); - preWarmTask?.GetAwaiter().GetResult(); processedBlocks[i] = processedBlock; // be cautious here as AuRa depends on processing @@ -147,6 +147,8 @@ the previous head state.*/ } preBlockStateRoot = processedBlock.StateRoot; + // Make sure the prewarm task is finished before we reset the state + preWarmTask?.GetAwaiter().GetResult(); _stateProvider.Reset(resizeCollections: true); }