From 44b72693bdd455521ab0ec8627fb20deb05600e5 Mon Sep 17 00:00:00 2001 From: Marcin Sobczak Date: Thu, 10 Oct 2024 16:23:30 +0200 Subject: [PATCH 1/2] Fix recreation of light blob tx collection --- .../Nethermind.TxPool/Collections/BlobTxDistinctSortedPool.cs | 3 +-- .../Collections/PersistentBlobTxDistinctSortedPool.cs | 3 +-- src/Nethermind/Nethermind.TxPool/Collections/SortedPool.cs | 2 +- 3 files changed, 3 insertions(+), 5 deletions(-) diff --git a/src/Nethermind/Nethermind.TxPool/Collections/BlobTxDistinctSortedPool.cs b/src/Nethermind/Nethermind.TxPool/Collections/BlobTxDistinctSortedPool.cs index 9f814668b0e..e924b9e5733 100644 --- a/src/Nethermind/Nethermind.TxPool/Collections/BlobTxDistinctSortedPool.cs +++ b/src/Nethermind/Nethermind.TxPool/Collections/BlobTxDistinctSortedPool.cs @@ -1,7 +1,6 @@ // SPDX-FileCopyrightText: 2023 Demerzel Solutions Limited // SPDX-License-Identifier: LGPL-3.0-only -using System.Collections.Concurrent; using System.Collections.Generic; using System.Diagnostics.CodeAnalysis; using System.Runtime.InteropServices; @@ -65,7 +64,7 @@ protected override bool InsertCore(ValueHash256 key, Transaction value, AddressA return false; } - protected void AddToBlobIndex(Transaction blobTx) + private void AddToBlobIndex(Transaction blobTx) { if (blobTx.BlobVersionedHashes?.Length > 0) { diff --git a/src/Nethermind/Nethermind.TxPool/Collections/PersistentBlobTxDistinctSortedPool.cs b/src/Nethermind/Nethermind.TxPool/Collections/PersistentBlobTxDistinctSortedPool.cs index 26e3d7ad826..c093800dc11 100644 --- a/src/Nethermind/Nethermind.TxPool/Collections/PersistentBlobTxDistinctSortedPool.cs +++ b/src/Nethermind/Nethermind.TxPool/Collections/PersistentBlobTxDistinctSortedPool.cs @@ -36,9 +36,8 @@ private void RecreateLightTxCollectionAndCache(ITxStorage blobTxStorage) long startTime = Stopwatch.GetTimestamp(); foreach (LightTransaction lightBlobTx in blobTxStorage.GetAll()) { - if (base.TryInsert(lightBlobTx.Hash, lightBlobTx, out _)) + if (base.InsertCore(lightBlobTx.Hash, lightBlobTx, lightBlobTx.SenderAddress!)) { - AddToBlobIndex(lightBlobTx); numberOfTxsInDb++; numberOfBlobsInDb += lightBlobTx.BlobVersionedHashes?.Length ?? 0; } diff --git a/src/Nethermind/Nethermind.TxPool/Collections/SortedPool.cs b/src/Nethermind/Nethermind.TxPool/Collections/SortedPool.cs index c8db34851c7..f5ebedda4d4 100644 --- a/src/Nethermind/Nethermind.TxPool/Collections/SortedPool.cs +++ b/src/Nethermind/Nethermind.TxPool/Collections/SortedPool.cs @@ -352,7 +352,7 @@ public bool TryGetValue(TKey key, [NotNullWhen(true)] out TValue? value) /// Element to insert. /// Element removed because of exceeding capacity /// If element was inserted. False if element was already present in pool. - public virtual bool TryInsert(TKey key, TValue value, out TValue? removed) + public bool TryInsert(TKey key, TValue value, out TValue? removed) { using var lockRelease = Lock.Acquire(); From b1ab5648a0cc90cca235b39873c933aec51562ac Mon Sep 17 00:00:00 2001 From: Marcin Sobczak Date: Thu, 10 Oct 2024 16:26:40 +0200 Subject: [PATCH 2/2] add fuse --- .../Collections/PersistentBlobTxDistinctSortedPool.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Nethermind/Nethermind.TxPool/Collections/PersistentBlobTxDistinctSortedPool.cs b/src/Nethermind/Nethermind.TxPool/Collections/PersistentBlobTxDistinctSortedPool.cs index c093800dc11..f17b0f51866 100644 --- a/src/Nethermind/Nethermind.TxPool/Collections/PersistentBlobTxDistinctSortedPool.cs +++ b/src/Nethermind/Nethermind.TxPool/Collections/PersistentBlobTxDistinctSortedPool.cs @@ -36,7 +36,8 @@ private void RecreateLightTxCollectionAndCache(ITxStorage blobTxStorage) long startTime = Stopwatch.GetTimestamp(); foreach (LightTransaction lightBlobTx in blobTxStorage.GetAll()) { - if (base.InsertCore(lightBlobTx.Hash, lightBlobTx, lightBlobTx.SenderAddress!)) + if (lightBlobTx.SenderAddress is not null + && base.InsertCore(lightBlobTx.Hash, lightBlobTx, lightBlobTx.SenderAddress)) { numberOfTxsInDb++; numberOfBlobsInDb += lightBlobTx.BlobVersionedHashes?.Length ?? 0;