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

Implement beacon chain push withdrawals (EIP-4895) #4731

Merged
merged 289 commits into from
Jan 11, 2023
Merged
Show file tree
Hide file tree
Changes from 21 commits
Commits
Show all changes
289 commits
Select commit Hold shift + click to select a range
f364bae
More test fixes
smartprogrammer93 Nov 2, 2022
92f8394
Merge branch 'master' into fix/forkId_calculation_is_wrong_after_time…
smartprogrammer93 Nov 2, 2022
b5f9883
Fix for init and meter
smartprogrammer93 Nov 2, 2022
b288926
Merge branch 'master' into feature/shanghai-eip-4895-withdrawals
MarekM25 Oct 28, 2022
9781b77
Make withdrawals decoding optional
rubo Oct 30, 2022
7b4d460
include 4895 in chainspecParameters
MarekM25 Oct 31, 2022
c793652
introduce WithdrawalTimestamp
MarekM25 Oct 31, 2022
a783b04
Fix `PayloadAttributes` handling when null
rubo Oct 31, 2022
6c7d34f
Fix withdrawals length calculation
rubo Oct 31, 2022
4207577
Refactor and add checks for withdrawals for RPC methods of v1
rubo Oct 31, 2022
1f1a08f
Add engine_getPayloadV2
rubo Oct 31, 2022
5275510
Format whitespaces
rubo Oct 31, 2022
ba0219b
Refactor and remove redundant "V1"
rubo Oct 31, 2022
3d09efa
started adding Enginge V2 tests - V2_processing_block_should_serializ…
MarekM25 Nov 1, 2022
10dcda2
formatting
MarekM25 Nov 1, 2022
94c17cb
formatting
MarekM25 Nov 1, 2022
45aae0a
Implement withdrawal root validation
rubo Nov 2, 2022
6cc1089
working on tests and fixes
MarekM25 Nov 2, 2022
86e8f72
Merge branch 'feature/shanghai-eip-4895-withdrawals' of https://githu…
MarekM25 Nov 2, 2022
2a724f9
fix block for processing
MarekM25 Nov 2, 2022
56f0774
BlockValidator WithdrawalRoot
MarekM25 Nov 2, 2022
1224c48
Fix withdrawal trie proof validation
rubo Nov 2, 2022
135b9f9
add WithdrawalApplier
MarekM25 Nov 2, 2022
473cd20
Merge branch 'feature/shanghai-eip-4895-withdrawals' of https://githu…
MarekM25 Nov 2, 2022
f3be3ea
Remove redundant withdrawals hash check
rubo Nov 2, 2022
ec2f25d
Remove withdrawal check for null
rubo Nov 2, 2022
b00b594
Add withdrawals test chain spec
rubo Nov 2, 2022
a43ca6d
Reformat whitespaces
rubo Nov 2, 2022
6fd2c3d
add withdrawalApplier to blockchainProcessor
MarekM25 Nov 3, 2022
c0adc96
Merge branch 'feature/shanghai-eip-4895-withdrawals' of https://githu…
MarekM25 Nov 3, 2022
cd18844
add withdrawals to ExecutionPayload
MarekM25 Nov 3, 2022
d9e2a08
test fixes
MarekM25 Nov 3, 2022
ea9ff25
fix EVM.test
MarekM25 Nov 3, 2022
78a06d4
fix EthereumTests
MarekM25 Nov 3, 2022
117225f
fix Benchmarks.sln
MarekM25 Nov 3, 2022
37f703c
Revise withdrawals representation according to the spec and refactor
rubo Nov 3, 2022
176fb16
Rename `IWithdrawalApplier` to `IWithdrawalProcessor`
rubo Nov 3, 2022
0279db6
Add tests for withdrawal encoding/decoding
rubo Nov 3, 2022
8751876
Rename `Recipient` to `Address`
rubo Nov 3, 2022
b49a1df
Reformat whitespaces
rubo Nov 3, 2022
d05c009
Revise withdrawals length calculation in block encoding
rubo Nov 3, 2022
f05fd1e
HasBody?
MarekM25 Nov 4, 2022
7ecaef2
Remove redundant withdrawals hash check
rubo Nov 2, 2022
a45ded2
fix withdrawals_test chainspec && added IReleaseSpec.WithdrawalsEnabled
MarekM25 Nov 7, 2022
e16253e
Fixes
smartprogrammer93 Nov 7, 2022
3d49cfe
Merge master
smartprogrammer93 Nov 7, 2022
feb997e
fix GenesisLoader
MarekM25 Nov 8, 2022
a29598f
Merge branch 'fix/forkId_calculation_is_wrong_after_timestamp_activat…
MarekM25 Nov 8, 2022
3794a14
fix extra-data
MarekM25 Nov 8, 2022
e2c0e98
Refactor withdrawal validation by implementing `IWithdrawalValidator`
rubo Nov 8, 2022
e35ca06
Fix failing tests
rubo Nov 8, 2022
f989fce
Merge branch 'master' into feature/shanghai-eip-4895-withdrawals
rubo Nov 8, 2022
1e64cc8
Reformat whitespaces
rubo Nov 8, 2022
1009366
Merge Master
smartprogrammer93 Nov 8, 2022
7314dd5
Merge branch 'master' into feature/shanghai-eip-4895-withdrawals
rubo Nov 9, 2022
d89d2ba
fix withdrawalsTimestamp
MarekM25 Nov 10, 2022
73ad787
Merge branch 'feature/shanghai-eip-4895-withdrawals' of https://githu…
MarekM25 Nov 10, 2022
a3824f7
temporary change validation
MarekM25 Nov 10, 2022
951fe85
null handling?
MarekM25 Nov 10, 2022
88108cf
Merging latest fix from forkId Calculation
smartprogrammer93 Nov 10, 2022
ddc75a5
Merge branch 'master' into feature/shanghai-eip-4895-withdrawals
rubo Nov 11, 2022
54b28d2
Merge branch 'master' into fix/forkId_calculation_is_wrong_after_time…
smartprogrammer93 Nov 15, 2022
c57cc7d
Applying Marek's suggestion. Not sure about this one
smartprogrammer93 Nov 15, 2022
e90256e
Fix Ethereum tests
smartprogrammer93 Nov 15, 2022
500185a
Fix test cases
smartprogrammer93 Nov 15, 2022
d821522
Fix benchmark build
smartprogrammer93 Nov 15, 2022
f3cb918
Merge branch 'master' into feature/shanghai-eip-4895-withdrawals
rubo Nov 15, 2022
0807e34
Fix payload attributes validation
rubo Nov 15, 2022
87b2721
Remove "V1" from `IForkchoiceUpdatedHandler` name
rubo Nov 15, 2022
b4b9eac
Update tests
rubo Nov 15, 2022
781a11f
hack AuRa tests for now
MarekM25 Nov 16, 2022
a11b424
fix more tests
MarekM25 Nov 16, 2022
01fbe57
Merge branch 'fix/forkId_calculation_is_wrong_after_timestamp_activat…
MarekM25 Nov 16, 2022
33c92d7
fix more tests
MarekM25 Nov 16, 2022
6fbc10d
fix build
MarekM25 Nov 16, 2022
8689463
+ fix one more tests
MarekM25 Nov 16, 2022
cf5a4a2
fix Synchronization tests
MarekM25 Nov 16, 2022
2e5d09c
Merge branch 'master' into feature/shanghai-eip-4895-withdrawals
MarekM25 Nov 16, 2022
9b8766c
Update tests to 0aa59689101f64cab8fa1526d9cf6e647ddba946
rubo Nov 16, 2022
276225d
fixed withdrawal chainspec
MarekM25 Nov 17, 2022
48cb901
withdrawals block validator tests
MarekM25 Nov 17, 2022
7fa3505
Implement Engine API tests
rubo Nov 17, 2022
46e62c8
Reformat code
rubo Nov 17, 2022
0919807
Merge branch 'master' into feature/shanghai-eip-4895-withdrawals
rubo Nov 17, 2022
30acb11
fix chainspec?
MarekM25 Nov 18, 2022
d280ddb
Merge branch 'feature/shanghai-eip-4895-withdrawals' of https://githu…
MarekM25 Nov 18, 2022
786b42c
Fix withdrawals decoding
rubo Nov 18, 2022
497581a
fix chainspec timestamp
MarekM25 Nov 18, 2022
a535927
Merge branch 'feature/shanghai-eip-4895-withdrawals' of https://githu…
MarekM25 Nov 18, 2022
e25eaf6
Add and fix Engine API tests
rubo Nov 18, 2022
4936691
Revise block decoder tests
rubo Nov 21, 2022
c1d98c5
Merge branch 'master' into feature/shanghai-eip-4895-withdrawals
rubo Nov 21, 2022
efc5e78
Revise file headers
rubo Nov 21, 2022
6736c0c
Revise file headers
rubo Nov 21, 2022
ab7c76e
Add missing file headers
rubo Nov 21, 2022
c4e398a
Merge branch 'feature/shanghai-eip-4895-withdrawals' of https://githu…
MarekM25 Nov 22, 2022
ec25ab6
fix AuRa test
MarekM25 Nov 22, 2022
5116555
adjusting comments
MarekM25 Nov 22, 2022
102535b
load genesis tests
MarekM25 Nov 22, 2022
d67ad62
Merge branch 'master' into feature/shanghai-eip-4895-withdrawals
rubo Nov 22, 2022
6ea17ce
Merge branch 'master' into fix/forkId_calculation_is_wrong_after_time…
smartprogrammer93 Nov 22, 2022
9465532
Lukasz suggestions
smartprogrammer93 Nov 22, 2022
aad391a
formating
smartprogrammer93 Nov 22, 2022
a6f34d2
Fix build
smartprogrammer93 Nov 22, 2022
c7d3087
withdrawals_hivetests.json + cosmetic
MarekM25 Nov 23, 2022
620981a
Add more unit tests
smartprogrammer93 Nov 23, 2022
1a35206
spacing
smartprogrammer93 Nov 23, 2022
a16cd0b
Try on fixing timestamp activation with same value as genesis timestamp
smartprogrammer93 Nov 23, 2022
f99bdec
Merge Master
smartprogrammer93 Nov 23, 2022
a891746
Fix gnosis and chiado ForkId Calculations
smartprogrammer93 Nov 23, 2022
22e3f37
Merge branch 'fix/forkId_calculation_is_wrong_after_timestamp_activat…
MarekM25 Nov 23, 2022
efa1329
fix tests
MarekM25 Nov 23, 2022
5d31d9e
Cleanup and more tests
smartprogrammer93 Nov 23, 2022
d75143d
Janky but working solution to very rare edge case?
smartprogrammer93 Nov 23, 2022
115d4d2
Fix flakiness of caused by Parallelizable
smartprogrammer93 Nov 23, 2022
b8dfefb
adding engine tests
MarekM25 Nov 24, 2022
bffad26
working on more tests
MarekM25 Nov 24, 2022
edf75cd
add loop in test
MarekM25 Nov 24, 2022
fe77f93
Can_apply_withdrawals_correctly test
MarekM25 Nov 24, 2022
c0c6e7c
more test cases
MarekM25 Nov 24, 2022
f13347e
Merge branch 'master' into feature/shanghai-eip-4895-withdrawals
rubo Nov 24, 2022
dc730aa
Update withdrawals hive tests configuration
rubo Nov 24, 2022
f1a9b18
Refactor and fix some null reference warnings
rubo Nov 24, 2022
13d3115
Expose withdrawals to JSON-RPC modules
rubo Nov 24, 2022
dbf6994
Fix broken tests
rubo Nov 24, 2022
803a9f5
Revise `ForkchoiceUpdatedHandler` string output
rubo Nov 24, 2022
189a02f
fix Can_apply_withdrawals_correctly
MarekM25 Nov 25, 2022
b805fde
Merge branch 'feature/shanghai-eip-4895-withdrawals' of https://githu…
MarekM25 Nov 25, 2022
a258284
fix whitespaces
MarekM25 Nov 25, 2022
9fe7a0b
fix whitespaces
MarekM25 Nov 25, 2022
47f49a3
more whitespaces fixes
MarekM25 Nov 25, 2022
5c63f4a
work on Withdrawals_transition test cases
MarekM25 Nov 28, 2022
abcab04
adjust CustomSpecProvider
MarekM25 Nov 28, 2022
4775775
Introduce IEip1995Spec
smartprogrammer93 Nov 28, 2022
0dbdec0
Merge branch 'fix/forkId_calculation_is_wrong_after_timestamp_activat…
smartprogrammer93 Nov 28, 2022
9a252d7
Merge branch 'master' into feature/shanghai-eip-4895-withdrawals
rubo Nov 28, 2022
a67f7d9
Merge branch 'fix/forkId_calculation_is_wrong_after_timestamp_activat…
MarekM25 Nov 28, 2022
94262c6
small changes in tests
MarekM25 Nov 29, 2022
0326564
Fix license
smartprogrammer93 Nov 29, 2022
26190a4
add comments
smartprogrammer93 Nov 29, 2022
d9c39e1
Apply Marek Suggestion
smartprogrammer93 Nov 29, 2022
1dd876a
Adjust Lic to Rubo
smartprogrammer93 Nov 29, 2022
a7bc607
Marek Suggestions
smartprogrammer93 Nov 29, 2022
b5aaff9
Fix
smartprogrammer93 Nov 29, 2022
c91da93
fix withdrawals in ChainLevelHelper
MarekM25 Nov 29, 2022
a40bfa7
Merge branch 'master' into fix/forkId_calculation_is_wrong_after_time…
smartprogrammer93 Nov 29, 2022
da1262e
fix hive sync tests
MarekM25 Nov 30, 2022
e1ae154
fix?
MarekM25 Nov 30, 2022
a5631de
Revise withdrawals root hash encoding/decoding and its tests
rubo Dec 1, 2022
494aaa1
Merge branch 'master' into feature/shanghai-eip-4895-withdrawals
rubo Dec 1, 2022
a33abb8
fix PayloadAttributes ToString
MarekM25 Dec 2, 2022
4caf2bc
add more temp logs to investigate hive tests
MarekM25 Dec 2, 2022
60a10bc
more logs
MarekM25 Dec 2, 2022
50a38a0
revert not needed logs
MarekM25 Dec 2, 2022
c1a8f78
fix test
MarekM25 Dec 2, 2022
661c50d
ignore incorrect tests
MarekM25 Dec 2, 2022
8f73c7e
Fix tests broken by withdrawals decoding revision
rubo Dec 5, 2022
c33b706
Merge branch 'master' into feature/shanghai-eip-4895-withdrawals
rubo Dec 7, 2022
5f97f90
Revise file headers
rubo Dec 7, 2022
c91193b
Final appraoch, removed GetSpec complexity
smartprogrammer93 Dec 7, 2022
85676fe
Forgotten changes
smartprogrammer93 Dec 7, 2022
9bfb991
Merge Master
smartprogrammer93 Dec 7, 2022
3bac96d
SecondsPerSlot to BlocksConfig
smartprogrammer93 Nov 29, 2022
78a9912
Minor + config changes
smartprogrammer93 Nov 29, 2022
1a454ba
Typo fix
smartprogrammer93 Dec 6, 2022
ebc1808
remove empty line
smartprogrammer93 Dec 7, 2022
1c41c4b
Move BlocksConfig to Nethermind.Config project
smartprogrammer93 Dec 7, 2022
4c86a4f
Benchmark build fix
smartprogrammer93 Dec 7, 2022
4847b22
Merge branch 'master' into feature/shanghai-eip-4895-withdrawals
rubo Dec 8, 2022
4fab706
Rename `ExecutionPayloadV1` to `ExecutionPayloadV2`
rubo Dec 8, 2022
e55177a
Merge branch 'master' into feature/shanghai-eip-4895-withdrawals
rubo Dec 11, 2022
9183250
Revise withdrawals check
rubo Dec 12, 2022
452b004
Refactor tests
rubo Dec 12, 2022
59743f1
Optimize withdrawals root hash decoding in block header
rubo Dec 12, 2022
82f9afa
Merge branch 'master' into feature/shanghai-eip-4895-withdrawals
rubo Dec 13, 2022
32e48f0
Implements ForkId tests that are ub EIP-6122
smartprogrammer93 Dec 13, 2022
6561ac3
Spacing
smartprogrammer93 Dec 13, 2022
e0e0960
Merge branch 'master' into fix/forkId_calculation_is_wrong_after_time…
smartprogrammer93 Dec 14, 2022
6fc2e92
Merge branch 'master' into fix/forkId_calculation_is_wrong_after_time…
smartprogrammer93 Dec 14, 2022
c5159b2
Fix build
smartprogrammer93 Dec 14, 2022
fe4b020
Fix ForkId Test case
smartprogrammer93 Dec 14, 2022
93ceb9c
Merge branch 'master' into fix/forkId_calculation_is_wrong_after_time…
smartprogrammer93 Dec 14, 2022
7869fd0
Removing 3675 and using MergeForkId Transition
smartprogrammer93 Dec 14, 2022
c931c3f
Final test fix
smartprogrammer93 Dec 14, 2022
35d7f10
Merge branch 'master' into feature/shanghai-eip-4895-withdrawals
rubo Dec 14, 2022
7f7f837
Fix tests
rubo Dec 14, 2022
4a7de80
Rename `ExecutionPayloadV2` to `ExecutionPayload`
rubo Dec 15, 2022
5a8abd0
Merge branch 'master' into feature/shanghai-eip-4895-withdrawals
rubo Dec 15, 2022
6084fe9
Merge branch 'master' into feature/shanghai-eip-4895-withdrawals
rubo Dec 16, 2022
d695f4e
add one more line in Nlog (temp)
MarekM25 Dec 19, 2022
75b9186
Revert NLog for jsonRpc
MarekM25 Dec 20, 2022
ec63830
fix missing body?
MarekM25 Dec 22, 2022
095b5de
adjust TxPool logs
MarekM25 Dec 22, 2022
b24a24d
Merge branch 'fix/slotTime_to_be_in_init_config_instead_of_merge' int…
MarekM25 Dec 22, 2022
751eded
Merge branch 'master' into feature/shanghai-eip-4895-withdrawals
rubo Dec 22, 2022
77e0ad0
Add more test cases for `BlockBodiesMessageSerializer`
rubo Dec 22, 2022
00db474
Add tests for `BlockHeader.HasBody`
rubo Dec 22, 2022
ea6aa43
Revise `null` handling for `BlockHeader.HasBody`
rubo Dec 22, 2022
3823f88
fix BlockBody empty
MarekM25 Dec 23, 2022
f5cf45a
Merge branch 'feature/shanghai-eip-4895-withdrawals' of https://githu…
MarekM25 Dec 23, 2022
0363da5
Merge Tracking Branch
smartprogrammer93 Dec 28, 2022
cb2469d
Merge Tracking Branch
smartprogrammer93 Dec 28, 2022
1bc58d6
Merge branch 'fix/forkId_calculation_is_wrong_after_timestamp_activat…
smartprogrammer93 Dec 28, 2022
5a0577e
Merge branch 'master' into fix/slotTime_to_be_in_init_config_instead_…
MarekM25 Dec 28, 2022
50fe945
Merge branch 'master' into fix/forkId_calculation_is_wrong_after_time…
MarekM25 Dec 28, 2022
71fa0a5
Merge branch 'master' into feature/shanghai-eip-4895-withdrawals
MarekM25 Dec 28, 2022
9d2037c
Merge branch 'fix/slotTime_to_be_in_init_config_instead_of_merge' int…
MarekM25 Dec 28, 2022
6351165
cosmetic
MarekM25 Dec 28, 2022
dd21379
fix CI
MarekM25 Dec 28, 2022
a856172
Merge branch 'master' into feature/shanghai-eip-4895-withdrawals
rubo Dec 28, 2022
aa3153e
Revise tests
rubo Dec 28, 2022
a74aaab
Update null checks with pattern matching
rubo Dec 28, 2022
ff5443f
Refactor block body initialization and add tests
rubo Dec 28, 2022
d4aba09
Revise whitespaces
rubo Dec 28, 2022
8878117
cosmetic
MarekM25 Dec 29, 2022
6d711da
Merge branch 'feature/shanghai-eip-4895-withdrawals' of https://githu…
MarekM25 Dec 29, 2022
31ffc99
Merge branch 'master' into fix/slotTime_to_be_in_init_config_instead_…
MarekM25 Dec 29, 2022
8632163
Merge branch 'fix/slotTime_to_be_in_init_config_instead_of_merge' int…
MarekM25 Dec 29, 2022
9ff4bf9
Merge branch 'master' into fix/forkId_calculation_is_wrong_after_time…
MarekM25 Dec 29, 2022
25f696a
ForkId calculation polish (#5068)
LukaszRozmej Dec 30, 2022
a5a54f3
Revise Clique block production according to withdrawals rules
rubo Dec 30, 2022
f6a9a52
Merge branch 'master' into feature/shanghai-eip-4895-withdrawals
rubo Dec 30, 2022
21c16e7
Add withdrawals to `eth_getBlockByNumber` tests
rubo Dec 30, 2022
f0d2f6a
SecondsPerSlot move to BlocksConfig (#4944)
smartprogrammer93 Jan 1, 2023
3ee9679
Merge branch 'fix/forkId_calculation_is_wrong_after_timestamp_activat…
MarekM25 Jan 2, 2023
12b81e9
fix build
MarekM25 Jan 2, 2023
4bc8426
Merge branch 'master' into fix/forkId_calculation_is_wrong_after_time…
MarekM25 Jan 2, 2023
59408a7
Merge branch 'master' into feature/shanghai-eip-4895-withdrawals
rubo Jan 2, 2023
44f80bc
Merge branch 'fix/forkId_calculation_is_wrong_after_timestamp_activat…
LukaszRozmej Jan 2, 2023
933f294
Merge branch 'master' into feature/shanghai-eip-4895-withdrawals
MarekM25 Jan 2, 2023
24552f1
removed duplicated NSubstitute
MarekM25 Jan 2, 2023
724968a
Merge branch 'master' into feature/shanghai-eip-4895-withdrawals
rubo Jan 3, 2023
7e804d8
Merge branch 'master' into feature/shanghai-eip-4895-withdrawals
rubo Jan 4, 2023
b3cd6bc
Add missing file headers
rubo Jan 4, 2023
ca1d670
resolved some review comments
MarekM25 Jan 5, 2023
e8df266
more review comments
MarekM25 Jan 5, 2023
ab6cf2e
more review related changes
MarekM25 Jan 5, 2023
b920306
fix Benchmarks build
MarekM25 Jan 5, 2023
96b43d2
Refactor tests
rubo Jan 5, 2023
82707e4
refactor tests - review comment
MarekM25 Jan 6, 2023
9fe4cb2
cosmetic
MarekM25 Jan 6, 2023
355be4f
Revise suggested block validation messages
rubo Jan 5, 2023
8e7be8d
Refactor patricia tries
rubo Jan 6, 2023
a25e999
Merge branch 'master' into feature/shanghai-eip-4895-withdrawals
rubo Jan 6, 2023
8224f06
fix InvalidBlockInterceptor for Withdrawals
MarekM25 Jan 9, 2023
7cf5d72
Merge branch 'feature/shanghai-eip-4895-withdrawals' of https://githu…
MarekM25 Jan 9, 2023
cf62d5e
fix whitespaces
MarekM25 Jan 9, 2023
6aec41d
fix tests
MarekM25 Jan 9, 2023
89e1705
Merge branch 'master' into feature/shanghai-eip-4895-withdrawals
rubo Jan 9, 2023
c579ce8
Merge branch 'master' of https://github.com/nethermindeth/nethermind …
MarekM25 Jan 10, 2023
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 @@ -438,7 +438,7 @@ bool IBlockProducer.IsProducingBlocks(ulong? maxProducingInterval)
_stateProvider.StateRoot = parentHeader.StateRoot!;

IEnumerable<Transaction> selectedTxs = _txSource.GetTransactions(parentBlock.Header, header.GasLimit);
Block block = new BlockToProduce(header, selectedTxs, Array.Empty<BlockHeader>());
Block block = new BlockToProduce(header, selectedTxs, Array.Empty<BlockHeader>(), Enumerable.Empty<Withdrawal>());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Enumerable.Empty() it should be null probably

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, since Shanghai, null is invalid. Decide based on timestamp?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, exactly.

header.TxRoot = new TxTrie(block.Transactions).RootHash;
block.Header.Author = _sealer.Address;
return block;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ internal static class BlockExtensions
{
public static Block CreateCopy(this Block block, BlockHeader header) =>
block is BlockToProduce blockToProduce
? new BlockToProduce(header, blockToProduce.Transactions, blockToProduce.Uncles)
: new Block(header, block.Transactions, block.Uncles);
? new BlockToProduce(header, blockToProduce.Transactions, blockToProduce.Uncles, blockToProduce.Withdrawals)
: new Block(header, block.Transactions, block.Uncles, block.Withdrawals);

public static IEnumerable<Transaction> GetTransactions(this Block block) =>
block is BlockToProduce blockToProduce
Expand Down
25 changes: 25 additions & 0 deletions src/Nethermind/Nethermind.Consensus/Processing/BlockProcessor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,7 @@ private void ValidateProcessedBlock(Block suggestedBlock, ProcessingOptions opti

block.Header.ReceiptsRoot = receipts.GetReceiptsRoot(spec, block.ReceiptsRoot);
ApplyMinerRewards(block, blockTracer, spec);
ApplyWithdrawals(block, spec);

_stateProvider.Commit(spec);
_stateProvider.RecalculateStateRoot();
Expand Down Expand Up @@ -354,5 +355,29 @@ private void ApplyDaoTransition(Block block)
}
}
}

private void ApplyWithdrawals(Block block, IReleaseSpec spec)
rubo marked this conversation as resolved.
Show resolved Hide resolved
{
if (!spec.IsEip4895Enabled)
return;

if (_logger.IsTrace) _logger.Trace($"Applying withdrawals");

foreach (var withdrawal in block.Withdrawals)
{
if (_logger.IsTrace) _logger.Trace($" {(BigInteger)withdrawal.Amount / (BigInteger)Unit.Ether:N3}{Unit.EthSymbol} to account {withdrawal.Recipient}");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what about traces around withdrawals?


if (_stateProvider.AccountExists(withdrawal.Recipient))
{
_stateProvider.AddToBalance(withdrawal.Recipient, withdrawal.Amount, spec);
}
else
{
_stateProvider.CreateAccount(withdrawal.Recipient, withdrawal.Amount);
}
}

if (_logger.IsTrace) _logger.Trace($"Withdrawals applied");
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,7 @@ protected virtual Block PrepareBlock(BlockHeader parent, PayloadAttributes? payl
BlockHeader header = PrepareBlockHeader(parent, payloadAttributes);

IEnumerable<Transaction> transactions = GetTransactions(parent);
return new BlockToProduce(header, transactions, Array.Empty<BlockHeader>());
return new BlockToProduce(header, transactions, Array.Empty<BlockHeader>(), payloadAttributes?.Withdrawals);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.CompilerServices;
using Nethermind.Core;

Expand All @@ -43,8 +44,12 @@ public new IEnumerable<Transaction> Transactions
}
}

public BlockToProduce(BlockHeader blockHeader, IEnumerable<Transaction> transactions, IEnumerable<BlockHeader> uncles)
: base(blockHeader, Array.Empty<Transaction>(), uncles)
public BlockToProduce(
BlockHeader blockHeader,
IEnumerable<Transaction> transactions,
IEnumerable<BlockHeader> uncles,
IEnumerable<Withdrawal>? withdrawals = null)
: base(blockHeader, Array.Empty<Transaction>(), uncles, withdrawals)
{
Transactions = transactions;
}
Expand Down
16 changes: 12 additions & 4 deletions src/Nethermind/Nethermind.Consensus/Producers/PayloadAttributes.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
// along with the Nethermind. If not, see <http://www.gnu.org/licenses/>.
//

using System.Collections.Generic;
using System.Text;
using Nethermind.Core;
using Nethermind.Core.Crypto;
using Nethermind.Int256;
Expand All @@ -29,6 +31,8 @@ public class PayloadAttributes

public Address SuggestedFeeRecipient { get; set; }

public IList<Withdrawal>? Withdrawals { get; set; }

/// <summary>
/// GasLimit
/// </summary>
Expand All @@ -37,9 +41,13 @@ public class PayloadAttributes
/// </remarks>
public long? GasLimit { get; set; }

public override string ToString()
{
return $"PayloadAttributes: ({nameof(Timestamp)}: {Timestamp}, {nameof(PrevRandao)}: {PrevRandao}, {nameof(SuggestedFeeRecipient)}: {SuggestedFeeRecipient})";
}
public override string ToString() => ToString(string.Empty);

public string ToString(string indentation) => new StringBuilder()
.AppendLine($"{indentation}{nameof(Timestamp)}: {Timestamp}")
.AppendLine($"{indentation}{nameof(PrevRandao)}: {PrevRandao}")
.AppendLine($"{indentation}{nameof(SuggestedFeeRecipient)}: {SuggestedFeeRecipient}")
.AppendLine($"{indentation}{nameof(Withdrawals)}: {Withdrawals}")
.ToString();
}
}
28 changes: 19 additions & 9 deletions src/Nethermind/Nethermind.Core/Block.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,16 +33,17 @@ public Block(BlockHeader blockHeader, BlockBody body)
Body = body;
}

