Skip to content

Commit

Permalink
Revert "Add filter for max transaction size (#7925)"
Browse files Browse the repository at this point in the history
This reverts commit 480f5f6
  • Loading branch information
marcindsobczak committed Jan 29, 2025
1 parent c0dd15e commit df244e8
Show file tree
Hide file tree
Showing 19 changed files with 30 additions and 123 deletions.
14 changes: 7 additions & 7 deletions src/Nethermind/Nethermind.Core/Transaction.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,10 @@ public class Transaction
public UInt256 MaxPriorityFeePerGas => GasPrice;
public UInt256 DecodedMaxFeePerGas { get; set; }
public UInt256 MaxFeePerGas => Supports1559 ? DecodedMaxFeePerGas : GasPrice;
public bool SupportsAccessList => Type.SupportsAccessList();
public bool Supports1559 => Type.Supports1559();
public bool SupportsBlobs => Type.SupportsBlobs();
public bool SupportsAuthorizationList => Type.SupportsAuthorizationList();
public bool SupportsAccessList => Type >= TxType.AccessList && Type != TxType.DepositTx;
public bool Supports1559 => Type >= TxType.EIP1559 && Type != TxType.DepositTx;
public bool SupportsBlobs => Type == TxType.Blob && Type != TxType.DepositTx;
public bool SupportsAuthorizationList => Type == TxType.SetCode && Type != TxType.DepositTx;
public long GasLimit { get; set; }
public Address? To { get; set; }
public UInt256 Value { get; set; }
Expand Down Expand Up @@ -195,9 +195,9 @@ private void ClearPreHashInternal()
/// <summary>
/// Encoded transaction length
/// </summary>
public int GetLength(ITransactionSizeCalculator sizeCalculator, bool shouldCountBlobs)
public int GetLength(ITransactionSizeCalculator sizeCalculator)
{
return _size ??= sizeCalculator.GetLength(this, shouldCountBlobs);
return _size ??= sizeCalculator.GetLength(this);
}

public string ToShortString()
Expand Down Expand Up @@ -334,7 +334,7 @@ public class SystemTransaction : Transaction
/// <remarks>Created because of cyclic dependencies between Core and Rlp modules</remarks>
public interface ITransactionSizeCalculator
{
int GetLength(Transaction tx, bool shouldCountBlobs = true);
int GetLength(Transaction tx);
}

