Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -505,8 +505,7 @@ public SafeFuture<Optional<Attestation>> createAggregate(
return SafeFuture.completedFuture(
attestationPool
.createAggregateFor(attestationHashTreeRoot, committeeIndex)
.filter(attestation -> attestation.getData().getSlot().equals(slot))
.map(ValidatableAttestation::getAttestation));
.filter(attestation -> attestation.getData().getSlot().equals(slot)));
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -734,7 +734,7 @@ public void createAggregate_shouldReturnAggregateFromAttestationPool() {
final Optional<Attestation> aggregate = Optional.of(dataStructureUtil.randomAttestation());
when(attestationPool.createAggregateFor(
eq(attestationData.hashTreeRoot()), eq(Optional.empty())))
.thenReturn(aggregate.map(attestation -> ValidatableAttestation.from(spec, attestation)));
.thenReturn(aggregate);

assertThat(
validatorApiHandler.createAggregate(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -354,10 +354,11 @@ private boolean isValid(
return spec.validateAttestation(stateAtBlockSlot, attestationData).isEmpty();
}

public synchronized Optional<ValidatableAttestation> createAggregateFor(
public synchronized Optional<Attestation> createAggregateFor(
final Bytes32 attestationHashTreeRoot, final Optional<UInt64> committeeIndex) {
return Optional.ofNullable(attestationGroupByDataHash.get(attestationHashTreeRoot))
.flatMap(attestations -> attestations.stream(committeeIndex).findFirst());
.flatMap(attestations -> attestations.stream(committeeIndex).findFirst())
.map(ValidatableAttestation::getAttestation);
}

public synchronized void onReorg(final UInt64 commonAncestorSlot) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ public void setUp(final SpecContext specContext) {

@TestTemplate
public void createAggregateFor_shouldReturnEmptyWhenNoAttestationsMatchGivenData() {
final Optional<ValidatableAttestation> result =
final Optional<Attestation> result =
aggregatingPool.createAggregateFor(
dataStructureUtil.randomAttestationData().hashTreeRoot(), committeeIndex);
assertThat(result).isEmpty();
Expand All @@ -136,10 +136,9 @@ public void createAggregateFor_shouldAggregateAttestationsWithMatchingData() {
final Attestation attestation1 = addAttestationFromValidators(attestationData, 1, 3, 5);
final Attestation attestation2 = addAttestationFromValidators(attestationData, 2, 4, 6);

final Optional<ValidatableAttestation> result =
final Optional<Attestation> result =
aggregatingPool.createAggregateFor(attestationData.hashTreeRoot(), committeeIndex);
assertThat(result.map(ValidatableAttestation::getAttestation))
.contains(aggregateAttestations(attestation1, attestation2));
assertThat(result).contains(aggregateAttestations(attestation1, attestation2));
}

@TestTemplate
Expand All @@ -149,10 +148,9 @@ public void createAggregateFor_shouldReturnBestAggregateForMatchingDataWhenSomeO
final Attestation attestation2 = addAttestationFromValidators(attestationData, 2, 4, 6, 8);
addAttestationFromValidators(attestationData, 2, 3, 9);

final Optional<ValidatableAttestation> result =
final Optional<Attestation> result =
aggregatingPool.createAggregateFor(attestationData.hashTreeRoot(), committeeIndex);
assertThat(result.map(ValidatableAttestation::getAttestation))
.contains(aggregateAttestations(attestation1, attestation2));
assertThat(result).contains(aggregateAttestations(attestation1, attestation2));
}

@TestTemplate
Expand Down