public Block(BlockHeader blockHeader, IEnumerable<Transaction> transactions, IEnumerable<BlockHeader> uncles)
public Block(
BlockHeader blockHeader,
IEnumerable<Transaction> transactions,
IEnumerable<BlockHeader> uncles,
IEnumerable<Withdrawal>? withdrawals = null)
{
Header = blockHeader;
Body = new BlockBody(transactions.ToArray(), uncles.ToArray());
Body = new BlockBody(transactions.ToArray(), uncles.ToArray(), withdrawals?.ToArray());
}

public Block(BlockHeader blockHeader)
: this(blockHeader, BlockBody.Empty)
{
}
public Block(BlockHeader blockHeader) : this(blockHeader, BlockBody.Empty) { }

public Block WithReplacedHeader(BlockHeader newHeader) => new(newHeader, Body);

Expand All @@ -60,6 +61,8 @@ public Block(BlockHeader blockHeader)

public BlockHeader[] Uncles => Body.Uncles; // do not add setter here

public Withdrawal[]? Withdrawals => Body.Withdrawals;

public Keccak? Hash => Header.Hash; // do not add setter here

public Keccak? ParentHash => Header.ParentHash; // do not add setter here
Expand Down Expand Up @@ -130,18 +133,25 @@ private string ToFullString()
StringBuilder builder = new();
builder.AppendLine($"Block {Number}");
builder.AppendLine(" Header:");
builder.Append($"{Header.ToString(" ")}");
builder.Append(Header.ToString(" "));

