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

Changes for EIP7685, 7002 & 6110: Flat Encoding of requests #7670

Merged
merged 671 commits into from
Nov 6, 2024
Merged
Show file tree
Hide file tree
Changes from 250 commits
Commits
Show all changes
671 commits
Select commit Hold shift + click to select a range
1053f7a
Revert "Use uint256 for sig values"
ak88 Sep 4, 2024
51856ad
unittest fixes
ak88 Sep 4, 2024
8335b61
unique check auth sig validity
ak88 Sep 4, 2024
d5b8037
test cleanup
ak88 Sep 4, 2024
e996c17
unittest fix
ak88 Sep 4, 2024
2ce9f73
do not allow empty auth list
ak88 Sep 5, 2024
2da8111
tx pool check if sender is delegation
ak88 Sep 5, 2024
22152a8
unittest for TxPool
ak88 Sep 6, 2024
904bdb6
modified hive.json for debugging
MarekM25 Sep 9, 2024
b6f2563
hive test cfg
ak88 Sep 9, 2024
6a77929
cleanup
ak88 Sep 9, 2024
2f1e85c
Auth list in RPC
ak88 Sep 9, 2024
d59d3fa
fix, disallow create tx in SetCode tx type
smartprogrammer93 Sep 10, 2024
189e566
fix chainid
ak88 Sep 12, 2024
0f388d1
revert temp path too long fix
ak88 Sep 12, 2024
c938923
small refactors
LukaszRozmej Sep 16, 2024
291ba9b
more basic refactors and cleanups
LukaszRozmej Sep 16, 2024
046fb36
Resolved conflicts
MarekM25 Sep 17, 2024
a0dbd21
Solving errors
MarekM25 Sep 17, 2024
7ec64d2
Builds error solved
MarekM25 Sep 17, 2024
7baea0b
Resolved conflicts
MarekM25 Sep 17, 2024
3e8726e
fix build errors
MarekM25 Sep 17, 2024
0db830c
cherry pick missing from 7702
ak88 Sep 17, 2024
b90b883
fix whitespaces
MarekM25 Sep 17, 2024
4532047
fix merge tests
MarekM25 Sep 17, 2024
93a7c75
cosmetic
MarekM25 Sep 17, 2024
a739b22
Null handling for requests
MarekM25 Sep 17, 2024
fa10981
tx decoder for setcode
ak88 Sep 17, 2024
7aa7aa8
RPC module tests for 7702
ak88 Sep 11, 2024
c9c1afc
cleanup after missing commit
ak88 Sep 17, 2024
5ac555e
tx validator for setcode refactor
ak88 Sep 18, 2024
7b5f627
fix tests
MarekM25 Sep 18, 2024
2953bca
cosmetic
MarekM25 Sep 18, 2024
f3c2c52
fix whitespace?
MarekM25 Sep 18, 2024
76b8b6f
whitespace?
MarekM25 Sep 18, 2024
540b86c
fix test
MarekM25 Sep 18, 2024
ce64d97
cosmetic
MarekM25 Sep 18, 2024
66bd24e
fix test
MarekM25 Sep 18, 2024
6465805
fix tx pool tests
ak88 Sep 18, 2024
958df8a
use BlockchainId instead
ak88 Sep 18, 2024
3f5e57b
unnecessary using
ak88 Sep 18, 2024
4c564b3
use BlockchainId instead
ak88 Sep 18, 2024
98d5277
Resolved conflicts with payload bodies
MarekM25 Sep 18, 2024
e39c754
Merge branch 'pectra_fix_7702_after_merge' of https://github.com/neth…
MarekM25 Sep 18, 2024
ff823b0
revert proof module
MarekM25 Sep 18, 2024
2653613
fix one more test
MarekM25 Sep 18, 2024
1857a61
fix whitespace
MarekM25 Sep 18, 2024
95fb7fa
whitespaces?
MarekM25 Sep 18, 2024
5c41d0a
fix whitespace
MarekM25 Sep 18, 2024
e8c1782
?fix
MarekM25 Sep 18, 2024
e8011ff
fix
MarekM25 Sep 18, 2024
28839a9
fix Evm.Test
MarekM25 Sep 18, 2024
63e262c
fix
MarekM25 Sep 18, 2024
2fac622
use SpecProvider.ChainId in test
ak88 Sep 18, 2024
6018e7d
Merge branch 'pectra_fix_7702_after_merge' of https://github.com/Neth…
ak88 Sep 18, 2024
d4b36c5
small refactor TransactionProcessorEip7702Tests
ak88 Sep 18, 2024
f3301ad
ignore authorization list if null TransactionForRpc
ak88 Sep 18, 2024
e7a91a2
fix SimulateReadOnlyBlocksProcessingEnv
ak88 Sep 18, 2024
51a63dd
fix EthModuleBenchmarks
ak88 Sep 18, 2024
ed6b5bf
remove unnecessary ?
LukaszRozmej Sep 19, 2024
a249a58
Move engine_getPayloadBodiesByHash to IHandler, no Async needed
LukaszRozmej Sep 19, 2024
b298026
syntatic suggar
LukaszRozmej Sep 19, 2024
638fd41
Merge branch 'master' into pectra_eips
MarekM25 Sep 19, 2024
a911023
Merge branch 'pectra_eips' into pectra_payload_bodies
MarekM25 Sep 19, 2024
bc5130b
Consensus requests change class structure
MarekM25 Sep 19, 2024
d29ca4d
one more field
MarekM25 Sep 19, 2024
1518f27
class to abstract
MarekM25 Sep 19, 2024
3acb335
Review fixes
MarekM25 Sep 19, 2024
650630e
Resolved conflicts
MarekM25 Sep 19, 2024
53043ad
extra test for refunds
ak88 Sep 19, 2024
d3197ec
some cosmetic changes
MarekM25 Sep 19, 2024
15040c9
Merge branch 'pectra_fix_7702_after_merge' of https://github.com/neth…
MarekM25 Sep 19, 2024
4e71d9a
Test null address
ak88 Sep 19, 2024
3361a63
remove unused
ak88 Sep 20, 2024
45bf7bd
enginemoduletest
ak88 Sep 20, 2024
28a0f7c
improve recoversignatures
ak88 Sep 20, 2024
026de88
Merge branch 'new_test' into pectra_fix_7702_after_merge
ak88 Sep 20, 2024
aec7e85
fix test
ak88 Sep 20, 2024
5e59935
if sender recovered from pool also set authority
ak88 Sep 20, 2024
54a59ba
Apply suggestions from code review
ak88 Sep 20, 2024
9c3ec4d
cosmetic
ak88 Sep 20, 2024
6d90306
Merge branch 'pectra_fix_7702_after_merge' of https://github.com/Neth…
ak88 Sep 20, 2024
7f48fd6
a few optimizations
MarekM25 Sep 20, 2024
552b704
Merge branch 'pectra_fix_7702_after_merge' of https://github.com/neth…
MarekM25 Sep 20, 2024
7da0be0
fix
MarekM25 Sep 20, 2024
18a3e0e
cosmetic
MarekM25 Sep 20, 2024
58ae212
cosmetic
MarekM25 Sep 23, 2024
c35e4ea
Resolved conflicts
MarekM25 Sep 23, 2024
581321d
cosmetic cleanup
ak88 Sep 23, 2024
43a99b2
cosmetic
ak88 Sep 24, 2024
757d06f
removed metric
ak88 Sep 24, 2024
1aa8096
cosmetic
MarekM25 Sep 25, 2024
65f06e2
Merge branch 'pectra_fix_7702_after_merge' of https://github.com/neth…
MarekM25 Sep 25, 2024
d124cf7
small optimization
ak88 Sep 25, 2024
f3bce87
small changes from review
ak88 Sep 25, 2024
0e23a9e
changes around CodeInfoRepository
LukaszRozmej Sep 26, 2024
e66c64c
Update src/Nethermind/Nethermind.Evm/CodeInfoRepository.cs
LukaszRozmej Sep 26, 2024
667e168
Update src/Nethermind/Nethermind.Evm/CodeInfoRepository.cs
LukaszRozmej Sep 26, 2024
42ab153
Update src/Nethermind/Nethermind.Consensus/Validators/TxValidator.cs
LukaszRozmej Sep 26, 2024
085fa42
Update src/Nethermind/Nethermind.Consensus/Validators/TxValidator.cs
LukaszRozmej Sep 26, 2024
a7dd3d9
Update src/Nethermind/Nethermind.Evm/VirtualMachine.cs
LukaszRozmej Sep 26, 2024
0b8062f
Update src/Nethermind/Nethermind.Facade/Eth/TransactionForRpc.cs
LukaszRozmej Sep 26, 2024
49105d2
Update src/Nethermind/Nethermind.State/IReadOnlyStateProviderExtensio…
LukaszRozmej Sep 26, 2024
110a5b8
fixes
LukaszRozmej Sep 26, 2024
c4b083d
avoid newing HashSet
ak88 Sep 26, 2024
1c69596
add NoContractCreationTxValidator, change SetCodeTxValidator to Autho…
LukaszRozmej Sep 26, 2024
8729021
Move code to value hashes
LukaszRozmej Sep 26, 2024
407effa
ReadConsolidationRequests reorder params to have consistency
LukaszRozmej Sep 26, 2024
a7035ce
simplify IntrinsicGasCalculator
LukaszRozmej Sep 26, 2024
d0dd643
simplify AccessListCost
LukaszRozmej Sep 26, 2024
295854f
grab TxExecutionContext by reference
LukaszRozmej Sep 26, 2024
c323bae
Invert VM condition for readability
LukaszRozmej Sep 26, 2024
900ac8b
Simplify RecoverAuthorityFilter
LukaszRozmej Sep 26, 2024
141c565
fix AuthorizationTupleDecoder
LukaszRozmej Sep 26, 2024
8607c8e
remove IRlpObjectDecoder<ConsolidationRequest>
LukaszRozmej Sep 26, 2024
b998979
bring back exceptions in IntrinsicGasCalculator
LukaszRozmej Sep 26, 2024
6a6db8b
fix
LukaszRozmej Sep 26, 2024
794f6da
fix
LukaszRozmej Sep 26, 2024
5f714d1
More CodeInfoRepository changes
LukaszRozmej Sep 26, 2024
fbc6822
More renames
LukaszRozmej Sep 26, 2024
cbde5c8
More refactors
LukaszRozmej Sep 26, 2024
2a9da1c
fixes
LukaszRozmej Sep 26, 2024
254ff42
changes from review
ak88 Sep 27, 2024
76129ad
decoder netty fix
ak88 Sep 27, 2024
70a3390
also check auth sig in recovery
ak88 Sep 27, 2024
ab855fb
move sign func to extension
ak88 Sep 28, 2024
e28f666
changes from review
ak88 Sep 30, 2024
2963ac2
fix tests
ak88 Oct 1, 2024
1be004e
refactor codeinforepo test
ak88 Oct 2, 2024
eeb4ff9
base class for processors
ak88 Sep 30, 2024
096fb43
Merge branch 'master' into pectra_fix_7702_after_merge
ak88 Oct 2, 2024
facba02
merge fix
ak88 Oct 2, 2024
60348e2
comment correction
ak88 Oct 2, 2024
e4c49d3
Merge branch 'master' into pectra_fix_7702_after_merge
ak88 Oct 2, 2024
86c9df2
format whitespace
ak88 Oct 2, 2024
cd151cc
benchmark fix
ak88 Oct 2, 2024
347a63a
small test change
ak88 Oct 2, 2024
0087008
Merge branch 'master' into pectra_fix_7702_after_merge
MarekM25 Oct 3, 2024
464deeb
Update src/Nethermind/Nethermind.Consensus/Processing/RecoverSignatur…
ak88 Oct 4, 2024
59a1ae2
Update src/Nethermind/Nethermind.Consensus/Processing/RecoverSignatur…
ak88 Oct 4, 2024
4b51139
Update src/Nethermind/Nethermind.Consensus/Processing/RecoverSignatur…
ak88 Oct 4, 2024
9f01cf2
review changes
ak88 Oct 4, 2024
0800ee3
use existing nulltxpool
ak88 Oct 4, 2024
7b51ea1
format
ak88 Oct 4, 2024
03db79c
cosmetic
ak88 Oct 4, 2024
86d8135
add flat encoding and requests as a side car
rjnrohit Oct 5, 2024
0d3aabe
Merge branch 'prague/devnet4' into flat_requests
rjnrohit Oct 5, 2024
28577ad
fix build error
rjnrohit Oct 5, 2024
f417572
fix more build error
rjnrohit Oct 5, 2024
ab9ca8e
more build errors
rjnrohit Oct 5, 2024
e085509
more build errors
rjnrohit Oct 5, 2024
aeba2a9
add requests to executionPayloadParams
rjnrohit Oct 5, 2024
db27172
ensure requests are in sorted order
rjnrohit Oct 5, 2024
8120251
add executionRequests processor tests
rjnrohit Oct 6, 2024
f97aa5a
make executionRequests optional
rjnrohit Oct 6, 2024
fafb812
fix test errors
rjnrohit Oct 7, 2024
26cb98e
format files
rjnrohit Oct 7, 2024
e2bfb69
remove Build.Deposit.cs
rjnrohit Oct 7, 2024
5bd226a
remove Build.WithdrawalRequest.cs
rjnrohit Oct 7, 2024
9ab33a1
requestsRoot -> requestsHash
rjnrohit Oct 7, 2024
23cba3c
remove test from block validator
rjnrohit Oct 7, 2024
47d94d4
remove undef ref
rjnrohit Oct 7, 2024
c92705d
fix cast error
rjnrohit Oct 7, 2024
5636cda
fix test build error
rjnrohit Oct 8, 2024
d2c0473
fix requests in Aura Test
rjnrohit Oct 8, 2024
f97a524
fix hash scheme
rjnrohit Oct 8, 2024
548ad77
Update root calculation
rjnrohit Oct 9, 2024
1c72a4e
move requestHash calc
rjnrohit Oct 9, 2024
b04c9f9
fix consensus test
rjnrohit Oct 9, 2024
465cbdf
fix ci tests
rjnrohit Oct 9, 2024
4e01f92
format files
rjnrohit Oct 9, 2024
c9cd867
remove signature changes
rjnrohit Oct 9, 2024
a87a144
optimise executionRequestProcessor
rjnrohit Oct 9, 2024
ac01e83
spec changes for 7702
ak88 Oct 10, 2024
41f86e3
Fix EXTCODEHASH for dead accounts
ak88 Oct 11, 2024
9b4267d
Merge branch 'master' into feature/7702-devnet-4
ak88 Oct 11, 2024
033dc7d
readd sig check after spec change
ak88 Oct 11, 2024
91e1c8f
fix test
ak88 Oct 11, 2024
54179bf
Change v in spec test
ak88 Oct 11, 2024
937ac55
Tuple decoder test for invalid field sizes
ak88 Oct 11, 2024
5bd0edf
address few comments
rjnrohit Oct 15, 2024
dc6dfec
Merge branch 'pectra_devnet_4' into prague/devnet4
rjnrohit Oct 15, 2024
0f29bbf
Merge branch 'prague/devnet4' into flat_requests
rjnrohit Oct 15, 2024
bb41884
fix address error
rjnrohit Oct 15, 2024
da380db
optimise alocations
rjnrohit Oct 15, 2024
226d904
optimize further
rjnrohit Oct 16, 2024
ad3698b
format files
rjnrohit Oct 16, 2024
76b3ff5
Add flat encoding and requests as a side car (#7608)
rjnrohit Oct 17, 2024
7a6885b
fix requestsHash calculation
rjnrohit Oct 17, 2024
a35445d
fix conflicts
rjnrohit Oct 17, 2024
59a2be2
fix test errors
rjnrohit Oct 17, 2024
15fe241
explicit prague tests
rjnrohit Oct 17, 2024
984bc07
format files
rjnrohit Oct 17, 2024
e854467
fix aura tests
rjnrohit Oct 17, 2024
215df80
format files
rjnrohit Oct 17, 2024
4a98a09
Merge branch 'master' into pectra_devnet_4
rjnrohit Oct 17, 2024
627207d
Merge branch 'pectra_devnet_4' into flat_requests
rjnrohit Oct 17, 2024
0c3dc33
7702 fix
ak88 Oct 17, 2024
855e354
Merge branch 'feature/7702-devnet-4' into pectra_devnet_4
MarekM25 Oct 17, 2024
58b5541
Merge branch 'master' into pectra_devnet_4
MarekM25 Oct 17, 2024
5eacd18
update addresses
MarekM25 Oct 17, 2024
d96af86
update executionRequestProcessor
rjnrohit Oct 17, 2024
141b961
Merge branch 'flat_requests' into pectra_devnet_4
rjnrohit Oct 17, 2024
70a5cce
format files
rjnrohit Oct 17, 2024
18b298c
fix hash calc
rjnrohit Oct 17, 2024
430f1b3
remove explicit
rjnrohit Oct 17, 2024
e3974bf
fixes for 7702
ak88 Oct 17, 2024
ca25cc8
revert test change
ak88 Oct 17, 2024
a8038c8
real fixes for tests + one missing TxValidator.cs fix
smartprogrammer93 Oct 17, 2024
1e410a3
revert load test strategy
ak88 Oct 17, 2024
5e3def2
format
ak88 Oct 17, 2024
c3827bc
fix test
ak88 Oct 17, 2024
0f9ce85
refactor sig check
ak88 Oct 22, 2024
dc660b4
Update src/Nethermind/Nethermind.Blockchain.Test/Validators/TxValidat…
ak88 Oct 23, 2024
df46327
fix chain spec loader
rjnrohit Oct 23, 2024
413917b
Merge branch 'master' into pectra_devnet_4
rjnrohit Oct 23, 2024
cffdcd2
address ak comments
rjnrohit Oct 23, 2024
35cdbb1
format files
rjnrohit Oct 23, 2024
480957a
make prague tests explicit
rjnrohit Oct 23, 2024
84e114c
Merge branch 'master' into pectra_devnet_4
rjnrohit Oct 24, 2024
3d2e6b7
add HeaderValidator tests
rjnrohit Oct 24, 2024
24ffe2f
Merge branch 'master' into pectra_devnet_4
rjnrohit Oct 24, 2024
1a6b6d9
fix invalid executionRequest error
rjnrohit Oct 24, 2024
b36b847
Merge branch 'master' into pectra_devnet_4
rjnrohit Oct 25, 2024
8a02510
fix build error
rjnrohit Oct 25, 2024
0f7468b
fix test case error
rjnrohit Oct 25, 2024
c0bb82c
Merge branch 'master' into pectra_devnet_4
rjnrohit Oct 28, 2024
24673f2
Merge branch 'master' into flat_encoding_requests
rjnrohit Oct 28, 2024
4b5d90d
Merge branch 'master' into flat_encoding_requests
rjnrohit Oct 30, 2024
234936b
address PR comments
rjnrohit Nov 5, 2024
8d62fcb
Merge branch 'master' into flat_encoding_requests
rjnrohit Nov 5, 2024
45340e7
fix errors
rjnrohit Nov 5, 2024
c31274e
fix some more error
rjnrohit Nov 5, 2024
bdae7e0
fix consensus test
rjnrohit Nov 5, 2024
d6caf82
fix errors
rjnrohit Nov 5, 2024
073f929
format files
rjnrohit Nov 5, 2024
b00ccdc
make prague tests explicit
rjnrohit Nov 5, 2024
83f2e11
Merge branch 'master' into flat_encoding_requests
rjnrohit Nov 5, 2024
3a5da76
some refactors
LukaszRozmej Nov 5, 2024
236cb2d
more refactors
LukaszRozmej Nov 5, 2024
84cc68c
test refactor
LukaszRozmej Nov 5, 2024
843bf5f
more refactor
LukaszRozmej Nov 5, 2024
3be860f
Merge branch 'master' into flat_encoding_requests
LukaszRozmej Nov 5, 2024
b9d598c
Merge branch 'master' into flat_encoding_requests
rjnrohit Nov 5, 2024
898e4f7
Merge branch 'master' into flat_encoding_requests
rjnrohit Nov 5, 2024
348c4ea
address PR comments
rjnrohit Nov 6, 2024
4633e9d
format files
rjnrohit Nov 6, 2024
7e827cd
Merge branch 'master' into flat_encoding_requests
rjnrohit Nov 6, 2024
ab2937c
Small refactor for Bytes (#7729)
ak88 Nov 6, 2024
8603336
Merge branch 'master' into flat_encoding_requests
rjnrohit Nov 6, 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
2 changes: 1 addition & 1 deletion src/Nethermind/Ethereum.Test.Base/GeneralStateTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public class GeneralStateTest : IEthereumTest
public UInt256? ParentBlobGasUsed { get; set; }
public UInt256? ParentExcessBlobGas { get; set; }

public Hash256? RequestsRoot { get; set; }
public Hash256? RequestsHash { get; set; }

public override string ToString()
{
Expand Down
2 changes: 1 addition & 1 deletion src/Nethermind/Ethereum.Test.Base/GeneralTestBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ protected EthereumTestResult RunTest(GeneralStateTest test, ITxTracer txTracer)
header.ParentBeaconBlockRoot = test.CurrentBeaconRoot;
header.ExcessBlobGas = test.CurrentExcessBlobGas ?? (test.Fork is Cancun ? 0ul : null);
header.BlobGasUsed = BlobGasCalculator.CalculateBlobGas(test.Transaction);
header.RequestsRoot = test.RequestsRoot;
header.RequestsHash = test.RequestsHash;

Stopwatch stopwatch = Stopwatch.StartNew();
IReleaseSpec? spec = specProvider.GetSpec((ForkActivation)test.CurrentNumber);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
// SPDX-License-Identifier: LGPL-3.0-only

using Nethermind.Consensus.Validators;
using Nethermind.Core.ConsensusRequests;
using Nethermind.Core;
using Nethermind.Core.Crypto;
using Nethermind.Core.Specs;
Expand Down Expand Up @@ -199,51 +198,4 @@ public void ValidateSuggestedBlock_SuggestedBlockIsInvalid_CorrectErrorIsSet(Blo

Assert.That(error, Does.StartWith(expectedError));
}

[Test]
public void ValidateBodyAgainstHeader_BlockHasInvalidRequestRoot_ReturnsFalse()
{
Block block = Build.A.Block
.WithConsensusRequests(new ConsensusRequest[] {
Build.A.Deposit.WithIndex(0).TestObject,
Build.A.WithdrawalRequest.TestObject
})
.TestObject;
block.Header.RequestsRoot = Keccak.OfAnEmptyString;

Assert.That(
BlockValidator.ValidateBodyAgainstHeader(block.Header, block.Body),
Is.False);
}

[Test]
public void ValidateBodyRequests_BlockHasReuests_InOrder_ReturnsTrue()
{
Block block = Build.A.Block
.WithConsensusRequests(new ConsensusRequest[] {
Build.A.Deposit.WithIndex(0).TestObject,
Build.A.WithdrawalRequest.TestObject
})
.TestObject;

Assert.That(
BlockValidator.ValidateRequestsOrder(block, out string? _),
Is.True);
}

[Test]
public void ValidateBodyRequests_BlockHasReuests_OutOfOrder_ReturnsFalse()
{
Block block = Build.A.Block
.WithConsensusRequests(new ConsensusRequest[] {
Build.A.WithdrawalRequest.TestObject,
Build.A.Deposit.WithIndex(0).TestObject
})
.TestObject;

Assert.That(
BlockValidator.ValidateRequestsOrder(block, out string? _),
Is.False);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
using Nethermind.Blockchain.Find;
using Nethermind.Blockchain.Receipts;
using Nethermind.Consensus.AuRa.Validators;
using Nethermind.Consensus.ExecutionRequests;
using Nethermind.Consensus.Processing;
using Nethermind.Consensus.Requests;
using Nethermind.Consensus.Rewards;
using Nethermind.Consensus.Transactions;
using Nethermind.Consensus.Validators;
Expand Down Expand Up @@ -51,7 +51,7 @@ public AuRaBlockProcessor(
AuRaContractGasLimitOverride? gasLimitOverride = null,
ContractRewriter? contractRewriter = null,
IBlockCachePreWarmer? preWarmer = null,
IConsensusRequestsProcessor? consensusRequestsProcessor = null)
IExecutionRequestsProcessor? executionRequestsProcessor = null)
: base(
specProvider,
blockValidator,
Expand All @@ -65,7 +65,7 @@ public AuRaBlockProcessor(
logManager,
withdrawalProcessor,
preWarmer: preWarmer,
consensusRequestsProcessor: consensusRequestsProcessor)
executionRequestsProcessor: executionRequestsProcessor)
{
_specProvider = specProvider;
_blockTree = blockTree ?? throw new ArgumentNullException(nameof(blockTree));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
using Nethermind.Consensus.Producers;
using Nethermind.Consensus.Transactions;
using Nethermind.Core;
using Nethermind.Core.ConsensusRequests;
using Nethermind.Core.Crypto;
using Nethermind.Core.Specs;
using Nethermind.Crypto;
Expand Down Expand Up @@ -500,8 +499,7 @@ ILogManager logManager
header,
selectedTxs,
Array.Empty<BlockHeader>(),
spec.WithdrawalsEnabled ? Enumerable.Empty<Withdrawal>() : null,
spec.RequestsEnabled ? Enumerable.Empty<ConsensusRequest>() : null
spec.WithdrawalsEnabled ? Enumerable.Empty<Withdrawal>() : null
);
header.TxRoot = TxTrie.CalculateRoot(block.Transactions);
block.Header.Author = _sealer.Address;
Expand Down
70 changes: 0 additions & 70 deletions src/Nethermind/Nethermind.Consensus.Test/DepositProcessorTests.cs

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,151 @@
// SPDX-FileCopyrightText: 2024 Demerzel Solutions Limited
// SPDX-License-Identifier: LGPL-3.0-only

using System;
using System.Linq;
using Nethermind.Abi;
using Nethermind.Consensus.ExecutionRequests;
using Nethermind.Core;
using Nethermind.Core.Collections;
using Nethermind.Core.Crypto;
using Nethermind.Core.ExecutionRequest;
using Nethermind.Core.Extensions;
using Nethermind.Core.Specs;
using Nethermind.Core.Test.Builders;
using Nethermind.Db;
using Nethermind.Evm;
using Nethermind.Evm.Tracing;
using Nethermind.Evm.TransactionProcessing;
using Nethermind.Int256;
using Nethermind.Logging;
using Nethermind.Specs;
using Nethermind.State;
using Nethermind.Trie.Pruning;
using NSubstitute;
using NUnit.Framework;

namespace Nethermind.Consensus.Test;

public class ExecutionProcessorTests
{
private ISpecProvider _specProvider;
private ITransactionProcessor _transactionProcessor;
private WorldState _stateProvider;
private static readonly UInt256 AccountBalance = 1.Ether();
private readonly Address DepositContractAddress = Eip6110Constants.MainnetDepositContractAddress;
private readonly Address eip7002Account = Eip7002Constants.WithdrawalRequestPredeployAddress;
private readonly Address eip7251Account = Eip7251Constants.ConsolidationRequestPredeployAddress;
private IReleaseSpec spec;
private readonly AbiSignature _depositEventABI = new("DepositEvent", AbiType.DynamicBytes, AbiType.DynamicBytes, AbiType.DynamicBytes, AbiType.DynamicBytes, AbiType.DynamicBytes);
private readonly AbiEncoder _abiEncoder = AbiEncoder.Instance;

ExecutionRequest[] executionDepositRequests = [TestItem.ExecutionRequestA, TestItem.ExecutionRequestB, TestItem.ExecutionRequestC];
ExecutionRequest[] executionWithdrawalRequests = [TestItem.ExecutionRequestD, TestItem.ExecutionRequestE, TestItem.ExecutionRequestF];
ExecutionRequest[] executionConsolidationRequests = [TestItem.ExecutionRequestG, TestItem.ExecutionRequestH, TestItem.ExecutionRequestI];

private void FlatEncodeWithoutType(ExecutionRequest[] requests, Span<byte> buffer)
{
int currentPosition = 0;

foreach (ExecutionRequest request in requests)
{
// Ensure the buffer has enough space to accommodate the new data
if (currentPosition + request.RequestData!.Length > buffer.Length)
{
throw new InvalidOperationException("Buffer is not large enough to hold all data of requests");
}

// Copy the RequestData to the buffer at the current position
request.RequestData.CopyTo(buffer.Slice(currentPosition, request.RequestData.Length));
currentPosition += request.RequestData.Length;
}
}

[SetUp]
public void Setup()
{
_specProvider = MainnetSpecProvider.Instance;
MemDb stateDb = new();
TrieStore trieStore = new(stateDb, LimboLogs.Instance);

_stateProvider = new WorldState(trieStore, new MemDb(), LimboLogs.Instance);
_stateProvider.CreateAccount(eip7002Account, AccountBalance);
_stateProvider.CreateAccount(eip7251Account, AccountBalance);
_stateProvider.Commit(_specProvider.GenesisSpec);
_stateProvider.CommitTree(0);

spec = Substitute.For<IReleaseSpec>();

spec.RequestsEnabled.Returns(true);
spec.DepositsEnabled.Returns(true);
spec.WithdrawalRequestsEnabled.Returns(true);
spec.ConsolidationRequestsEnabled.Returns(true);

spec.DepositContractAddress.Returns(DepositContractAddress);
spec.Eip7002ContractAddress.Returns(eip7002Account);
spec.Eip7251ContractAddress.Returns(eip7251Account);

_transactionProcessor = Substitute.For<ITransactionProcessor>();

_transactionProcessor.Execute(Arg.Any<Transaction>(), Arg.Any<BlockExecutionContext>(), Arg.Any<CallOutputTracer>())
.Returns(ci =>
{
Transaction transaction = ci.Arg<Transaction>();
CallOutputTracer tracer = ci.Arg<CallOutputTracer>();
if (transaction.To == eip7002Account)
{
Span<byte> buffer = new byte[executionWithdrawalRequests.GetRequestsByteSize()];
FlatEncodeWithoutType(executionWithdrawalRequests, buffer);
tracer.ReturnValue = buffer.ToArray();
}
else if (transaction.To == eip7251Account)
{
Span<byte> buffer = new byte[executionConsolidationRequests.GetRequestsByteSize()];
FlatEncodeWithoutType(executionConsolidationRequests, buffer);
tracer.ReturnValue = buffer.ToArray();
}
else
{
tracer.ReturnValue = Array.Empty<byte>();
}
return new TransactionResult();
});
}


public static Hash256 CalculateHash(
ExecutionRequest[] depositRequests,
ExecutionRequest[] withdrawalRequests,
ExecutionRequest[] consolidationRequests
)
{
using ArrayPoolList<byte[]> requests = ExecutionRequestExtensions.GetFlatEncodedRequests(depositRequests, withdrawalRequests, consolidationRequests);
return ExecutionRequestExtensions.CalculateHashFromFlatEncodedRequests(requests.ToArray());
}

[Test]
public void ShouldProcessExecutionRequests()
{
Block block = Build.A.Block.TestObject;
ExecutionRequestsProcessor executionRequestsProcessor = new(_transactionProcessor);

TxReceipt[] txReceipts = [
Build.A.Receipt.WithLogs(
Build.A.LogEntry.WithData(
_abiEncoder.Encode(AbiEncodingStyle.None, _depositEventABI, [TestItem.PublicKeyA.Bytes.Slice(0, 48), TestItem.KeccakA.Bytes.ToArray(), BitConverter.GetBytes((ulong)1_000_000_000), TestItem.SignatureBytes, BitConverter.GetBytes((ulong)1)])
).WithAddress(DepositContractAddress).TestObject,
Build.A.LogEntry.WithData(
_abiEncoder.Encode(AbiEncodingStyle.None, _depositEventABI, [TestItem.PublicKeyB.Bytes.Slice(0, 48), TestItem.KeccakB.Bytes.ToArray(), BitConverter.GetBytes((ulong)2_000_000_000), TestItem.SignatureBytes, BitConverter.GetBytes((ulong)2)])
).WithAddress(DepositContractAddress).TestObject,
Build.A.LogEntry.WithData(
_abiEncoder.Encode(AbiEncodingStyle.None, _depositEventABI, [TestItem.PublicKeyC.Bytes.Slice(0, 48), TestItem.KeccakC.Bytes.ToArray(), BitConverter.GetBytes((ulong)3_000_000_000), TestItem.SignatureBytes, BitConverter.GetBytes((ulong)3)])
).WithAddress(DepositContractAddress).TestObject
LukaszRozmej marked this conversation as resolved.
Show resolved Hide resolved
).TestObject
];
executionRequestsProcessor.ProcessExecutionRequests(block, _stateProvider, txReceipts, spec);

Assert.That(block.Header.RequestsHash, Is.EqualTo(
CalculateHash(executionDepositRequests, executionWithdrawalRequests, executionConsolidationRequests)
));
}
}
Loading
Loading