-
Notifications
You must be signed in to change notification settings - Fork 560
Implement EIP-7805 (FOCIL) #8003
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
Open
Marchhill
wants to merge
136
commits into
master
Choose a base branch
from
feature/eip-7805
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 134 commits
Commits
Show all changes
136 commits
Select commit
Hold shift + click to select a range
caafcee
add to release spec, chainspec, engineapi
Marchhill 92523fc
change inclusionlisttransactions type, add to block
Marchhill a7e59cb
implement GetInclusionListTransactions handler
Marchhill b71294e
fix tests
Marchhill df33833
use IL for block building
Marchhill e2557cd
check that block satisfies IL
Marchhill 1a6c7f1
Merge remote-tracking branch 'upstream/master' into feature/eip-7805
Marchhill 72204a1
fix engine rpc registration, fix old tests, add test
Marchhill 3789381
formatting
Marchhill 2f2abaf
change getInclusionList type to bytes
Marchhill d7b3dab
fix some tests
Marchhill dd73442
fix some things and add engineapi tests for inclusion lists
Marchhill 6cf18ad
tidy
Marchhill 99e0963
refactor inclusion list validation to block validator
Marchhill c26ba5e
add test for inclusion list validation, fix check if tx contained in …
Marchhill da6e88f
improve efficiency of checking block tx hashes
Marchhill 5e79e5b
fix IL block production and add test
Marchhill ebd456e
refactor tests and tidy
Marchhill 2300836
use txpooltxsource for inclusion list
Marchhill 4791cb0
whitespace
Marchhill fd56978
Merge remote-tracking branch 'upstream/master' into feature/eip-7805
Marchhill 274a563
remove merge conflicts
Marchhill 9d58825
remove syncthreadtests
Marchhill efecc21
small test change
Marchhill acc500f
fix aura tests
Marchhill 33b6412
move inclusion list validator to separate class
Marchhill 1a00e1c
remove transactionProcessor from blockValidator
Marchhill 180f85a
formatting
Marchhill 8afa7e6
tidy up old tests
Marchhill 2eec53c
tidy
Marchhill c82a9c5
fix auramergeengine newpayload IL test, improve hash mismatch error m…
Marchhill e859eca
restore refactor
Marchhill a9ff72f
revert whitespace
Marchhill 0339125
limit IL size to 8kb
Marchhill 7ccde5e
avoid recalculating header hash
Marchhill d5e7fad
refactor and decode IL txs earlier
Marchhill 86ea63a
Merge remote-tracking branch 'upstream/master' into feature/eip-7805
Marchhill b4a285f
Fix formatting
rubo 8f97620
don't decode inclusion list again in txsource
Marchhill 439e725
cleanup IL validator
Marchhill 00fec89
IL satisfied if no gas for simple transfer
Marchhill e1f004b
use txpooltxsource explicitly in GetInclusionListHandler
Marchhill f4e0894
max IL size 8192, use ILDecode for encoding, comment on ordering by p…
Marchhill f1a359c
avoid allocating for creating IL trie, move constants to file
Marchhill 8f1bb99
make txpooltxsource nullable
Marchhill e2fae0c
add 7805 constants file
Marchhill 4b7cfd1
Merge remote-tracking branch 'upstream/master' into feature/eip-7805
Marchhill b038b4d
check if InclusionListTransactions null in payloadattributes
Marchhill b3d1c9b
fix payloadattributes syntax
Marchhill 3c6f62a
fix formatting
Marchhill 54f3baa
fix inclusion list satisfied test
Marchhill 9b34e14
fit as many txs as possible into inclusion list
Marchhill e10df74
use upper bound estimate for IL packing
Marchhill 9fe0f74
rename getInclusionList to have V1
Marchhill 7acb872
add dummy version updatePayloadWithInclusionList
Marchhill e8080b9
add new file
Marchhill 93357c7
comment FCU changes
Marchhill b9d7896
force rebuild payload for updateInclusionListHandler
Marchhill e0802dc
inclusionlisttxsource pass to update handler and add to additional so…
Marchhill 063d0da
taiko, optimism
Marchhill d57586f
add cts and ILtxsource to tests
Marchhill b40e077
INVALID_INCLUSION_LIST error on newpayload
Marchhill 1f3e12d
don't invalidate block for invalid IL
Marchhill 7066d80
move IL validator to public BlockProcessor method
Marchhill e3cb3ba
fix tests for spec changes
Marchhill d23b10e
fix auramergeenginemoduletests test name
Marchhill 2327a3e
fix build with force payload rebuild and inclusion list test
Marchhill 29ed2c0
remoe unneeded minor changes
Marchhill 07a4d91
remove old comments
Marchhill 169a5ff
remove unused ecdsa payloadattributes
Marchhill 61f320c
more tidying
Marchhill b14e50c
add test of force rebuild payload
Marchhill d6d693d
Merge remote-tracking branch 'upstream/master' into feature/eip-7805
Marchhill 8bc0634
use CallAndRestore for testing IL txs
Marchhill 8d54857
custom 7805 fork
Marchhill 2511879
remove unused ecdsa
Marchhill e5adae2
use cancellationtokens in payloadpreparationservice
Marchhill a41e492
fix force rebuild, track build count for tests
Marchhill 8ed54f6
fork activation, remove old usings
Marchhill bc6c8d7
fix whitespace
Marchhill 4a297f1
randomise IL building tx order
Marchhill 4a5348e
fix aura tests
Marchhill b1cb3de
Merge remote-tracking branch 'upstream/master' into feature/eip-7805
Marchhill 5aa695e
fix Can_include_inclusion_list to account for randomisation
Marchhill a2c9f1b
fix shutter keys missed test with delay
Marchhill 0b400bf
comment out Shutter test
Marchhill 37512ca
use arraypoollist for getInclusionList
Marchhill e3efc6a
Merge remote-tracking branch 'upstream/master' into feature/eip-7805
Marchhill efb6260
Improvements
LukaszRozmej 0b44442
reuse transactionsInBlock hash set
Marchhill ec85830
Merge branch 'feature/eip-7805' of github.com:NethermindEth/nethermin…
Marchhill 4a2a26e
Merge remote-tracking branch 'upstream/master' into feature/eip-7805
Marchhill 8dfef56
fix whitespace
Marchhill 8a5f745
remove comments
Marchhill 67d6b37
Merge remote-tracking branch 'upstream/master' into feature/eip-7805
Marchhill 77dc23f
throw invalidoperation for TransactionInBlock
Marchhill df22ddf
disable osaka test
Marchhill 448c0a1
notimplementedexception
Marchhill 8373eae
fix checking for transactions in block
Marchhill 6eff241
Merge remote-tracking branch 'upstream/master' into feature/eip-7805
Marchhill 3a4d340
whitespace
Marchhill 6c0d84c
check nonce and balance
Marchhill f90835f
Merge remote-tracking branch 'upstream/master' into feature/eip-7805
Marchhill 30158de
Merge remote-tracking branch 'upstream/master' into feature/eip-7805
Marchhill fc0985d
Merge remote-tracking branch 'upstream/master' into feature/eip-7805
Marchhill 69acd56
format
Marchhill 723d33a
comment tests
Marchhill 1205ccd
fix IL test
Marchhill da0c12f
fix some tests
Marchhill f761280
fix aura tests
Marchhill dde1d97
Merge remote-tracking branch 'upstream/master' into feature/eip-7805
Marchhill b5ff810
use txpool directly for building
Marchhill 552dd31
separate IL builder class
Marchhill 69575ac
add IL builder class
Marchhill f3ead60
todo IL building
Marchhill fa3e27d
improve payload storage
Marchhill c6d886c
Merge remote-tracking branch 'upstream/master' into feature/eip-7805
Marchhill 782eccc
fix test
Marchhill 6f54a3c
formatting
Marchhill e4c6377
optimise sender recovery
Marchhill 3563120
set IL txs in execution payload, recover later
Marchhill 96e1574
only expose build count
Marchhill 2fe01bf
ImproveBlock overload take payloadstore
Marchhill 37c1107
reuse txs decoding
Marchhill c7906c1
formatting
Marchhill 9d0ecc7
prewarm IL tx sender addresses
Marchhill 9cfdf66
parallelise validation
Marchhill fae7077
move asOrdered
Marchhill ed4ddc9
Merge remote-tracking branch 'upstream/master' into feature/eip-7805
Marchhill 4809fca
tidy, disable txsdecoder parallelism
Marchhill 36c94c1
fix RLP decoding exception handling
Marchhill 600812e
add delay in force rebuild test
Marchhill 1d439af
format
Marchhill 007cbfb
Merge remote-tracking branch 'upstream/master' into feature/eip-7805
Marchhill 17dc92e
Merge remote-tracking branch 'upstream/master' into feature/eip-7805
Marchhill 5e37d24
Merge remote-tracking branch 'upstream/master' into feature/eip-7805
Marchhill File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
104 changes: 104 additions & 0 deletions
104
src/Nethermind/Nethermind.Blockchain.Test/Validators/InclusionListValidatorTests.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,104 @@ | ||
// SPDX-FileCopyrightText: 2025 Demerzel Solutions Limited | ||
// SPDX-License-Identifier: LGPL-3.0-only | ||
|
||
using Nethermind.Consensus.Validators; | ||
using Nethermind.Core; | ||
using Nethermind.Core.Extensions; | ||
using Nethermind.Core.Specs; | ||
using Nethermind.Core.Test; | ||
using Nethermind.Core.Test.Builders; | ||
using Nethermind.Db; | ||
using Nethermind.Logging; | ||
using Nethermind.Specs.Forks; | ||
using Nethermind.Specs.Test; | ||
using Nethermind.State; | ||
using Nethermind.Trie.Pruning; | ||
using NUnit.Framework; | ||
|
||
namespace Nethermind.Blockchain.Test.Validators; | ||
|
||
public class InclusionListValidatorTests | ||
{ | ||
private IWorldState _stateProvider; | ||
private ISpecProvider _specProvider; | ||
private InclusionListValidator _inclusionListValidator; | ||
private Transaction _validTx; | ||
|
||
[SetUp] | ||
public void Setup() | ||
{ | ||
_specProvider = new CustomSpecProvider(((ForkActivation)0, Fork7805.Instance)); | ||
|
||
MemDb stateDb = new(); | ||
TrieStore trieStore = TestTrieStoreFactory.Build(stateDb, LimboLogs.Instance); | ||
_stateProvider = new WorldState(trieStore, new MemDb(), LimboLogs.Instance); | ||
_stateProvider.CreateAccount(TestItem.AddressA, 10.Ether()); | ||
_stateProvider.Commit(_specProvider.GenesisSpec); | ||
_stateProvider.CommitTree(0); | ||
|
||
_inclusionListValidator = new InclusionListValidator( | ||
_specProvider, | ||
_stateProvider); | ||
|
||
_validTx = Build.A.Transaction | ||
.WithGasLimit(100_000) | ||
.WithGasPrice(10.GWei()) | ||
.WithNonce(0) | ||
.WithValue(1.Ether()) | ||
.WithTo(TestItem.AddressA) | ||
.SignedAndResolved(TestItem.PrivateKeyA) | ||
.TestObject; | ||
} | ||
|
||
[Test] | ||
public void When_block_full_then_accept() | ||
{ | ||
Block block = Build.A.Block | ||
.WithGasLimit(30_000_000) | ||
.WithGasUsed(30_000_000) | ||
.WithInclusionListTransactions([_validTx]) | ||
.TestObject; | ||
|
||
bool isValid = _inclusionListValidator.ValidateInclusionList(block, _ => false); | ||
Assert.That(isValid, Is.True); | ||
} | ||
|
||
[Test] | ||
public void When_all_inclusion_list_txs_included_then_accept() | ||
{ | ||
Block block = Build.A.Block | ||
.WithGasLimit(30_000_000) | ||
.WithGasUsed(1_000_000) | ||
.WithTransactions(_validTx) | ||
.WithInclusionListTransactions([_validTx]) | ||
.TestObject; | ||
|
||
bool isValid = _inclusionListValidator.ValidateInclusionList(block, tx => tx == _validTx); | ||
Assert.That(isValid, Is.True); | ||
} | ||
|
||
[Test] | ||
public void When_valid_tx_excluded_then_reject() | ||
{ | ||
Block block = Build.A.Block | ||
.WithGasLimit(30_000_000) | ||
.WithGasUsed(1_000_000) | ||
.WithInclusionListTransactions([_validTx]) | ||
.TestObject; | ||
|
||
bool isValid = _inclusionListValidator.ValidateInclusionList(block, _ => false); | ||
Assert.That(isValid, Is.False); | ||
} | ||
|
||
[Test] | ||
public void When_no_inclusion_list_then_reject() | ||
{ | ||
Block block = Build.A.Block | ||
.WithGasLimit(30_000_000) | ||
.WithGasUsed(1_000_000) | ||
.TestObject; | ||
|
||
bool isValid = _inclusionListValidator.ValidateInclusionList(block, _ => false); | ||
Assert.That(isValid, Is.False); | ||
} | ||
} |
34 changes: 34 additions & 0 deletions
34
src/Nethermind/Nethermind.Consensus/Decoders/InclusionListDecoder.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
// SPDX-FileCopyrightText: 2025 Demerzel Solutions Limited | ||
// SPDX-License-Identifier: LGPL-3.0-only | ||
|
||
using System.Collections.Generic; | ||
using System.Linq; | ||
using Nethermind.Consensus.Processing; | ||
using Nethermind.Core; | ||
using Nethermind.Core.Specs; | ||
using Nethermind.Crypto; | ||
using Nethermind.Serialization.Rlp; | ||
|
||
namespace Nethermind.Consensus.Decoders; | ||
|
||
public class InclusionListDecoder( | ||
IEthereumEcdsa? ecdsa, | ||
TxPool.ITxPool? txPool, | ||
ISpecProvider? specProvider, | ||
Logging.ILogManager? logManager) | ||
{ | ||
private readonly RecoverSignatures _recoverSignatures = new(ecdsa, txPool, specProvider, logManager); | ||
|
||
public IEnumerable<Transaction> DecodeAndRecover(byte[][] txBytes, IReleaseSpec spec) | ||
{ | ||
Transaction[] transactions = TxsDecoder.DecodeTxs(txBytes, true).Transactions; | ||
_recoverSignatures.RecoverData(transactions, spec, false); | ||
return transactions; | ||
} | ||
|
||
public static byte[] Encode(Transaction transaction) | ||
=> TxDecoder.Instance.Encode(transaction, RlpBehaviors.SkipTypedWrapping).Bytes; | ||
|
||
public static byte[][] Encode(IEnumerable<Transaction> transactions) | ||
=> [.. transactions.Select(Encode)]; | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -46,6 +46,8 @@ public partial class BlockProcessor( | |
IBlockCachePreWarmer? preWarmer = null) | ||
: IBlockProcessor | ||
{ | ||
private readonly IBlockProcessor.IBlockTransactionsExecutor _blockTransactionsExecutor = blockTransactionsExecutor ?? throw new ArgumentNullException(nameof(blockTransactionsExecutor)); | ||
private readonly IInclusionListValidator _inclusionListValidator = new InclusionListValidator(specProvider, stateProvider); | ||
private readonly ILogger _logger = logManager.GetClassLogger(); | ||
protected readonly WorldStateMetricsDecorator _stateProvider = new WorldStateMetricsDecorator(stateProvider); | ||
private readonly IReceiptsRootCalculator _receiptsRootCalculator = ReceiptsRootCalculator.Instance; | ||
|
@@ -294,6 +296,17 @@ private void ValidateProcessedBlock(Block suggestedBlock, ProcessingOptions opti | |
suggestedBlock.ExecutionRequests = block.ExecutionRequests; | ||
} | ||
|
||
public bool ValidateInclusionList(Block suggestedBlock, Block block, ProcessingOptions options) | ||
{ | ||
if (options.ContainsFlag(ProcessingOptions.NoValidation)) | ||
{ | ||
return true; | ||
} | ||
|
||
block.InclusionListTransactions = suggestedBlock.InclusionListTransactions; | ||
return _inclusionListValidator.ValidateInclusionList(block, _blockTransactionsExecutor.IsTransactionInBlock); | ||
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. I think we don't need |
||
} | ||
|
||
private bool ShouldComputeStateRoot(BlockHeader header) => | ||
!header.IsGenesis || !specProvider.GenesisStateUnavailable; | ||
|
||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Not sure if needs update after: #8724