Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add new BlobSidecar #7668

Merged
merged 6 commits into from
Nov 8, 2023
Merged
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 @@ -28,7 +28,7 @@ public class FetchBlobSidecarTaskTest extends AbstractFetchTaskTest {

@Test
public void run_successful() {
final BlobSidecarOld blobSidecar = dataStructureUtil.randomBlobSidecar();
final BlobSidecarOld blobSidecar = dataStructureUtil.randomBlobSidecarOld();
final BlobIdentifier blobIdentifier =
new BlobIdentifier(blobSidecar.getBlockRoot(), blobSidecar.getIndex());
final FetchBlobSidecarTask task = new FetchBlobSidecarTask(eth2P2PNetwork, blobIdentifier);
Expand All @@ -48,7 +48,7 @@ public void run_successful() {

@Test
public void run_noPeers() {
final BlobSidecarOld blobSidecar = dataStructureUtil.randomBlobSidecar();
final BlobSidecarOld blobSidecar = dataStructureUtil.randomBlobSidecarOld();
final BlobIdentifier blobIdentifier =
new BlobIdentifier(blobSidecar.getBlockRoot(), blobSidecar.getIndex());
final FetchBlobSidecarTask task = new FetchBlobSidecarTask(eth2P2PNetwork, blobIdentifier);
Expand All @@ -63,7 +63,7 @@ public void run_noPeers() {

@Test
public void run_failAndRetryWithNoNewPeers() {
final BlobSidecarOld blobSidecar = dataStructureUtil.randomBlobSidecar();
final BlobSidecarOld blobSidecar = dataStructureUtil.randomBlobSidecarOld();
final BlobIdentifier blobIdentifier =
new BlobIdentifier(blobSidecar.getBlockRoot(), blobSidecar.getIndex());
final FetchBlobSidecarTask task = new FetchBlobSidecarTask(eth2P2PNetwork, blobIdentifier);
Expand Down Expand Up @@ -92,7 +92,7 @@ public void run_failAndRetryWithNoNewPeers() {

@Test
public void run_failAndRetryWithNewPeer() {
final BlobSidecarOld blobSidecar = dataStructureUtil.randomBlobSidecar();
final BlobSidecarOld blobSidecar = dataStructureUtil.randomBlobSidecarOld();
final BlobIdentifier blobIdentifier =
new BlobIdentifier(blobSidecar.getBlockRoot(), blobSidecar.getIndex());
final FetchBlobSidecarTask task = new FetchBlobSidecarTask(eth2P2PNetwork, blobIdentifier);
Expand Down Expand Up @@ -126,7 +126,7 @@ public void run_failAndRetryWithNewPeer() {

@Test
public void run_withMultiplesPeersAvailable() {
final BlobSidecarOld blobSidecar = dataStructureUtil.randomBlobSidecar();
final BlobSidecarOld blobSidecar = dataStructureUtil.randomBlobSidecarOld();
final BlobIdentifier blobIdentifier =
new BlobIdentifier(blobSidecar.getBlockRoot(), blobSidecar.getIndex());
final FetchBlobSidecarTask task = new FetchBlobSidecarTask(eth2P2PNetwork, blobIdentifier);
Expand All @@ -153,7 +153,7 @@ public void run_withMultiplesPeersAvailable() {
@Test
public void run_withPreferredPeer() {
final Eth2Peer preferredPeer = createNewPeer(1);
final BlobSidecarOld blobSidecar = dataStructureUtil.randomBlobSidecar();
final BlobSidecarOld blobSidecar = dataStructureUtil.randomBlobSidecarOld();
final BlobIdentifier blobIdentifier =
new BlobIdentifier(blobSidecar.getBlockRoot(), blobSidecar.getIndex());
when(preferredPeer.requestBlobSidecarByRoot(blobIdentifier))
Expand All @@ -176,7 +176,7 @@ public void run_withPreferredPeer() {
@Test
public void run_withRandomPeerWhenFetchingWithPreferredPeerFails() {
final Eth2Peer preferredPeer = createNewPeer(1);
final BlobSidecarOld blobSidecar = dataStructureUtil.randomBlobSidecar();
final BlobSidecarOld blobSidecar = dataStructureUtil.randomBlobSidecarOld();
final BlobIdentifier blobIdentifier =
new BlobIdentifier(blobSidecar.getBlockRoot(), blobSidecar.getIndex());
when(preferredPeer.requestBlobSidecarByRoot(blobIdentifier))
Expand Down Expand Up @@ -210,7 +210,7 @@ public void run_withRandomPeerWhenFetchingWithPreferredPeerFails() {

@Test
public void cancel() {
final BlobSidecarOld blobSidecar = dataStructureUtil.randomBlobSidecar();
final BlobSidecarOld blobSidecar = dataStructureUtil.randomBlobSidecarOld();
final BlobIdentifier blobIdentifier =
new BlobIdentifier(blobSidecar.getBlockRoot(), blobSidecar.getIndex());
final FetchBlobSidecarTask task = new FetchBlobSidecarTask(eth2P2PNetwork, blobIdentifier);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ public void fetchSingleBlobSidecarSuccessfully() {
assertThat(importedBlobSidecars).isEmpty();

final SafeFuture<FetchResult<BlobSidecarOld>> future = taskFutures.get(0);
final BlobSidecarOld blobSidecar = dataStructureUtil.randomBlobSidecar(blobIdentifier);
final BlobSidecarOld blobSidecar = dataStructureUtil.randomBlobSidecarOld(blobIdentifier);
future.complete(FetchResult.createSuccessful(blobSidecar));

assertThat(importedBlobSidecars).containsExactly(blobSidecar);
Expand All @@ -107,7 +107,7 @@ public void handleDuplicateRequiredBlobSidecars() {
assertThat(importedBlobSidecars).isEmpty();

final SafeFuture<FetchResult<BlobSidecarOld>> future = taskFutures.get(0);
final BlobSidecarOld blobSidecar = dataStructureUtil.randomBlobSidecar(blobIdentifier);
final BlobSidecarOld blobSidecar = dataStructureUtil.randomBlobSidecarOld(blobIdentifier);
future.complete(FetchResult.createSuccessful(blobSidecar));

assertThat(importedBlobSidecars).containsExactly(blobSidecar);
Expand Down Expand Up @@ -222,7 +222,7 @@ public void queueFetchTaskWhenConcurrencyLimitReached() {

// Complete first task
final SafeFuture<FetchResult<BlobSidecarOld>> future = taskFutures.get(0);
final BlobSidecarOld blobSidecar = dataStructureUtil.randomBlobSidecar();
final BlobSidecarOld blobSidecar = dataStructureUtil.randomBlobSidecarOld();
future.complete(FetchResult.createSuccessful(blobSidecar));

// After first task completes, remaining pending count should become active
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -374,7 +374,7 @@ public Function<BeaconBlock, SafeFuture<List<BlobSidecarOld>>> createBlobSidecar
return block -> {
final BlobSidecarSchemaOld blobSidecarSchema =
SchemaDefinitionsDeneb.required(spec.atSlot(block.getSlot()).getSchemaDefinitions())
.getBlobSidecarSchema();
.getBlobSidecarOldSchema();
return getCachedBlobsBundle(block.getSlot())
.thenApply(
blobsBundle ->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ public Response get(final UInt64 slot) throws IOException {
private List<BlobSidecarOld> parseBlobSidecars(final Response response) throws IOException {
final DeserializableTypeDefinition<BlobSidecarOld> blobSidecarTypeDefinition =
SchemaDefinitionsDeneb.required(spec.getGenesisSchemaDefinitions())
.getBlobSidecarSchema()
.getBlobSidecarOldSchema()
.getJsonTypeDefinition();
final DeserializableTypeDefinition<List<BlobSidecarOld>> jsonTypeDefinition =
SharedApiTypes.withDataWrapper("blobSidecars", listOf(blobSidecarTypeDefinition));
Expand All @@ -181,7 +181,8 @@ private List<BlobSidecarOld> parseBlobSidecars(final Response response) throws I
private List<BlobSidecarOld> parseBlobSidecarsFromSsz(final Response response)
throws IOException {
final BlobSidecarSchemaOld blobSidecarSchema =
SchemaDefinitionsDeneb.required(spec.getGenesisSchemaDefinitions()).getBlobSidecarSchema();
SchemaDefinitionsDeneb.required(spec.getGenesisSchemaDefinitions())
.getBlobSidecarOldSchema();
SszListSchema<BlobSidecarOld, ? extends SszList<BlobSidecarOld>> blobSidecarSszListSchema =
SszListSchema.create(
blobSidecarSchema, SpecConfigDeneb.required(specConfig).getMaxBlobsPerBlock());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ public Response get(final String blockIdString, final List<UInt64> indices) thro
private List<BlobSidecarOld> parseBlobSidecars(final Response response) throws IOException {
final DeserializableTypeDefinition<BlobSidecarOld> blobSidecarTypeDefinition =
SchemaDefinitionsDeneb.required(spec.getGenesisSchemaDefinitions())
.getBlobSidecarSchema()
.getBlobSidecarOldSchema()
.getJsonTypeDefinition();
final DeserializableTypeDefinition<List<BlobSidecarOld>> jsonTypeDefinition =
SharedApiTypes.withDataWrapper("blobSidecars", listOf(blobSidecarTypeDefinition));
Expand All @@ -208,7 +208,8 @@ private List<BlobSidecarOld> parseBlobSidecars(final Response response) throws I
private List<BlobSidecarOld> parseBlobSidecarsFromSsz(final Response response)
throws IOException {
final BlobSidecarSchemaOld blobSidecarSchema =
SchemaDefinitionsDeneb.required(spec.getGenesisSchemaDefinitions()).getBlobSidecarSchema();
SchemaDefinitionsDeneb.required(spec.getGenesisSchemaDefinitions())
.getBlobSidecarOldSchema();
SszListSchema<BlobSidecarOld, ? extends SszList<BlobSidecarOld>> blobSidecarSszListSchema =
SszListSchema.create(
blobSidecarSchema, SpecConfigDeneb.required(specConfig).getMaxBlobsPerBlock());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ private static SerializableTypeDefinition<List<BlobSidecarOld>> getResponseType(
final SchemaDefinitionCache schemaCache) {
final DeserializableTypeDefinition<BlobSidecarOld> blobSidecarType =
SchemaDefinitionsDeneb.required(schemaCache.getSchemaDefinition(SpecMilestone.DENEB))
.getBlobSidecarSchema()
.getBlobSidecarOldSchema()
.getJsonTypeDefinition();
return SerializableTypeDefinition.<List<BlobSidecarOld>>object()
.name("GetAllBlobSidecarsAtSlotResponse")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ private static SerializableTypeDefinition<List<BlobSidecarOld>> getResponseType(
final SchemaDefinitionCache schemaCache) {
final DeserializableTypeDefinition<BlobSidecarOld> blobSidecarType =
SchemaDefinitionsDeneb.required(schemaCache.getSchemaDefinition(SpecMilestone.DENEB))
.getBlobSidecarSchema()
.getBlobSidecarOldSchema()
.getJsonTypeDefinition();
return SerializableTypeDefinition.<List<BlobSidecarOld>>object()
.name("GetBlobSidecarsResponse")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ public class EventSubscriptionManagerTest {
private final SyncState sampleSyncState = SyncState.IN_SYNC;
private final SignedBeaconBlock sampleBlock =
SignedBeaconBlock.create(data.randomSignedBeaconBlock(0));
private final BlobSidecarOld sampleBlobSidecar = data.randomBlobSidecar();
private final BlobSidecarOld sampleBlobSidecar = data.randomBlobSidecarOld();
private final Attestation sampleAttestation = data.randomAttestation(0);
private final SignedVoluntaryExit sampleVoluntaryExit = data.randomSignedVoluntaryExit();
private final SignedBlsToExecutionChange sampleBlsToExecutionChange =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -179,11 +179,12 @@ public class SszTestExecutor<T extends SszData> implements TestExecutor {
.put(
"ssz_static/BlobSidecar",
new SszTestExecutor<>(
schemas -> SchemaDefinitionsDeneb.required(schemas).getBlobSidecarSchema()))
schemas -> SchemaDefinitionsDeneb.required(schemas).getBlobSidecarOldSchema()))
.put(
"ssz_static/SignedBlobSidecar",
new SszTestExecutor<>(
schemas -> SchemaDefinitionsDeneb.required(schemas).getSignedBlobSidecarSchema()))
schemas ->
SchemaDefinitionsDeneb.required(schemas).getSignedBlobSidecarOldSchema()))
.put(
"ssz_static/BlobIdentifier",
new SszTestExecutor<>(schemas -> BlobIdentifier.SSZ_SCHEMA))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -395,7 +395,7 @@ public BlobSidecarOld deserializeBlobSidecar(
.toVersionDeneb()
.orElseThrow(
() -> new RuntimeException("Deneb milestone is required to deserialize blob sidecar"))
.getBlobSidecarSchema()
.getBlobSidecarOldSchema()
.sszDeserialize(serializedBlobSidecar);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ static SpecConfigDeneb required(final SpecConfig specConfig) {

int getMaxBlobsPerBlock();

int getKzgCommitmentInclusionProofDepth();

int getEpochsStoreBlobs();

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ public class SpecConfigDenebImpl extends DelegatingSpecConfigCapella implements
private final int fieldElementsPerBlob;
private final int maxBlobCommitmentsPerBlock;
private final int maxBlobsPerBlock;
private final int kzgCommitmentInclusionProofDepth;
private final int maxRequestBlocksDeneb;
private final int maxRequestBlobSidecars;
private final int minEpochsForBlobSidecarsRequests;
Expand All @@ -41,6 +42,7 @@ public SpecConfigDenebImpl(
final int fieldElementsPerBlob,
final int maxBlobCommitmentsPerBlock,
final int maxBlobsPerBlock,
final int kzgCommitmentInclusionProofDepth,
final int maxRequestBlocksDeneb,
final int maxRequestBlobSidecars,
final int minEpochsForBlobSidecarsRequests,
Expand All @@ -53,6 +55,7 @@ public SpecConfigDenebImpl(
this.fieldElementsPerBlob = fieldElementsPerBlob;
this.maxBlobCommitmentsPerBlock = maxBlobCommitmentsPerBlock;
this.maxBlobsPerBlock = maxBlobsPerBlock;
this.kzgCommitmentInclusionProofDepth = kzgCommitmentInclusionProofDepth;
this.maxRequestBlocksDeneb = maxRequestBlocksDeneb;
this.maxRequestBlobSidecars = maxRequestBlobSidecars;
this.minEpochsForBlobSidecarsRequests = minEpochsForBlobSidecarsRequests;
Expand Down Expand Up @@ -90,6 +93,11 @@ public int getMaxBlobsPerBlock() {
return maxBlobsPerBlock;
}

@Override
public int getKzgCommitmentInclusionProofDepth() {
return kzgCommitmentInclusionProofDepth;
}

@Override
public int getMaxRequestBlocksDeneb() {
return maxRequestBlocksDeneb;
Expand Down Expand Up @@ -138,6 +146,7 @@ public boolean equals(final Object o) {
&& fieldElementsPerBlob == that.fieldElementsPerBlob
&& maxBlobCommitmentsPerBlock == that.maxBlobCommitmentsPerBlock
&& maxBlobsPerBlock == that.maxBlobsPerBlock
&& kzgCommitmentInclusionProofDepth == that.kzgCommitmentInclusionProofDepth
&& maxRequestBlocksDeneb == that.maxRequestBlocksDeneb
&& maxRequestBlobSidecars == that.maxRequestBlobSidecars
&& minEpochsForBlobSidecarsRequests == that.minEpochsForBlobSidecarsRequests
Expand All @@ -153,6 +162,7 @@ public int hashCode() {
fieldElementsPerBlob,
maxBlobCommitmentsPerBlock,
maxBlobsPerBlock,
kzgCommitmentInclusionProofDepth,
maxRequestBlocksDeneb,
maxRequestBlobSidecars,
minEpochsForBlobSidecarsRequests,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,12 @@ public class DenebBuilder implements ForkConfigBuilder<SpecConfigCapella, SpecCo
private Integer fieldElementsPerBlob;
private Integer maxBlobCommitmentsPerBlock;
private Integer maxBlobsPerBlock;
private Integer kzgCommitmentInclusionProofDepth;
private Integer maxRequestBlocksDeneb;
private Integer maxRequestBlobSidecars;
private Integer minEpochsForBlobSidecarsRequests;
private Optional<Integer> epochsStoreBlobs = Optional.empty();
private Integer blobSidecarSubnetCount;
private Optional<Integer> epochsStoreBlobs = Optional.empty();

DenebBuilder() {}

Expand All @@ -54,6 +55,7 @@ public SpecConfigDeneb build(final SpecConfigCapella specConfig) {
fieldElementsPerBlob,
maxBlobCommitmentsPerBlock,
maxBlobsPerBlock,
kzgCommitmentInclusionProofDepth,
maxRequestBlocksDeneb,
maxRequestBlobSidecars,
minEpochsForBlobSidecarsRequests,
Expand Down Expand Up @@ -95,6 +97,12 @@ public DenebBuilder maxBlobsPerBlock(final Integer maxBlobsPerBlock) {
return this;
}

public DenebBuilder kzgCommitmentInclusionProofDepth(
final Integer kzgCommitmentInclusionProofDepth) {
this.kzgCommitmentInclusionProofDepth = kzgCommitmentInclusionProofDepth;
return this;
}

public DenebBuilder maxRequestBlocksDeneb(final Integer maxRequestBlocksDeneb) {
this.maxRequestBlocksDeneb = maxRequestBlocksDeneb;
return this;
Expand Down Expand Up @@ -146,6 +154,7 @@ public Map<String, Object> getValidationMap() {
constants.put("fieldElementsPerBlob", fieldElementsPerBlob);
constants.put("maxBlobCommitmentsPerBlock", maxBlobCommitmentsPerBlock);
constants.put("maxBlobsPerBlock", maxBlobsPerBlock);
constants.put("kzgCommitmentInclusionProofDepth", kzgCommitmentInclusionProofDepth);
constants.put("maxRequestBlocksDeneb", maxRequestBlocksDeneb);
constants.put("maxRequestBlobSidecars", maxRequestBlobSidecars);
constants.put("minEpochsForBlobSidecarsRequests", minEpochsForBlobSidecarsRequests);
Expand Down
Loading
Loading