@Test public void retrieveFinalizedCheckpointAndState() { final UpdatableStore store = createGenesisStore(); final SignedBlockAndState finalizedBlockAndState = chainBuilder.generateBlockAtSlot(Constants.SLOTS_PER_EPOCH - 1); final Checkpoint finalizedCheckpoint = new Checkpoint(UInt64.ONE, finalizedBlockAndState.getRoot()); final StoreTransaction tx = store.startTransaction(new StubStorageUpdateChannel()); tx.putBlockAndState(finalizedBlockAndState); tx.setFinalizedCheckpoint(finalizedCheckpoint); assertThat(tx.commit()).isCompleted(); final SafeFuture<CheckpointState> result = store.retrieveFinalizedCheckpointAndState(); assertThat(result).isCompleted(); assertThat(result.join().getCheckpoint()).isEqualTo(finalizedCheckpoint); assertThat(result.join().getBlock()).isEqualTo(finalizedBlockAndState.getBlock()); assertThat(result.join().getState()).isNotEqualTo(finalizedBlockAndState.getState()); assertThat(result.join().getState().getSlot()) .isEqualTo(finalizedBlockAndState.getSlot().plus(1)); }
@Override public SafeFuture<CheckpointState> retrieveFinalizedCheckpointAndState() { final Checkpoint finalizedCheckpoint; final SignedBlockAndState finalizedBlockAndState; readLock.lock(); try { finalizedCheckpoint = this.finalized_checkpoint; finalizedBlockAndState = this.finalizedBlockAndState; } finally { readLock.unlock(); } return checkpointStates .perform( new CheckpointStateTask(finalizedCheckpoint, fromBlockAndState(finalizedBlockAndState))) .thenApply( maybeState -> new CheckpointState( finalizedCheckpoint, finalizedBlockAndState.getBlock(), maybeState.orElseThrow())); }
Store implements UpdatableStore { @Override public SafeFuture<CheckpointState> retrieveFinalizedCheckpointAndState() { final Checkpoint finalizedCheckpoint; final SignedBlockAndState finalizedBlockAndState; readLock.lock(); try { finalizedCheckpoint = this.finalized_checkpoint; finalizedBlockAndState = this.finalizedBlockAndState; } finally { readLock.unlock(); } return checkpointStates .perform( new CheckpointStateTask(finalizedCheckpoint, fromBlockAndState(finalizedBlockAndState))) .thenApply( maybeState -> new CheckpointState( finalizedCheckpoint, finalizedBlockAndState.getBlock(), maybeState.orElseThrow())); } }
Store implements UpdatableStore { @Override public SafeFuture<CheckpointState> retrieveFinalizedCheckpointAndState() { final Checkpoint finalizedCheckpoint; final SignedBlockAndState finalizedBlockAndState; readLock.lock(); try { finalizedCheckpoint = this.finalized_checkpoint; finalizedBlockAndState = this.finalizedBlockAndState; } finally { readLock.unlock(); } return checkpointStates .perform( new CheckpointStateTask(finalizedCheckpoint, fromBlockAndState(finalizedBlockAndState))) .thenApply( maybeState -> new CheckpointState( finalizedCheckpoint, finalizedBlockAndState.getBlock(), maybeState.orElseThrow())); } private  Store(
      final MetricsSystem metricsSystem,
      int hotStatePersistenceFrequencyInEpochs,
      final BlockProvider blockProvider,
      final StateAndBlockProvider stateAndBlockProvider,
      final CachingTaskQueue<Bytes32, SignedBlockAndState> states,
      final UInt64 time,
      final UInt64 genesis_time,
      final Checkpoint justified_checkpoint,
      final Checkpoint finalized_checkpoint,
      final Checkpoint best_justified_checkpoint,
      final BlockTree blockTree,
      final SignedBlockAndState finalizedBlockAndState,
      final Map<UInt64, VoteTracker> votes,
      final Map<Bytes32, SignedBeaconBlock> blocks,
      final CachingTaskQueue<Checkpoint, BeaconState> checkpointStates); }
