@Test public void getCommitteeAssignmentAtEpoch_shouldReturnEmptyListWhenStateAtSlotIsNotFound() throws Exception { final ChainDataProvider provider = new ChainDataProvider(recentChainData, combinedChainDataClient); final SafeFuture<Optional<List<Committee>>> future = provider.getCommitteesAtEpoch(UInt64.valueOf(50)); assertThat(future.get()).isEmpty(); }
public SafeFuture<Optional<List<Committee>>> getCommitteesAtEpoch(final UInt64 epoch) { if (!combinedChainDataClient.isChainDataFullyAvailable()) { return chainUnavailable(); } final UInt64 earliestQueryableSlot = CommitteeUtil.getEarliestQueryableSlotForTargetEpoch(epoch); if (recentChainData.getHeadSlot().isLessThan(earliestQueryableSlot)) { return SafeFuture.completedFuture(Optional.empty()); } final UInt64 queryEpoch = compute_epoch_at_slot(earliestQueryableSlot); return combinedChainDataClient .getCheckpointStateAtEpoch(queryEpoch) .thenApply( maybeResult -> maybeResult.map( checkpointState -> combinedChainDataClient .getCommitteesFromState(checkpointState.getState(), epoch).stream() .map(Committee::new) .collect(Collectors.toList()))); }
ChainDataProvider { public SafeFuture<Optional<List<Committee>>> getCommitteesAtEpoch(final UInt64 epoch) { if (!combinedChainDataClient.isChainDataFullyAvailable()) { return chainUnavailable(); } final UInt64 earliestQueryableSlot = CommitteeUtil.getEarliestQueryableSlotForTargetEpoch(epoch); if (recentChainData.getHeadSlot().isLessThan(earliestQueryableSlot)) { return SafeFuture.completedFuture(Optional.empty()); } final UInt64 queryEpoch = compute_epoch_at_slot(earliestQueryableSlot); return combinedChainDataClient .getCheckpointStateAtEpoch(queryEpoch) .thenApply( maybeResult -> maybeResult.map( checkpointState -> combinedChainDataClient .getCommitteesFromState(checkpointState.getState(), epoch).stream() .map(Committee::new) .collect(Collectors.toList()))); } }
ChainDataProvider { public SafeFuture<Optional<List<Committee>>> getCommitteesAtEpoch(final UInt64 epoch) { if (!combinedChainDataClient.isChainDataFullyAvailable()) { return chainUnavailable(); } final UInt64 earliestQueryableSlot = CommitteeUtil.getEarliestQueryableSlotForTargetEpoch(epoch); if (recentChainData.getHeadSlot().isLessThan(earliestQueryableSlot)) { return SafeFuture.completedFuture(Optional.empty()); } final UInt64 queryEpoch = compute_epoch_at_slot(earliestQueryableSlot); return combinedChainDataClient .getCheckpointStateAtEpoch(queryEpoch) .thenApply( maybeResult -> maybeResult.map( checkpointState -> combinedChainDataClient .getCommitteesFromState(checkpointState.getState(), epoch).stream() .map(Committee::new) .collect(Collectors.toList()))); } ChainDataProvider(
      final RecentChainData recentChainData,
      final CombinedChainDataClient combinedChainDataClient); }
ChainDataProvider { public SafeFuture<Optional<List<Committee>>> getCommitteesAtEpoch(final UInt64 epoch) { if (!combinedChainDataClient.isChainDataFullyAvailable()) { return chainUnavailable(); } final UInt64 earliestQueryableSlot = CommitteeUtil.getEarliestQueryableSlotForTargetEpoch(epoch); if (recentChainData.getHeadSlot().isLessThan(earliestQueryableSlot)) { return SafeFuture.completedFuture(Optional.empty()); } final UInt64 queryEpoch = compute_epoch_at_slot(earliestQueryableSlot); return combinedChainDataClient .getCheckpointStateAtEpoch(queryEpoch) .thenApply( maybeResult -> maybeResult.map( checkpointState -> combinedChainDataClient .getCommitteesFromState(checkpointState.getState(), epoch).stream() .map(Committee::new) .collect(Collectors.toList()))); } 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<List<Committee>>> getCommitteesAtEpoch(final UInt64 epoch) { if (!combinedChainDataClient.isChainDataFullyAvailable()) { return chainUnavailable(); } final UInt64 earliestQueryableSlot = CommitteeUtil.getEarliestQueryableSlotForTargetEpoch(epoch); if (recentChainData.getHeadSlot().isLessThan(earliestQueryableSlot)) { return SafeFuture.completedFuture(Optional.empty()); } final UInt64 queryEpoch = compute_epoch_at_slot(earliestQueryableSlot); return combinedChainDataClient .getCheckpointStateAtEpoch(queryEpoch) .thenApply( maybeResult -> maybeResult.map( checkpointState -> combinedChainDataClient .getCommitteesFromState(checkpointState.getState(), epoch).stream() .map(Committee::new) .collect(Collectors.toList()))); } 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);  }