From cb41867b9d2f5c625e6fe275890e0ef984ed3536 Mon Sep 17 00:00:00 2001 From: Simon Dudley Date: Fri, 5 Apr 2024 15:24:47 +1000 Subject: [PATCH] Add debug logging to see why we stop downloading from peer (#6885) Signed-off-by: Simon Dudley Signed-off-by: amsmota --- .../FastSyncDownloadPipelineFactory.java | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/sync/fastsync/FastSyncDownloadPipelineFactory.java b/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/sync/fastsync/FastSyncDownloadPipelineFactory.java index f7e42b32f65..a458e9bd51a 100644 --- a/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/sync/fastsync/FastSyncDownloadPipelineFactory.java +++ b/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/sync/fastsync/FastSyncDownloadPipelineFactory.java @@ -47,7 +47,12 @@ import java.util.concurrent.CompletionStage; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + public class FastSyncDownloadPipelineFactory implements DownloadPipelineFactory { + private static final Logger LOG = LoggerFactory.getLogger(FastSyncDownloadPipelineFactory.class); + protected final SynchronizerConfiguration syncConfig; protected final ProtocolSchedule protocolSchedule; protected final ProtocolContext protocolContext; @@ -172,6 +177,18 @@ protected BlockHeader getCommonAncestor(final SyncTarget syncTarget) { protected boolean shouldContinueDownloadingFromPeer( final EthPeer peer, final BlockHeader lastRoundHeader) { final BlockHeader pivotBlockHeader = fastSyncState.getPivotBlockHeader().get(); - return !peer.isDisconnected() && lastRoundHeader.getNumber() < pivotBlockHeader.getNumber(); + final boolean shouldContinue = + !peer.isDisconnected() && lastRoundHeader.getNumber() < pivotBlockHeader.getNumber(); + + if (!shouldContinue && peer.isDisconnected()) { + LOG.debug("Stopping chain download due to disconnected peer {}", peer); + } else if (!shouldContinue && lastRoundHeader.getNumber() >= pivotBlockHeader.getNumber()) { + LOG.debug( + "Stopping chain download as lastRoundHeader={} is not less than pivotBlockHeader={} for peer {}", + lastRoundHeader.getNumber(), + pivotBlockHeader.getNumber(), + peer); + } + return shouldContinue; } }