@Test void signAttestationData_shouldNotSignWhenSlashingProtectionRejects() { final AttestationData attestationData = dataStructureUtil.randomAttestationData(); when(slashingProtector.maySignAttestation( publicKey, forkInfo.getGenesisValidatorsRoot(), attestationData.getSource().getEpoch(), attestationData.getTarget().getEpoch())) .thenReturn(SafeFuture.completedFuture(false)); when(delegate.signAttestationData(attestationData, forkInfo)).thenReturn(signatureFuture); assertThatSafeFuture(signer.signAttestationData(attestationData, forkInfo)) .isCompletedExceptionallyWith(SlashableConditionException.class); }
@Override public SafeFuture<BLSSignature> signAttestationData( final AttestationData attestationData, final ForkInfo forkInfo) { return slashingProtector .maySignAttestation( validatorPublicKey, forkInfo.getGenesisValidatorsRoot(), attestationData.getSource().getEpoch(), attestationData.getTarget().getEpoch()) .thenAccept(verifySigningAllowed(slashableAttestationMessage(attestationData))) .thenCompose(__ -> delegate.signAttestationData(attestationData, forkInfo)); }
SlashingProtectedSigner implements Signer { @Override public SafeFuture<BLSSignature> signAttestationData( final AttestationData attestationData, final ForkInfo forkInfo) { return slashingProtector .maySignAttestation( validatorPublicKey, forkInfo.getGenesisValidatorsRoot(), attestationData.getSource().getEpoch(), attestationData.getTarget().getEpoch()) .thenAccept(verifySigningAllowed(slashableAttestationMessage(attestationData))) .thenCompose(__ -> delegate.signAttestationData(attestationData, forkInfo)); } }
SlashingProtectedSigner implements Signer { @Override public SafeFuture<BLSSignature> signAttestationData( final AttestationData attestationData, final ForkInfo forkInfo) { return slashingProtector .maySignAttestation( validatorPublicKey, forkInfo.getGenesisValidatorsRoot(), attestationData.getSource().getEpoch(), attestationData.getTarget().getEpoch()) .thenAccept(verifySigningAllowed(slashableAttestationMessage(attestationData))) .thenCompose(__ -> delegate.signAttestationData(attestationData, forkInfo)); } SlashingProtectedSigner(
      final BLSPublicKey validatorPublicKey,
      final SlashingProtector slashingProtector,
      final Signer delegate); }
SlashingProtectedSigner implements Signer { @Override public SafeFuture<BLSSignature> signAttestationData( final AttestationData attestationData, final ForkInfo forkInfo) { return slashingProtector .maySignAttestation( validatorPublicKey, forkInfo.getGenesisValidatorsRoot(), attestationData.getSource().getEpoch(), attestationData.getTarget().getEpoch()) .thenAccept(verifySigningAllowed(slashableAttestationMessage(attestationData))) .thenCompose(__ -> delegate.signAttestationData(attestationData, forkInfo)); } SlashingProtectedSigner(
      final BLSPublicKey validatorPublicKey,
      final SlashingProtector slashingProtector,
      final Signer delegate); @Override SafeFuture<BLSSignature> signBlock(final BeaconBlock block, final ForkInfo forkInfo); @Override SafeFuture<BLSSignature> signAttestationData(
      final AttestationData attestationData, final ForkInfo forkInfo); @Override SafeFuture<BLSSignature> createRandaoReveal(final UInt64 epoch, final ForkInfo forkInfo); @Override SafeFuture<BLSSignature> signAggregationSlot(final UInt64 slot, final ForkInfo forkInfo); @Override SafeFuture<BLSSignature> signAggregateAndProof(
      final AggregateAndProof aggregateAndProof, final ForkInfo forkInfo); @Override SafeFuture<BLSSignature> signVoluntaryExit(
      final VoluntaryExit voluntaryExit, final ForkInfo forkInfo); @Override boolean isLocal(); }
SlashingProtectedSigner implements Signer { @Override public SafeFuture<BLSSignature> signAttestationData( final AttestationData attestationData, final ForkInfo forkInfo) { return slashingProtector .maySignAttestation( validatorPublicKey, forkInfo.getGenesisValidatorsRoot(), attestationData.getSource().getEpoch(), attestationData.getTarget().getEpoch()) .thenAccept(verifySigningAllowed(slashableAttestationMessage(attestationData))) .thenCompose(__ -> delegate.signAttestationData(attestationData, forkInfo)); } SlashingProtectedSigner(
      final BLSPublicKey validatorPublicKey,
      final SlashingProtector slashingProtector,
      final Signer delegate); @Override SafeFuture<BLSSignature> signBlock(final BeaconBlock block, final ForkInfo forkInfo); @Override SafeFuture<BLSSignature> signAttestationData(
      final AttestationData attestationData, final ForkInfo forkInfo); @Override SafeFuture<BLSSignature> createRandaoReveal(final UInt64 epoch, final ForkInfo forkInfo); @Override SafeFuture<BLSSignature> signAggregationSlot(final UInt64 slot, final ForkInfo forkInfo); @Override SafeFuture<BLSSignature> signAggregateAndProof(
      final AggregateAndProof aggregateAndProof, final ForkInfo forkInfo); @Override SafeFuture<BLSSignature> signVoluntaryExit(
      final VoluntaryExit voluntaryExit, final ForkInfo forkInfo); @Override boolean isLocal();  }