Skip to content
Open
Show file tree
Hide file tree
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 Jan 3, 2025
92523fc
change inclusionlisttransactions type, add to block
Marchhill Jan 3, 2025
a7e59cb
implement GetInclusionListTransactions handler
Marchhill Jan 3, 2025
b71294e
fix tests
Marchhill Jan 3, 2025
df33833
use IL for block building
Marchhill Jan 4, 2025
e2557cd
check that block satisfies IL
Marchhill Jan 4, 2025
1a6c7f1
Merge remote-tracking branch 'upstream/master' into feature/eip-7805
Marchhill Jan 4, 2025
72204a1
fix engine rpc registration, fix old tests, add test
Marchhill Jan 21, 2025
3789381
formatting
Marchhill Jan 21, 2025
2f2abaf
change getInclusionList type to bytes
Marchhill Jan 23, 2025
d7b3dab
fix some tests
Marchhill Jan 23, 2025
dd73442
fix some things and add engineapi tests for inclusion lists
Marchhill Jan 28, 2025
6cf18ad
tidy
Marchhill Jan 28, 2025
99e0963
refactor inclusion list validation to block validator
Marchhill Jan 28, 2025
c26ba5e
add test for inclusion list validation, fix check if tx contained in …
Marchhill Jan 28, 2025
da6e88f
improve efficiency of checking block tx hashes
Marchhill Jan 28, 2025
5e79e5b
fix IL block production and add test
Marchhill Jan 29, 2025
ebd456e
refactor tests and tidy
Marchhill Jan 29, 2025
2300836
use txpooltxsource for inclusion list
Marchhill Jan 29, 2025
4791cb0
whitespace
Marchhill Jan 29, 2025
fd56978
Merge remote-tracking branch 'upstream/master' into feature/eip-7805
Marchhill Jan 30, 2025
274a563
remove merge conflicts
Marchhill Jan 30, 2025
9d58825
remove syncthreadtests
Marchhill Jan 30, 2025
efecc21
small test change
Marchhill Jan 30, 2025
acc500f
fix aura tests
Marchhill Jan 30, 2025
33b6412
move inclusion list validator to separate class
Marchhill Feb 3, 2025
1a00e1c
remove transactionProcessor from blockValidator
Marchhill Feb 3, 2025
180f85a
formatting
Marchhill Feb 3, 2025
8afa7e6
tidy up old tests
Marchhill Feb 3, 2025
2eec53c
tidy
Marchhill Feb 3, 2025
c82a9c5
fix auramergeengine newpayload IL test, improve hash mismatch error m…
Marchhill Feb 3, 2025
e859eca
restore refactor
Marchhill Feb 3, 2025
a9ff72f
revert whitespace
Marchhill Feb 3, 2025
0339125
limit IL size to 8kb
Marchhill Feb 13, 2025
7ccde5e
avoid recalculating header hash
Marchhill Feb 13, 2025
d5e7fad
refactor and decode IL txs earlier
Marchhill Feb 14, 2025
86ea63a
Merge remote-tracking branch 'upstream/master' into feature/eip-7805
Marchhill Feb 14, 2025
b4a285f
Fix formatting
rubo Feb 14, 2025
8f97620
don't decode inclusion list again in txsource
Marchhill Feb 17, 2025
439e725
cleanup IL validator
Marchhill Feb 17, 2025
00fec89
IL satisfied if no gas for simple transfer
Marchhill Feb 17, 2025
e1f004b
use txpooltxsource explicitly in GetInclusionListHandler
Marchhill Feb 17, 2025
f4e0894
max IL size 8192, use ILDecode for encoding, comment on ordering by p…
Marchhill Feb 17, 2025
f1a359c
avoid allocating for creating IL trie, move constants to file
Marchhill Feb 17, 2025
8f1bb99
make txpooltxsource nullable
Marchhill Feb 17, 2025
e2fae0c
add 7805 constants file
Marchhill Feb 17, 2025
4b7cfd1
Merge remote-tracking branch 'upstream/master' into feature/eip-7805
Marchhill Feb 17, 2025
b038b4d
check if InclusionListTransactions null in payloadattributes
Marchhill Feb 17, 2025
b3d1c9b
fix payloadattributes syntax
Marchhill Feb 17, 2025
3c6f62a
fix formatting
Marchhill Feb 17, 2025
54f3baa
fix inclusion list satisfied test
Marchhill Feb 18, 2025
9b34e14
fit as many txs as possible into inclusion list
Marchhill Feb 18, 2025
e10df74
use upper bound estimate for IL packing
Marchhill Feb 18, 2025
9fe0f74
rename getInclusionList to have V1
Marchhill Feb 18, 2025
7acb872
add dummy version updatePayloadWithInclusionList
Marchhill Feb 18, 2025
e8080b9
add new file
Marchhill Feb 18, 2025
93357c7
comment FCU changes
Marchhill Feb 18, 2025
b9d7896
force rebuild payload for updateInclusionListHandler
Marchhill Feb 19, 2025
e0802dc
inclusionlisttxsource pass to update handler and add to additional so…
Marchhill Feb 20, 2025
063d0da
taiko, optimism
Marchhill Feb 20, 2025
d57586f
add cts and ILtxsource to tests
Marchhill Feb 20, 2025
b40e077
INVALID_INCLUSION_LIST error on newpayload
Marchhill Feb 21, 2025
1f3e12d
don't invalidate block for invalid IL
Marchhill Feb 22, 2025
7066d80
move IL validator to public BlockProcessor method
Marchhill Feb 22, 2025
e3cb3ba
fix tests for spec changes
Marchhill Mar 6, 2025
d23b10e
fix auramergeenginemoduletests test name
Marchhill Mar 24, 2025
2327a3e
fix build with force payload rebuild and inclusion list test
Marchhill Mar 24, 2025
29ed2c0
remoe unneeded minor changes
Marchhill Mar 26, 2025
07a4d91
remove old comments
Marchhill Mar 26, 2025
169a5ff
remove unused ecdsa payloadattributes
Marchhill Mar 27, 2025
61f320c
more tidying
Marchhill Mar 27, 2025
b14e50c
add test of force rebuild payload
Marchhill Mar 27, 2025
d6d693d
Merge remote-tracking branch 'upstream/master' into feature/eip-7805
Marchhill Mar 30, 2025
8bc0634
use CallAndRestore for testing IL txs
Marchhill Mar 30, 2025
8d54857
custom 7805 fork
Marchhill Mar 31, 2025
2511879
remove unused ecdsa
Marchhill Mar 31, 2025
e5adae2
use cancellationtokens in payloadpreparationservice
Marchhill Mar 31, 2025
a41e492
fix force rebuild, track build count for tests
Marchhill Mar 31, 2025
8ed54f6
fork activation, remove old usings
Marchhill Mar 31, 2025
bc6c8d7
fix whitespace
Marchhill Mar 31, 2025
4a297f1
randomise IL building tx order
Marchhill Mar 31, 2025
4a5348e
fix aura tests
Marchhill Apr 1, 2025
b1cb3de
Merge remote-tracking branch 'upstream/master' into feature/eip-7805
Marchhill Apr 1, 2025
5aa695e
fix Can_include_inclusion_list to account for randomisation
Marchhill Apr 1, 2025
a2c9f1b
fix shutter keys missed test with delay
Marchhill Apr 1, 2025
0b400bf
comment out Shutter test
Marchhill Apr 1, 2025
37512ca
use arraypoollist for getInclusionList
Marchhill Apr 1, 2025
e3efc6a
Merge remote-tracking branch 'upstream/master' into feature/eip-7805
Marchhill Apr 1, 2025
efb6260
Improvements
LukaszRozmej Apr 1, 2025
0b44442
reuse transactionsInBlock hash set
Marchhill Apr 2, 2025
ec85830
Merge branch 'feature/eip-7805' of github.com:NethermindEth/nethermin…
Marchhill Apr 2, 2025
4a2a26e
Merge remote-tracking branch 'upstream/master' into feature/eip-7805
Marchhill May 2, 2025
8dfef56
fix whitespace
Marchhill May 2, 2025
8a5f745
remove comments
Marchhill May 8, 2025
67d6b37
Merge remote-tracking branch 'upstream/master' into feature/eip-7805
Marchhill May 8, 2025
77dc23f
throw invalidoperation for TransactionInBlock
Marchhill May 8, 2025
df22ddf
disable osaka test
Marchhill May 8, 2025
448c0a1
notimplementedexception
Marchhill May 8, 2025
8373eae
fix checking for transactions in block
Marchhill May 9, 2025
6eff241
Merge remote-tracking branch 'upstream/master' into feature/eip-7805
Marchhill May 20, 2025
3a4d340
whitespace
Marchhill May 20, 2025
6c0d84c
check nonce and balance
Marchhill May 20, 2025
f90835f
Merge remote-tracking branch 'upstream/master' into feature/eip-7805
Marchhill May 29, 2025
30158de
Merge remote-tracking branch 'upstream/master' into feature/eip-7805
Marchhill May 29, 2025
fc0985d
Merge remote-tracking branch 'upstream/master' into feature/eip-7805
Marchhill May 29, 2025
69acd56
format
Marchhill May 29, 2025
723d33a
comment tests
Marchhill May 30, 2025
1205ccd
fix IL test
Marchhill May 30, 2025
da0c12f
fix some tests
Marchhill May 30, 2025
f761280
fix aura tests
Marchhill May 30, 2025
dde1d97
Merge remote-tracking branch 'upstream/master' into feature/eip-7805
Marchhill May 30, 2025
b5ff810
use txpool directly for building
Marchhill May 30, 2025
552dd31
separate IL builder class
Marchhill May 30, 2025
69575ac
add IL builder class
Marchhill May 30, 2025
f3ead60
todo IL building
Marchhill May 30, 2025
fa3e27d
improve payload storage
Marchhill Jun 2, 2025
c6d886c
Merge remote-tracking branch 'upstream/master' into feature/eip-7805
Marchhill Jun 2, 2025
782eccc
fix test
Marchhill Jun 2, 2025
6f54a3c
formatting
Marchhill Jun 2, 2025
e4c6377
optimise sender recovery
Marchhill Jun 2, 2025
3563120
set IL txs in execution payload, recover later
Marchhill Jun 2, 2025
96e1574
only expose build count
Marchhill Jun 2, 2025
2fe01bf
ImproveBlock overload take payloadstore
Marchhill Jun 2, 2025
37c1107
reuse txs decoding
Marchhill Jun 3, 2025
c7906c1
formatting
Marchhill Jun 3, 2025
9d0ecc7
prewarm IL tx sender addresses
Marchhill Jun 3, 2025
9cfdf66
parallelise validation
Marchhill Jun 3, 2025
fae7077
move asOrdered
Marchhill Jun 3, 2025
ed4ddc9
Merge remote-tracking branch 'upstream/master' into feature/eip-7805
Marchhill Jun 3, 2025
4809fca
tidy, disable txsdecoder parallelism
Marchhill Jun 3, 2025
36c94c1
fix RLP decoding exception handling
Marchhill Jun 3, 2025
600812e
add delay in force rebuild test
Marchhill Jun 3, 2025
1d439af
format
Marchhill Jun 3, 2025
007cbfb
Merge remote-tracking branch 'upstream/master' into feature/eip-7805
Marchhill Jun 3, 2025
17dc92e
Merge remote-tracking branch 'upstream/master' into feature/eip-7805
Marchhill Jul 15, 2025
5e37d24
Merge remote-tracking branch 'upstream/master' into feature/eip-7805
Marchhill Jul 30, 2025
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 @@ -111,6 +111,11 @@ public Block[] Process(Hash256 newBranchStateRoot, IReadOnlyList<Block> suggeste
}
}

