@Test public void regenerateStateForBlock_failOnMissingBlocks() { testGeneratorWithMissingBlock( (generator, missingBlock) -> { SafeFuture<SignedBlockAndState> result = generator.regenerateStateForBlock(missingBlock.getRoot()); assertThatThrownBy(result::get) .hasCauseInstanceOf(IllegalStateException.class) .hasMessageContaining( "Failed to retrieve 1 / 3 blocks building on state at slot 0: " + missingBlock.getRoot()); }); }
public SafeFuture<SignedBlockAndState> regenerateStateForBlock(final Bytes32 blockRoot) { final int blockCount = blockTree.size(); LOG.info("Regenerate state for block {} by replaying {} blocks", blockRoot, blockCount); final long startTime = System.currentTimeMillis(); return chainStateGenerator .generateTargetState(blockRoot) .thenPeek( result -> LOG.info( "Completed regeneration of block {} at slot {} by replaying {} blocks. Took {}ms", blockRoot, result.getSlot(), blockCount, System.currentTimeMillis() - startTime)); }
StateGenerator { public SafeFuture<SignedBlockAndState> regenerateStateForBlock(final Bytes32 blockRoot) { final int blockCount = blockTree.size(); LOG.info("Regenerate state for block {} by replaying {} blocks", blockRoot, blockCount); final long startTime = System.currentTimeMillis(); return chainStateGenerator .generateTargetState(blockRoot) .thenPeek( result -> LOG.info( "Completed regeneration of block {} at slot {} by replaying {} blocks. Took {}ms", blockRoot, result.getSlot(), blockCount, System.currentTimeMillis() - startTime)); } }
StateGenerator { public SafeFuture<SignedBlockAndState> regenerateStateForBlock(final Bytes32 blockRoot) { final int blockCount = blockTree.size(); LOG.info("Regenerate state for block {} by replaying {} blocks", blockRoot, blockCount); final long startTime = System.currentTimeMillis(); return chainStateGenerator .generateTargetState(blockRoot) .thenPeek( result -> LOG.info( "Completed regeneration of block {} at slot {} by replaying {} blocks. Took {}ms", blockRoot, result.getSlot(), blockCount, System.currentTimeMillis() - startTime)); } private  StateGenerator(
      final HashTree blockTree,
      final BlockProvider blockProvider,
      final AsyncChainStateGenerator chainStateGenerator,
      final StateCache stateCache,
      final int blockBatchSize); }
StateGenerator { public SafeFuture<SignedBlockAndState> regenerateStateForBlock(final Bytes32 blockRoot) { final int blockCount = blockTree.size(); LOG.info("Regenerate state for block {} by replaying {} blocks", blockRoot, blockCount); final long startTime = System.currentTimeMillis(); return chainStateGenerator .generateTargetState(blockRoot) .thenPeek( result -> LOG.info( "Completed regeneration of block {} at slot {} by replaying {} blocks. Took {}ms", blockRoot, result.getSlot(), blockCount, System.currentTimeMillis() - startTime)); } private  StateGenerator(
      final HashTree blockTree,
      final BlockProvider blockProvider,
      final AsyncChainStateGenerator chainStateGenerator,
      final StateCache stateCache,
      final int blockBatchSize); static StateGenerator create(
      final HashTree blockTree,
      final SignedBlockAndState rootBlockAndState,
      final BlockProvider blockProvider); static StateGenerator create(
      final HashTree blockTree,
      final SignedBlockAndState rootBlockAndState,
      final BlockProvider blockProvider,
      final Map<Bytes32, BeaconState> knownStates); static StateGenerator create(
      final HashTree blockTree,
      final SignedBlockAndState rootBlockAndState,
      final BlockProvider blockProvider,
      final Map<Bytes32, BeaconState> knownStates,
      final int blockBatchSize,
      final int stateCacheSize); SafeFuture<SignedBlockAndState> regenerateStateForBlock(final Bytes32 blockRoot); SafeFuture<Void> regenerateAllStates(final StateHandler stateHandler); }
StateGenerator { public SafeFuture<SignedBlockAndState> regenerateStateForBlock(final Bytes32 blockRoot) { final int blockCount = blockTree.size(); LOG.info("Regenerate state for block {} by replaying {} blocks", blockRoot, blockCount); final long startTime = System.currentTimeMillis(); return chainStateGenerator .generateTargetState(blockRoot) .thenPeek( result -> LOG.info( "Completed regeneration of block {} at slot {} by replaying {} blocks. Took {}ms", blockRoot, result.getSlot(), blockCount, System.currentTimeMillis() - startTime)); } private  StateGenerator(
      final HashTree blockTree,
      final BlockProvider blockProvider,
      final AsyncChainStateGenerator chainStateGenerator,
      final StateCache stateCache,
      final int blockBatchSize); static StateGenerator create(
      final HashTree blockTree,
      final SignedBlockAndState rootBlockAndState,
      final BlockProvider blockProvider); static StateGenerator create(
      final HashTree blockTree,
      final SignedBlockAndState rootBlockAndState,
      final BlockProvider blockProvider,
      final Map<Bytes32, BeaconState> knownStates); static StateGenerator create(
      final HashTree blockTree,
      final SignedBlockAndState rootBlockAndState,
      final BlockProvider blockProvider,
      final Map<Bytes32, BeaconState> knownStates,
      final int blockBatchSize,
      final int stateCacheSize); SafeFuture<SignedBlockAndState> regenerateStateForBlock(final Bytes32 blockRoot); SafeFuture<Void> regenerateAllStates(final StateHandler stateHandler); static final int DEFAULT_STATE_CACHE_SIZE; }