Store implements UpdatableStore { @Override public SafeFuture<CheckpointState> retrieveFinalizedCheckpointAndState() { final Checkpoint finalizedCheckpoint; final SignedBlockAndState finalizedBlockAndState; readLock.lock(); try { finalizedCheckpoint = this.finalized_checkpoint; finalizedBlockAndState = this.finalizedBlockAndState; } finally { readLock.unlock(); } return checkpointStates .perform( new CheckpointStateTask(finalizedCheckpoint, fromBlockAndState(finalizedBlockAndState))) .thenApply( maybeState -> new CheckpointState( finalizedCheckpoint, finalizedBlockAndState.getBlock(), maybeState.orElseThrow())); } private  Store(
      final MetricsSystem metricsSystem,
      int hotStatePersistenceFrequencyInEpochs,
      final BlockProvider blockProvider,
      final StateAndBlockProvider stateAndBlockProvider,
      final CachingTaskQueue<Bytes32, SignedBlockAndState> states,
      final UInt64 time,
      final UInt64 genesis_time,
      final Checkpoint justified_checkpoint,
      final Checkpoint finalized_checkpoint,
      final Checkpoint best_justified_checkpoint,
      final BlockTree blockTree,
      final SignedBlockAndState finalizedBlockAndState,
      final Map<UInt64, VoteTracker> votes,
      final Map<Bytes32, SignedBeaconBlock> blocks,
      final CachingTaskQueue<Checkpoint, BeaconState> checkpointStates); static SafeFuture<UpdatableStore> create(
      final AsyncRunner asyncRunner,
      final MetricsSystem metricsSystem,
      final BlockProvider blockProvider,
      final StateAndBlockProvider stateAndBlockProvider,
      final UInt64 time,
      final UInt64 genesisTime,
      final Checkpoint justifiedCheckpoint,
      final Checkpoint finalizedCheckpoint,
      final Checkpoint bestJustifiedCheckpoint,
      final Map<Bytes32, Bytes32> childToParentRoot,
      final Map<Bytes32, UInt64> rootToSlotMap,
      final SignedBlockAndState finalizedBlockAndState,
      final Map<UInt64, VoteTracker> votes,
      final StoreConfig config); @Override void startMetrics(); @Override StoreTransaction startTransaction(final StorageUpdateChannel storageUpdateChannel); @Override StoreTransaction startTransaction(
      final StorageUpdateChannel storageUpdateChannel, final StoreUpdateHandler updateHandler); @Override UInt64 getTime(); @Override UInt64 getGenesisTime(); @Override Checkpoint getJustifiedCheckpoint(); @Override Checkpoint getFinalizedCheckpoint(); @Override SignedBlockAndState getLatestFinalizedBlockAndState(); @Override UInt64 getLatestFinalizedBlockSlot(); @Override Checkpoint getBestJustifiedCheckpoint(); @Override boolean containsBlock(Bytes32 blockRoot); @Override Set<Bytes32> getBlockRoots(); @Override List<Bytes32> getOrderedBlockRoots(); @Override Optional<BeaconState> getBlockStateIfAvailable(final Bytes32 blockRoot); @Override Optional<SignedBeaconBlock> getBlockIfAvailable(final Bytes32 blockRoot); @Override SafeFuture<Optional<SignedBeaconBlock>> retrieveSignedBlock(final Bytes32 blockRoot); @Override SafeFuture<Optional<SignedBlockAndState>> retrieveBlockAndState(Bytes32 blockRoot); @Override SafeFuture<Optional<BeaconState>> retrieveBlockState(Bytes32 blockRoot); @Override SafeFuture<Optional<BeaconState>> retrieveCheckpointState(Checkpoint checkpoint); @Override SafeFuture<CheckpointState> retrieveFinalizedCheckpointAndState(); @Override SafeFuture<Optional<BeaconState>> retrieveCheckpointState(
      Checkpoint checkpoint, final BeaconState latestStateAtEpoch); @Override Set<UInt64> getVotedValidatorIndices(); }
