From 1b9922f8b8c75e5054fd68efbf6bb8c9c7a945e9 Mon Sep 17 00:00:00 2001 From: Matilda Clerke Date: Fri, 25 Oct 2024 09:17:33 +1100 Subject: [PATCH] 7311: Wrap peer task system usage in ethScheduler call to match other usages Signed-off-by: Matilda Clerke --- .../CheckpointDownloadBlockStep.java | 46 +++++++++---------- 1 file changed, 23 insertions(+), 23 deletions(-) diff --git a/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/sync/checkpointsync/CheckpointDownloadBlockStep.java b/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/sync/checkpointsync/CheckpointDownloadBlockStep.java index 70e9958bea..bf32358d83 100644 --- a/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/sync/checkpointsync/CheckpointDownloadBlockStep.java +++ b/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/sync/checkpointsync/CheckpointDownloadBlockStep.java @@ -84,31 +84,31 @@ public class CheckpointDownloadBlockStep { final PeerTaskResult peerTaskResult) { final Block block = peerTaskResult.getResult(); if (synchronizerConfiguration.isPeerTaskSystemEnabled()) { - CompletableFuture> futureReceipts = new CompletableFuture<>(); - GetReceiptsFromPeerTask task = - new GetReceiptsFromPeerTask( - List.of(block.getHeader()), new BodyValidator(), currentProtocolSpecSupplier); - PeerTaskExecutorResult>> executorResult = - peerTaskExecutor.execute(task); + return ethContext.getScheduler().scheduleServiceTask(() -> { + GetReceiptsFromPeerTask task = + new GetReceiptsFromPeerTask( + List.of(block.getHeader()), new BodyValidator(), currentProtocolSpecSupplier); + PeerTaskExecutorResult>> executorResult = + peerTaskExecutor.execute(task); - if (executorResult.responseCode() == PeerTaskExecutorResponseCode.SUCCESS) { - List transactionReceipts = - executorResult - .result() - .map((map) -> map.get(block.getHeader())) - .orElseThrow( - () -> - new IllegalStateException("PeerTask response code was success, but empty")); - if (block.getBody().getTransactions().size() != transactionReceipts.size()) { - throw new IllegalStateException( - "PeerTask response code was success, but incorrect number of receipts returned"); + if (executorResult.responseCode() == PeerTaskExecutorResponseCode.SUCCESS) { + List transactionReceipts = + executorResult + .result() + .map((map) -> map.get(block.getHeader())) + .orElseThrow( + () -> + new IllegalStateException("PeerTask response code was success, but empty")); + if (block.getBody().getTransactions().size() != transactionReceipts.size()) { + throw new IllegalStateException( + "PeerTask response code was success, but incorrect number of receipts returned"); + } + BlockWithReceipts blockWithReceipts = new BlockWithReceipts(block, transactionReceipts); + return CompletableFuture.completedFuture(Optional.of(blockWithReceipts)); + } else { + return CompletableFuture.completedFuture(Optional.empty()); } - BlockWithReceipts blockWithReceipts = new BlockWithReceipts(block, transactionReceipts); - futureReceipts.complete(Optional.of(blockWithReceipts)); - } else { - futureReceipts.complete(Optional.empty()); - } - return futureReceipts; + }); } else { final org.hyperledger.besu.ethereum.eth.manager.task.GetReceiptsFromPeerTask