public bool ValidateInclusionList(Block suggestedBlock, Block block, ProcessingOptions options)
{
throw new NotImplementedException();
}

public event EventHandler<BlocksProcessingEventArgs>? BlocksProcessing;

public event EventHandler<BlockEventArgs>? BlockProcessing;
Expand Down
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);
Copy link
Member

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

_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);
}
}
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)];
}
1 change: 1 addition & 0 deletions src/Nethermind/Nethermind.Consensus/EngineApiVersions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,5 @@ public static class EngineApiVersions
public const int Shanghai = 2;
public const int Cancun = 3;
public const int Prague = 4;
public const int Fork7805 = 5;
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ namespace Nethermind.Consensus.Processing;

public sealed class BlockCachePreWarmer(IReadOnlyTxProcessingEnvFactory envFactory, IWorldState worldStateToWarmup, ISpecProvider specProvider, int concurrency, ILogManager logManager, PreBlockCaches? preBlockCaches = null) : IBlockCachePreWarmer
{
private int _concurrencyLevel = (concurrency == 0 ? RuntimeInformation.PhysicalCoreCount - 1 : concurrency);
private readonly int _concurrencyLevel = (concurrency == 0 ? RuntimeInformation.PhysicalCoreCount - 1 : concurrency);
private readonly ObjectPool<IReadOnlyTxProcessorSource> _envPool = new DefaultObjectPool<IReadOnlyTxProcessorSource>(new ReadOnlyTxProcessingEnvPooledObjectPolicy(envFactory, worldStateToWarmup), Environment.ProcessorCount * 2);
private readonly ILogger _logger = logManager.GetClassLogger<BlockCachePreWarmer>();

Expand Down Expand Up @@ -275,57 +275,67 @@ private void WarmupAddresses(ParallelOptions parallelOptions, Block block)
}
}

