@Test void shouldRestartSyncFromFinalizedCheckpointWhenBatchFromNewChainDoesNotLineUp() { final SafeFuture<SyncResult> firstSyncResult = sync.syncToChain(targetChain); assertThat(batches).hasSize(5); final Batch batch0 = batches.get(0); final Batch batch4 = batches.get(4); targetChain = chainWith( new SlotAndBlockRoot(UInt64.valueOf(2000), dataStructureUtil.randomBytes32()), syncSource); final SafeFuture<SyncResult> secondSyncResult = sync.syncToChain(targetChain); assertThat(firstSyncResult).isCompletedWithValue(SyncResult.TARGET_CHANGED); batches.receiveBlocks(batch0); assertThat(batches).hasSize(6); final Batch batch5 = batches.get(5); assertThatBatch(batch5).hasFirstSlot(batch4.getLastSlot().plus(1)); batches.receiveBlocks(batch4, dataStructureUtil.randomSignedBeaconBlock(batch4.getLastSlot())); final List<Batch> originalBatches = batches.clearBatchList(); batches.receiveBlocks(batch5, dataStructureUtil.randomSignedBeaconBlock(batch5.getFirstSlot())); originalBatches.forEach( batch -> { assertThatBatch(batch).isNotContested(); batches.assertNotMarkedInvalid(batch); }); assertThat(batches).hasSize(5); assertThatBatch(batches.get(0)) .hasFirstSlot(compute_start_slot_at_epoch(recentChainData.getFinalizedEpoch()).plus(1)); assertThat(secondSyncResult).isNotDone(); }
@Override public SafeFuture<SyncResult> syncToChain(final TargetChain targetChain) { final SafeFuture<SyncResult> result = new SafeFuture<>(); eventThread.execute(() -> switchSyncTarget(targetChain, result)); return result; }
BatchSync implements Sync { @Override public SafeFuture<SyncResult> syncToChain(final TargetChain targetChain) { final SafeFuture<SyncResult> result = new SafeFuture<>(); eventThread.execute(() -> switchSyncTarget(targetChain, result)); return result; } }
BatchSync implements Sync { @Override public SafeFuture<SyncResult> syncToChain(final TargetChain targetChain) { final SafeFuture<SyncResult> result = new SafeFuture<>(); eventThread.execute(() -> switchSyncTarget(targetChain, result)); return result; } private  BatchSync(
      final EventThread eventThread,
      final RecentChainData recentChainData,
      final BatchChain activeBatches,
      final BatchImporter batchImporter,
      final BatchDataRequester batchDataRequester); }
BatchSync implements Sync { @Override public SafeFuture<SyncResult> syncToChain(final TargetChain targetChain) { final SafeFuture<SyncResult> result = new SafeFuture<>(); eventThread.execute(() -> switchSyncTarget(targetChain, result)); return result; } private  BatchSync(
      final EventThread eventThread,
      final RecentChainData recentChainData,
      final BatchChain activeBatches,
      final BatchImporter batchImporter,
      final BatchDataRequester batchDataRequester); static BatchSync create(
      final EventThread eventThread,
      final RecentChainData recentChainData,
      final BatchImporter batchImporter,
      final BatchFactory batchFactory,
      final UInt64 batchSize); @Override SafeFuture<SyncResult> syncToChain(final TargetChain targetChain); }
BatchSync implements Sync { @Override public SafeFuture<SyncResult> syncToChain(final TargetChain targetChain) { final SafeFuture<SyncResult> result = new SafeFuture<>(); eventThread.execute(() -> switchSyncTarget(targetChain, result)); return result; } private  BatchSync(
      final EventThread eventThread,
      final RecentChainData recentChainData,
      final BatchChain activeBatches,
      final BatchImporter batchImporter,
      final BatchDataRequester batchDataRequester); static BatchSync create(
      final EventThread eventThread,
      final RecentChainData recentChainData,
      final BatchImporter batchImporter,
      final BatchFactory batchFactory,
      final UInt64 batchSize); @Override SafeFuture<SyncResult> syncToChain(final TargetChain targetChain);  }