Bugfix concurrent legacy transaction eviction in BaseFee txpool (#4390)

* make static range comparator safe for non-1559 transactions

Signed-off-by: garyschulte <garyschulte@gmail.com>

* spotless, and rebase

Signed-off-by: garyschulte <garyschulte@gmail.com>

Signed-off-by: garyschulte <garyschulte@gmail.com>
Co-authored-by: Sally MacFarlane <macfarla.github@gmail.com>
pull/4410/head
garyschulte 2 years ago committed by GitHub
parent 4691bfdba7
commit 240a4811f4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 9
      ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/transactions/sorter/BaseFeePendingTransactionsSorter.java

@ -72,8 +72,8 @@ public class BaseFeePendingTransactionsSorter extends AbstractPendingTransaction
transactionInfo transactionInfo
.getTransaction() .getTransaction()
.getMaxPriorityFeePerGas() .getMaxPriorityFeePerGas()
// safe to .get() here because only 1559 txs can be in the static range // just in case we attempt to compare non-1559 transaction
.get() .orElse(Wei.ZERO)
.getAsBigInteger() .getAsBigInteger()
.longValue()) .longValue())
.thenComparing(TransactionInfo::getAddedToPoolAt) .thenComparing(TransactionInfo::getAddedToPoolAt)
@ -104,7 +104,10 @@ public class BaseFeePendingTransactionsSorter extends AbstractPendingTransaction
pendingTransactions.remove(transaction.getHash()); pendingTransactions.remove(transaction.getHash());
if (removedTransactionInfo != null) { if (removedTransactionInfo != null) {
if (!prioritizedTransactionsDynamicRange.remove(removedTransactionInfo)) if (!prioritizedTransactionsDynamicRange.remove(removedTransactionInfo))
prioritizedTransactionsStaticRange.remove(removedTransactionInfo); removedTransactionInfo
.getTransaction()
.getMaxPriorityFeePerGas()
.ifPresent(__ -> prioritizedTransactionsStaticRange.remove(removedTransactionInfo));
removeTransactionTrackedBySenderAndNonce(transaction); removeTransactionTrackedBySenderAndNonce(transaction);
incrementTransactionRemovedCounter( incrementTransactionRemovedCounter(
removedTransactionInfo.isReceivedFromLocalSource(), addedToBlock); removedTransactionInfo.isReceivedFromLocalSource(), addedToBlock);

Loading…
Cancel
Save