use of tech.pegasys.teku.statetransition.attestation.AttestationManager in project teku by ConsenSys.
the class ValidatorApiHandlerTest method sendAggregateAndProofs_shouldProcessMixOfValidAndInvalidAggregates.
@Test
void sendAggregateAndProofs_shouldProcessMixOfValidAndInvalidAggregates() {
final SignedAggregateAndProof invalidAggregate = dataStructureUtil.randomSignedAggregateAndProof();
final SignedAggregateAndProof validAggregate = dataStructureUtil.randomSignedAggregateAndProof();
when(attestationManager.onAttestation(ValidateableAttestation.aggregateFromValidator(spec, invalidAggregate))).thenReturn(completedFuture(AttestationProcessingResult.invalid("Bad juju")));
when(attestationManager.onAttestation(ValidateableAttestation.aggregateFromValidator(spec, validAggregate))).thenReturn(completedFuture(SUCCESSFUL));
final SafeFuture<List<SubmitDataError>> result = validatorApiHandler.sendAggregateAndProofs(List.of(invalidAggregate, validAggregate));
assertThat(result).isCompletedWithValue(List.of(new SubmitDataError(ZERO, "Bad juju")));
// Should send both to the attestation manager.
verify(attestationManager).onAttestation(argThat(validatableAttestation -> validatableAttestation.getSignedAggregateAndProof().equals(validAggregate)));
verify(attestationManager).onAttestation(argThat(validatableAttestation -> validatableAttestation.getSignedAggregateAndProof().equals(invalidAggregate)));
}
use of tech.pegasys.teku.statetransition.attestation.AttestationManager in project teku by ConsenSys.
the class BeaconChainController method initAttestationManager.
protected void initAttestationManager() {
final PendingPool<ValidateableAttestation> pendingAttestations = PendingPool.createForAttestations(spec);
final FutureItems<ValidateableAttestation> futureAttestations = FutureItems.create(ValidateableAttestation::getEarliestSlotForForkChoiceProcessing, UInt64.valueOf(3));
AttestationValidator attestationValidator = new AttestationValidator(spec, recentChainData, signatureVerificationService);
AggregateAttestationValidator aggregateValidator = new AggregateAttestationValidator(spec, recentChainData, attestationValidator, signatureVerificationService);
blockImporter.subscribeToVerifiedBlockAttestations((slot, attestations) -> attestations.forEach(attestation -> aggregateValidator.addSeenAggregate(ValidateableAttestation.from(spec, attestation))));
attestationManager = AttestationManager.create(pendingAttestations, futureAttestations, forkChoice, attestationPool, attestationValidator, aggregateValidator, signatureVerificationService, eventChannels.getPublisher(ActiveValidatorChannel.class, beaconAsyncRunner));
eventChannels.subscribe(SlotEventsChannel.class, attestationManager).subscribe(FinalizedCheckpointChannel.class, pendingAttestations).subscribe(BlockImportNotifications.class, attestationManager);
}
Aggregations