diff --git a/data/beaconrestapi/src/integration-test/resources/tech/pegasys/teku/beaconrestapi/beacon/schema/MetaData.json b/data/beaconrestapi/src/integration-test/resources/tech/pegasys/teku/beaconrestapi/beacon/schema/MetaData.json index d31c977b044..56d34e17d79 100644 --- a/data/beaconrestapi/src/integration-test/resources/tech/pegasys/teku/beaconrestapi/beacon/schema/MetaData.json +++ b/data/beaconrestapi/src/integration-test/resources/tech/pegasys/teku/beaconrestapi/beacon/schema/MetaData.json @@ -21,9 +21,9 @@ "description" : "Bitvector representing the node's persistent sync committee subnet subscriptions.", "format" : "bytes" }, - "custody_subnet_count" : { + "custody_group_count" : { "type" : "string", - "description" : "PeerDAS custody subnet count.", + "description" : "PeerDAS custody group count.", "example" : "1", "format" : "uint64" } diff --git a/data/beaconrestapi/src/main/java/tech/pegasys/teku/beaconrestapi/handlers/v1/node/GetIdentity.java b/data/beaconrestapi/src/main/java/tech/pegasys/teku/beaconrestapi/handlers/v1/node/GetIdentity.java index 8d49660e3f4..97c160fa4af 100644 --- a/data/beaconrestapi/src/main/java/tech/pegasys/teku/beaconrestapi/handlers/v1/node/GetIdentity.java +++ b/data/beaconrestapi/src/main/java/tech/pegasys/teku/beaconrestapi/handlers/v1/node/GetIdentity.java @@ -140,9 +140,9 @@ private static SerializableTypeDefinition createMetadataType( "Bitvector representing the node's persistent sync committee subnet subscriptions."), MetadataMessage::getOptionalSyncnets) .withOptionalField( - "custody_subnet_count", - UINT64_TYPE.withDescription("PeerDAS custody subnet count."), - MetadataMessage::getOptionalCustodySubnetCount) + "custody_group_count", + UINT64_TYPE.withDescription("PeerDAS custody group count."), + MetadataMessage::getOptionalCustodyGroupCount) .build(); } diff --git a/data/serializer/src/main/java/tech/pegasys/teku/api/schema/Metadata.java b/data/serializer/src/main/java/tech/pegasys/teku/api/schema/Metadata.java index f17194feb95..a771ae50ee7 100644 --- a/data/serializer/src/main/java/tech/pegasys/teku/api/schema/Metadata.java +++ b/data/serializer/src/main/java/tech/pegasys/teku/api/schema/Metadata.java @@ -57,23 +57,23 @@ public class Metadata { @JsonInclude(JsonInclude.Include.NON_NULL) public final String syncCommitteeSubscriptions; - @JsonProperty("custody_subnet_count") + @JsonProperty("custody_group_count") @Schema( type = "string", pattern = PATTERN_UINT8, - description = "Uint8 value representing the node's custody subnet count") - public final String custodySubnetCount; + description = "Uint8 value representing the node's custody group count") + public final String custodyGroupCount; @JsonCreator public Metadata( @JsonProperty("seq_number") final String sequenceNumber, @JsonProperty("attnets") final String attestationSubnetSubscriptions, @JsonProperty("syncnets") final String syncCommitteeSubscriptions, - @JsonProperty("custody_subnet_count") final String custodySubnetCount) { + @JsonProperty("custody_group_count") final String custodyGroupCount) { this.sequenceNumber = sequenceNumber; this.attestationSubnetSubscriptions = attestationSubnetSubscriptions; this.syncCommitteeSubscriptions = syncCommitteeSubscriptions; - this.custodySubnetCount = custodySubnetCount; + this.custodyGroupCount = custodyGroupCount; } public Metadata(final MetadataMessage metadataMessage) { @@ -88,8 +88,8 @@ public Metadata(final MetadataMessage metadataMessage) { .sszSerialize() .toHexString() .toLowerCase(Locale.ROOT); - this.custodySubnetCount = - ((MetadataMessageFulu) metadataMessage).getCustodySubnetCount().toString(); + this.custodyGroupCount = + ((MetadataMessageFulu) metadataMessage).getCustodyGroupCount().toString(); } else if (metadataMessage instanceof MetadataMessageAltair) { this.syncCommitteeSubscriptions = ((MetadataMessageAltair) metadataMessage) @@ -97,10 +97,10 @@ public Metadata(final MetadataMessage metadataMessage) { .sszSerialize() .toHexString() .toLowerCase(Locale.ROOT); - this.custodySubnetCount = null; + this.custodyGroupCount = null; } else { this.syncCommitteeSubscriptions = null; - this.custodySubnetCount = null; + this.custodyGroupCount = null; } } @@ -116,7 +116,7 @@ public boolean equals(final Object o) { return Objects.equals(sequenceNumber, metadata.sequenceNumber) && Objects.equals(attestationSubnetSubscriptions, metadata.attestationSubnetSubscriptions) && Objects.equals(syncCommitteeSubscriptions, metadata.syncCommitteeSubscriptions) - && Objects.equals(custodySubnetCount, metadata.custodySubnetCount); + && Objects.equals(custodyGroupCount, metadata.custodyGroupCount); } @Override @@ -125,6 +125,6 @@ public int hashCode() { sequenceNumber, attestationSubnetSubscriptions, syncCommitteeSubscriptions, - custodySubnetCount); + custodyGroupCount); } } diff --git a/eth-reference-tests/src/referenceTest/java/tech/pegasys/teku/reference/fulu/networking/ComputeColumnsForCustodyGroupTestExecutor.java b/eth-reference-tests/src/referenceTest/java/tech/pegasys/teku/reference/fulu/networking/ComputeColumnsForCustodyGroupTestExecutor.java new file mode 100644 index 00000000000..c2732f639be --- /dev/null +++ b/eth-reference-tests/src/referenceTest/java/tech/pegasys/teku/reference/fulu/networking/ComputeColumnsForCustodyGroupTestExecutor.java @@ -0,0 +1,59 @@ +/* + * Copyright Consensys Software Inc., 2022 + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package tech.pegasys.teku.reference.fulu.networking; + +import static org.assertj.core.api.Assertions.assertThat; +import static tech.pegasys.teku.reference.TestDataUtils.loadYaml; + +import com.fasterxml.jackson.annotation.JsonProperty; +import java.util.HashSet; +import java.util.List; +import java.util.Set; +import java.util.stream.Collectors; +import tech.pegasys.teku.ethtests.finder.TestDefinition; +import tech.pegasys.teku.infrastructure.unsigned.UInt64; +import tech.pegasys.teku.reference.TestExecutor; +import tech.pegasys.teku.spec.SpecVersion; +import tech.pegasys.teku.spec.logic.versions.fulu.helpers.MiscHelpersFulu; + +public class ComputeColumnsForCustodyGroupTestExecutor implements TestExecutor { + + @Override + public void runTest(final TestDefinition testDefinition) throws Exception { + final ComputeColumnForCustodyGroupMetaData metaData = + loadYaml(testDefinition, "meta.yaml", ComputeColumnForCustodyGroupMetaData.class); + final SpecVersion spec = testDefinition.getSpec().getGenesisSpec(); + final List actualResult = + MiscHelpersFulu.required(spec.miscHelpers()) + .computeColumnsForCustodyGroup(UInt64.valueOf(metaData.getCustodyGroup())); + assertThat(new HashSet<>(actualResult)).isEqualTo(metaData.getResult()); + } + + private static class ComputeColumnForCustodyGroupMetaData { + + @JsonProperty(value = "custody_group", required = true) + private int custodyGroup; + + @JsonProperty(value = "result", required = true) + private List result; + + public int getCustodyGroup() { + return custodyGroup; + } + + public Set getResult() { + return result.stream().map(UInt64::valueOf).collect(Collectors.toUnmodifiableSet()); + } + } +} diff --git a/eth-reference-tests/src/referenceTest/java/tech/pegasys/teku/reference/fulu/networking/GetCustodyColumnsTestExecutor.java b/eth-reference-tests/src/referenceTest/java/tech/pegasys/teku/reference/fulu/networking/GetCustodyGroupsTestExecutor.java similarity index 83% rename from eth-reference-tests/src/referenceTest/java/tech/pegasys/teku/reference/fulu/networking/GetCustodyColumnsTestExecutor.java rename to eth-reference-tests/src/referenceTest/java/tech/pegasys/teku/reference/fulu/networking/GetCustodyGroupsTestExecutor.java index 39493712101..53d59db7e98 100644 --- a/eth-reference-tests/src/referenceTest/java/tech/pegasys/teku/reference/fulu/networking/GetCustodyColumnsTestExecutor.java +++ b/eth-reference-tests/src/referenceTest/java/tech/pegasys/teku/reference/fulu/networking/GetCustodyGroupsTestExecutor.java @@ -29,25 +29,25 @@ import tech.pegasys.teku.spec.SpecVersion; import tech.pegasys.teku.spec.logic.versions.fulu.helpers.MiscHelpersFulu; -public class GetCustodyColumnsTestExecutor implements TestExecutor { +public class GetCustodyGroupsTestExecutor implements TestExecutor { @Override public void runTest(final TestDefinition testDefinition) throws Exception { - final GetCustodyColumnsMetaData metaData = - loadYaml(testDefinition, "meta.yaml", GetCustodyColumnsMetaData.class); + final GetCustodyGroupsMetaData metaData = + loadYaml(testDefinition, "meta.yaml", GetCustodyGroupsMetaData.class); final SpecVersion spec = testDefinition.getSpec().getGenesisSpec(); final List actualResult = MiscHelpersFulu.required(spec.miscHelpers()) - .computeCustodyColumnIndexes(metaData.getNodeId(), metaData.getCustodySubnetCount()); + .getCustodyGroups(metaData.getNodeId(), metaData.getCustodySubnetCount()); assertThat(new HashSet<>(actualResult)).isEqualTo(metaData.getResult()); } - private static class GetCustodyColumnsMetaData { + private static class GetCustodyGroupsMetaData { @JsonProperty(value = "node_id", required = true) private String nodeId; - @JsonProperty(value = "custody_subnet_count", required = true) + @JsonProperty(value = "custody_group_count", required = true) private int custodySubnetCount; @JsonProperty(value = "result", required = true) diff --git a/eth-reference-tests/src/referenceTest/java/tech/pegasys/teku/reference/fulu/networking/NetworkingTests.java b/eth-reference-tests/src/referenceTest/java/tech/pegasys/teku/reference/fulu/networking/NetworkingTests.java index 0d1a0306ed7..c30c27fed72 100644 --- a/eth-reference-tests/src/referenceTest/java/tech/pegasys/teku/reference/fulu/networking/NetworkingTests.java +++ b/eth-reference-tests/src/referenceTest/java/tech/pegasys/teku/reference/fulu/networking/NetworkingTests.java @@ -19,6 +19,9 @@ public class NetworkingTests { public static final ImmutableMap NETWORKING_TEST_TYPES = ImmutableMap.builder() - .put("networking/get_custody_columns", new GetCustodyColumnsTestExecutor()) + .put("networking/get_custody_groups", new GetCustodyGroupsTestExecutor()) + .put( + "networking/compute_columns_for_custody_group", + new ComputeColumnsForCustodyGroupTestExecutor()) .build(); } diff --git a/ethereum/spec/src/main/java/tech/pegasys/teku/spec/Spec.java b/ethereum/spec/src/main/java/tech/pegasys/teku/spec/Spec.java index fd8a82f5815..af4d8e2b4bf 100644 --- a/ethereum/spec/src/main/java/tech/pegasys/teku/spec/Spec.java +++ b/ethereum/spec/src/main/java/tech/pegasys/teku/spec/Spec.java @@ -1022,12 +1022,6 @@ public boolean isAvailabilityOfDataColumnSidecarsRequiredAtEpoch( .isLessThanOrEqualTo(specConfigFulu.getMinEpochsForDataColumnSidecarsRequests()); } - public UInt64 computeSubnetForDataColumnSidecar(final DataColumnSidecar dataColumnSidecar) { - final SpecConfig config = atSlot(dataColumnSidecar.getSlot()).getConfig(); - final SpecConfigFulu specConfigFulu = SpecConfigFulu.required(config); - return dataColumnSidecar.getIndex().mod(specConfigFulu.getDataColumnSidecarSubnetCount()); - } - public Optional computeFirstSlotWithBlobSupport() { return getSpecConfigDeneb() .map(SpecConfigDeneb::getDenebForkEpoch) diff --git a/ethereum/spec/src/main/java/tech/pegasys/teku/spec/config/DelegatingSpecConfigFulu.java b/ethereum/spec/src/main/java/tech/pegasys/teku/spec/config/DelegatingSpecConfigFulu.java index 87dec9c8008..58f59fed82c 100644 --- a/ethereum/spec/src/main/java/tech/pegasys/teku/spec/config/DelegatingSpecConfigFulu.java +++ b/ethereum/spec/src/main/java/tech/pegasys/teku/spec/config/DelegatingSpecConfigFulu.java @@ -62,6 +62,11 @@ public int getNumberOfColumns() { return delegate.getNumberOfColumns(); } + @Override + public int getNumberOfCustodyGroups() { + return delegate.getNumberOfCustodyGroups(); + } + @Override public int getDataColumnSidecarSubnetCount() { return delegate.getDataColumnSidecarSubnetCount(); diff --git a/ethereum/spec/src/main/java/tech/pegasys/teku/spec/config/SpecConfigFulu.java b/ethereum/spec/src/main/java/tech/pegasys/teku/spec/config/SpecConfigFulu.java index 28052703a7e..624d65fad74 100644 --- a/ethereum/spec/src/main/java/tech/pegasys/teku/spec/config/SpecConfigFulu.java +++ b/ethereum/spec/src/main/java/tech/pegasys/teku/spec/config/SpecConfigFulu.java @@ -41,6 +41,8 @@ static SpecConfigFulu required(final SpecConfig specConfig) { int getNumberOfColumns(); + int getNumberOfCustodyGroups(); + // networking int getDataColumnSidecarSubnetCount(); diff --git a/ethereum/spec/src/main/java/tech/pegasys/teku/spec/config/SpecConfigFuluImpl.java b/ethereum/spec/src/main/java/tech/pegasys/teku/spec/config/SpecConfigFuluImpl.java index 34d75d4d09c..9da46c3899d 100644 --- a/ethereum/spec/src/main/java/tech/pegasys/teku/spec/config/SpecConfigFuluImpl.java +++ b/ethereum/spec/src/main/java/tech/pegasys/teku/spec/config/SpecConfigFuluImpl.java @@ -25,6 +25,7 @@ public class SpecConfigFuluImpl extends DelegatingSpecConfigElectra implements S private final UInt64 fuluForkEpoch; private final int numberOfColumns; + private final int numberOfCustodyGroups; private final int dataColumnSidecarSubnetCount; private final int custodyRequirement; private final int samplesPerSlot; @@ -42,6 +43,7 @@ public SpecConfigFuluImpl( final UInt64 fieldElementsPerExtBlob, final UInt64 kzgCommitmentsInclusionProofDepth, final int numberOfColumns, + final int numberOfCustodyGroups, final int dataColumnSidecarSubnetCount, final int custodyRequirement, final int samplesPerSlot, @@ -54,6 +56,7 @@ public SpecConfigFuluImpl( this.fieldElementsPerExtBlob = fieldElementsPerExtBlob; this.kzgCommitmentsInclusionProofDepth = kzgCommitmentsInclusionProofDepth; this.numberOfColumns = numberOfColumns; + this.numberOfCustodyGroups = numberOfCustodyGroups; this.dataColumnSidecarSubnetCount = dataColumnSidecarSubnetCount; this.custodyRequirement = custodyRequirement; this.samplesPerSlot = samplesPerSlot; @@ -91,6 +94,11 @@ public int getNumberOfColumns() { return numberOfColumns; } + @Override + public int getNumberOfCustodyGroups() { + return numberOfCustodyGroups; + } + @Override public int getDataColumnSidecarSubnetCount() { return dataColumnSidecarSubnetCount; @@ -142,6 +150,7 @@ public boolean equals(final Object o) { && Objects.equals(fieldElementsPerExtBlob, that.fieldElementsPerExtBlob) && Objects.equals(kzgCommitmentsInclusionProofDepth, that.kzgCommitmentsInclusionProofDepth) && numberOfColumns == that.numberOfColumns + && numberOfCustodyGroups == that.numberOfCustodyGroups && dataColumnSidecarSubnetCount == that.dataColumnSidecarSubnetCount && custodyRequirement == that.custodyRequirement && minEpochsForDataColumnSidecarsRequests == that.minEpochsForDataColumnSidecarsRequests @@ -155,6 +164,7 @@ public int hashCode() { fuluForkVersion, fuluForkEpoch, numberOfColumns, + numberOfCustodyGroups, dataColumnSidecarSubnetCount, custodyRequirement, fieldElementsPerCell, diff --git a/ethereum/spec/src/main/java/tech/pegasys/teku/spec/config/builder/FuluBuilder.java b/ethereum/spec/src/main/java/tech/pegasys/teku/spec/config/builder/FuluBuilder.java index b5cee91c6a9..d4fad700193 100644 --- a/ethereum/spec/src/main/java/tech/pegasys/teku/spec/config/builder/FuluBuilder.java +++ b/ethereum/spec/src/main/java/tech/pegasys/teku/spec/config/builder/FuluBuilder.java @@ -36,6 +36,8 @@ public class FuluBuilder implements ForkConfigBuilder build( fieldElementsPerExtBlob, kzgCommitmentsInclusionProofDepth, numberOfColumns, + numberOfCustodyGroups, dataColumnSidecarSubnetCount, custodyRequirement, samplesPerSlot, @@ -101,6 +104,12 @@ public FuluBuilder numberOfColumns(final Integer numberOfColumns) { return this; } + public FuluBuilder numberOfCustodyGroups(final Integer numberOfCustodyGroups) { + checkNotNull(numberOfCustodyGroups); + this.numberOfCustodyGroups = numberOfCustodyGroups; + return this; + } + public FuluBuilder dataColumnSidecarSubnetCount(final Integer dataColumnSidecarSubnetCount) { checkNotNull(dataColumnSidecarSubnetCount); this.dataColumnSidecarSubnetCount = dataColumnSidecarSubnetCount; @@ -153,6 +162,7 @@ public Map getValidationMap() { constants.put("fuluForkEpoch", fuluForkEpoch); constants.put("fuluForkVersion", fuluForkVersion); constants.put("numberOfColumns", numberOfColumns); + constants.put("numberOfCustodyGroups", numberOfCustodyGroups); constants.put("dataColumnSidecarSubnetCount", dataColumnSidecarSubnetCount); constants.put("custodyRequirement", custodyRequirement); constants.put("samplesPerSlot", samplesPerSlot); diff --git a/ethereum/spec/src/main/java/tech/pegasys/teku/spec/datastructures/networking/libp2p/rpc/metadata/MetadataMessage.java b/ethereum/spec/src/main/java/tech/pegasys/teku/spec/datastructures/networking/libp2p/rpc/metadata/MetadataMessage.java index 1bbcb463c89..e8bfd51f67a 100644 --- a/ethereum/spec/src/main/java/tech/pegasys/teku/spec/datastructures/networking/libp2p/rpc/metadata/MetadataMessage.java +++ b/ethereum/spec/src/main/java/tech/pegasys/teku/spec/datastructures/networking/libp2p/rpc/metadata/MetadataMessage.java @@ -33,7 +33,7 @@ default Optional getOptionalSyncnets() { return Optional.empty(); } - default Optional getOptionalCustodySubnetCount() { + default Optional getOptionalCustodyGroupCount() { return Optional.empty(); } } diff --git a/ethereum/spec/src/main/java/tech/pegasys/teku/spec/datastructures/networking/libp2p/rpc/metadata/versions/fulu/MetadataMessageFulu.java b/ethereum/spec/src/main/java/tech/pegasys/teku/spec/datastructures/networking/libp2p/rpc/metadata/versions/fulu/MetadataMessageFulu.java index 15fbc2369eb..b08834d85e4 100644 --- a/ethereum/spec/src/main/java/tech/pegasys/teku/spec/datastructures/networking/libp2p/rpc/metadata/versions/fulu/MetadataMessageFulu.java +++ b/ethereum/spec/src/main/java/tech/pegasys/teku/spec/datastructures/networking/libp2p/rpc/metadata/versions/fulu/MetadataMessageFulu.java @@ -38,8 +38,8 @@ public class MetadataMessageFulu final UInt64 seqNumber, final SszBitvector attNets, final SszBitvector syncNets, - final UInt64 custodySubnetCount) { - super(schema, SszUInt64.of(seqNumber), attNets, syncNets, SszUInt64.of(custodySubnetCount)); + final UInt64 custodyGroupCount) { + super(schema, SszUInt64.of(seqNumber), attNets, syncNets, SszUInt64.of(custodyGroupCount)); } @Override @@ -56,7 +56,7 @@ public SszBitvector getSyncnets() { return getField2(); } - public UInt64 getCustodySubnetCount() { + public UInt64 getCustodyGroupCount() { return getField3().get(); } @@ -66,7 +66,7 @@ public Optional getOptionalSyncnets() { } @Override - public Optional getOptionalCustodySubnetCount() { - return Optional.of(getCustodySubnetCount()); + public Optional getOptionalCustodyGroupCount() { + return Optional.of(getCustodyGroupCount()); } } diff --git a/ethereum/spec/src/main/java/tech/pegasys/teku/spec/datastructures/networking/libp2p/rpc/metadata/versions/fulu/MetadataMessageSchemaFulu.java b/ethereum/spec/src/main/java/tech/pegasys/teku/spec/datastructures/networking/libp2p/rpc/metadata/versions/fulu/MetadataMessageSchemaFulu.java index 765ca9325d3..d064c5b2391 100644 --- a/ethereum/spec/src/main/java/tech/pegasys/teku/spec/datastructures/networking/libp2p/rpc/metadata/versions/fulu/MetadataMessageSchemaFulu.java +++ b/ethereum/spec/src/main/java/tech/pegasys/teku/spec/datastructures/networking/libp2p/rpc/metadata/versions/fulu/MetadataMessageSchemaFulu.java @@ -36,7 +36,7 @@ public MetadataMessageSchemaFulu(final NetworkingSpecConfig networkingSpecConfig "attnets", SszBitvectorSchema.create(networkingSpecConfig.getAttestationSubnetCount())), namedSchema( "syncnets", SszBitvectorSchema.create(NetworkConstants.SYNC_COMMITTEE_SUBNET_COUNT)), - namedSchema("custody_subnet_count", SszPrimitiveSchemas.UINT64_SCHEMA)); + namedSchema("custody_group_count", SszPrimitiveSchemas.UINT64_SCHEMA)); } @Override @@ -44,13 +44,13 @@ public MetadataMessageFulu create( final UInt64 seqNumber, final Iterable attnets, final Iterable syncnets, - final Optional custodySubnetCount) { + final Optional custodyGroupCount) { return new MetadataMessageFulu( this, seqNumber, getAttnestSchema().ofBits(attnets), getSyncnetsSchema().ofBits(syncnets), - custodySubnetCount.orElse(UInt64.ZERO)); + custodyGroupCount.orElse(UInt64.ZERO)); } @Override diff --git a/ethereum/spec/src/main/java/tech/pegasys/teku/spec/logic/versions/fulu/helpers/MiscHelpersFulu.java b/ethereum/spec/src/main/java/tech/pegasys/teku/spec/logic/versions/fulu/helpers/MiscHelpersFulu.java index 55764099710..c18269db2fa 100644 --- a/ethereum/spec/src/main/java/tech/pegasys/teku/spec/logic/versions/fulu/helpers/MiscHelpersFulu.java +++ b/ethereum/spec/src/main/java/tech/pegasys/teku/spec/logic/versions/fulu/helpers/MiscHelpersFulu.java @@ -25,7 +25,6 @@ import java.util.stream.Collectors; import java.util.stream.IntStream; import java.util.stream.Stream; -import org.apache.commons.lang3.tuple.Pair; import org.apache.tuweni.bytes.Bytes32; import org.apache.tuweni.units.bigints.UInt256; import tech.pegasys.teku.infrastructure.crypto.Hash; @@ -97,62 +96,71 @@ public Optional toVersionFulu() { return Optional.of(this); } + private UInt256 incrementByModule(final UInt256 n) { + if (n.equals(UInt256.MAX_VALUE)) { + return UInt256.ZERO; + } else { + return n.plus(1); + } + } + public UInt64 computeSubnetForDataColumnSidecar(final UInt64 columnIndex) { return columnIndex.mod(specConfigFulu.getDataColumnSidecarSubnetCount()); } - private UInt64 computeCustodySubnetIndex(final UInt256 nodeId) { - return bytesToUInt64(Hash.sha256(uint256ToBytes(nodeId)).slice(0, 8)) - .mod(specConfigFulu.getDataColumnSidecarSubnetCount()); + public List computeDataColumnSidecarBackboneSubnets( + final UInt256 nodeId, final UInt64 epoch, final int groupCount) { + final List columns = computeCustodyColumnIndexes(nodeId, groupCount); + return columns.stream().map(this::computeSubnetForDataColumnSidecar).toList(); + } + + public List computeCustodyColumnIndexes(final UInt256 nodeId, final int groupCount) { + final List custodyGroups = getCustodyGroups(nodeId, groupCount); + return custodyGroups.stream() + .flatMap(group -> computeColumnsForCustodyGroup(group).stream()) + .toList(); } - public List computeCustodySubnetIndexes(final UInt256 nodeId, final int subnetCount) { - // assert custody_subnet_count <= DATA_COLUMN_SIDECAR_SUBNET_COUNT - if (subnetCount > specConfigFulu.getDataColumnSidecarSubnetCount()) { + public List computeColumnsForCustodyGroup(final UInt64 custodyGroup) { + if (custodyGroup.isGreaterThanOrEqualTo(specConfigFulu.getNumberOfCustodyGroups())) { throw new IllegalArgumentException( String.format( - "Subnet count %s couldn't exceed number of subnet columns %s", - subnetCount, specConfigFulu.getDataColumnSidecarSubnetCount())); + "Custody group %s couldn't exceed number of groups %s", + custodyGroup, specConfigFulu.getNumberOfCustodyGroups())); } - return Stream.iterate(nodeId, this::incrementByModule) - .map(this::computeCustodySubnetIndex) - .distinct() - .limit(subnetCount) + final int columnsPerGroup = + specConfigFulu.getNumberOfColumns() / specConfigFulu.getNumberOfCustodyGroups(); + + return IntStream.range(0, columnsPerGroup) + .mapToLong( + i -> (long) specConfigFulu.getNumberOfCustodyGroups() * i + custodyGroup.intValue()) .sorted() + .mapToObj(UInt64::valueOf) .toList(); } - private UInt256 incrementByModule(final UInt256 n) { - if (n.equals(UInt256.MAX_VALUE)) { - return UInt256.ZERO; - } else { - return n.plus(1); - } + private UInt64 computeCustodyGroupIndex(final UInt256 nodeId) { + return bytesToUInt64(Hash.sha256(uint256ToBytes(nodeId)).slice(0, 8)) + .mod(specConfigFulu.getNumberOfCustodyGroups()); } - public List computeCustodyColumnIndexes(final UInt256 nodeId, final int subnetCount) { - final List subnetIds = computeCustodySubnetIndexes(nodeId, subnetCount); - final int columnsPerSubnet = - specConfigFulu.getNumberOfColumns() / specConfigFulu.getDataColumnSidecarSubnetCount(); - return subnetIds.stream() - .flatMap( - subnetId -> IntStream.range(0, columnsPerSubnet).mapToObj(i -> Pair.of(subnetId, i))) - .map( - // ColumnIndex(DATA_COLUMN_SIDECAR_SUBNET_COUNT * i + subnet_id) - pair -> - specConfigFulu.getDataColumnSidecarSubnetCount() * pair.getRight() - + pair.getLeft().intValue()) - .map(UInt64::valueOf) + public List getCustodyGroups(final UInt256 nodeId, final int custodyGroupCount) { + if (custodyGroupCount > specConfigFulu.getNumberOfCustodyGroups()) { + throw new IllegalArgumentException( + String.format( + "Custody group count %s couldn't exceed number of groups %s", + custodyGroupCount, specConfigFulu.getNumberOfCustodyGroups())); + } + + return Stream.iterate(nodeId, this::incrementByModule) + .map(this::computeCustodyGroupIndex) + .distinct() + .limit(custodyGroupCount) .sorted() .toList(); } - public List computeDataColumnSidecarBackboneSubnets( - final UInt256 nodeId, final UInt64 epoch, final int subnetCount) { - return computeCustodySubnetIndexes(nodeId, subnetCount); - } - public boolean verifyDataColumnSidecarKzgProof( final KZG kzg, final DataColumnSidecar dataColumnSidecar) { final int dataColumns = specConfigFulu.getNumberOfColumns(); diff --git a/ethereum/spec/src/main/resources/tech/pegasys/teku/spec/config/configs/mainnet.yaml b/ethereum/spec/src/main/resources/tech/pegasys/teku/spec/config/configs/mainnet.yaml index e11bd949335..aecd8059029 100644 --- a/ethereum/spec/src/main/resources/tech/pegasys/teku/spec/config/configs/mainnet.yaml +++ b/ethereum/spec/src/main/resources/tech/pegasys/teku/spec/config/configs/mainnet.yaml @@ -161,6 +161,7 @@ MAX_REQUEST_BLOB_SIDECARS_ELECTRA: 1152 # [New in FULU] NUMBER_OF_COLUMNS: 128 +NUMBER_OF_CUSTODY_GROUPS: 128 DATA_COLUMN_SIDECAR_SUBNET_COUNT: 128 MAX_REQUEST_DATA_COLUMN_SIDECARS: 512 SAMPLES_PER_SLOT: 8 diff --git a/ethereum/spec/src/main/resources/tech/pegasys/teku/spec/config/configs/minimal.yaml b/ethereum/spec/src/main/resources/tech/pegasys/teku/spec/config/configs/minimal.yaml index 1c23a98c95d..38efd2c492b 100644 --- a/ethereum/spec/src/main/resources/tech/pegasys/teku/spec/config/configs/minimal.yaml +++ b/ethereum/spec/src/main/resources/tech/pegasys/teku/spec/config/configs/minimal.yaml @@ -162,6 +162,7 @@ MAX_REQUEST_BLOB_SIDECARS_ELECTRA: 1152 # [New in FULU] NUMBER_OF_COLUMNS: 128 +NUMBER_OF_CUSTODY_GROUPS: 128 DATA_COLUMN_SIDECAR_SUBNET_COUNT: 128 MAX_REQUEST_DATA_COLUMN_SIDECARS: 512 SAMPLES_PER_SLOT: 8 diff --git a/ethereum/spec/src/main/resources/tech/pegasys/teku/spec/config/configs/swift.yaml b/ethereum/spec/src/main/resources/tech/pegasys/teku/spec/config/configs/swift.yaml index b61879ee9d6..dccf2c6fc8e 100644 --- a/ethereum/spec/src/main/resources/tech/pegasys/teku/spec/config/configs/swift.yaml +++ b/ethereum/spec/src/main/resources/tech/pegasys/teku/spec/config/configs/swift.yaml @@ -156,6 +156,7 @@ MAX_REQUEST_BLOB_SIDECARS_ELECTRA: 1152 # [New in FULU] NUMBER_OF_COLUMNS: 128 +NUMBER_OF_CUSTODY_GROUPS: 128 DATA_COLUMN_SIDECAR_SUBNET_COUNT: 128 MAX_REQUEST_DATA_COLUMN_SIDECARS: 512 SAMPLES_PER_SLOT: 8 diff --git a/ethereum/spec/src/test/java/tech/pegasys/teku/spec/logic/versions/fulu/helpers/MiscHelpersFuluTest.java b/ethereum/spec/src/test/java/tech/pegasys/teku/spec/logic/versions/fulu/helpers/MiscHelpersFuluTest.java index b2ead7eb2fb..90a0804f345 100644 --- a/ethereum/spec/src/test/java/tech/pegasys/teku/spec/logic/versions/fulu/helpers/MiscHelpersFuluTest.java +++ b/ethereum/spec/src/test/java/tech/pegasys/teku/spec/logic/versions/fulu/helpers/MiscHelpersFuluTest.java @@ -59,7 +59,11 @@ public class MiscHelpersFuluTest extends KZGAbstractBenchmark { TestSpecFactory.createMinimalFulu( builder -> builder.fuluBuilder( - fuluBuilder -> fuluBuilder.numberOfColumns(128).samplesPerSlot(16))); + fuluBuilder -> + fuluBuilder + .numberOfColumns(128) + .numberOfCustodyGroups(128) + .samplesPerSlot(16))); private final PredicatesElectra predicates = new PredicatesElectra(spec.getGenesisSpecConfig()); private final SchemaDefinitionsElectra schemaDefinitionsElectra = SchemaDefinitionsElectra.required(spec.getGenesisSchemaDefinitions()); diff --git a/ethereum/statetransition/src/main/java/tech/pegasys/teku/statetransition/datacolumns/DasSamplerBasic.java b/ethereum/statetransition/src/main/java/tech/pegasys/teku/statetransition/datacolumns/DasSamplerBasic.java index efa5450c3ae..e99829e61a8 100644 --- a/ethereum/statetransition/src/main/java/tech/pegasys/teku/statetransition/datacolumns/DasSamplerBasic.java +++ b/ethereum/statetransition/src/main/java/tech/pegasys/teku/statetransition/datacolumns/DasSamplerBasic.java @@ -45,7 +45,7 @@ public class DasSamplerBasic implements DataAvailabilitySampler, FinalizedCheckp private static final Logger LOG = LogManager.getLogger("das-nyota"); private final UInt256 nodeId; - private final int totalCustodySubnetCount; + private final int myTotalCustodyGroups; private final UpdatableDataColumnSidecarCustody custody; private final DataColumnSidecarRetriever retriever; @@ -60,7 +60,7 @@ public DasSamplerBasic( final UpdatableDataColumnSidecarCustody custody, final DataColumnSidecarRetriever retriever, final UInt256 nodeId, - final int totalCustodySubnetCount) { + final int myTotalCustodyGroups) { this.currentSlotProvider = currentSlotProvider; checkNotNull(spec); checkNotNull(db); @@ -71,7 +71,7 @@ public DasSamplerBasic( this.custody = custody; this.retriever = retriever; this.nodeId = nodeId; - this.totalCustodySubnetCount = totalCustodySubnetCount; + this.myTotalCustodyGroups = myTotalCustodyGroups; } private int getColumnCount(final UInt64 slot) { @@ -85,7 +85,7 @@ private List calculateSamplingColumnIds( return maybeMiscHelpers .map( miscHelpersFulu -> - miscHelpersFulu.computeCustodyColumnIndexes(nodeId, totalCustodySubnetCount)) + miscHelpersFulu.computeCustodyColumnIndexes(nodeId, myTotalCustodyGroups)) .orElse(Collections.emptyList()) .stream() .map(columnIndex -> new DataColumnSlotAndIdentifier(slot, blockRoot, columnIndex)) diff --git a/ethereum/statetransition/src/main/java/tech/pegasys/teku/statetransition/datacolumns/DataColumnSidecarCustodyImpl.java b/ethereum/statetransition/src/main/java/tech/pegasys/teku/statetransition/datacolumns/DataColumnSidecarCustodyImpl.java index d07f6fd3739..cf31ac2e821 100644 --- a/ethereum/statetransition/src/main/java/tech/pegasys/teku/statetransition/datacolumns/DataColumnSidecarCustodyImpl.java +++ b/ethereum/statetransition/src/main/java/tech/pegasys/teku/statetransition/datacolumns/DataColumnSidecarCustodyImpl.java @@ -87,7 +87,7 @@ public boolean isIncomplete() { private final DataColumnSidecarDbAccessor db; private final CanonicalBlockResolver blockResolver; private final UInt256 nodeId; - private final int totalCustodySubnetCount; + private final int totalCustodyGroupCount; private final MinCustodyPeriodSlotCalculator minCustodyPeriodSlotCalculator; private volatile UInt64 currentSlot = null; @@ -98,7 +98,7 @@ public DataColumnSidecarCustodyImpl( final DataColumnSidecarDbAccessor db, final MinCustodyPeriodSlotCalculator minCustodyPeriodSlotCalculator, final UInt256 nodeId, - final int totalCustodySubnetCount) { + final int totalCustodyGroupCount) { checkNotNull(spec); checkNotNull(blockResolver); checkNotNull(minCustodyPeriodSlotCalculator); @@ -110,7 +110,7 @@ public DataColumnSidecarCustodyImpl( this.blockResolver = blockResolver; this.minCustodyPeriodSlotCalculator = minCustodyPeriodSlotCalculator; this.nodeId = nodeId; - this.totalCustodySubnetCount = totalCustodySubnetCount; + this.totalCustodyGroupCount = totalCustodyGroupCount; } private List getCustodyColumnsForSlot(final UInt64 slot) { @@ -119,7 +119,7 @@ private List getCustodyColumnsForSlot(final UInt64 slot) { private List getCustodyColumnsForEpoch(final UInt64 epoch) { return MiscHelpersFulu.required(spec.atEpoch(epoch).miscHelpers()) - .computeCustodyColumnIndexes(nodeId, totalCustodySubnetCount); + .computeCustodyColumnIndexes(nodeId, totalCustodyGroupCount); } @Override @@ -140,7 +140,7 @@ private boolean isMyCustody(final UInt64 slot, final UInt64 columnIndex) { .map( miscHelpersFulu -> miscHelpersFulu - .computeCustodyColumnIndexes(nodeId, totalCustodySubnetCount) + .computeCustodyColumnIndexes(nodeId, totalCustodyGroupCount) .contains(columnIndex)) .orElse(false); } diff --git a/ethereum/statetransition/src/main/java/tech/pegasys/teku/statetransition/datacolumns/retriever/DasPeerCustodyCountSupplier.java b/ethereum/statetransition/src/main/java/tech/pegasys/teku/statetransition/datacolumns/retriever/DasPeerCustodyCountSupplier.java index e373873e497..c8a80188ec1 100644 --- a/ethereum/statetransition/src/main/java/tech/pegasys/teku/statetransition/datacolumns/retriever/DasPeerCustodyCountSupplier.java +++ b/ethereum/statetransition/src/main/java/tech/pegasys/teku/statetransition/datacolumns/retriever/DasPeerCustodyCountSupplier.java @@ -26,8 +26,8 @@ static DasPeerCustodyCountSupplier createStub(final int defaultValue) { static DasPeerCustodyCountSupplier capped( final DasPeerCustodyCountSupplier delegate, final int minValue, final int maxValue) { - return (nodeId) -> min(maxValue, max(minValue, delegate.getCustodyCountForPeer(nodeId))); + return (nodeId) -> min(maxValue, max(minValue, delegate.getCustodyGroupCountForPeer(nodeId))); } - int getCustodyCountForPeer(UInt256 nodeId); + int getCustodyGroupCountForPeer(UInt256 nodeId); } diff --git a/ethereum/statetransition/src/main/java/tech/pegasys/teku/statetransition/datacolumns/retriever/SimpleSidecarRetriever.java b/ethereum/statetransition/src/main/java/tech/pegasys/teku/statetransition/datacolumns/retriever/SimpleSidecarRetriever.java index ca8d8df28fb..4ebe74d5286 100644 --- a/ethereum/statetransition/src/main/java/tech/pegasys/teku/statetransition/datacolumns/retriever/SimpleSidecarRetriever.java +++ b/ethereum/statetransition/src/main/java/tech/pegasys/teku/statetransition/datacolumns/retriever/SimpleSidecarRetriever.java @@ -52,6 +52,7 @@ public class SimpleSidecarRetriever private static final Logger LOG = LogManager.getLogger("das-nyota"); private final Spec spec; + private final MiscHelpersFulu miscHelpersFulu; private final DataColumnPeerSearcher peerSearcher; private final DasPeerCustodyCountSupplier custodyCountSupplier; private final DataColumnReqResp reqResp; @@ -75,6 +76,8 @@ public SimpleSidecarRetriever( final AsyncRunner asyncRunner, final Duration roundPeriod) { this.spec = spec; + this.miscHelpersFulu = + MiscHelpersFulu.required(spec.forMilestone(SpecMilestone.FULU).miscHelpers()); this.peerSearcher = peerSearcher; this.custodyCountSupplier = custodyCountSupplier; this.asyncRunner = asyncRunner; @@ -289,13 +292,12 @@ public ConnectedPeer(final UInt256 nodeId) { private Set calcNodeCustodyIndexes(final CacheKey cacheKey) { return new HashSet<>( - MiscHelpersFulu.required(cacheKey.specVersion().miscHelpers()) - .computeCustodyColumnIndexes(nodeId, cacheKey.custodyCount())); + miscHelpersFulu.computeCustodyColumnIndexes(nodeId, cacheKey.custodyCount())); } private Set getNodeCustodyIndexes(final SpecVersion specVersion) { return custodyIndexesCache.get( - new CacheKey(specVersion, custodyCountSupplier.getCustodyCountForPeer(nodeId)), + new CacheKey(specVersion, custodyCountSupplier.getCustodyGroupCountForPeer(nodeId)), this::calcNodeCustodyIndexes); } diff --git a/ethereum/statetransition/src/test/java/tech/pegasys/teku/statetransition/datacolumns/DasCustodySyncTest.java b/ethereum/statetransition/src/test/java/tech/pegasys/teku/statetransition/datacolumns/DasCustodySyncTest.java index d1ad69e9481..e6c6ca280f7 100644 --- a/ethereum/statetransition/src/test/java/tech/pegasys/teku/statetransition/datacolumns/DasCustodySyncTest.java +++ b/ethereum/statetransition/src/test/java/tech/pegasys/teku/statetransition/datacolumns/DasCustodySyncTest.java @@ -50,6 +50,7 @@ public class DasCustodySyncTest { fuluBuilder .dataColumnSidecarSubnetCount(4) .numberOfColumns(8) + .numberOfCustodyGroups(8) .custodyRequirement(2) .minEpochsForDataColumnSidecarsRequests(64))); diff --git a/ethereum/statetransition/src/test/java/tech/pegasys/teku/statetransition/datacolumns/DasLongPollCustodyTest.java b/ethereum/statetransition/src/test/java/tech/pegasys/teku/statetransition/datacolumns/DasLongPollCustodyTest.java index 0f6f6396db7..e7f4a5434a1 100644 --- a/ethereum/statetransition/src/test/java/tech/pegasys/teku/statetransition/datacolumns/DasLongPollCustodyTest.java +++ b/ethereum/statetransition/src/test/java/tech/pegasys/teku/statetransition/datacolumns/DasLongPollCustodyTest.java @@ -54,7 +54,7 @@ public class DasLongPollCustodyTest { final SpecConfigFulu config = SpecConfigFulu.required(spec.forMilestone(SpecMilestone.FULU).getConfig()); - final int subnetCount = config.getDataColumnSidecarSubnetCount(); + final int groupCount = config.getNumberOfCustodyGroups(); final DataColumnSidecarCustodyImpl custodyImpl = new DataColumnSidecarCustodyImpl( @@ -63,7 +63,7 @@ public class DasLongPollCustodyTest { dbAccessor, MinCustodyPeriodSlotCalculator.createFromSpec(spec), myNodeId, - subnetCount); + groupCount); private final DataStructureUtil dataStructureUtil = new DataStructureUtil(0, spec); private final Duration currentSlotTimeout = ofSeconds(3); diff --git a/ethereum/statetransition/src/test/java/tech/pegasys/teku/statetransition/datacolumns/DataColumnSidecarCustodyImplTest.java b/ethereum/statetransition/src/test/java/tech/pegasys/teku/statetransition/datacolumns/DataColumnSidecarCustodyImplTest.java index 8aee7d2f065..8a481a55d74 100644 --- a/ethereum/statetransition/src/test/java/tech/pegasys/teku/statetransition/datacolumns/DataColumnSidecarCustodyImplTest.java +++ b/ethereum/statetransition/src/test/java/tech/pegasys/teku/statetransition/datacolumns/DataColumnSidecarCustodyImplTest.java @@ -45,7 +45,7 @@ public class DataColumnSidecarCustodyImplTest { final SpecConfigFulu config = SpecConfigFulu.required(spec.forMilestone(SpecMilestone.FULU).getConfig()); - final int subnetCount = config.getDataColumnSidecarSubnetCount(); + final int groupCount = config.getNumberOfCustodyGroups(); private final DataStructureUtil dataStructureUtil = new DataStructureUtil(0, spec); @@ -66,7 +66,7 @@ void sanityTest() throws Throwable { dbAccessor, MinCustodyPeriodSlotCalculator.createFromSpec(spec), myNodeId, - subnetCount); + groupCount); BeaconBlock block = blockResolver.addBlock(10, true); DataColumnSidecar sidecar0 = createSidecar(block, 0); DataColumnSidecar sidecar1 = createSidecar(block, 1); diff --git a/ethereum/statetransition/src/test/java/tech/pegasys/teku/statetransition/datacolumns/retriever/SimpleSidecarRetrieverTest.java b/ethereum/statetransition/src/test/java/tech/pegasys/teku/statetransition/datacolumns/retriever/SimpleSidecarRetrieverTest.java index 36487db2bc5..6d1e1d31e85 100644 --- a/ethereum/statetransition/src/test/java/tech/pegasys/teku/statetransition/datacolumns/retriever/SimpleSidecarRetrieverTest.java +++ b/ethereum/statetransition/src/test/java/tech/pegasys/teku/statetransition/datacolumns/retriever/SimpleSidecarRetrieverTest.java @@ -96,7 +96,7 @@ private DataColumnSlotAndIdentifier createId(final BeaconBlock block, final int List nodeCustodyColumns(final UInt256 nodeId) { return miscHelpers.computeCustodyColumnIndexes( - nodeId, custodyCountSupplier.getCustodyCountForPeer(nodeId)); + nodeId, custodyCountSupplier.getCustodyGroupCountForPeer(nodeId)); } Stream craftNodeIds() { @@ -281,7 +281,7 @@ void shouldTrackCustodyCountChangesForPeers() { colIds.forEach(simpleSidecarRetriever::retrieve); - int peerCustodyCount = custodyCountSupplier.getCustodyCountForPeer(peer.getNodeId()); + int peerCustodyCount = custodyCountSupplier.getCustodyGroupCountForPeer(peer.getNodeId()); advanceTimeGradually(retrieverRound); assertThat(peer.getRequests()).hasSize(peerCustodyCount); diff --git a/ethereum/statetransition/src/testFixtures/java/tech/pegasys/teku/statetransition/datacolumns/DasCustodyStand.java b/ethereum/statetransition/src/testFixtures/java/tech/pegasys/teku/statetransition/datacolumns/DasCustodyStand.java index de23063ed92..5e0b11a8b74 100644 --- a/ethereum/statetransition/src/testFixtures/java/tech/pegasys/teku/statetransition/datacolumns/DasCustodyStand.java +++ b/ethereum/statetransition/src/testFixtures/java/tech/pegasys/teku/statetransition/datacolumns/DasCustodyStand.java @@ -66,7 +66,7 @@ public static Builder builder(final Spec spec) { private final List slotListeners = new CopyOnWriteArrayList<>(); private final List finalizedListeners = new CopyOnWriteArrayList<>(); - private final int totalCustodySubnetCount; + private final int totalCustodyGroupCount; private UInt64 currentSlot = UInt64.ZERO; @@ -74,7 +74,7 @@ public DasCustodyStand( final Spec spec, final UInt64 currentSlot, final UInt256 myNodeId, - final int totalCustodySubnetCount, + final int totalCustodyGroupCount, final Optional asyncDbDelay, final Optional asyncBlockResolverDelay) { this.spec = spec; @@ -107,7 +107,7 @@ public DasCustodyStand( dbAccessor, minCustodyPeriodSlotCalculator, myNodeId, - totalCustodySubnetCount); + totalCustodyGroupCount); subscribeToSlotEvents(this.custody); subscribeToFinalizedEvents(this.custody); @@ -116,7 +116,7 @@ public DasCustodyStand( final BLSPublicKey singlePubKey = util.randomPublicKey(); this.dataStructureUtil = util.withSignatureGenerator(__ -> singleSignature).withPubKeyGenerator(() -> singlePubKey); - this.totalCustodySubnetCount = totalCustodySubnetCount; + this.totalCustodyGroupCount = totalCustodyGroupCount; } public void advanceTimeGradually(final Duration delta) { @@ -162,7 +162,7 @@ public Collection getCustodyColumnIndexes(final UInt64 slot) { .toVersionFulu() .map( miscHelpersFulu -> - miscHelpersFulu.computeCustodyColumnIndexes(myNodeId, totalCustodySubnetCount)) + miscHelpersFulu.computeCustodyColumnIndexes(myNodeId, totalCustodyGroupCount)) .orElse(Collections.emptyList()); } @@ -214,7 +214,7 @@ public static class Builder { private Spec spec; private UInt64 currentSlot = UInt64.ZERO; private UInt256 myNodeId = UInt256.ONE; - private Integer totalCustodySubnetCount; + private Integer totalCustodyGroupCount; private Optional asyncDbDelay = Optional.empty(); private Optional asyncBlockResolverDelay = Optional.empty(); @@ -234,7 +234,7 @@ public Builder withMyNodeId(final UInt256 myNodeId) { } public Builder withTotalCustodySubnetCount(final Integer totalCustodySubnetCount) { - this.totalCustodySubnetCount = totalCustodySubnetCount; + this.totalCustodyGroupCount = totalCustodySubnetCount; return this; } @@ -249,17 +249,17 @@ public Builder withAsyncBlockResolver(final Duration asyncBlockResolverDelay) { } public DasCustodyStand build() { - if (totalCustodySubnetCount == null) { + if (totalCustodyGroupCount == null) { checkNotNull(spec); final SpecConfigFulu configFulu = SpecConfigFulu.required(spec.forMilestone(SpecMilestone.FULU).getConfig()); - totalCustodySubnetCount = configFulu.getCustodyRequirement(); + totalCustodyGroupCount = configFulu.getCustodyRequirement(); } return new DasCustodyStand( spec, currentSlot, myNodeId, - totalCustodySubnetCount, + totalCustodyGroupCount, asyncDbDelay, asyncBlockResolverDelay); } diff --git a/ethereum/statetransition/src/testFixtures/java/tech/pegasys/teku/statetransition/datacolumns/retriever/DasPeerCustodyCountSupplierStub.java b/ethereum/statetransition/src/testFixtures/java/tech/pegasys/teku/statetransition/datacolumns/retriever/DasPeerCustodyCountSupplierStub.java index 1cdc50841fa..936c764d3e6 100644 --- a/ethereum/statetransition/src/testFixtures/java/tech/pegasys/teku/statetransition/datacolumns/retriever/DasPeerCustodyCountSupplierStub.java +++ b/ethereum/statetransition/src/testFixtures/java/tech/pegasys/teku/statetransition/datacolumns/retriever/DasPeerCustodyCountSupplierStub.java @@ -26,7 +26,7 @@ public DasPeerCustodyCountSupplierStub(final int defaultCount) { } @Override - public int getCustodyCountForPeer(final UInt256 nodeId) { + public int getCustodyGroupCountForPeer(final UInt256 nodeId) { return customCounts.getOrDefault(nodeId, defaultCount); } diff --git a/networking/eth2/src/integration-test/java/tech/pegasys/teku/networking/eth2/GetMetadataIntegrationTest.java b/networking/eth2/src/integration-test/java/tech/pegasys/teku/networking/eth2/GetMetadataIntegrationTest.java index 91fbbce53f0..c83b1f98f53 100644 --- a/networking/eth2/src/integration-test/java/tech/pegasys/teku/networking/eth2/GetMetadataIntegrationTest.java +++ b/networking/eth2/src/integration-test/java/tech/pegasys/teku/networking/eth2/GetMetadataIntegrationTest.java @@ -130,7 +130,7 @@ public void requestMetadata_shouldIncludeCustodySubnetCount( MetadataMessage md1 = peer.requestMetadata().get(10, TimeUnit.SECONDS); Assumptions.assumeTrue(md1 instanceof MetadataMessageFulu, "Milestone skipped"); - assertThat(((MetadataMessageFulu) md1).getCustodySubnetCount().isGreaterThan(0)).isTrue(); + assertThat(((MetadataMessageFulu) md1).getCustodyGroupCount().isGreaterThan(0)).isTrue(); } @ParameterizedTest(name = "{0} => {1}, nextSpecEnabledLocally={2}, nextSpecEnabledRemotely={3}") @@ -153,7 +153,7 @@ public void requestMetadata_withDisparateVersionsEnabled( assertThat(res).isCompleted(); final MetadataMessage metadata = safeJoin(res); assertThat(metadata).isInstanceOf(expectedType); - // There will be update of custody_subnet_count in this case + // There will be update of custody_group_count in this case if (!(nextMilestone == SpecMilestone.FULU && nextSpecEnabledRemotely)) { assertThat(metadata.getSeqNumber()).isEqualTo(UInt64.ZERO); } diff --git a/networking/eth2/src/main/java/tech/pegasys/teku/networking/eth2/Eth2P2PNetworkBuilder.java b/networking/eth2/src/main/java/tech/pegasys/teku/networking/eth2/Eth2P2PNetworkBuilder.java index 58c0aa11514..a4ef7f1264a 100644 --- a/networking/eth2/src/main/java/tech/pegasys/teku/networking/eth2/Eth2P2PNetworkBuilder.java +++ b/networking/eth2/src/main/java/tech/pegasys/teku/networking/eth2/Eth2P2PNetworkBuilder.java @@ -163,11 +163,11 @@ public Eth2P2PNetwork build() { statusMessageFactory = new StatusMessageFactory(combinedChainDataClient.getRecentChainData()); } - final Optional dasTotalCustodySubnetCount = + final Optional dasTotalCustodyGroupCount = spec.isMilestoneSupported(SpecMilestone.FULU) ? Optional.of( UInt64.valueOf( - config.getTotalCustodySubnetCount(spec.forMilestone(SpecMilestone.FULU)))) + config.getTotalCustodyGroupCount(spec.forMilestone(SpecMilestone.FULU)))) : Optional.empty(); final Eth2PeerManager eth2PeerManager = @@ -190,7 +190,7 @@ public Eth2P2PNetwork build() { spec, kzg, discoveryNodeIdExtractor, - dasTotalCustodySubnetCount, + dasTotalCustodyGroupCount, dasReqRespLogger); final Collection> eth2RpcMethods = eth2PeerManager.getBeaconChainMethods().all(); @@ -218,7 +218,7 @@ public Eth2P2PNetwork build() { gossipEncoding, config.getGossipConfigurator(), processedAttestationSubscriptionProvider, - dasTotalCustodySubnetCount.orElse(UInt64.ZERO).intValue(), + dasTotalCustodyGroupCount.orElse(UInt64.ZERO).intValue(), config.isAllTopicsFilterEnabled()); } diff --git a/networking/eth2/src/main/java/tech/pegasys/teku/networking/eth2/P2PConfig.java b/networking/eth2/src/main/java/tech/pegasys/teku/networking/eth2/P2PConfig.java index e575de7ef31..0da3ed33133 100644 --- a/networking/eth2/src/main/java/tech/pegasys/teku/networking/eth2/P2PConfig.java +++ b/networking/eth2/src/main/java/tech/pegasys/teku/networking/eth2/P2PConfig.java @@ -47,7 +47,7 @@ public class P2PConfig { public static final int DEFAULT_BATCH_VERIFY_QUEUE_CAPACITY = 15_000; public static final int DEFAULT_BATCH_VERIFY_MAX_BATCH_SIZE = 250; public static final boolean DEFAULT_BATCH_VERIFY_STRICT_THREAD_LIMIT_ENABLED = false; - public static final int DEFAULT_DAS_EXTRA_CUSTODY_SUBNET_COUNT = 0; + public static final int DEFAULT_DAS_EXTRA_CUSTODY_GROUP_COUNT = 0; public static final boolean DEFAULT_DAS_LOSSY_SAMPLER_ENABLED = false; private final Spec spec; @@ -59,7 +59,7 @@ public class P2PConfig { private final GossipEncoding gossipEncoding; private final int targetSubnetSubscriberCount; private final boolean subscribeAllSubnetsEnabled; - private final int dasExtraCustodySubnetCount; + private final int dasExtraCustodyGroupCount; private final boolean dasLossySamplerEnabled; private final int peerRateLimit; private final int peerRequestLimit; @@ -78,7 +78,7 @@ private P2PConfig( final GossipEncoding gossipEncoding, final int targetSubnetSubscriberCount, final boolean subscribeAllSubnetsEnabled, - final int dasExtraCustodySubnetCount, + final int dasExtraCustodyGroupCount, final boolean dasLossySamplerEnabled, final int peerRateLimit, final int peerRequestLimit, @@ -95,7 +95,7 @@ private P2PConfig( this.gossipEncoding = gossipEncoding; this.targetSubnetSubscriberCount = targetSubnetSubscriberCount; this.subscribeAllSubnetsEnabled = subscribeAllSubnetsEnabled; - this.dasExtraCustodySubnetCount = dasExtraCustodySubnetCount; + this.dasExtraCustodyGroupCount = dasExtraCustodyGroupCount; this.dasLossySamplerEnabled = dasLossySamplerEnabled; this.peerRateLimit = peerRateLimit; this.peerRequestLimit = peerRequestLimit; @@ -140,13 +140,13 @@ public boolean isSubscribeAllSubnetsEnabled() { return subscribeAllSubnetsEnabled; } - public int getTotalCustodySubnetCount(final SpecVersion specVersion) { + public int getTotalCustodyGroupCount(final SpecVersion specVersion) { final SpecConfigFulu specConfig = SpecConfigFulu.required(specVersion.getConfig()); - final int minCustodyRequirement = specConfig.getCustodyRequirement(); - final int maxSubnets = specConfig.getDataColumnSidecarSubnetCount(); + final int minCustodyGroupRequirement = specConfig.getCustodyRequirement(); + final int maxGroups = specConfig.getNumberOfCustodyGroups(); return Integer.min( - maxSubnets, - MathHelpers.intPlusMaxIntCapped(minCustodyRequirement, dasExtraCustodySubnetCount)); + maxGroups, + MathHelpers.intPlusMaxIntCapped(minCustodyGroupRequirement, dasExtraCustodyGroupCount)); } public int getPeerRateLimit() { @@ -199,7 +199,7 @@ public static class Builder { private Integer targetSubnetSubscriberCount = DEFAULT_P2P_TARGET_SUBNET_SUBSCRIBER_COUNT; private Boolean subscribeAllSubnetsEnabled = DEFAULT_SUBSCRIBE_ALL_SUBNETS_ENABLED; private Boolean subscribeAllCustodySubnetsEnabled = DEFAULT_SUBSCRIBE_ALL_SUBNETS_ENABLED; - private int dasExtraCustodySubnetCount = DEFAULT_DAS_EXTRA_CUSTODY_SUBNET_COUNT; + private int dasExtraCustodyGroupCount = DEFAULT_DAS_EXTRA_CUSTODY_GROUP_COUNT; private boolean dasLossySamplerEnabled = DEFAULT_DAS_LOSSY_SAMPLER_ENABLED; private Integer peerRateLimit = DEFAULT_PEER_RATE_LIMIT; private Integer peerRequestLimit = DEFAULT_PEER_REQUEST_LIMIT; @@ -245,7 +245,7 @@ public P2PConfig build() { OptionalInt.of(networkConfig.getAdvertisedPortIpv6())); if (subscribeAllCustodySubnetsEnabled) { - dasExtraCustodySubnetCount = Integer.MAX_VALUE; + dasExtraCustodyGroupCount = Integer.MAX_VALUE; } return new P2PConfig( @@ -256,7 +256,7 @@ public P2PConfig build() { gossipEncoding, targetSubnetSubscriberCount, subscribeAllSubnetsEnabled, - dasExtraCustodySubnetCount, + dasExtraCustodyGroupCount, dasLossySamplerEnabled, peerRateLimit, peerRequestLimit, @@ -315,8 +315,8 @@ public Builder dasLossySamplerEnabled(final boolean dasLossySamplerEnabled) { return this; } - public Builder dasExtraCustodySubnetCount(final int dasExtraCustodySubnetCount) { - this.dasExtraCustodySubnetCount = dasExtraCustodySubnetCount; + public Builder dasExtraCustodyGroupCount(final int dasExtraCustodyGroupCount) { + this.dasExtraCustodyGroupCount = dasExtraCustodyGroupCount; return this; } diff --git a/networking/eth2/src/main/java/tech/pegasys/teku/networking/eth2/gossip/subnets/DataColumnSidecarSubnetBackboneSubscriber.java b/networking/eth2/src/main/java/tech/pegasys/teku/networking/eth2/gossip/subnets/DataColumnSidecarSubnetBackboneSubscriber.java index 4a43cd6f327..3dd0e7f6b69 100644 --- a/networking/eth2/src/main/java/tech/pegasys/teku/networking/eth2/gossip/subnets/DataColumnSidecarSubnetBackboneSubscriber.java +++ b/networking/eth2/src/main/java/tech/pegasys/teku/networking/eth2/gossip/subnets/DataColumnSidecarSubnetBackboneSubscriber.java @@ -26,7 +26,7 @@ public class DataColumnSidecarSubnetBackboneSubscriber implements SlotEventsChannel { private final Eth2P2PNetwork eth2P2PNetwork; private final UInt256 nodeId; - private final int totalSubnetCount; + private final int totalGroupCount; private final Spec spec; private IntSet currentSubscribedSubnets = IntSet.of(); @@ -36,11 +36,11 @@ public DataColumnSidecarSubnetBackboneSubscriber( final Spec spec, final Eth2P2PNetwork eth2P2PNetwork, final UInt256 nodeId, - final int totalSubnetCount) { + final int totalGroupCount) { this.spec = spec; this.eth2P2PNetwork = eth2P2PNetwork; this.nodeId = nodeId; - this.totalSubnetCount = totalSubnetCount; + this.totalGroupCount = totalGroupCount; } private void subscribeToSubnets(final Collection newSubscriptions) { @@ -70,7 +70,7 @@ private void onEpoch(final UInt64 epoch) { miscHelpersFulu -> { List subnets = miscHelpersFulu.computeDataColumnSidecarBackboneSubnets( - nodeId, epoch, totalSubnetCount); + nodeId, epoch, totalGroupCount); subscribeToSubnets(subnets.stream().map(UInt64::intValue).toList()); }); } diff --git a/networking/eth2/src/main/java/tech/pegasys/teku/networking/eth2/gossip/subnets/DataColumnSidecarSubnetSubscriptions.java b/networking/eth2/src/main/java/tech/pegasys/teku/networking/eth2/gossip/subnets/DataColumnSidecarSubnetSubscriptions.java index 4dbc9c0d1f6..ee1b74b4648 100644 --- a/networking/eth2/src/main/java/tech/pegasys/teku/networking/eth2/gossip/subnets/DataColumnSidecarSubnetSubscriptions.java +++ b/networking/eth2/src/main/java/tech/pegasys/teku/networking/eth2/gossip/subnets/DataColumnSidecarSubnetSubscriptions.java @@ -28,10 +28,10 @@ import tech.pegasys.teku.spec.Spec; import tech.pegasys.teku.spec.SpecMilestone; import tech.pegasys.teku.spec.SpecVersion; -import tech.pegasys.teku.spec.config.SpecConfigFulu; import tech.pegasys.teku.spec.datastructures.blobs.versions.fulu.DataColumnSidecar; import tech.pegasys.teku.spec.datastructures.blobs.versions.fulu.DataColumnSidecarSchema; import tech.pegasys.teku.spec.datastructures.state.ForkInfo; +import tech.pegasys.teku.spec.logic.versions.fulu.helpers.MiscHelpersFulu; import tech.pegasys.teku.spec.schemas.SchemaDefinitionsFulu; import tech.pegasys.teku.statetransition.util.DebugDataDumper; import tech.pegasys.teku.storage.client.RecentChainData; @@ -43,9 +43,9 @@ public class DataColumnSidecarSubnetSubscriptions extends CommitteeSubnetSubscri private final RecentChainData recentChainData; private final OperationProcessor processor; private final ForkInfo forkInfo; - private final int subnetCount; private final DataColumnSidecarSchema dataColumnSidecarSchema; private final DebugDataDumper debugDataDumper; + private final MiscHelpersFulu miscHelpersFulu; public DataColumnSidecarSubnetSubscriptions( final Spec spec, @@ -67,8 +67,8 @@ public DataColumnSidecarSubnetSubscriptions( this.dataColumnSidecarSchema = SchemaDefinitionsFulu.required(specVersion.getSchemaDefinitions()) .getDataColumnSidecarSchema(); - this.subnetCount = - SpecConfigFulu.required(specVersion.getConfig()).getDataColumnSidecarSubnetCount(); + this.miscHelpersFulu = + MiscHelpersFulu.required(spec.forMilestone(SpecMilestone.FULU).miscHelpers()); } public SafeFuture gossip(final DataColumnSidecar sidecar) { @@ -101,6 +101,6 @@ protected Eth2TopicHandler createTopicHandler(final int subnetId) { } private int computeSubnetForSidecar(final DataColumnSidecar sidecar) { - return sidecar.getIndex().mod(subnetCount).intValue(); + return miscHelpersFulu.computeSubnetForDataColumnSidecar(sidecar.getIndex()).intValue(); } } diff --git a/networking/eth2/src/main/java/tech/pegasys/teku/networking/eth2/gossip/subnets/NodeIdToDataColumnSidecarSubnetsCalculator.java b/networking/eth2/src/main/java/tech/pegasys/teku/networking/eth2/gossip/subnets/NodeIdToDataColumnSidecarSubnetsCalculator.java index 2a955a54db2..eb5474d6af0 100644 --- a/networking/eth2/src/main/java/tech/pegasys/teku/networking/eth2/gossip/subnets/NodeIdToDataColumnSidecarSubnetsCalculator.java +++ b/networking/eth2/src/main/java/tech/pegasys/teku/networking/eth2/gossip/subnets/NodeIdToDataColumnSidecarSubnetsCalculator.java @@ -30,7 +30,7 @@ @FunctionalInterface public interface NodeIdToDataColumnSidecarSubnetsCalculator { - Optional calculateSubnets(UInt256 nodeId, Optional subnetCount); + Optional calculateSubnets(UInt256 nodeId, Optional groupCount); NodeIdToDataColumnSidecarSubnetsCalculator NOOP = (nodeId, subnetCount) -> Optional.empty(); @@ -40,11 +40,11 @@ private static NodeIdToDataColumnSidecarSubnetsCalculator createAtSlot( UInt64 currentEpoch = miscHelpers.computeEpochAtSlot(currentSlot); SszBitvectorSchema bitvectorSchema = SszBitvectorSchema.create(config.getDataColumnSidecarSubnetCount()); - return (nodeId, subnetCount) -> { + return (nodeId, groupCount) -> { List nodeSubnets = MiscHelpersFulu.required(miscHelpers) .computeDataColumnSidecarBackboneSubnets( - nodeId, currentEpoch, subnetCount.orElse(config.getCustodyRequirement())); + nodeId, currentEpoch, groupCount.orElse(config.getCustodyRequirement())); return Optional.of( bitvectorSchema.ofBits(nodeSubnets.stream().map(UInt64::intValue).toList())); }; @@ -54,7 +54,7 @@ private static NodeIdToDataColumnSidecarSubnetsCalculator createAtSlot( static NodeIdToDataColumnSidecarSubnetsCalculator create( final Spec spec, final Supplier> currentSlotSupplier) { - return (nodeId, subnetCount) -> + return (nodeId, groupCount) -> currentSlotSupplier .get() .flatMap( @@ -70,7 +70,7 @@ static NodeIdToDataColumnSidecarSubnetsCalculator create( } else { calculatorAtSlot = NOOP; } - return calculatorAtSlot.calculateSubnets(nodeId, subnetCount); + return calculatorAtSlot.calculateSubnets(nodeId, groupCount); }); } } diff --git a/networking/eth2/src/main/java/tech/pegasys/teku/networking/eth2/gossip/topics/topichandlers/DataColumnSidecarTopicHandler.java b/networking/eth2/src/main/java/tech/pegasys/teku/networking/eth2/gossip/topics/topichandlers/DataColumnSidecarTopicHandler.java index 75671cf185c..8cc32ec0253 100644 --- a/networking/eth2/src/main/java/tech/pegasys/teku/networking/eth2/gossip/topics/topichandlers/DataColumnSidecarTopicHandler.java +++ b/networking/eth2/src/main/java/tech/pegasys/teku/networking/eth2/gossip/topics/topichandlers/DataColumnSidecarTopicHandler.java @@ -21,9 +21,11 @@ import tech.pegasys.teku.networking.eth2.gossip.topics.OperationMilestoneValidator; import tech.pegasys.teku.networking.eth2.gossip.topics.OperationProcessor; import tech.pegasys.teku.spec.Spec; +import tech.pegasys.teku.spec.SpecMilestone; import tech.pegasys.teku.spec.datastructures.blobs.versions.fulu.DataColumnSidecar; import tech.pegasys.teku.spec.datastructures.blobs.versions.fulu.DataColumnSidecarSchema; import tech.pegasys.teku.spec.datastructures.state.ForkInfo; +import tech.pegasys.teku.spec.logic.versions.fulu.helpers.MiscHelpersFulu; import tech.pegasys.teku.statetransition.util.DebugDataDumper; import tech.pegasys.teku.statetransition.validation.InternalValidationResult; import tech.pegasys.teku.storage.client.RecentChainData; @@ -59,15 +61,27 @@ public static Eth2TopicHandler createHandler( debugDataDumper); } - private record TopicSubnetIdAwareOperationProcessor( - Spec spec, int subnetId, OperationProcessor delegate) + private static class TopicSubnetIdAwareOperationProcessor implements OperationProcessor { + private final int subnetId; + private final OperationProcessor delegate; + private final MiscHelpersFulu miscHelpersFulu; + + TopicSubnetIdAwareOperationProcessor( + final Spec spec, final int subnetId, final OperationProcessor delegate) { + this.subnetId = subnetId; + this.delegate = delegate; + this.miscHelpersFulu = + MiscHelpersFulu.required(spec.forMilestone(SpecMilestone.FULU).miscHelpers()); + } @Override public SafeFuture process( final DataColumnSidecar dataColumnSidecar, final Optional arrivalTimestamp) { final int dataColumnSidecarSubnet = - spec.computeSubnetForDataColumnSidecar(dataColumnSidecar).intValue(); + miscHelpersFulu + .computeSubnetForDataColumnSidecar(dataColumnSidecar.getIndex()) + .intValue(); if (dataColumnSidecarSubnet != subnetId) { return SafeFuture.completedFuture( InternalValidationResult.reject( diff --git a/networking/eth2/src/main/java/tech/pegasys/teku/networking/eth2/peers/Eth2PeerManager.java b/networking/eth2/src/main/java/tech/pegasys/teku/networking/eth2/peers/Eth2PeerManager.java index 6a276f90087..40d22d16a93 100644 --- a/networking/eth2/src/main/java/tech/pegasys/teku/networking/eth2/peers/Eth2PeerManager.java +++ b/networking/eth2/src/main/java/tech/pegasys/teku/networking/eth2/peers/Eth2PeerManager.java @@ -127,12 +127,12 @@ public static Eth2PeerManager create( final Spec spec, final KZG kzg, final DiscoveryNodeIdExtractor discoveryNodeIdExtractor, - final Optional custodySubnetCount, + final Optional custodyGroupCount, final DasReqRespLogger dasLogger) { final MetadataMessagesFactory metadataMessagesFactory = new MetadataMessagesFactory(); - custodySubnetCount.ifPresent(metadataMessagesFactory::updateCustodySubnetCount); + custodyGroupCount.ifPresent(metadataMessagesFactory::updateCustodyGroupCount); attestationSubnetService.subscribeToUpdates( metadataMessagesFactory::updateAttestationSubnetIds); syncCommitteeSubnetService.subscribeToUpdates( diff --git a/networking/eth2/src/main/java/tech/pegasys/teku/networking/eth2/peers/GossipTopicDasPeerCustodyTracker.java b/networking/eth2/src/main/java/tech/pegasys/teku/networking/eth2/peers/GossipTopicDasPeerCustodyTracker.java index d0ebdc536f1..00bed3b8293 100644 --- a/networking/eth2/src/main/java/tech/pegasys/teku/networking/eth2/peers/GossipTopicDasPeerCustodyTracker.java +++ b/networking/eth2/src/main/java/tech/pegasys/teku/networking/eth2/peers/GossipTopicDasPeerCustodyTracker.java @@ -107,7 +107,7 @@ record NodeTopic(NodeId nodeId, String topic) {} } @Override - public int getCustodyCountForPeer(final UInt256 nodeId) { + public int getCustodyGroupCountForPeer(final UInt256 nodeId) { Entry entry = connectedPeerSubnets.get(nodeId); return entry != null ? entry.subnetCount() : 0; } diff --git a/networking/eth2/src/main/java/tech/pegasys/teku/networking/eth2/peers/MetadataDasPeerCustodyTracker.java b/networking/eth2/src/main/java/tech/pegasys/teku/networking/eth2/peers/MetadataDasPeerCustodyTracker.java index e65359238c7..885426c1356 100644 --- a/networking/eth2/src/main/java/tech/pegasys/teku/networking/eth2/peers/MetadataDasPeerCustodyTracker.java +++ b/networking/eth2/src/main/java/tech/pegasys/teku/networking/eth2/peers/MetadataDasPeerCustodyTracker.java @@ -37,7 +37,7 @@ private void peerDisconnected(final Eth2Peer peer) { private void onPeerMetadataUpdate(final Eth2Peer peer, final MetadataMessage metadata) { metadata - .getOptionalCustodySubnetCount() + .getOptionalCustodyGroupCount() .ifPresent( subnetCount -> connectedPeerSubnetCount.put( @@ -45,7 +45,7 @@ private void onPeerMetadataUpdate(final Eth2Peer peer, final MetadataMessage met } @Override - public int getCustodyCountForPeer(final UInt256 nodeId) { + public int getCustodyGroupCountForPeer(final UInt256 nodeId) { return connectedPeerSubnetCount.getOrDefault(nodeId, 0); } } diff --git a/networking/eth2/src/main/java/tech/pegasys/teku/networking/eth2/rpc/beaconchain/methods/MetadataMessagesFactory.java b/networking/eth2/src/main/java/tech/pegasys/teku/networking/eth2/rpc/beaconchain/methods/MetadataMessagesFactory.java index bafd5bfb82e..953f6c27c46 100644 --- a/networking/eth2/src/main/java/tech/pegasys/teku/networking/eth2/rpc/beaconchain/methods/MetadataMessagesFactory.java +++ b/networking/eth2/src/main/java/tech/pegasys/teku/networking/eth2/rpc/beaconchain/methods/MetadataMessagesFactory.java @@ -26,7 +26,7 @@ public class MetadataMessagesFactory { private final AtomicLong seqNumberGenerator = new AtomicLong(0L); private Iterable attestationSubnetIds = Collections.emptyList(); private Iterable syncCommitteeSubnetIds = Collections.emptyList(); - private Optional custodySubnetCount = Optional.empty(); + private Optional custodyGroupCount = Optional.empty(); public synchronized void updateAttestationSubnetIds( final Iterable attestationSubnetIds) { @@ -40,8 +40,8 @@ public synchronized void updateSyncCommitteeSubnetIds( handleUpdate(); } - public synchronized void updateCustodySubnetCount(final UInt64 custodySubnetCount) { - this.custodySubnetCount = Optional.of(custodySubnetCount); + public synchronized void updateCustodyGroupCount(final UInt64 custodyGroupCount) { + this.custodyGroupCount = Optional.of(custodyGroupCount); handleUpdate(); } @@ -51,7 +51,7 @@ private void handleUpdate() { public synchronized MetadataMessage createMetadataMessage(final MetadataMessageSchema schema) { return schema.create( - getCurrentSeqNumber(), attestationSubnetIds, syncCommitteeSubnetIds, custodySubnetCount); + getCurrentSeqNumber(), attestationSubnetIds, syncCommitteeSubnetIds, custodyGroupCount); } public PingMessage createPingMessage() { diff --git a/networking/eth2/src/testFixtures/java/tech/pegasys/teku/networking/eth2/Eth2P2PNetworkFactory.java b/networking/eth2/src/testFixtures/java/tech/pegasys/teku/networking/eth2/Eth2P2PNetworkFactory.java index 2725bb82219..bcdb28a3422 100644 --- a/networking/eth2/src/testFixtures/java/tech/pegasys/teku/networking/eth2/Eth2P2PNetworkFactory.java +++ b/networking/eth2/src/testFixtures/java/tech/pegasys/teku/networking/eth2/Eth2P2PNetworkFactory.java @@ -232,7 +232,7 @@ protected Eth2P2PNetwork buildNetwork(final P2PConfig config) { spec.isMilestoneSupported(SpecMilestone.FULU) ? Optional.of( UInt64.valueOf( - config.getTotalCustodySubnetCount(spec.forMilestone(SpecMilestone.FULU)))) + config.getTotalCustodyGroupCount(spec.forMilestone(SpecMilestone.FULU)))) : Optional.empty(); final Eth2PeerManager eth2PeerManager = Eth2PeerManager.create( diff --git a/networking/p2p/src/main/java/tech/pegasys/teku/networking/p2p/discovery/DiscoveryNetwork.java b/networking/p2p/src/main/java/tech/pegasys/teku/networking/p2p/discovery/DiscoveryNetwork.java index 49fa14fd622..4e94e53b971 100644 --- a/networking/p2p/src/main/java/tech/pegasys/teku/networking/p2p/discovery/DiscoveryNetwork.java +++ b/networking/p2p/src/main/java/tech/pegasys/teku/networking/p2p/discovery/DiscoveryNetwork.java @@ -45,7 +45,7 @@ public class DiscoveryNetwork

extends DelegatingP2PNetwork

{ public static final String ATTESTATION_SUBNET_ENR_FIELD = "attnets"; public static final String SYNC_COMMITTEE_SUBNET_ENR_FIELD = "syncnets"; - public static final String DAS_CUSTODY_SUBNET_COUNT_ENR_FIELD = "csc"; + public static final String DAS_CUSTODY_GROUP_COUNT_ENR_FIELD = "cgc"; public static final String ETH2_ENR_FIELD = "eth2"; private final Spec spec; @@ -145,7 +145,7 @@ public void setDASTotalCustodySubnetCount(final int count) { String.format("Custody subnet count should be a positive number, but was %s", count)); } discoveryService.updateCustomENRField( - DAS_CUSTODY_SUBNET_COUNT_ENR_FIELD, Bytes.ofUnsignedInt(count).trimLeadingZeros()); + DAS_CUSTODY_GROUP_COUNT_ENR_FIELD, Bytes.ofUnsignedInt(count).trimLeadingZeros()); } public void setPreGenesisForkInfo() { diff --git a/networking/p2p/src/main/java/tech/pegasys/teku/networking/p2p/discovery/discv5/NodeRecordConverter.java b/networking/p2p/src/main/java/tech/pegasys/teku/networking/p2p/discovery/discv5/NodeRecordConverter.java index 96526037298..f1af60e1b7f 100644 --- a/networking/p2p/src/main/java/tech/pegasys/teku/networking/p2p/discovery/discv5/NodeRecordConverter.java +++ b/networking/p2p/src/main/java/tech/pegasys/teku/networking/p2p/discovery/discv5/NodeRecordConverter.java @@ -14,7 +14,7 @@ package tech.pegasys.teku.networking.p2p.discovery.discv5; import static tech.pegasys.teku.networking.p2p.discovery.DiscoveryNetwork.ATTESTATION_SUBNET_ENR_FIELD; -import static tech.pegasys.teku.networking.p2p.discovery.DiscoveryNetwork.DAS_CUSTODY_SUBNET_COUNT_ENR_FIELD; +import static tech.pegasys.teku.networking.p2p.discovery.DiscoveryNetwork.DAS_CUSTODY_GROUP_COUNT_ENR_FIELD; import static tech.pegasys.teku.networking.p2p.discovery.DiscoveryNetwork.ETH2_ENR_FIELD; import static tech.pegasys.teku.networking.p2p.discovery.DiscoveryNetwork.SYNC_COMMITTEE_SUBNET_ENR_FIELD; @@ -78,7 +78,7 @@ private static DiscoveryPeer socketAddressToDiscoveryPeer( final Optional dasTotalCustodySubnetCount = parseField( nodeRecord, - DAS_CUSTODY_SUBNET_COUNT_ENR_FIELD, + DAS_CUSTODY_GROUP_COUNT_ENR_FIELD, bytes -> UInt64.fromBytes(bytes).intValue()); return new DiscoveryPeer( diff --git a/networking/p2p/src/test/java/tech/pegasys/teku/networking/p2p/discovery/DiscoveryNetworkTest.java b/networking/p2p/src/test/java/tech/pegasys/teku/networking/p2p/discovery/DiscoveryNetworkTest.java index 1f599ae7c28..c1b35a390bc 100644 --- a/networking/p2p/src/test/java/tech/pegasys/teku/networking/p2p/discovery/DiscoveryNetworkTest.java +++ b/networking/p2p/src/test/java/tech/pegasys/teku/networking/p2p/discovery/DiscoveryNetworkTest.java @@ -22,7 +22,7 @@ import static org.mockito.Mockito.verifyNoInteractions; import static org.mockito.Mockito.verifyNoMoreInteractions; import static org.mockito.Mockito.when; -import static tech.pegasys.teku.networking.p2p.discovery.DiscoveryNetwork.DAS_CUSTODY_SUBNET_COUNT_ENR_FIELD; +import static tech.pegasys.teku.networking.p2p.discovery.DiscoveryNetwork.DAS_CUSTODY_GROUP_COUNT_ENR_FIELD; import java.math.BigInteger; import java.net.InetSocketAddress; @@ -296,7 +296,7 @@ public void nodeIdMustBeWrappedInUint256(final String nodeIdValue) { public void cscIsCorrectlyEncoded(final String hexString, final Integer csc) { discoveryNetwork.setDASTotalCustodySubnetCount(csc); verify(discoveryService) - .updateCustomENRField(DAS_CUSTODY_SUBNET_COUNT_ENR_FIELD, Bytes.fromHexString(hexString)); + .updateCustomENRField(DAS_CUSTODY_GROUP_COUNT_ENR_FIELD, Bytes.fromHexString(hexString)); } public DiscoveryPeer createDiscoveryPeer(final Optional maybeForkId) { diff --git a/networking/p2p/src/test/java/tech/pegasys/teku/networking/p2p/discovery/discv5/NodeRecordConverterTest.java b/networking/p2p/src/test/java/tech/pegasys/teku/networking/p2p/discovery/discv5/NodeRecordConverterTest.java index 04b7061fa37..e273140ce7b 100644 --- a/networking/p2p/src/test/java/tech/pegasys/teku/networking/p2p/discovery/discv5/NodeRecordConverterTest.java +++ b/networking/p2p/src/test/java/tech/pegasys/teku/networking/p2p/discovery/discv5/NodeRecordConverterTest.java @@ -15,7 +15,7 @@ import static org.assertj.core.api.Assertions.assertThat; import static tech.pegasys.teku.networking.p2p.discovery.DiscoveryNetwork.ATTESTATION_SUBNET_ENR_FIELD; -import static tech.pegasys.teku.networking.p2p.discovery.DiscoveryNetwork.DAS_CUSTODY_SUBNET_COUNT_ENR_FIELD; +import static tech.pegasys.teku.networking.p2p.discovery.DiscoveryNetwork.DAS_CUSTODY_GROUP_COUNT_ENR_FIELD; import static tech.pegasys.teku.networking.p2p.discovery.DiscoveryNetwork.ETH2_ENR_FIELD; import static tech.pegasys.teku.networking.p2p.discovery.DiscoveryNetwork.SYNC_COMMITTEE_SUBNET_ENR_FIELD; @@ -353,7 +353,7 @@ public void shouldDecodeCscCorrectly(final String hexString, final Integer csc) false, new EnrField(EnrField.IP_V4, Bytes.wrap(new byte[] {127, 0, 0, 1})), new EnrField(EnrField.TCP, 1234), - new EnrField(DAS_CUSTODY_SUBNET_COUNT_ENR_FIELD, Bytes.fromHexString(hexString)))) + new EnrField(DAS_CUSTODY_GROUP_COUNT_ENR_FIELD, Bytes.fromHexString(hexString)))) .contains( new DiscoveryPeer( PUB_KEY, diff --git a/services/beaconchain/src/main/java/tech/pegasys/teku/services/beaconchain/BeaconChainController.java b/services/beaconchain/src/main/java/tech/pegasys/teku/services/beaconchain/BeaconChainController.java index 3e0cbd2ad5b..26ce2e56841 100644 --- a/services/beaconchain/src/main/java/tech/pegasys/teku/services/beaconchain/BeaconChainController.java +++ b/services/beaconchain/src/main/java/tech/pegasys/teku/services/beaconchain/BeaconChainController.java @@ -728,10 +728,10 @@ protected void initDasCustody() { .getBlockAtSlotExact(slot) .thenApply(sbb -> sbb.flatMap(SignedBeaconBlock::getBeaconBlock)); - int minCustodyRequirement = specConfigFulu.getCustodyRequirement(); - int maxSubnets = specConfigFulu.getDataColumnSidecarSubnetCount(); - int totalMyCustodySubnets = - beaconConfig.p2pConfig().getTotalCustodySubnetCount(spec.forMilestone(SpecMilestone.FULU)); + final int minCustodyGroupRequirement = specConfigFulu.getCustodyRequirement(); + final int maxGroups = specConfigFulu.getNumberOfCustodyGroups(); + final int totalMyCustodyGroups = + beaconConfig.p2pConfig().getTotalCustodyGroupCount(spec.forMilestone(SpecMilestone.FULU)); final UpdatableDataColumnSidecarCustody custody; { @@ -742,7 +742,7 @@ protected void initDasCustody() { dbAccessor, minCustodyPeriodSlotCalculator, nodeId, - totalMyCustodySubnets); + totalMyCustodyGroups); eventChannels.subscribe(SlotEventsChannel.class, dataColumnSidecarCustodyImpl); eventChannels.subscribe(FinalizedCheckpointChannel.class, dataColumnSidecarCustodyImpl); @@ -781,7 +781,8 @@ protected void initDasCustody() { MetadataDasPeerCustodyTracker peerCustodyTracker = new MetadataDasPeerCustodyTracker(); p2pNetwork.subscribeConnect(peerCustodyTracker); DasPeerCustodyCountSupplier custodyCountSupplier = - DasPeerCustodyCountSupplier.capped(peerCustodyTracker, minCustodyRequirement, maxSubnets); + DasPeerCustodyCountSupplier.capped( + peerCustodyTracker, minCustodyGroupRequirement, maxGroups); // TODO NOOP peer searcher should work for interop but needs to be implemented DataColumnPeerSearcher dataColumnPeerSearcher = DataColumnPeerSearcher.NOOP; @@ -827,8 +828,8 @@ protected void initDasCustody() { custody, recoveringSidecarRetriever, nodeId, - totalMyCustodySubnets); - LOG.info("DAS Basic Sampler initialized with {} subnets to sample", totalMyCustodySubnets); + totalMyCustodyGroups); + LOG.info("DAS Basic Sampler initialized with {} groups to sample", totalMyCustodyGroups); eventChannels.subscribe(FinalizedCheckpointChannel.class, dasSampler); this.dataAvailabilitySampler = dasSampler; } @@ -1164,7 +1165,7 @@ protected void initDataColumnSidecarSubnetBackboneSubscriber() { nodeId, beaconConfig .p2pConfig() - .getTotalCustodySubnetCount(spec.forMilestone(SpecMilestone.FULU))); + .getTotalCustodyGroupCount(spec.forMilestone(SpecMilestone.FULU))); eventChannels.subscribe(SlotEventsChannel.class, subnetBackboneSubscriber); } diff --git a/teku/src/main/java/tech/pegasys/teku/cli/options/P2POptions.java b/teku/src/main/java/tech/pegasys/teku/cli/options/P2POptions.java index 0d7a2352d50..511d1175d5a 100644 --- a/teku/src/main/java/tech/pegasys/teku/cli/options/P2POptions.java +++ b/teku/src/main/java/tech/pegasys/teku/cli/options/P2POptions.java @@ -402,12 +402,12 @@ The network interface(s) on which the node listens for P2P communication. GossipConfig.DEFAULT_FLOOD_PUBLISH_MAX_MESSAGE_SIZE_THRESHOLD; @Option( - names = {"--Xdas-extra-custody-subnet-count"}, + names = {"--Xdas-extra-custody-group-count"}, paramLabel = "", - description = "Number of extra custody subnets", + description = "Number of extra custody groups", arity = "1", hidden = true) - private int dasExtraCustodySubnetCount = P2PConfig.DEFAULT_DAS_EXTRA_CUSTODY_SUBNET_COUNT; + private int dasExtraCustodyGroupCount = P2PConfig.DEFAULT_DAS_EXTRA_CUSTODY_GROUP_COUNT; @Option( names = {"--Xdas-lossy-sampler-enabled"}, @@ -453,7 +453,7 @@ public void configure(final TekuConfiguration.Builder builder) { .peerRequestLimit(peerRequestLimit) .floodPublishMaxMessageSizeThreshold(floodPublishMaxMessageSizeThreshold) .gossipBlobsAfterBlockEnabled(gossipBlobsAfterBlockEnabled) - .dasExtraCustodySubnetCount(dasExtraCustodySubnetCount) + .dasExtraCustodyGroupCount(dasExtraCustodyGroupCount) .dasLossySamplerEnabled(dasLossySamplerEnabled); batchVerifyQueueCapacity.ifPresent(b::batchVerifyQueueCapacity); })