From 6ca679fb362b4e2aa21349c1abf9147539775d84 Mon Sep 17 00:00:00 2001 From: Enrico Del Fante Date: Thu, 21 Nov 2024 11:37:10 +0100 Subject: [PATCH] Migrate builder bids to schema registry (#8836) --- .../builder/SignedBuilderBidSchema.java | 9 ++++-- .../bellatrix/BuilderBidSchemaBellatrix.java | 11 ++++--- .../versions/deneb/BuilderBidSchemaDeneb.java | 17 +++++----- .../electra/BuilderBidSchemaElectra.java | 22 ++++++------- .../schemas/SchemaDefinitionsBellatrix.java | 9 +++--- .../schemas/SchemaDefinitionsCapella.java | 20 ------------ .../spec/schemas/SchemaDefinitionsDeneb.java | 21 ------------ .../schemas/SchemaDefinitionsElectra.java | 25 --------------- .../registry/SchemaRegistryBuilder.java | 32 +++++++++++++++++++ .../spec/schemas/registry/SchemaTypes.java | 8 +++++ 10 files changed, 77 insertions(+), 97 deletions(-) diff --git a/ethereum/spec/src/main/java/tech/pegasys/teku/spec/datastructures/builder/SignedBuilderBidSchema.java b/ethereum/spec/src/main/java/tech/pegasys/teku/spec/datastructures/builder/SignedBuilderBidSchema.java index ac17c5b6054..c5f51f6dfad 100644 --- a/ethereum/spec/src/main/java/tech/pegasys/teku/spec/datastructures/builder/SignedBuilderBidSchema.java +++ b/ethereum/spec/src/main/java/tech/pegasys/teku/spec/datastructures/builder/SignedBuilderBidSchema.java @@ -13,6 +13,8 @@ package tech.pegasys.teku.spec.datastructures.builder; +import static tech.pegasys.teku.spec.schemas.registry.SchemaTypes.BUILDER_BID_SCHEMA; + import tech.pegasys.teku.bls.BLSSignature; import tech.pegasys.teku.infrastructure.ssz.containers.ContainerSchema2; import tech.pegasys.teku.infrastructure.ssz.schema.SszContainerSchema; @@ -20,16 +22,17 @@ import tech.pegasys.teku.infrastructure.ssz.tree.TreeNode; import tech.pegasys.teku.spec.datastructures.type.SszSignature; import tech.pegasys.teku.spec.datastructures.type.SszSignatureSchema; +import tech.pegasys.teku.spec.schemas.registry.SchemaRegistry; public class SignedBuilderBidSchema extends ContainerSchema2 implements SszContainerSchema { - public SignedBuilderBidSchema( - final String schemaName, final BuilderBidSchema builderBidSchema) { + public SignedBuilderBidSchema(final String schemaName, final SchemaRegistry schemaRegistry) { super( schemaName, - namedSchema("message", SszSchema.as(BuilderBid.class, builderBidSchema)), + namedSchema( + "message", SszSchema.as(BuilderBid.class, schemaRegistry.get(BUILDER_BID_SCHEMA))), namedSchema("signature", SszSignatureSchema.INSTANCE)); } diff --git a/ethereum/spec/src/main/java/tech/pegasys/teku/spec/datastructures/builder/versions/bellatrix/BuilderBidSchemaBellatrix.java b/ethereum/spec/src/main/java/tech/pegasys/teku/spec/datastructures/builder/versions/bellatrix/BuilderBidSchemaBellatrix.java index 69047fb5ebd..332809233b2 100644 --- a/ethereum/spec/src/main/java/tech/pegasys/teku/spec/datastructures/builder/versions/bellatrix/BuilderBidSchemaBellatrix.java +++ b/ethereum/spec/src/main/java/tech/pegasys/teku/spec/datastructures/builder/versions/bellatrix/BuilderBidSchemaBellatrix.java @@ -13,6 +13,8 @@ package tech.pegasys.teku.spec.datastructures.builder.versions.bellatrix; +import static tech.pegasys.teku.spec.schemas.registry.SchemaTypes.EXECUTION_PAYLOAD_HEADER_SCHEMA; + import java.util.function.Consumer; import tech.pegasys.teku.infrastructure.ssz.containers.ContainerSchema3; import tech.pegasys.teku.infrastructure.ssz.primitive.SszUInt256; @@ -23,21 +25,22 @@ import tech.pegasys.teku.spec.datastructures.builder.BuilderBidBuilder; import tech.pegasys.teku.spec.datastructures.builder.BuilderBidSchema; import tech.pegasys.teku.spec.datastructures.execution.ExecutionPayloadHeader; -import tech.pegasys.teku.spec.datastructures.execution.ExecutionPayloadHeaderSchema; import tech.pegasys.teku.spec.datastructures.type.SszPublicKey; import tech.pegasys.teku.spec.datastructures.type.SszPublicKeySchema; +import tech.pegasys.teku.spec.schemas.registry.SchemaRegistry; public class BuilderBidSchemaBellatrix extends ContainerSchema3 implements BuilderBidSchema { public BuilderBidSchemaBellatrix( - final String containerName, - final ExecutionPayloadHeaderSchema executionPayloadHeaderSchema) { + final String containerName, final SchemaRegistry schemaRegistry) { super( containerName, namedSchema( - "header", SszSchema.as(ExecutionPayloadHeader.class, executionPayloadHeaderSchema)), + "header", + SszSchema.as( + ExecutionPayloadHeader.class, schemaRegistry.get(EXECUTION_PAYLOAD_HEADER_SCHEMA))), namedSchema("value", SszPrimitiveSchemas.UINT256_SCHEMA), namedSchema("pubkey", SszPublicKeySchema.INSTANCE)); } diff --git a/ethereum/spec/src/main/java/tech/pegasys/teku/spec/datastructures/builder/versions/deneb/BuilderBidSchemaDeneb.java b/ethereum/spec/src/main/java/tech/pegasys/teku/spec/datastructures/builder/versions/deneb/BuilderBidSchemaDeneb.java index 1b4f9c7749e..5d0ec060a0d 100644 --- a/ethereum/spec/src/main/java/tech/pegasys/teku/spec/datastructures/builder/versions/deneb/BuilderBidSchemaDeneb.java +++ b/ethereum/spec/src/main/java/tech/pegasys/teku/spec/datastructures/builder/versions/deneb/BuilderBidSchemaDeneb.java @@ -13,6 +13,9 @@ package tech.pegasys.teku.spec.datastructures.builder.versions.deneb; +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 java.util.function.Consumer; import tech.pegasys.teku.infrastructure.ssz.SszList; import tech.pegasys.teku.infrastructure.ssz.containers.ContainerSchema4; @@ -20,15 +23,14 @@ import tech.pegasys.teku.infrastructure.ssz.schema.SszPrimitiveSchemas; import tech.pegasys.teku.infrastructure.ssz.schema.SszSchema; import tech.pegasys.teku.infrastructure.ssz.tree.TreeNode; -import tech.pegasys.teku.spec.datastructures.blobs.versions.deneb.BlobKzgCommitmentsSchema; import tech.pegasys.teku.spec.datastructures.builder.BuilderBid; import tech.pegasys.teku.spec.datastructures.builder.BuilderBidBuilder; import tech.pegasys.teku.spec.datastructures.builder.BuilderBidSchema; import tech.pegasys.teku.spec.datastructures.execution.ExecutionPayloadHeader; -import tech.pegasys.teku.spec.datastructures.execution.ExecutionPayloadHeaderSchema; import tech.pegasys.teku.spec.datastructures.type.SszKZGCommitment; import tech.pegasys.teku.spec.datastructures.type.SszPublicKey; import tech.pegasys.teku.spec.datastructures.type.SszPublicKeySchema; +import tech.pegasys.teku.spec.schemas.registry.SchemaRegistry; public class BuilderBidSchemaDeneb extends ContainerSchema4< @@ -39,15 +41,14 @@ public class BuilderBidSchemaDeneb SszPublicKey> implements BuilderBidSchema { - public BuilderBidSchemaDeneb( - final String containerName, - final ExecutionPayloadHeaderSchema executionPayloadHeaderSchema, - final BlobKzgCommitmentsSchema blobKzgCommitmentsSchema) { + public BuilderBidSchemaDeneb(final String containerName, final SchemaRegistry schemaRegistry) { super( containerName, namedSchema( - "header", SszSchema.as(ExecutionPayloadHeader.class, executionPayloadHeaderSchema)), - namedSchema("blob_kzg_commitments", blobKzgCommitmentsSchema), + "header", + SszSchema.as( + ExecutionPayloadHeader.class, schemaRegistry.get(EXECUTION_PAYLOAD_HEADER_SCHEMA))), + namedSchema("blob_kzg_commitments", schemaRegistry.get(BLOB_KZG_COMMITMENTS_SCHEMA)), namedSchema("value", SszPrimitiveSchemas.UINT256_SCHEMA), namedSchema("pubkey", SszPublicKeySchema.INSTANCE)); } diff --git a/ethereum/spec/src/main/java/tech/pegasys/teku/spec/datastructures/builder/versions/electra/BuilderBidSchemaElectra.java b/ethereum/spec/src/main/java/tech/pegasys/teku/spec/datastructures/builder/versions/electra/BuilderBidSchemaElectra.java index 9e5d3252f45..0db152239a1 100644 --- a/ethereum/spec/src/main/java/tech/pegasys/teku/spec/datastructures/builder/versions/electra/BuilderBidSchemaElectra.java +++ b/ethereum/spec/src/main/java/tech/pegasys/teku/spec/datastructures/builder/versions/electra/BuilderBidSchemaElectra.java @@ -13,6 +13,10 @@ package tech.pegasys.teku.spec.datastructures.builder.versions.electra; +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 java.util.function.Consumer; import tech.pegasys.teku.infrastructure.ssz.SszList; import tech.pegasys.teku.infrastructure.ssz.containers.ContainerSchema5; @@ -20,17 +24,15 @@ import tech.pegasys.teku.infrastructure.ssz.schema.SszPrimitiveSchemas; import tech.pegasys.teku.infrastructure.ssz.schema.SszSchema; import tech.pegasys.teku.infrastructure.ssz.tree.TreeNode; -import tech.pegasys.teku.spec.datastructures.blobs.versions.deneb.BlobKzgCommitmentsSchema; import tech.pegasys.teku.spec.datastructures.builder.BuilderBid; import tech.pegasys.teku.spec.datastructures.builder.BuilderBidBuilder; import tech.pegasys.teku.spec.datastructures.builder.BuilderBidSchema; import tech.pegasys.teku.spec.datastructures.execution.ExecutionPayloadHeader; -import tech.pegasys.teku.spec.datastructures.execution.ExecutionPayloadHeaderSchema; import tech.pegasys.teku.spec.datastructures.execution.versions.electra.ExecutionRequests; -import tech.pegasys.teku.spec.datastructures.execution.versions.electra.ExecutionRequestsSchema; import tech.pegasys.teku.spec.datastructures.type.SszKZGCommitment; import tech.pegasys.teku.spec.datastructures.type.SszPublicKey; import tech.pegasys.teku.spec.datastructures.type.SszPublicKeySchema; +import tech.pegasys.teku.spec.schemas.registry.SchemaRegistry; public class BuilderBidSchemaElectra extends ContainerSchema5< @@ -42,17 +44,15 @@ public class BuilderBidSchemaElectra SszPublicKey> implements BuilderBidSchema { - public BuilderBidSchemaElectra( - final String containerName, - final ExecutionPayloadHeaderSchema executionPayloadHeaderSchema, - final BlobKzgCommitmentsSchema blobKzgCommitmentsSchema, - final ExecutionRequestsSchema executionRequestsSchema) { + public BuilderBidSchemaElectra(final String containerName, final SchemaRegistry schemaRegistry) { super( containerName, namedSchema( - "header", SszSchema.as(ExecutionPayloadHeader.class, executionPayloadHeaderSchema)), - namedSchema("blob_kzg_commitments", blobKzgCommitmentsSchema), - namedSchema("execution_requests", executionRequestsSchema), + "header", + SszSchema.as( + ExecutionPayloadHeader.class, schemaRegistry.get(EXECUTION_PAYLOAD_HEADER_SCHEMA))), + namedSchema("blob_kzg_commitments", schemaRegistry.get(BLOB_KZG_COMMITMENTS_SCHEMA)), + namedSchema("execution_requests", schemaRegistry.get(EXECUTION_REQUESTS_SCHEMA)), namedSchema("value", SszPrimitiveSchemas.UINT256_SCHEMA), namedSchema("pubkey", SszPublicKeySchema.INSTANCE)); } 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 5cd24784011..65aedde7523 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 @@ -16,9 +16,11 @@ 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.BUILDER_BID_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 static tech.pegasys.teku.spec.schemas.registry.SchemaTypes.SIGNED_BUILDER_BID_SCHEMA; import java.util.Optional; import tech.pegasys.teku.spec.datastructures.blocks.BeaconBlockSchema; @@ -34,7 +36,6 @@ import tech.pegasys.teku.spec.datastructures.builder.BuilderBidSchema; import tech.pegasys.teku.spec.datastructures.builder.BuilderPayloadSchema; 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.schemas.registry.SchemaRegistry; @@ -55,10 +56,8 @@ public SchemaDefinitionsBellatrix(final SchemaRegistry schemaRegistry) { this.blindedBeaconBlockBodySchema = schemaRegistry.get(BLINDED_BEACON_BLOCK_BODY_SCHEMA); 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 = - new SignedBuilderBidSchema("SignedBuilderBidBellatrix", builderBidSchema); + this.builderBidSchema = schemaRegistry.get(BUILDER_BID_SCHEMA); + this.signedBuilderBidSchema = schemaRegistry.get(SIGNED_BUILDER_BID_SCHEMA); } public static SchemaDefinitionsBellatrix required(final SchemaDefinitions schemaDefinitions) { 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 ecba91d36fd..89464135c32 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 @@ -23,9 +23,6 @@ import tech.pegasys.teku.infrastructure.ssz.schema.SszListSchema; import tech.pegasys.teku.spec.datastructures.blocks.blockbody.BeaconBlockBodyBuilder; import tech.pegasys.teku.spec.datastructures.blocks.blockbody.versions.capella.BeaconBlockBodyBuilderCapella; -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.versions.capella.WithdrawalSchema; import tech.pegasys.teku.spec.datastructures.operations.BlsToExecutionChangeSchema; import tech.pegasys.teku.spec.datastructures.operations.SignedBlsToExecutionChangeSchema; @@ -37,10 +34,7 @@ public class SchemaDefinitionsCapella extends SchemaDefinitionsBellatrix { private final WithdrawalSchema withdrawalSchema; private final BlsToExecutionChangeSchema blsToExecutionChangeSchema; - private final SignedBlsToExecutionChangeSchema signedBlsToExecutionChangeSchema; - private final BuilderBidSchema builderBidSchemaCapella; - private final SignedBuilderBidSchema signedBuilderBidSchemaCapella; private final SszListSchema historicalSummariesSchema; @@ -51,10 +45,6 @@ public SchemaDefinitionsCapella(final SchemaRegistry schemaRegistry) { this.signedBlsToExecutionChangeSchema = schemaRegistry.get(SIGNED_BLS_TO_EXECUTION_CHANGE_SCHEMA); this.withdrawalSchema = schemaRegistry.get(WITHDRAWAL_SCHEMA); - this.builderBidSchemaCapella = - new BuilderBidSchemaBellatrix("BuilderBidCapella", getExecutionPayloadHeaderSchema()); - this.signedBuilderBidSchemaCapella = - new SignedBuilderBidSchema("SignedBuilderBidCapella", builderBidSchemaCapella); } public static SchemaDefinitionsCapella required(final SchemaDefinitions schemaDefinitions) { @@ -89,16 +79,6 @@ public HistoricalSummarySchema getHistoricalSummarySchema() { return (HistoricalSummarySchema) historicalSummariesSchema.getElementSchema(); } - @Override - public BuilderBidSchema getBuilderBidSchema() { - return builderBidSchemaCapella; - } - - @Override - public SignedBuilderBidSchema getSignedBuilderBidSchema() { - return signedBuilderBidSchemaCapella; - } - @Override public Optional toVersionCapella() { return Optional.of(this); 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 5cd35c30630..9099819dd25 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 @@ -38,20 +38,14 @@ 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; -import tech.pegasys.teku.spec.datastructures.builder.BuilderBidSchema; import tech.pegasys.teku.spec.datastructures.builder.BuilderPayloadSchema; 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.networking.libp2p.rpc.BlobSidecarsByRootRequestMessageSchema; import tech.pegasys.teku.spec.schemas.registry.SchemaRegistry; public class SchemaDefinitionsDeneb extends SchemaDefinitionsCapella { private final BlobKzgCommitmentsSchema blobKzgCommitmentsSchema; - private final BuilderBidSchema builderBidSchemaDeneb; - private final SignedBuilderBidSchema signedBuilderBidSchemaDeneb; - private final BlobSchema blobSchema; private final SszListSchema> blobsInBlockSchema; private final BlobSidecarSchema blobSidecarSchema; @@ -65,11 +59,6 @@ public SchemaDefinitionsDeneb(final SchemaRegistry schemaRegistry) { super(schemaRegistry); final SpecConfigDeneb specConfig = SpecConfigDeneb.required(schemaRegistry.getSpecConfig()); this.blobKzgCommitmentsSchema = schemaRegistry.get(BLOB_KZG_COMMITMENTS_SCHEMA); - this.builderBidSchemaDeneb = - new BuilderBidSchemaDeneb( - "BuilderBidDeneb", getExecutionPayloadHeaderSchema(), blobKzgCommitmentsSchema); - this.signedBuilderBidSchemaDeneb = - new SignedBuilderBidSchema("SignedBuilderBidDeneb", builderBidSchemaDeneb); this.blobSchema = schemaRegistry.get(BLOB_SCHEMA); this.blobsInBlockSchema = schemaRegistry.get(BLOBS_IN_BLOCK_SCHEMA); @@ -106,16 +95,6 @@ public SignedBlockContainerSchema getSignedBlockContainerS return getSignedBlockContentsSchema().castTypeToSignedBlockContainer(); } - @Override - public BuilderBidSchema getBuilderBidSchema() { - return builderBidSchemaDeneb; - } - - @Override - public SignedBuilderBidSchema getSignedBuilderBidSchema() { - return signedBuilderBidSchemaDeneb; - } - @Override public BuilderPayloadSchema getBuilderPayloadSchema() { return getExecutionPayloadAndBlobsBundleSchema(); 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 0d0f4b4204f..cbf50701f83 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 @@ -32,11 +32,8 @@ import tech.pegasys.teku.spec.datastructures.blocks.blockbody.versions.electra.BeaconBlockBodyBuilderElectra; 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; import tech.pegasys.teku.spec.datastructures.builder.BuilderPayloadSchema; import tech.pegasys.teku.spec.datastructures.builder.ExecutionPayloadAndBlobsBundleSchema; -import tech.pegasys.teku.spec.datastructures.builder.SignedBuilderBidSchema; -import tech.pegasys.teku.spec.datastructures.builder.versions.electra.BuilderBidSchemaElectra; import tech.pegasys.teku.spec.datastructures.execution.versions.electra.ConsolidationRequest; import tech.pegasys.teku.spec.datastructures.execution.versions.electra.ConsolidationRequestSchema; import tech.pegasys.teku.spec.datastructures.execution.versions.electra.DepositRequest; @@ -50,9 +47,6 @@ import tech.pegasys.teku.spec.schemas.registry.SchemaRegistry; public class SchemaDefinitionsElectra extends SchemaDefinitionsDeneb { - private final BuilderBidSchema builderBidSchemaElectra; - private final SignedBuilderBidSchema signedBuilderBidSchemaElectra; - private final BlockContentsSchema blockContentsSchema; private final SignedBlockContentsSchema signedBlockContentsSchema; private final ExecutionPayloadAndBlobsBundleSchema executionPayloadAndBlobsBundleSchema; @@ -80,15 +74,6 @@ public SchemaDefinitionsElectra(final SchemaRegistry schemaRegistry) { this.pendingPartialWithdrawalsSchema = schemaRegistry.get(PENDING_PARTIAL_WITHDRAWALS_SCHEMA); this.pendingConsolidationsSchema = schemaRegistry.get(PENDING_CONSOLIDATIONS_SCHEMA); - this.builderBidSchemaElectra = - new BuilderBidSchemaElectra( - "BuilderBidElectra", - getExecutionPayloadHeaderSchema(), - getBlobKzgCommitmentsSchema(), - executionRequestsSchema); - this.signedBuilderBidSchemaElectra = - new SignedBuilderBidSchema("SignedBuilderBidElectra", builderBidSchemaElectra); - this.blockContentsSchema = BlockContentsSchema.create( specConfig, getBeaconBlockSchema(), getBlobSchema(), "BlockContentsElectra"); @@ -130,16 +115,6 @@ public SignedBlockContainerSchema getSignedBlockContainerS return getSignedBlockContentsSchema().castTypeToSignedBlockContainer(); } - @Override - public BuilderBidSchema getBuilderBidSchema() { - return builderBidSchemaElectra; - } - - @Override - public SignedBuilderBidSchema getSignedBuilderBidSchema() { - return signedBuilderBidSchemaElectra; - } - @Override public BuilderPayloadSchema getBuilderPayloadSchema() { return getExecutionPayloadAndBlobsBundleSchema(); 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 2dbcbce7fc9..e2f1c03ffb6 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 @@ -38,6 +38,7 @@ import static tech.pegasys.teku.spec.schemas.registry.SchemaTypes.BLOB_SIDECARS_BY_ROOT_REQUEST_MESSAGE_SCHEMA; import static tech.pegasys.teku.spec.schemas.registry.SchemaTypes.BLOB_SIDECAR_SCHEMA; import static tech.pegasys.teku.spec.schemas.registry.SchemaTypes.BLS_TO_EXECUTION_CHANGE_SCHEMA; +import static tech.pegasys.teku.spec.schemas.registry.SchemaTypes.BUILDER_BID_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.EXECUTION_REQUESTS_SCHEMA; @@ -51,6 +52,7 @@ 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.SIGNED_BUILDER_BID_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; @@ -83,6 +85,10 @@ 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.builder.SignedBuilderBidSchema; +import tech.pegasys.teku.spec.datastructures.builder.versions.bellatrix.BuilderBidSchemaBellatrix; +import tech.pegasys.teku.spec.datastructures.builder.versions.deneb.BuilderBidSchemaDeneb; +import tech.pegasys.teku.spec.datastructures.builder.versions.electra.BuilderBidSchemaElectra; import tech.pegasys.teku.spec.datastructures.execution.versions.bellatrix.ExecutionPayloadHeaderSchemaBellatrix; import tech.pegasys.teku.spec.datastructures.execution.versions.bellatrix.ExecutionPayloadSchemaBellatrix; import tech.pegasys.teku.spec.datastructures.execution.versions.capella.ExecutionPayloadHeaderSchemaCapella; @@ -143,6 +149,8 @@ public static SchemaRegistryBuilder create() { .addProvider(createBlindedBeaconBlockBodySchemaProvider()) .addProvider(createBlindedBeaconBlockSchemaProvider()) .addProvider(createSignedBlindedBeaconBlockSchemaProvider()) + .addProvider(createBuilderBidSchemaProvider()) + .addProvider(createSignedBuilderBidSchemaProvider()) // CAPELLA .addProvider(createWithdrawalSchemaProvider()) @@ -165,6 +173,30 @@ public static SchemaRegistryBuilder create() { .addProvider(createExecutionRequestsSchemaProvider()); } + private static SchemaProvider createSignedBuilderBidSchemaProvider() { + return providerBuilder(SIGNED_BUILDER_BID_SCHEMA) + .withCreator( + BELLATRIX, + (registry, specConfig, schemaName) -> new SignedBuilderBidSchema(schemaName, registry)) + .build(); + } + + private static SchemaProvider createBuilderBidSchemaProvider() { + return providerBuilder(BUILDER_BID_SCHEMA) + .withCreator( + BELLATRIX, + (registry, specConfig, schemaName) -> + new BuilderBidSchemaBellatrix(schemaName, registry)) + // CAPELLA is same as BELLATRIX + .withCreator( + DENEB, + (registry, specConfig, schemaName) -> new BuilderBidSchemaDeneb(schemaName, registry)) + .withCreator( + ELECTRA, + (registry, specConfig, schemaName) -> new BuilderBidSchemaElectra(schemaName, registry)) + .build(); + } + private static SchemaProvider createPendingDepositsSchemaProvider() { return providerBuilder(PENDING_DEPOSITS_SCHEMA) .withCreator( diff --git a/ethereum/spec/src/main/java/tech/pegasys/teku/spec/schemas/registry/SchemaTypes.java b/ethereum/spec/src/main/java/tech/pegasys/teku/spec/schemas/registry/SchemaTypes.java index 000b338fe82..236fd66f8b1 100644 --- a/ethereum/spec/src/main/java/tech/pegasys/teku/spec/schemas/registry/SchemaTypes.java +++ b/ethereum/spec/src/main/java/tech/pegasys/teku/spec/schemas/registry/SchemaTypes.java @@ -36,6 +36,9 @@ 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; +import tech.pegasys.teku.spec.datastructures.builder.BuilderBid; +import tech.pegasys.teku.spec.datastructures.builder.BuilderBidSchema; +import tech.pegasys.teku.spec.datastructures.builder.SignedBuilderBidSchema; import tech.pegasys.teku.spec.datastructures.execution.ExecutionPayload; import tech.pegasys.teku.spec.datastructures.execution.ExecutionPayloadHeader; import tech.pegasys.teku.spec.datastructures.execution.ExecutionPayloadHeaderSchema; @@ -112,6 +115,11 @@ public class SchemaTypes { public static final SchemaId SIGNED_BLINDED_BEACON_BLOCK_SCHEMA = create("SIGNED_BLINDED_BEACON_BLOCK_SCHEMA"); + public static final SchemaId> BUILDER_BID_SCHEMA = + create("BUILDER_BID_SCHEMA"); + public static final SchemaId SIGNED_BUILDER_BID_SCHEMA = + create("SIGNED_BUILDER_BID_SCHEMA"); + // Capella public static final SchemaId WITHDRAWAL_SCHEMA = create("WITHDRAWAL_SCHEMA"); public static final SchemaId BLS_TO_EXECUTION_CHANGE_SCHEMA =