builder.AppendLine(" Uncles:");
foreach (BlockHeader uncle in Body.Uncles ?? Array.Empty<BlockHeader>())
{
builder.Append($"{uncle.ToString(" ")}");
builder.Append(uncle.ToString(" "));
}

builder.AppendLine(" Transactions:");
foreach (Transaction tx in Body?.Transactions ?? Array.Empty<Transaction>())
{
builder.Append($"{tx.ToString(" ")}");
builder.Append(tx.ToString(" "));
}

builder.AppendLine(" Withdrawals:");

foreach (var w in Body?.Withdrawals ?? Array.Empty<Withdrawal>())
{
builder.Append(w.ToString(" "));
}

return builder.ToString();
Expand Down
32 changes: 13 additions & 19 deletions src/Nethermind/Nethermind.Core/BlockBody.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,37 +20,31 @@ namespace Nethermind.Core
{
public class BlockBody
{
public BlockBody(Transaction[]? transactions, BlockHeader[]? uncles)
public BlockBody(Transaction[]? transactions, BlockHeader[]? uncles, Withdrawal[]? withdrawals = null)
{
Transactions = transactions ?? Array.Empty<Transaction>();
Uncles = uncles ?? Array.Empty<BlockHeader>();
Withdrawals = withdrawals;
}

public BlockBody()
: this(null, null)
{
}
public BlockBody() : this(null, null, null) { }

public BlockBody WithChangedTransactions(Transaction[] transactions)
{
return new(transactions, Uncles);
}
public BlockBody WithChangedTransactions(Transaction[] transactions) => new(transactions, Uncles, Withdrawals);

public BlockBody WithChangedUncles(BlockHeader[] uncles)
{
return new(Transactions, uncles);
}
public BlockBody WithChangedUncles(BlockHeader[] uncles) => new(Transactions, uncles, Withdrawals);

public static BlockBody WithOneTransactionOnly(Transaction tx)
{
return new(new[] { tx }, Array.Empty<BlockHeader>());
}
public BlockBody WithChangedWithdrawals(Withdrawal[]? withdrawals) => new(Transactions, Uncles, withdrawals);

public static BlockBody WithOneTransactionOnly(Transaction tx) => new(new[] { tx }, null, null);

public Transaction[] Transactions { get; internal set; }

public BlockHeader[] Uncles { get; }

public static readonly BlockBody Empty = new();
public Withdrawal[]? Withdrawals { get; internal set; }
MarekM25 marked this conversation as resolved.
Show resolved Hide resolved

public static BlockBody Empty { get; } = new();

public bool IsEmpty => Transactions.Length == 0 && Uncles.Length == 0;
public bool IsEmpty => Transactions.Length == 0 && Uncles.Length == 0 && (Withdrawals?.Length ?? 0) == 0;
}
}
23 changes: 8 additions & 15 deletions src/Nethermind/Nethermind.Core/BlockHeader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ public class BlockHeader
public Address? GasBeneficiary => Author ?? Beneficiary;
public Keccak? StateRoot { get; set; }
public Keccak? TxRoot { get; set; }
public Keccak? WithdrawalsRoot { get; set; }
public Keccak? ReceiptsRoot { get; set; }
public Bloom? Bloom { get; set; }
public UInt256 Difficulty { get; set; }
Expand Down Expand Up @@ -99,6 +100,7 @@ public string ToString(string indent)
builder.AppendLine($"{indent}Nonce: {Nonce}");
builder.AppendLine($"{indent}Uncles Hash: {UnclesHash}");
builder.AppendLine($"{indent}Tx Root: {TxRoot}");
builder.AppendLine($"{indent}Withdrawals Root: {WithdrawalsRoot}");
builder.AppendLine($"{indent}Receipts Root: {ReceiptsRoot}");
builder.AppendLine($"{indent}State Root: {StateRoot}");
builder.AppendLine($"{indent}BaseFeePerGas: {BaseFeePerGas}");
Expand All @@ -108,23 +110,14 @@ public string ToString(string indent)
return builder.ToString();
}

