Skip to content

Commit

Permalink
Skip prewarming tx if main processing has caught up (#7143)
Browse files Browse the repository at this point in the history
  • Loading branch information
benaadams authored Jun 6, 2024
1 parent 0d700b3 commit 89d9ce4
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,9 @@ void WarmupTransactions(ParallelOptions parallelOptions, IReleaseSpec spec, Bloc
{
Parallel.For(0, block.Transactions.Length, parallelOptions, i =>
{
// If the transaction has already been processed or being processed, exit early
if (block.TransactionProcessed >= i) return;

using ThreadExtensions.Disposable handle = Thread.CurrentThread.BoostPriority();
Transaction tx = block.Transactions[i];
ReadOnlyTxProcessingEnv env = _envPool.Get();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ public TxReceipt[] ProcessTransactions(Block block, ProcessingOptions processing
BlockExecutionContext blkCtx = new(block.Header);
for (int i = 0; i < block.Transactions.Length; i++)
{
block.TransactionProcessed = i;
Transaction currentTx = block.Transactions[i];
ProcessTransaction(in blkCtx, currentTx, i, receiptsTracer, processingOptions);
}
Expand Down
2 changes: 2 additions & 0 deletions src/Nethermind/Nethermind.Core/Block.cs
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,8 @@ public Transaction[] Transactions

[JsonIgnore]
public ArrayPoolList<AddressAsKey>? AccountChanges { get; set; }
[JsonIgnore]
internal volatile int TransactionProcessed;

public override string ToString() => ToString(Format.Short);

Expand Down

0 comments on commit 89d9ce4

Please sign in to comment.