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 <macfarla.github@gmail.com>

---------

Signed-off-by: Sally MacFarlane <macfarla.github@gmail.com>
pull/6466/head
Sally MacFarlane 10 months ago committed by GitHub
parent a1a5b20983
commit 11b6c31272
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 6
      ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/sync/AbstractSyncTargetManager.java
  2. 4
      ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/sync/PipelineChainDownloader.java
  3. 6
      ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/sync/checkpointsync/CheckpointSyncChainDownloader.java
  4. 4
      ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/sync/fastsync/FastSyncChainDownloader.java
  5. 4
      ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/sync/fastsync/FastSyncDownloadPipelineFactory.java
  6. 14
      ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/sync/fastsync/FastSyncDownloader.java
  7. 6
      ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/sync/fastsync/ImportBlocksStep.java
  8. 3
      ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/sync/fastsync/PivotBlockRetriever.java
  9. 2
      ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/sync/fastsync/SyncError.java
  10. 14
      ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/sync/fastsync/SyncException.java
  11. 8
      ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/sync/fastsync/SyncTargetManager.java
  12. 4
      ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/sync/fullsync/FullSyncTargetManager.java
  13. 5
      ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/sync/snapsync/SnapSyncDownloader.java
  14. 8
      ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/sync/snapsync/SnapSyncMetricsManager.java
  15. 6
      ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/sync/snapsync/SnapWorldDownloadState.java
  16. 6
      ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/sync/snapsync/SnapWorldStateDownloader.java
  17. 2
      ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/sync/snapsync/request/AccountRangeDataRequest.java
  18. 2
      ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/sync/snapsync/request/heal/AccountFlatDatabaseHealingRangeRequest.java
  19. 2
      ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/sync/PipelineChainDownloaderTest.java
  20. 12
      ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/sync/fastsync/FastImportBlocksPercentageCalculationTest.java
  21. 18
      ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/sync/fastsync/FastSyncDownloaderTest.java
  22. 6
      ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/sync/fastsync/ImportBlocksStepTest.java
  23. 12
      ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/sync/fastsync/PivotBlockRetrieverTest.java
  24. 2
      ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/sync/snapsync/PersistDataStepTest.java
  25. 2
      ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/sync/snapsync/SnapWorldDownloadStateTest.java
  26. 4
      ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/sync/snapsync/request/heal/AccountFlatDatabaseHealingRangeRequestTest.java

@ -32,9 +32,9 @@ import java.util.concurrent.CompletableFuture;
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,