public override string ToString()
{
return ToString(string.Empty);
}
public override string ToString() => ToString(string.Empty);

public string ToString(Format format)
public string ToString(Format format) => format switch
{
switch (format)
{
case Format.Full:
return ToString(string.Empty);
case Format.FullHashAndNumber:
return Hash == null ? $"{Number} null" : $"{Number} ({Hash})";
default:
return Hash == null ? $"{Number} null" : $"{Number} ({Hash.ToShortString()})";
}
}
Format.Full => ToString(string.Empty),
Format.FullHashAndNumber => Hash == null ? $"{Number} null" : $"{Number} ({Hash})",
_ => Hash == null ? $"{Number} null" : $"{Number} ({Hash.ToShortString()})",
};

[Todo(Improve.Refactor, "Use IFormattable here")]
public enum Format
Expand Down
19 changes: 14 additions & 5 deletions src/Nethermind/Nethermind.Core/Specs/IReleaseSpec.cs
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
// Copyright (c) 2021 Demerzel Solutions Limited
// This file is part of the Nethermind library.
//
//
// The Nethermind library is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
//
// The Nethermind library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
//
//
// You should have received a copy of the GNU Lesser General Public License
// along with the Nethermind. If not, see <http://www.gnu.org/licenses/>.

Expand Down Expand Up @@ -241,7 +241,7 @@ public interface IReleaseSpec
bool IsEip3529Enabled { get; }

