From d0c8e5c949dfba20d10a8be0f8a12fc1b65f49dd Mon Sep 17 00:00:00 2001 From: Enrico Del Fante Date: Fri, 15 Nov 2024 14:12:32 +0100 Subject: [PATCH] migrate beacon block related schemas --- .../blockbody/BeaconBlockBodySchema.java | 20 +++++ ...dedBeaconBlockBodySchemaBellatrixImpl.java | 14 +++- ...indedBeaconBlockBodySchemaCapellaImpl.java | 25 +++--- ...BlindedBeaconBlockBodySchemaDenebImpl.java | 6 ++ ...indedBeaconBlockBodySchemaElectraImpl.java | 35 ++++---- .../spec/schemas/SchemaDefinitionsAltair.java | 8 +- .../schemas/SchemaDefinitionsBellatrix.java | 28 ++----- .../schemas/SchemaDefinitionsCapella.java | 74 +---------------- .../spec/schemas/SchemaDefinitionsDeneb.java | 71 ++--------------- .../schemas/SchemaDefinitionsElectra.java | 76 +++--------------- .../spec/schemas/SchemaDefinitionsPhase0.java | 8 +- .../registry/SchemaRegistryBuilder.java | 79 +++++++++++++++++-- .../BeaconBlockBodySchemaPhase0Test.java | 4 - 13 files changed, 175 insertions(+), 273 deletions(-) diff --git a/ethereum/spec/src/main/java/tech/pegasys/teku/spec/datastructures/blocks/blockbody/BeaconBlockBodySchema.java b/ethereum/spec/src/main/java/tech/pegasys/teku/spec/datastructures/blocks/blockbody/BeaconBlockBodySchema.java index 633678af8b7..00602d42578 100644 --- a/ethereum/spec/src/main/java/tech/pegasys/teku/spec/datastructures/blocks/blockbody/BeaconBlockBodySchema.java +++ b/ethereum/spec/src/main/java/tech/pegasys/teku/spec/datastructures/blocks/blockbody/BeaconBlockBodySchema.java @@ -22,9 +22,13 @@ import tech.pegasys.teku.infrastructure.ssz.tree.TreeNode; import tech.pegasys.teku.spec.datastructures.blocks.blockbody.versions.altair.BeaconBlockBodySchemaAltair; import tech.pegasys.teku.spec.datastructures.blocks.blockbody.versions.bellatrix.BeaconBlockBodySchemaBellatrix; +import tech.pegasys.teku.spec.datastructures.blocks.blockbody.versions.bellatrix.BlindedBeaconBlockBodySchemaBellatrix; import tech.pegasys.teku.spec.datastructures.blocks.blockbody.versions.capella.BeaconBlockBodySchemaCapella; +import tech.pegasys.teku.spec.datastructures.blocks.blockbody.versions.capella.BlindedBeaconBlockBodySchemaCapella; import tech.pegasys.teku.spec.datastructures.blocks.blockbody.versions.deneb.BeaconBlockBodySchemaDeneb; +import tech.pegasys.teku.spec.datastructures.blocks.blockbody.versions.deneb.BlindedBeaconBlockBodySchemaDeneb; import tech.pegasys.teku.spec.datastructures.blocks.blockbody.versions.electra.BeaconBlockBodySchemaElectra; +import tech.pegasys.teku.spec.datastructures.blocks.blockbody.versions.electra.BlindedBeaconBlockBodySchemaElectra; import tech.pegasys.teku.spec.datastructures.operations.Attestation; import tech.pegasys.teku.spec.datastructures.operations.AttesterSlashing; import tech.pegasys.teku.spec.datastructures.operations.Deposit; @@ -70,6 +74,22 @@ default Optional> toVersionElectra() { return Optional.empty(); } + default Optional> toBlindedVersionBellatrix() { + return Optional.empty(); + } + + default Optional> toBlindedVersionCapella() { + return Optional.empty(); + } + + default Optional> toBlindedVersionDeneb() { + return Optional.empty(); + } + + default Optional> toBlindedVersionElectra() { + return Optional.empty(); + } + /** * getBlindedNodeGeneralizedIndices * diff --git a/ethereum/spec/src/main/java/tech/pegasys/teku/spec/datastructures/blocks/blockbody/versions/bellatrix/BlindedBeaconBlockBodySchemaBellatrixImpl.java b/ethereum/spec/src/main/java/tech/pegasys/teku/spec/datastructures/blocks/blockbody/versions/bellatrix/BlindedBeaconBlockBodySchemaBellatrixImpl.java index 91a85e46f9a..32e9ef2bae6 100644 --- a/ethereum/spec/src/main/java/tech/pegasys/teku/spec/datastructures/blocks/blockbody/versions/bellatrix/BlindedBeaconBlockBodySchemaBellatrixImpl.java +++ b/ethereum/spec/src/main/java/tech/pegasys/teku/spec/datastructures/blocks/blockbody/versions/bellatrix/BlindedBeaconBlockBodySchemaBellatrixImpl.java @@ -18,6 +18,7 @@ import static tech.pegasys.teku.spec.schemas.registry.SchemaTypes.EXECUTION_PAYLOAD_HEADER_SCHEMA; import it.unimi.dsi.fastutil.longs.LongList; +import java.util.Optional; import java.util.function.Function; import tech.pegasys.teku.infrastructure.async.SafeFuture; import tech.pegasys.teku.infrastructure.ssz.SszList; @@ -41,7 +42,6 @@ import tech.pegasys.teku.spec.datastructures.operations.Deposit; import tech.pegasys.teku.spec.datastructures.operations.ProposerSlashing; import tech.pegasys.teku.spec.datastructures.operations.SignedVoluntaryExit; -import tech.pegasys.teku.spec.datastructures.operations.versions.phase0.AttestationPhase0Schema; import tech.pegasys.teku.spec.datastructures.type.SszSignature; import tech.pegasys.teku.spec.datastructures.type.SszSignatureSchema; import tech.pegasys.teku.spec.schemas.registry.SchemaRegistry; @@ -108,8 +108,7 @@ public static BlindedBeaconBlockBodySchemaBellatrixImpl create( namedSchema( BlockBodyFields.ATTESTATIONS, SszListSchema.create( - schemaRegistry.get(ATTESTATION_SCHEMA), - specConfig.getMaxAttestations())), + schemaRegistry.get(ATTESTATION_SCHEMA), specConfig.getMaxAttestations())), namedSchema( BlockBodyFields.DEPOSITS, SszListSchema.create(Deposit.SSZ_SCHEMA, specConfig.getMaxDeposits())), @@ -120,7 +119,9 @@ public static BlindedBeaconBlockBodySchemaBellatrixImpl create( namedSchema( BlockBodyFields.SYNC_AGGREGATE, SyncAggregateSchema.create(specConfig.getSyncCommitteeSize())), - namedSchema(BlockBodyFields.EXECUTION_PAYLOAD_HEADER, schemaRegistry.get(EXECUTION_PAYLOAD_HEADER_SCHEMA).toVersionBellatrixRequired())); + namedSchema( + BlockBodyFields.EXECUTION_PAYLOAD_HEADER, + schemaRegistry.get(EXECUTION_PAYLOAD_HEADER_SCHEMA).toVersionBellatrixRequired())); } @Override @@ -180,6 +181,11 @@ public ExecutionPayloadHeaderSchemaBellatrix getExecutionPayloadHeaderSchema() { return (ExecutionPayloadHeaderSchemaBellatrix) getFieldSchema9(); } + @Override + public Optional> toBlindedVersionBellatrix() { + return Optional.of(this); + } + @Override public LongList getBlindedNodeGeneralizedIndices() { return GIndexUtil.gIdxComposeAll( diff --git a/ethereum/spec/src/main/java/tech/pegasys/teku/spec/datastructures/blocks/blockbody/versions/capella/BlindedBeaconBlockBodySchemaCapellaImpl.java b/ethereum/spec/src/main/java/tech/pegasys/teku/spec/datastructures/blocks/blockbody/versions/capella/BlindedBeaconBlockBodySchemaCapellaImpl.java index c42ec77e714..41a665a8373 100644 --- a/ethereum/spec/src/main/java/tech/pegasys/teku/spec/datastructures/blocks/blockbody/versions/capella/BlindedBeaconBlockBodySchemaCapellaImpl.java +++ b/ethereum/spec/src/main/java/tech/pegasys/teku/spec/datastructures/blocks/blockbody/versions/capella/BlindedBeaconBlockBodySchemaCapellaImpl.java @@ -13,7 +13,13 @@ package tech.pegasys.teku.spec.datastructures.blocks.blockbody.versions.capella; +import static tech.pegasys.teku.spec.schemas.registry.SchemaTypes.ATTESTATION_SCHEMA; +import static tech.pegasys.teku.spec.schemas.registry.SchemaTypes.ATTESTER_SLASHING_SCHEMA; +import static tech.pegasys.teku.spec.schemas.registry.SchemaTypes.EXECUTION_PAYLOAD_HEADER_SCHEMA; +import static tech.pegasys.teku.spec.schemas.registry.SchemaTypes.SIGNED_BLS_TO_EXECUTION_CHANGE_SCHEMA; + import it.unimi.dsi.fastutil.longs.LongList; +import java.util.Optional; import java.util.function.Function; import tech.pegasys.teku.infrastructure.async.SafeFuture; import tech.pegasys.teku.infrastructure.ssz.SszList; @@ -37,18 +43,10 @@ import tech.pegasys.teku.spec.datastructures.operations.Deposit; import tech.pegasys.teku.spec.datastructures.operations.ProposerSlashing; import tech.pegasys.teku.spec.datastructures.operations.SignedBlsToExecutionChange; -import tech.pegasys.teku.spec.datastructures.operations.SignedBlsToExecutionChangeSchema; import tech.pegasys.teku.spec.datastructures.operations.SignedVoluntaryExit; -import tech.pegasys.teku.spec.datastructures.operations.versions.phase0.AttestationPhase0Schema; import tech.pegasys.teku.spec.datastructures.type.SszSignature; import tech.pegasys.teku.spec.datastructures.type.SszSignatureSchema; import tech.pegasys.teku.spec.schemas.registry.SchemaRegistry; -import tech.pegasys.teku.spec.schemas.registry.SchemaTypes; - -import static tech.pegasys.teku.spec.schemas.registry.SchemaTypes.ATTESTATION_SCHEMA; -import static tech.pegasys.teku.spec.schemas.registry.SchemaTypes.ATTESTER_SLASHING_SCHEMA; -import static tech.pegasys.teku.spec.schemas.registry.SchemaTypes.EXECUTION_PAYLOAD_HEADER_SCHEMA; -import static tech.pegasys.teku.spec.schemas.registry.SchemaTypes.SIGNED_BLS_TO_EXECUTION_CHANGE_SCHEMA; public class BlindedBeaconBlockBodySchemaCapellaImpl extends ContainerSchema11< @@ -115,8 +113,7 @@ public static BlindedBeaconBlockBodySchemaCapellaImpl create( namedSchema( BlockBodyFields.ATTESTATIONS, SszListSchema.create( - schemaRegistry.get(ATTESTATION_SCHEMA), - specConfig.getMaxAttestations())), + schemaRegistry.get(ATTESTATION_SCHEMA), specConfig.getMaxAttestations())), namedSchema( BlockBodyFields.DEPOSITS, SszListSchema.create(Deposit.SSZ_SCHEMA, specConfig.getMaxDeposits())), @@ -133,7 +130,8 @@ public static BlindedBeaconBlockBodySchemaCapellaImpl create( namedSchema( BlockBodyFields.BLS_TO_EXECUTION_CHANGES, SszListSchema.create( - schemaRegistry.get(SIGNED_BLS_TO_EXECUTION_CHANGE_SCHEMA), specConfig.getMaxBlsToExecutionChanges()))); + schemaRegistry.get(SIGNED_BLS_TO_EXECUTION_CHANGE_SCHEMA), + specConfig.getMaxBlsToExecutionChanges()))); } @Override @@ -199,6 +197,11 @@ public ExecutionPayloadHeaderSchemaCapella getExecutionPayloadHeaderSchema() { return (SszListSchema) getFieldSchema10(); } + @Override + public Optional> toBlindedVersionCapella() { + return Optional.of(this); + } + @Override public LongList getBlindedNodeGeneralizedIndices() { return GIndexUtil.gIdxComposeAll( diff --git a/ethereum/spec/src/main/java/tech/pegasys/teku/spec/datastructures/blocks/blockbody/versions/deneb/BlindedBeaconBlockBodySchemaDenebImpl.java b/ethereum/spec/src/main/java/tech/pegasys/teku/spec/datastructures/blocks/blockbody/versions/deneb/BlindedBeaconBlockBodySchemaDenebImpl.java index 15bf7d4f678..603dd571d64 100644 --- a/ethereum/spec/src/main/java/tech/pegasys/teku/spec/datastructures/blocks/blockbody/versions/deneb/BlindedBeaconBlockBodySchemaDenebImpl.java +++ b/ethereum/spec/src/main/java/tech/pegasys/teku/spec/datastructures/blocks/blockbody/versions/deneb/BlindedBeaconBlockBodySchemaDenebImpl.java @@ -14,6 +14,7 @@ package tech.pegasys.teku.spec.datastructures.blocks.blockbody.versions.deneb; import it.unimi.dsi.fastutil.longs.LongList; +import java.util.Optional; import java.util.function.Function; import tech.pegasys.teku.infrastructure.async.SafeFuture; import tech.pegasys.teku.infrastructure.ssz.SszList; @@ -223,4 +224,9 @@ public LongList getBlindedNodeGeneralizedIndices() { getChildGeneralizedIndex(getFieldIndex(BlockBodyFields.EXECUTION_PAYLOAD_HEADER)), getExecutionPayloadHeaderSchema().getBlindedNodeGeneralizedIndices()); } + + @Override + public Optional> toBlindedVersionDeneb() { + return Optional.of(this); + } } 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 76c96f447cc..30d3a53e5f2 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 @@ -13,7 +13,14 @@ package tech.pegasys.teku.spec.datastructures.blocks.blockbody.versions.electra; +import static tech.pegasys.teku.spec.schemas.registry.SchemaTypes.ATTESTATION_SCHEMA; +import static tech.pegasys.teku.spec.schemas.registry.SchemaTypes.BLOB_KZG_COMMITMENTS_SCHEMA; +import static tech.pegasys.teku.spec.schemas.registry.SchemaTypes.EXECUTION_PAYLOAD_HEADER_SCHEMA; +import static tech.pegasys.teku.spec.schemas.registry.SchemaTypes.EXECUTION_REQUESTS_SCHEMA; +import static tech.pegasys.teku.spec.schemas.registry.SchemaTypes.SIGNED_BLS_TO_EXECUTION_CHANGE_SCHEMA; + import it.unimi.dsi.fastutil.longs.LongList; +import java.util.Optional; import java.util.function.Function; import tech.pegasys.teku.infrastructure.async.SafeFuture; import tech.pegasys.teku.infrastructure.ssz.SszList; @@ -24,7 +31,6 @@ import tech.pegasys.teku.infrastructure.ssz.tree.GIndexUtil; import tech.pegasys.teku.infrastructure.ssz.tree.TreeNode; import tech.pegasys.teku.spec.config.SpecConfigElectra; -import tech.pegasys.teku.spec.datastructures.blobs.versions.deneb.BlobKzgCommitmentsSchema; 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.BeaconBlockBodyBuilder; @@ -40,9 +46,7 @@ import tech.pegasys.teku.spec.datastructures.operations.Deposit; import tech.pegasys.teku.spec.datastructures.operations.ProposerSlashing; import tech.pegasys.teku.spec.datastructures.operations.SignedBlsToExecutionChange; -import tech.pegasys.teku.spec.datastructures.operations.SignedBlsToExecutionChangeSchema; import tech.pegasys.teku.spec.datastructures.operations.SignedVoluntaryExit; -import tech.pegasys.teku.spec.datastructures.operations.versions.electra.AttestationElectraSchema; import tech.pegasys.teku.spec.datastructures.type.SszKZGCommitment; import tech.pegasys.teku.spec.datastructures.type.SszSignature; import tech.pegasys.teku.spec.datastructures.type.SszSignatureSchema; @@ -101,10 +105,6 @@ private BlindedBeaconBlockBodySchemaElectraImpl( public static BlindedBeaconBlockBodySchemaElectraImpl create( final SpecConfigElectra specConfig, - final SignedBlsToExecutionChangeSchema signedBlsToExecutionChangeSchema, - final BlobKzgCommitmentsSchema blobKzgCommitmentsSchema, - final ExecutionRequestsSchema executionRequestsSchema, - final long maxValidatorsPerAttestation, final String containerName, final SchemaRegistry schemaRegistry) { return new BlindedBeaconBlockBodySchemaElectraImpl( @@ -124,10 +124,7 @@ public static BlindedBeaconBlockBodySchemaElectraImpl create( namedSchema( BlockBodyFields.ATTESTATIONS, SszListSchema.create( - new AttestationElectraSchema( - maxValidatorsPerAttestation, specConfig.getMaxCommitteesPerSlot()) - .castTypeToAttestationSchema(), - specConfig.getMaxAttestationsElectra())), + schemaRegistry.get(ATTESTATION_SCHEMA), specConfig.getMaxAttestationsElectra())), namedSchema( BlockBodyFields.DEPOSITS, SszListSchema.create(Deposit.SSZ_SCHEMA, specConfig.getMaxDeposits())), @@ -140,13 +137,16 @@ public static BlindedBeaconBlockBodySchemaElectraImpl create( SyncAggregateSchema.create(specConfig.getSyncCommitteeSize())), namedSchema( BlockBodyFields.EXECUTION_PAYLOAD_HEADER, - new ExecutionPayloadHeaderSchemaDeneb(specConfig)), + schemaRegistry.get(EXECUTION_PAYLOAD_HEADER_SCHEMA).toVersionDenebRequired()), namedSchema( BlockBodyFields.BLS_TO_EXECUTION_CHANGES, SszListSchema.create( - signedBlsToExecutionChangeSchema, specConfig.getMaxBlsToExecutionChanges())), - namedSchema(BlockBodyFields.BLOB_KZG_COMMITMENTS, blobKzgCommitmentsSchema), - namedSchema(BlockBodyFields.EXECUTION_REQUESTS, executionRequestsSchema)); + schemaRegistry.get(SIGNED_BLS_TO_EXECUTION_CHANGE_SCHEMA), + specConfig.getMaxBlsToExecutionChanges())), + namedSchema( + BlockBodyFields.BLOB_KZG_COMMITMENTS, schemaRegistry.get(BLOB_KZG_COMMITMENTS_SCHEMA)), + namedSchema( + BlockBodyFields.EXECUTION_REQUESTS, schemaRegistry.get(EXECUTION_REQUESTS_SCHEMA))); } @Override @@ -237,4 +237,9 @@ public LongList getBlindedNodeGeneralizedIndices() { getChildGeneralizedIndex(getFieldIndex(BlockBodyFields.EXECUTION_PAYLOAD_HEADER)), getExecutionPayloadHeaderSchema().getBlindedNodeGeneralizedIndices()); } + + @Override + public Optional> toBlindedVersionElectra() { + return Optional.of(this); + } } diff --git a/ethereum/spec/src/main/java/tech/pegasys/teku/spec/schemas/SchemaDefinitionsAltair.java b/ethereum/spec/src/main/java/tech/pegasys/teku/spec/schemas/SchemaDefinitionsAltair.java index 400bb621069..13c69f96e07 100644 --- a/ethereum/spec/src/main/java/tech/pegasys/teku/spec/schemas/SchemaDefinitionsAltair.java +++ b/ethereum/spec/src/main/java/tech/pegasys/teku/spec/schemas/SchemaDefinitionsAltair.java @@ -15,7 +15,9 @@ import static tech.pegasys.teku.spec.schemas.registry.SchemaTypes.AGGREGATE_AND_PROOF_SCHEMA; import static tech.pegasys.teku.spec.schemas.registry.SchemaTypes.BEACON_BLOCK_BODY_SCHEMA; +import static tech.pegasys.teku.spec.schemas.registry.SchemaTypes.BEACON_BLOCK_SCHEMA; import static tech.pegasys.teku.spec.schemas.registry.SchemaTypes.SIGNED_AGGREGATE_AND_PROOF_SCHEMA; +import static tech.pegasys.teku.spec.schemas.registry.SchemaTypes.SIGNED_BEACON_BLOCK_SCHEMA; import com.google.common.base.Preconditions; import java.util.Optional; @@ -30,7 +32,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.BeaconBlockBodyBuilderAltair; -import tech.pegasys.teku.spec.datastructures.blocks.blockbody.versions.altair.BeaconBlockBodySchemaAltairImpl; import tech.pegasys.teku.spec.datastructures.lightclient.LightClientBootstrapSchema; import tech.pegasys.teku.spec.datastructures.lightclient.LightClientHeaderSchema; import tech.pegasys.teku.spec.datastructures.lightclient.LightClientUpdateResponseSchema; @@ -83,9 +84,8 @@ public SchemaDefinitionsAltair(final SchemaRegistry schemaRegistry) { this.signedAggregateAndProofSchema = schemaRegistry.get(SIGNED_AGGREGATE_AND_PROOF_SCHEMA); this.beaconStateSchema = BeaconStateSchemaAltair.create(specConfig); this.beaconBlockBodySchema = schemaRegistry.get(BEACON_BLOCK_BODY_SCHEMA); - this.beaconBlockSchema = new BeaconBlockSchema(beaconBlockBodySchema, "BeaconBlockAltair"); - this.signedBeaconBlockSchema = - new SignedBeaconBlockSchema(beaconBlockSchema, "SignedBeaconBlockAltair"); + this.beaconBlockSchema = schemaRegistry.get(BEACON_BLOCK_SCHEMA); + this.signedBeaconBlockSchema = schemaRegistry.get(SIGNED_BEACON_BLOCK_SCHEMA); this.syncCommitteeContributionSchema = SyncCommitteeContributionSchema.create(specConfig); this.contributionAndProofSchema = ContributionAndProofSchema.create(syncCommitteeContributionSchema); diff --git a/ethereum/spec/src/main/java/tech/pegasys/teku/spec/schemas/SchemaDefinitionsBellatrix.java b/ethereum/spec/src/main/java/tech/pegasys/teku/spec/schemas/SchemaDefinitionsBellatrix.java index 6010287d6f4..aaf69cf8e18 100644 --- a/ethereum/spec/src/main/java/tech/pegasys/teku/spec/schemas/SchemaDefinitionsBellatrix.java +++ b/ethereum/spec/src/main/java/tech/pegasys/teku/spec/schemas/SchemaDefinitionsBellatrix.java @@ -15,8 +15,10 @@ import static com.google.common.base.Preconditions.checkArgument; import static tech.pegasys.teku.spec.schemas.registry.SchemaTypes.BLINDED_BEACON_BLOCK_BODY_SCHEMA; +import static tech.pegasys.teku.spec.schemas.registry.SchemaTypes.BLINDED_BEACON_BLOCK_SCHEMA; import static tech.pegasys.teku.spec.schemas.registry.SchemaTypes.EXECUTION_PAYLOAD_HEADER_SCHEMA; import static tech.pegasys.teku.spec.schemas.registry.SchemaTypes.EXECUTION_PAYLOAD_SCHEMA; +import static tech.pegasys.teku.spec.schemas.registry.SchemaTypes.SIGNED_BLINDED_BEACON_BLOCK_SCHEMA; import java.util.Optional; import tech.pegasys.teku.spec.config.SpecConfigBellatrix; @@ -29,9 +31,7 @@ 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.bellatrix.BeaconBlockBodyBuilderBellatrix; -import tech.pegasys.teku.spec.datastructures.blocks.blockbody.versions.bellatrix.BeaconBlockBodySchemaBellatrixImpl; import tech.pegasys.teku.spec.datastructures.blocks.blockbody.versions.bellatrix.BlindedBeaconBlockBodySchemaBellatrix; -import tech.pegasys.teku.spec.datastructures.blocks.blockbody.versions.bellatrix.BlindedBeaconBlockBodySchemaBellatrixImpl; import tech.pegasys.teku.spec.datastructures.builder.BuilderBidSchema; import tech.pegasys.teku.spec.datastructures.builder.BuilderPayloadSchema; import tech.pegasys.teku.spec.datastructures.builder.SignedBuilderBidSchema; @@ -49,7 +49,6 @@ public class SchemaDefinitionsBellatrix extends SchemaDefinitionsAltair { private final ExecutionPayloadSchema executionPayloadSchema; private final BlindedBeaconBlockBodySchemaBellatrix blindedBeaconBlockBodySchema; private final BeaconBlockSchema blindedBeaconBlockSchema; - private final SignedBeaconBlockSchema signedBeaconBlockSchema; private final SignedBeaconBlockSchema signedBlindedBeaconBlockSchema; private final ExecutionPayloadHeaderSchema executionPayloadHeaderSchema; private final BuilderBidSchema builderBidSchema; @@ -63,12 +62,8 @@ public SchemaDefinitionsBellatrix(final SchemaRegistry schemaRegistry) { this.executionPayloadSchema = schemaRegistry.get(EXECUTION_PAYLOAD_SCHEMA); this.executionPayloadHeaderSchema = schemaRegistry.get(EXECUTION_PAYLOAD_HEADER_SCHEMA); this.blindedBeaconBlockBodySchema = schemaRegistry.get(BLINDED_BEACON_BLOCK_BODY_SCHEMA); - this.blindedBeaconBlockSchema = - new BeaconBlockSchema(blindedBeaconBlockBodySchema, "BlindedBlockBellatrix"); - this.signedBeaconBlockSchema = - new SignedBeaconBlockSchema(beaconBlockSchema, "SignedBeaconBlockBellatrix"); - this.signedBlindedBeaconBlockSchema = - new SignedBeaconBlockSchema(blindedBeaconBlockSchema, "SignedBlindedBlockBellatrix"); + this.blindedBeaconBlockSchema = schemaRegistry.get(BLINDED_BEACON_BLOCK_SCHEMA); + this.signedBlindedBeaconBlockSchema = schemaRegistry.get(SIGNED_BLINDED_BEACON_BLOCK_SCHEMA); this.builderBidSchema = new BuilderBidSchemaBellatrix("BuilderBidBellatrix", executionPayloadHeaderSchema); this.signedBuilderBidSchema = @@ -90,11 +85,6 @@ public static SchemaDefinitionsBellatrix required(final SchemaDefinitions schema return beaconStateSchema; } - @Override - public SignedBeaconBlockSchema getSignedBeaconBlockSchema() { - return signedBeaconBlockSchema; - } - @Override public BeaconBlockSchema getBlindedBeaconBlockSchema() { return blindedBeaconBlockSchema; @@ -110,17 +100,11 @@ public SignedBeaconBlockSchema getSignedBlindedBeaconBlockSchema() { return signedBlindedBeaconBlockSchema; } - @Override public BlockContainerSchema getBlindedBlockContainerSchema() { return getBlindedBeaconBlockSchema().castTypeToBlockContainer(); } - @Override - public SignedBlockContainerSchema getSignedBlockContainerSchema() { - return getSignedBeaconBlockSchema().castTypeToSignedBlockContainer(); - } - @Override public SignedBlockContainerSchema getSignedBlindedBlockContainerSchema() { return getSignedBlindedBeaconBlockSchema().castTypeToSignedBlockContainer(); @@ -128,7 +112,9 @@ public SignedBlockContainerSchema getSignedBlindedBlockCon @Override public BeaconBlockBodyBuilder createBeaconBlockBodyBuilder() { - return new BeaconBlockBodyBuilderBellatrix(getBeaconBlockBodySchema().toVersionBellatrix().orElseThrow(), blindedBeaconBlockBodySchema); + return new BeaconBlockBodyBuilderBellatrix( + getBeaconBlockBodySchema().toVersionBellatrix().orElseThrow(), + blindedBeaconBlockBodySchema); } public ExecutionPayloadSchema getExecutionPayloadSchema() { diff --git a/ethereum/spec/src/main/java/tech/pegasys/teku/spec/schemas/SchemaDefinitionsCapella.java b/ethereum/spec/src/main/java/tech/pegasys/teku/spec/schemas/SchemaDefinitionsCapella.java index f203a4ac990..b58434a1e57 100644 --- a/ethereum/spec/src/main/java/tech/pegasys/teku/spec/schemas/SchemaDefinitionsCapella.java +++ b/ethereum/spec/src/main/java/tech/pegasys/teku/spec/schemas/SchemaDefinitionsCapella.java @@ -21,24 +21,13 @@ import java.util.Optional; import tech.pegasys.teku.spec.config.SpecConfigCapella; -import tech.pegasys.teku.spec.datastructures.blocks.BeaconBlockSchema; -import tech.pegasys.teku.spec.datastructures.blocks.BlockContainer; -import tech.pegasys.teku.spec.datastructures.blocks.BlockContainerSchema; -import tech.pegasys.teku.spec.datastructures.blocks.SignedBeaconBlockSchema; -import tech.pegasys.teku.spec.datastructures.blocks.SignedBlockContainer; -import tech.pegasys.teku.spec.datastructures.blocks.SignedBlockContainerSchema; 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.capella.BeaconBlockBodyBuilderCapella; -import tech.pegasys.teku.spec.datastructures.blocks.blockbody.versions.capella.BeaconBlockBodySchemaCapellaImpl; -import tech.pegasys.teku.spec.datastructures.blocks.blockbody.versions.capella.BlindedBeaconBlockBodySchemaCapellaImpl; import tech.pegasys.teku.spec.datastructures.builder.BuilderBidSchema; import tech.pegasys.teku.spec.datastructures.builder.SignedBuilderBidSchema; import tech.pegasys.teku.spec.datastructures.builder.versions.bellatrix.BuilderBidSchemaBellatrix; import tech.pegasys.teku.spec.datastructures.execution.ExecutionPayloadHeaderSchema; -import tech.pegasys.teku.spec.datastructures.execution.ExecutionPayloadSchema; import tech.pegasys.teku.spec.datastructures.execution.versions.capella.ExecutionPayloadHeaderSchemaCapella; -import tech.pegasys.teku.spec.datastructures.execution.versions.capella.ExecutionPayloadSchemaCapella; import tech.pegasys.teku.spec.datastructures.execution.versions.capella.WithdrawalSchema; import tech.pegasys.teku.spec.datastructures.operations.BlsToExecutionChangeSchema; import tech.pegasys.teku.spec.datastructures.operations.SignedBlsToExecutionChangeSchema; @@ -53,14 +42,8 @@ public class SchemaDefinitionsCapella extends SchemaDefinitionsBellatrix { private final BeaconStateSchemaCapella beaconStateSchema; - private final ExecutionPayloadSchemaCapella executionPayloadSchemaCapella; private final ExecutionPayloadHeaderSchemaCapella executionPayloadHeaderSchemaCapella; - private final BeaconBlockSchema beaconBlockSchema; - private final BeaconBlockSchema blindedBeaconBlockSchema; - private final SignedBeaconBlockSchema signedBeaconBlockSchema; - private final SignedBeaconBlockSchema signedBlindedBeaconBlockSchema; - private final WithdrawalSchema withdrawalSchema; private final BlsToExecutionChangeSchema blsToExecutionChangeSchema; @@ -75,7 +58,6 @@ public SchemaDefinitionsCapella(final SchemaRegistry schemaRegistry) { super(schemaRegistry); final SpecConfigCapella specConfig = SpecConfigCapella.required(schemaRegistry.getSpecConfig()); this.historicalSummarySchema = schemaRegistry.get(HISTORICAL_SUMMARY_SCHEMA); - this.executionPayloadSchemaCapella = new ExecutionPayloadSchemaCapella(specConfig); this.blsToExecutionChangeSchema = schemaRegistry.get(BLS_TO_EXECUTION_CHANGE_SCHEMA); this.signedBlsToExecutionChangeSchema = schemaRegistry.get(SIGNED_BLS_TO_EXECUTION_CHANGE_SCHEMA); @@ -84,13 +66,6 @@ public SchemaDefinitionsCapella(final SchemaRegistry schemaRegistry) { this.beaconStateSchema = BeaconStateSchemaCapella.create(specConfig); this.executionPayloadHeaderSchemaCapella = beaconStateSchema.getLastExecutionPayloadHeaderSchema(); - this.beaconBlockSchema = new BeaconBlockSchema(beaconBlockBodySchema, "BeaconBlockCapella"); - this.blindedBeaconBlockSchema = - new BeaconBlockSchema(blindedBeaconBlockBodySchema, "BlindedBlockCapella"); - this.signedBeaconBlockSchema = - new SignedBeaconBlockSchema(beaconBlockSchema, "SignedBeaconBlockCapella"); - this.signedBlindedBeaconBlockSchema = - new SignedBeaconBlockSchema(blindedBeaconBlockSchema, "SignedBlindedBlockCapella"); this.builderBidSchemaCapella = new BuilderBidSchemaBellatrix("BuilderBidCapella", executionPayloadHeaderSchemaCapella); this.signedBuilderBidSchemaCapella = @@ -112,51 +87,6 @@ public static SchemaDefinitionsCapella required(final SchemaDefinitions schemaDe return beaconStateSchema; } - @Override - public BeaconBlockSchema getBeaconBlockSchema() { - return beaconBlockSchema; - } - - @Override - public BeaconBlockSchema getBlindedBeaconBlockSchema() { - return blindedBeaconBlockSchema; - } - - @Override - public SignedBeaconBlockSchema getSignedBeaconBlockSchema() { - return signedBeaconBlockSchema; - } - - @Override - public SignedBeaconBlockSchema getSignedBlindedBeaconBlockSchema() { - return signedBlindedBeaconBlockSchema; - } - - @Override - public BlockContainerSchema getBlockContainerSchema() { - return getBeaconBlockSchema().castTypeToBlockContainer(); - } - - @Override - public BlockContainerSchema getBlindedBlockContainerSchema() { - return getBlindedBeaconBlockSchema().castTypeToBlockContainer(); - } - - @Override - public SignedBlockContainerSchema getSignedBlockContainerSchema() { - return getSignedBeaconBlockSchema().castTypeToSignedBlockContainer(); - } - - @Override - public SignedBlockContainerSchema getSignedBlindedBlockContainerSchema() { - return getSignedBlindedBeaconBlockSchema().castTypeToSignedBlockContainer(); - } - - @Override - public ExecutionPayloadSchema getExecutionPayloadSchema() { - return executionPayloadSchemaCapella; - } - @Override public ExecutionPayloadHeaderSchema getExecutionPayloadHeaderSchema() { return executionPayloadHeaderSchemaCapella; @@ -164,7 +94,9 @@ public ExecutionPayloadHeaderSchema getExecutionPayloadHeaderSchema() { @Override public BeaconBlockBodyBuilder createBeaconBlockBodyBuilder() { - return new BeaconBlockBodyBuilderCapella(getBeaconBlockBodySchema().toVersionCapella().orElseThrow(), getBlindedBeaconBlockBodySchema().toVersionCapella().orElseThrow()); + return new BeaconBlockBodyBuilderCapella( + getBeaconBlockBodySchema().toVersionCapella().orElseThrow(), + getBlindedBeaconBlockBodySchema().toBlindedVersionCapella().orElseThrow()); } public WithdrawalSchema getWithdrawalSchema() { 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 bbd559f8ccf..68c5da29e1c 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 @@ -30,17 +30,12 @@ import tech.pegasys.teku.spec.datastructures.blobs.versions.deneb.BlobKzgCommitmentsSchema; 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.blocks.BeaconBlockSchema; import tech.pegasys.teku.spec.datastructures.blocks.BlockContainer; import tech.pegasys.teku.spec.datastructures.blocks.BlockContainerSchema; -import tech.pegasys.teku.spec.datastructures.blocks.SignedBeaconBlockSchema; import tech.pegasys.teku.spec.datastructures.blocks.SignedBlockContainer; import tech.pegasys.teku.spec.datastructures.blocks.SignedBlockContainerSchema; 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.blocks.blockbody.versions.deneb.BeaconBlockBodySchemaDenebImpl; -import tech.pegasys.teku.spec.datastructures.blocks.blockbody.versions.deneb.BlindedBeaconBlockBodySchemaDenebImpl; import tech.pegasys.teku.spec.datastructures.blocks.versions.deneb.BlockContentsSchema; import tech.pegasys.teku.spec.datastructures.blocks.versions.deneb.SignedBlockContentsSchema; import tech.pegasys.teku.spec.datastructures.builder.BlobsBundleSchema; @@ -68,13 +63,6 @@ public class SchemaDefinitionsDeneb extends SchemaDefinitionsCapella { private final BlobKzgCommitmentsSchema blobKzgCommitmentsSchema; - private final BlindedBeaconBlockBodySchemaDenebImpl blindedBeaconBlockBodySchema; - - private final BeaconBlockSchema beaconBlockSchema; - private final BeaconBlockSchema blindedBeaconBlockSchema; - private final SignedBeaconBlockSchema signedBeaconBlockSchema; - private final SignedBeaconBlockSchema signedBlindedBeaconBlockSchema; - private final BuilderBidSchema builderBidSchemaDeneb; private final SignedBuilderBidSchema signedBuilderBidSchemaDeneb; @@ -96,21 +84,6 @@ public SchemaDefinitionsDeneb(final SchemaRegistry schemaRegistry) { this.executionPayloadHeaderSchemaDeneb = beaconStateSchema.getLastExecutionPayloadHeaderSchema(); this.blobKzgCommitmentsSchema = schemaRegistry.get(BLOB_KZG_COMMITMENTS_SCHEMA); - this.blindedBeaconBlockBodySchema = - BlindedBeaconBlockBodySchemaDenebImpl.create( - specConfig, - getSignedBlsToExecutionChangeSchema(), - blobKzgCommitmentsSchema, - getMaxValidatorsPerAttestation(specConfig), - "BlindedBlockBodyDeneb", - schemaRegistry); - this.beaconBlockSchema = new BeaconBlockSchema(beaconBlockBodySchema, "BeaconBlockDeneb"); - this.blindedBeaconBlockSchema = - new BeaconBlockSchema(blindedBeaconBlockBodySchema, "BlindedBlockDeneb"); - this.signedBeaconBlockSchema = - new SignedBeaconBlockSchema(beaconBlockSchema, "SignedBeaconBlockDeneb"); - this.signedBlindedBeaconBlockSchema = - new SignedBeaconBlockSchema(blindedBeaconBlockSchema, "SignedBlindedBlockDeneb"); this.builderBidSchemaDeneb = new BuilderBidSchemaDeneb( "BuilderBidDeneb", executionPayloadHeaderSchemaDeneb, blobKzgCommitmentsSchema); @@ -121,10 +94,11 @@ public SchemaDefinitionsDeneb(final SchemaRegistry schemaRegistry) { this.blobsInBlockSchema = schemaRegistry.get(BLOBS_IN_BLOCK_SCHEMA); this.blobSidecarSchema = schemaRegistry.get(BLOB_SIDECAR_SCHEMA); this.blockContentsSchema = - BlockContentsSchema.create(specConfig, beaconBlockSchema, blobSchema, "BlockContentsDeneb"); + BlockContentsSchema.create( + specConfig, getBeaconBlockSchema(), blobSchema, "BlockContentsDeneb"); this.signedBlockContentsSchema = SignedBlockContentsSchema.create( - specConfig, signedBeaconBlockSchema, blobSchema, "SignedBlockContentsDeneb"); + specConfig, getSignedBeaconBlockSchema(), blobSchema, "SignedBlockContentsDeneb"); this.blobsBundleSchema = schemaRegistry.get(BLOBS_BUNDLE_SCHEMA); this.executionPayloadAndBlobsBundleSchema = new ExecutionPayloadAndBlobsBundleSchema(executionPayloadSchemaDeneb, blobsBundleSchema); @@ -147,51 +121,16 @@ public static SchemaDefinitionsDeneb required(final SchemaDefinitions schemaDefi return beaconStateSchema; } - @Override - public BeaconBlockBodySchema getBlindedBeaconBlockBodySchema() { - return blindedBeaconBlockBodySchema; - } - - @Override - public BeaconBlockSchema getBeaconBlockSchema() { - return beaconBlockSchema; - } - - @Override - public BeaconBlockSchema getBlindedBeaconBlockSchema() { - return blindedBeaconBlockSchema; - } - - @Override - public SignedBeaconBlockSchema getSignedBeaconBlockSchema() { - return signedBeaconBlockSchema; - } - - @Override - public SignedBeaconBlockSchema getSignedBlindedBeaconBlockSchema() { - return signedBlindedBeaconBlockSchema; - } - @Override public BlockContainerSchema getBlockContainerSchema() { return getBlockContentsSchema().castTypeToBlockContainer(); } - @Override - public BlockContainerSchema getBlindedBlockContainerSchema() { - return getBlindedBeaconBlockSchema().castTypeToBlockContainer(); - } - @Override public SignedBlockContainerSchema getSignedBlockContainerSchema() { return getSignedBlockContentsSchema().castTypeToSignedBlockContainer(); } - @Override - public SignedBlockContainerSchema getSignedBlindedBlockContainerSchema() { - return getSignedBlindedBeaconBlockSchema().castTypeToSignedBlockContainer(); - } - @Override public ExecutionPayloadSchema getExecutionPayloadSchema() { return executionPayloadSchemaDeneb; @@ -219,7 +158,9 @@ public BuilderPayloadSchema getBuilderPayloadSchema() { @Override public BeaconBlockBodyBuilder createBeaconBlockBodyBuilder() { - return new BeaconBlockBodyBuilderDeneb(getBeaconBlockBodySchema().toVersionDeneb().orElseThrow(), blindedBeaconBlockBodySchema); + return new BeaconBlockBodyBuilderDeneb( + getBeaconBlockBodySchema().toVersionDeneb().orElseThrow(), + getBlindedBeaconBlockBodySchema().toBlindedVersionDeneb().orElseThrow()); } public BlobSchema getBlobSchema() { 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 b5a2f91f5ec..378aca177f5 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 @@ -21,17 +21,12 @@ import tech.pegasys.teku.infrastructure.ssz.schema.SszListSchema; import tech.pegasys.teku.spec.config.SpecConfig; import tech.pegasys.teku.spec.config.SpecConfigElectra; -import tech.pegasys.teku.spec.datastructures.blocks.BeaconBlockSchema; import tech.pegasys.teku.spec.datastructures.blocks.BlockContainer; import tech.pegasys.teku.spec.datastructures.blocks.BlockContainerSchema; -import tech.pegasys.teku.spec.datastructures.blocks.SignedBeaconBlockSchema; import tech.pegasys.teku.spec.datastructures.blocks.SignedBlockContainer; import tech.pegasys.teku.spec.datastructures.blocks.SignedBlockContainerSchema; 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.electra.BeaconBlockBodyBuilderElectra; -import tech.pegasys.teku.spec.datastructures.blocks.blockbody.versions.electra.BeaconBlockBodySchemaElectraImpl; -import tech.pegasys.teku.spec.datastructures.blocks.blockbody.versions.electra.BlindedBeaconBlockBodySchemaElectraImpl; import tech.pegasys.teku.spec.datastructures.blocks.versions.deneb.BlockContentsSchema; import tech.pegasys.teku.spec.datastructures.blocks.versions.deneb.SignedBlockContentsSchema; import tech.pegasys.teku.spec.datastructures.builder.BuilderBidSchema; @@ -57,12 +52,6 @@ public class SchemaDefinitionsElectra extends SchemaDefinitionsDeneb { private final BeaconStateSchemaElectra beaconStateSchema; - private final BlindedBeaconBlockBodySchemaElectraImpl blindedBeaconBlockBodySchema; - - private final BeaconBlockSchema beaconBlockSchema; - private final BeaconBlockSchema blindedBeaconBlockSchema; - private final SignedBeaconBlockSchema signedBeaconBlockSchema; - private final SignedBeaconBlockSchema signedBlindedBeaconBlockSchema; private final BuilderBidSchema builderBidSchemaElectra; private final SignedBuilderBidSchema signedBuilderBidSchemaElectra; @@ -86,26 +75,9 @@ public SchemaDefinitionsElectra(final SchemaRegistry schemaRegistry) { super(schemaRegistry); final SpecConfigElectra specConfig = SpecConfigElectra.required(schemaRegistry.getSpecConfig()); - final long maxValidatorsPerAttestation = getMaxValidatorsPerAttestation(specConfig); - this.executionRequestsSchema = schemaRegistry.get(EXECUTION_REQUESTS_SCHEMA); this.beaconStateSchema = BeaconStateSchemaElectra.create(specConfig); - this.blindedBeaconBlockBodySchema = - BlindedBeaconBlockBodySchemaElectraImpl.create( - specConfig, - getSignedBlsToExecutionChangeSchema(), - getBlobKzgCommitmentsSchema(), - getExecutionRequestsSchema(), - maxValidatorsPerAttestation, - "BlindedBlockBodyElectra", - schemaRegistry); - this.beaconBlockSchema = new BeaconBlockSchema(beaconBlockBodySchema, "BeaconBlockElectra"); - this.blindedBeaconBlockSchema = - new BeaconBlockSchema(blindedBeaconBlockBodySchema, "BlindedBlockElectra"); - this.signedBeaconBlockSchema = - new SignedBeaconBlockSchema(beaconBlockSchema, "SignedBeaconBlockElectra"); - this.signedBlindedBeaconBlockSchema = - new SignedBeaconBlockSchema(blindedBeaconBlockSchema, "SignedBlindedBlockElectra"); + this.builderBidSchemaElectra = new BuilderBidSchemaElectra( "BuilderBidElectra", @@ -117,10 +89,13 @@ public SchemaDefinitionsElectra(final SchemaRegistry schemaRegistry) { this.blockContentsSchema = BlockContentsSchema.create( - specConfig, beaconBlockSchema, getBlobSchema(), "BlockContentsElectra"); + specConfig, getBeaconBlockSchema(), getBlobSchema(), "BlockContentsElectra"); this.signedBlockContentsSchema = SignedBlockContentsSchema.create( - specConfig, signedBeaconBlockSchema, getBlobSchema(), "SignedBlockContentsElectra"); + specConfig, + getSignedBeaconBlockSchema(), + getBlobSchema(), + "SignedBlockContentsElectra"); this.executionPayloadAndBlobsBundleSchema = new ExecutionPayloadAndBlobsBundleSchema( getExecutionPayloadSchema(), schemaRegistry.get(BLOBS_BUNDLE_SCHEMA)); @@ -149,51 +124,16 @@ public static SchemaDefinitionsElectra required(final SchemaDefinitions schemaDe return beaconStateSchema; } - @Override - public BeaconBlockBodySchema getBlindedBeaconBlockBodySchema() { - return blindedBeaconBlockBodySchema; - } - - @Override - public BeaconBlockSchema getBeaconBlockSchema() { - return beaconBlockSchema; - } - - @Override - public BeaconBlockSchema getBlindedBeaconBlockSchema() { - return blindedBeaconBlockSchema; - } - - @Override - public SignedBeaconBlockSchema getSignedBeaconBlockSchema() { - return signedBeaconBlockSchema; - } - - @Override - public SignedBeaconBlockSchema getSignedBlindedBeaconBlockSchema() { - return signedBlindedBeaconBlockSchema; - } - @Override public BlockContainerSchema getBlockContainerSchema() { return getBlockContentsSchema().castTypeToBlockContainer(); } - @Override - public BlockContainerSchema getBlindedBlockContainerSchema() { - return getBlindedBeaconBlockSchema().castTypeToBlockContainer(); - } - @Override public SignedBlockContainerSchema getSignedBlockContainerSchema() { return getSignedBlockContentsSchema().castTypeToSignedBlockContainer(); } - @Override - public SignedBlockContainerSchema getSignedBlindedBlockContainerSchema() { - return getSignedBlindedBeaconBlockSchema().castTypeToSignedBlockContainer(); - } - @Override public BuilderBidSchema getBuilderBidSchema() { return builderBidSchemaElectra; @@ -211,7 +151,9 @@ public BuilderPayloadSchema getBuilderPayloadSchema() { @Override public BeaconBlockBodyBuilder createBeaconBlockBodyBuilder() { - return new BeaconBlockBodyBuilderElectra(getBeaconBlockBodySchema().toVersionElectra().orElseThrow(), blindedBeaconBlockBodySchema); + return new BeaconBlockBodyBuilderElectra( + getBeaconBlockBodySchema().toVersionElectra().orElseThrow(), + getBlindedBeaconBlockBodySchema().toBlindedVersionElectra().orElseThrow()); } @Override diff --git a/ethereum/spec/src/main/java/tech/pegasys/teku/spec/schemas/SchemaDefinitionsPhase0.java b/ethereum/spec/src/main/java/tech/pegasys/teku/spec/schemas/SchemaDefinitionsPhase0.java index 8d4e64d0f29..d84275d06ab 100644 --- a/ethereum/spec/src/main/java/tech/pegasys/teku/spec/schemas/SchemaDefinitionsPhase0.java +++ b/ethereum/spec/src/main/java/tech/pegasys/teku/spec/schemas/SchemaDefinitionsPhase0.java @@ -15,7 +15,9 @@ import static tech.pegasys.teku.spec.schemas.registry.SchemaTypes.AGGREGATE_AND_PROOF_SCHEMA; import static tech.pegasys.teku.spec.schemas.registry.SchemaTypes.BEACON_BLOCK_BODY_SCHEMA; +import static tech.pegasys.teku.spec.schemas.registry.SchemaTypes.BEACON_BLOCK_SCHEMA; import static tech.pegasys.teku.spec.schemas.registry.SchemaTypes.SIGNED_AGGREGATE_AND_PROOF_SCHEMA; +import static tech.pegasys.teku.spec.schemas.registry.SchemaTypes.SIGNED_BEACON_BLOCK_SCHEMA; import java.util.Optional; import tech.pegasys.teku.spec.config.SpecConfig; @@ -28,7 +30,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.phase0.BeaconBlockBodyBuilderPhase0; -import tech.pegasys.teku.spec.datastructures.blocks.blockbody.versions.phase0.BeaconBlockBodySchemaPhase0; import tech.pegasys.teku.spec.datastructures.networking.libp2p.rpc.metadata.versions.phase0.MetadataMessageSchemaPhase0; import tech.pegasys.teku.spec.datastructures.operations.AggregateAndProof.AggregateAndProofSchema; import tech.pegasys.teku.spec.datastructures.operations.Attestation; @@ -65,9 +66,8 @@ public SchemaDefinitionsPhase0(final SchemaRegistry schemaRegistry) { this.beaconStateSchema = BeaconStateSchemaPhase0.create(specConfig); this.beaconBlockBodySchema = schemaRegistry.get(BEACON_BLOCK_BODY_SCHEMA); this.metadataMessageSchema = new MetadataMessageSchemaPhase0(specConfig.getNetworkingConfig()); - beaconBlockSchema = new BeaconBlockSchema(beaconBlockBodySchema, "BeaconBlockPhase0"); - signedBeaconBlockSchema = - new SignedBeaconBlockSchema(beaconBlockSchema, "SignedBeaconBlockPhase0"); + this.beaconBlockSchema = schemaRegistry.get(BEACON_BLOCK_SCHEMA); + this.signedBeaconBlockSchema = schemaRegistry.get(SIGNED_BEACON_BLOCK_SCHEMA); } @Override diff --git a/ethereum/spec/src/main/java/tech/pegasys/teku/spec/schemas/registry/SchemaRegistryBuilder.java b/ethereum/spec/src/main/java/tech/pegasys/teku/spec/schemas/registry/SchemaRegistryBuilder.java index 6f66db014b8..d7c41ba328c 100644 --- a/ethereum/spec/src/main/java/tech/pegasys/teku/spec/schemas/registry/SchemaRegistryBuilder.java +++ b/ethereum/spec/src/main/java/tech/pegasys/teku/spec/schemas/registry/SchemaRegistryBuilder.java @@ -27,7 +27,9 @@ import static tech.pegasys.teku.spec.schemas.registry.SchemaTypes.ATTNETS_ENR_FIELD_SCHEMA; import static tech.pegasys.teku.spec.schemas.registry.SchemaTypes.BEACON_BLOCKS_BY_ROOT_REQUEST_MESSAGE_SCHEMA; import static tech.pegasys.teku.spec.schemas.registry.SchemaTypes.BEACON_BLOCK_BODY_SCHEMA; +import static tech.pegasys.teku.spec.schemas.registry.SchemaTypes.BEACON_BLOCK_SCHEMA; import static tech.pegasys.teku.spec.schemas.registry.SchemaTypes.BLINDED_BEACON_BLOCK_BODY_SCHEMA; +import static tech.pegasys.teku.spec.schemas.registry.SchemaTypes.BLINDED_BEACON_BLOCK_SCHEMA; import static tech.pegasys.teku.spec.schemas.registry.SchemaTypes.BLOBS_BUNDLE_SCHEMA; import static tech.pegasys.teku.spec.schemas.registry.SchemaTypes.BLOBS_IN_BLOCK_SCHEMA; import static tech.pegasys.teku.spec.schemas.registry.SchemaTypes.BLOB_KZG_COMMITMENTS_SCHEMA; @@ -42,6 +44,8 @@ import static tech.pegasys.teku.spec.schemas.registry.SchemaTypes.HISTORICAL_SUMMARY_SCHEMA; import static tech.pegasys.teku.spec.schemas.registry.SchemaTypes.INDEXED_ATTESTATION_SCHEMA; import static tech.pegasys.teku.spec.schemas.registry.SchemaTypes.SIGNED_AGGREGATE_AND_PROOF_SCHEMA; +import static tech.pegasys.teku.spec.schemas.registry.SchemaTypes.SIGNED_BEACON_BLOCK_SCHEMA; +import static tech.pegasys.teku.spec.schemas.registry.SchemaTypes.SIGNED_BLINDED_BEACON_BLOCK_SCHEMA; import static tech.pegasys.teku.spec.schemas.registry.SchemaTypes.SIGNED_BLS_TO_EXECUTION_CHANGE_SCHEMA; import static tech.pegasys.teku.spec.schemas.registry.SchemaTypes.SYNCNETS_ENR_FIELD_SCHEMA; import static tech.pegasys.teku.spec.schemas.registry.SchemaTypes.WITHDRAWAL_SCHEMA; @@ -61,7 +65,9 @@ import tech.pegasys.teku.spec.datastructures.blobs.versions.deneb.BlobKzgCommitmentsSchema; 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.blocks.BeaconBlockSchema; import tech.pegasys.teku.spec.datastructures.blocks.SignedBeaconBlockHeader; +import tech.pegasys.teku.spec.datastructures.blocks.SignedBeaconBlockSchema; import tech.pegasys.teku.spec.datastructures.blocks.blockbody.versions.altair.BeaconBlockBodySchemaAltairImpl; import tech.pegasys.teku.spec.datastructures.blocks.blockbody.versions.bellatrix.BeaconBlockBodySchemaBellatrixImpl; import tech.pegasys.teku.spec.datastructures.blocks.blockbody.versions.bellatrix.BlindedBeaconBlockBodySchemaBellatrixImpl; @@ -69,6 +75,7 @@ import tech.pegasys.teku.spec.datastructures.blocks.blockbody.versions.capella.BlindedBeaconBlockBodySchemaCapellaImpl; import tech.pegasys.teku.spec.datastructures.blocks.blockbody.versions.deneb.BeaconBlockBodySchemaDenebImpl; import tech.pegasys.teku.spec.datastructures.blocks.blockbody.versions.electra.BeaconBlockBodySchemaElectraImpl; +import tech.pegasys.teku.spec.datastructures.blocks.blockbody.versions.electra.BlindedBeaconBlockBodySchemaElectraImpl; import tech.pegasys.teku.spec.datastructures.blocks.blockbody.versions.phase0.BeaconBlockBodySchemaPhase0; import tech.pegasys.teku.spec.datastructures.builder.BlobsBundleSchema; import tech.pegasys.teku.spec.datastructures.execution.versions.bellatrix.ExecutionPayloadHeaderSchemaBellatrix; @@ -112,10 +119,15 @@ public static SchemaRegistryBuilder create() { .addProvider(createAggregateAndProofSchemaProvider()) .addProvider(createSignedAggregateAndProofSchemaProvider()) .addProvider(createBeaconBlockBodySchemaProvider()) + .addProvider(createBeaconBlockSchemaProvider()) + .addProvider(createSignedBeaconBlockSchemaProvider()) // BELLATRIX .addProvider(createExecutionPayloadSchemaProvider()) .addProvider(createExecutionPayloadHeaderSchemaProvider()) + .addProvider(createBlindedBeaconBlockBodySchemaProvider()) + .addProvider(createBlindedBeaconBlockSchemaProvider()) + .addProvider(createSignedBlindedBeaconBlockSchemaProvider()) // CAPELLA .addProvider(createWithdrawalSchemaProvider()) @@ -135,6 +147,50 @@ public static SchemaRegistryBuilder create() { .addProvider(createExecutionRequestsSchemaProvider()); } + private static SchemaProvider createBlindedBeaconBlockSchemaProvider() { + return providerBuilder(BLINDED_BEACON_BLOCK_SCHEMA) + .withCreator( + PHASE0, + (registry, specConfig) -> + new BeaconBlockSchema( + registry.get(BLINDED_BEACON_BLOCK_BODY_SCHEMA), + BEACON_BLOCK_SCHEMA.getContainerName(registry))) + .build(); + } + + private static SchemaProvider createSignedBlindedBeaconBlockSchemaProvider() { + return providerBuilder(SIGNED_BLINDED_BEACON_BLOCK_SCHEMA) + .withCreator( + PHASE0, + (registry, specConfig) -> + new SignedBeaconBlockSchema( + registry.get(BLINDED_BEACON_BLOCK_SCHEMA), + BEACON_BLOCK_SCHEMA.getContainerName(registry))) + .build(); + } + + private static SchemaProvider createBeaconBlockSchemaProvider() { + return providerBuilder(BEACON_BLOCK_SCHEMA) + .withCreator( + PHASE0, + (registry, specConfig) -> + new BeaconBlockSchema( + registry.get(BEACON_BLOCK_BODY_SCHEMA), + BEACON_BLOCK_SCHEMA.getContainerName(registry))) + .build(); + } + + private static SchemaProvider createSignedBeaconBlockSchemaProvider() { + return providerBuilder(SIGNED_BEACON_BLOCK_SCHEMA) + .withCreator( + PHASE0, + (registry, specConfig) -> + new SignedBeaconBlockSchema( + registry.get(BEACON_BLOCK_SCHEMA), + BEACON_BLOCK_SCHEMA.getContainerName(registry))) + .build(); + } + private static SchemaProvider createExecutionRequestsSchemaProvider() { return providerBuilder(EXECUTION_REQUESTS_SCHEMA) .withCreator( @@ -148,16 +204,25 @@ private static SchemaProvider createBlindedBeaconBlockBodySchemaProvider() { return providerBuilder(BLINDED_BEACON_BLOCK_BODY_SCHEMA) .withCreator( BELLATRIX, - (registry, specConfig) -> BlindedBeaconBlockBodySchemaBellatrixImpl.create( + (registry, specConfig) -> + BlindedBeaconBlockBodySchemaBellatrixImpl.create( SpecConfigBellatrix.required(specConfig), BLINDED_BEACON_BLOCK_BODY_SCHEMA.getContainerName(registry), registry)) - .withCreator( - CAPELLA, - (registry, specConfig) -> BlindedBeaconBlockBodySchemaCapellaImpl.create( - SpecConfigCapella.required(specConfig), - BLINDED_BEACON_BLOCK_BODY_SCHEMA.getContainerName(registry), - registry)) + .withCreator( + CAPELLA, + (registry, specConfig) -> + BlindedBeaconBlockBodySchemaCapellaImpl.create( + SpecConfigCapella.required(specConfig), + BLINDED_BEACON_BLOCK_BODY_SCHEMA.getContainerName(registry), + registry)) + .withCreator( + ELECTRA, + (registry, specConfig) -> + BlindedBeaconBlockBodySchemaElectraImpl.create( + SpecConfigElectra.required(specConfig), + BLINDED_BEACON_BLOCK_BODY_SCHEMA.getContainerName(registry), + registry)) .build(); } diff --git a/ethereum/spec/src/test/java/tech/pegasys/teku/spec/datastructures/blocks/blockbody/versions/phase0/BeaconBlockBodySchemaPhase0Test.java b/ethereum/spec/src/test/java/tech/pegasys/teku/spec/datastructures/blocks/blockbody/versions/phase0/BeaconBlockBodySchemaPhase0Test.java index c1613970362..8db06f2ca5f 100644 --- a/ethereum/spec/src/test/java/tech/pegasys/teku/spec/datastructures/blocks/blockbody/versions/phase0/BeaconBlockBodySchemaPhase0Test.java +++ b/ethereum/spec/src/test/java/tech/pegasys/teku/spec/datastructures/blocks/blockbody/versions/phase0/BeaconBlockBodySchemaPhase0Test.java @@ -29,13 +29,11 @@ public void create_minimal() { final BeaconBlockBodySchemaPhase0 specA = BeaconBlockBodySchemaPhase0.create( specConfig, - specConfig.getMaxValidatorsPerCommittee(), "BeaconBlockBodyPhase0", spec.getGenesisSchemaDefinitions().getSchemaRegistry()); final BeaconBlockBodySchemaPhase0 specB = BeaconBlockBodySchemaPhase0.create( specConfig, - specConfig.getMaxValidatorsPerCommittee(), "BeaconBlockBodyPhase0", spec.getGenesisSchemaDefinitions().getSchemaRegistry()); @@ -49,13 +47,11 @@ public void create_mainnet() { final BeaconBlockBodySchemaPhase0 specA = BeaconBlockBodySchemaPhase0.create( specConfig, - specConfig.getMaxValidatorsPerCommittee(), "BeaconBlockBodyPhase0", spec.getGenesisSchemaDefinitions().getSchemaRegistry()); final BeaconBlockBodySchemaPhase0 specB = BeaconBlockBodySchemaPhase0.create( specConfig, - specConfig.getMaxValidatorsPerCommittee(), "BeaconBlockBodyPhase0", spec.getGenesisSchemaDefinitions().getSchemaRegistry());