From 240a4811f4c01d96a974d6d0d483653a8c256477 Mon Sep 17 00:00:00 2001 From: garyschulte Date: Wed, 14 Sep 2022 09:29:11 -0700 Subject: [PATCH] Bugfix concurrent legacy transaction eviction in BaseFee txpool (#4390) * make static range comparator safe for non-1559 transactions Signed-off-by: garyschulte * spotless, and rebase Signed-off-by: garyschulte Signed-off-by: garyschulte Co-authored-by: Sally MacFarlane --- .../sorter/BaseFeePendingTransactionsSorter.java | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/transactions/sorter/BaseFeePendingTransactionsSorter.java b/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/transactions/sorter/BaseFeePendingTransactionsSorter.java index 2b2d0e8eca..be5a064b3c 100644 --- a/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/transactions/sorter/BaseFeePendingTransactionsSorter.java +++ b/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/transactions/sorter/BaseFeePendingTransactionsSorter.java @@ -72,8 +72,8 @@ public class BaseFeePendingTransactionsSorter extends AbstractPendingTransaction transactionInfo .getTransaction() .getMaxPriorityFeePerGas() - // safe to .get() here because only 1559 txs can be in the static range - .get() + // just in case we attempt to compare non-1559 transaction + .orElse(Wei.ZERO) .getAsBigInteger() .longValue()) .thenComparing(TransactionInfo::getAddedToPoolAt) @@ -104,7 +104,10 @@ public class BaseFeePendingTransactionsSorter extends AbstractPendingTransaction pendingTransactions.remove(transaction.getHash()); if (removedTransactionInfo != null) { if (!prioritizedTransactionsDynamicRange.remove(removedTransactionInfo)) - prioritizedTransactionsStaticRange.remove(removedTransactionInfo); + removedTransactionInfo + .getTransaction() + .getMaxPriorityFeePerGas() + .ifPresent(__ -> prioritizedTransactionsStaticRange.remove(removedTransactionInfo)); removeTransactionTrackedBySenderAndNonce(transaction); incrementTransactionRemovedCounter( removedTransactionInfo.isReceivedFromLocalSource(), addedToBlock);