/// <summary>
Expand Down
16 changes: 3 additions & 13 deletions src/Nethermind/Nethermind.Core/TxTypeExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,7 @@ namespace Nethermind.Core;
public static class TxTypeExtensions
{
public static bool IsTxTypeWithAccessList(this TxType txType)
=> txType != TxType.Legacy;

public static bool SupportsAccessList(this TxType txType)
=> txType >= TxType.AccessList && txType != TxType.DepositTx;

public static bool Supports1559(this TxType txType)
=> txType >= TxType.EIP1559 && txType != TxType.DepositTx;

public static bool SupportsBlobs(this TxType txType)
=> txType == TxType.Blob && txType != TxType.DepositTx;

public static bool SupportsAuthorizationList(this TxType txType)
=> txType == TxType.SetCode && txType != TxType.DepositTx;
{
return txType != TxType.Legacy;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// SPDX-License-Identifier: LGPL-3.0-only

using System;
using System.Collections.Generic;
using System.Net;
using DotNetty.Buffers;
using FluentAssertions;
Expand Down Expand Up @@ -230,7 +231,7 @@ public void should_divide_GetPooledTransactionsMessage_if_max_message_size_is_ex
_syncManager,
RunImmediatelyScheduler.Instance,
_transactionPool,
new PooledTxsRequestor(_transactionPool, new TxPoolConfig() { MaxTxSize = sizeOfOneTx }, _specProvider),
new PooledTxsRequestor(_transactionPool, new TxPoolConfig()),
_gossipPolicy,
new ForkInfo(_specProvider, _genesisBlock.Header.Hash!),
LimboLogs.Instance,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,6 @@ public void RequestTransactionsEth68(Action<V66.Messages.GetPooledTransactionsMe
int txSize = size;
TxType txType = (TxType)type;

long maxSize = txType.SupportsBlobs() ? _configuredMaxBlobTxSize : _configuredMaxTxSize;
if (txSize > maxSize)
continue;

if (txSize > packetSizeLeft && toRequestCount > 0)
{
RequestPooledTransactionsEth66(send, hashesToRequest);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@ public class ModExpBenchmark : PrecompileBenchmarkBase
protected override IEnumerable<IPrecompile> Precompiles => new[] { ModExpPrecompile.Instance };
protected override string InputsDirectory => "modexp";

[Benchmark]
public (ReadOnlyMemory<byte>, bool) BigInt()
{
#pragma warning disable CS0618 // Type or member is obsolete
return ModExpPrecompile.OldRun(Input.Bytes);
#pragma warning restore CS0618 // Type or member is obsolete
}
// [Benchmark]
// public (ReadOnlyMemory<byte>, bool) BigInt()
// {
// #pragma warning disable CS0618 // Type or member is obsolete
// return ModExpPrecompile.OldRun(Input.Bytes);
// #pragma warning restore CS0618 // Type or member is obsolete
// }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@
},
"Mainnet": {
"commandName": "Project",
"commandLineArgs": "-c mainnet --data-dir .data",
"commandLineArgs": "-c mainnet --data-dir C:/praca/",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
Expand Down
5 changes: 3 additions & 2 deletions src/Nethermind/Nethermind.Runner/configs/mainnet.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,10 @@
"Port": 8545,
"AdditionalRpcUrls": [
"http://localhost:8551|http;ws|net;eth;subscribe;engine;web3;client"
]
],
"JwtSecretFile": "C:/tmp/jwtsecret"
},
"Merge": {
"Enabled": true
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ public void should_announce_details_of_full_blob_tx()
_broadcaster.AddPeer(peer);
_broadcaster.BroadcastPersistentTxs();

peer.Received(1).SendNewTransactions(Arg.Is<IEnumerable<Transaction>>(t => t.FirstOrDefault().GetLength(true) == size), false);
peer.Received(1).SendNewTransactions(Arg.Is<IEnumerable<Transaction>>(t => t.FirstOrDefault().GetLength() == size), false);
}

[Test]
Expand Down
18 changes: 0 additions & 18 deletions src/Nethermind/Nethermind.TxPool.Test/TxPoolTests.Blobs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,24 +42,6 @@ public void should_reject_blob_tx_if_blobs_not_supported([Values(true, false)] b
: AcceptTxResult.NotSupportedTxType);
}

[Test]
public void should_reject_blob_tx_if_max_size_is_exceeded([Values(true, false)] bool sizeExceeded, [Values(1, 2, 3, 4, 5, 6)] int numberOfBlobs)
{
Transaction tx = Build.A.Transaction
.WithShardBlobTxTypeAndFields(numberOfBlobs)
.WithMaxPriorityFeePerGas(1.GWei())
.WithMaxFeePerGas(1.GWei())
.SignedAndResolved(_ethereumEcdsa, TestItem.PrivateKeyA).TestObject;
EnsureSenderBalance(TestItem.AddressA, UInt256.MaxValue);

var txPoolConfig = new TxPoolConfig() { MaxBlobTxSize = tx.GetLength(shouldCountBlobs: false) - (sizeExceeded ? 1 : 0) };
_txPool = CreatePool(txPoolConfig, GetCancunSpecProvider());

AcceptTxResult result = _txPool.SubmitTx(tx, TxHandlingOptions.PersistentBroadcast);
result.Should().Be(sizeExceeded ? AcceptTxResult.MaxTxSizeExceeded : AcceptTxResult.Accepted);
_txPool.GetPendingBlobTransactionsCount().Should().Be(sizeExceeded ? 0 : 1);
}

[Test]
public void blob_pool_size_should_be_correct([Values(true, false)] bool persistentStorageEnabled)
{
Expand Down
14 changes: 0 additions & 14 deletions src/Nethermind/Nethermind.TxPool.Test/TxPoolTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -361,20 +361,6 @@ public void should_ignore_block_gas_limit_exceeded()
result.Should().Be(AcceptTxResult.GasLimitExceeded);
}

[Test]
public void should_reject_tx_if_max_size_is_exceeded([Values(true, false)] bool sizeExceeded)
{
Transaction tx = Build.A.Transaction.SignedAndResolved(_ethereumEcdsa, TestItem.PrivateKeyA).TestObject;
EnsureSenderBalance(tx);

var txPoolConfig = new TxPoolConfig() { MaxTxSize = tx.GetLength() - (sizeExceeded ? 1 : 0) };
_txPool = CreatePool(txPoolConfig);

AcceptTxResult result = _txPool.SubmitTx(tx, TxHandlingOptions.PersistentBroadcast);
result.Should().Be(sizeExceeded ? AcceptTxResult.MaxTxSizeExceeded : AcceptTxResult.Accepted);
_txPool.GetPendingTransactionsCount().Should().Be(sizeExceeded ? 0 : 1);
}

[Test]
public void should_accept_tx_when_base_fee_is_high()
{
Expand Down
5 changes: 0 additions & 5 deletions src/Nethermind/Nethermind.TxPool/AcceptTxResult.cs
Original file line number Diff line number Diff line change
Expand Up @@ -90,11 +90,6 @@ namespace Nethermind.TxPool
/// </summary>
public static readonly AcceptTxResult NotSupportedTxType = new(15, nameof(NotSupportedTxType));

/// <summary>
/// Transaction size exceeds configured max size.
/// </summary>
public static readonly AcceptTxResult MaxTxSizeExceeded = new(16, nameof(MaxTxSizeExceeded));

/// <summary>
/// The node is syncing and cannot accept transactions at this time.
/// </summary>
Expand Down
29 changes: 0 additions & 29 deletions src/Nethermind/Nethermind.TxPool/Filters/SizeTxFilter.cs

This file was deleted.

8 changes: 0 additions & 8 deletions src/Nethermind/Nethermind.TxPool/ITxPoolConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,14 +43,6 @@ public interface ITxPoolConfig : IConfig

long? GasLimit { get; set; }

[ConfigItem(DefaultValue = "131072",
Description = "The max transaction size allowed, in bytes.")]
long? MaxTxSize { get; set; }

[ConfigItem(DefaultValue = "1048576",
Description = "The max blob transaction size allowed, excluding blobs, in bytes.")]
long? MaxBlobTxSize { get; set; }

[ConfigItem(DefaultValue = "null",
Description = "The current transaction pool state reporting interval, in minutes.")]
int? ReportMinutes { get; set; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,8 @@ public NetworkTransactionSizeCalculator(TxDecoder txDecoder)
_txDecoder = txDecoder;
}

public int GetLength(Transaction tx, bool shouldCountBlobs)
public int GetLength(Transaction tx)
{
return shouldCountBlobs
? _txDecoder.GetLength(tx, RlpBehaviors.InMempoolForm | RlpBehaviors.SkipTypedWrapping)
: _txDecoder.GetLength(tx, RlpBehaviors.SkipTypedWrapping);
return _txDecoder.GetLength(tx, RlpBehaviors.InMempoolForm | RlpBehaviors.SkipTypedWrapping);
}
}
4 changes: 2 additions & 2 deletions src/Nethermind/Nethermind.TxPool/TransactionExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ public static class TransactionExtensions
private static readonly long MaxSizeOfTxForBroadcast = 4.KiB(); //4KB, as in Geth https://github.com/ethereum/go-ethereum/pull/27618
private static readonly ITransactionSizeCalculator _transactionSizeCalculator = new NetworkTransactionSizeCalculator(TxDecoder.Instance);

public static int GetLength(this Transaction tx, bool shouldCountBlobs = true)
public static int GetLength(this Transaction tx)
{
return tx.GetLength(_transactionSizeCalculator, shouldCountBlobs);
return tx.GetLength(_transactionSizeCalculator);
}

public static bool CanPayBaseFee(this Transaction tx, UInt256 currentBaseFee) => tx.MaxFeePerGas >= currentBaseFee;
Expand Down
1 change: 0 additions & 1 deletion src/Nethermind/Nethermind.TxPool/TxPool.cs
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,6 @@ public TxPool(IEthereumEcdsa ecdsa,
_preHashFilters =
[
new NotSupportedTxFilter(txPoolConfig, _logger),
new SizeTxFilter(txPoolConfig, _logger),
new GasLimitTxFilter(_headInfo, txPoolConfig, _logger),
new PriorityFeeTooLowFilter(_logger),
new FeeTooLowFilter(_headInfo, _transactions, _blobTransactions, thereIsPriorityContract, _logger),
Expand Down
4 changes: 0 additions & 4 deletions src/Nethermind/Nethermind.TxPool/TxPoolConfig.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
// SPDX-FileCopyrightText: 2022 Demerzel Solutions Limited
// SPDX-License-Identifier: LGPL-3.0-only

using Nethermind.Core.Extensions;

namespace Nethermind.TxPool
{
public class TxPoolConfig : ITxPoolConfig
Expand All @@ -20,8 +18,6 @@ public class TxPoolConfig : ITxPoolConfig
public int MaxPendingBlobTxsPerSender { get; set; } = 16;
public int HashCacheSize { get; set; } = 512 * 1024;
public long? GasLimit { get; set; } = null;
public long? MaxTxSize { get; set; } = 128.KiB();
public long? MaxBlobTxSize { get; set; } = 1.MiB();
public int? ReportMinutes { get; set; } = null;
}
}
2 changes: 1 addition & 1 deletion src/bench_precompiles
Submodule bench_precompiles updated 96 files
+0 −408 .gitignore
+0 −7 LICENSE.txt
+0 −1 vectors/blsg1add/current/bench-g1add-1.csv
+0 −1 vectors/blsg1msm/current/bench-g1msm-1.csv
+0 −1 vectors/blsg1msm/current/bench-g1msm-10.csv
+0 −1 vectors/blsg1msm/current/bench-g1msm-11.csv
+0 −1 vectors/blsg1msm/current/bench-g1msm-12.csv
+0 −1 vectors/blsg1msm/current/bench-g1msm-128.csv
+0 −1 vectors/blsg1msm/current/bench-g1msm-13.csv
+0 −1 vectors/blsg1msm/current/bench-g1msm-14.csv
+0 −1 vectors/blsg1msm/current/bench-g1msm-15.csv
+0 −1 vectors/blsg1msm/current/bench-g1msm-16.csv
+0 −1 vectors/blsg1msm/current/bench-g1msm-17.csv
+0 −1 vectors/blsg1msm/current/bench-g1msm-18.csv
+0 −1 vectors/blsg1msm/current/bench-g1msm-19.csv
+0 −1 vectors/blsg1msm/current/bench-g1msm-2.csv
+0 −1 vectors/blsg1msm/current/bench-g1msm-20.csv
+0 −1 vectors/blsg1msm/current/bench-g1msm-2048.csv
+0 −1 vectors/blsg1msm/current/bench-g1msm-21.csv
+0 −1 vectors/blsg1msm/current/bench-g1msm-22.csv
+0 −1 vectors/blsg1msm/current/bench-g1msm-23.csv
+0 −1 vectors/blsg1msm/current/bench-g1msm-24.csv
+0 −1 vectors/blsg1msm/current/bench-g1msm-25.csv
+0 −1 vectors/blsg1msm/current/bench-g1msm-256.csv
+0 −1 vectors/blsg1msm/current/bench-g1msm-26.csv
+0 −1 vectors/blsg1msm/current/bench-g1msm-27.csv
+0 −1 vectors/blsg1msm/current/bench-g1msm-28.csv
+0 −1 vectors/blsg1msm/current/bench-g1msm-29.csv
+0 −1 vectors/blsg1msm/current/bench-g1msm-3.csv
+0 −1 vectors/blsg1msm/current/bench-g1msm-30.csv
+0 −1 vectors/blsg1msm/current/bench-g1msm-31.csv
+0 −1 vectors/blsg1msm/current/bench-g1msm-32.csv
+0 −1 vectors/blsg1msm/current/bench-g1msm-4.csv
+0 −1 vectors/blsg1msm/current/bench-g1msm-4096.csv
+0 −1 vectors/blsg1msm/current/bench-g1msm-5.csv
+0 −1 vectors/blsg1msm/current/bench-g1msm-512.csv
+0 −1 vectors/blsg1msm/current/bench-g1msm-6.csv
+0 −1 vectors/blsg1msm/current/bench-g1msm-64.csv
+0 −1 vectors/blsg1msm/current/bench-g1msm-7.csv
+0 −1 vectors/blsg1msm/current/bench-g1msm-8.csv
+0 −1 vectors/blsg1msm/current/bench-g1msm-9.csv
+0 −1 vectors/blsg1mul/current/bench-g1mul-1.csv
+0 −1 vectors/blsg2add/current/bench-g2add-1.csv
+0 −1 vectors/blsg2msm/current/bench-g2msm-1.csv
+0 −1 vectors/blsg2msm/current/bench-g2msm-10.csv
+0 −1 vectors/blsg2msm/current/bench-g2msm-11.csv
+0 −1 vectors/blsg2msm/current/bench-g2msm-12.csv
+0 −1 vectors/blsg2msm/current/bench-g2msm-128.csv
+0 −1 vectors/blsg2msm/current/bench-g2msm-13.csv
+0 −1 vectors/blsg2msm/current/bench-g2msm-14.csv
+0 −1 vectors/blsg2msm/current/bench-g2msm-15.csv
+0 −1 vectors/blsg2msm/current/bench-g2msm-16.csv
+0 −1 vectors/blsg2msm/current/bench-g2msm-17.csv
+0 −1 vectors/blsg2msm/current/bench-g2msm-18.csv
+0 −1 vectors/blsg2msm/current/bench-g2msm-19.csv
+0 −1 vectors/blsg2msm/current/bench-g2msm-2.csv
+0 −1 vectors/blsg2msm/current/bench-g2msm-20.csv
+0 −1 vectors/blsg2msm/current/bench-g2msm-2048.csv
+0 −1 vectors/blsg2msm/current/bench-g2msm-21.csv
+0 −1 vectors/blsg2msm/current/bench-g2msm-22.csv
+0 −1 vectors/blsg2msm/current/bench-g2msm-23.csv
+0 −1 vectors/blsg2msm/current/bench-g2msm-24.csv
+0 −1 vectors/blsg2msm/current/bench-g2msm-25.csv
+0 −1 vectors/blsg2msm/current/bench-g2msm-256.csv
+0 −1 vectors/blsg2msm/current/bench-g2msm-26.csv
+0 −1 vectors/blsg2msm/current/bench-g2msm-27.csv
+0 −1 vectors/blsg2msm/current/bench-g2msm-28.csv
+0 −1 vectors/blsg2msm/current/bench-g2msm-29.csv
+0 −1 vectors/blsg2msm/current/bench-g2msm-3.csv
+0 −1 vectors/blsg2msm/current/bench-g2msm-30.csv
+0 −1 vectors/blsg2msm/current/bench-g2msm-31.csv
+0 −1 vectors/blsg2msm/current/bench-g2msm-32.csv
+0 −1 vectors/blsg2msm/current/bench-g2msm-4.csv
+0 −1 vectors/blsg2msm/current/bench-g2msm-4096.csv
+0 −1 vectors/blsg2msm/current/bench-g2msm-5.csv
+0 −1 vectors/blsg2msm/current/bench-g2msm-512.csv
+0 −1 vectors/blsg2msm/current/bench-g2msm-6.csv
+0 −1 vectors/blsg2msm/current/bench-g2msm-64.csv
+0 −1 vectors/blsg2msm/current/bench-g2msm-7.csv
+0 −1 vectors/blsg2msm/current/bench-g2msm-8.csv
+0 −1 vectors/blsg2msm/current/bench-g2msm-9.csv
+0 −1 vectors/blsg2mul/current/bench-g2mul-1.csv
+0 −1 vectors/blsmapfp2tog2/current/bench-mapfp2-1.csv
+0 −1 vectors/blsmapfptog1/current/bench-mapfp-1.csv
+0 −1 vectors/blspairingcheck/current/bench-pairing-1.csv
+0 −1 vectors/blspairingcheck/current/bench-pairing-2.csv
+0 −1 vectors/blspairingcheck/current/bench-pairing-3.csv
+0 −1 vectors/blspairingcheck/current/bench-pairing-4.csv
+0 −1 vectors/blspairingcheck/current/bench-pairing-5.csv
+0 −1 vectors/blspairingcheck/current/bench-pairing-6.csv
+0 −1 vectors/blspairingcheck/current/bench-pairing-7.csv
+0 −1 vectors/blspairingcheck/current/bench-pairing-8.csv
+0 −37 vectors/ec_recover/current/ecRecover.json
+0 −142 vectors/modexp/current/file.json
+0 −1,642 vectors/point_evaluation/current/fail-pointEvaluation.json
+0 −9 vectors/point_evaluation/current/pointEvaluation.json
2 changes: 1 addition & 1 deletion src/tests
Submodule tests updated 522 files

0 comments on commit df244e8

Please sign in to comment.