From 4bf18f347301122ad6c864d99b7d50d2d328394c Mon Sep 17 00:00:00 2001 From: "stefan.pingel@consensys.net" Date: Thu, 20 Jun 2024 13:18:44 +1000 Subject: [PATCH] updates after review Signed-off-by: stefan.pingel@consensys.net --- .../manager/snap/RetryingGetAccountRangeFromPeerTask.java | 2 +- .../besu/ethereum/eth/sync/fastsync/SyncTargetManager.java | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/manager/snap/RetryingGetAccountRangeFromPeerTask.java b/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/manager/snap/RetryingGetAccountRangeFromPeerTask.java index 25d93eddff2..36d6b75e6ee 100644 --- a/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/manager/snap/RetryingGetAccountRangeFromPeerTask.java +++ b/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/manager/snap/RetryingGetAccountRangeFromPeerTask.java @@ -30,7 +30,7 @@ public class RetryingGetAccountRangeFromPeerTask extends AbstractRetryingPeerTask { - public static final int MAX_RETRIES = 5; + public static final int MAX_RETRIES = 4; private final EthContext ethContext; private final Bytes32 startKeyHash; private final Bytes32 endKeyHash; diff --git a/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/sync/fastsync/SyncTargetManager.java b/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/sync/fastsync/SyncTargetManager.java index a4cf4b14ec9..2a667de5b6d 100644 --- a/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/sync/fastsync/SyncTargetManager.java +++ b/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/sync/fastsync/SyncTargetManager.java @@ -42,6 +42,7 @@ public class SyncTargetManager extends AbstractSyncTargetManager { private static final Logger LOG = LoggerFactory.getLogger(SyncTargetManager.class); + private static final int SECONDS_PER_REQUEST = 6; // 5 seconds timeout + 1 second wait between retries private final WorldStateStorageCoordinator worldStateStorageCoordinator; private final ProtocolSchedule protocolSchedule; @@ -124,8 +125,8 @@ private CompletableFuture> confirmPivotBlockHeader(final EthPe task.assignPeer(bestPeer); return ethContext .getScheduler() - .timeout(task, Duration.ofSeconds(MAX_QUERY_RETRIES_PER_PEER * 5 + 1)) - // 5 because there is a 5 sec timout per request + // Task is a retrying task. Make sure that the timeout is long enough to allow for retries. + .timeout(task, Duration.ofSeconds(MAX_QUERY_RETRIES_PER_PEER * SECONDS_PER_REQUEST + 2)) .thenCompose( result -> { if (peerHasDifferentPivotBlock(result)) {