/// <summary>
/// Reject new contracts starting with the 0xEF byte
/// Reject new contracts starting with the 0xEF byte
/// </summary>
bool IsEip3541Enabled { get; }

Expand Down Expand Up @@ -271,6 +271,13 @@ public interface IReleaseSpec
/// </summary>
bool IsEip3855Enabled { get; }

/// <summary>
/// Gets or sets a value indicating whether the
/// <see href="https://eips.ethereum.org/EIPS/eip-4895">EIP-4895</see>
/// validator withdrawals are enabled.
/// </summary>
bool IsEip4895Enabled { get; }

/// <summary>
/// Should transactions be validated against chainId.
/// </summary>
Expand All @@ -285,7 +292,9 @@ public interface IReleaseSpec

public long Eip1559TransitionBlock { get; }

// STATE related
public ulong WithdrawalTimestamp { get; }
MarekM25 marked this conversation as resolved.
Show resolved Hide resolved

// STATE related
public bool ClearEmptyAccountWhenTouched => IsEip158Enabled;

// VM
Expand Down
39 changes: 39 additions & 0 deletions src/Nethermind/Nethermind.Core/Withdrawal.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
using System.Text;
using Nethermind.Int256;

namespace Nethermind.Core;

/// <summary>
/// Represents a withdrawal that has been validated at the consensus layer.
/// </summary>
public class Withdrawal
{
/// <summary>
/// Gets or sets the withdrawal amount as a big-endian value in units of Wei.
/// </summary>
public UInt256 Amount { get; set; }

/// <summary>
/// Gets or sets the withdrawal unique id.
/// </summary>
public ulong Index { get; set; }

/// <summary>
/// Gets or sets the withdrawal recipient address.
/// </summary>
public Address Recipient { get; set; } = Address.Zero;

/// <summary>
/// Gets or sets the validator index on the consensus layer the withdrawal corresponds to.
/// </summary>
public ulong ValidatorIndex { get; set; }

public override string ToString() => ToString(string.Empty);

public string ToString(string indentation) => new StringBuilder()
.AppendLine($"{indentation}{nameof(Index)}: {Index}")
.AppendLine($"{indentation}{nameof(ValidatorIndex)}: {ValidatorIndex}")
.AppendLine($"{indentation}{nameof(Recipient)}: {Recipient}")
.AppendLine($"{indentation}{nameof(Amount)}: {Amount}")
.ToString();
}
Loading