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 65e6f84636..a7015369db 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 @@ -17,6 +17,7 @@ package org.hyperledger.besu.ethereum.eth.sync.fastsync; import static java.util.Collections.emptyList; import static java.util.stream.Collectors.toList; +import org.hyperledger.besu.datatypes.Hash; import org.hyperledger.besu.ethereum.core.Block; import org.hyperledger.besu.ethereum.core.BlockHeader; import org.hyperledger.besu.ethereum.core.BlockWithReceipts; @@ -80,6 +81,10 @@ public class DownloadReceiptsStep private CompletableFuture>> getReceiptsWithPeerTaskSystem(final List headers) { Map> getReceipts = new HashMap<>(); + headers.stream() + .filter(header -> header.getReceiptsRoot().equals(Hash.EMPTY_TRIE_HASH)) + .forEach(header -> getReceipts.put(header, emptyList())); + headers.removeAll(getReceipts.keySet()); do { GetReceiptsFromPeerTask task = new GetReceiptsFromPeerTask(headers, new BodyValidator(), currentProtocolSpecSupplier); diff --git a/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/sync/tasks/GetReceiptsForHeadersTask.java b/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/sync/tasks/GetReceiptsForHeadersTask.java index 58c4d3a7af..3096eb1ac9 100644 --- a/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/sync/tasks/GetReceiptsForHeadersTask.java +++ b/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/sync/tasks/GetReceiptsForHeadersTask.java @@ -65,6 +65,7 @@ public class GetReceiptsForHeadersTask completeEmptyReceipts(headers); } + // TODO: This is only used in test code and should be removed public static GetReceiptsForHeadersTask forHeaders( final EthContext ethContext, final List headers, diff --git a/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/sync/fastsync/DownloadReceiptsStepTest.java b/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/sync/fastsync/DownloadReceiptsStepTest.java index 6261d397dd..caa31bdf5c 100644 --- a/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/sync/fastsync/DownloadReceiptsStepTest.java +++ b/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/sync/fastsync/DownloadReceiptsStepTest.java @@ -18,6 +18,7 @@ import static java.util.Arrays.asList; import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.Mockito.mock; +import org.hyperledger.besu.datatypes.Hash; import org.hyperledger.besu.ethereum.ProtocolContext; import org.hyperledger.besu.ethereum.chain.MutableBlockchain; import org.hyperledger.besu.ethereum.core.Block; @@ -156,6 +157,7 @@ public class DownloadReceiptsStepTest { final Block block = Mockito.mock(Block.class); final BlockHeader blockHeader = Mockito.mock(BlockHeader.class); Mockito.when(block.getHeader()).thenAnswer((invocationOnMock) -> blockHeader); + Mockito.when(blockHeader.getReceiptsRoot()).thenReturn(Hash.fromHexStringLenient("DEADBEEF")); final BlockBody blockBody = Mockito.mock(BlockBody.class); Mockito.when(block.getBody()).thenAnswer((invocationOnMock) -> blockBody); Mockito.when(blockBody.getTransactions())