From 74579b58b1498355981f42fb6105a9a59ef66d96 Mon Sep 17 00:00:00 2001 From: Ameziane H Date: Wed, 6 Sep 2023 16:14:22 +0200 Subject: [PATCH 1/3] Fix issue 5824 - Duplicate key errors in EthScheduler-Transactions Signed-off-by: Ameziane H --- .../eth/transactions/TransactionPool.java | 3 ++- .../TransactionPoolLondonTest.java | 21 +++++++++++++++++++ 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/transactions/TransactionPool.java b/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/transactions/TransactionPool.java index 41978bcb932..9f5cc273b29 100644 --- a/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/transactions/TransactionPool.java +++ b/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/transactions/TransactionPool.java @@ -218,7 +218,8 @@ public Map> addRemoteTransactio addedTransactions.add(transaction); } return result; - })); + }, + (transaction1, transaction2) -> transaction1)); LOG_FOR_REPLAY .atTrace() diff --git a/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/transactions/TransactionPoolLondonTest.java b/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/transactions/TransactionPoolLondonTest.java index fc03f9805ce..fca1bb8ef84 100644 --- a/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/transactions/TransactionPoolLondonTest.java +++ b/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/transactions/TransactionPoolLondonTest.java @@ -18,6 +18,7 @@ import static java.util.Collections.emptyList; import static java.util.stream.Collectors.toList; import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.assertThatCode; import static org.mockito.Mockito.when; import org.hyperledger.besu.config.StubGenesisConfigOptions; @@ -53,6 +54,7 @@ import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.ValueSource; +@SuppressWarnings("unchecked") public class TransactionPoolLondonTest extends AbstractTransactionPoolTest { private static final Wei BASE_FEE_FLOOR = Wei.of(7L); @@ -252,6 +254,25 @@ public void shouldAcceptLocal1559TxsWhenMaxFeePerGasIsAtLeastEqualToMinMinGasPri .isEqualTo(1); } + @Test + public void addRemoteTransactionsShouldNotTriggerIllegalStateException() { + final Transaction transaction1 = createTransaction(1, Wei.of(7L)); + final Transaction transaction2 = createTransaction(2, Wei.of(7L)); + final Transaction transaction3 = createTransaction(2, Wei.of(7L)); + final Transaction transaction4 = createTransaction(3, Wei.of(7L)); + + givenTransactionIsValid(transaction1); + givenTransactionIsValid(transaction2); + givenTransactionIsValid(transaction3); + givenTransactionIsValid(transaction4); + + assertThatCode( + () -> + transactionPool.addRemoteTransactions( + List.of(transaction1, transaction2, transaction3, transaction4))) + .doesNotThrowAnyException(); + } + private int add1559TxAndGetPendingTxsCount( final Wei genesisBaseFee, final Wei minGasPrice, From ea403bbd2a75f5ff62263860bd57def13d152b9a Mon Sep 17 00:00:00 2001 From: Ameziane H Date: Wed, 6 Sep 2023 16:32:32 +0200 Subject: [PATCH 2/3] Add a changelog entry Signed-off-by: Ameziane H --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index ccca9652cf4..6be0a80994e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,7 @@ ### Bug Fixes - do not create ignorable storage on revert storage-variables subcommand [#5830](https://github.com/hyperledger/besu/pull/5830) +- fix duplicate key errors in EthScheduler-Transactions [#5857](https://github.com/hyperledger/besu/pull/5857) ### Download Links From 1b4fe6bebf192a734ab796adeaa1e4961564486f Mon Sep 17 00:00:00 2001 From: Ameziane H Date: Fri, 8 Sep 2023 15:07:38 +0200 Subject: [PATCH 3/3] Change method naming Signed-off-by: Ameziane H --- .../ethereum/eth/transactions/TransactionPoolLondonTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/transactions/TransactionPoolLondonTest.java b/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/transactions/TransactionPoolLondonTest.java index fca1bb8ef84..8773d9a6452 100644 --- a/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/transactions/TransactionPoolLondonTest.java +++ b/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/transactions/TransactionPoolLondonTest.java @@ -255,7 +255,7 @@ public void shouldAcceptLocal1559TxsWhenMaxFeePerGasIsAtLeastEqualToMinMinGasPri } @Test - public void addRemoteTransactionsShouldNotTriggerIllegalStateException() { + public void addRemoteTransactionsShouldAllowDuplicates() { final Transaction transaction1 = createTransaction(1, Wei.of(7L)); final Transaction transaction2 = createTransaction(2, Wei.of(7L)); final Transaction transaction3 = createTransaction(2, Wei.of(7L));