use of tech.pegasys.teku.core.synccomittee.SignedContributionAndProofTestBuilder in project teku by ConsenSys.
the class ChainBuilder method createValidSignedContributionAndProofBuilder.
public SignedContributionAndProofTestBuilder createValidSignedContributionAndProofBuilder(final UInt64 slot, final Bytes32 beaconBlockRoot) {
final SyncCommitteeUtil syncCommitteeUtil = spec.getSyncCommitteeUtilRequired(slot);
final SignedBlockAndState latestBlockAndState = getLatestBlockAndState();
final UInt64 epoch = syncCommitteeUtil.getEpochForDutiesAtSlot(slot);
final Map<UInt64, SyncSubcommitteeAssignments> subcommitteeAssignments = syncCommitteeUtil.getSyncSubcommittees(latestBlockAndState.getState(), epoch);
for (Map.Entry<UInt64, SyncSubcommitteeAssignments> entry : subcommitteeAssignments.entrySet()) {
final UInt64 validatorIndex = entry.getKey();
final Signer signer = getSigner(validatorIndex.intValue());
final SyncSubcommitteeAssignments assignments = entry.getValue();
for (int subcommitteeIndex : assignments.getAssignedSubcommittees()) {
final SyncAggregatorSelectionData syncAggregatorSelectionData = syncCommitteeUtil.createSyncAggregatorSelectionData(slot, UInt64.valueOf(subcommitteeIndex));
final BLSSignature proof = signer.signSyncCommitteeSelectionProof(syncAggregatorSelectionData, latestBlockAndState.getState().getForkInfo()).join();
if (syncCommitteeUtil.isSyncCommitteeAggregator(proof)) {
return new SignedContributionAndProofTestBuilder().signerProvider(this::getSigner).syncCommitteeUtil(syncCommitteeUtil).spec(spec).state(latestBlockAndState.getState()).subcommitteeIndex(subcommitteeIndex).slot(slot).selectionProof(proof).beaconBlockRoot(beaconBlockRoot).aggregator(validatorIndex, signer);
}
}
}
throw new IllegalStateException("No valid sync subcommittee aggregators found");
}
Aggregations