class ValidatorApiHandler implements ValidatorApiChannel {

  @Override
  public SafeFuture<Optional<Attestation>> createUnsignedAttestation(
      final UInt64 slot, final int committeeIndex) {
    if (isSyncActive()) {
      return NodeSyncingException.failedFuture();
    }

    final UInt64 minQuerySlot = CommitteeUtil.getEarliestQueryableSlotForTargetSlot(slot);

    return combinedChainDataClient
        .getSignedBlockAndStateInEffectAtSlot(slot)
        .thenCompose(
            maybeBlockAndState -> {
              if (maybeBlockAndState.isEmpty()) {
                return SafeFuture.completedFuture(Optional.empty());
              }
              final SignedBlockAndState blockAndState = maybeBlockAndState.get();
              final BeaconBlock block = blockAndState.getBlock().getMessage();
              if (blockAndState.getSlot().compareTo(minQuerySlot) < 0) {
                // The current effective block is too far in the past - so roll the state
                // forward to the minimum epoch
                final UInt64 epoch = compute_epoch_at_slot(minQuerySlot);
                return combinedChainDataClient
                    .getCheckpointState(epoch, blockAndState)
                    .thenApply(
                        checkpointState ->
                            Optional.of(
                                createAttestation(
                                    block, checkpointState.getState(), slot, committeeIndex)));
              } else {
                final Attestation attestation =
                    createAttestation(block, blockAndState.getState(), slot, committeeIndex);
                return SafeFuture.completedFuture(Optional.of(attestation));
              }
            });
  }

  public  ValidatorApiHandler(
      final CombinedChainDataClient combinedChainDataClient,
      final SyncStateTracker syncStateTracker,
      final StateTransition stateTransition,
      final BlockFactory blockFactory,
      final AggregatingAttestationPool attestationPool,
      final AttestationManager attestationManager,
      final AttestationTopicSubscriber attestationTopicSubscriber,
      final EventBus eventBus,
      final DutyMetrics dutyMetrics,
      final PerformanceTracker performanceTracker);

}