diff --git a/src/Nethermind/Nethermind.Consensus/Producers/TxPoolTxSource.cs b/src/Nethermind/Nethermind.Consensus/Producers/TxPoolTxSource.cs index 233b44315c2..bf7201af967 100644 --- a/src/Nethermind/Nethermind.Consensus/Producers/TxPoolTxSource.cs +++ b/src/Nethermind/Nethermind.Consensus/Producers/TxPoolTxSource.cs @@ -62,7 +62,12 @@ public IEnumerable GetTransactions(BlockHeader parent, long gasLimi int checkedTransactions = 0; int selectedTransactions = 0; - using ArrayPoolList selectedBlobTxs = new((int)(payloadAttributes?.MaxBlobCount ?? Eip4844Constants.GetMaxBlobsPerBlock())); + if (spec.IsEip7742Enabled && payloadAttributes == null) + { + if (_logger.IsDebug) _logger.Debug("Eip-7742 is enabled, but no payload attributes were provided."); + yield break; + } + using ArrayPoolList selectedBlobTxs = new((int)(payloadAttributes.MaxBlobCount ?? Eip4844Constants.GetMaxBlobsPerBlock())); SelectBlobTransactions(blobTransactions, parent, spec, selectedBlobTxs); @@ -119,7 +124,7 @@ private static IEnumerable PickBlobTxsBetterThanCurrentTx(ArrayPool } } - private void SelectBlobTransactions(IEnumerable blobTransactions, BlockHeader parent, IReleaseSpec spec, ArrayPoolList selectedBlobTxs) + private void SelectBlobTransactions(IEnumerable blobTransactions, BlockHeader parent, IReleaseSpec spec, ArrayPoolList selectedBlobTxs, PayloadAttributes? payloadAttributes = null) { int checkedBlobTransactions = 0; int selectedBlobTransactions = 0; @@ -128,7 +133,8 @@ private void SelectBlobTransactions(IEnumerable blobTransactions, B foreach (Transaction blobTx in blobTransactions) { - if (!spec.IsEip7742Enabled && blobGasCounter >= _eip4844Config.MaxBlobGasPerBlock) + if ((spec.IsEip7742Enabled && blobGasCounter >= payloadAttributes?.MaxBlobCount * Eip4844Constants.GasPerBlob) + || (!spec.IsEip7742Enabled && blobGasCounter >= _eip4844Config.MaxBlobGasPerBlock)) { if (_logger.IsTrace) _logger.Trace($"Declining {blobTx.ToShortString()}, no more blob space. Block already have {blobGasCounter} blob gas which is max value allowed."); break; @@ -137,8 +143,9 @@ private void SelectBlobTransactions(IEnumerable blobTransactions, B checkedBlobTransactions++; ulong txBlobGas = (ulong)(blobTx.BlobVersionedHashes?.Length ?? 0) * _eip4844Config.GasPerBlob; - // no validation is needed when eip7742 is activated - if (!spec.IsEip7742Enabled && txBlobGas > _eip4844Config.MaxBlobGasPerBlock - blobGasCounter) + + if ((spec.IsEip7742Enabled && txBlobGas >= payloadAttributes?.MaxBlobCount * Eip4844Constants.GasPerBlob - blobGasCounter) + || (!spec.IsEip7742Enabled && txBlobGas > _eip4844Config.MaxBlobGasPerBlock - blobGasCounter)) { if (_logger.IsTrace) _logger.Trace($"Declining {blobTx.ToShortString()}, not enough blob space."); continue; diff --git a/src/Nethermind/Nethermind.Core/Eip7742Constants.cs b/src/Nethermind/Nethermind.Core/Eip7742Constants.cs index c13a63355fd..4ea67b5f159 100644 --- a/src/Nethermind/Nethermind.Core/Eip7742Constants.cs +++ b/src/Nethermind/Nethermind.Core/Eip7742Constants.cs @@ -1,8 +1,6 @@ // SPDX-FileCopyrightText: 2024 Demerzel Solutions Limited // SPDX-License-Identifier: LGPL-3.0-only -using Nethermind.Int256; - namespace Nethermind.Core; public class Eip7742Constants