@Test public void retrieveCheckpointState_fromUnderlyingStore_withLimitedCache() { processCheckpointsWithLimitedCache( (store, checkpointState) -> { UpdatableStore.StoreTransaction tx = store.startTransaction(storageUpdateChannel); SafeFuture<Optional<BeaconState>> result = tx.retrieveCheckpointState(checkpointState.getCheckpoint()); assertThat(result) .withFailMessage( "Expected checkpoint state for checkpoint %s", checkpointState.getCheckpoint()) .isCompletedWithValue(Optional.of(checkpointState.getState())); }); }
@Override public SafeFuture<Optional<BeaconState>> retrieveCheckpointState(Checkpoint checkpoint) { SignedBlockAndState inMemoryCheckpointBlockState = blockAndStates.get(checkpoint.getRoot()); if (inMemoryCheckpointBlockState != null) { return new CheckpointStateTask(checkpoint, fromBlockAndState(inMemoryCheckpointBlockState)) .performTask(); } return store.retrieveCheckpointState(checkpoint); }
StoreTransaction implements UpdatableStore.StoreTransaction { @Override public SafeFuture<Optional<BeaconState>> retrieveCheckpointState(Checkpoint checkpoint) { SignedBlockAndState inMemoryCheckpointBlockState = blockAndStates.get(checkpoint.getRoot()); if (inMemoryCheckpointBlockState != null) { return new CheckpointStateTask(checkpoint, fromBlockAndState(inMemoryCheckpointBlockState)) .performTask(); } return store.retrieveCheckpointState(checkpoint); } }
StoreTransaction implements UpdatableStore.StoreTransaction { @Override public SafeFuture<Optional<BeaconState>> retrieveCheckpointState(Checkpoint checkpoint) { SignedBlockAndState inMemoryCheckpointBlockState = blockAndStates.get(checkpoint.getRoot()); if (inMemoryCheckpointBlockState != null) { return new CheckpointStateTask(checkpoint, fromBlockAndState(inMemoryCheckpointBlockState)) .performTask(); } return store.retrieveCheckpointState(checkpoint); } StoreTransaction(
      final Store store,
      final ReadWriteLock lock,
      final StorageUpdateChannel storageUpdateChannel,
      final UpdatableStore.StoreUpdateHandler updateHandler); }
StoreTransaction implements UpdatableStore.StoreTransaction { @Override public SafeFuture<Optional<BeaconState>> retrieveCheckpointState(Checkpoint checkpoint) { SignedBlockAndState inMemoryCheckpointBlockState = blockAndStates.get(checkpoint.getRoot()); if (inMemoryCheckpointBlockState != null) { return new CheckpointStateTask(checkpoint, fromBlockAndState(inMemoryCheckpointBlockState)) .performTask(); } return store.retrieveCheckpointState(checkpoint); } StoreTransaction(
      final Store store,
      final ReadWriteLock lock,
      final StorageUpdateChannel storageUpdateChannel,
      final UpdatableStore.StoreUpdateHandler updateHandler); @Override void putBlockAndState(final SignedBeaconBlock block, final BeaconState state); @Override void putBlockAndState(final SignedBlockAndState blockAndState); @Override void putStateRoot(final Bytes32 stateRoot, final SlotAndBlockRoot slotAndBlockRoot); @Override void setTime(UInt64 time); @Override void setGenesis_time(UInt64 genesis_time); @Override void setJustifiedCheckpoint(Checkpoint justified_checkpoint); @Override void setFinalizedCheckpoint(Checkpoint finalized_checkpoint); @Override void setBestJustifiedCheckpoint(Checkpoint best_justified_checkpoint); @Override VoteTracker getVote(UInt64 validatorIndex); @CheckReturnValue @Override SafeFuture<Void> commit(); @Override void commit(final Runnable onSuccess, final String errorMessage); @Override UInt64 getTime(); @Override UInt64 getGenesisTime(); @Override Checkpoint getJustifiedCheckpoint(); @Override Checkpoint getFinalizedCheckpoint(); @Override SignedBlockAndState getLatestFinalizedBlockAndState(); @Override UInt64 getLatestFinalizedBlockSlot(); @Override Checkpoint getBestJustifiedCheckpoint(); @Override boolean containsBlock(final Bytes32 blockRoot); @Override Set<Bytes32> getBlockRoots(); @Override List<Bytes32> getOrderedBlockRoots(); @Override Optional<BeaconState> getBlockStateIfAvailable(final Bytes32 blockRoot); @Override SafeFuture<Optional<SignedBeaconBlock>> retrieveSignedBlock(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(
      final Checkpoint checkpoint, final BeaconState latestStateAtEpoch); @Override Optional<SignedBeaconBlock> getBlockIfAvailable(final Bytes32 blockRoot); @Override Set<UInt64> getVotedValidatorIndices(); }
StoreTransaction implements UpdatableStore.StoreTransaction { @Override public SafeFuture<Optional<BeaconState>> retrieveCheckpointState(Checkpoint checkpoint) { SignedBlockAndState inMemoryCheckpointBlockState = blockAndStates.get(checkpoint.getRoot()); if (inMemoryCheckpointBlockState != null) { return new CheckpointStateTask(checkpoint, fromBlockAndState(inMemoryCheckpointBlockState)) .performTask(); } return store.retrieveCheckpointState(checkpoint); } StoreTransaction(
      final Store store,
      final ReadWriteLock lock,
      final StorageUpdateChannel storageUpdateChannel,
      final UpdatableStore.StoreUpdateHandler updateHandler); @Override void putBlockAndState(final SignedBeaconBlock block, final BeaconState state); @Override void putBlockAndState(final SignedBlockAndState blockAndState); @Override void putStateRoot(final Bytes32 stateRoot, final SlotAndBlockRoot slotAndBlockRoot); @Override void setTime(UInt64 time); @Override void setGenesis_time(UInt64 genesis_time); @Override void setJustifiedCheckpoint(Checkpoint justified_checkpoint); @Override void setFinalizedCheckpoint(Checkpoint finalized_checkpoint); @Override void setBestJustifiedCheckpoint(Checkpoint best_justified_checkpoint); @Override VoteTracker getVote(UInt64 validatorIndex); @CheckReturnValue @Override SafeFuture<Void> commit(); @Override void commit(final Runnable onSuccess, final String errorMessage); @Override UInt64 getTime(); @Override UInt64 getGenesisTime(); @Override Checkpoint getJustifiedCheckpoint(); @Override Checkpoint getFinalizedCheckpoint(); @Override SignedBlockAndState getLatestFinalizedBlockAndState(); @Override UInt64 getLatestFinalizedBlockSlot(); @Override Checkpoint getBestJustifiedCheckpoint(); @Override boolean containsBlock(final Bytes32 blockRoot); @Override Set<Bytes32> getBlockRoots(); @Override List<Bytes32> getOrderedBlockRoots(); @Override Optional<BeaconState> getBlockStateIfAvailable(final Bytes32 blockRoot); @Override SafeFuture<Optional<SignedBeaconBlock>> retrieveSignedBlock(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(
      final Checkpoint checkpoint, final BeaconState latestStateAtEpoch); @Override Optional<SignedBeaconBlock> getBlockIfAvailable(final Bytes32 blockRoot); @Override Set<UInt64> getVotedValidatorIndices();  }