AddressWarmingState baseState = new(envPool, block, StateRoot);

ParallelUnbalancedWork.For(
0,
block.Transactions.Length,
parallelOptions,
baseState.InitThreadState,
static (i, state) =>
WarmupTransactionAddresses(envPool, block.Transactions, true);
if (block.InclusionListTransactions is not null)
{
Transaction tx = state.Block.Transactions[i];
Address? sender = tx.SenderAddress;
WarmupTransactionAddresses(envPool, block.InclusionListTransactions, false);
}
}
catch (OperationCanceledException)
{
// Ignore, block completed cancel
}
}

try
{
if (sender is not null)
{
state.Scope.WorldState.WarmUp(sender);
}
private void WarmupTransactionAddresses(ObjectPool<IReadOnlyTxProcessorSource> envPool, Transaction[] transactions, bool warmToAddress)
{
AddressWarmingState baseState = new(envPool, transactions, StateRoot, warmToAddress);

Address to = tx.To;
if (to is not null)
{
state.Scope.WorldState.WarmUp(to);
}
ParallelUnbalancedWork.For(
0,
transactions.Length,
parallelOptions,
baseState.InitThreadState,
static (i, state) =>
{
Transaction tx = state.Transactions[i];
Address? sender = tx.SenderAddress;

try
{
if (sender is not null)
{
state.Scope.WorldState.WarmUp(sender);
}
catch (MissingTrieNodeException)

Address? to = state.WarmToAddress ? null : tx.To;
if (to is not null)
{
state.Scope.WorldState.WarmUp(to);
}
}
catch (MissingTrieNodeException)
{
}

return state;
},
AddressWarmingState.FinallyAction);
}
catch (OperationCanceledException)
{
// Ignore, block completed cancel
}
return state;
},
AddressWarmingState.FinallyAction);
}
}

