Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Skip committing state during warmup #7595

Merged
merged 1 commit into from
Oct 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ private void WarmupTransactions(ParallelOptions parallelOptions, IReleaseSpec sp
{
scope.WorldState.WarmUp(tx.AccessList); // eip-2930
}
TransactionResult result = scope.TransactionProcessor.Trace(systemTransaction, new BlockExecutionContext(block.Header.Clone()), NullTxTracer.Instance);
TransactionResult result = scope.TransactionProcessor.Warmup(systemTransaction, new BlockExecutionContext(block.Header.Clone()), NullTxTracer.Instance);
if (_logger.IsTrace) _logger.Trace($"Finished pre-warming cache for tx[{i}] {tx.Hash} with {result}");
}
catch (Exception ex) when (ex is EvmException or OverflowException)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,10 @@ public interface ITransactionProcessor
/// Will NOT charge gas from sender account, so stateDiff will miss gas fee
/// </summary>
TransactionResult Trace(Transaction transaction, in BlockExecutionContext blCtx, ITxTracer txTracer);

/// <summary>
/// Call transaction, no validations, don't commit state
/// Will NOT charge gas from sender account
/// </summary>
TransactionResult Warmup(Transaction transaction, in BlockExecutionContext blCtx, ITxTracer txTracer);
}
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ protected override TransactionResult Execute(Transaction tx, in BlockExecutionCo
WorldState.CreateAccountIfNotExists(Address.SystemUser, UInt256.Zero, UInt256.Zero);
}

return base.Execute(tx, in blCtx, tracer, !opts.HasFlag(ExecutionOptions.NoValidation)
return base.Execute(tx, in blCtx, tracer, (opts != ExecutionOptions.Warmup && !opts.HasFlag(ExecutionOptions.NoValidation))
? opts | (ExecutionOptions)OriginalValidate | ExecutionOptions.NoValidation
: opts);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,12 @@ protected enum ExecutionOptions
/// <summary>
/// Skip potential fail checks
/// </summary>
NoValidation = Commit | 4,
Warmup = 4,

/// <summary>
/// Skip potential fail checks and commit state after execution
/// </summary>
NoValidation = Commit | Warmup,

/// <summary>
/// Commit and later restore state also skip validation, use for CallAndRestore
Expand Down Expand Up @@ -112,6 +117,9 @@ public TransactionResult Execute(Transaction transaction, in BlockExecutionConte
public TransactionResult Trace(Transaction transaction, in BlockExecutionContext blCtx, ITxTracer txTracer) =>
ExecuteCore(transaction, in blCtx, txTracer, ExecutionOptions.NoValidation);

public TransactionResult Warmup(Transaction transaction, in BlockExecutionContext blCtx, ITxTracer txTracer) =>
ExecuteCore(transaction, in blCtx, txTracer, ExecutionOptions.Warmup);

private TransactionResult ExecuteCore(Transaction tx, in BlockExecutionContext blCtx, ITxTracer tracer, ExecutionOptions opts)
{
if (tx.IsSystem())
Expand Down
Loading