use of tech.pegasys.teku.spec.datastructures.operations.versions.altair.SignedContributionAndProof in project teku by ConsenSys.
the class BlockOperationSelectorFactoryTest method shouldIncludeValidOperations.
@Test
void shouldIncludeValidOperations() {
final UInt64 slot = UInt64.valueOf(2);
final BeaconState blockSlotState = dataStructureUtil.randomBeaconState(slot);
final SignedVoluntaryExit voluntaryExit = dataStructureUtil.randomSignedVoluntaryExit();
final ProposerSlashing proposerSlashing = dataStructureUtil.randomProposerSlashing();
final AttesterSlashing attesterSlashing = dataStructureUtil.randomAttesterSlashing();
final SignedContributionAndProof contribution = dataStructureUtil.randomSignedContributionAndProof(1, parentRoot);
addToPool(voluntaryExitPool, voluntaryExit);
addToPool(proposerSlashingPool, proposerSlashing);
addToPool(attesterSlashingPool, attesterSlashing);
assertThat(contributionPool.add(contribution)).isCompletedWithValue(ACCEPT);
factory.createSelector(parentRoot, blockSlotState, randaoReveal, Optional.empty()).accept(bodyBuilder);
assertThat(bodyBuilder.randaoReveal).isEqualTo(randaoReveal);
assertThat(bodyBuilder.graffiti).isEqualTo(defaultGraffiti);
assertThat(bodyBuilder.proposerSlashings).containsOnly(proposerSlashing);
assertThat(bodyBuilder.attesterSlashings).containsOnly(attesterSlashing);
assertThat(bodyBuilder.voluntaryExits).containsOnly(voluntaryExit);
assertThat(bodyBuilder.syncAggregate).isEqualTo(spec.getSyncCommitteeUtilRequired(slot).createSyncAggregate(List.of(contribution.getMessage().getContribution())));
}
use of tech.pegasys.teku.spec.datastructures.operations.versions.altair.SignedContributionAndProof in project teku by ConsenSys.
the class SyncCommitteeContributionPoolTest method shouldSelectBestContribution.
@Test
void shouldSelectBestContribution() {
final SignedContributionAndProof proof = dataStructureUtil.randomSignedContributionAndProof(25);
final SignedContributionAndProof bestProof = withParticipationBits(proof, 1, 2, 3);
addValid(withParticipationBits(proof, 1, 3));
addValid(bestProof);
addValid(withParticipationBits(proof, 2));
final SyncCommitteeContribution contribution = bestProof.getMessage().getContribution();
final SyncAggregate result = pool.createSyncAggregateForBlock(contribution.getSlot().plus(1), contribution.getBeaconBlockRoot());
assertSyncAggregateFromContribution(contribution, result);
}
use of tech.pegasys.teku.spec.datastructures.operations.versions.altair.SignedContributionAndProof in project teku by ConsenSys.
the class SignedContributionAndProofValidatorTest method shouldHandleBeaconBlockRootBeingFromBeforeCurrentSyncCommitteePeriod.
@Test
void shouldHandleBeaconBlockRootBeingFromBeforeCurrentSyncCommitteePeriod() {
final Bytes32 blockRoot = chainBuilder.getLatestBlockAndState().getRoot();
final UInt64 slot = UInt64.valueOf(config.getEpochsPerSyncCommitteePeriod() * config.getSlotsPerEpoch() + 1);
final UInt64 slotSeconds = slot.times(spec.getSecondsPerSlot(slot));
timeProvider.advanceTimeBy(Duration.ofSeconds(slotSeconds.longValue()));
storageSystem.chainUpdater().advanceChain(slot);
final SignedContributionAndProof message = chainBuilder.createValidSignedContributionAndProofBuilder().beaconBlockRoot(blockRoot).resetParticipantsToOnlyAggregator().build();
assertThat(validator.validate(message)).isCompletedWithValue(ACCEPT);
}
use of tech.pegasys.teku.spec.datastructures.operations.versions.altair.SignedContributionAndProof in project teku by ConsenSys.
the class SignedContributionAndProofValidatorTest method shouldRejectAggregateSignatureIsInvalid.
@Test
void shouldRejectAggregateSignatureIsInvalid() {
final SignedContributionAndProof message = chainBuilder.createValidSignedContributionAndProofBuilder().addParticipantSignature(dataStructureUtil.randomSignature()).build();
assertThat(validator.validate(message)).isCompletedWithValueMatching(InternalValidationResult::isReject);
}
use of tech.pegasys.teku.spec.datastructures.operations.versions.altair.SignedContributionAndProof in project teku by ConsenSys.
the class SignedContributionAndProofValidatorTest method shouldIgnoreWhenContributionIsNotFromTheCurrentSlot.
@Test
void shouldIgnoreWhenContributionIsNotFromTheCurrentSlot() {
final SignedContributionAndProof message = chainBuilder.createValidSignedContributionAndProofBuilder().build();
final UInt64 slot = message.getMessage().getContribution().getSlot().plus(1);
// disparity is 500 millis, so 1 second into next slot will be time
final UInt64 slotSeconds = slot.times(spec.getSecondsPerSlot(slot)).plus(1);
timeProvider.advanceTimeBy(Duration.ofSeconds(slotSeconds.longValue()));
storageSystem.chainUpdater().setCurrentSlot(message.getMessage().getContribution().getSlot().plus(1));
final SafeFuture<InternalValidationResult> result = validator.validate(message);
assertThat(result).isCompletedWithValue(IGNORE);
}
Aggregations