From 1c25ac533716e084f903dde105dc6a8db4fbf3d5 Mon Sep 17 00:00:00 2001 From: Matilda Clerke Date: Wed, 2 Oct 2024 14:53:48 +1000 Subject: [PATCH] 7311: Fix broken workflow Signed-off-by: Matilda Clerke --- .../sync/fastsync/DownloadReceiptsStep.java | 25 +++++-------------- 1 file changed, 6 insertions(+), 19 deletions(-) diff --git a/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/sync/fastsync/DownloadReceiptsStep.java b/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/sync/fastsync/DownloadReceiptsStep.java index 5b13b8f2b9..d1fc60b937 100644 --- a/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/sync/fastsync/DownloadReceiptsStep.java +++ b/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/sync/fastsync/DownloadReceiptsStep.java @@ -32,10 +32,10 @@ import org.hyperledger.besu.ethereum.mainnet.BodyValidator; import org.hyperledger.besu.plugin.services.MetricsSystem; import java.util.ArrayList; +import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.concurrent.CompletableFuture; -import java.util.concurrent.ConcurrentHashMap; import java.util.function.Function; public class DownloadReceiptsStep @@ -62,10 +62,10 @@ public class DownloadReceiptsStep if (synchronizerConfiguration.isPeerTaskSystemEnabled()) { return CompletableFuture.supplyAsync( () -> { - final Map> getReceipts = - new ConcurrentHashMap>(); List blockWithReceiptsList = new ArrayList<>(headers.size()); do { + final Map> getReceipts = + new HashMap>(); GetReceiptsFromPeerTask getReceiptsFromPeerTask = new GetReceiptsFromPeerTask(headers, new BodyValidator()); PeerTaskExecutorResult>> getReceiptsResult = @@ -75,13 +75,7 @@ public class DownloadReceiptsStep Map> receiptsResult = getReceiptsResult.result().get(); for (BlockHeader blockHeader : receiptsResult.keySet()) { - getReceipts.merge( - blockHeader, - receiptsResult.get(blockHeader), - (initialReceipts, newReceipts) -> { - throw new IllegalStateException( - "Unexpectedly got receipts for block header already populated!"); - }); + getReceipts.put(blockHeader, receiptsResult.get(blockHeader)); } } // remove all the headers we found receipts for @@ -91,15 +85,7 @@ public class DownloadReceiptsStep } while (!headers.isEmpty()); // verify that all blocks have receipts - if (!blocks.stream() - .filter( - (b) -> - blockWithReceiptsList.stream() - .map((bwr) -> bwr.getBlock()) - .toList() - .contains(b)) - .toList() - .isEmpty()) { + if (blocks.size() != blockWithReceiptsList.size()) { throw new IllegalStateException("Not all blocks have been matched to receipts!"); } return blockWithReceiptsList; @@ -115,6 +101,7 @@ public class DownloadReceiptsStep private List combineBlocksAndReceipts( final List blocks, final Map> receiptsByHeader) { return blocks.stream() + .filter((b) -> receiptsByHeader.keySet().contains(b.getHeader())) .map( block -> { final List receipts =