@Test public void getStateAtSlot_shouldThrowWhenHeadRootMissing() { final UpdatableStore store = mock(UpdatableStore.class); final RecentChainData storageClient = mock(RecentChainData.class); when(storageClient.isPreGenesis()).thenReturn(false); when(storageClient.isPreForkChoice()).thenReturn(true); when(storageClient.getStore()).thenReturn(store); final CombinedChainDataClient combinedChainDataClient = new CombinedChainDataClient(storageClient, historicalChainData); final ChainDataProvider provider = new ChainDataProvider(recentChainData, combinedChainDataClient); final SafeFuture<Optional<BeaconState>> future = provider.getStateAtSlot(ZERO); assertThatThrownBy(future::get).hasCauseInstanceOf(ChainDataUnavailableException.class); }
public SafeFuture<Optional<BeaconState>> getStateAtSlot(final UInt64 slot) { if (!combinedChainDataClient.isChainDataFullyAvailable()) { return chainUnavailable(); } return combinedChainDataClient .getStateAtSlotExact(slot) .thenApply(stateInternal -> stateInternal.map(BeaconState::new)); }
ChainDataProvider { public SafeFuture<Optional<BeaconState>> getStateAtSlot(final UInt64 slot) { if (!combinedChainDataClient.isChainDataFullyAvailable()) { return chainUnavailable(); } return combinedChainDataClient .getStateAtSlotExact(slot) .thenApply(stateInternal -> stateInternal.map(BeaconState::new)); } }
ChainDataProvider { public SafeFuture<Optional<BeaconState>> getStateAtSlot(final UInt64 slot) { if (!combinedChainDataClient.isChainDataFullyAvailable()) { return chainUnavailable(); } return combinedChainDataClient .getStateAtSlotExact(slot) .thenApply(stateInternal -> stateInternal.map(BeaconState::new)); } ChainDataProvider(
      final RecentChainData recentChainData,
      final CombinedChainDataClient combinedChainDataClient); }
ChainDataProvider { public SafeFuture<Optional<BeaconState>> getStateAtSlot(final UInt64 slot) { if (!combinedChainDataClient.isChainDataFullyAvailable()) { return chainUnavailable(); } return combinedChainDataClient .getStateAtSlotExact(slot) .thenApply(stateInternal -> stateInternal.map(BeaconState::new)); } ChainDataProvider(
      final RecentChainData recentChainData,
      final CombinedChainDataClient combinedChainDataClient); UInt64 getGenesisTime(); Optional<BeaconHead> getBeaconHead(); GetForkResponse getForkInfo(); SafeFuture<Optional<List<Committee>>> getCommitteesAtEpoch(final UInt64 epoch); SafeFuture<Optional<GetBlockResponse>> getBlockBySlot(final UInt64 slot); boolean isStoreAvailable(); Optional<Bytes32> getBestBlockRoot(); UInt64 getCurrentEpoch(); SafeFuture<Optional<GetBlockResponse>> getBlockByBlockRoot(final Bytes32 blockParam); SafeFuture<Optional<BeaconState>> getStateByBlockRoot(final Bytes32 blockRoot); SafeFuture<Optional<BeaconState>> getStateByStateRoot(final Bytes32 stateRoot); SafeFuture<Optional<BeaconState>> getStateAtSlot(final UInt64 slot); SafeFuture<Optional<Bytes32>> getStateRootAtSlot(final UInt64 slot); SafeFuture<Optional<BeaconValidators>> getValidatorsByValidatorsRequest(
      final ValidatorsRequest request); boolean isFinalized(final SignedBeaconBlock signedBeaconBlock); boolean isFinalized(final UInt64 slot); boolean isFinalizedEpoch(final UInt64 epoch); Optional<BeaconChainHead> getHeadState(); Optional<UInt64> stateParameterToSlot(final String pathParam); Optional<Integer> validatorParameterToIndex(final String validatorParameter); SafeFuture<Optional<Fork>> getForkAtSlot(final UInt64 slot); SafeFuture<Optional<ValidatorResponse>> getValidatorDetails(
      final Optional<UInt64> maybeSlot, final Optional<Integer> maybeIndex); Optional<Bytes32> getStateRootFromBlockRoot(final Bytes32 blockRoot); }
ChainDataProvider { public SafeFuture<Optional<BeaconState>> getStateAtSlot(final UInt64 slot) { if (!combinedChainDataClient.isChainDataFullyAvailable()) { return chainUnavailable(); } return combinedChainDataClient .getStateAtSlotExact(slot) .thenApply(stateInternal -> stateInternal.map(BeaconState::new)); } ChainDataProvider(
      final RecentChainData recentChainData,
      final CombinedChainDataClient combinedChainDataClient); UInt64 getGenesisTime(); Optional<BeaconHead> getBeaconHead(); GetForkResponse getForkInfo(); SafeFuture<Optional<List<Committee>>> getCommitteesAtEpoch(final UInt64 epoch); SafeFuture<Optional<GetBlockResponse>> getBlockBySlot(final UInt64 slot); boolean isStoreAvailable(); Optional<Bytes32> getBestBlockRoot(); UInt64 getCurrentEpoch(); SafeFuture<Optional<GetBlockResponse>> getBlockByBlockRoot(final Bytes32 blockParam); SafeFuture<Optional<BeaconState>> getStateByBlockRoot(final Bytes32 blockRoot); SafeFuture<Optional<BeaconState>> getStateByStateRoot(final Bytes32 stateRoot); SafeFuture<Optional<BeaconState>> getStateAtSlot(final UInt64 slot); SafeFuture<Optional<Bytes32>> getStateRootAtSlot(final UInt64 slot); SafeFuture<Optional<BeaconValidators>> getValidatorsByValidatorsRequest(
      final ValidatorsRequest request); boolean isFinalized(final SignedBeaconBlock signedBeaconBlock); boolean isFinalized(final UInt64 slot); boolean isFinalizedEpoch(final UInt64 epoch); Optional<BeaconChainHead> getHeadState(); Optional<UInt64> stateParameterToSlot(final String pathParam); Optional<Integer> validatorParameterToIndex(final String validatorParameter); SafeFuture<Optional<Fork>> getForkAtSlot(final UInt64 slot); SafeFuture<Optional<ValidatorResponse>> getValidatorDetails(
      final Optional<UInt64> maybeSlot, final Optional<Integer> maybeIndex); Optional<Bytes32> getStateRootFromBlockRoot(final Bytes32 blockRoot);  }