diff --git a/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/sync/BlockPropagationManager.java b/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/sync/BlockPropagationManager.java index 7c7ee28eb30..c08346f400a 100644 --- a/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/sync/BlockPropagationManager.java +++ b/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/sync/BlockPropagationManager.java @@ -263,6 +263,7 @@ private void handleNewBlockHashesFromNetwork(final EthMessage message) { @SuppressWarnings("unused") private CompletableFuture retrieveMissingAnnouncedBlock(final long blockNumber) { + LOG.info("retrieveMissingAnnouncedBlock " + blockNumber); final List peers = ethContext.getEthPeers().streamBestPeers().collect(Collectors.toList()); final GetBlockFromPeersTask getBlockTask = diff --git a/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/sync/state/PendingBlocksManagerTest.java b/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/sync/state/PendingBlocksManagerTest.java index 18e1315d56a..8c867c7d254 100644 --- a/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/sync/state/PendingBlocksManagerTest.java +++ b/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/sync/state/PendingBlocksManagerTest.java @@ -245,4 +245,18 @@ public void shouldReplaceLowestPriorityBlockWhenCacheIsFull() { } assertThat(pendingBlocksManager.contains(reorgBlock.getHash())).isTrue(); } + + @Test + public void shouldReturnLowestBlockByNumber() { + final BlockDataGenerator gen = new BlockDataGenerator(); + final Block parentBlock = gen.block(); + final Block childBlock = gen.nextBlock(parentBlock); + final Block childBlock2 = gen.nextBlock(parentBlock); + + pendingBlocksManager.registerPendingBlock(parentBlock, NODE_ID_1); + pendingBlocksManager.registerPendingBlock(childBlock, NODE_ID_1); + pendingBlocksManager.registerPendingBlock(childBlock2, NODE_ID_1); + + assertThat(pendingBlocksManager.lowestAnnouncedBlock()).contains(parentBlock.getHeader()); + } }