use of tech.pegasys.teku.infrastructure.ssz.collections.SszBitvector in project teku by ConsenSys.
the class SubnetScorer method scoreExistingPeer.
@Override
public int scoreExistingPeer(final NodeId peerId) {
final SszBitvector attSubscriptions = peerSubnetSubscriptions.getAttestationSubnetSubscriptions(peerId);
final SszBitvector syncCommitteeSubscriptions = peerSubnetSubscriptions.getSyncCommitteeSubscriptions(peerId);
return score(attSubscriptions, syncCommitteeSubscriptions, this::scoreSubnetForExistingPeer);
}
use of tech.pegasys.teku.infrastructure.ssz.collections.SszBitvector in project teku by ConsenSys.
the class NodeRecordConverterTest method shouldConvertAttnets.
@Test
public void shouldConvertAttnets() {
SszBitvector persistentSubnets = ATT_SUBNET_SCHEMA.ofBits(1, 8, 14, 32);
Bytes encodedPersistentSubnets = persistentSubnets.sszSerialize();
final Optional<DiscoveryPeer> result = convertNodeRecordWithFields(new EnrField(EnrField.IP_V6, IPV6_LOCALHOST), new EnrField(EnrField.TCP_V6, 1234), new EnrField(ATTESTATION_SUBNET_ENR_FIELD, encodedPersistentSubnets));
assertThat(result).contains(new DiscoveryPeer(PUB_KEY, new InetSocketAddress("::1", 1234), ENR_FORK_ID, persistentSubnets, SYNCNETS));
}
use of tech.pegasys.teku.infrastructure.ssz.collections.SszBitvector in project teku by ConsenSys.
the class NodeRecordConverterTest method shouldUseEmptyAttnetsWhenFieldValueIsInvalid.
@Test
public void shouldUseEmptyAttnetsWhenFieldValueIsInvalid() {
// Incorrect length
SszBitvector persistentSubnets = SszBitvectorSchema.create(4).ofBits(1, 2);
Bytes encodedPersistentSubnets = persistentSubnets.sszSerialize();
final Optional<DiscoveryPeer> result = convertNodeRecordWithFields(new EnrField(EnrField.IP_V6, IPV6_LOCALHOST), new EnrField(EnrField.TCP_V6, 1234), new EnrField(ATTESTATION_SUBNET_ENR_FIELD, encodedPersistentSubnets));
assertThat(result).contains(new DiscoveryPeer(PUB_KEY, new InetSocketAddress("::1", 1234), ENR_FORK_ID, ATT_SUBNET_SCHEMA.getDefault(), SYNCNETS));
}
use of tech.pegasys.teku.infrastructure.ssz.collections.SszBitvector in project teku by ConsenSys.
the class ValidatorDataProvider method getAggregationBits.
private IntIterable getAggregationBits(final Bytes aggregationBits, final UInt64 slot) {
final SchemaDefinitionsAltair altairDefinitions = SchemaDefinitionsAltair.required(spec.atSlot(slot).getSchemaDefinitions());
final SyncCommitteeContributionSchema syncCommitteeContributionSchema = altairDefinitions.getSyncCommitteeContributionSchema();
final SszBitvector aggregationBitsVector = syncCommitteeContributionSchema.getAggregationBitsSchema().fromBytes(aggregationBits);
return aggregationBitsVector.getAllSetBits();
}
use of tech.pegasys.teku.infrastructure.ssz.collections.SszBitvector in project teku by ConsenSys.
the class SyncCommitteeContribution method asInternalSyncCommitteeContribution.
public static tech.pegasys.teku.spec.datastructures.operations.versions.altair.SyncCommitteeContribution asInternalSyncCommitteeContribution(final Spec spec, final SyncCommitteeContribution syncCommitteeContribution) {
final SchemaDefinitionsAltair altairDefinitions = SchemaDefinitionsAltair.required(spec.atSlot(syncCommitteeContribution.slot).getSchemaDefinitions());
final SyncCommitteeContributionSchema syncCommitteeContributionSchema = altairDefinitions.getSyncCommitteeContributionSchema();
final SszBitvector aggregationBitsVector = syncCommitteeContributionSchema.getAggregationBitsSchema().fromBytes(syncCommitteeContribution.aggregationBits);
return spec.getSyncCommitteeUtilRequired(syncCommitteeContribution.slot).createSyncCommitteeContribution(syncCommitteeContribution.slot, syncCommitteeContribution.beaconBlockRoot, syncCommitteeContribution.subcommitteeIndex, aggregationBitsVector.getAllSetBits(), syncCommitteeContribution.signature.asInternalBLSSignature());
}
Aggregations