-
Notifications
You must be signed in to change notification settings - Fork 465
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 sstore gas metering read for system tx #7958
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,6 +18,7 @@ | |
using Nethermind.Consensus.Withdrawals; | ||
using Nethermind.Core; | ||
using Nethermind.Core.Crypto; | ||
using Nethermind.Core.Extensions; | ||
using Nethermind.Core.Specs; | ||
using Nethermind.Core.Threading; | ||
using Nethermind.Crypto; | ||
|
@@ -107,44 +108,51 @@ the previous head state.*/ | |
preWarmTask = null; | ||
WaitForCacheClear(); | ||
Block suggestedBlock = suggestedBlocks[i]; | ||
if (blocksCount > 64 && i % 8 == 0) | ||
{ | ||
if (_logger.IsInfo) _logger.Info($"Processing part of a long blocks branch {i}/{blocksCount}. Block: {suggestedBlock}"); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This log was helpful in determining that something went seriously wrong in the past :D |
||
} | ||
|
||
if (notReadOnly) | ||
{ | ||
BlockProcessing?.Invoke(this, new BlockEventArgs(suggestedBlock)); | ||
} | ||
|
||
CancellationTokenSource? cancellationTokenSource = null; | ||
Block processedBlock; | ||
TxReceipt[] receipts; | ||
|
||
bool skipPrewarming = preWarmer is null || suggestedBlock.Transactions.Length < 3; | ||
if (!skipPrewarming) | ||
try | ||
{ | ||
using CancellationTokenSource cancellationTokenSource = new(); | ||
preWarmTask = preWarmer.PreWarmCaches(suggestedBlock, preBlockStateRoot, _specProvider.GetSpec(suggestedBlock.Header), cancellationTokenSource.Token, _beaconBlockRootHandler); | ||
(processedBlock, receipts) = ProcessOne(suggestedBlock, options, blockTracer); | ||
// Block is processed, we can cancel the prewarm task | ||
cancellationTokenSource.Cancel(); | ||
} | ||
else | ||
{ | ||
CacheType result = preWarmer?.ClearCaches() ?? default; | ||
if (result != default) | ||
bool skipPrewarming = preWarmer is null || suggestedBlock.Transactions.Length < 3; | ||
if (!skipPrewarming) | ||
{ | ||
cancellationTokenSource = new(); | ||
preWarmTask = preWarmer.PreWarmCaches(suggestedBlock, preBlockStateRoot, _specProvider.GetSpec(suggestedBlock.Header), cancellationTokenSource.Token, _beaconBlockRootHandler); | ||
} | ||
else | ||
{ | ||
if (_logger.IsWarn) _logger.Warn($"Low txs, caches {result} are not empty. Clearing them."); | ||
// Even though we skip prewarming we still need to ensure the caches are cleared | ||
CacheType result = preWarmer?.ClearCaches() ?? default; | ||
if (result != default) | ||
{ | ||
if (_logger.IsWarn) _logger.Warn($"Low txs, caches {result} are not empty. Clearing them."); | ||
} | ||
} | ||
// Even though we skip prewarming we still need to ensure the caches are cleared | ||
|
||
if (blocksCount > 64 && i % 8 == 0) | ||
{ | ||
if (_logger.IsInfo) _logger.Info($"Processing part of a long blocks branch {i}/{blocksCount}. Block: {suggestedBlock}"); | ||
} | ||
|
||
if (notReadOnly) | ||
{ | ||
BlockProcessing?.Invoke(this, new BlockEventArgs(suggestedBlock)); | ||
} | ||
|
||
(processedBlock, receipts) = ProcessOne(suggestedBlock, options, blockTracer); | ||
} | ||
|
||
processedBlocks[i] = processedBlock; | ||
processedBlocks[i] = processedBlock; | ||
|
||
// be cautious here as AuRa depends on processing | ||
PreCommitBlock(newBranchStateRoot, suggestedBlock.Number); | ||
QueueClearCaches(preWarmTask); | ||
// be cautious here as AuRa depends on processing | ||
PreCommitBlock(newBranchStateRoot, suggestedBlock.Number); | ||
} | ||
finally | ||
{ | ||
// Block is processed, we can cancel the prewarm task | ||
CancellationTokenExtensions.CancelDisposeAndClear(ref cancellationTokenSource); | ||
QueueClearCaches(preWarmTask); | ||
} | ||
|
||
if (notReadOnly) | ||
{ | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -419,5 +419,10 @@ public interface IReleaseSpec : IEip1559Spec, IReceiptSpec | |
bool IsAuthorizationListEnabled => IsEip7702Enabled; | ||
|
||
public bool RequestsEnabled => ConsolidationRequestsEnabled || WithdrawalRequestsEnabled || DepositsEnabled; | ||
|
||
/// <summary> | ||
/// Skip read in SSTORE for calculating gas cost as not charged | ||
/// </summary> | ||
bool IsSystemTransaction { get; } | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Looks weird, this is added to ReleaseSpec and the field seems to be referenced to Transaction object |
||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes that is correct, but I think Geth adds only 1 of them to access list - can you check?
Having different access list could potentially break on edge case of out of gas - generally shouldn't happen with 30mln gas...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Spec doesn't mention Access Lists; no gas is charged 30M should be enough for x2 SSTOREs
Spec is actually more wild and says
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@MarekM25 WDYT?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hmmm I think some chains use a different implementation of this contract, so not sure if we should add anything besides just calling sys call