Skip to content
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

Fix sending new single tx p2p update #6895

Merged
merged 3 commits into from
Apr 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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 @@ -175,7 +175,25 @@ public void should_send_up_to_MaxCount_hashes_in_one_NewPooledTransactionHashesM

_handler.SendNewTransactions(txs, false);

_session.Received(1).DeliverMessage(Arg.Is<NewPooledTransactionHashesMessage68>(m => m.Hashes.Count == txCount));
_session.Received(1).DeliverMessage(Arg.Is<NewPooledTransactionHashesMessage68>(m =>
m.Hashes.Count == txCount &&
m.Sizes.Count == txCount &&
m.Types.Count == txCount));
}

[Test]
public void should_send_blob_tx_announcement_in_NewPooledTransactionHashesMessage68()
{
Transaction tx = Build.A.Transaction.WithNonce((UInt256)0).WithShardBlobTxTypeAndFields().SignedAndResolved().TestObject;

_handler.SendNewTransaction(tx);

_session.Received(1).DeliverMessage(Arg.Is<NewPooledTransactionHashesMessage68>(m =>
m.Hashes.Count == 1 &&
m.Sizes.Count == 1 &&
m.Types.Count == 1 &&
m.Hashes[0] == tx.Hash &&
(TxType)m.Types[0] == tx.Type));
}

[TestCase(NewPooledTransactionHashesMessage68.MaxCount - 1)]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
using Nethermind.Core.Extensions;
using Nethermind.Int256;
using Nethermind.Logging;
using Nethermind.Network.P2P.Messages;
using Nethermind.Network.P2P.Subprotocols.Eth.V62;
using Nethermind.Network.P2P.Subprotocols.Eth.V62.Messages;
using Nethermind.Network.P2P.Subprotocols.Eth.V63.Messages;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,8 @@ protected override void SendNewTransactionCore(Transaction tx)
else
{
SendMessage(
new ArrayPoolList<byte>((byte)tx.Type),
new ArrayPoolList<int>(tx.GetLength()),
new ArrayPoolList<byte>(1) { (byte)tx.Type },
new ArrayPoolList<int>(1) { tx.GetLength() },
new ArrayPoolList<Hash256>(1) { tx.Hash }
);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,24 +1,16 @@
// SPDX-FileCopyrightText: 2023 Demerzel Solutions Limited
// SPDX-License-Identifier: LGPL-3.0-only

using System;
using System.Collections.Generic;
using Nethermind.Core;
using Nethermind.Core.Crypto;
using Nethermind.Logging;

namespace Nethermind.TxPool.Collections;

public class BlobTxDistinctSortedPool : TxDistinctSortedPool
public class BlobTxDistinctSortedPool(int capacity, IComparer<Transaction> comparer, ILogManager logManager)
: TxDistinctSortedPool(capacity, comparer, logManager)
{
private readonly ILogger _logger;

public BlobTxDistinctSortedPool(int capacity, IComparer<Transaction> comparer, ILogManager logManager)
: base(capacity, comparer, logManager)
{
_logger = logManager?.GetClassLogger() ?? throw new ArgumentNullException(nameof(logManager));
}

protected override IComparer<Transaction> GetReplacementComparer(IComparer<Transaction> comparer)
=> comparer.GetBlobReplacementComparer();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,11 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;

using Nethermind.Core;
using Nethermind.Core.Collections;
using Nethermind.Core.Crypto;
using Nethermind.Core.Threading;
using Nethermind.Int256;
using Nethermind.Logging;
using Nethermind.TxPool.Comparison;
Expand Down Expand Up @@ -73,7 +72,7 @@ protected override void UpdateGroup(AddressAsKey groupKey, EnhancedSortedSet<Tra

public void UpdatePool(IAccountStateProvider accounts, Func<Address, AccountStruct, EnhancedSortedSet<Transaction>, IEnumerable<(Transaction Tx, UInt256? changedGasBottleneck)>> changingElements)
{
using var lockRelease = Lock.Acquire();
using McsLock.Disposable lockRelease = Lock.Acquire();

EnsureCapacity();
foreach ((AddressAsKey address, EnhancedSortedSet<Transaction> bucket) in _buckets)
Expand Down Expand Up @@ -122,7 +121,7 @@ private void UpdateGroupNonLocked(Address groupKey, AccountStruct groupValue, En

public void UpdateGroup(Address groupKey, AccountStruct groupValue, Func<Address, AccountStruct, EnhancedSortedSet<Transaction>, IEnumerable<(Transaction Tx, UInt256? changedGasBottleneck)>> changingElements)
{
using var lockRelease = Lock.Acquire();
using McsLock.Disposable lockRelease = Lock.Acquire();

ArgumentNullException.ThrowIfNull(groupKey);
if (_buckets.TryGetValue(groupKey, out EnhancedSortedSet<Transaction>? bucket))
Expand Down