Skip to content

Commit

Permalink
fix TxPoolTxSource
Browse files Browse the repository at this point in the history
  • Loading branch information
yerke26 committed Dec 8, 2024
1 parent 34ec30c commit 8657a8c
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
17 changes: 12 additions & 5 deletions src/Nethermind/Nethermind.Consensus/Producers/TxPoolTxSource.cs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,12 @@ public IEnumerable<Transaction> GetTransactions(BlockHeader parent, long gasLimi

int checkedTransactions = 0;
int selectedTransactions = 0;
using ArrayPoolList<Transaction> 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<Transaction> selectedBlobTxs = new((int)(payloadAttributes.MaxBlobCount ?? Eip4844Constants.GetMaxBlobsPerBlock()));

SelectBlobTransactions(blobTransactions, parent, spec, selectedBlobTxs);

Expand Down Expand Up @@ -119,7 +124,7 @@ private static IEnumerable<Transaction> PickBlobTxsBetterThanCurrentTx(ArrayPool
}
}

private void SelectBlobTransactions(IEnumerable<Transaction> blobTransactions, BlockHeader parent, IReleaseSpec spec, ArrayPoolList<Transaction> selectedBlobTxs)
private void SelectBlobTransactions(IEnumerable<Transaction> blobTransactions, BlockHeader parent, IReleaseSpec spec, ArrayPoolList<Transaction> selectedBlobTxs, PayloadAttributes? payloadAttributes = null)
{
int checkedBlobTransactions = 0;
int selectedBlobTransactions = 0;
Expand All @@ -128,7 +133,8 @@ private void SelectBlobTransactions(IEnumerable<Transaction> 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;
Expand All @@ -137,8 +143,9 @@ private void SelectBlobTransactions(IEnumerable<Transaction> 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;
Expand Down
2 changes: 0 additions & 2 deletions src/Nethermind/Nethermind.Core/Eip7742Constants.cs
Original file line number Diff line number Diff line change
@@ -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
Expand Down

0 comments on commit 8657a8c

Please sign in to comment.