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

Optimization/cache precompiles #7106

Merged
merged 309 commits into from
Jun 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
309 commits
Select commit Hold shift + click to select a range
4407a1b
minor protocol update
OlegJakushkin Aug 3, 2023
d4d8ba1
Merge remote-tracking branch 'origin/master' into feature/eth_multicall
OlegJakushkin Aug 3, 2023
9430acc
Fixing Nonce
OlegJakushkin Aug 3, 2023
fda6c87
Softer defaults
OlegJakushkin Sep 11, 2023
a3dc077
Merge remote-tracking branch 'origin/master' into feature/eth_multicall
OlegJakushkin Sep 11, 2023
58b1c75
Minor refactoring following the review
OlegJakushkin Sep 11, 2023
fb2d861
Fixing Spaces
OlegJakushkin Sep 11, 2023
9eaf7ce
Merge remote-tracking branch 'origin/master' into feature/eth_multicall
OlegJakushkin Sep 11, 2023
c893254
Spec ordering
OlegJakushkin Sep 11, 2023
43009d4
Added checked longs
OlegJakushkin Sep 11, 2023
c99343a
Moving stuff to initialiser
OlegJakushkin Sep 11, 2023
202484f
Account Overrides ordering
OlegJakushkin Sep 11, 2023
da4c347
fix spaces
OlegJakushkin Sep 11, 2023
1faa5b9
Restricting DB set operations to 32b
OlegJakushkin Sep 11, 2023
9771637
Merge remote-tracking branch 'origin/master' into feature/eth_multicall
OlegJakushkin Sep 11, 2023
d822593
enum only
OlegJakushkin Sep 11, 2023
00d4db3
Result structure reordering following the protocol
OlegJakushkin Sep 11, 2023
8bbe975
Ordering following protocoll
OlegJakushkin Sep 11, 2023
59de531
Minor naming refactoring
OlegJakushkin Sep 11, 2023
044bc93
Minor refactoring of a stub class unused fields
OlegJakushkin Sep 11, 2023
0b22f18
removed unused flag
OlegJakushkin Sep 11, 2023
d5e9ce5
removing some of the interfaces implemented only once
OlegJakushkin Sep 12, 2023
a6e1398
Spaces fixing
OlegJakushkin Sep 12, 2023
d05e466
inheritance into composition
OlegJakushkin Sep 12, 2023
730753b
Merge remote-tracking branch 'origin/master' into feature/eth_multicall
OlegJakushkin Sep 12, 2023
819d0c5
removing unused parameter
OlegJakushkin Sep 12, 2023
634e41e
minor clean up
OlegJakushkin Sep 12, 2023
f9a6e91
Use of IReadOnlyList of MultiCallBlockResults
OlegJakushkin Sep 12, 2023
62348dc
minor refactoring
OlegJakushkin Sep 12, 2023
8619dc5
minor clean-up
OlegJakushkin Sep 12, 2023
30f5743
Inheritance simplified
OlegJakushkin Sep 12, 2023
e09142d
Classes extraction
OlegJakushkin Sep 12, 2023
d72c8e6
important refactoring
OlegJakushkin Sep 12, 2023
fd5ce5d
extracting Multicall Bridge Helper
OlegJakushkin Sep 12, 2023
474066e
Publish draft releases as the latest (#6058)
rubo Sep 13, 2023
add699c
Change version suffix from unstable to rc
kamilchodola Sep 13, 2023
26189fe
minor refactorings
OlegJakushkin Sep 13, 2023
edb0490
using NullReceiptStorage
OlegJakushkin Sep 13, 2023
4c3fc92
Merge remote-tracking branch 'origin/master' into feature/eth_multicall
OlegJakushkin Sep 13, 2023
15a7bb1
Merge remote-tracking branch 'origin/master' into feature/eth_multicall
OlegJakushkin Sep 18, 2023
8a04905
minor test fixes
OlegJakushkin Sep 18, 2023
b30d377
minor test fixes
OlegJakushkin Sep 18, 2023
bce00e4
Setting correct Tx type defaults
OlegJakushkin Sep 18, 2023
20fade3
minor tests fix
OlegJakushkin Sep 18, 2023
95e7c09
Merge remote-tracking branch 'origin/master' into feature/eth_multicall
OlegJakushkin Sep 18, 2023
a142364
clean up txTypes diff
OlegJakushkin Sep 19, 2023
9454814
Merge remote-tracking branch 'origin/master' into feature/eth_multicall
OlegJakushkin Sep 27, 2023
81f52a2
fixing missing state on "latest"
OlegJakushkin Sep 27, 2023
f5e616e
updated interface
OlegJakushkin Sep 27, 2023
1c7c4bf
updating tests
OlegJakushkin Sep 27, 2023
2a70ac4
Change TuneDb default to HeavyWrite (#6136)
kamilchodola Sep 27, 2023
a785044
[Fix][Holesky] timestamps and genesis updates (#6112)
smartprogrammer93 Sep 21, 2023
f02c690
Fix PPA package post-install script (#5991)
rubo Sep 28, 2023
92c8f81
Update executable and networks (#6141)
rubo Sep 28, 2023
bb9b72c
Bump client version to 1.21.0
kamilchodola Sep 28, 2023
08c3890
Merge remote-tracking branch 'origin/release/1.21.0' into feature/eth…
OlegJakushkin Oct 2, 2023
42b2e3a
Minor test fixes
OlegJakushkin Oct 2, 2023
b6c3b21
Feature/eth multicall refactor (#6175)
LukaszRozmej Oct 11, 2023
0603dd7
Merge 1.22
OlegJakushkin Oct 11, 2023
dc43a3d
Merge remote-tracking branch 'origin/release/1.22.0' into feature/eth…
OlegJakushkin Oct 11, 2023
e81f015
Merge branch 'master' into feature/eth_multicall
OlegJakushkin Oct 11, 2023
201baeb
post merge conflict resolution
OlegJakushkin Oct 11, 2023
6c1cebc
benchmark fixes
OlegJakushkin Oct 11, 2023
26f17fa
Revert VirtualMachine code layout a bit
LukaszRozmej Oct 11, 2023
cedafab
Clear state storrage on accountOverride.State (not StateDiff)
LukaszRozmej Oct 11, 2023
00d0d49
Refactor to introduce overrides in eth_call
LukaszRozmej Oct 12, 2023
e6e5324
HiveTests Added
OlegJakushkin Oct 16, 2023
d180fb1
Uint256 hex parsing when it is inside dictionary
OlegJakushkin Oct 23, 2023
64b34b1
Fixing dictionary parsing
OlegJakushkin Oct 24, 2023
b38c1b5
spaces fix
OlegJakushkin Oct 24, 2023
c719612
fixing nonce, parsing and processing issues
OlegJakushkin Nov 1, 2023
f8ea79c
merge master
OlegJakushkin Nov 1, 2023
3b5ff68
post merge build fixes
OlegJakushkin Nov 1, 2023
0af77c7
most tests fixed
OlegJakushkin Nov 1, 2023
a3df479
fixing block gas calculation, block processing catch
OlegJakushkin Nov 1, 2023
43e5af9
hot fix
OlegJakushkin Nov 1, 2023
cb0c102
merge master into eth_multycall
OlegJakushkin Nov 6, 2023
08acb1e
Fix aAPI update related issues
OlegJakushkin Nov 6, 2023
8536de7
Unit tests fix
OlegJakushkin Nov 6, 2023
ee5e4f6
fixing state used in multicall
OlegJakushkin Nov 13, 2023
857f835
Gas cap limits enforcement
OlegJakushkin Nov 13, 2023
f2274a9
fix spacing
OlegJakushkin Nov 13, 2023
0518264
Merge master
OlegJakushkin Nov 13, 2023
6118b29
fixing local move test
OlegJakushkin Nov 14, 2023
bf944ed
Hunted down trie exception
OlegJakushkin Nov 20, 2023
0c04244
Merge remote-tracking branch 'origin/master' into feature/eth_multicall
OlegJakushkin Nov 20, 2023
19f075a
fix whitespace
OlegJakushkin Nov 20, 2023
f5907c3
merge
OlegJakushkin Jan 18, 2024
36a6785
Merge remote-tracking branch 'origin/master' into feature/eth_multicall
OlegJakushkin Jan 18, 2024
7cd7f58
merge hotfix
OlegJakushkin Jan 18, 2024
909f927
Tree State Failed example
OlegJakushkin Jan 18, 2024
465baee
reset submodule
LukaszRozmej Jan 18, 2024
a85c00d
fixed serialisation tests
OlegJakushkin Jan 19, 2024
6d53c57
Add OverlayTrieStore and OverlayWorldStateManager
LukaszRozmej Jan 19, 2024
08cf03b
Merge remote-tracking branch 'origin/feature/eth_multicall' into feat…
LukaszRozmej Jan 19, 2024
687a460
fix test
LukaszRozmej Jan 19, 2024
277cc4f
Add UInt256 property conversion (for Dictionary key)
LukaszRozmej Jan 19, 2024
4021aff
Optimize WriteAsPropertyName
benaadams Jan 19, 2024
92f5c7e
Revert ` Extract revert messages #6226`
OlegJakushkin Jan 22, 2024
b7983f6
Moving to eth_simulate
OlegJakushkin Jan 22, 2024
b3fa159
Merge latest
OlegJakushkin Jan 22, 2024
c322262
fixing post merge
OlegJakushkin Jan 22, 2024
a4ae238
Renaming to simulate missed stuff
OlegJakushkin Jan 22, 2024
ae1c561
Merge remote-tracking branch 'origin/master' into feature/eth_multicall
OlegJakushkin Jan 22, 2024
56960ae
Fixing tree access
OlegJakushkin Jan 23, 2024
f0cd700
basic hive updates
OlegJakushkin Feb 7, 2024
4dbe050
Merge remote-tracking branch 'origin/master' into feature/eth_multicall
OlegJakushkin Feb 7, 2024
df4aee1
MissingTrieNodeException fix
OlegJakushkin Feb 7, 2024
1d07f61
minor debuggability tree exploration fix
OlegJakushkin Feb 8, 2024
8126d5b
Hive like Prunning And Persistence in tests
OlegJakushkin Feb 8, 2024
9cb16b7
Merge remote-tracking branch 'origin/master' into feature/eth_multicall
OlegJakushkin Feb 8, 2024
8eefe3e
fixing most of the unit tests
OlegJakushkin Feb 9, 2024
585927f
Test fixes
OlegJakushkin Feb 12, 2024
ced6a1b
Getting ready for merge
OlegJakushkin Feb 12, 2024
7021aaf
Merge remote-tracking branch 'origin/master' into feature/eth_multicall
OlegJakushkin Feb 12, 2024
2eeb005
initialize overlay tree with main tree head
LukaszRozmej Feb 13, 2024
d6e339b
FIx managing state
LukaszRozmej Feb 20, 2024
6d9b0cb
Merge remote-tracking branch 'origin/master' into feature/eth_multicall
OlegJakushkin Feb 20, 2024
6626f1d
minor fix
OlegJakushkin Feb 20, 2024
7766aeb
minor bug fixes
OlegJakushkin Feb 21, 2024
7420391
minor trello fixes
OlegJakushkin Feb 21, 2024
feeadf6
Minor tests fix
OlegJakushkin Feb 21, 2024
dd9843a
fix serialization of Uint256 as dictionary property name
LukaszRozmej Feb 21, 2024
c4bd380
add leading zeros
LukaszRozmej Feb 21, 2024
e4a381c
minor CI fixes
OlegJakushkin Feb 21, 2024
bd5fc59
cleanup
LukaszRozmej Feb 21, 2024
7d7c499
More cleanups
LukaszRozmej Feb 21, 2024
9fde5e0
BlockHash refactor
LukaszRozmej Feb 21, 2024
4c2110e
BlockTree refactor
LukaszRozmej Feb 21, 2024
a03fc36
restoring hive tests
OlegJakushkin Feb 21, 2024
db876c1
minor blockHashProvider related fixes
OlegJakushkin Feb 21, 2024
6ef4946
fix tests
LukaszRozmej Feb 21, 2024
e083535
refactor EthCliModule
LukaszRozmej Feb 21, 2024
44e67c7
Fixing project build
OlegJakushkin Feb 21, 2024
31a4a47
Merge branch 'feature/eth_multicall' of https://github.com/Nethermind…
OlegJakushkin Feb 21, 2024
20605b5
Merge remote-tracking branch 'origin/master' into feature/eth_multicall
OlegJakushkin Feb 21, 2024
6bca09f
revert BlockHashProvider rename
LukaszRozmej Feb 21, 2024
64d3503
more revert
LukaszRozmej Feb 21, 2024
9431c73
fix
LukaszRozmej Feb 21, 2024
f9ec7d1
more revert
LukaszRozmej Feb 21, 2024
74b68ae
Merge branch 'feature/eth_multicall' of https://github.com/Nethermind…
OlegJakushkin Feb 21, 2024
be04bdf
minor trello fixes
OlegJakushkin Feb 21, 2024
6664f2f
status text issue fix
OlegJakushkin Feb 21, 2024
4cb263d
changing test that shall fail on current setup due to gas fees
OlegJakushkin Feb 21, 2024
0408f1d
Fixing project build
OlegJakushkin Feb 21, 2024
0df45dc
more revert
LukaszRozmej Feb 21, 2024
67425a6
fix CodeInfoRepository
LukaszRozmej Feb 21, 2024
cd8d307
more refactor
LukaszRozmej Feb 21, 2024
c7507db
majour protocol fixes
OlegJakushkin Mar 25, 2024
4373849
minor fixes
OlegJakushkin Mar 25, 2024
453b37c
merge
OlegJakushkin Mar 25, 2024
29ae661
post merge fixes
OlegJakushkin Mar 25, 2024
79e6a72
fixing hive tests
OlegJakushkin Mar 27, 2024
ce872a6
Merge remote-tracking branch 'origin/master' into feature/eth_multicall
OlegJakushkin Mar 27, 2024
069b452
merge
OlegJakushkin Apr 2, 2024
1614e12
fix formating
OlegJakushkin Apr 2, 2024
4472169
fixing protocol issues
OlegJakushkin Apr 3, 2024
be34ebe
Merge remote-tracking branch 'origin/master' into feature/eth_multicall
OlegJakushkin Apr 3, 2024
ef83e97
merge fix
OlegJakushkin Apr 29, 2024
2dc5513
Minor fixes
OlegJakushkin Apr 29, 2024
11d0e6a
Extra transfer Logs use eEE address
OlegJakushkin Apr 29, 2024
706aacf
manual diff merge with maser using araxis
OlegJakushkin Apr 29, 2024
3a3e115
fix formatting
OlegJakushkin Apr 29, 2024
1d6874d
Merge remote-tracking branch 'origin/master' into feature/eth_multicall
OlegJakushkin Apr 29, 2024
5b717b6
fix test
LukaszRozmej May 3, 2024
2665446
Revert "fix test"
LukaszRozmej May 3, 2024
932c615
Merge remote-tracking branch 'origin/master' into feature/eth_multicall
OlegJakushkin May 7, 2024
1a99a29
pre review fixes
OlegJakushkin May 7, 2024
ffbec51
merge and tests fix
OlegJakushkin May 7, 2024
c007a4e
post merge tests fixes
OlegJakushkin May 7, 2024
bf57556
automated cleanup of new files
OlegJakushkin May 8, 2024
3df6703
Merge branch 'feature/eth_multicall' of https://github.com/Nethermind…
OlegJakushkin May 8, 2024
5e22d16
Merge branch 'master' into feature/eth_multicall
OlegJakushkin May 8, 2024
183d303
Merge remote-tracking branch 'origin/master' into feature/eth_multicall
OlegJakushkin May 13, 2024
918e9fd
Minor bug fixes
OlegJakushkin May 13, 2024
37b52bb
refactors
LukaszRozmej May 14, 2024
5e7be69
Refactor ITxLogsTracer to ITxLogsMutator and introduce SimulateVirtua…
LukaszRozmej May 14, 2024
4ac4f6e
Merge remote-tracking branch 'origin/feature/eth_multicall' into feat…
LukaszRozmej May 14, 2024
b9be04d
Revert TxHashCalculator changes
LukaszRozmej May 14, 2024
57805bd
Move ErrorCodes,
LukaszRozmej May 14, 2024
d542546
Revert "Move ErrorCodes,"
LukaszRozmej May 14, 2024
e443f84
more refactors
LukaszRozmej May 14, 2024
fe87832
Big SimulateBridgeHelper refactor
LukaszRozmej May 14, 2024
b408aaf
minor issues fix
OlegJakushkin May 14, 2024
4740cc1
more refactor
LukaszRozmej May 14, 2024
9701065
not null
LukaszRozmej May 14, 2024
e4efdc6
minor Trello issues fixes
OlegJakushkin May 14, 2024
944566c
merge fixes
OlegJakushkin May 14, 2024
2343eb8
merge master
OlegJakushkin May 14, 2024
17fdf84
minor fix
OlegJakushkin May 14, 2024
d85bf1d
dotnet format
OlegJakushkin May 14, 2024
98f2a1f
Add SimulateTransactionProcessor
LukaszRozmej May 14, 2024
a9e1b70
Merge branch 'feature/eth_multicall' of github.com:NethermindEth/neth…
LukaszRozmej May 14, 2024
997ea55
Bring back AnalyseInBackgroundIfRequired
LukaszRozmej May 14, 2024
8b37572
fix
LukaszRozmej May 14, 2024
a72a6a8
revert format
LukaszRozmej May 14, 2024
0acf045
Review updates
OlegJakushkin May 16, 2024
67a4c43
Merge branch 'feature/eth_multicall' of https://github.com/Nethermind…
OlegJakushkin May 16, 2024
a201a10
merged
OlegJakushkin May 16, 2024
77fda4b
Minor fixes
OlegJakushkin May 16, 2024
1ac41f5
review RLP fixes
OlegJakushkin May 17, 2024
ea29971
Merge remote-tracking branch 'origin/master' into feature/eth_multicall
OlegJakushkin May 17, 2024
dc24c33
integrating SecondsPerSlot
OlegJakushkin May 17, 2024
ad2d7f9
merge fixes
OlegJakushkin May 23, 2024
c3923f3
merge fixes
OlegJakushkin May 23, 2024
f3c4056
minor review fixes
OlegJakushkin May 23, 2024
00c0bd7
Merge branch 'master' into feature/eth_multicall
OlegJakushkin May 23, 2024
37219c5
merge
OlegJakushkin May 28, 2024
88fea58
minor clean-up
OlegJakushkin May 28, 2024
9db6836
minor cleanup
LukaszRozmej May 29, 2024
57461c3
merge fix
LukaszRozmej May 29, 2024
c804851
fix
LukaszRozmej May 29, 2024
9adf550
fix
LukaszRozmej May 29, 2024
6b6b255
Cache precompile results & Optimize precompiles
LukaszRozmej May 29, 2024
3d55d47
Add IPrecompile.Failure;
LukaszRozmej May 29, 2024
b846f77
fixes
LukaszRozmej May 29, 2024
9613d30
Merge remote-tracking branch 'origin/master' into feature/eth_multicall
LukaszRozmej May 29, 2024
5f324a9
merge fix
LukaszRozmej May 29, 2024
ec1071d
Merge branch 'feature/eth_multicall' into optimization/cache-precompiles
LukaszRozmej May 29, 2024
ce2c6c2
remove bloated text from test results
LukaszRozmej May 29, 2024
9051151
try fixing precompile
LukaszRozmej May 29, 2024
6a41a19
fix
LukaszRozmej May 29, 2024
4fd1f00
fix
LukaszRozmej May 29, 2024
e4e585a
more fixes
LukaszRozmej May 29, 2024
2a56558
Merge remote-tracking branch 'origin/master' into feature/eth_multicall
LukaszRozmej May 31, 2024
0c3c72c
Merge branch 'feature/eth_multicall' into optimization/cache-precompiles
LukaszRozmej May 31, 2024
f5e4b86
fix use of cache
LukaszRozmej May 31, 2024
e9744b9
fix clearing cache
LukaszRozmej May 31, 2024
dfd66a2
Merge branch 'master' into feature/eth_multicall
benaadams May 31, 2024
d8a8d10
Merge branch 'feature/eth_multicall' into optimization/cache-precompiles
benaadams May 31, 2024
ce25160
Fix PrecompileCacheKey.GetHashCode
benaadams May 31, 2024
8dc0303
Fix merge conflict
benaadams May 31, 2024
fd2985b
Use non-blocking dict
benaadams May 31, 2024
3ac4834
Merge remote-tracking branch 'origin/master' into feature/eth_multicall
OlegJakushkin Jun 3, 2024
f84c67b
Review based changes
OlegJakushkin Jun 3, 2024
53a79b1
Minor review fixes
OlegJakushkin Jun 3, 2024
d1cde8f
some minor fixes
OlegJakushkin Jun 3, 2024
9440eda
merge
OlegJakushkin Jun 10, 2024
aa6277b
new call result layout
OlegJakushkin Jun 10, 2024
3838f3e
move of RPC structures to Facade
OlegJakushkin Jun 10, 2024
69528a1
Merge remote-tracking branch 'origin/master' into feature/eth_multicall
OlegJakushkin Jun 10, 2024
b559c8c
Removing a flag
OlegJakushkin Jun 10, 2024
e1a1f93
minor fixes
OlegJakushkin Jun 10, 2024
751ab48
Merge remote-tracking branch 'origin/feature/eth_multicall' into opti…
LukaszRozmej Jun 10, 2024
0992e1b
Merge remote-tracking branch 'origin/master' into optimization/cache-…
LukaszRozmej Jun 10, 2024
f13ad6f
fixes
LukaszRozmej Jun 10, 2024
eb1e2d7
fix
LukaszRozmej Jun 12, 2024
cec2018
Merge remote-tracking branch 'origin/master' into optimization/cache-…
LukaszRozmej Jun 12, 2024
6394072
Update src/Nethermind/Nethermind.Evm/CodeInfoRepository.cs
LukaszRozmej Jun 12, 2024
42bf7cd
fix
LukaszRozmej Jun 12, 2024
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 @@ -14,6 +14,7 @@
using Nethermind.Blockchain.Contracts.Json;
using Nethermind.Consensus;
using Nethermind.Core;
using Nethermind.Core.Collections;
using Nethermind.Core.Crypto;
using Nethermind.Core.Extensions;
using Nethermind.Core.Test.Builders;
Expand Down Expand Up @@ -96,9 +97,10 @@ public Address GetAccountAddress(TestRpcBlockchain chain, Address entryPointAddr
.SignedAndResolved(TestItem.PrivateKeyA)
.TestObject;

Address accountAddress = new(Bytes.FromHexString(chain.EthRpcModule.eth_call(new TransactionForRpc(getAccountAddressTransaction)).Data).SliceWithZeroPaddingEmptyOnError(12, 20));
using ArrayPoolList<byte> data = Bytes.FromHexString(chain.EthRpcModule.eth_call(new TransactionForRpc(getAccountAddressTransaction)).Data)
.SliceWithZeroPaddingEmptyOnError(12, 20);

return accountAddress;
return new(data.ToArray());
}

public byte[] GetWalletConstructor(Address entryPointAddress)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public PerfStateTest(ITestSourceLoader testsSource)
public IEnumerable<EthereumTestResult> RunTests()
{
List<EthereumTestResult> results = new List<EthereumTestResult>();
Console.WriteLine($"RUNNING tests");
Console.WriteLine("RUNNING tests");
Stopwatch stopwatch = new Stopwatch();
IEnumerable<GeneralStateTest> tests = (IEnumerable<GeneralStateTest>)_testsSource.LoadTests();
bool isNewLine = true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@ public AuRaBlockProcessor(
IAuRaValidator? auRaValidator,
ITxFilter? txFilter = null,
AuRaContractGasLimitOverride? gasLimitOverride = null,
ContractRewriter? contractRewriter = null)
ContractRewriter? contractRewriter = null,
IBlockCachePreWarmer? preWarmer = null)
: base(
specProvider,
blockValidator,
Expand All @@ -55,7 +56,8 @@ public AuRaBlockProcessor(
receiptStorage,
new BlockhashStore(blockTree, specProvider, stateProvider),
logManager,
withdrawalProcessor)
withdrawalProcessor,
preWarmer: preWarmer)
{
_specProvider = specProvider;
_blockTree = blockTree ?? throw new ArgumentNullException(nameof(blockTree));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ protected override async Task InitBlockchain()
}
}

protected override BlockProcessor CreateBlockProcessor()
protected override BlockProcessor CreateBlockProcessor(BlockCachePreWarmer? preWarmer)
{
if (_api.SpecProvider is null) throw new StepDependencyException(nameof(_api.SpecProvider));
if (_api.ChainHeadStateProvider is null) throw new StepDependencyException(nameof(_api.ChainHeadStateProvider));
Expand All @@ -89,10 +89,10 @@ protected override BlockProcessor CreateBlockProcessor()
_api,
new ServiceTxFilter(_api.SpecProvider));

return NewAuraBlockProcessor(auRaTxFilter);
return NewAuraBlockProcessor(auRaTxFilter, preWarmer);
}

protected virtual AuRaBlockProcessor NewAuraBlockProcessor(ITxFilter txFilter)
protected virtual AuRaBlockProcessor NewAuraBlockProcessor(ITxFilter txFilter, BlockCachePreWarmer? preWarmer)
{
IDictionary<long, IDictionary<Address, byte[]>> rewriteBytecode = _api.ChainSpec.AuRa.RewriteBytecode;
ContractRewriter? contractRewriter = rewriteBytecode?.Count > 0 ? new ContractRewriter(rewriteBytecode) : null;
Expand All @@ -112,7 +112,8 @@ protected virtual AuRaBlockProcessor NewAuraBlockProcessor(ITxFilter txFilter)
CreateAuRaValidator(),
txFilter,
GetGasLimitCalculator(),
contractRewriter
contractRewriter,
preWarmer: preWarmer
);
}

Expand Down
11 changes: 7 additions & 4 deletions src/Nethermind/Nethermind.Consensus/Processing/BlockProcessor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -117,9 +117,9 @@ the previous head state.*/
}

using CancellationTokenSource cancellationTokenSource = new();
Task? preWarmTask = suggestedBlock.Transactions.Length < 3 ?
null :
_preWarmer?.PreWarmCaches(suggestedBlock, preBlockStateRoot!, cancellationTokenSource.Token);
Task? preWarmTask = suggestedBlock.Transactions.Length < 3
? null
: _preWarmer?.PreWarmCaches(suggestedBlock, preBlockStateRoot!, cancellationTokenSource.Token);
(Block processedBlock, TxReceipt[] receipts) = ProcessOne(suggestedBlock, options, blockTracer);
cancellationTokenSource.Cancel();
preWarmTask?.GetAwaiter().GetResult();
Expand Down Expand Up @@ -160,9 +160,12 @@ the previous head state.*/
{
_logger.Trace($"Encountered exception {ex} while processing blocks.");
RestoreBranch(previousBranchStateRoot);
_preWarmer?.ClearCaches();
throw;
}
finally
{
_preWarmer?.ClearCaches();
}
}

public event EventHandler<BlocksProcessingEventArgs>? BlocksProcessing;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public ReadOnlyTxProcessingEnv(
IWorldState? worldStateToWarmUp = null
) : base(worldStateManager, readOnlyBlockTree, specProvider, logManager, worldStateToWarmUp)
{
CodeInfoRepository = new CodeInfoRepository();
CodeInfoRepository = new CodeInfoRepository((worldStateToWarmUp as IPreBlockCaches)?.Caches.PrecompileCache);
Machine = new VirtualMachine(BlockhashProvider, specProvider, CodeInfoRepository, logManager);
BlockTree = readOnlyBlockTree ?? throw new ArgumentNullException(nameof(readOnlyBlockTree));
BlockhashProvider = new BlockhashProvider(BlockTree, specProvider, StateProvider, logManager);
Expand Down
21 changes: 10 additions & 11 deletions src/Nethermind/Nethermind.Core/Extensions/ByteArrayExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// SPDX-License-Identifier: LGPL-3.0-only

using System;
using Nethermind.Core.Collections;

namespace Nethermind.Core.Extensions
{
Expand Down Expand Up @@ -34,39 +35,37 @@ public static byte[] Slice(this byte[] bytes, int startIndex, int length)
{
if (length == 1)
{
return new[] { bytes[startIndex] };
return [bytes[startIndex]];
}

byte[] slice = new byte[length];
Buffer.BlockCopy(bytes, startIndex, slice, 0, length);
return slice;
}

public static byte[] SliceWithZeroPaddingEmptyOnError(this byte[] bytes, int startIndex, int length)
public static ArrayPoolList<byte> SliceWithZeroPaddingEmptyOnError(this byte[] bytes, int startIndex, int length)
{
int copiedFragmentLength = Math.Min(bytes.Length - startIndex, length);
if (copiedFragmentLength <= 0)
{
return Array.Empty<byte>();
return ArrayPoolList<byte>.Empty();
}

byte[] slice = new byte[length];

Buffer.BlockCopy(bytes, startIndex, slice, 0, copiedFragmentLength);
ArrayPoolList<byte> slice = new(length, length);
bytes.Slice(startIndex, copiedFragmentLength).CopyTo(slice.AsSpan().Slice(0, copiedFragmentLength));
return slice;
}

public static byte[] SliceWithZeroPaddingEmptyOnError(this ReadOnlySpan<byte> bytes, int startIndex, int length)
public static ArrayPoolList<byte> SliceWithZeroPaddingEmptyOnError(this ReadOnlySpan<byte> bytes, int startIndex, int length)
{
int copiedFragmentLength = Math.Min(bytes.Length - startIndex, length);
if (copiedFragmentLength <= 0)
{
return Array.Empty<byte>();
return ArrayPoolList<byte>.Empty();
}

byte[] slice = new byte[length];

bytes.Slice(startIndex, copiedFragmentLength).CopyTo(slice.AsSpan(0, copiedFragmentLength));
ArrayPoolList<byte> slice = new(length, length);
bytes.Slice(startIndex, copiedFragmentLength).CopyTo(slice.AsSpan().Slice(0, copiedFragmentLength));
return slice;
}
}
Expand Down
6 changes: 6 additions & 0 deletions src/Nethermind/Nethermind.Core/Extensions/Bytes.cs
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,12 @@ public static int LeadingZerosCount(this Span<byte> bytes, int startIndex = 0)
return nonZeroIndex < 0 ? bytes.Length - startIndex : nonZeroIndex;
}

public static int LeadingZerosCount(this ReadOnlySpan<byte> bytes, int startIndex = 0)
{
int nonZeroIndex = bytes[startIndex..].IndexOfAnyExcept((byte)0);
return nonZeroIndex < 0 ? bytes.Length - startIndex : nonZeroIndex;
}

public static int TrailingZerosCount(this byte[] bytes)
{
int lastIndex = bytes.AsSpan().LastIndexOfAnyExcept((byte)0);
Expand Down
42 changes: 41 additions & 1 deletion src/Nethermind/Nethermind.Evm/CodeInfoRepository.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// SPDX-License-Identifier: LGPL-3.0-only

using System;
using System.Collections.Concurrent;
using System.Collections.Frozen;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
Expand Down Expand Up @@ -61,6 +62,7 @@ public bool TryGet(in ValueHash256 codeHash, [NotNullWhen(true)] out CodeInfo? c

private static readonly FrozenDictionary<AddressAsKey, CodeInfo> _precompiles = InitializePrecompiledContracts();
private static readonly CodeLruCache _codeCache = new();
private readonly FrozenDictionary<AddressAsKey, CodeInfo> _localPrecompiles;

private static FrozenDictionary<AddressAsKey, CodeInfo> InitializePrecompiledContracts()
{
Expand Down Expand Up @@ -92,11 +94,18 @@ private static FrozenDictionary<AddressAsKey, CodeInfo> InitializePrecompiledCon
}.ToFrozenDictionary();
}

public CodeInfoRepository(ConcurrentDictionary<PreBlockCaches.PrecompileCacheKey, (ReadOnlyMemory<byte>, bool)>? precompileCache = null)
{
_localPrecompiles = precompileCache is null
? _precompiles
: _precompiles.ToFrozenDictionary(kvp => kvp.Key, kvp => CreateCachedPrecompile(kvp, precompileCache));
}

public CodeInfo GetCachedCodeInfo(IWorldState worldState, Address codeSource, IReleaseSpec vmSpec)
{
if (codeSource.IsPrecompile(vmSpec))
{
return _precompiles[codeSource];
return _localPrecompiles[codeSource];
}

CodeInfo? cachedCodeInfo = null;
Expand Down Expand Up @@ -158,4 +167,35 @@ public void InsertCode(IWorldState state, ReadOnlyMemory<byte> code, Address cod
state.InsertCode(codeOwner, codeHash, code, spec);
_codeCache.Set(codeHash, codeInfo);
}

private CodeInfo CreateCachedPrecompile(
in KeyValuePair<AddressAsKey, CodeInfo> originalPrecompile,
ConcurrentDictionary<PreBlockCaches.PrecompileCacheKey, (ReadOnlyMemory<byte>, bool)> cache) =>
new(new CachedPrecompile(originalPrecompile.Key.Value, originalPrecompile.Value.Precompile!, cache));

private class CachedPrecompile(
Address address,
IPrecompile precompile,
ConcurrentDictionary<PreBlockCaches.PrecompileCacheKey, (ReadOnlyMemory<byte>, bool)> cache) : IPrecompile
{
public static Address Address => Address.Zero;

public long BaseGasCost(IReleaseSpec releaseSpec) => precompile.BaseGasCost(releaseSpec);

public long DataGasCost(in ReadOnlyMemory<byte> inputData, IReleaseSpec releaseSpec) => precompile.DataGasCost(inputData, releaseSpec);

public (ReadOnlyMemory<byte>, bool) Run(in ReadOnlyMemory<byte> inputData, IReleaseSpec releaseSpec)
{
PreBlockCaches.PrecompileCacheKey key = new(address, inputData);
if (!cache.TryGetValue(key, out (ReadOnlyMemory<byte>, bool) result))
{
result = precompile.Run(inputData, releaseSpec);
// we need to rebuild the key with data copy as the data can be changed by VM processing
key = new PreBlockCaches.PrecompileCacheKey(address, inputData.ToArray());
cache.TryAdd(key, result);
}

return result;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,13 @@ public long DataGasCost(in ReadOnlyMemory<byte> inputData, IReleaseSpec releaseS
{
if (inputData.Length != RequiredInputLength)
{
return (Array.Empty<byte>(), false);
return IPrecompile.Failure;
}

byte finalByte = inputData.Span[212];
if (finalByte != 0 && finalByte != 1)
{
return (Array.Empty<byte>(), false);
return IPrecompile.Failure;
}

byte[] result = new byte[64];
Expand Down
25 changes: 4 additions & 21 deletions src/Nethermind/Nethermind.Evm/Precompiles/Bls/G1AddPrecompile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,37 +21,20 @@ private G1AddPrecompile()

public static Address Address { get; } = Address.FromNumber(0x0b);

public long BaseGasCost(IReleaseSpec releaseSpec)
{
return 500L;
}
public long BaseGasCost(IReleaseSpec releaseSpec) => 500L;

public long DataGasCost(in ReadOnlyMemory<byte> inputData, IReleaseSpec releaseSpec)
{
return 0L;
}
public long DataGasCost(in ReadOnlyMemory<byte> inputData, IReleaseSpec releaseSpec) => 0L;

public (ReadOnlyMemory<byte>, bool) Run(in ReadOnlyMemory<byte> inputData, IReleaseSpec releaseSpec)
{
const int expectedInputLength = 4 * BlsParams.LenFp;
if (inputData.Length != expectedInputLength)
{
return (Array.Empty<byte>(), false);
return IPrecompile.Failure;
}

(byte[], bool) result;

Span<byte> output = stackalloc byte[2 * BlsParams.LenFp];
bool success = Pairings.BlsG1Add(inputData.Span, output);
if (success)
{
result = (output.ToArray(), true);
}
else
{
result = (Array.Empty<byte>(), false);
}

return result;
return success ? (output.ToArray(), true) : IPrecompile.Failure;
}
}
27 changes: 6 additions & 21 deletions src/Nethermind/Nethermind.Evm/Precompiles/Bls/G1MulPrecompile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// SPDX-License-Identifier: LGPL-3.0-only

using System;
using System.Runtime.CompilerServices;
using Nethermind.Core;
using Nethermind.Core.Specs;
using Nethermind.Crypto;
Expand All @@ -21,39 +22,23 @@ private G1MulPrecompile()

public static Address Address { get; } = Address.FromNumber(0x0c);

public long BaseGasCost(IReleaseSpec releaseSpec)
{
return 12000L;
}
public long BaseGasCost(IReleaseSpec releaseSpec) => 12000L;

public long DataGasCost(in ReadOnlyMemory<byte> inputData, IReleaseSpec releaseSpec)
{
return 0L;
}
public long DataGasCost(in ReadOnlyMemory<byte> inputData, IReleaseSpec releaseSpec) => 0L;

[SkipLocalsInit]
public (ReadOnlyMemory<byte>, bool) Run(in ReadOnlyMemory<byte> inputData, IReleaseSpec releaseSpec)
{
const int expectedInputLength = 2 * BlsParams.LenFp + BlsParams.LenFr;
if (inputData.Length != expectedInputLength)
{
return (Array.Empty<byte>(), false);
return IPrecompile.Failure;
}

(byte[], bool) result;

Span<byte> output = stackalloc byte[2 * BlsParams.LenFp];
bool success = SubgroupChecks.G1IsInSubGroup(inputData.Span[..(2 * BlsParams.LenFp)])
&& Pairings.BlsG1Mul(inputData.Span, output);

if (success)
{
result = (output.ToArray(), true);
}
else
{
result = (Array.Empty<byte>(), false);
}

return result;
return success ? (output.ToArray(), true) : IPrecompile.Failure;
}
}
Loading