private readonly struct AddressWarmingState(ObjectPool<IReadOnlyTxProcessorSource> envPool, Block block, Hash256 stateRoot) : IDisposable
private readonly struct AddressWarmingState(ObjectPool<IReadOnlyTxProcessorSource> envPool, Transaction[] transactions, Hash256 stateRoot, bool warmToAddress) : IDisposable
{
public static Action<AddressWarmingState> FinallyAction { get; } = DisposeThreadState;

public readonly ObjectPool<IReadOnlyTxProcessorSource> EnvPool = envPool;
public readonly Block Block = block;
public readonly Transaction[] Transactions = transactions;
public readonly Hash256 StateRoot = stateRoot;
public readonly bool WarmToAddress = warmToAddress;
public readonly IReadOnlyTxProcessorSource? Env;
public readonly IReadOnlyTxProcessingScope? Scope;

public AddressWarmingState(ObjectPool<IReadOnlyTxProcessorSource> envPool, Block block, Hash256 stateRoot, IReadOnlyTxProcessorSource env, IReadOnlyTxProcessingScope scope) : this(envPool, block, stateRoot)
public AddressWarmingState(ObjectPool<IReadOnlyTxProcessorSource> envPool, Transaction[] transactions, Hash256 stateRoot, IReadOnlyTxProcessorSource env, IReadOnlyTxProcessingScope scope, bool warmToAddress) : this(envPool, transactions, stateRoot, warmToAddress)
{
Env = env;
Scope = scope;
Expand All @@ -334,7 +344,8 @@ public AddressWarmingState(ObjectPool<IReadOnlyTxProcessorSource> envPool, Block
public AddressWarmingState InitThreadState()
{
IReadOnlyTxProcessorSource env = EnvPool.Get();
return new(EnvPool, Block, StateRoot, env, scope: env.Build(StateRoot));
IReadOnlyTxProcessingScope scope = env.Build(StateRoot);
return new(EnvPool, Transactions, StateRoot, env, scope, WarmToAddress);
}

public void Dispose()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,5 +45,10 @@ public enum ProcessingResult
/// <summary>
/// Processing failed
/// </summary>
ProcessingError
ProcessingError,

/// <summary>
/// Invalid inclusion list
/// </summary>
InvalidInclusionList
}
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@ public BlockProductionTransactionsExecutor(
{
}

public bool IsTransactionInBlock(Transaction tx) => throw new NotImplementedException();

protected EventHandler<TxProcessedEventArgs>? _transactionProcessed;

event EventHandler<TxProcessedEventArgs>? IBlockProcessor.IBlockTransactionsExecutor.TransactionProcessed
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,20 @@
// SPDX-License-Identifier: LGPL-3.0-only

using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
using System.Threading;
using Nethermind.Blockchain;
using Nethermind.Core;
using Nethermind.Core.Collections;
using Nethermind.Core.Specs;
using Nethermind.Evm;
using Nethermind.Evm.Tracing;
using Nethermind.Evm.TransactionProcessing;
using Nethermind.State;

using Nethermind.TxPool.Comparison;
using Metrics = Nethermind.Evm.Metrics;

namespace Nethermind.Consensus.Processing
Expand All @@ -25,6 +27,8 @@ public class BlockValidationTransactionsExecutor(
IWorldState stateProvider)
: IBlockProcessor.IBlockTransactionsExecutor
{
private readonly HashSet<Transaction> _transactionsInBlock = new(ByHashTxComparer.Instance);

public BlockValidationTransactionsExecutor(ITransactionProcessor transactionProcessor, IWorldState stateProvider)
: this(new ExecuteTransactionProcessorAdapter(transactionProcessor), stateProvider)
{
Expand All @@ -38,6 +42,9 @@ public TxReceipt[] ProcessTransactions(Block block, in BlockExecutionContext blk

var enhanced = EnhanceBlockExecutionContext(blkCtx);

_transactionsInBlock.Clear();
_transactionsInBlock.AddRange(block.Transactions);

for (int i = 0; i < block.Transactions.Length; i++)
{
block.TransactionProcessed = i;
Expand All @@ -47,6 +54,9 @@ public TxReceipt[] ProcessTransactions(Block block, in BlockExecutionContext blk
return receiptsTracer.TxReceipts.ToArray();
}

public bool IsTransactionInBlock(Transaction tx)
=> _transactionsInBlock.Contains(tx);

protected virtual BlockExecutionContext EnhanceBlockExecutionContext(in BlockExecutionContext blkCtx) => blkCtx;

protected virtual void ProcessTransaction(in BlockExecutionContext blkCtx, Transaction currentTx, int index, BlockReceiptsTracer receiptsTracer, ProcessingOptions processingOptions)
Expand Down
13 changes: 13 additions & 0 deletions src/Nethermind/Nethermind.Consensus/Processing/BlockProcessor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Copy link
Member

Choose a reason for hiding this comment

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

I think we don't need IsTransactionInBlock in executor and can simply check against block.Transactions?

}

private bool ShouldComputeStateRoot(BlockHeader header) =>
!header.IsGenesis || !specProvider.GenesisStateUnavailable;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -309,6 +309,11 @@ private async Task RunProcessingLoop()
if (_logger.IsTrace) _logger.Trace($"Failed / skipped processing {block.ToString(Block.Format.Full)}");
BlockRemoved?.Invoke(this, new BlockRemovedEventArgs(blockRef.BlockHash, ProcessingResult.ProcessingError, error));
}
else if (!_blockProcessor.ValidateInclusionList(block, processedBlock, blockRef.ProcessingOptions))
{
if (_logger.IsTrace) _logger.Trace($"Invalid inclusion list for block {block.ToString(Block.Format.Full)}");
BlockRemoved?.Invoke(this, new BlockRemovedEventArgs(blockRef.BlockHash, ProcessingResult.InvalidInclusionList, error));
}
else
{
if (_logger.IsTrace) _logger.Trace($"Processed block {block.ToString(Block.Format.Full)}");
Expand Down
Loading