Skip to content
Open
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 @@ -25,6 +25,7 @@
import tech.pegasys.teku.spec.datastructures.blobs.versions.deneb.Blob;
import tech.pegasys.teku.spec.datastructures.blobs.versions.fulu.MatrixEntry;
import tech.pegasys.teku.spec.datastructures.blocks.SignedBeaconBlock;
import tech.pegasys.teku.spec.datastructures.execution.BlobAndCellProofs;
import tech.pegasys.teku.spec.datastructures.type.SszKZGCommitment;
import tech.pegasys.teku.spec.logic.versions.electra.helpers.PredicatesElectra;
import tech.pegasys.teku.spec.logic.versions.fulu.helpers.MiscHelpersFulu;
Expand Down Expand Up @@ -62,7 +63,11 @@ public class SidecarBenchmarkConfig {
.map(SszKZGCommitment::new)
.toList();
miscHelpersFulu.setKzg(getKzg(useRustLibrary));
extendedMatrix = miscHelpersFulu.computeExtendedMatrixAndProofs(blobs);
Comment thread
Matilda-Clerke marked this conversation as resolved.
List<BlobAndCellProofs> blobsAndCellProofs =
blobs.stream()
.map((b) -> dataStructureUtil.computeBlobAndCellProofs(miscHelpersFulu.getKzg(), b))
.toList();
extendedMatrix = miscHelpersFulu.computeExtendedMatrix(blobsAndCellProofs);
signedBeaconBlock =
dataStructureUtil.randomSignedBeaconBlockWithCommitments(
blobKzgCommitmentsSchema.createFromElements(kzgCommitments));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,13 @@ public void setup() {

@Benchmark
public void computeExtendedMatrixAndProofs(final ExecutionPlan plan) {
plan.config.miscHelpersFulu.computeExtendedMatrixAndProofs(plan.config.blobs);
plan.config.miscHelpersFulu.computeExtendedMatrix(
plan.config.blobs.stream()
.map(
(b) ->
plan.config.dataStructureUtil.computeBlobAndCellProofs(
plan.config.miscHelpersFulu.getKzg(), b))
.toList());
Comment thread
cursor[bot] marked this conversation as resolved.
}

@Benchmark
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@
import tech.pegasys.teku.spec.datastructures.blobs.DataColumnSidecar;
import tech.pegasys.teku.spec.datastructures.blobs.DataColumnSidecarBuilder;
import tech.pegasys.teku.spec.datastructures.blobs.DataColumnSidecarSchema;
import tech.pegasys.teku.spec.datastructures.blobs.versions.deneb.Blob;
import tech.pegasys.teku.spec.datastructures.blobs.versions.fulu.Cell;
import tech.pegasys.teku.spec.datastructures.blobs.versions.fulu.DataColumn;
import tech.pegasys.teku.spec.datastructures.blobs.versions.fulu.DataColumnSidecarFulu;
Expand Down Expand Up @@ -365,16 +364,6 @@ public List<Bytes32> computeDataColumnKzgCommitmentsInclusionProof(
beaconBlockBody.getBackingNode(), getBlockBodyKzgCommitmentsGeneralizedIndex());
}

@VisibleForTesting
@Deprecated
public List<DataColumnSidecar> constructDataColumnSidecarsOld(
final SignedBeaconBlock signedBeaconBlock, final List<Blob> blobs) {
return constructDataColumnSidecars(
signedBeaconBlock.getMessage(),
signedBeaconBlock.asHeader(),
computeExtendedMatrixAndProofs(blobs));
}

public List<DataColumnSidecar> constructDataColumnSidecars(
final SignedBeaconBlock signedBeaconBlock,
final List<BlobAndCellProofs> blobAndCellProofsList) {
Expand All @@ -400,40 +389,6 @@ public List<DataColumnSidecar> constructDataColumnSidecars(
extendedMatrix);
}

/**
* Return the full ``ExtendedMatrix``.
*
* <p>This helper demonstrates the relationship between blobs and ``ExtendedMatrix``.
*
* <p>The data structure for storing cells is implementation-dependent.
*
* <p>This method uses heavy calculation, use it only when needed
*/
@VisibleForTesting
@Deprecated
public List<List<MatrixEntry>> computeExtendedMatrixAndProofs(final List<Blob> blobs) {
return IntStream.range(0, blobs.size())
.parallel()
.mapToObj(
blobIndex -> {
final List<KZGCellAndProof> kzgCellAndProofs =
getKzg().computeCellsAndProofs(blobs.get(blobIndex).getBytes());
final List<MatrixEntry> row = new ArrayList<>();
for (int cellIndex = 0; cellIndex < kzgCellAndProofs.size(); ++cellIndex) {
row.add(
schemaDefinitionsFulu
.getMatrixEntrySchema()
.create(
kzgCellAndProofs.get(cellIndex).cell(),
kzgCellAndProofs.get(cellIndex).proof(),
cellIndex,
blobIndex));
}
return row;
})
.toList();
}

public List<List<MatrixEntry>> computeExtendedMatrix(
final List<BlobAndCellProofs> blobAndCellProofsList) {
return IntStream.range(0, blobAndCellProofsList.size())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,12 @@
import tech.pegasys.teku.spec.config.SpecConfigFulu;
import tech.pegasys.teku.spec.datastructures.blobs.DataColumnSidecar;
import tech.pegasys.teku.spec.datastructures.blobs.DataColumnSidecarSchema;
import tech.pegasys.teku.spec.datastructures.blobs.versions.deneb.Blob;
import tech.pegasys.teku.spec.datastructures.blobs.versions.fulu.DataColumn;
import tech.pegasys.teku.spec.datastructures.blobs.versions.fulu.DataColumnSidecarFulu;
import tech.pegasys.teku.spec.datastructures.blocks.BeaconBlockHeader;
import tech.pegasys.teku.spec.datastructures.blocks.SignedBeaconBlock;
import tech.pegasys.teku.spec.datastructures.blocks.SignedBeaconBlockHeader;
import tech.pegasys.teku.spec.datastructures.execution.BlobAndCellProofs;
import tech.pegasys.teku.spec.datastructures.state.BeaconStateTestBuilder;
import tech.pegasys.teku.spec.datastructures.state.beaconstate.BeaconState;
import tech.pegasys.teku.spec.logic.common.statetransition.availability.AvailabilityCheckerFactory;
Expand Down Expand Up @@ -304,17 +304,23 @@ static void setUpSharedTestData() {
MiscHelpersFulu.required(SPEC.forMilestone(SpecMilestone.FULU).miscHelpers());

// Create test data once for all tests
final List<Blob> blobs =
IntStream.range(0, 4).mapToObj(__ -> dataStructureUtil.randomValidBlob()).toList();
final List<BlobAndCellProofs> blobsAndCellProofs =
IntStream.range(0, 4)
.mapToObj(
__ -> {
return dataStructureUtil.computeBlobAndCellProofs(
miscHelpersFulu.getKzg(), dataStructureUtil.randomValidBlob());
})
.toList();

sharedSignedBeaconBlock =
dataStructureUtil.randomSignedBeaconBlockWithCommitments(blobs.size());
dataStructureUtil.randomSignedBeaconBlockWithCommitments(blobsAndCellProofs.size());

sharedOriginalSidecars =
miscHelpersFulu.constructDataColumnSidecars(
sharedSignedBeaconBlock.getMessage(),
sharedSignedBeaconBlock.asHeader(),
miscHelpersFulu.computeExtendedMatrixAndProofs(blobs));
miscHelpersFulu.computeExtendedMatrix(blobsAndCellProofs));
}

@ParameterizedTest(name = "{0} validator custody groups required")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,9 @@
import tech.pegasys.teku.infrastructure.ssz.schema.collections.SszUInt64VectorSchema;
import tech.pegasys.teku.infrastructure.time.SystemTimeProvider;
import tech.pegasys.teku.infrastructure.unsigned.UInt64;
import tech.pegasys.teku.kzg.KZG;
import tech.pegasys.teku.kzg.KZGCell;
import tech.pegasys.teku.kzg.KZGCellAndProof;
import tech.pegasys.teku.kzg.KZGCommitment;
import tech.pegasys.teku.kzg.KZGProof;
import tech.pegasys.teku.spec.Spec;
Expand Down Expand Up @@ -160,6 +162,7 @@
import tech.pegasys.teku.spec.datastructures.epbs.versions.gloas.SignedExecutionPayloadBid;
import tech.pegasys.teku.spec.datastructures.epbs.versions.gloas.SignedExecutionPayloadEnvelope;
import tech.pegasys.teku.spec.datastructures.epbs.versions.gloas.SignedProposerPreferences;
import tech.pegasys.teku.spec.datastructures.execution.BlobAndCellProofs;
import tech.pegasys.teku.spec.datastructures.execution.BlobsBundle;
import tech.pegasys.teku.spec.datastructures.execution.ClientVersion;
import tech.pegasys.teku.spec.datastructures.execution.ExecutionPayload;
Expand Down Expand Up @@ -555,6 +558,12 @@ public SszKZGProof randomSszKZGProof() {
return new SszKZGProof(randomKZGProof());
}

public BlobAndCellProofs computeBlobAndCellProofs(final KZG kzg, final Blob blob) {
return new BlobAndCellProofs(
blob,
kzg.computeCellsAndProofs(blob.getBytes()).stream().map(KZGCellAndProof::proof).toList());
}

public Bytes48 randomPublicKeyBytes() {
return pubKeyGenerator.get().toBytesCompressed();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,6 @@ private void advanceTimeGradually(final Duration delta) {
}

@Test
@SuppressWarnings("deprecation")
void sanityTest() {
final TestPeer custodyPeerMissingData = createCustodyPeer();
final TestPeer custodyPeerHavingData = createCustodyPeer();
Expand All @@ -136,7 +135,11 @@ void sanityTest() {
final List<Blob> blobs = Stream.generate(dataStructureUtil::randomValidBlob).limit(1).toList();
final BeaconBlock block = blockResolver.addBlock(10, 1);
final List<DataColumnSidecar> sidecars =
miscHelpers.constructDataColumnSidecarsOld(createSigned(block), blobs);
miscHelpers.constructDataColumnSidecars(
createSigned(block),
blobs.stream()
.map((b) -> dataStructureUtil.computeBlobAndCellProofs(miscHelpers.getKzg(), b))
.toList());
final DataColumnSidecar sidecar0 = sidecars.get(columnIndex.intValue());

final DataColumnSlotAndIdentifier id0 = createId(block, columnIndex.intValue());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
import tech.pegasys.teku.spec.TestSpecFactory;
import tech.pegasys.teku.spec.config.SpecConfigFulu;
import tech.pegasys.teku.spec.datastructures.blobs.DataColumnSidecar;
import tech.pegasys.teku.spec.datastructures.blobs.versions.deneb.Blob;
import tech.pegasys.teku.spec.datastructures.blocks.BeaconBlock;
import tech.pegasys.teku.spec.datastructures.util.DataColumnSlotAndIdentifier;
import tech.pegasys.teku.spec.logic.versions.fulu.helpers.MiscHelpersFulu;
Expand Down Expand Up @@ -162,9 +163,11 @@ void successfulRetrievalShouldRemoveFromPendingRequests() {
final int blobCount = 1;
final int columnsInDbCount = 1;
final BeaconBlock block = blockResolver.addBlock(10, blobCount);
final Blob blob = dataStructureUtil.randomValidBlob();
final List<DataColumnSidecar> sidecars =
miscHelpers.constructDataColumnSidecarsOld(
dataStructureUtil.signedBlock(block), List.of(dataStructureUtil.randomValidBlob()));
miscHelpers.constructDataColumnSidecars(
dataStructureUtil.signedBlock(block),
List.of(dataStructureUtil.computeBlobAndCellProofs(miscHelpers.getKzg(), blob)));
final List<Integer> dbColumnIndices =
IntStream.range(10, Integer.MAX_VALUE).limit(columnsInDbCount).boxed().toList();
dbColumnIndices.forEach(idx -> assertThat(db.addSidecar(sidecars.get(idx))).isDone());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ public class BlobReconstructionAbstractTest {

@Test
@Disabled
@SuppressWarnings("deprecation")
public void regenerateValidBlobsAndCellsFile() {
reinitializeSpecWithProductionKZG();

Expand All @@ -67,7 +66,10 @@ public void regenerateValidBlobsAndCellsFile() {
.map(
b -> {
final var sidecars =
miscHelpers.constructDataColumnSidecarsOld(block, List.of(b));
miscHelpers.constructDataColumnSidecars(
block,
List.of(
dataStructureUtil.computeBlobAndCellProofs(miscHelpers.getKzg(), b)));
return new CellData(
b.getBytes().toHexString(),
sidecars.stream()
Expand Down
Loading