Store implements UpdatableStore { @Override public SafeFuture<CheckpointState> retrieveFinalizedCheckpointAndState() { final Checkpoint finalizedCheckpoint; final SignedBlockAndState finalizedBlockAndState; readLock.lock(); try { finalizedCheckpoint = this.finalized_checkpoint; finalizedBlockAndState = this.finalizedBlockAndState; } finally { readLock.unlock(); } return checkpointStates .perform( new CheckpointStateTask(finalizedCheckpoint, fromBlockAndState(finalizedBlockAndState))) .thenApply( maybeState -> new CheckpointState( finalizedCheckpoint, finalizedBlockAndState.getBlock(), maybeState.orElseThrow())); } private  Store(
      final MetricsSystem metricsSystem,
      int hotStatePersistenceFrequencyInEpochs,
      final BlockProvider blockProvider,
      final StateAndBlockProvider stateAndBlockProvider,
      final CachingTaskQueue<Bytes32, SignedBlockAndState> states,
      final UInt64 time,
      final UInt64 genesis_time,
      final Checkpoint justified_checkpoint,
      final Checkpoint finalized_checkpoint,
      final Checkpoint best_justified_checkpoint,
      final BlockTree blockTree,
      final SignedBlockAndState finalizedBlockAndState,
      final Map<UInt64, VoteTracker> votes,
      final Map<Bytes32, SignedBeaconBlock> blocks,
      final CachingTaskQueue<Checkpoint, BeaconState> checkpointStates); static SafeFuture<UpdatableStore> create(
      final AsyncRunner asyncRunner,
      final MetricsSystem metricsSystem,
      final BlockProvider blockProvider,
      final StateAndBlockProvider stateAndBlockProvider,
      final UInt64 time,
      final UInt64 genesisTime,
      final Checkpoint justifiedCheckpoint,
      final Checkpoint finalizedCheckpoint,
      final Checkpoint bestJustifiedCheckpoint,
      final Map<Bytes32, Bytes32> childToParentRoot,
      final Map<Bytes32, UInt64> rootToSlotMap,
      final SignedBlockAndState finalizedBlockAndState,
      final Map<UInt64, VoteTracker> votes,
      final StoreConfig config); @Override void startMetrics(); @Override StoreTransaction startTransaction(final StorageUpdateChannel storageUpdateChannel); @Override StoreTransaction startTransaction(
      final StorageUpdateChannel storageUpdateChannel, final StoreUpdateHandler updateHandler); @Override UInt64 getTime(); @Override UInt64 getGenesisTime(); @Override Checkpoint getJustifiedCheckpoint(); @Override Checkpoint getFinalizedCheckpoint(); @Override SignedBlockAndState getLatestFinalizedBlockAndState(); @Override UInt64 getLatestFinalizedBlockSlot(); @Override Checkpoint getBestJustifiedCheckpoint(); @Override boolean containsBlock(Bytes32 blockRoot); @Override Set<Bytes32> getBlockRoots(); @Override List<Bytes32> getOrderedBlockRoots(); @Override Optional<BeaconState> getBlockStateIfAvailable(final Bytes32 blockRoot); @Override Optional<SignedBeaconBlock> getBlockIfAvailable(final Bytes32 blockRoot); @Override SafeFuture<Optional<SignedBeaconBlock>> retrieveSignedBlock(final Bytes32 blockRoot); @Override SafeFuture<Optional<SignedBlockAndState>> retrieveBlockAndState(Bytes32 blockRoot); @Override SafeFuture<Optional<BeaconState>> retrieveBlockState(Bytes32 blockRoot); @Override SafeFuture<Optional<BeaconState>> retrieveCheckpointState(Checkpoint checkpoint); @Override SafeFuture<CheckpointState> retrieveFinalizedCheckpointAndState(); @Override SafeFuture<Optional<BeaconState>> retrieveCheckpointState(
      Checkpoint checkpoint, final BeaconState latestStateAtEpoch); @Override Set<UInt64> getVotedValidatorIndices();  }