@Test public void createUnsignedAttestation_shouldFailWhenNodeIsSyncing() { nodeIsSyncing(); final SafeFuture<Optional<Attestation>> result = validatorApiHandler.createUnsignedAttestation(ONE, 1); assertThat(result).isCompletedExceptionally(); assertThatThrownBy(result::get).hasRootCauseInstanceOf(NodeSyncingException.class); }
@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) { 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)); } }); }
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) { 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)); } }); } }
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) { 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)); } }); } 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); }
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) { 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)); } }); } 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); @Override SafeFuture<Optional<ForkInfo>> getForkInfo(); @Override SafeFuture<Optional<UInt64>> getGenesisTime(); @Override SafeFuture<Optional<List<ValidatorDuties>>> getDuties(
      final UInt64 epoch, final Collection<BLSPublicKey> publicKeys); @Override SafeFuture<Optional<List<AttesterDuties>>> getAttestationDuties(
      final UInt64 epoch, final Collection<Integer> validatorIndexes); @Override SafeFuture<Optional<List<ProposerDuties>>> getProposerDuties(final UInt64 epoch); @Override SafeFuture<Optional<BeaconBlock>> createUnsignedBlock(
      final UInt64 slot, final BLSSignature randaoReveal, final Optional<Bytes32> graffiti); @Override SafeFuture<Optional<Attestation>> createUnsignedAttestation(
      final UInt64 slot, final int committeeIndex); @Override SafeFuture<Optional<Attestation>> createAggregate(final Bytes32 attestationHashTreeRoot); @Override void subscribeToBeaconCommitteeForAggregation(
      final int committeeIndex, final UInt64 aggregationSlot); @Override void subscribeToPersistentSubnets(Set<SubnetSubscription> subnetSubscriptions); @Override void sendSignedAttestation(
      final Attestation attestation, final Optional<Integer> expectedValidatorIndex); @Override void sendSignedAttestation(final Attestation attestation); @Override void sendAggregateAndProof(final SignedAggregateAndProof aggregateAndProof); @Override void sendSignedBlock(final SignedBeaconBlock block); }
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) { 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)); } }); } 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); @Override SafeFuture<Optional<ForkInfo>> getForkInfo(); @Override SafeFuture<Optional<UInt64>> getGenesisTime(); @Override SafeFuture<Optional<List<ValidatorDuties>>> getDuties(
      final UInt64 epoch, final Collection<BLSPublicKey> publicKeys); @Override SafeFuture<Optional<List<AttesterDuties>>> getAttestationDuties(
      final UInt64 epoch, final Collection<Integer> validatorIndexes); @Override SafeFuture<Optional<List<ProposerDuties>>> getProposerDuties(final UInt64 epoch); @Override SafeFuture<Optional<BeaconBlock>> createUnsignedBlock(
      final UInt64 slot, final BLSSignature randaoReveal, final Optional<Bytes32> graffiti); @Override SafeFuture<Optional<Attestation>> createUnsignedAttestation(
      final UInt64 slot, final int committeeIndex); @Override SafeFuture<Optional<Attestation>> createAggregate(final Bytes32 attestationHashTreeRoot); @Override void subscribeToBeaconCommitteeForAggregation(
      final int committeeIndex, final UInt64 aggregationSlot); @Override void subscribeToPersistentSubnets(Set<SubnetSubscription> subnetSubscriptions); @Override void sendSignedAttestation(
      final Attestation attestation, final Optional<Integer> expectedValidatorIndex); @Override void sendSignedAttestation(final Attestation attestation); @Override void sendAggregateAndProof(final SignedAggregateAndProof aggregateAndProof); @Override void sendSignedBlock(final SignedBeaconBlock block);  }