From d55c73dbe1e58b6bfe8659d3575ea4f4e19c5503 Mon Sep 17 00:00:00 2001 From: Stefan Bratanov Date: Tue, 25 Jun 2024 13:48:01 +0100 Subject: [PATCH 1/2] Remove consolidations from electra block body (#8401) --- .../BlockOperationSelectorFactory.java | 10 --- .../BlockOperationSelectorFactoryTest.java | 78 ++--------------- .../beacon/schema/BeaconBlockBodyElectra.json | 8 +- .../schema/BlindedBlockBodyElectra.json | 8 +- .../beacon/schema/Consolidation.json | 25 ------ .../beacon/schema/SignedConsolidation.json | 16 ---- .../v3/newBlindedBlockELECTRA.json | 3 +- .../v3/newBlockContentsELECTRA.json | 3 +- .../electra/BeaconBlockBodyElectra.java | 18 +--- .../BlindedBeaconBlockBodyElectra.java | 20 +---- .../api/schema/electra/Consolidation.java | 66 -------------- .../schema/electra/SignedConsolidation.java | 59 ------------- .../phase0/ssz_static/SszTestExecutor.java | 14 ++- .../electra/signedBlindedBeaconBlock.json | 3 +- .../blockbody/BeaconBlockBodyBuilder.java | 7 -- .../BeaconBlockBodyBuilderElectra.java | 25 +----- .../electra/BeaconBlockBodyElectra.java | 4 - .../electra/BeaconBlockBodyElectraImpl.java | 19 ++-- .../electra/BeaconBlockBodySchemaElectra.java | 4 - .../BeaconBlockBodySchemaElectraImpl.java | 28 ++---- .../BlindedBeaconBlockBodyElectra.java | 4 - .../BlindedBeaconBlockBodyElectraImpl.java | 19 ++-- .../BlindedBeaconBlockBodySchemaElectra.java | 4 - ...indedBeaconBlockBodySchemaElectraImpl.java | 28 ++---- .../phase0/BeaconBlockBodyBuilderPhase0.java | 7 -- .../consolidations/Consolidation.java | 87 ------------------- .../consolidations/SignedConsolidation.java | 68 --------------- .../ExecutionLayerChannelStub.java | 3 +- .../OperationSignatureVerifier.java | 22 ----- .../schemas/SchemaDefinitionsElectra.java | 14 --- .../ConsolidationRequestPropertyTest.java | 41 +++++++++ .../spec/generator/BlockProposalTestUtil.java | 6 -- .../electra/ConsolidationRequestSupplier.java | 26 ++++++ .../teku/spec/util/DataStructureUtil.java | 26 ------ .../util/DebugDataFileDumper.java | 4 + .../newBlindedBlockELECTRA.json | 3 +- .../newBlockContentsELECTRA.json | 3 +- 37 files changed, 116 insertions(+), 667 deletions(-) delete mode 100644 data/beaconrestapi/src/integration-test/resources/tech/pegasys/teku/beaconrestapi/beacon/schema/Consolidation.json delete mode 100644 data/beaconrestapi/src/integration-test/resources/tech/pegasys/teku/beaconrestapi/beacon/schema/SignedConsolidation.json delete mode 100644 data/serializer/src/main/java/tech/pegasys/teku/api/schema/electra/Consolidation.java delete mode 100644 data/serializer/src/main/java/tech/pegasys/teku/api/schema/electra/SignedConsolidation.java delete mode 100644 ethereum/spec/src/main/java/tech/pegasys/teku/spec/datastructures/consolidations/Consolidation.java delete mode 100644 ethereum/spec/src/main/java/tech/pegasys/teku/spec/datastructures/consolidations/SignedConsolidation.java create mode 100644 ethereum/spec/src/property-test/java/tech/pegasys/teku/spec/datastructures/execution/versions/electra/ConsolidationRequestPropertyTest.java create mode 100644 ethereum/spec/src/testFixtures/java/tech/pegasys/teku/spec/propertytest/suppliers/execution/versions/electra/ConsolidationRequestSupplier.java diff --git a/beacon/validator/src/main/java/tech/pegasys/teku/validator/coordinator/BlockOperationSelectorFactory.java b/beacon/validator/src/main/java/tech/pegasys/teku/validator/coordinator/BlockOperationSelectorFactory.java index 39e4c10e3b8..fdb577f54c4 100644 --- a/beacon/validator/src/main/java/tech/pegasys/teku/validator/coordinator/BlockOperationSelectorFactory.java +++ b/beacon/validator/src/main/java/tech/pegasys/teku/validator/coordinator/BlockOperationSelectorFactory.java @@ -63,7 +63,6 @@ import tech.pegasys.teku.spec.schemas.SchemaDefinitions; import tech.pegasys.teku.spec.schemas.SchemaDefinitionsBellatrix; import tech.pegasys.teku.spec.schemas.SchemaDefinitionsDeneb; -import tech.pegasys.teku.spec.schemas.SchemaDefinitionsElectra; import tech.pegasys.teku.statetransition.OperationPool; import tech.pegasys.teku.statetransition.attestation.AggregatingAttestationPool; import tech.pegasys.teku.statetransition.attestation.AttestationForkChecker; @@ -177,15 +176,6 @@ public Function> createSelector( final SchemaDefinitions schemaDefinitions = spec.atSlot(blockSlotState.getSlot()).getSchemaDefinitions(); - // Post-Electra: Consolidations - if (bodyBuilder.supportsConsolidations()) { - // devnet-0 blocks are empty of consolidations, so just default their list. - bodyBuilder.consolidations( - SchemaDefinitionsElectra.required(schemaDefinitions) - .getConsolidationsSchema() - .createFromElements(List.of())); - } - final SafeFuture blockProductionComplete; // In `setExecutionData` the following fields are set: diff --git a/beacon/validator/src/test/java/tech/pegasys/teku/validator/coordinator/BlockOperationSelectorFactoryTest.java b/beacon/validator/src/test/java/tech/pegasys/teku/validator/coordinator/BlockOperationSelectorFactoryTest.java index f0c4d75deed..548d254130b 100644 --- a/beacon/validator/src/test/java/tech/pegasys/teku/validator/coordinator/BlockOperationSelectorFactoryTest.java +++ b/beacon/validator/src/test/java/tech/pegasys/teku/validator/coordinator/BlockOperationSelectorFactoryTest.java @@ -58,7 +58,6 @@ import tech.pegasys.teku.spec.datastructures.blocks.versions.deneb.SignedBlockContents; import tech.pegasys.teku.spec.datastructures.builder.BuilderBid; import tech.pegasys.teku.spec.datastructures.builder.BuilderPayload; -import tech.pegasys.teku.spec.datastructures.consolidations.SignedConsolidation; import tech.pegasys.teku.spec.datastructures.execution.BlobsBundle; import tech.pegasys.teku.spec.datastructures.execution.BuilderBidOrFallbackData; import tech.pegasys.teku.spec.datastructures.execution.BuilderPayloadOrFallbackData; @@ -102,7 +101,6 @@ class BlockOperationSelectorFactoryTest { private final Spec spec = TestSpecFactory.createMinimalDeneb(); private final Spec specBellatrix = TestSpecFactory.createMinimalBellatrix(); - final Spec specElectra = TestSpecFactory.createMinimalElectra(); private final DataStructureUtil dataStructureUtil = new DataStructureUtil(spec); private final Function> beaconBlockSchemaSupplier = @@ -183,25 +181,11 @@ class BlockOperationSelectorFactoryTest { .getHeaderOfDefaultPayload(); private final CapturingBeaconBlockBodyBuilder bodyBuilder = - new CapturingBeaconBlockBodyBuilder(false, false); + new CapturingBeaconBlockBodyBuilder(false); private final GraffitiBuilder graffitiBuilder = new GraffitiBuilder(ClientGraffitiAppendFormat.DISABLED); - private final BlockOperationSelectorFactory factoryElectra = - new BlockOperationSelectorFactory( - specElectra, - attestationPool, - attesterSlashingPool, - proposerSlashingPool, - voluntaryExitPool, - blsToExecutionChangePool, - contributionPool, - depositProvider, - eth1DataCache, - graffitiBuilder, - forkChoiceNotifier, - executionLayer); private final BlockOperationSelectorFactory factory = new BlockOperationSelectorFactory( spec, @@ -637,8 +621,7 @@ void shouldIncludeExecutionPayloadIfRequestedBlindedIsEmptyAndBuilderFlowFallsBa final UInt256 blockExecutionValue = dataStructureUtil.randomUInt256(); - final CapturingBeaconBlockBodyBuilder bodyBuilder = - new CapturingBeaconBlockBodyBuilder(true, false); + final CapturingBeaconBlockBodyBuilder bodyBuilder = new CapturingBeaconBlockBodyBuilder(true); when(forkChoiceNotifier.getPayloadId(any(), any())) .thenReturn(SafeFuture.completedFuture(Optional.of(executionPayloadContext))); @@ -712,8 +695,7 @@ void shouldIncludeKzgCommitmentsInBlock() { blobsBundle, blockExecutionValue); - final CapturingBeaconBlockBodyBuilder bodyBuilder = - new CapturingBeaconBlockBodyBuilder(true, false); + final CapturingBeaconBlockBodyBuilder bodyBuilder = new CapturingBeaconBlockBodyBuilder(true); safeJoin( factory @@ -735,37 +717,6 @@ void shouldIncludeKzgCommitmentsInBlock() { .hasSameElementsAs(blobsBundle.getCommitments()); } - @Test - void shouldIncludeConsolidationsInBlock() { - final BeaconState blockSlotState = dataStructureUtil.randomBeaconState(); - final ExecutionPayload randomExecutionPayload = dataStructureUtil.randomExecutionPayload(); - final UInt256 blockExecutionValue = dataStructureUtil.randomUInt256(); - final BlobsBundle blobsBundle = dataStructureUtil.randomBlobsBundle(); - - prepareBlockAndBlobsProduction( - randomExecutionPayload, - executionPayloadContext, - blockSlotState, - blobsBundle, - blockExecutionValue); - - final CapturingBeaconBlockBodyBuilder bodyBuilder = - new CapturingBeaconBlockBodyBuilder(true, true); - safeJoin( - factoryElectra - .createSelector( - parentRoot, - blockSlotState, - dataStructureUtil.randomSignature(), - Optional.empty(), - Optional.of(false), - Optional.empty(), - BlockProductionPerformance.NOOP) - .apply(bodyBuilder)); - - assertThat(bodyBuilder.consolidations).isEmpty(); - } - @Test void shouldIncludeKzgCommitmentsInBlindedBlock() { final BeaconState blockSlotState = dataStructureUtil.randomBeaconState(); @@ -785,8 +736,7 @@ void shouldIncludeKzgCommitmentsInBlindedBlock() { blobKzgCommitments, blockExecutionValue); - final CapturingBeaconBlockBodyBuilder bodyBuilder = - new CapturingBeaconBlockBodyBuilder(true, false); + final CapturingBeaconBlockBodyBuilder bodyBuilder = new CapturingBeaconBlockBodyBuilder(true); safeJoin( factory @@ -1229,7 +1179,6 @@ private void prepareCachedFallbackData( private static class CapturingBeaconBlockBodyBuilder implements BeaconBlockBodyBuilder { private final boolean supportsKzgCommitments; - private final boolean supportsConsolidations; protected BLSSignature randaoReveal; protected Bytes32 graffiti; @@ -1242,13 +1191,8 @@ private static class CapturingBeaconBlockBodyBuilder implements BeaconBlockBodyB protected ExecutionPayloadHeader executionPayloadHeader; protected SszList blobKzgCommitments; - @SuppressWarnings("unused") - protected SszList consolidations; - - public CapturingBeaconBlockBodyBuilder( - final boolean supportsKzgCommitments, final boolean supportsConsolidations) { + public CapturingBeaconBlockBodyBuilder(final boolean supportsKzgCommitments) { this.supportsKzgCommitments = supportsKzgCommitments; - this.supportsConsolidations = supportsConsolidations; } @Override @@ -1345,11 +1289,6 @@ public Boolean supportsKzgCommitments() { return supportsKzgCommitments; } - @Override - public Boolean supportsConsolidations() { - return supportsConsolidations; - } - @Override public BeaconBlockBodyBuilder blobKzgCommitments( final SszList blobKzgCommitments) { @@ -1357,13 +1296,6 @@ public BeaconBlockBodyBuilder blobKzgCommitments( return this; } - @Override - public BeaconBlockBodyBuilder consolidations( - final SszList consolidations) { - this.consolidations = consolidations; - return this; - } - @Override public BeaconBlockBody build() { return null; diff --git a/data/beaconrestapi/src/integration-test/resources/tech/pegasys/teku/beaconrestapi/beacon/schema/BeaconBlockBodyElectra.json b/data/beaconrestapi/src/integration-test/resources/tech/pegasys/teku/beaconrestapi/beacon/schema/BeaconBlockBodyElectra.json index 1679f9eb138..103710357b8 100644 --- a/data/beaconrestapi/src/integration-test/resources/tech/pegasys/teku/beaconrestapi/beacon/schema/BeaconBlockBodyElectra.json +++ b/data/beaconrestapi/src/integration-test/resources/tech/pegasys/teku/beaconrestapi/beacon/schema/BeaconBlockBodyElectra.json @@ -1,7 +1,7 @@ { "title" : "BeaconBlockBodyElectra", "type" : "object", - "required" : [ "randao_reveal", "eth1_data", "graffiti", "proposer_slashings", "attester_slashings", "attestations", "deposits", "voluntary_exits", "sync_aggregate", "execution_payload", "bls_to_execution_changes", "blob_kzg_commitments", "consolidations" ], + "required" : [ "randao_reveal", "eth1_data", "graffiti", "proposer_slashings", "attester_slashings", "attestations", "deposits", "voluntary_exits", "sync_aggregate", "execution_payload", "bls_to_execution_changes", "blob_kzg_commitments" ], "properties" : { "randao_reveal" : { "type" : "string", @@ -68,12 +68,6 @@ "description" : "Bytes48 hexadecimal", "format" : "bytes" } - }, - "consolidations" : { - "type" : "array", - "items" : { - "$ref" : "#/components/schemas/SignedConsolidation" - } } } } \ No newline at end of file diff --git a/data/beaconrestapi/src/integration-test/resources/tech/pegasys/teku/beaconrestapi/beacon/schema/BlindedBlockBodyElectra.json b/data/beaconrestapi/src/integration-test/resources/tech/pegasys/teku/beaconrestapi/beacon/schema/BlindedBlockBodyElectra.json index b1100a891b4..1576186b3ba 100644 --- a/data/beaconrestapi/src/integration-test/resources/tech/pegasys/teku/beaconrestapi/beacon/schema/BlindedBlockBodyElectra.json +++ b/data/beaconrestapi/src/integration-test/resources/tech/pegasys/teku/beaconrestapi/beacon/schema/BlindedBlockBodyElectra.json @@ -1,7 +1,7 @@ { "title" : "BlindedBlockBodyElectra", "type" : "object", - "required" : [ "randao_reveal", "eth1_data", "graffiti", "proposer_slashings", "attester_slashings", "attestations", "deposits", "voluntary_exits", "sync_aggregate", "execution_payload_header", "bls_to_execution_changes", "blob_kzg_commitments", "consolidations" ], + "required" : [ "randao_reveal", "eth1_data", "graffiti", "proposer_slashings", "attester_slashings", "attestations", "deposits", "voluntary_exits", "sync_aggregate", "execution_payload_header", "bls_to_execution_changes", "blob_kzg_commitments" ], "properties" : { "randao_reveal" : { "type" : "string", @@ -68,12 +68,6 @@ "description" : "Bytes48 hexadecimal", "format" : "bytes" } - }, - "consolidations" : { - "type" : "array", - "items" : { - "$ref" : "#/components/schemas/SignedConsolidation" - } } } } \ No newline at end of file diff --git a/data/beaconrestapi/src/integration-test/resources/tech/pegasys/teku/beaconrestapi/beacon/schema/Consolidation.json b/data/beaconrestapi/src/integration-test/resources/tech/pegasys/teku/beaconrestapi/beacon/schema/Consolidation.json deleted file mode 100644 index 0aae8241507..00000000000 --- a/data/beaconrestapi/src/integration-test/resources/tech/pegasys/teku/beaconrestapi/beacon/schema/Consolidation.json +++ /dev/null @@ -1,25 +0,0 @@ -{ - "title" : "Consolidation", - "type" : "object", - "required" : [ "source_index", "target_index", "epoch" ], - "properties" : { - "source_index" : { - "type" : "string", - "description" : "unsigned 64 bit integer", - "example" : "1", - "format" : "uint64" - }, - "target_index" : { - "type" : "string", - "description" : "unsigned 64 bit integer", - "example" : "1", - "format" : "uint64" - }, - "epoch" : { - "type" : "string", - "description" : "unsigned 64 bit integer", - "example" : "1", - "format" : "uint64" - } - } -} \ No newline at end of file diff --git a/data/beaconrestapi/src/integration-test/resources/tech/pegasys/teku/beaconrestapi/beacon/schema/SignedConsolidation.json b/data/beaconrestapi/src/integration-test/resources/tech/pegasys/teku/beaconrestapi/beacon/schema/SignedConsolidation.json deleted file mode 100644 index 55df4a81974..00000000000 --- a/data/beaconrestapi/src/integration-test/resources/tech/pegasys/teku/beaconrestapi/beacon/schema/SignedConsolidation.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "title" : "SignedConsolidation", - "type" : "object", - "required" : [ "message", "signature" ], - "properties" : { - "message" : { - "$ref" : "#/components/schemas/Consolidation" - }, - "signature" : { - "type" : "string", - "pattern" : "^0x[a-fA-F0-9]{2,}$", - "description" : "SSZ hexadecimal", - "format" : "bytes" - } - } -} \ No newline at end of file diff --git a/data/beaconrestapi/src/integration-test/resources/tech/pegasys/teku/beaconrestapi/v3/newBlindedBlockELECTRA.json b/data/beaconrestapi/src/integration-test/resources/tech/pegasys/teku/beaconrestapi/v3/newBlindedBlockELECTRA.json index f1a5516ea20..307412bbaf6 100644 --- a/data/beaconrestapi/src/integration-test/resources/tech/pegasys/teku/beaconrestapi/v3/newBlindedBlockELECTRA.json +++ b/data/beaconrestapi/src/integration-test/resources/tech/pegasys/teku/beaconrestapi/v3/newBlindedBlockELECTRA.json @@ -358,8 +358,7 @@ "0x49f540426ff48680416a1a43b562d4c24d9e1b5012cefb1979a3c9c1b8fbd42b8517c05e35b3e879984ec65a9ddb52af", "0xa99a23428f6ee3d80bb91e1cd80e3bc46cad162aa2b9c7bc5e291babfcdf69e17bb59e3819984a1ffcc715b881c2452f", "0xbcbb1d422fbac21d01fc8547ab974f9172b015bc5882f0768caa5e73d640216c13d5649714f92a0d43e05864498aa915" - ], - "consolidations": [] + ] } } } \ No newline at end of file diff --git a/data/beaconrestapi/src/integration-test/resources/tech/pegasys/teku/beaconrestapi/v3/newBlockContentsELECTRA.json b/data/beaconrestapi/src/integration-test/resources/tech/pegasys/teku/beaconrestapi/v3/newBlockContentsELECTRA.json index b175a7af310..073b43197fa 100644 --- a/data/beaconrestapi/src/integration-test/resources/tech/pegasys/teku/beaconrestapi/v3/newBlockContentsELECTRA.json +++ b/data/beaconrestapi/src/integration-test/resources/tech/pegasys/teku/beaconrestapi/v3/newBlockContentsELECTRA.json @@ -399,8 +399,7 @@ "0xa250734616e5e744f48c493c6d932629d574d0f2b953d406c14b88999cbfbe0227821f9f2e60836eaef3cf363a0cfffd", "0xb5716d46b630c789e9cfb067411c3bf6db77cf84701cfdc0efcccb617720768dbea1e5fd28c1635cf50b13e301d462e4", "0x7c0e7f46d64d29bb09077be5c681fd8ec96ed2ce4dc2829266490109e8fd4fedf74293e1399ec2921fc349deac7c3731" - ], - "consolidations": [] + ] } }, "kzg_proofs": [ diff --git a/data/serializer/src/main/java/tech/pegasys/teku/api/schema/electra/BeaconBlockBodyElectra.java b/data/serializer/src/main/java/tech/pegasys/teku/api/schema/electra/BeaconBlockBodyElectra.java index 21252e07f9a..9926c2b0c98 100644 --- a/data/serializer/src/main/java/tech/pegasys/teku/api/schema/electra/BeaconBlockBodyElectra.java +++ b/data/serializer/src/main/java/tech/pegasys/teku/api/schema/electra/BeaconBlockBodyElectra.java @@ -18,7 +18,6 @@ import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonProperty; import java.util.List; -import java.util.stream.Collectors; import org.apache.tuweni.bytes.Bytes32; import tech.pegasys.teku.api.schema.Attestation; import tech.pegasys.teku.api.schema.AttesterSlashing; @@ -49,9 +48,6 @@ public class BeaconBlockBodyElectra extends BeaconBlockBodyAltair { @JsonProperty("blob_kzg_commitments") public final List blobKZGCommitments; - @JsonProperty("consolidations") - public final List consolidations; - @JsonCreator public BeaconBlockBodyElectra( @JsonProperty("randao_reveal") final BLSSignature randaoReveal, @@ -66,8 +62,7 @@ public BeaconBlockBodyElectra( @JsonProperty("execution_payload") final ExecutionPayloadElectra executionPayload, @JsonProperty("bls_to_execution_changes") final List blsToExecutionChanges, - @JsonProperty("blob_kzg_commitments") final List blobKZGCommitments, - @JsonProperty("consolidations") final List consolidations) { + @JsonProperty("blob_kzg_commitments") final List blobKZGCommitments) { super( randaoReveal, eth1Data, @@ -84,7 +79,6 @@ public BeaconBlockBodyElectra( this.blsToExecutionChanges = blsToExecutionChanges; checkNotNull(blobKZGCommitments, "blobKZGCommitments is required for Electra blocks"); this.blobKZGCommitments = blobKZGCommitments; - this.consolidations = consolidations; } public BeaconBlockBodyElectra( @@ -106,10 +100,6 @@ public BeaconBlockBodyElectra( .map(SszKZGCommitment::getKZGCommitment) .map(KZGCommitment::new) .toList(); - this.consolidations = - message.getConsolidations().stream() - .map(SignedConsolidation::new) - .collect(Collectors.toList()); } @Override @@ -125,8 +115,6 @@ public BeaconBlockBody asInternalBeaconBlockBody(final SpecVersion spec) { getBeaconBlockBodySchema(spec).getBlsToExecutionChangesSchema(); final SszListSchema blobKZGCommitmentsSchema = getBeaconBlockBodySchema(spec).getBlobKzgCommitmentsSchema(); - final SszListSchema - signedConsolidationSchema = getBeaconBlockBodySchema(spec).getConsolidationsSchema(); return super.asInternalBeaconBlockBody( spec, builder -> { @@ -140,10 +128,6 @@ public BeaconBlockBody asInternalBeaconBlockBody(final SpecVersion spec) { .map(KZGCommitment::asInternalKZGCommitment) .map(SszKZGCommitment::new) .collect(blobKZGCommitmentsSchema.collector())); - builder.consolidations( - this.consolidations.stream() - .map(b -> b.asInternalSignedConsolidation(spec)) - .collect(signedConsolidationSchema.collector())); return SafeFuture.COMPLETE; }); } diff --git a/data/serializer/src/main/java/tech/pegasys/teku/api/schema/electra/BlindedBeaconBlockBodyElectra.java b/data/serializer/src/main/java/tech/pegasys/teku/api/schema/electra/BlindedBeaconBlockBodyElectra.java index be785bf2e9e..90a70dbd21b 100644 --- a/data/serializer/src/main/java/tech/pegasys/teku/api/schema/electra/BlindedBeaconBlockBodyElectra.java +++ b/data/serializer/src/main/java/tech/pegasys/teku/api/schema/electra/BlindedBeaconBlockBodyElectra.java @@ -18,7 +18,6 @@ import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonProperty; import java.util.List; -import java.util.stream.Collectors; import org.apache.tuweni.bytes.Bytes32; import tech.pegasys.teku.api.schema.Attestation; import tech.pegasys.teku.api.schema.AttesterSlashing; @@ -50,9 +49,6 @@ public class BlindedBeaconBlockBodyElectra extends BeaconBlockBodyAltair { @JsonProperty("blob_kzg_commitments") public final List blobKZGCommitments; - @JsonProperty("consolidations") - public final List consolidations; - @JsonCreator public BlindedBeaconBlockBodyElectra( @JsonProperty("randao_reveal") final BLSSignature randaoReveal, @@ -68,8 +64,7 @@ public BlindedBeaconBlockBodyElectra( final ExecutionPayloadHeaderElectra executionPayloadHeader, @JsonProperty("bls_to_execution_changes") final List blsToExecutionChanges, - @JsonProperty("blob_kzg_commitments") final List blobKZGCommitments, - @JsonProperty("consolidations") final List consolidations) { + @JsonProperty("blob_kzg_commitments") final List blobKZGCommitments) { super( randaoReveal, eth1Data, @@ -88,8 +83,6 @@ public BlindedBeaconBlockBodyElectra( this.blsToExecutionChanges = blsToExecutionChanges; checkNotNull(blobKZGCommitments, "blobKZGCommitments is required for Electra blinded blocks"); this.blobKZGCommitments = blobKZGCommitments; - - this.consolidations = consolidations; } public BlindedBeaconBlockBodyElectra( @@ -106,10 +99,6 @@ public BlindedBeaconBlockBodyElectra( .map(SszKZGCommitment::getKZGCommitment) .map(KZGCommitment::new) .toList(); - this.consolidations = - blockBody.getConsolidations().stream() - .map(SignedConsolidation::new) - .collect(Collectors.toList()); } @Override @@ -136,9 +125,6 @@ public BeaconBlockBody asInternalBeaconBlockBody(final SpecVersion spec) { final SszListSchema blobKZGCommitmentsSchema = getBeaconBlockBodySchema(spec).getBlobKzgCommitmentsSchema(); - final SszListSchema - signedConsolidationSchema = getBeaconBlockBodySchema(spec).getConsolidationsSchema(); - return super.asInternalBeaconBlockBody( spec, builder -> { @@ -154,10 +140,6 @@ public BeaconBlockBody asInternalBeaconBlockBody(final SpecVersion spec) { .map(KZGCommitment::asInternalKZGCommitment) .map(SszKZGCommitment::new) .collect(blobKZGCommitmentsSchema.collector())); - builder.consolidations( - this.consolidations.stream() - .map(b -> b.asInternalSignedConsolidation(spec)) - .collect(signedConsolidationSchema.collector())); return SafeFuture.COMPLETE; }); } diff --git a/data/serializer/src/main/java/tech/pegasys/teku/api/schema/electra/Consolidation.java b/data/serializer/src/main/java/tech/pegasys/teku/api/schema/electra/Consolidation.java deleted file mode 100644 index 34f8362a269..00000000000 --- a/data/serializer/src/main/java/tech/pegasys/teku/api/schema/electra/Consolidation.java +++ /dev/null @@ -1,66 +0,0 @@ -/* - * Copyright Consensys Software Inc., 2024 - * - * 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.api.schema.electra; - -import com.fasterxml.jackson.annotation.JsonProperty; -import java.util.Optional; -import tech.pegasys.teku.infrastructure.ssz.primitive.SszUInt64; -import tech.pegasys.teku.infrastructure.unsigned.UInt64; -import tech.pegasys.teku.spec.SpecVersion; -import tech.pegasys.teku.spec.schemas.SchemaDefinitionsElectra; - -public class Consolidation { - @JsonProperty("source_index") - public final int sourceIndex; - - @JsonProperty("target_index") - public final int targetIndex; - - @JsonProperty("epoch") - public final UInt64 epoch; - - public Consolidation( - @JsonProperty("source_index") final int sourceIndex, - @JsonProperty("target_index") final int targetIndex, - @JsonProperty("epoch") final UInt64 epoch) { - this.sourceIndex = sourceIndex; - this.targetIndex = targetIndex; - this.epoch = epoch; - } - - public Consolidation( - final tech.pegasys.teku.spec.datastructures.consolidations.Consolidation - internalConsolidation) { - this.sourceIndex = internalConsolidation.getSourceIndex(); - this.targetIndex = internalConsolidation.getTargetIndex(); - this.epoch = internalConsolidation.getEpoch(); - } - - public tech.pegasys.teku.spec.datastructures.consolidations.Consolidation asInternalConsolidation( - final SpecVersion spec) { - final Optional schemaDefinitionsElectra = - spec.getSchemaDefinitions().toVersionElectra(); - if (schemaDefinitionsElectra.isEmpty()) { - throw new IllegalArgumentException( - "Could not create PendingConsolidation for pre-electra spec"); - } - return schemaDefinitionsElectra - .get() - .getConsolidationSchema() - .create( - SszUInt64.of(UInt64.valueOf(this.sourceIndex)), - SszUInt64.of(UInt64.valueOf(this.targetIndex)), - SszUInt64.of(epoch)); - } -} diff --git a/data/serializer/src/main/java/tech/pegasys/teku/api/schema/electra/SignedConsolidation.java b/data/serializer/src/main/java/tech/pegasys/teku/api/schema/electra/SignedConsolidation.java deleted file mode 100644 index 36c61191a06..00000000000 --- a/data/serializer/src/main/java/tech/pegasys/teku/api/schema/electra/SignedConsolidation.java +++ /dev/null @@ -1,59 +0,0 @@ -/* - * Copyright Consensys Software Inc., 2024 - * - * 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.api.schema.electra; - -import static tech.pegasys.teku.api.schema.SchemaConstants.DESCRIPTION_BYTES96; - -import com.fasterxml.jackson.annotation.JsonProperty; -import io.swagger.v3.oas.annotations.media.Schema; -import java.util.Optional; -import tech.pegasys.teku.api.schema.BLSSignature; -import tech.pegasys.teku.spec.SpecVersion; -import tech.pegasys.teku.spec.schemas.SchemaDefinitionsElectra; - -public class SignedConsolidation { - @JsonProperty("message") - public final Consolidation message; - - @Schema(type = "string", format = "byte", description = DESCRIPTION_BYTES96) - public final BLSSignature signature; - - public SignedConsolidation( - @JsonProperty("message") final Consolidation message, - @JsonProperty("signature") final BLSSignature signature) { - this.message = message; - this.signature = signature; - } - - public SignedConsolidation( - final tech.pegasys.teku.spec.datastructures.consolidations.SignedConsolidation - internalConsolidation) { - this.message = new Consolidation(internalConsolidation.getMessage()); - this.signature = new BLSSignature(internalConsolidation.getSignature()); - } - - public tech.pegasys.teku.spec.datastructures.consolidations.SignedConsolidation - asInternalSignedConsolidation(final SpecVersion spec) { - final Optional schemaDefinitionsElectra = - spec.getSchemaDefinitions().toVersionElectra(); - if (schemaDefinitionsElectra.isEmpty()) { - throw new IllegalArgumentException( - "Could not create PendingConsolidation for pre-electra spec"); - } - return schemaDefinitionsElectra - .get() - .getSignedConsolidationSchema() - .create(message.asInternalConsolidation(spec), signature.asInternalBLSSignature()); - } -} 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 a46fa465dba..4d8eb4cecae 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 @@ -186,10 +186,6 @@ public class SszTestExecutor implements TestExecutor { new SszTestExecutor<>(schemas -> BlobIdentifier.SSZ_SCHEMA)) // Electra types - .put( - "ssz_static/Consolidation", - new SszTestExecutor<>( - schemas -> SchemaDefinitionsElectra.required(schemas).getConsolidationSchema())) .put( "ssz_static/DepositRequest", new SszTestExecutor<>( @@ -199,6 +195,11 @@ public class SszTestExecutor implements TestExecutor { new SszTestExecutor<>( schemas -> SchemaDefinitionsElectra.required(schemas).getWithdrawalRequestSchema())) + .put( + "ssz_static/ConsolidationRequest", + new SszTestExecutor<>( + schemas -> + SchemaDefinitionsElectra.required(schemas).getConsolidationRequestSchema())) .put( "ssz_static/PendingBalanceDeposit", new SszTestExecutor<>( @@ -215,11 +216,6 @@ public class SszTestExecutor implements TestExecutor { schemas -> SchemaDefinitionsElectra.required(schemas) .getPendingPartialWithdrawalSchema())) - .put( - "ssz_static/SignedConsolidation", - new SszTestExecutor<>( - schemas -> - SchemaDefinitionsElectra.required(schemas).getSignedConsolidationSchema())) // Legacy Schemas (Not yet migrated to SchemaDefinitions) .put( diff --git a/ethereum/executionclient/src/integration-test/resources/builder/electra/signedBlindedBeaconBlock.json b/ethereum/executionclient/src/integration-test/resources/builder/electra/signedBlindedBeaconBlock.json index cb83c875aca..c9f237cff2c 100644 --- a/ethereum/executionclient/src/integration-test/resources/builder/electra/signedBlindedBeaconBlock.json +++ b/ethereum/executionclient/src/integration-test/resources/builder/electra/signedBlindedBeaconBlock.json @@ -350,8 +350,7 @@ ], "blob_kzg_commitments": [ "0xa94170080872584e54a1cf092d845703b13907f2e6b3b1c0ad573b910530499e3bcd48c6378846b80d2bfa58c81cf3d5" - ], - "consolidations": [] + ] } }, "signature": "0xa208fa451f0cb280d1bad7212a5b619097885383a9fdf300b91b33e73fd360329161843794ad1c2c7e84a3f0826a4f181165840b29947d2e681005811ee84f4d222510b1287eb1d4de480ce50be7cb2eeb007bdb4ed6c23358fc03b225abc8a8" diff --git a/ethereum/spec/src/main/java/tech/pegasys/teku/spec/datastructures/blocks/blockbody/BeaconBlockBodyBuilder.java b/ethereum/spec/src/main/java/tech/pegasys/teku/spec/datastructures/blocks/blockbody/BeaconBlockBodyBuilder.java index 007fa39c1b4..abaf77057b9 100644 --- a/ethereum/spec/src/main/java/tech/pegasys/teku/spec/datastructures/blocks/blockbody/BeaconBlockBodyBuilder.java +++ b/ethereum/spec/src/main/java/tech/pegasys/teku/spec/datastructures/blocks/blockbody/BeaconBlockBodyBuilder.java @@ -18,7 +18,6 @@ import tech.pegasys.teku.infrastructure.ssz.SszList; import tech.pegasys.teku.spec.datastructures.blocks.Eth1Data; import tech.pegasys.teku.spec.datastructures.blocks.blockbody.versions.altair.SyncAggregate; -import tech.pegasys.teku.spec.datastructures.consolidations.SignedConsolidation; import tech.pegasys.teku.spec.datastructures.execution.ExecutionPayload; import tech.pegasys.teku.spec.datastructures.execution.ExecutionPayloadHeader; import tech.pegasys.teku.spec.datastructures.operations.Attestation; @@ -72,13 +71,7 @@ default Boolean supportsKzgCommitments() { return false; } - default Boolean supportsConsolidations() { - return false; - } - BeaconBlockBodyBuilder blobKzgCommitments(SszList blobKzgCommitments); - BeaconBlockBodyBuilder consolidations(SszList consolidations); - BeaconBlockBody build(); } diff --git a/ethereum/spec/src/main/java/tech/pegasys/teku/spec/datastructures/blocks/blockbody/versions/electra/BeaconBlockBodyBuilderElectra.java b/ethereum/spec/src/main/java/tech/pegasys/teku/spec/datastructures/blocks/blockbody/versions/electra/BeaconBlockBodyBuilderElectra.java index fd874c86ecc..8f1bf8d71fa 100644 --- a/ethereum/spec/src/main/java/tech/pegasys/teku/spec/datastructures/blocks/blockbody/versions/electra/BeaconBlockBodyBuilderElectra.java +++ b/ethereum/spec/src/main/java/tech/pegasys/teku/spec/datastructures/blocks/blockbody/versions/electra/BeaconBlockBodyBuilderElectra.java @@ -13,19 +13,15 @@ package tech.pegasys.teku.spec.datastructures.blocks.blockbody.versions.electra; -import tech.pegasys.teku.infrastructure.ssz.SszList; import tech.pegasys.teku.infrastructure.ssz.primitive.SszBytes32; import tech.pegasys.teku.spec.datastructures.blocks.blockbody.BeaconBlockBody; -import tech.pegasys.teku.spec.datastructures.blocks.blockbody.BeaconBlockBodyBuilder; import tech.pegasys.teku.spec.datastructures.blocks.blockbody.BeaconBlockBodySchema; import tech.pegasys.teku.spec.datastructures.blocks.blockbody.versions.deneb.BeaconBlockBodyBuilderDeneb; -import tech.pegasys.teku.spec.datastructures.consolidations.SignedConsolidation; import tech.pegasys.teku.spec.datastructures.execution.versions.electra.ExecutionPayloadElectraImpl; import tech.pegasys.teku.spec.datastructures.execution.versions.electra.ExecutionPayloadHeaderElectraImpl; import tech.pegasys.teku.spec.datastructures.type.SszSignature; public class BeaconBlockBodyBuilderElectra extends BeaconBlockBodyBuilderDeneb { - private SszList consolidations; public BeaconBlockBodyBuilderElectra( final BeaconBlockBodySchema schema, @@ -33,21 +29,6 @@ public BeaconBlockBodyBuilderElectra( super(schema, blindedSchema); } - protected SszList getConsolidations() { - return consolidations; - } - - @Override - public Boolean supportsConsolidations() { - return true; - } - - @Override - public BeaconBlockBodyBuilder consolidations(final SszList consolidations) { - this.consolidations = consolidations; - return this; - } - @Override protected void validate() { super.validate(); @@ -73,8 +54,7 @@ public BeaconBlockBody build() { (ExecutionPayloadHeaderElectraImpl) executionPayloadHeader.toVersionElectra().orElseThrow(), getBlsToExecutionChanges(), - getBlobKzgCommitments(), - getConsolidations()); + getBlobKzgCommitments()); } final BeaconBlockBodySchemaElectraImpl schema = @@ -92,7 +72,6 @@ public BeaconBlockBody build() { syncAggregate, (ExecutionPayloadElectraImpl) executionPayload.toVersionElectra().orElseThrow(), getBlsToExecutionChanges(), - getBlobKzgCommitments(), - getConsolidations()); + getBlobKzgCommitments()); } } diff --git a/ethereum/spec/src/main/java/tech/pegasys/teku/spec/datastructures/blocks/blockbody/versions/electra/BeaconBlockBodyElectra.java b/ethereum/spec/src/main/java/tech/pegasys/teku/spec/datastructures/blocks/blockbody/versions/electra/BeaconBlockBodyElectra.java index 3183ef133e4..85bac9bad45 100644 --- a/ethereum/spec/src/main/java/tech/pegasys/teku/spec/datastructures/blocks/blockbody/versions/electra/BeaconBlockBodyElectra.java +++ b/ethereum/spec/src/main/java/tech/pegasys/teku/spec/datastructures/blocks/blockbody/versions/electra/BeaconBlockBodyElectra.java @@ -14,10 +14,8 @@ package tech.pegasys.teku.spec.datastructures.blocks.blockbody.versions.electra; import java.util.Optional; -import tech.pegasys.teku.infrastructure.ssz.SszList; import tech.pegasys.teku.spec.datastructures.blocks.blockbody.BeaconBlockBody; import tech.pegasys.teku.spec.datastructures.blocks.blockbody.versions.deneb.BeaconBlockBodyDeneb; -import tech.pegasys.teku.spec.datastructures.consolidations.SignedConsolidation; import tech.pegasys.teku.spec.datastructures.execution.versions.electra.ExecutionPayloadElectra; public interface BeaconBlockBodyElectra extends BeaconBlockBodyDeneb { @@ -39,6 +37,4 @@ static BeaconBlockBodyElectra required(final BeaconBlockBody body) { default Optional toVersionElectra() { return Optional.of(this); } - - SszList getConsolidations(); } diff --git a/ethereum/spec/src/main/java/tech/pegasys/teku/spec/datastructures/blocks/blockbody/versions/electra/BeaconBlockBodyElectraImpl.java b/ethereum/spec/src/main/java/tech/pegasys/teku/spec/datastructures/blocks/blockbody/versions/electra/BeaconBlockBodyElectraImpl.java index 68a862a3077..bc94413a2cd 100644 --- a/ethereum/spec/src/main/java/tech/pegasys/teku/spec/datastructures/blocks/blockbody/versions/electra/BeaconBlockBodyElectraImpl.java +++ b/ethereum/spec/src/main/java/tech/pegasys/teku/spec/datastructures/blocks/blockbody/versions/electra/BeaconBlockBodyElectraImpl.java @@ -18,13 +18,12 @@ import org.apache.tuweni.bytes.Bytes32; import tech.pegasys.teku.bls.BLSSignature; import tech.pegasys.teku.infrastructure.ssz.SszList; -import tech.pegasys.teku.infrastructure.ssz.containers.Container13; +import tech.pegasys.teku.infrastructure.ssz.containers.Container12; import tech.pegasys.teku.infrastructure.ssz.primitive.SszBytes32; import tech.pegasys.teku.infrastructure.ssz.tree.TreeNode; import tech.pegasys.teku.spec.datastructures.blocks.Eth1Data; import tech.pegasys.teku.spec.datastructures.blocks.blockbody.BeaconBlockBody; import tech.pegasys.teku.spec.datastructures.blocks.blockbody.versions.altair.SyncAggregate; -import tech.pegasys.teku.spec.datastructures.consolidations.SignedConsolidation; import tech.pegasys.teku.spec.datastructures.execution.versions.electra.ExecutionPayloadElectra; import tech.pegasys.teku.spec.datastructures.execution.versions.electra.ExecutionPayloadElectraImpl; import tech.pegasys.teku.spec.datastructures.operations.Attestation; @@ -37,7 +36,7 @@ import tech.pegasys.teku.spec.datastructures.type.SszSignature; public class BeaconBlockBodyElectraImpl - extends Container13< + extends Container12< BeaconBlockBodyElectraImpl, SszSignature, Eth1Data, @@ -50,8 +49,7 @@ public class BeaconBlockBodyElectraImpl SyncAggregate, ExecutionPayloadElectraImpl, SszList, - SszList, - SszList> + SszList> implements BeaconBlockBodyElectra { BeaconBlockBodyElectraImpl( @@ -67,8 +65,7 @@ public class BeaconBlockBodyElectraImpl final SyncAggregate syncAggregate, final ExecutionPayloadElectraImpl executionPayload, final SszList blsToExecutionChanges, - final SszList blobKzgCommitments, - final SszList consolidations) { + final SszList blobKzgCommitments) { super( type, randaoReveal, @@ -82,8 +79,7 @@ public class BeaconBlockBodyElectraImpl syncAggregate, executionPayload, blsToExecutionChanges, - blobKzgCommitments, - consolidations); + blobKzgCommitments); } BeaconBlockBodyElectraImpl(final BeaconBlockBodySchemaElectraImpl type) { @@ -173,11 +169,6 @@ public SszList getBlobKzgCommitments() { return getField11(); } - @Override - public SszList getConsolidations() { - return getField12(); - } - @Override public BeaconBlockBodySchemaElectraImpl getSchema() { return (BeaconBlockBodySchemaElectraImpl) super.getSchema(); diff --git a/ethereum/spec/src/main/java/tech/pegasys/teku/spec/datastructures/blocks/blockbody/versions/electra/BeaconBlockBodySchemaElectra.java b/ethereum/spec/src/main/java/tech/pegasys/teku/spec/datastructures/blocks/blockbody/versions/electra/BeaconBlockBodySchemaElectra.java index 00347ffdafc..cc0aaf4002d 100644 --- a/ethereum/spec/src/main/java/tech/pegasys/teku/spec/datastructures/blocks/blockbody/versions/electra/BeaconBlockBodySchemaElectra.java +++ b/ethereum/spec/src/main/java/tech/pegasys/teku/spec/datastructures/blocks/blockbody/versions/electra/BeaconBlockBodySchemaElectra.java @@ -16,10 +16,8 @@ import static com.google.common.base.Preconditions.checkArgument; import java.util.Optional; -import tech.pegasys.teku.infrastructure.ssz.schema.SszListSchema; import tech.pegasys.teku.spec.datastructures.blocks.blockbody.BeaconBlockBodySchema; import tech.pegasys.teku.spec.datastructures.blocks.blockbody.versions.deneb.BeaconBlockBodySchemaDeneb; -import tech.pegasys.teku.spec.datastructures.consolidations.SignedConsolidation; public interface BeaconBlockBodySchemaElectra extends BeaconBlockBodySchemaDeneb { @@ -32,8 +30,6 @@ static BeaconBlockBodySchemaElectra required(final BeaconBlockBodySchema s return (BeaconBlockBodySchemaElectra) schema; } - SszListSchema getConsolidationsSchema(); - @Override default Optional> toVersionElectra() { return Optional.of(this); diff --git a/ethereum/spec/src/main/java/tech/pegasys/teku/spec/datastructures/blocks/blockbody/versions/electra/BeaconBlockBodySchemaElectraImpl.java b/ethereum/spec/src/main/java/tech/pegasys/teku/spec/datastructures/blocks/blockbody/versions/electra/BeaconBlockBodySchemaElectraImpl.java index 7e3c521f5b0..aa7b4530193 100644 --- a/ethereum/spec/src/main/java/tech/pegasys/teku/spec/datastructures/blocks/blockbody/versions/electra/BeaconBlockBodySchemaElectraImpl.java +++ b/ethereum/spec/src/main/java/tech/pegasys/teku/spec/datastructures/blocks/blockbody/versions/electra/BeaconBlockBodySchemaElectraImpl.java @@ -17,7 +17,7 @@ import java.util.function.Function; import tech.pegasys.teku.infrastructure.async.SafeFuture; import tech.pegasys.teku.infrastructure.ssz.SszList; -import tech.pegasys.teku.infrastructure.ssz.containers.ContainerSchema13; +import tech.pegasys.teku.infrastructure.ssz.containers.ContainerSchema12; import tech.pegasys.teku.infrastructure.ssz.primitive.SszBytes32; import tech.pegasys.teku.infrastructure.ssz.schema.SszListSchema; import tech.pegasys.teku.infrastructure.ssz.schema.SszPrimitiveSchemas; @@ -31,7 +31,6 @@ import tech.pegasys.teku.spec.datastructures.blocks.blockbody.common.BlockBodyFields; import tech.pegasys.teku.spec.datastructures.blocks.blockbody.versions.altair.SyncAggregate; import tech.pegasys.teku.spec.datastructures.blocks.blockbody.versions.altair.SyncAggregateSchema; -import tech.pegasys.teku.spec.datastructures.consolidations.SignedConsolidation; import tech.pegasys.teku.spec.datastructures.execution.ExecutionPayloadSchema; import tech.pegasys.teku.spec.datastructures.execution.versions.electra.ExecutionPayloadElectraImpl; import tech.pegasys.teku.spec.datastructures.execution.versions.electra.ExecutionPayloadSchemaElectra; @@ -49,7 +48,7 @@ import tech.pegasys.teku.spec.datastructures.type.SszSignatureSchema; public class BeaconBlockBodySchemaElectraImpl - extends ContainerSchema13< + extends ContainerSchema12< BeaconBlockBodyElectraImpl, SszSignature, Eth1Data, @@ -62,8 +61,7 @@ public class BeaconBlockBodySchemaElectraImpl SyncAggregate, ExecutionPayloadElectraImpl, SszList, - SszList, - SszList> + SszList> implements BeaconBlockBodySchemaElectra { protected BeaconBlockBodySchemaElectraImpl( @@ -79,8 +77,7 @@ protected BeaconBlockBodySchemaElectraImpl( final NamedSchema syncAggregateSchema, final NamedSchema executionPayloadSchema, final NamedSchema> blsToExecutionChange, - final NamedSchema> blobKzgCommitments, - final NamedSchema> consolidations) { + final NamedSchema> blobKzgCommitments) { super( containerName, randaoRevealSchema, @@ -94,8 +91,7 @@ protected BeaconBlockBodySchemaElectraImpl( syncAggregateSchema, executionPayloadSchema, blsToExecutionChange, - blobKzgCommitments, - consolidations); + blobKzgCommitments); } public static BeaconBlockBodySchemaElectraImpl create( @@ -141,12 +137,7 @@ BlockBodyFields.EXECUTION_PAYLOAD, new ExecutionPayloadSchemaElectra(specConfig) BlockBodyFields.BLS_TO_EXECUTION_CHANGES, SszListSchema.create( blsToExecutionChangeSchema, specConfig.getMaxBlsToExecutionChanges())), - namedSchema(BlockBodyFields.BLOB_KZG_COMMITMENTS, blobKzgCommitmentsSchema), - namedSchema( - BlockBodyFields.CONSOLIDATIONS, - SszListSchema.create( - SignedConsolidation.SSZ_SCHEMA, - specConfig.getMaxConsolidationRequestsPerPayload()))); + namedSchema(BlockBodyFields.BLOB_KZG_COMMITMENTS, blobKzgCommitmentsSchema)); } @Override @@ -236,11 +227,4 @@ public LongList getBlindedNodeGeneralizedIndices() { getChildGeneralizedIndex(getFieldIndex(BlockBodyFields.EXECUTION_PAYLOAD)), getExecutionPayloadSchema().getBlindedNodeGeneralizedIndices()); } - - @SuppressWarnings("unchecked") - @Override - public SszListSchema getConsolidationsSchema() { - return (SszListSchema) - getChildSchema(getFieldIndex(BlockBodyFields.CONSOLIDATIONS)); - } } diff --git a/ethereum/spec/src/main/java/tech/pegasys/teku/spec/datastructures/blocks/blockbody/versions/electra/BlindedBeaconBlockBodyElectra.java b/ethereum/spec/src/main/java/tech/pegasys/teku/spec/datastructures/blocks/blockbody/versions/electra/BlindedBeaconBlockBodyElectra.java index 977f7e02363..e4118f7a27e 100644 --- a/ethereum/spec/src/main/java/tech/pegasys/teku/spec/datastructures/blocks/blockbody/versions/electra/BlindedBeaconBlockBodyElectra.java +++ b/ethereum/spec/src/main/java/tech/pegasys/teku/spec/datastructures/blocks/blockbody/versions/electra/BlindedBeaconBlockBodyElectra.java @@ -14,10 +14,8 @@ package tech.pegasys.teku.spec.datastructures.blocks.blockbody.versions.electra; import java.util.Optional; -import tech.pegasys.teku.infrastructure.ssz.SszList; import tech.pegasys.teku.spec.datastructures.blocks.blockbody.BeaconBlockBody; import tech.pegasys.teku.spec.datastructures.blocks.blockbody.versions.deneb.BlindedBeaconBlockBodyDeneb; -import tech.pegasys.teku.spec.datastructures.consolidations.SignedConsolidation; public interface BlindedBeaconBlockBodyElectra extends BlindedBeaconBlockBodyDeneb { static BlindedBeaconBlockBodyElectra required(final BeaconBlockBody body) { @@ -36,6 +34,4 @@ default Optional toBlindedVersionElectra() { @Override BlindedBeaconBlockBodySchemaElectra getSchema(); - - SszList getConsolidations(); } diff --git a/ethereum/spec/src/main/java/tech/pegasys/teku/spec/datastructures/blocks/blockbody/versions/electra/BlindedBeaconBlockBodyElectraImpl.java b/ethereum/spec/src/main/java/tech/pegasys/teku/spec/datastructures/blocks/blockbody/versions/electra/BlindedBeaconBlockBodyElectraImpl.java index 39f40672105..afb0f4634fd 100644 --- a/ethereum/spec/src/main/java/tech/pegasys/teku/spec/datastructures/blocks/blockbody/versions/electra/BlindedBeaconBlockBodyElectraImpl.java +++ b/ethereum/spec/src/main/java/tech/pegasys/teku/spec/datastructures/blocks/blockbody/versions/electra/BlindedBeaconBlockBodyElectraImpl.java @@ -18,13 +18,12 @@ import org.apache.tuweni.bytes.Bytes32; import tech.pegasys.teku.bls.BLSSignature; import tech.pegasys.teku.infrastructure.ssz.SszList; -import tech.pegasys.teku.infrastructure.ssz.containers.Container13; +import tech.pegasys.teku.infrastructure.ssz.containers.Container12; import tech.pegasys.teku.infrastructure.ssz.primitive.SszBytes32; import tech.pegasys.teku.infrastructure.ssz.tree.TreeNode; import tech.pegasys.teku.spec.datastructures.blocks.Eth1Data; import tech.pegasys.teku.spec.datastructures.blocks.blockbody.BeaconBlockBody; import tech.pegasys.teku.spec.datastructures.blocks.blockbody.versions.altair.SyncAggregate; -import tech.pegasys.teku.spec.datastructures.consolidations.SignedConsolidation; import tech.pegasys.teku.spec.datastructures.execution.ExecutionPayloadHeader; import tech.pegasys.teku.spec.datastructures.execution.versions.electra.ExecutionPayloadHeaderElectraImpl; import tech.pegasys.teku.spec.datastructures.operations.Attestation; @@ -37,7 +36,7 @@ import tech.pegasys.teku.spec.datastructures.type.SszSignature; class BlindedBeaconBlockBodyElectraImpl - extends Container13< + extends Container12< BlindedBeaconBlockBodyElectraImpl, SszSignature, Eth1Data, @@ -50,8 +49,7 @@ class BlindedBeaconBlockBodyElectraImpl SyncAggregate, ExecutionPayloadHeaderElectraImpl, SszList, - SszList, - SszList> + SszList> implements BlindedBeaconBlockBodyElectra { BlindedBeaconBlockBodyElectraImpl(final BlindedBeaconBlockBodySchemaElectraImpl type) { @@ -76,8 +74,7 @@ class BlindedBeaconBlockBodyElectraImpl final SyncAggregate syncAggregate, final ExecutionPayloadHeaderElectraImpl executionPayloadHeader, final SszList blsToExecutionChanges, - final SszList blobKzgCommitments, - final SszList consolidations) { + final SszList blobKzgCommitments) { super( type, randaoReveal, @@ -91,8 +88,7 @@ class BlindedBeaconBlockBodyElectraImpl syncAggregate, executionPayloadHeader, blsToExecutionChanges, - blobKzgCommitments, - consolidations); + blobKzgCommitments); } public static BlindedBeaconBlockBodyElectraImpl required(final BeaconBlockBody body) { @@ -173,11 +169,6 @@ public SszList getBlobKzgCommitments() { return getField11(); } - @Override - public SszList getConsolidations() { - return getField12(); - } - @Override public BlindedBeaconBlockBodySchemaElectraImpl getSchema() { return (BlindedBeaconBlockBodySchemaElectraImpl) super.getSchema(); diff --git a/ethereum/spec/src/main/java/tech/pegasys/teku/spec/datastructures/blocks/blockbody/versions/electra/BlindedBeaconBlockBodySchemaElectra.java b/ethereum/spec/src/main/java/tech/pegasys/teku/spec/datastructures/blocks/blockbody/versions/electra/BlindedBeaconBlockBodySchemaElectra.java index ebe71caf7ba..58cdb1d860f 100644 --- a/ethereum/spec/src/main/java/tech/pegasys/teku/spec/datastructures/blocks/blockbody/versions/electra/BlindedBeaconBlockBodySchemaElectra.java +++ b/ethereum/spec/src/main/java/tech/pegasys/teku/spec/datastructures/blocks/blockbody/versions/electra/BlindedBeaconBlockBodySchemaElectra.java @@ -15,10 +15,8 @@ import static com.google.common.base.Preconditions.checkArgument; -import tech.pegasys.teku.infrastructure.ssz.schema.SszListSchema; import tech.pegasys.teku.spec.datastructures.blocks.blockbody.BeaconBlockBodySchema; import tech.pegasys.teku.spec.datastructures.blocks.blockbody.versions.deneb.BlindedBeaconBlockBodySchemaDeneb; -import tech.pegasys.teku.spec.datastructures.consolidations.SignedConsolidation; public interface BlindedBeaconBlockBodySchemaElectra extends BlindedBeaconBlockBodySchemaDeneb { @@ -30,6 +28,4 @@ static BlindedBeaconBlockBodySchemaElectra required(final BeaconBlockBodySche schema.getClass()); return (BlindedBeaconBlockBodySchemaElectra) schema; } - - SszListSchema getConsolidationsSchema(); } diff --git a/ethereum/spec/src/main/java/tech/pegasys/teku/spec/datastructures/blocks/blockbody/versions/electra/BlindedBeaconBlockBodySchemaElectraImpl.java b/ethereum/spec/src/main/java/tech/pegasys/teku/spec/datastructures/blocks/blockbody/versions/electra/BlindedBeaconBlockBodySchemaElectraImpl.java index bd49088d1dc..0c9e16d5c4e 100644 --- a/ethereum/spec/src/main/java/tech/pegasys/teku/spec/datastructures/blocks/blockbody/versions/electra/BlindedBeaconBlockBodySchemaElectraImpl.java +++ b/ethereum/spec/src/main/java/tech/pegasys/teku/spec/datastructures/blocks/blockbody/versions/electra/BlindedBeaconBlockBodySchemaElectraImpl.java @@ -17,7 +17,7 @@ import java.util.function.Function; import tech.pegasys.teku.infrastructure.async.SafeFuture; import tech.pegasys.teku.infrastructure.ssz.SszList; -import tech.pegasys.teku.infrastructure.ssz.containers.ContainerSchema13; +import tech.pegasys.teku.infrastructure.ssz.containers.ContainerSchema12; import tech.pegasys.teku.infrastructure.ssz.primitive.SszBytes32; import tech.pegasys.teku.infrastructure.ssz.schema.SszListSchema; import tech.pegasys.teku.infrastructure.ssz.schema.SszPrimitiveSchemas; @@ -31,7 +31,6 @@ import tech.pegasys.teku.spec.datastructures.blocks.blockbody.common.BlockBodyFields; import tech.pegasys.teku.spec.datastructures.blocks.blockbody.versions.altair.SyncAggregate; import tech.pegasys.teku.spec.datastructures.blocks.blockbody.versions.altair.SyncAggregateSchema; -import tech.pegasys.teku.spec.datastructures.consolidations.SignedConsolidation; import tech.pegasys.teku.spec.datastructures.execution.versions.electra.ExecutionPayloadHeaderElectraImpl; import tech.pegasys.teku.spec.datastructures.execution.versions.electra.ExecutionPayloadHeaderSchemaElectra; import tech.pegasys.teku.spec.datastructures.operations.Attestation; @@ -48,7 +47,7 @@ import tech.pegasys.teku.spec.datastructures.type.SszSignatureSchema; public class BlindedBeaconBlockBodySchemaElectraImpl - extends ContainerSchema13< + extends ContainerSchema12< BlindedBeaconBlockBodyElectraImpl, SszSignature, Eth1Data, @@ -61,8 +60,7 @@ public class BlindedBeaconBlockBodySchemaElectraImpl SyncAggregate, ExecutionPayloadHeaderElectraImpl, SszList, - SszList, - SszList> + SszList> implements BlindedBeaconBlockBodySchemaElectra { private BlindedBeaconBlockBodySchemaElectraImpl( @@ -78,8 +76,7 @@ private BlindedBeaconBlockBodySchemaElectraImpl( final NamedSchema syncAggregate, final NamedSchema executionPayloadHeader, final NamedSchema> blsToExecutionChanges, - final NamedSchema> blobKzgCommitments, - final NamedSchema> consolidations) { + final NamedSchema> blobKzgCommitments) { super( containerName, randaoReveal, @@ -93,8 +90,7 @@ private BlindedBeaconBlockBodySchemaElectraImpl( syncAggregate, executionPayloadHeader, blsToExecutionChanges, - blobKzgCommitments, - consolidations); + blobKzgCommitments); } public static BlindedBeaconBlockBodySchemaElectraImpl create( @@ -141,12 +137,7 @@ public static BlindedBeaconBlockBodySchemaElectraImpl create( BlockBodyFields.BLS_TO_EXECUTION_CHANGES, SszListSchema.create( signedBlsToExecutionChangeSchema, specConfig.getMaxBlsToExecutionChanges())), - namedSchema(BlockBodyFields.BLOB_KZG_COMMITMENTS, blobKzgCommitmentsSchema), - namedSchema( - BlockBodyFields.CONSOLIDATIONS, - SszListSchema.create( - SignedConsolidation.SSZ_SCHEMA, - specConfig.getMaxConsolidationRequestsPerPayload()))); + namedSchema(BlockBodyFields.BLOB_KZG_COMMITMENTS, blobKzgCommitmentsSchema)); } @Override @@ -231,11 +222,4 @@ public LongList getBlindedNodeGeneralizedIndices() { getChildGeneralizedIndex(getFieldIndex(BlockBodyFields.EXECUTION_PAYLOAD_HEADER)), getExecutionPayloadHeaderSchema().getBlindedNodeGeneralizedIndices()); } - - @SuppressWarnings("unchecked") - @Override - public SszListSchema getConsolidationsSchema() { - return (SszListSchema) - getChildSchema(getFieldIndex(BlockBodyFields.CONSOLIDATIONS)); - } } diff --git a/ethereum/spec/src/main/java/tech/pegasys/teku/spec/datastructures/blocks/blockbody/versions/phase0/BeaconBlockBodyBuilderPhase0.java b/ethereum/spec/src/main/java/tech/pegasys/teku/spec/datastructures/blocks/blockbody/versions/phase0/BeaconBlockBodyBuilderPhase0.java index 3e36327e2a8..f7600483e82 100644 --- a/ethereum/spec/src/main/java/tech/pegasys/teku/spec/datastructures/blocks/blockbody/versions/phase0/BeaconBlockBodyBuilderPhase0.java +++ b/ethereum/spec/src/main/java/tech/pegasys/teku/spec/datastructures/blocks/blockbody/versions/phase0/BeaconBlockBodyBuilderPhase0.java @@ -25,7 +25,6 @@ import tech.pegasys.teku.spec.datastructures.blocks.blockbody.BeaconBlockBodyBuilder; import tech.pegasys.teku.spec.datastructures.blocks.blockbody.BeaconBlockBodySchema; import tech.pegasys.teku.spec.datastructures.blocks.blockbody.versions.altair.SyncAggregate; -import tech.pegasys.teku.spec.datastructures.consolidations.SignedConsolidation; import tech.pegasys.teku.spec.datastructures.execution.ExecutionPayload; import tech.pegasys.teku.spec.datastructures.execution.ExecutionPayloadHeader; import tech.pegasys.teku.spec.datastructures.operations.Attestation; @@ -136,12 +135,6 @@ public BeaconBlockBodyBuilder blobKzgCommitments( return this; } - @Override - public BeaconBlockBodyBuilder consolidations(final SszList consolidations) { - // No consolidations in phase 0 - return this; - } - protected void validate() { checkNotNull(randaoReveal, "randaoReveal must be specified"); checkNotNull(eth1Data, "eth1Data must be specified"); diff --git a/ethereum/spec/src/main/java/tech/pegasys/teku/spec/datastructures/consolidations/Consolidation.java b/ethereum/spec/src/main/java/tech/pegasys/teku/spec/datastructures/consolidations/Consolidation.java deleted file mode 100644 index fe3fbd4f7a1..00000000000 --- a/ethereum/spec/src/main/java/tech/pegasys/teku/spec/datastructures/consolidations/Consolidation.java +++ /dev/null @@ -1,87 +0,0 @@ -/* - * Copyright Consensys Software Inc., 2024 - * - * 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.consolidations; - -import tech.pegasys.teku.infrastructure.ssz.containers.Container3; -import tech.pegasys.teku.infrastructure.ssz.containers.ContainerSchema3; -import tech.pegasys.teku.infrastructure.ssz.primitive.SszUInt64; -import tech.pegasys.teku.infrastructure.ssz.schema.SszPrimitiveSchemas; -import tech.pegasys.teku.infrastructure.ssz.tree.TreeNode; -import tech.pegasys.teku.infrastructure.unsigned.UInt64; - -public class Consolidation extends Container3 { - public static final ConsolidationSchema SSZ_SCHEMA = new ConsolidationSchema(); - - public static class ConsolidationSchema - extends ContainerSchema3 { - public ConsolidationSchema() { - super( - "Consolidation", - namedSchema("source_index", SszPrimitiveSchemas.UINT64_SCHEMA), - namedSchema("target_index", SszPrimitiveSchemas.UINT64_SCHEMA), - namedSchema("epoch", SszPrimitiveSchemas.UINT64_SCHEMA)); - } - - public Consolidation create( - final SszUInt64 sourceIndex, final SszUInt64 targetIndex, final SszUInt64 epoch) { - return new Consolidation(this, sourceIndex, targetIndex, epoch); - } - - public SszUInt64 getSourceIndexSchema() { - return (SszUInt64) getFieldSchema0(); - } - - public SszUInt64 getTargetIndexSchema() { - return (SszUInt64) getFieldSchema1(); - } - - public SszUInt64 getEpochSchema() { - return (SszUInt64) getFieldSchema2(); - } - - @Override - public Consolidation createFromBackingNode(final TreeNode node) { - return new Consolidation(this, node); - } - } - - protected Consolidation( - final ContainerSchema3 schema) { - super(schema); - } - - private Consolidation(final Consolidation.ConsolidationSchema type, final TreeNode backingNode) { - super(type, backingNode); - } - - public Consolidation( - final ConsolidationSchema consolidationSchema, - final SszUInt64 sourceIndex, - final SszUInt64 targetIndex, - final SszUInt64 epoch) { - super(consolidationSchema, sourceIndex, targetIndex, epoch); - } - - public int getSourceIndex() { - return ((SszUInt64) get(0)).get().intValue(); - } - - public int getTargetIndex() { - return ((SszUInt64) get(1)).get().intValue(); - } - - public UInt64 getEpoch() { - return ((SszUInt64) get(2)).get(); - } -} diff --git a/ethereum/spec/src/main/java/tech/pegasys/teku/spec/datastructures/consolidations/SignedConsolidation.java b/ethereum/spec/src/main/java/tech/pegasys/teku/spec/datastructures/consolidations/SignedConsolidation.java deleted file mode 100644 index c2d87a01243..00000000000 --- a/ethereum/spec/src/main/java/tech/pegasys/teku/spec/datastructures/consolidations/SignedConsolidation.java +++ /dev/null @@ -1,68 +0,0 @@ -/* - * Copyright Consensys Software Inc., 2024 - * - * 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.consolidations; - -import tech.pegasys.teku.bls.BLSSignature; -import tech.pegasys.teku.infrastructure.ssz.containers.Container2; -import tech.pegasys.teku.infrastructure.ssz.containers.ContainerSchema2; -import tech.pegasys.teku.infrastructure.ssz.tree.TreeNode; -import tech.pegasys.teku.spec.datastructures.type.SszSignature; -import tech.pegasys.teku.spec.datastructures.type.SszSignatureSchema; - -public class SignedConsolidation - extends Container2 { - public static final SignedConsolidationSchema SSZ_SCHEMA = new SignedConsolidationSchema(); - - protected SignedConsolidation( - final ContainerSchema2 schema, - final TreeNode backingNode) { - super(schema, backingNode); - } - - protected SignedConsolidation( - final ContainerSchema2 schema, - final Consolidation arg0, - final SszSignature arg1) { - super(schema, arg0, arg1); - } - - public static class SignedConsolidationSchema - extends ContainerSchema2 { - - public SignedConsolidationSchema() { - super( - "SignedConsolidation", - namedSchema("message", Consolidation.SSZ_SCHEMA), - namedSchema("signature", SszSignatureSchema.INSTANCE)); - } - - @Override - public SignedConsolidation createFromBackingNode(final TreeNode node) { - return new SignedConsolidation(this, node); - } - - public SignedConsolidation create( - final Consolidation consolidation, final BLSSignature signature) { - return new SignedConsolidation(this, consolidation, new SszSignature(signature)); - } - } - - public Consolidation getMessage() { - return getField0(); - } - - public BLSSignature getSignature() { - return getField1().getSignature(); - } -} diff --git a/ethereum/spec/src/main/java/tech/pegasys/teku/spec/executionlayer/ExecutionLayerChannelStub.java b/ethereum/spec/src/main/java/tech/pegasys/teku/spec/executionlayer/ExecutionLayerChannelStub.java index d53550f957f..f1777120e15 100644 --- a/ethereum/spec/src/main/java/tech/pegasys/teku/spec/executionlayer/ExecutionLayerChannelStub.java +++ b/ethereum/spec/src/main/java/tech/pegasys/teku/spec/executionlayer/ExecutionLayerChannelStub.java @@ -290,7 +290,8 @@ public SafeFuture engineGetPayload( .blobGasUsed(() -> UInt64.ZERO) .excessBlobGas(() -> UInt64.ZERO) .depositRequests(() -> generateDepositRequests(state)) - .withdrawalRequests(List::of)); + .withdrawalRequests(List::of) + .consolidationRequests(List::of)); // we assume all blocks are produced locally lastValidBlock = diff --git a/ethereum/spec/src/main/java/tech/pegasys/teku/spec/logic/common/operations/OperationSignatureVerifier.java b/ethereum/spec/src/main/java/tech/pegasys/teku/spec/logic/common/operations/OperationSignatureVerifier.java index e92d6f0b250..633782194fe 100644 --- a/ethereum/spec/src/main/java/tech/pegasys/teku/spec/logic/common/operations/OperationSignatureVerifier.java +++ b/ethereum/spec/src/main/java/tech/pegasys/teku/spec/logic/common/operations/OperationSignatureVerifier.java @@ -13,7 +13,6 @@ package tech.pegasys.teku.spec.logic.common.operations; -import java.util.List; import java.util.Optional; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; @@ -25,8 +24,6 @@ import tech.pegasys.teku.infrastructure.async.SafeFuture; import tech.pegasys.teku.spec.constants.Domain; import tech.pegasys.teku.spec.datastructures.blocks.BeaconBlockHeader; -import tech.pegasys.teku.spec.datastructures.consolidations.Consolidation; -import tech.pegasys.teku.spec.datastructures.consolidations.SignedConsolidation; import tech.pegasys.teku.spec.datastructures.operations.BlsToExecutionChange; import tech.pegasys.teku.spec.datastructures.operations.ProposerSlashing; import tech.pegasys.teku.spec.datastructures.operations.SignedBlsToExecutionChange; @@ -141,25 +138,6 @@ public SafeFuture verifyBlsToExecutionChangeSignatureAsync( return signatureVerifier.verify(publicKey, signingRoot, signature); } - /* Signature verification for process_consolidation */ - public boolean verifyConsolidationSignature( - final BeaconState state, - final SignedConsolidation signedConsolidation, - final BLSSignatureVerifier signatureVerifier) { - final Bytes32 domain = - miscHelpers.computeDomain(Domain.DOMAIN_CONSOLIDATION, state.getGenesisValidatorsRoot()); - final Consolidation consolidation = signedConsolidation.getMessage(); - final Bytes signingRoot = miscHelpers.computeSigningRoot(consolidation, domain); - - final BLSPublicKey sourcePublicKey = - state.getValidators().get(consolidation.getSourceIndex()).getPublicKey(); - final BLSPublicKey targetPublicKey = - state.getValidators().get(consolidation.getTargetIndex()).getPublicKey(); - - return signatureVerifier.verify( - List.of(sourcePublicKey, targetPublicKey), signingRoot, signedConsolidation.getSignature()); - } - private Bytes calculateBlsToExecutionChangeSigningRoot( final BeaconState state, final BlsToExecutionChange addressChange) { final Bytes32 domain = diff --git a/ethereum/spec/src/main/java/tech/pegasys/teku/spec/schemas/SchemaDefinitionsElectra.java b/ethereum/spec/src/main/java/tech/pegasys/teku/spec/schemas/SchemaDefinitionsElectra.java index 64aad13e009..f96914bdb76 100644 --- a/ethereum/spec/src/main/java/tech/pegasys/teku/spec/schemas/SchemaDefinitionsElectra.java +++ b/ethereum/spec/src/main/java/tech/pegasys/teku/spec/schemas/SchemaDefinitionsElectra.java @@ -38,8 +38,6 @@ import tech.pegasys.teku.spec.datastructures.builder.ExecutionPayloadAndBlobsBundleSchema; import tech.pegasys.teku.spec.datastructures.builder.SignedBuilderBidSchema; import tech.pegasys.teku.spec.datastructures.builder.versions.deneb.BuilderBidSchemaDeneb; -import tech.pegasys.teku.spec.datastructures.consolidations.Consolidation; -import tech.pegasys.teku.spec.datastructures.consolidations.SignedConsolidation; import tech.pegasys.teku.spec.datastructures.execution.ExecutionPayloadHeaderSchema; import tech.pegasys.teku.spec.datastructures.execution.ExecutionPayloadSchema; import tech.pegasys.teku.spec.datastructures.execution.versions.electra.ConsolidationRequest; @@ -277,10 +275,6 @@ public BeaconBlockBodyBuilder createBeaconBlockBodyBuilder() { return new BeaconBlockBodyBuilderElectra(beaconBlockBodySchema, blindedBeaconBlockBodySchema); } - public SszListSchema getConsolidationsSchema() { - return beaconBlockBodySchema.getConsolidationsSchema(); - } - @Override public BlockContentsSchema getBlockContentsSchema() { return blockContentsSchema; @@ -343,14 +337,6 @@ public ConsolidationRequestSchema getConsolidationRequestSchema() { return consolidationRequestSchema; } - public Consolidation.ConsolidationSchema getConsolidationSchema() { - return Consolidation.SSZ_SCHEMA; - } - - public SignedConsolidation.SignedConsolidationSchema getSignedConsolidationSchema() { - return SignedConsolidation.SSZ_SCHEMA; - } - @Override long getMaxValidatorPerAttestation(final SpecConfig specConfig) { return (long) specConfig.getMaxValidatorsPerCommittee() * specConfig.getMaxCommitteesPerSlot(); diff --git a/ethereum/spec/src/property-test/java/tech/pegasys/teku/spec/datastructures/execution/versions/electra/ConsolidationRequestPropertyTest.java b/ethereum/spec/src/property-test/java/tech/pegasys/teku/spec/datastructures/execution/versions/electra/ConsolidationRequestPropertyTest.java new file mode 100644 index 00000000000..59e93cacae2 --- /dev/null +++ b/ethereum/spec/src/property-test/java/tech/pegasys/teku/spec/datastructures/execution/versions/electra/ConsolidationRequestPropertyTest.java @@ -0,0 +1,41 @@ +/* + * 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.spec.datastructures.execution.versions.electra; + +import static tech.pegasys.teku.spec.propertytest.util.PropertyTestHelper.assertDeserializeMutatedThrowsExpected; +import static tech.pegasys.teku.spec.propertytest.util.PropertyTestHelper.assertRoundTrip; + +import com.fasterxml.jackson.core.JsonProcessingException; +import net.jqwik.api.ForAll; +import net.jqwik.api.Property; +import tech.pegasys.teku.spec.propertytest.suppliers.execution.versions.electra.ConsolidationRequestSupplier; + +public class ConsolidationRequestPropertyTest { + + @Property + void roundTrip( + @ForAll(supplier = ConsolidationRequestSupplier.class) + final ConsolidationRequest consolidationRequest) + throws JsonProcessingException { + assertRoundTrip(consolidationRequest); + } + + @Property + void deserializeMutated( + @ForAll(supplier = ConsolidationRequestSupplier.class) + final ConsolidationRequest consolidationRequest, + @ForAll final int seed) { + assertDeserializeMutatedThrowsExpected(consolidationRequest, seed); + } +} diff --git a/ethereum/spec/src/testFixtures/java/tech/pegasys/teku/spec/generator/BlockProposalTestUtil.java b/ethereum/spec/src/testFixtures/java/tech/pegasys/teku/spec/generator/BlockProposalTestUtil.java index fe8f1b5220a..7d8d262f7be 100644 --- a/ethereum/spec/src/testFixtures/java/tech/pegasys/teku/spec/generator/BlockProposalTestUtil.java +++ b/ethereum/spec/src/testFixtures/java/tech/pegasys/teku/spec/generator/BlockProposalTestUtil.java @@ -128,9 +128,6 @@ public SafeFuture createNewBlock( builder.blobKzgCommitments( kzgCommitments.orElseGet(dataStructureUtil::emptyBlobKzgCommitments)); } - if (builder.supportsConsolidations()) { - builder.consolidations(dataStructureUtil.emptyConsolidations()); - } return SafeFuture.COMPLETE; }, BlockProductionPerformance.NOOP) @@ -204,9 +201,6 @@ public SafeFuture createNewBlockSkippingStateTransition( builder.blobKzgCommitments( kzgCommitments.orElseGet(dataStructureUtil::emptyBlobKzgCommitments)); } - if (builder.supportsConsolidations()) { - builder.consolidations(dataStructureUtil.emptyConsolidations()); - } return SafeFuture.COMPLETE; }) .thenApply( diff --git a/ethereum/spec/src/testFixtures/java/tech/pegasys/teku/spec/propertytest/suppliers/execution/versions/electra/ConsolidationRequestSupplier.java b/ethereum/spec/src/testFixtures/java/tech/pegasys/teku/spec/propertytest/suppliers/execution/versions/electra/ConsolidationRequestSupplier.java new file mode 100644 index 00000000000..18000d60cff --- /dev/null +++ b/ethereum/spec/src/testFixtures/java/tech/pegasys/teku/spec/propertytest/suppliers/execution/versions/electra/ConsolidationRequestSupplier.java @@ -0,0 +1,26 @@ +/* + * Copyright Consensys Software Inc., 2024 + * + * 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.propertytest.suppliers.execution.versions.electra; + +import tech.pegasys.teku.spec.SpecMilestone; +import tech.pegasys.teku.spec.datastructures.execution.versions.electra.ConsolidationRequest; +import tech.pegasys.teku.spec.propertytest.suppliers.DataStructureUtilSupplier; +import tech.pegasys.teku.spec.util.DataStructureUtil; + +public class ConsolidationRequestSupplier extends DataStructureUtilSupplier { + + public ConsolidationRequestSupplier() { + super(DataStructureUtil::randomConsolidationRequest, SpecMilestone.ELECTRA); + } +} 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 88c47d0879d..1e6ee19fefc 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 @@ -118,7 +118,6 @@ import tech.pegasys.teku.spec.datastructures.builder.SignedBuilderBid; import tech.pegasys.teku.spec.datastructures.builder.SignedValidatorRegistration; import tech.pegasys.teku.spec.datastructures.builder.ValidatorRegistration; -import tech.pegasys.teku.spec.datastructures.consolidations.SignedConsolidation; import tech.pegasys.teku.spec.datastructures.execution.BlobsBundle; import tech.pegasys.teku.spec.datastructures.execution.ClientVersion; import tech.pegasys.teku.spec.datastructures.execution.ExecutionPayload; @@ -1287,9 +1286,6 @@ public BeaconBlockBody randomBlindedBeaconBlockBodyWithCommitments( if (builder.supportsKzgCommitments()) { builder.blobKzgCommitments(commitments); } - if (builder.supportsConsolidations()) { - builder.consolidations(emptyConsolidations()); - } }); } @@ -1333,9 +1329,6 @@ public BeaconBlockBody randomBlindedBeaconBlockBody( if (builder.supportsKzgCommitments()) { builder.blobKzgCommitments(randomBlobKzgCommitments()); } - if (builder.supportsConsolidations()) { - builder.consolidations(emptyConsolidations()); - } builderModifier.accept(builder); return SafeFuture.COMPLETE; }) @@ -1376,9 +1369,6 @@ public BeaconBlockBody randomBeaconBlockBody( if (builder.supportsExecutionPayload()) { builder.executionPayload(randomExecutionPayload(proposalSlot)); } - if (builder.supportsConsolidations()) { - builder.consolidations(emptyConsolidations()); - } }); } @@ -1397,9 +1387,6 @@ public BeaconBlockBody randomBeaconBlockBodyWithCommitments( if (builder.supportsKzgCommitments()) { builder.blobKzgCommitments(commitments); } - if (builder.supportsConsolidations()) { - builder.consolidations(emptyConsolidations()); - } }); } @@ -1444,9 +1431,6 @@ public BeaconBlockBody randomBeaconBlockBody( if (builder.supportsKzgCommitments()) { builder.blobKzgCommitments(randomBlobKzgCommitments()); } - if (builder.supportsConsolidations()) { - builder.consolidations(emptyConsolidations()); - } builderModifier.accept(builder); return SafeFuture.COMPLETE; }) @@ -1501,9 +1485,6 @@ public BeaconBlockBody randomFullBeaconBlockBody( BeaconBlockBodySchemaDeneb.required(schema).getBlobKzgCommitmentsSchema(), this::randomSszKZGCommitment)); } - if (builder.supportsConsolidations()) { - builder.consolidations(emptyConsolidations()); - } builderModifier.accept(builder); return SafeFuture.COMPLETE; }) @@ -2415,13 +2396,6 @@ public SszList randomAttestations(final int count, final UInt64 slo count); } - public SszList emptyConsolidations() { - return SchemaDefinitionsElectra.required( - spec.forMilestone(SpecMilestone.ELECTRA).getSchemaDefinitions()) - .getConsolidationsSchema() - .createFromElements(List.of()); - } - public class RandomBlobSidecarBuilder { private Optional index = Optional.empty(); private Optional blob = Optional.empty(); diff --git a/ethereum/statetransition/src/main/java/tech/pegasys/teku/statetransition/util/DebugDataFileDumper.java b/ethereum/statetransition/src/main/java/tech/pegasys/teku/statetransition/util/DebugDataFileDumper.java index ccdd1da1710..0f12a32f512 100644 --- a/ethereum/statetransition/src/main/java/tech/pegasys/teku/statetransition/util/DebugDataFileDumper.java +++ b/ethereum/statetransition/src/main/java/tech/pegasys/teku/statetransition/util/DebugDataFileDumper.java @@ -61,6 +61,10 @@ public DebugDataFileDumper(final Path directory) { createDirectory( gossipMessagesPath.resolve(REJECTED_SUB_DIR), REJECTED_SUB_DIR, "rejected gossip messages"); createDirectory(directory.resolve(INVALID_BLOCK_DIR), INVALID_BLOCK_DIR, "invalid blocks"); + createDirectory( + directory.resolve(INVALID_BLOB_SIDECARS_DIR), + INVALID_BLOB_SIDECARS_DIR, + "invalid blob sidecars"); } @Override diff --git a/validator/remote/src/integration-test/resources/responses/produce_block_responses/newBlindedBlockELECTRA.json b/validator/remote/src/integration-test/resources/responses/produce_block_responses/newBlindedBlockELECTRA.json index 4aed4d26eb9..2040bda7c82 100644 --- a/validator/remote/src/integration-test/resources/responses/produce_block_responses/newBlindedBlockELECTRA.json +++ b/validator/remote/src/integration-test/resources/responses/produce_block_responses/newBlindedBlockELECTRA.json @@ -358,8 +358,7 @@ "0x49f540426ff48680416a1a43b562d4c24d9e1b5012cefb1979a3c9c1b8fbd42b8517c05e35b3e879984ec65a9ddb52af", "0xa99a23428f6ee3d80bb91e1cd80e3bc46cad162aa2b9c7bc5e291babfcdf69e17bb59e3819984a1ffcc715b881c2452f", "0xbcbb1d422fbac21d01fc8547ab974f9172b015bc5882f0768caa5e73d640216c13d5649714f92a0d43e05864498aa915" - ], - "consolidations": [] + ] } } } \ No newline at end of file diff --git a/validator/remote/src/integration-test/resources/responses/produce_block_responses/newBlockContentsELECTRA.json b/validator/remote/src/integration-test/resources/responses/produce_block_responses/newBlockContentsELECTRA.json index 407907e8df1..113a85283b0 100644 --- a/validator/remote/src/integration-test/resources/responses/produce_block_responses/newBlockContentsELECTRA.json +++ b/validator/remote/src/integration-test/resources/responses/produce_block_responses/newBlockContentsELECTRA.json @@ -399,8 +399,7 @@ "0xa250734616e5e744f48c493c6d932629d574d0f2b953d406c14b88999cbfbe0227821f9f2e60836eaef3cf363a0cfffd", "0xb5716d46b630c789e9cfb067411c3bf6db77cf84701cfdc0efcccb617720768dbea1e5fd28c1635cf50b13e301d462e4", "0x7c0e7f46d64d29bb09077be5c681fd8ec96ed2ce4dc2829266490109e8fd4fedf74293e1399ec2921fc349deac7c3731" - ], - "consolidations": [] + ] } }, "kzg_proofs": [ From 487b75f281e6e13cab6655de80fe538780dac7bf Mon Sep 17 00:00:00 2001 From: Enrico Del Fante Date: Tue, 25 Jun 2024 15:41:12 +0200 Subject: [PATCH 2/2] Provide Electra body builder test (#8402) * provide electra body builder test * rebase --- .../common/AbstractBeaconBlockBodyTest.java | 5 +- .../electra/BeaconBlockBodyElectraTest.java | 82 +++++++++++++++++++ 2 files changed, 83 insertions(+), 4 deletions(-) create mode 100644 ethereum/spec/src/test/java/tech/pegasys/teku/spec/datastructures/blocks/blockbody/versions/electra/BeaconBlockBodyElectraTest.java diff --git a/ethereum/spec/src/test/java/tech/pegasys/teku/spec/datastructures/blocks/blockbody/common/AbstractBeaconBlockBodyTest.java b/ethereum/spec/src/test/java/tech/pegasys/teku/spec/datastructures/blocks/blockbody/common/AbstractBeaconBlockBodyTest.java index 8fbe8a21d0c..b1ecc4a1c5b 100644 --- a/ethereum/spec/src/test/java/tech/pegasys/teku/spec/datastructures/blocks/blockbody/common/AbstractBeaconBlockBodyTest.java +++ b/ethereum/spec/src/test/java/tech/pegasys/teku/spec/datastructures/blocks/blockbody/common/AbstractBeaconBlockBodyTest.java @@ -22,7 +22,6 @@ import java.util.List; import java.util.function.Consumer; import java.util.stream.Collectors; -import java.util.stream.Stream; import org.apache.tuweni.bytes.Bytes32; import org.junit.jupiter.api.Test; import tech.pegasys.teku.bls.BLSSignature; @@ -166,9 +165,7 @@ void equalsReturnsFalseWhenProposerSlashingsAreDifferent() { void equalsReturnsFalseWhenAttesterSlashingsAreDifferent() { // Create copy of attesterSlashings and change the element to ensure it is different. attesterSlashings = - Stream.concat( - Stream.of(dataStructureUtil.randomAttesterSlashing()), attesterSlashings.stream()) - .collect(blockBodySchema.getAttesterSlashingsSchema().collector()); + blockBodySchema.getAttesterSlashingsSchema().of(dataStructureUtil.randomAttesterSlashing()); T testBeaconBlockBody = createBlockBody(); diff --git a/ethereum/spec/src/test/java/tech/pegasys/teku/spec/datastructures/blocks/blockbody/versions/electra/BeaconBlockBodyElectraTest.java b/ethereum/spec/src/test/java/tech/pegasys/teku/spec/datastructures/blocks/blockbody/versions/electra/BeaconBlockBodyElectraTest.java new file mode 100644 index 00000000000..6b1b8fedc11 --- /dev/null +++ b/ethereum/spec/src/test/java/tech/pegasys/teku/spec/datastructures/blocks/blockbody/versions/electra/BeaconBlockBodyElectraTest.java @@ -0,0 +1,82 @@ +/* + * 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.spec.datastructures.blocks.blockbody.versions.electra; + +import java.util.function.Consumer; +import org.junit.jupiter.api.BeforeEach; +import tech.pegasys.teku.infrastructure.ssz.SszList; +import tech.pegasys.teku.spec.SpecMilestone; +import tech.pegasys.teku.spec.datastructures.blocks.blockbody.BeaconBlockBodyBuilder; +import tech.pegasys.teku.spec.datastructures.blocks.blockbody.common.AbstractBeaconBlockBodyTest; +import tech.pegasys.teku.spec.datastructures.blocks.blockbody.versions.altair.SyncAggregate; +import tech.pegasys.teku.spec.datastructures.blocks.blockbody.versions.bellatrix.BlindedBeaconBlockBodyBellatrix; +import tech.pegasys.teku.spec.datastructures.execution.ExecutionPayload; +import tech.pegasys.teku.spec.datastructures.execution.ExecutionPayloadHeader; +import tech.pegasys.teku.spec.datastructures.operations.SignedBlsToExecutionChange; +import tech.pegasys.teku.spec.datastructures.type.SszKZGCommitment; + +class BeaconBlockBodyElectraTest extends AbstractBeaconBlockBodyTest { + + protected SyncAggregate syncAggregate; + protected ExecutionPayload executionPayload; + protected ExecutionPayloadHeader executionPayloadHeader; + protected SszList blsToExecutionChanges; + protected SszList blobKzgCommitments; + + @BeforeEach + void setup() { + super.setUpBaseClass( + SpecMilestone.ELECTRA, + () -> { + syncAggregate = dataStructureUtil.randomSyncAggregate(); + executionPayload = dataStructureUtil.randomExecutionPayload(); + executionPayloadHeader = dataStructureUtil.randomExecutionPayloadHeader(); + blsToExecutionChanges = dataStructureUtil.randomSignedBlsToExecutionChangesList(); + blobKzgCommitments = dataStructureUtil.randomBlobKzgCommitments(); + }); + } + + @Override + protected BeaconBlockBodyElectra createBlockBody( + final Consumer contentProvider) { + final BeaconBlockBodyBuilder bodyBuilder = createBeaconBlockBodyBuilder(); + contentProvider.accept(bodyBuilder); + return bodyBuilder.build().toVersionElectra().orElseThrow(); + } + + @Override + protected BlindedBeaconBlockBodyBellatrix createBlindedBlockBody( + final Consumer contentProvider) { + final BeaconBlockBodyBuilder bodyBuilder = createBeaconBlockBodyBuilder(); + contentProvider.accept(bodyBuilder); + return bodyBuilder.build().toBlindedVersionElectra().orElseThrow(); + } + + @Override + protected Consumer createContentProvider(final boolean blinded) { + return super.createContentProvider(blinded) + .andThen( + builder -> { + builder + .syncAggregate(syncAggregate) + .blsToExecutionChanges(blsToExecutionChanges) + .blobKzgCommitments(blobKzgCommitments); + if (blinded) { + builder.executionPayloadHeader(executionPayloadHeader); + } else { + builder.executionPayload(executionPayload); + } + }); + } +}