From 49b2a442920a6445a1c241df229e351351fe301e Mon Sep 17 00:00:00 2001 From: Stefan Bratanov Date: Thu, 16 Nov 2023 10:29:25 +0000 Subject: [PATCH] Remove `SignedBlobSidecar` container --- .../phase0/ssz_static/SszTestExecutor.java | 7 +- .../versions/deneb/SignedBlobSidecarOld.java | 52 -------------- .../deneb/SignedBlobSidecarSchemaOld.java | 47 ------------ .../spec/schemas/SchemaDefinitionsDeneb.java | 7 -- .../versions/deneb/SignedBlobSidecarTest.java | 71 ------------------- .../teku/spec/util/DataStructureUtil.java | 48 ++----------- 6 files changed, 8 insertions(+), 224 deletions(-) delete mode 100644 ethereum/spec/src/main/java/tech/pegasys/teku/spec/datastructures/blobs/versions/deneb/SignedBlobSidecarOld.java delete mode 100644 ethereum/spec/src/main/java/tech/pegasys/teku/spec/datastructures/blobs/versions/deneb/SignedBlobSidecarSchemaOld.java delete mode 100644 ethereum/spec/src/test/java/tech/pegasys/teku/spec/datastructures/blocks/blockbody/versions/deneb/SignedBlobSidecarTest.java diff --git a/eth-reference-tests/src/referenceTest/java/tech/pegasys/teku/reference/phase0/ssz_static/SszTestExecutor.java b/eth-reference-tests/src/referenceTest/java/tech/pegasys/teku/reference/phase0/ssz_static/SszTestExecutor.java index 5c1c6a27cc3..d0449a50145 100644 --- a/eth-reference-tests/src/referenceTest/java/tech/pegasys/teku/reference/phase0/ssz_static/SszTestExecutor.java +++ b/eth-reference-tests/src/referenceTest/java/tech/pegasys/teku/reference/phase0/ssz_static/SszTestExecutor.java @@ -179,12 +179,7 @@ public class SszTestExecutor implements TestExecutor { .put( "ssz_static/BlobSidecar", new SszTestExecutor<>( - schemas -> SchemaDefinitionsDeneb.required(schemas).getBlobSidecarOldSchema())) - .put( - "ssz_static/SignedBlobSidecar", - new SszTestExecutor<>( - schemas -> - SchemaDefinitionsDeneb.required(schemas).getSignedBlobSidecarOldSchema())) + schemas -> SchemaDefinitionsDeneb.required(schemas).getBlobSidecarSchema())) .put( "ssz_static/BlobIdentifier", new SszTestExecutor<>(schemas -> BlobIdentifier.SSZ_SCHEMA)) diff --git a/ethereum/spec/src/main/java/tech/pegasys/teku/spec/datastructures/blobs/versions/deneb/SignedBlobSidecarOld.java b/ethereum/spec/src/main/java/tech/pegasys/teku/spec/datastructures/blobs/versions/deneb/SignedBlobSidecarOld.java deleted file mode 100644 index ec84f4d10c7..00000000000 --- a/ethereum/spec/src/main/java/tech/pegasys/teku/spec/datastructures/blobs/versions/deneb/SignedBlobSidecarOld.java +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright Consensys Software Inc., 2023 - * - * 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.spec.datastructures.blobs.versions.deneb; - -import tech.pegasys.teku.bls.BLSSignature; -import tech.pegasys.teku.infrastructure.ssz.containers.Container2; -import tech.pegasys.teku.infrastructure.ssz.tree.TreeNode; -import tech.pegasys.teku.infrastructure.unsigned.UInt64; -import tech.pegasys.teku.spec.datastructures.type.SszSignature; - -@Deprecated -public class SignedBlobSidecarOld - extends Container2 { - - SignedBlobSidecarOld(final SignedBlobSidecarSchemaOld type, final TreeNode backingNode) { - super(type, backingNode); - } - - public SignedBlobSidecarOld( - final SignedBlobSidecarSchemaOld schema, - final BlobSidecarOld blobSidecar, - final BLSSignature signature) { - super(schema, blobSidecar, new SszSignature(signature)); - } - - public BlobSidecarOld getMessage() { - return getField0(); - } - - public BlobSidecarOld getBlobSidecar() { - return getField0(); - } - - public BLSSignature getSignature() { - return getField1().getSignature(); - } - - public UInt64 getSlot() { - return getBlobSidecar().getSlot(); - } -} diff --git a/ethereum/spec/src/main/java/tech/pegasys/teku/spec/datastructures/blobs/versions/deneb/SignedBlobSidecarSchemaOld.java b/ethereum/spec/src/main/java/tech/pegasys/teku/spec/datastructures/blobs/versions/deneb/SignedBlobSidecarSchemaOld.java deleted file mode 100644 index 21f215bf994..00000000000 --- a/ethereum/spec/src/main/java/tech/pegasys/teku/spec/datastructures/blobs/versions/deneb/SignedBlobSidecarSchemaOld.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Copyright Consensys Software Inc., 2023 - * - * 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.spec.datastructures.blobs.versions.deneb; - -import tech.pegasys.teku.bls.BLSSignature; -import tech.pegasys.teku.infrastructure.ssz.containers.ContainerSchema2; -import tech.pegasys.teku.infrastructure.ssz.tree.TreeNode; -import tech.pegasys.teku.spec.datastructures.blocks.SignedBeaconBlockFields; -import tech.pegasys.teku.spec.datastructures.type.SszSignature; -import tech.pegasys.teku.spec.datastructures.type.SszSignatureSchema; - -@Deprecated -public class SignedBlobSidecarSchemaOld - extends ContainerSchema2 { - - SignedBlobSidecarSchemaOld(final BlobSidecarSchemaOld blobSidecarSchema) { - super( - "SignedBlobSidecar", - namedSchema("message", blobSidecarSchema), - namedSchema(SignedBeaconBlockFields.SIGNATURE, SszSignatureSchema.INSTANCE)); - } - - public static SignedBlobSidecarSchemaOld create(final BlobSidecarSchemaOld blobSidecarSchema) { - return new SignedBlobSidecarSchemaOld(blobSidecarSchema); - } - - public SignedBlobSidecarOld create( - final BlobSidecarOld blobSidecar, final BLSSignature signature) { - return new SignedBlobSidecarOld(this, blobSidecar, signature); - } - - @Override - public SignedBlobSidecarOld createFromBackingNode(final TreeNode node) { - return new SignedBlobSidecarOld(this, node); - } -} diff --git a/ethereum/spec/src/main/java/tech/pegasys/teku/spec/schemas/SchemaDefinitionsDeneb.java b/ethereum/spec/src/main/java/tech/pegasys/teku/spec/schemas/SchemaDefinitionsDeneb.java index c8d426d4d29..fb0f5e41fe2 100644 --- a/ethereum/spec/src/main/java/tech/pegasys/teku/spec/schemas/SchemaDefinitionsDeneb.java +++ b/ethereum/spec/src/main/java/tech/pegasys/teku/spec/schemas/SchemaDefinitionsDeneb.java @@ -24,7 +24,6 @@ import tech.pegasys.teku.spec.datastructures.blobs.versions.deneb.BlobSchema; import tech.pegasys.teku.spec.datastructures.blobs.versions.deneb.BlobSidecarSchema; import tech.pegasys.teku.spec.datastructures.blobs.versions.deneb.BlobSidecarSchemaOld; -import tech.pegasys.teku.spec.datastructures.blobs.versions.deneb.SignedBlobSidecarSchemaOld; import tech.pegasys.teku.spec.datastructures.blocks.BeaconBlockSchema; import tech.pegasys.teku.spec.datastructures.blocks.BlockContainer; import tech.pegasys.teku.spec.datastructures.blocks.BlockContainerSchema; @@ -80,7 +79,6 @@ public class SchemaDefinitionsDeneb extends SchemaDefinitionsCapella { private final SszListSchema> blobsInBlockSchema; private final BlobSidecarSchema blobSidecarSchema; private final BlobSidecarSchemaOld blobSidecarOldSchema; - private final SignedBlobSidecarSchemaOld signedBlobSidecarOldSchema; private final BlockContentsSchema blockContentsSchema; private final SignedBlockContentsSchema signedBlockContentsSchema; private final BlobsBundleSchema blobsBundleSchema; @@ -132,7 +130,6 @@ public SchemaDefinitionsDeneb(final SpecConfigDeneb specConfig) { blobSchema, specConfig.getKzgCommitmentInclusionProofDepth()); this.blobSidecarOldSchema = BlobSidecarSchemaOld.create(blobSchema); - this.signedBlobSidecarOldSchema = SignedBlobSidecarSchemaOld.create(blobSidecarOldSchema); this.blockContentsSchema = BlockContentsSchema.create(specConfig, beaconBlockSchema, blobSchema, "BlockContentsDeneb"); this.signedBlockContentsSchema = @@ -256,10 +253,6 @@ public BlobSidecarSchemaOld getBlobSidecarOldSchema() { return blobSidecarOldSchema; } - public SignedBlobSidecarSchemaOld getSignedBlobSidecarOldSchema() { - return signedBlobSidecarOldSchema; - } - public BlockContentsSchema getBlockContentsSchema() { return blockContentsSchema; } diff --git a/ethereum/spec/src/test/java/tech/pegasys/teku/spec/datastructures/blocks/blockbody/versions/deneb/SignedBlobSidecarTest.java b/ethereum/spec/src/test/java/tech/pegasys/teku/spec/datastructures/blocks/blockbody/versions/deneb/SignedBlobSidecarTest.java deleted file mode 100644 index fa0756adc02..00000000000 --- a/ethereum/spec/src/test/java/tech/pegasys/teku/spec/datastructures/blocks/blockbody/versions/deneb/SignedBlobSidecarTest.java +++ /dev/null @@ -1,71 +0,0 @@ -/* - * Copyright Consensys Software Inc., 2023 - * - * 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.spec.datastructures.blocks.blockbody.versions.deneb; - -import static org.assertj.core.api.Assertions.assertThat; - -import org.apache.tuweni.bytes.Bytes; -import org.junit.jupiter.api.Test; -import tech.pegasys.teku.bls.BLSSignature; -import tech.pegasys.teku.spec.SpecMilestone; -import tech.pegasys.teku.spec.TestSpecFactory; -import tech.pegasys.teku.spec.datastructures.blobs.versions.deneb.BlobSidecarOld; -import tech.pegasys.teku.spec.datastructures.blobs.versions.deneb.SignedBlobSidecarOld; -import tech.pegasys.teku.spec.datastructures.blobs.versions.deneb.SignedBlobSidecarSchemaOld; -import tech.pegasys.teku.spec.schemas.SchemaDefinitions; -import tech.pegasys.teku.spec.util.DataStructureUtil; - -public class SignedBlobSidecarTest { - - private final DataStructureUtil dataStructureUtil = - new DataStructureUtil(TestSpecFactory.createMinimal(SpecMilestone.DENEB)); - final SchemaDefinitions schemaDefinitions = - dataStructureUtil.getSpec().getGenesisSchemaDefinitions(); - private final SignedBlobSidecarSchemaOld signedBlobSidecarSchema = - schemaDefinitions.toVersionDeneb().orElseThrow().getSignedBlobSidecarOldSchema(); - private final BlobSidecarOld blobSidecar = dataStructureUtil.randomBlobSidecarOld(); - - private final BLSSignature signature = dataStructureUtil.randomSignature(); - - @Test - public void objectEquality() { - final SignedBlobSidecarOld signedBlobSidecar1 = - signedBlobSidecarSchema.create(blobSidecar, signature); - final SignedBlobSidecarOld signedBlobSidecar2 = - signedBlobSidecarSchema.create(blobSidecar, signature); - - assertThat(signedBlobSidecar1).isEqualTo(signedBlobSidecar2); - } - - @Test - public void objectAccessorMethods() { - final SignedBlobSidecarOld signedBlobSidecar = - signedBlobSidecarSchema.create(blobSidecar, signature); - - assertThat(signedBlobSidecar.getBlobSidecar()).isEqualTo(blobSidecar); - assertThat(signedBlobSidecar.getSignature()).isEqualTo(signature); - } - - @Test - public void roundTripSSZ() { - final SignedBlobSidecarOld signedBlobSidecar = - signedBlobSidecarSchema.create(blobSidecar, signature); - - final Bytes sszSignedBlobSidecarBytes = signedBlobSidecar.sszSerialize(); - final SignedBlobSidecarOld deserializedObject = - signedBlobSidecarSchema.sszDeserialize(sszSignedBlobSidecarBytes); - - assertThat(signedBlobSidecar).isEqualTo(deserializedObject); - } -} diff --git a/ethereum/spec/src/testFixtures/java/tech/pegasys/teku/spec/util/DataStructureUtil.java b/ethereum/spec/src/testFixtures/java/tech/pegasys/teku/spec/util/DataStructureUtil.java index e56f4ea72dc..0fe56657903 100644 --- a/ethereum/spec/src/testFixtures/java/tech/pegasys/teku/spec/util/DataStructureUtil.java +++ b/ethereum/spec/src/testFixtures/java/tech/pegasys/teku/spec/util/DataStructureUtil.java @@ -92,8 +92,6 @@ import tech.pegasys.teku.spec.datastructures.blobs.versions.deneb.BlobSidecarOld; import tech.pegasys.teku.spec.datastructures.blobs.versions.deneb.BlobSidecarSchema; import tech.pegasys.teku.spec.datastructures.blobs.versions.deneb.BlobSidecarSchemaOld; -import tech.pegasys.teku.spec.datastructures.blobs.versions.deneb.SignedBlobSidecarOld; -import tech.pegasys.teku.spec.datastructures.blobs.versions.deneb.SignedBlobSidecarSchemaOld; import tech.pegasys.teku.spec.datastructures.blocks.BeaconBlock; import tech.pegasys.teku.spec.datastructures.blocks.BeaconBlockAndState; import tech.pegasys.teku.spec.datastructures.blocks.BeaconBlockHeader; @@ -2129,16 +2127,6 @@ public List randomBlobSidecarsForBlockOld( final SignedBeaconBlock block, final BiFunction modifier) { - return randomSignedBlobSidecarsForBlock(block, modifier).stream() - .map(SignedBlobSidecarOld::getBlobSidecar) - .collect(toList()); - } - - @Deprecated - public List randomSignedBlobSidecarsForBlock( - final SignedBeaconBlock block, - final BiFunction - modifier) { final SszList blobKzgCommitments = BeaconBlockBodyDeneb.required(block.getBeaconBlock().orElseThrow().getBody()) .getBlobKzgCommitments(); @@ -2155,7 +2143,7 @@ public List randomSignedBlobSidecarsForBlock( .kzgCommitment(blobKzgCommitments.get(index).getBytes()) .index(UInt64.valueOf(index)); - return modifier.apply(index, builder).buildSigned(); + return modifier.apply(index, builder).build(); }) .collect(toList()); } @@ -2191,10 +2179,12 @@ public BlobSidecar randomBlobSidecar() { return new RandomBlobSidecarBuilder().build(); } + @Deprecated public BlobSidecarOld randomBlobSidecarOld() { return new RandomBlobSidecarOldBuilder().build(); } + @Deprecated public BlobSidecarOld randomBlobSidecarOld(final BlobIdentifier blobIdentifier) { return new RandomBlobSidecarOldBuilder() .index(blobIdentifier.getIndex()) @@ -2202,6 +2192,7 @@ public BlobSidecarOld randomBlobSidecarOld(final BlobIdentifier blobIdentifier) .build(); } + @Deprecated public List randomBlobSidecarsOld(final int count) { List blobSidecars = new ArrayList<>(); for (int i = 0; i < count; i++) { @@ -2227,11 +2218,13 @@ public List randomBlobSidecars(final int count) { return blobSidecars; } + @Deprecated public BlobSidecarOld randomBlobSidecarOld( final UInt64 slot, final Bytes32 blockRoot, final UInt64 index) { return new RandomBlobSidecarOldBuilder().slot(slot).index(index).blockRoot(blockRoot).build(); } + @Deprecated public BlobSidecarOld randomBlobSidecarOld( final UInt64 slot, final Bytes32 blockRoot, @@ -2245,10 +2238,6 @@ public BlobSidecarOld randomBlobSidecarOld( .build(); } - public BlobSidecarOld randomBlobSidecarOld(final Bytes32 blockRoot, final UInt64 index) { - return new RandomBlobSidecarOldBuilder().index(index).blockRoot(blockRoot).build(); - } - public BlobIdentifier randomBlobIdentifier() { return randomBlobIdentifier(randomBytes32()); } @@ -2302,18 +2291,6 @@ private BlobsBundle randomBlobsBundle(final Optional count, final UInt6 .collect(toList())); } - public SignedBlobSidecarOld randomSignedBlobSidecar() { - return new RandomBlobSidecarOldBuilder().buildSigned(); - } - - public List randomSignedBlobSidecars(final int count) { - final List signedBlobSidecars = new ArrayList<>(); - for (int i = 0; i < count; i++) { - signedBlobSidecars.add(new RandomBlobSidecarOldBuilder().buildSigned()); - } - return signedBlobSidecars; - } - public SignedBlockContents randomSignedBlockContents() { return randomSignedBlockContents(randomSlot()); } @@ -2342,6 +2319,7 @@ public BlockContents randomBlockContents(final UInt64 slot) { .create(beaconBlock, kzgProofs, blobs); } + @Deprecated public RandomBlobSidecarOldBuilder createRandomBlobSidecarBuilderOld() { return new RandomBlobSidecarOldBuilder(); } @@ -2446,18 +2424,6 @@ public BlobSidecarOld build() { kzgCommitment.orElse(randomBytes48()), kzgProof.orElse(randomBytes48())); } - - public SignedBlobSidecarOld buildSigned(final Optional blsSignature) { - BlobSidecarOld blobSidecar = build(); - final SignedBlobSidecarSchemaOld blobSidecarSchema = - getDenebSchemaDefinitions(slot.orElse(randomUInt64())).getSignedBlobSidecarOldSchema(); - - return blobSidecarSchema.create(blobSidecar, blsSignature.orElse(randomSignature())); - } - - public SignedBlobSidecarOld buildSigned() { - return buildSigned(Optional.empty()); - } } public class RandomBlobSidecarBuilder {