@ -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) {

@ -20,7 +20,7 @@ import org.hyperledger.besu.ethereum.eth.sync.PipelineChainDownloader;
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 class CheckpointSyncChainDownloader extends FastSyncChainDownloader {
final MetricsSystem metricsSystem,
final FastSyncState fastSyncState) {
final FastSyncTargetManager syncTargetManager =
new FastSyncTargetManager(
final SyncTargetManager syncTargetManager =
new SyncTargetManager(
config,
worldStateStorage,
protocolSchedule,

@ -38,8 +38,8 @@ public class FastSyncChainDownloader {
final MetricsSystem metricsSystem,
final FastSyncState fastSyncState) {
final FastSyncTargetManager syncTargetManager =
new FastSyncTargetManager(
final SyncTargetManager syncTargetManager =
new SyncTargetManager(
config,
worldStateStorage,
protocolSchedule,

@ -136,8 +136,8 @@ public class FastSyncDownloadPipelineFactory implements DownloadPipelineFactory
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,

@ -44,7 +44,9 @@ public class FastSyncDownloader<REQUEST> {
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<REQUEST> taskCollection;
@ -75,7 +77,7 @@ public class FastSyncDownloader<REQUEST> {
public CompletableFuture<FastSyncState> 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 class FastSyncDownloader<REQUEST> {
protected CompletableFuture<FastSyncState> 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 @@ public class FastSyncDownloader<REQUEST> {
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 @@ public class FastSyncDownloader<REQUEST> {
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 class FastSyncDownloader<REQUEST> {
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);
}
}

@ -33,8 +33,8 @@ import com.google.common.annotations.VisibleForTesting;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class FastImportBlocksStep implements Consumer<List<BlockWithReceipts>> {
private static final Logger LOG = LoggerFactory.getLogger(FastImportBlocksStep.class);
public class ImportBlocksStep implements Consumer<List<BlockWithReceipts>> {
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<List<BlockWithReceipts>> {
private OptionalLong logStartBlock = OptionalLong.empty();
private final BlockHeader pivotHeader;
public FastImportBlocksStep(
public ImportBlocksStep(
final ProtocolSchedule protocolSchedule,
final ProtocolContext protocolContext,
final ValidationPolicy headerValidationPolicy,

@ -156,8 +156,7 @@ public class PivotBlockRetriever {
|| 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);

@ -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

@ -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;
}
}

@ -23,7 +23,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.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 java.util.concurrent.atomic.AtomicBoolean;
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,

@ -21,7 +21,7 @@ import org.hyperledger.besu.ethereum.chain.MutableBlockchain;
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 java.util.concurrent.CompletableFuture;
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;

@ -26,13 +26,8 @@ import org.hyperledger.besu.services.tasks.TaskCollection;
import java.nio.file.Path;
import java.util.concurrent.CompletableFuture;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class SnapSyncDownloader extends FastSyncDownloader<SnapDataRequest> {
private static final Logger LOG = LoggerFactory.getLogger(SnapSyncDownloader.class);
public SnapSyncDownloader(
final FastSyncActions fastSyncActions,
final WorldStateStorage worldStateStorage,

@ -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.Logger;
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));

@ -83,7 +83,7 @@ public class SnapWorldDownloadState extends WorldDownloadState<SnapDataRequest>
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 class SnapWorldDownloadState extends WorldDownloadState<SnapDataRequest>
final InMemoryTasksPriorityQueues<SnapDataRequest> pendingRequests,
final int maxRequestsWithoutProgress,
final long minMillisBeforeStalling,
final SnapsyncMetricsManager metricsManager,
final SnapSyncMetricsManager metricsManager,
final Clock clock) {
super(
worldStateStorage,
@ -400,7 +400,7 @@ public class SnapWorldDownloadState extends WorldDownloadState<SnapDataRequest>
__ -> {});
}
public SnapsyncMetricsManager getMetricsManager() {
public SnapSyncMetricsManager getMetricsManager() {
return metricsManager;
}

@ -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 class SnapWorldStateDownloader implements WorldStateDownloader {
stateRoot,
snapTaskCollection.size());
final SnapsyncMetricsManager snapsyncMetricsManager =
new SnapsyncMetricsManager(metricsSystem, ethContext);
final SnapSyncMetricsManager snapsyncMetricsManager =
new SnapSyncMetricsManager(metricsSystem, ethContext);
final SnapWorldDownloadState newDownloadState =
new SnapWorldDownloadState(

@ -18,7 +18,7 @@ import static org.hyperledger.besu.ethereum.eth.sync.snapsync.RangeManager.MAX_R
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;

@ -16,7 +16,7 @@ package org.hyperledger.besu.ethereum.eth.sync.snapsync.request.heal;
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;

@ -52,7 +52,7 @@ import org.mockito.junit.jupiter.MockitoExtension;
@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;

@ -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);
}
}

@ -150,11 +150,11 @@ public class FastSyncDownloaderTest {
@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<FastSyncState> 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 class FastSyncDownloaderTest {
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 class FastSyncDownloaderTest {
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 class FastSyncDownloaderTest {
}
private <T> void assertCompletedExceptionally(
final CompletableFuture<T> future, final FastSyncError expectedError) {
final CompletableFuture<T> 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;
});

@ -45,7 +45,7 @@ import org.mockito.Mock;
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 class FastImportBlocksStepTest {
when(ommerValidationPolicy.getValidationModeForNextBlock()).thenReturn(LIGHT);
importBlocksStep =
new FastImportBlocksStep(
new ImportBlocksStep(
protocolSchedule,
protocolContext,
validationPolicy,

@ -376,9 +376,9 @@ public class PivotBlockRetrieverTest {
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 class PivotBlockRetrieverTest {
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) {

@ -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

@ -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);

@ -19,9 +19,9 @@ import org.hyperledger.besu.ethereum.core.InMemoryKeyValueStorageProvider;
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<>());
}

Loading…
Cancel
Save