From 11b6c312720daa5a5ef79bfd9ea6563e6e93b957 Mon Sep 17 00:00:00 2001 From: Sally MacFarlane Date: Thu, 25 Jan 2024 12:03:39 +1000 Subject: [PATCH] Snap sync downloader logging (#6403) * non-static logger for inheriting classes * refactor to some classes and log messages to make snap sync logs make sense * rename SnapsyncMetricsManage * rename FastImportBlocksStep -> ImportBlocksStep Signed-off-by: Sally MacFarlane --------- Signed-off-by: Sally MacFarlane --- ...ger.java => AbstractSyncTargetManager.java} | 6 +++--- .../eth/sync/PipelineChainDownloader.java | 4 ++-- .../CheckpointSyncChainDownloader.java | 6 +++--- .../sync/fastsync/FastSyncChainDownloader.java | 4 ++-- .../FastSyncDownloadPipelineFactory.java | 4 ++-- .../eth/sync/fastsync/FastSyncDownloader.java | 14 ++++++++------ ...rtBlocksStep.java => ImportBlocksStep.java} | 6 +++--- .../eth/sync/fastsync/PivotBlockRetriever.java | 3 +-- .../{FastSyncError.java => SyncError.java} | 2 +- ...stSyncException.java => SyncException.java} | 14 +++++++------- ...rgetManager.java => SyncTargetManager.java} | 8 ++++---- .../sync/fullsync/FullSyncTargetManager.java | 4 ++-- .../eth/sync/snapsync/SnapSyncDownloader.java | 5 ----- ...anager.java => SnapSyncMetricsManager.java} | 8 ++++---- .../sync/snapsync/SnapWorldDownloadState.java | 6 +++--- .../snapsync/SnapWorldStateDownloader.java | 6 +++--- .../request/AccountRangeDataRequest.java | 2 +- ...AccountFlatDatabaseHealingRangeRequest.java | 2 +- .../eth/sync/PipelineChainDownloaderTest.java | 2 +- ...tImportBlocksPercentageCalculationTest.java | 12 ++++++------ .../sync/fastsync/FastSyncDownloaderTest.java | 18 +++++++++--------- ...StepTest.java => ImportBlocksStepTest.java} | 6 +++--- .../sync/fastsync/PivotBlockRetrieverTest.java | 12 ++++++------ .../eth/sync/snapsync/PersistDataStepTest.java | 2 +- .../snapsync/SnapWorldDownloadStateTest.java | 2 +- ...untFlatDatabaseHealingRangeRequestTest.java | 4 ++-- 26 files changed, 79 insertions(+), 83 deletions(-) rename ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/sync/{SyncTargetManager.java => AbstractSyncTargetManager.java} (96%) rename ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/sync/fastsync/{FastImportBlocksStep.java => ImportBlocksStep.java} (96%) rename ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/sync/fastsync/{FastSyncError.java => SyncError.java} (96%) rename ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/sync/fastsync/{FastSyncException.java => SyncException.java} (69%) rename ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/sync/fastsync/{FastSyncTargetManager.java => SyncTargetManager.java} (96%) rename ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/sync/snapsync/{SnapsyncMetricsManager.java => SnapSyncMetricsManager.java} (98%) rename ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/sync/fastsync/{FastImportBlocksStepTest.java => ImportBlocksStepTest.java} (97%) diff --git a/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/sync/SyncTargetManager.java b/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/sync/AbstractSyncTargetManager.java similarity index 96% rename from ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/sync/SyncTargetManager.java rename to ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/sync/AbstractSyncTargetManager.java index c231d13af35..9c6b9327e4b 100644 --- a/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/sync/SyncTargetManager.java +++ b/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/sync/AbstractSyncTargetManager.java @@ -32,9 +32,9 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; -public abstract class SyncTargetManager { +public abstract class AbstractSyncTargetManager { - private static final Logger LOG = LoggerFactory.getLogger(SyncTargetManager.class); + private static final Logger LOG = LoggerFactory.getLogger(AbstractSyncTargetManager.class); private final SynchronizerConfiguration config; private final ProtocolSchedule protocolSchedule; @@ -42,7 +42,7 @@ public abstract class SyncTargetManager { private final EthContext ethContext; private final MetricsSystem metricsSystem; - protected SyncTargetManager( + protected AbstractSyncTargetManager( final SynchronizerConfiguration config, final ProtocolSchedule protocolSchedule, final ProtocolContext protocolContext, diff --git a/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/sync/PipelineChainDownloader.java b/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/sync/PipelineChainDownloader.java index d1c3d008830..5ae78ca280f 100644 --- a/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/sync/PipelineChainDownloader.java +++ b/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/sync/PipelineChainDownloader.java @@ -43,7 +43,7 @@ public class PipelineChainDownloader implements ChainDownloader { private static final Logger LOG = LoggerFactory.getLogger(PipelineChainDownloader.class); static final Duration PAUSE_AFTER_ERROR_DURATION = Duration.ofSeconds(2); private final SyncState syncState; - private final SyncTargetManager syncTargetManager; + private final AbstractSyncTargetManager syncTargetManager; private final DownloadPipelineFactory downloadPipelineFactory; private final EthScheduler scheduler; @@ -55,7 +55,7 @@ public class PipelineChainDownloader implements ChainDownloader { public PipelineChainDownloader( final SyncState syncState, - final SyncTargetManager syncTargetManager, + final AbstractSyncTargetManager syncTargetManager, final DownloadPipelineFactory downloadPipelineFactory, final EthScheduler scheduler, final MetricsSystem metricsSystem) { diff --git a/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/sync/checkpointsync/CheckpointSyncChainDownloader.java b/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/sync/checkpointsync/CheckpointSyncChainDownloader.java index 854972c39fd..356ad0d078d 100644 --- a/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/sync/checkpointsync/CheckpointSyncChainDownloader.java +++ b/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/sync/checkpointsync/CheckpointSyncChainDownloader.java @@ -20,7 +20,7 @@ import org.hyperledger.besu.ethereum.eth.sync.SynchronizerConfiguration; import org.hyperledger.besu.ethereum.eth.sync.fastsync.FastSyncChainDownloader; import org.hyperledger.besu.ethereum.eth.sync.fastsync.FastSyncState; -import org.hyperledger.besu.ethereum.eth.sync.fastsync.FastSyncTargetManager; +import org.hyperledger.besu.ethereum.eth.sync.fastsync.SyncTargetManager; import org.hyperledger.besu.ethereum.eth.sync.state.SyncState; import org.hyperledger.besu.ethereum.mainnet.ProtocolSchedule; import org.hyperledger.besu.ethereum.worldstate.WorldStateStorage; @@ -38,8 +38,8 @@ public static ChainDownloader create( final MetricsSystem metricsSystem, final FastSyncState fastSyncState) { - final FastSyncTargetManager syncTargetManager = - new FastSyncTargetManager( + final SyncTargetManager syncTargetManager = + new SyncTargetManager( config, worldStateStorage, protocolSchedule, diff --git a/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/sync/fastsync/FastSyncChainDownloader.java b/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/sync/fastsync/FastSyncChainDownloader.java index c4034cb87a0..ae49cfdec29 100644 --- a/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/sync/fastsync/FastSyncChainDownloader.java +++ b/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/sync/fastsync/FastSyncChainDownloader.java @@ -38,8 +38,8 @@ public static ChainDownloader create( final MetricsSystem metricsSystem, final FastSyncState fastSyncState) { - final FastSyncTargetManager syncTargetManager = - new FastSyncTargetManager( + final SyncTargetManager syncTargetManager = + new SyncTargetManager( config, worldStateStorage, protocolSchedule, 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 206b76c09a5..f7e42b32f65 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 @@ -136,8 +136,8 @@ public Pipeline createDownloadPipelineForSyncTarget(final SyncT new DownloadBodiesStep(protocolSchedule, ethContext, metricsSystem); final DownloadReceiptsStep downloadReceiptsStep = new DownloadReceiptsStep(ethContext, metricsSystem); - final FastImportBlocksStep importBlockStep = - new FastImportBlocksStep( + final ImportBlocksStep importBlockStep = + new ImportBlocksStep( protocolSchedule, protocolContext, attachedValidationPolicy, diff --git a/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/sync/fastsync/FastSyncDownloader.java b/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/sync/fastsync/FastSyncDownloader.java index b73daa28301..d7c2707af08 100644 --- a/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/sync/fastsync/FastSyncDownloader.java +++ b/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/sync/fastsync/FastSyncDownloader.java @@ -44,7 +44,9 @@ public class FastSyncDownloader { private static final Duration FAST_SYNC_RETRY_DELAY = Duration.ofSeconds(5); - private static final Logger LOG = LoggerFactory.getLogger(FastSyncDownloader.class); + @SuppressWarnings("PrivateStaticFinalLoggers") + protected final Logger LOG = LoggerFactory.getLogger(getClass()); + private final WorldStateStorage worldStateStorage; private final WorldStateDownloader worldStateDownloader; private final TaskCollection taskCollection; @@ -75,7 +77,7 @@ public FastSyncDownloader( public CompletableFuture start() { if (!running.compareAndSet(false, true)) { - throw new IllegalStateException("FastSyncDownloader already running"); + throw new IllegalStateException("SyncDownloader already running"); } LOG.info("Starting sync"); return start(initialFastSyncState); @@ -107,7 +109,7 @@ public CompletableFuture findPivotBlock( protected CompletableFuture handleFailure(final Throwable error) { trailingPeerRequirements = Optional.empty(); Throwable rootCause = ExceptionUtils.rootCause(error); - if (rootCause instanceof FastSyncException) { + if (rootCause instanceof SyncException) { return CompletableFuture.failedFuture(error); } else if (rootCause instanceof StalledDownloadException) { LOG.debug("Stalled sync re-pivoting to newer block."); @@ -120,7 +122,7 @@ protected CompletableFuture handleFailure(final Throwable error) return start(FastSyncState.EMPTY_SYNC_STATE); } else { LOG.error( - "Encountered an unexpected error during fast sync. Restarting sync in " + "Encountered an unexpected error during sync. Restarting sync in " + FAST_SYNC_RETRY_DELAY.getSeconds() + " seconds.", error); @@ -132,7 +134,7 @@ protected CompletableFuture handleFailure(final Throwable error) public void stop() { synchronized (this) { if (running.compareAndSet(true, false)) { - LOG.info("Stopping fast sync"); + LOG.info("Stopping sync"); // Cancelling the world state download will also cause the chain download to be cancelled. worldStateDownloader.cancel(); } @@ -149,7 +151,7 @@ public void deleteFastSyncState() { MoreFiles.deleteRecursively(fastSyncDataDirectory, RecursiveDeleteOption.ALLOW_INSECURE); } } catch (final IOException e) { - LOG.error("Unable to clean up fast sync state", e); + LOG.error("Unable to clean up sync state", e); } } diff --git a/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/sync/fastsync/FastImportBlocksStep.java b/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/sync/fastsync/ImportBlocksStep.java similarity index 96% rename from ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/sync/fastsync/FastImportBlocksStep.java rename to ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/sync/fastsync/ImportBlocksStep.java index c2297faa199..bcf8f00307b 100644 --- a/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/sync/fastsync/FastImportBlocksStep.java +++ b/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/sync/fastsync/ImportBlocksStep.java @@ -33,8 +33,8 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; -public class FastImportBlocksStep implements Consumer> { - private static final Logger LOG = LoggerFactory.getLogger(FastImportBlocksStep.class); +public class ImportBlocksStep implements Consumer> { + private static final Logger LOG = LoggerFactory.getLogger(ImportBlocksStep.class); private static final long PRINT_DELAY = TimeUnit.SECONDS.toMillis(30L); private final ProtocolSchedule protocolSchedule; @@ -46,7 +46,7 @@ public class FastImportBlocksStep implements Consumer> { private OptionalLong logStartBlock = OptionalLong.empty(); private final BlockHeader pivotHeader; - public FastImportBlocksStep( + public ImportBlocksStep( final ProtocolSchedule protocolSchedule, final ProtocolContext protocolContext, final ValidationPolicy headerValidationPolicy, diff --git a/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/sync/fastsync/PivotBlockRetriever.java b/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/sync/fastsync/PivotBlockRetriever.java index e20bb16799c..6ddd7db9012 100644 --- a/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/sync/fastsync/PivotBlockRetriever.java +++ b/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/sync/fastsync/PivotBlockRetriever.java @@ -156,8 +156,7 @@ private void handleContestedPivotBlock(final long contestedBlockNumber) { || pivotBlockNumber.get() <= BlockHeader.GENESIS_BLOCK_NUMBER) { LOG.info("Max retries reached, cancel pivot block download."); // Pivot block selection has failed - result.completeExceptionally( - new FastSyncException(FastSyncError.PIVOT_BLOCK_HEADER_MISMATCH)); + result.completeExceptionally(new SyncException(SyncError.PIVOT_BLOCK_HEADER_MISMATCH)); return; } else { LOG.info("Move pivot block back to {} and retry.", pivotBlockNumber); diff --git a/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/sync/fastsync/FastSyncError.java b/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/sync/fastsync/SyncError.java similarity index 96% rename from ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/sync/fastsync/FastSyncError.java rename to ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/sync/fastsync/SyncError.java index d8361733574..d1277ddfdc1 100644 --- a/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/sync/fastsync/FastSyncError.java +++ b/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/sync/fastsync/SyncError.java @@ -14,7 +14,7 @@ */ package org.hyperledger.besu.ethereum.eth.sync.fastsync; -public enum FastSyncError { +public enum SyncError { NO_PEERS_AVAILABLE, PIVOT_BLOCK_HEADER_MISMATCH, UNEXPECTED_ERROR diff --git a/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/sync/fastsync/FastSyncException.java b/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/sync/fastsync/SyncException.java similarity index 69% rename from ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/sync/fastsync/FastSyncException.java rename to ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/sync/fastsync/SyncException.java index 79baf02c43c..72e928dc18b 100644 --- a/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/sync/fastsync/FastSyncException.java +++ b/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/sync/fastsync/SyncException.java @@ -14,21 +14,21 @@ */ package org.hyperledger.besu.ethereum.eth.sync.fastsync; -public class FastSyncException extends RuntimeException { +public class SyncException extends RuntimeException { - private final FastSyncError error; + private final SyncError error; - public FastSyncException(final FastSyncError error) { - super("Fast sync failed: " + error); + public SyncException(final SyncError error) { + super("Sync failed: " + error); this.error = error; } - public FastSyncError getError() { + public SyncError getError() { return error; } - public FastSyncException(final Throwable error) { + public SyncException(final Throwable error) { super(error); - this.error = FastSyncError.UNEXPECTED_ERROR; + this.error = SyncError.UNEXPECTED_ERROR; } } diff --git a/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/sync/fastsync/FastSyncTargetManager.java b/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/sync/fastsync/SyncTargetManager.java similarity index 96% rename from ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/sync/fastsync/FastSyncTargetManager.java rename to ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/sync/fastsync/SyncTargetManager.java index 11dc8c1af61..d0e0a1f0fd0 100644 --- a/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/sync/fastsync/FastSyncTargetManager.java +++ b/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/sync/fastsync/SyncTargetManager.java @@ -23,7 +23,7 @@ import org.hyperledger.besu.ethereum.eth.manager.EthContext; import org.hyperledger.besu.ethereum.eth.manager.EthPeer; import org.hyperledger.besu.ethereum.eth.manager.EthPeers; -import org.hyperledger.besu.ethereum.eth.sync.SyncTargetManager; +import org.hyperledger.besu.ethereum.eth.sync.AbstractSyncTargetManager; import org.hyperledger.besu.ethereum.eth.sync.SynchronizerConfiguration; import org.hyperledger.besu.ethereum.eth.sync.tasks.RetryingGetHeaderFromPeerByNumberTask; import org.hyperledger.besu.ethereum.mainnet.ProtocolSchedule; @@ -39,8 +39,8 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; -public class FastSyncTargetManager extends SyncTargetManager { - private static final Logger LOG = LoggerFactory.getLogger(FastSyncTargetManager.class); +public class SyncTargetManager extends AbstractSyncTargetManager { + private static final Logger LOG = LoggerFactory.getLogger(SyncTargetManager.class); private final WorldStateStorage worldStateStorage; private final ProtocolSchedule protocolSchedule; @@ -53,7 +53,7 @@ public class FastSyncTargetManager extends SyncTargetManager { private final int logDebugRepeatDelay = 15; private final int logInfoRepeatDelay = 120; - public FastSyncTargetManager( + public SyncTargetManager( final SynchronizerConfiguration config, final WorldStateStorage worldStateStorage, final ProtocolSchedule protocolSchedule, diff --git a/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/sync/fullsync/FullSyncTargetManager.java b/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/sync/fullsync/FullSyncTargetManager.java index 43c2cfa19c5..ee3d36a31ab 100644 --- a/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/sync/fullsync/FullSyncTargetManager.java +++ b/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/sync/fullsync/FullSyncTargetManager.java @@ -21,7 +21,7 @@ import org.hyperledger.besu.ethereum.core.BlockHeader; import org.hyperledger.besu.ethereum.eth.manager.EthContext; import org.hyperledger.besu.ethereum.eth.manager.EthPeer; -import org.hyperledger.besu.ethereum.eth.sync.SyncTargetManager; +import org.hyperledger.besu.ethereum.eth.sync.AbstractSyncTargetManager; import org.hyperledger.besu.ethereum.eth.sync.SynchronizerConfiguration; import org.hyperledger.besu.ethereum.eth.sync.state.SyncTarget; import org.hyperledger.besu.ethereum.mainnet.ProtocolSchedule; @@ -34,7 +34,7 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; -class FullSyncTargetManager extends SyncTargetManager { +class FullSyncTargetManager extends AbstractSyncTargetManager { private static final Logger LOG = LoggerFactory.getLogger(FullSyncTargetManager.class); private final ProtocolContext protocolContext; diff --git a/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/sync/snapsync/SnapSyncDownloader.java b/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/sync/snapsync/SnapSyncDownloader.java index ac409513156..32c2dc23c0b 100644 --- a/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/sync/snapsync/SnapSyncDownloader.java +++ b/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/sync/snapsync/SnapSyncDownloader.java @@ -26,13 +26,8 @@ import java.nio.file.Path; import java.util.concurrent.CompletableFuture; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - public class SnapSyncDownloader extends FastSyncDownloader { - private static final Logger LOG = LoggerFactory.getLogger(SnapSyncDownloader.class); - public SnapSyncDownloader( final FastSyncActions fastSyncActions, final WorldStateStorage worldStateStorage, diff --git a/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/sync/snapsync/SnapsyncMetricsManager.java b/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/sync/snapsync/SnapSyncMetricsManager.java similarity index 98% rename from ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/sync/snapsync/SnapsyncMetricsManager.java rename to ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/sync/snapsync/SnapSyncMetricsManager.java index 25af2e4262e..da7607de7fd 100644 --- a/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/sync/snapsync/SnapsyncMetricsManager.java +++ b/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/sync/snapsync/SnapSyncMetricsManager.java @@ -15,7 +15,7 @@ package org.hyperledger.besu.ethereum.eth.sync.snapsync; import static io.netty.util.internal.ObjectUtil.checkNonEmpty; -import static org.hyperledger.besu.ethereum.eth.sync.snapsync.SnapsyncMetricsManager.Step.HEAL_TRIE; +import static org.hyperledger.besu.ethereum.eth.sync.snapsync.SnapSyncMetricsManager.Step.HEAL_TRIE; import org.hyperledger.besu.ethereum.eth.manager.EthContext; import org.hyperledger.besu.metrics.BesuMetricCategory; @@ -37,9 +37,9 @@ import org.slf4j.LoggerFactory; /** Manages the metrics related to the SnapSync process. */ -public class SnapsyncMetricsManager { +public class SnapSyncMetricsManager { - private static final Logger LOG = LoggerFactory.getLogger(SnapsyncMetricsManager.class); + private static final Logger LOG = LoggerFactory.getLogger(SnapSyncMetricsManager.class); private static final long PRINT_DELAY = TimeUnit.MINUTES.toMillis(1); private final MetricsSystem metricsSystem; @@ -79,7 +79,7 @@ public class SnapsyncMetricsManager { private long lastNotifyTimestamp; - public SnapsyncMetricsManager(final MetricsSystem metricsSystem, final EthContext ethContext) { + public SnapSyncMetricsManager(final MetricsSystem metricsSystem, final EthContext ethContext) { this.metricsSystem = metricsSystem; this.ethContext = ethContext; percentageProgress = new AtomicReference<>(new BigDecimal(0)); diff --git a/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/sync/snapsync/SnapWorldDownloadState.java b/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/sync/snapsync/SnapWorldDownloadState.java index dd7481cdd00..76d31562106 100644 --- a/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/sync/snapsync/SnapWorldDownloadState.java +++ b/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/sync/snapsync/SnapWorldDownloadState.java @@ -83,7 +83,7 @@ public class SnapWorldDownloadState extends WorldDownloadState private OptionalLong blockObserverId; // metrics around the snapsync - private final SnapsyncMetricsManager metricsManager; + private final SnapSyncMetricsManager metricsManager; public SnapWorldDownloadState( final WorldStateStorage worldStateStorage, @@ -93,7 +93,7 @@ public SnapWorldDownloadState( final InMemoryTasksPriorityQueues pendingRequests, final int maxRequestsWithoutProgress, final long minMillisBeforeStalling, - final SnapsyncMetricsManager metricsManager, + final SnapSyncMetricsManager metricsManager, final Clock clock) { super( worldStateStorage, @@ -400,7 +400,7 @@ public synchronized Task dequeueStorageFlatDatabaseHealingReque __ -> {}); } - public SnapsyncMetricsManager getMetricsManager() { + public SnapSyncMetricsManager getMetricsManager() { return metricsManager; } diff --git a/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/sync/snapsync/SnapWorldStateDownloader.java b/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/sync/snapsync/SnapWorldStateDownloader.java index 313d5a3770f..5b2f51d87ba 100644 --- a/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/sync/snapsync/SnapWorldStateDownloader.java +++ b/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/sync/snapsync/SnapWorldStateDownloader.java @@ -14,7 +14,7 @@ */ package org.hyperledger.besu.ethereum.eth.sync.snapsync; -import static org.hyperledger.besu.ethereum.eth.sync.snapsync.SnapsyncMetricsManager.Step.DOWNLOAD; +import static org.hyperledger.besu.ethereum.eth.sync.snapsync.SnapSyncMetricsManager.Step.DOWNLOAD; import static org.hyperledger.besu.ethereum.eth.sync.snapsync.request.SnapDataRequest.createAccountRangeDataRequest; import org.hyperledger.besu.datatypes.Hash; @@ -133,8 +133,8 @@ public CompletableFuture run( stateRoot, snapTaskCollection.size()); - final SnapsyncMetricsManager snapsyncMetricsManager = - new SnapsyncMetricsManager(metricsSystem, ethContext); + final SnapSyncMetricsManager snapsyncMetricsManager = + new SnapSyncMetricsManager(metricsSystem, ethContext); final SnapWorldDownloadState newDownloadState = new SnapWorldDownloadState( diff --git a/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/sync/snapsync/request/AccountRangeDataRequest.java b/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/sync/snapsync/request/AccountRangeDataRequest.java index ea5c25ec0de..acf8adc4aa9 100644 --- a/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/sync/snapsync/request/AccountRangeDataRequest.java +++ b/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/sync/snapsync/request/AccountRangeDataRequest.java @@ -18,7 +18,7 @@ import static org.hyperledger.besu.ethereum.eth.sync.snapsync.RangeManager.MIN_RANGE; import static org.hyperledger.besu.ethereum.eth.sync.snapsync.RangeManager.findNewBeginElementInRange; import static org.hyperledger.besu.ethereum.eth.sync.snapsync.RequestType.ACCOUNT_RANGE; -import static org.hyperledger.besu.ethereum.eth.sync.snapsync.SnapsyncMetricsManager.Step.DOWNLOAD; +import static org.hyperledger.besu.ethereum.eth.sync.snapsync.SnapSyncMetricsManager.Step.DOWNLOAD; import static org.hyperledger.besu.ethereum.eth.sync.snapsync.StackTrie.FlatDatabaseUpdater.noop; import org.hyperledger.besu.datatypes.Hash; diff --git a/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/sync/snapsync/request/heal/AccountFlatDatabaseHealingRangeRequest.java b/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/sync/snapsync/request/heal/AccountFlatDatabaseHealingRangeRequest.java index 7de77607450..526a0e9c58b 100644 --- a/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/sync/snapsync/request/heal/AccountFlatDatabaseHealingRangeRequest.java +++ b/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/sync/snapsync/request/heal/AccountFlatDatabaseHealingRangeRequest.java @@ -16,7 +16,7 @@ import static org.hyperledger.besu.ethereum.eth.sync.snapsync.RangeManager.MAX_RANGE; import static org.hyperledger.besu.ethereum.eth.sync.snapsync.RangeManager.MIN_RANGE; -import static org.hyperledger.besu.ethereum.eth.sync.snapsync.SnapsyncMetricsManager.Step.HEAL_FLAT; +import static org.hyperledger.besu.ethereum.eth.sync.snapsync.SnapSyncMetricsManager.Step.HEAL_FLAT; import org.hyperledger.besu.datatypes.Hash; import org.hyperledger.besu.ethereum.eth.sync.snapsync.RangeManager; diff --git a/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/sync/PipelineChainDownloaderTest.java b/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/sync/PipelineChainDownloaderTest.java index babacfc5e0f..91d33a11145 100644 --- a/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/sync/PipelineChainDownloaderTest.java +++ b/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/sync/PipelineChainDownloaderTest.java @@ -52,7 +52,7 @@ @ExtendWith(MockitoExtension.class) public class PipelineChainDownloaderTest { - @Mock private SyncTargetManager syncTargetManager; + @Mock private AbstractSyncTargetManager syncTargetManager; @Mock private DownloadPipelineFactory downloadPipelineFactory; @Mock private EthScheduler scheduler; @Mock private Pipeline downloadPipeline; diff --git a/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/sync/fastsync/FastImportBlocksPercentageCalculationTest.java b/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/sync/fastsync/FastImportBlocksPercentageCalculationTest.java index a68194abbe7..ed5303897ae 100644 --- a/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/sync/fastsync/FastImportBlocksPercentageCalculationTest.java +++ b/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/sync/fastsync/FastImportBlocksPercentageCalculationTest.java @@ -22,11 +22,11 @@ public class FastImportBlocksPercentageCalculationTest { @Test public void blocksPercent_calculations() { - assertThat(FastImportBlocksStep.getBlocksPercent(1, 1)).isEqualByComparingTo(100l); - assertThat(FastImportBlocksStep.getBlocksPercent(1, 100)).isEqualByComparingTo(1l); - assertThat(FastImportBlocksStep.getBlocksPercent(0, 100)).isEqualByComparingTo(0l); - assertThat(FastImportBlocksStep.getBlocksPercent(99, 0)).isEqualByComparingTo(0l); - assertThat(FastImportBlocksStep.getBlocksPercent(1, 1000)).isEqualByComparingTo(0l); - assertThat(FastImportBlocksStep.getBlocksPercent(1, 10000)).isEqualByComparingTo(0l); + assertThat(ImportBlocksStep.getBlocksPercent(1, 1)).isEqualByComparingTo(100l); + assertThat(ImportBlocksStep.getBlocksPercent(1, 100)).isEqualByComparingTo(1l); + assertThat(ImportBlocksStep.getBlocksPercent(0, 100)).isEqualByComparingTo(0l); + assertThat(ImportBlocksStep.getBlocksPercent(99, 0)).isEqualByComparingTo(0l); + assertThat(ImportBlocksStep.getBlocksPercent(1, 1000)).isEqualByComparingTo(0l); + assertThat(ImportBlocksStep.getBlocksPercent(1, 10000)).isEqualByComparingTo(0l); } } diff --git a/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/sync/fastsync/FastSyncDownloaderTest.java b/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/sync/fastsync/FastSyncDownloaderTest.java index 632fed6ede1..c05770e6d72 100644 --- a/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/sync/fastsync/FastSyncDownloaderTest.java +++ b/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/sync/fastsync/FastSyncDownloaderTest.java @@ -150,11 +150,11 @@ public void shouldResumeFastSync() { @Test public void shouldAbortIfSelectPivotBlockFails() { when(fastSyncActions.selectPivotBlock(FastSyncState.EMPTY_SYNC_STATE)) - .thenThrow(new FastSyncException(FastSyncError.UNEXPECTED_ERROR)); + .thenThrow(new SyncException(SyncError.UNEXPECTED_ERROR)); final CompletableFuture result = downloader.start(); - assertCompletedExceptionally(result, FastSyncError.UNEXPECTED_ERROR); + assertCompletedExceptionally(result, SyncError.UNEXPECTED_ERROR); verify(fastSyncActions).selectPivotBlock(FastSyncState.EMPTY_SYNC_STATE); verifyNoMoreInteractions(fastSyncActions); @@ -191,10 +191,10 @@ public void shouldAbortIfWorldStateDownloadFails() { assertThat(result).isNotDone(); - worldStateFuture.completeExceptionally(new FastSyncException(FastSyncError.NO_PEERS_AVAILABLE)); + worldStateFuture.completeExceptionally(new SyncException(SyncError.NO_PEERS_AVAILABLE)); verify(chainDownloader).cancel(); chainFuture.completeExceptionally(new CancellationException()); - assertCompletedExceptionally(result, FastSyncError.NO_PEERS_AVAILABLE); + assertCompletedExceptionally(result, SyncError.NO_PEERS_AVAILABLE); assertThat(chainFuture).isCancelled(); } @@ -229,8 +229,8 @@ public void shouldAbortIfChainDownloadFails() { assertThat(result).isNotDone(); - chainFuture.completeExceptionally(new FastSyncException(FastSyncError.NO_PEERS_AVAILABLE)); - assertCompletedExceptionally(result, FastSyncError.NO_PEERS_AVAILABLE); + chainFuture.completeExceptionally(new SyncException(SyncError.NO_PEERS_AVAILABLE)); + assertCompletedExceptionally(result, SyncError.NO_PEERS_AVAILABLE); assertThat(worldStateFuture).isCancelled(); } @@ -536,13 +536,13 @@ public void shouldNotHaveTrailingPeerRequirementsAfterDownloadCompletes() { } private void assertCompletedExceptionally( - final CompletableFuture future, final FastSyncError expectedError) { + final CompletableFuture future, final SyncError expectedError) { assertThat(future).isCompletedExceptionally(); future.exceptionally( actualError -> { assertThat(actualError) - .isInstanceOf(FastSyncException.class) - .extracting(ex -> ((FastSyncException) ex).getError()) + .isInstanceOf(SyncException.class) + .extracting(ex -> ((SyncException) ex).getError()) .isEqualTo(expectedError); return null; }); diff --git a/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/sync/fastsync/FastImportBlocksStepTest.java b/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/sync/fastsync/ImportBlocksStepTest.java similarity index 97% rename from ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/sync/fastsync/FastImportBlocksStepTest.java rename to ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/sync/fastsync/ImportBlocksStepTest.java index 448608df715..70c9e10eba6 100644 --- a/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/sync/fastsync/FastImportBlocksStepTest.java +++ b/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/sync/fastsync/ImportBlocksStepTest.java @@ -45,7 +45,7 @@ import org.mockito.junit.jupiter.MockitoExtension; @ExtendWith(MockitoExtension.class) -public class FastImportBlocksStepTest { +public class ImportBlocksStepTest { @Mock private ProtocolSchedule protocolSchedule; @Mock private ProtocolSpec protocolSpec; @@ -56,7 +56,7 @@ public class FastImportBlocksStepTest { @Mock private BlockHeader pivotHeader; private final BlockDataGenerator gen = new BlockDataGenerator(); - private FastImportBlocksStep importBlocksStep; + private ImportBlocksStep importBlocksStep; @BeforeEach public void setUp() { @@ -66,7 +66,7 @@ public void setUp() { when(ommerValidationPolicy.getValidationModeForNextBlock()).thenReturn(LIGHT); importBlocksStep = - new FastImportBlocksStep( + new ImportBlocksStep( protocolSchedule, protocolContext, validationPolicy, diff --git a/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/sync/fastsync/PivotBlockRetrieverTest.java b/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/sync/fastsync/PivotBlockRetrieverTest.java index 7e539c8a596..723c5afe65f 100644 --- a/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/sync/fastsync/PivotBlockRetrieverTest.java +++ b/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/sync/fastsync/PivotBlockRetrieverTest.java @@ -376,9 +376,9 @@ public void shouldRetryWhenPeersDisagreeOnPivot_exceedMaxRetries( assertThat(future).isCompletedExceptionally(); assertThatThrownBy(future::get) - .hasRootCauseInstanceOf(FastSyncException.class) - .extracting(e -> ((FastSyncException) ExceptionUtils.rootCause(e)).getError()) - .isEqualTo(FastSyncError.PIVOT_BLOCK_HEADER_MISMATCH); + .hasRootCauseInstanceOf(SyncException.class) + .extracting(e -> ((SyncException) ExceptionUtils.rootCause(e)).getError()) + .isEqualTo(SyncError.PIVOT_BLOCK_HEADER_MISMATCH); } @ParameterizedTest @@ -406,9 +406,9 @@ public void shouldRetryWhenPeersDisagreeOnPivot_pivotInvalidOnRetry( assertThat(future).isCompletedExceptionally(); assertThatThrownBy(future::get) - .hasRootCauseInstanceOf(FastSyncException.class) - .extracting(e -> ((FastSyncException) ExceptionUtils.rootCause(e)).getError()) - .isEqualTo(FastSyncError.PIVOT_BLOCK_HEADER_MISMATCH); + .hasRootCauseInstanceOf(SyncException.class) + .extracting(e -> ((SyncException) ExceptionUtils.rootCause(e)).getError()) + .isEqualTo(SyncError.PIVOT_BLOCK_HEADER_MISMATCH); } private Responder responderForFakeBlocks(final long... blockNumbers) { diff --git a/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/sync/snapsync/PersistDataStepTest.java b/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/sync/snapsync/PersistDataStepTest.java index dedce974c49..3b8bc7f2193 100644 --- a/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/sync/snapsync/PersistDataStepTest.java +++ b/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/sync/snapsync/PersistDataStepTest.java @@ -51,7 +51,7 @@ public class PersistDataStepTest { @BeforeEach public void setUp() { - when(downloadState.getMetricsManager()).thenReturn(mock(SnapsyncMetricsManager.class)); + when(downloadState.getMetricsManager()).thenReturn(mock(SnapSyncMetricsManager.class)); } @Test diff --git a/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/sync/snapsync/SnapWorldDownloadStateTest.java b/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/sync/snapsync/SnapWorldDownloadStateTest.java index b275e60e273..d10e2b21e29 100644 --- a/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/sync/snapsync/SnapWorldDownloadStateTest.java +++ b/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/sync/snapsync/SnapWorldDownloadStateTest.java @@ -82,7 +82,7 @@ public class SnapWorldDownloadStateTest { private final SnapSyncProcessState snapSyncState = mock(SnapSyncProcessState.class); private final SnapSyncStatePersistenceManager snapContext = mock(SnapSyncStatePersistenceManager.class); - private final SnapsyncMetricsManager metricsManager = mock(SnapsyncMetricsManager.class); + private final SnapSyncMetricsManager metricsManager = mock(SnapSyncMetricsManager.class); private final Blockchain blockchain = mock(Blockchain.class); private final DynamicPivotBlockSelector dynamicPivotBlockManager = mock(DynamicPivotBlockSelector.class); diff --git a/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/sync/snapsync/request/heal/AccountFlatDatabaseHealingRangeRequestTest.java b/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/sync/snapsync/request/heal/AccountFlatDatabaseHealingRangeRequestTest.java index 40db311c4f1..ebd8c24a3d4 100644 --- a/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/sync/snapsync/request/heal/AccountFlatDatabaseHealingRangeRequestTest.java +++ b/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/sync/snapsync/request/heal/AccountFlatDatabaseHealingRangeRequestTest.java @@ -19,9 +19,9 @@ import org.hyperledger.besu.ethereum.core.TrieGenerator; import org.hyperledger.besu.ethereum.eth.sync.snapsync.RangeManager; import org.hyperledger.besu.ethereum.eth.sync.snapsync.SnapSyncConfiguration; +import org.hyperledger.besu.ethereum.eth.sync.snapsync.SnapSyncMetricsManager; import org.hyperledger.besu.ethereum.eth.sync.snapsync.SnapSyncProcessState; import org.hyperledger.besu.ethereum.eth.sync.snapsync.SnapWorldDownloadState; -import org.hyperledger.besu.ethereum.eth.sync.snapsync.SnapsyncMetricsManager; import org.hyperledger.besu.ethereum.eth.sync.snapsync.request.SnapDataRequest; import org.hyperledger.besu.ethereum.proof.WorldStateProofProvider; import org.hyperledger.besu.ethereum.storage.StorageProvider; @@ -67,7 +67,7 @@ public class AccountFlatDatabaseHealingRangeRequestTest { @BeforeEach public void setup() { Mockito.when(downloadState.getMetricsManager()) - .thenReturn(Mockito.mock(SnapsyncMetricsManager.class)); + .thenReturn(Mockito.mock(SnapSyncMetricsManager.class)); Mockito.when(downloadState.getAccountsHealingList()).thenReturn(new HashSet<>()); }